/* Make droid/structure look for a better target */ static BOOL updateAttackTarget(BASE_OBJECT * psAttacker, SDWORD weapon_slot) { BASE_OBJECT *psBetterTarget=NULL; UWORD tmpOrigin = ORIGIN_UNKNOWN; if(aiChooseTarget(psAttacker, &psBetterTarget, weapon_slot, true, &tmpOrigin)) //update target { if(psAttacker->type == OBJ_DROID) { DROID *psDroid = (DROID *)psAttacker; if( (orderState(psDroid, DORDER_NONE) || orderState(psDroid, DORDER_GUARD) || orderState(psDroid, DORDER_ATTACKTARGET)) && weapon_slot == 0) //Watermelon:only primary slot(0) updates affect order { orderDroidObj((DROID *)psAttacker, DORDER_ATTACKTARGET, psBetterTarget); } else //can't override current order { setDroidActionTarget(psDroid, psBetterTarget, weapon_slot); } } else if (psAttacker->type == OBJ_STRUCTURE) { STRUCTURE *psBuilding = (STRUCTURE *)psAttacker; setStructureTarget(psBuilding, psBetterTarget, weapon_slot, tmpOrigin); } return true; } return false; }
/* Make droid/structure look for a better target */ static bool updateAttackTarget(BASE_OBJECT *psAttacker, SDWORD weapon_slot) { BASE_OBJECT *psBetterTarget = NULL; TARGET_ORIGIN tmpOrigin = ORIGIN_UNKNOWN; if (aiChooseTarget(psAttacker, &psBetterTarget, weapon_slot, true, &tmpOrigin)) //update target { if (psAttacker->type == OBJ_DROID) { DROID *psDroid = (DROID *)psAttacker; if ((orderState(psDroid, DORDER_NONE) || orderState(psDroid, DORDER_GUARD) || orderState(psDroid, DORDER_ATTACKTARGET)) && weapon_slot == 0) { actionDroid((DROID *)psAttacker, DACTION_ATTACK, psBetterTarget); } else //can't override current order { setDroidActionTarget(psDroid, psBetterTarget, weapon_slot); } } else if (psAttacker->type == OBJ_STRUCTURE) { STRUCTURE *psBuilding = (STRUCTURE *)psAttacker; setStructureTarget(psBuilding, psBetterTarget, weapon_slot, tmpOrigin); } return true; } return false; }