Make waiting-at-HQ units go to newly-built repair facilities or rearming pads.
Fixes ticket:3105.master
parent
20398a50e8
commit
e67fde4eec
|
@ -274,7 +274,6 @@ void orderUpdateDroid(DROID *psDroid)
|
|||
{
|
||||
BASE_OBJECT *psObj;
|
||||
STRUCTURE *psStruct, *psWall;
|
||||
REPAIR_FACILITY *psRepairFac;
|
||||
SDWORD xdiff,ydiff;
|
||||
bool bAttack;
|
||||
SDWORD xoffset,yoffset;
|
||||
|
@ -889,9 +888,6 @@ void orderUpdateDroid(DROID *psDroid)
|
|||
psStruct = (STRUCTURE *)psDroid->order.psObj;
|
||||
ASSERT( psStruct != NULL,
|
||||
"orderUpdateUnit: invalid structure pointer" );
|
||||
psRepairFac = (REPAIR_FACILITY *) psStruct->pFunctionality;
|
||||
ASSERT( psRepairFac != NULL,
|
||||
"orderUpdateUnit: invalid repair facility pointer" );
|
||||
|
||||
if (objPosDiffSq(psDroid->pos, psDroid->order.psObj->pos) < (TILE_UNITS * 8) * (TILE_UNITS * 8))
|
||||
{
|
||||
|
@ -1717,30 +1713,23 @@ void orderDroidBase(DROID *psDroid, DROID_ORDER_DATA *psOrder)
|
|||
/* give repair order if repair facility found */
|
||||
if (psRepairFac != NULL)
|
||||
{
|
||||
if (psRepairFac->pStructureType->type == REF_REPAIR_FACILITY)
|
||||
/* move to front of structure */
|
||||
psDroid->order = DroidOrder(psOrder->type, psRepairFac);
|
||||
psDroid->order.pos = removeZ(psRepairFac->pos);
|
||||
/* If in multiPlayer, and the Transporter has been sent to be
|
||||
* repaired, need to find a suitable location to drop down. */
|
||||
if (game.type == SKIRMISH && (psDroid->droidType == DROID_TRANSPORTER || psDroid->droidType == DROID_SUPERTRANSPORTER))
|
||||
{
|
||||
/* move to front of structure */
|
||||
psDroid->order = DroidOrder(psOrder->type, psRepairFac);
|
||||
psDroid->order.pos = removeZ(psRepairFac->pos);
|
||||
/* If in multiPlayer, and the Transporter has been sent to be
|
||||
* repaired, need to find a suitable location to drop down. */
|
||||
if (game.type == SKIRMISH && (psDroid->droidType == DROID_TRANSPORTER || psDroid->droidType == DROID_SUPERTRANSPORTER))
|
||||
{
|
||||
Vector2i pos = psDroid->order.pos;
|
||||
Vector2i pos = psDroid->order.pos;
|
||||
|
||||
objTrace(psDroid->id, "Repair transport");
|
||||
actionVTOLLandingPos(psDroid, &pos);
|
||||
actionDroid(psDroid, DACTION_MOVE, pos.x, pos.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
objTrace(psDroid->id, "Go to repair facility at (%d, %d) using (%d, %d)!", psRepairFac->pos.x, psRepairFac->pos.y, psDroid->order.pos.x, psDroid->order.pos.y);
|
||||
actionDroid(psDroid, DACTION_MOVE, psRepairFac, psDroid->order.pos.x, psDroid->order.pos.y);
|
||||
}
|
||||
objTrace(psDroid->id, "Repair transport");
|
||||
actionVTOLLandingPos(psDroid, &pos);
|
||||
actionDroid(psDroid, DACTION_MOVE, pos.x, pos.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
orderDroid(psDroid, DORDER_RTB, ModeImmediate);
|
||||
objTrace(psDroid->id, "Go to repair facility at (%d, %d) using (%d, %d)!", psRepairFac->pos.x, psRepairFac->pos.y, psDroid->order.pos.x, psDroid->order.pos.y);
|
||||
actionDroid(psDroid, DACTION_MOVE, psRepairFac, psDroid->order.pos.x, psDroid->order.pos.y);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -2859,9 +2859,13 @@ static void aiUpdateStructure(STRUCTURE *psStructure, bool isMission)
|
|||
else if (psTarget && mindist > (TILE_UNITS*8)*(TILE_UNITS*8)
|
||||
&& psTarget != psStructure && psDroid->action == DACTION_WAITFORREPAIR)
|
||||
{
|
||||
REPAIR_FACILITY *stealFrom = &((STRUCTURE *)psTarget)->pFunctionality->repairFacility;
|
||||
// make a wild guess about what is a good distance
|
||||
int distLimit = world_coord(stealFrom->droidQueue) * world_coord(stealFrom->droidQueue) * 10;
|
||||
int distLimit = mindist;
|
||||
if (psTarget->type == OBJ_STRUCTURE && ((STRUCTURE *)psTarget)->pStructureType->type == REF_REPAIR_FACILITY) // Is a repair facility (not the HQ).
|
||||
{
|
||||
REPAIR_FACILITY *stealFrom = &((STRUCTURE *)psTarget)->pFunctionality->repairFacility;
|
||||
// make a wild guess about what is a good distance
|
||||
distLimit = world_coord(stealFrom->droidQueue) * world_coord(stealFrom->droidQueue) * 10;
|
||||
}
|
||||
|
||||
xdiff = (SDWORD)psDroid->pos.x - (SDWORD)psStructure->pos.x;
|
||||
ydiff = (SDWORD)psDroid->pos.y - (SDWORD)psStructure->pos.y;
|
||||
|
@ -6763,8 +6767,13 @@ STRUCTURE * findNearestReArmPad(DROID *psDroid, STRUCTURE *psTarget, bool bClear
|
|||
totallyDist = SDWORD_MAX;
|
||||
psNearest = NULL;
|
||||
psTotallyClear = NULL;
|
||||
STRUCTURE *hq = nullptr;
|
||||
for(psStruct = apsStructLists[psDroid->player]; psStruct; psStruct=psStruct->psNext)
|
||||
{
|
||||
if (psStruct->pStructureType->type == REF_HQ)
|
||||
{
|
||||
hq = psStruct;
|
||||
}
|
||||
if ((psStruct->pStructureType->type == REF_REARM_PAD) &&
|
||||
(psTarget == NULL || psTarget->cluster == psStruct->cluster) &&
|
||||
(!bClear || clearRearmPad(psStruct)))
|
||||
|
@ -6795,6 +6804,7 @@ STRUCTURE * findNearestReArmPad(DROID *psDroid, STRUCTURE *psTarget, bool bClear
|
|||
{
|
||||
psNearest = psTotallyClear;
|
||||
}
|
||||
psNearest = psNearest != nullptr? psNearest : hq;
|
||||
|
||||
return psNearest;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue