Simplify orders a bit.
Droid orders are now contained in a DroidOrder structure, instead of order, orderX, orderY, orderX2, orderY2, orderDirection, psTarget, psTarStats members of DROID.master
parent
1ec0d635d0
commit
8dc9d09904
|
@ -235,6 +235,13 @@ static void queue(const Q &q, Rotation &v)
|
||||||
queue(q, v.roll);
|
queue(q, v.roll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class Q>
|
||||||
|
static void queue(const Q &q, Vector2i &v)
|
||||||
|
{
|
||||||
|
queue(q, v.x);
|
||||||
|
queue(q, v.y);
|
||||||
|
}
|
||||||
|
|
||||||
template<class Q, class T>
|
template<class Q, class T>
|
||||||
static void queue(const Q &q, std::vector<T> &v)
|
static void queue(const Q &q, std::vector<T> &v)
|
||||||
{
|
{
|
||||||
|
@ -648,6 +655,11 @@ void NETRotation(Rotation *vp)
|
||||||
queueAuto(*vp);
|
queueAuto(*vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NETVector2i(Vector2i *vp)
|
||||||
|
{
|
||||||
|
queueAuto(*vp);
|
||||||
|
}
|
||||||
|
|
||||||
void NETnetMessage(NetMessage const **message)
|
void NETnetMessage(NetMessage const **message)
|
||||||
{
|
{
|
||||||
if (NETgetPacketDir() == PACKET_ENCODE)
|
if (NETgetPacketDir() == PACKET_ENCODE)
|
||||||
|
|
|
@ -104,6 +104,7 @@ static void NETenum(EnumT* enumPtr)
|
||||||
|
|
||||||
void NETPosition(Position *vp);
|
void NETPosition(Position *vp);
|
||||||
void NETRotation(Rotation *vp);
|
void NETRotation(Rotation *vp);
|
||||||
|
void NETVector2i(Vector2i *vp);
|
||||||
|
|
||||||
static inline void NETauto(int8_t *ip) { NETint8_t(ip); }
|
static inline void NETauto(int8_t *ip) { NETint8_t(ip); }
|
||||||
static inline void NETauto(uint8_t *ip) { NETuint8_t(ip); }
|
static inline void NETauto(uint8_t *ip) { NETuint8_t(ip); }
|
||||||
|
@ -116,6 +117,7 @@ static inline void NETauto(uint64_t *ip) { NETuint64_t(ip); }
|
||||||
static inline void NETauto(bool *bp) { NETbool(bp); }
|
static inline void NETauto(bool *bp) { NETbool(bp); }
|
||||||
static inline void NETauto(Position *vp) { NETPosition(vp); }
|
static inline void NETauto(Position *vp) { NETPosition(vp); }
|
||||||
static inline void NETauto(Rotation *vp) { NETRotation(vp); }
|
static inline void NETauto(Rotation *vp) { NETRotation(vp); }
|
||||||
|
static inline void NETauto(Vector2i *vp) { NETVector2i(vp); }
|
||||||
|
|
||||||
|
|
||||||
void NETnetMessage(NetMessage const **message); ///< If decoding, must delete the NETMESSAGE.
|
void NETnetMessage(NetMessage const **message); ///< If decoding, must delete the NETMESSAGE.
|
||||||
|
|
182
src/action.cpp
182
src/action.cpp
|
@ -177,7 +177,7 @@ static bool actionInAttackRange(DROID *psDroid, BASE_OBJECT *psObj, int weapon_s
|
||||||
ASSERT_OR_RETURN( false, compIndex < numWeaponStats, "Invalid range referenced for numWeaponStats, %d > %d", compIndex, numWeaponStats);
|
ASSERT_OR_RETURN( false, compIndex < numWeaponStats, "Invalid range referenced for numWeaponStats, %d > %d", compIndex, numWeaponStats);
|
||||||
psStats = asWeaponStats + compIndex;
|
psStats = asWeaponStats + compIndex;
|
||||||
|
|
||||||
if (psDroid->order == DORDER_ATTACKTARGET
|
if (psDroid->order.type == DORDER_ATTACKTARGET
|
||||||
&& secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_HOLD)
|
&& secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_HOLD)
|
||||||
{
|
{
|
||||||
longRange = proj_GetLongRange(psStats);
|
longRange = proj_GetLongRange(psStats);
|
||||||
|
@ -550,9 +550,9 @@ static void actionAddVtolAttackRun( DROID *psDroid )
|
||||||
{
|
{
|
||||||
psTarget = psDroid->psActionTarget[0];
|
psTarget = psDroid->psActionTarget[0];
|
||||||
}
|
}
|
||||||
else if ( psDroid->psTarget != NULL )
|
else if (psDroid->order.psObj != NULL )
|
||||||
{
|
{
|
||||||
psTarget = psDroid->psTarget;
|
psTarget = psDroid->order.psObj;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -586,7 +586,7 @@ static void actionUpdateVtolAttack( DROID *psDroid )
|
||||||
CHECK_DROID(psDroid);
|
CHECK_DROID(psDroid);
|
||||||
|
|
||||||
/* don't do attack runs whilst returning to base */
|
/* don't do attack runs whilst returning to base */
|
||||||
if ( psDroid->order == DORDER_RTB )
|
if (psDroid->order.type == DORDER_RTB)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -755,7 +755,7 @@ static bool actionRemoveDroidsFromBuildPos(unsigned player, Vector2i pos, uint16
|
||||||
void actionSanity(DROID *psDroid)
|
void actionSanity(DROID *psDroid)
|
||||||
{
|
{
|
||||||
// Don't waste ammo unless given a direct attack order.
|
// Don't waste ammo unless given a direct attack order.
|
||||||
bool avoidOverkill = psDroid->order != DORDER_ATTACK && psDroid->order != DORDER_ATTACK &&
|
bool avoidOverkill = psDroid->order.type != DORDER_ATTACK && psDroid->order.type != DORDER_ATTACK &&
|
||||||
(psDroid->action == DACTION_ATTACK || psDroid->action == DACTION_MOVEFIRE || psDroid->action == DACTION_MOVETOATTACK ||
|
(psDroid->action == DACTION_ATTACK || psDroid->action == DACTION_MOVEFIRE || psDroid->action == DACTION_MOVETOATTACK ||
|
||||||
psDroid->action == DACTION_ROTATETOATTACK || psDroid->action == DACTION_VTOLATTACK);
|
psDroid->action == DACTION_ROTATETOATTACK || psDroid->action == DACTION_VTOLATTACK);
|
||||||
|
|
||||||
|
@ -775,10 +775,10 @@ void actionSanity(DROID *psDroid)
|
||||||
// if VTOL - return to rearm pad if not patrolling
|
// if VTOL - return to rearm pad if not patrolling
|
||||||
if (isVtolDroid(psDroid))
|
if (isVtolDroid(psDroid))
|
||||||
{
|
{
|
||||||
if ((psDroid->order == DORDER_PATROL || psDroid->order == DORDER_CIRCLE) && !vtolEmpty(psDroid))
|
if ((psDroid->order.type == DORDER_PATROL || psDroid->order.type == DORDER_CIRCLE) && !vtolEmpty(psDroid))
|
||||||
{
|
{
|
||||||
// Back to the patrol.
|
// Back to the patrol.
|
||||||
actionDroid(psDroid, DACTION_MOVE, psDroid->orderX, psDroid->orderY);
|
actionDroid(psDroid, DACTION_MOVE, psDroid->order.pos.x, psDroid->order.pos.y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -843,7 +843,8 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
if (psDroid->numWeaps <= 1)
|
if (psDroid->numWeaps <= 1)
|
||||||
nonNullWeapon[0] = true;
|
nonNullWeapon[0] = true;
|
||||||
|
|
||||||
psTarget = psDroid->psTarget;
|
DROID_ORDER_DATA *order = &psDroid->order;
|
||||||
|
psTarget = order->psObj;
|
||||||
|
|
||||||
switch (psDroid->action)
|
switch (psDroid->action)
|
||||||
{
|
{
|
||||||
|
@ -852,7 +853,7 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
// doing nothing
|
// doing nothing
|
||||||
// see if there's anything to shoot.
|
// see if there's anything to shoot.
|
||||||
if (psDroid->numWeaps > 0 && !isVtolDroid(psDroid)
|
if (psDroid->numWeaps > 0 && !isVtolDroid(psDroid)
|
||||||
&& (psDroid->order == DORDER_NONE || psDroid->order == DORDER_TEMP_HOLD || psDroid->order == DORDER_RTR))
|
&& (order->type == DORDER_NONE || order->type == DORDER_TEMP_HOLD || order->type == DORDER_RTR))
|
||||||
{
|
{
|
||||||
for (i = 0;i < psDroid->numWeaps;i++)
|
for (i = 0;i < psDroid->numWeaps;i++)
|
||||||
{
|
{
|
||||||
|
@ -883,7 +884,7 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
break;
|
break;
|
||||||
case DACTION_WAITDURINGREPAIR:
|
case DACTION_WAITDURINGREPAIR:
|
||||||
// Check that repair facility still exists
|
// Check that repair facility still exists
|
||||||
if (!psDroid->psTarget)
|
if (!order->psObj)
|
||||||
{
|
{
|
||||||
psDroid->action = DACTION_NONE;
|
psDroid->action = DACTION_NONE;
|
||||||
break;
|
break;
|
||||||
|
@ -891,10 +892,10 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
// move back to the repair facility if necessary
|
// move back to the repair facility if necessary
|
||||||
if (DROID_STOPPED(psDroid) &&
|
if (DROID_STOPPED(psDroid) &&
|
||||||
!actionReachedBuildPos(psDroid,
|
!actionReachedBuildPos(psDroid,
|
||||||
psDroid->psTarget->pos.x, psDroid->psTarget->pos.y, ((STRUCTURE*)psDroid->psTarget)->rot.direction,
|
order->psObj->pos.x, order->psObj->pos.y, ((STRUCTURE*)order->psObj)->rot.direction,
|
||||||
((STRUCTURE*)psDroid->psTarget)->pStructureType ) )
|
((STRUCTURE*)order->psObj)->pStructureType ) )
|
||||||
{
|
{
|
||||||
moveDroidToNoFormation(psDroid, psDroid->psTarget->pos.x, psDroid->psTarget->pos.y);
|
moveDroidToNoFormation(psDroid, order->psObj->pos.x, order->psObj->pos.y);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DACTION_TRANSPORTWAITTOFLYIN:
|
case DACTION_TRANSPORTWAITTOFLYIN:
|
||||||
|
@ -947,7 +948,7 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
/* notify scripts we have reached the destination
|
/* notify scripts we have reached the destination
|
||||||
* also triggers when patrolling and reached a waypoint
|
* also triggers when patrolling and reached a waypoint
|
||||||
*/
|
*/
|
||||||
psScrCBOrder = psDroid->order;
|
psScrCBOrder = order->type;
|
||||||
psScrCBOrderDroid = psDroid;
|
psScrCBOrderDroid = psDroid;
|
||||||
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_DROID_REACH_LOCATION);
|
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_DROID_REACH_LOCATION);
|
||||||
psScrCBOrderDroid = NULL;
|
psScrCBOrderDroid = NULL;
|
||||||
|
@ -1113,7 +1114,7 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
// If we're ordered to shoot something, and we can, shoot it
|
// If we're ordered to shoot something, and we can, shoot it
|
||||||
if ((psDroid->order == DORDER_ATTACK || psDroid->order == DORDER_ATTACKTARGET) &&
|
if ((order->type == DORDER_ATTACK || order->type == DORDER_ATTACKTARGET) &&
|
||||||
psDroid->psActionTarget[i] != psDroid->psActionTarget[0] &&
|
psDroid->psActionTarget[i] != psDroid->psActionTarget[0] &&
|
||||||
validTarget(psDroid, psDroid->psActionTarget[0], i) &&
|
validTarget(psDroid, psDroid->psActionTarget[0], i) &&
|
||||||
actionInRange(psDroid, psDroid->psActionTarget[0], i))
|
actionInRange(psDroid, psDroid->psActionTarget[0], i))
|
||||||
|
@ -1195,14 +1196,14 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
|
|
||||||
if (!bHasTarget)
|
if (!bHasTarget)
|
||||||
{
|
{
|
||||||
if (((psDroid->order == DORDER_ATTACKTARGET
|
if (((order->type == DORDER_ATTACKTARGET
|
||||||
|| psDroid->order == DORDER_FIRESUPPORT)
|
|| order->type == DORDER_FIRESUPPORT)
|
||||||
&& secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_HOLD)
|
&& secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_HOLD)
|
||||||
|| (!isVtolDroid(psDroid)
|
|| (!isVtolDroid(psDroid)
|
||||||
&& (psTarget = orderStateObj(psDroid, DORDER_FIRESUPPORT))
|
&& (psTarget = orderStateObj(psDroid, DORDER_FIRESUPPORT))
|
||||||
&& psTarget->type == OBJ_STRUCTURE)
|
&& psTarget->type == OBJ_STRUCTURE)
|
||||||
|| (psDroid->order == DORDER_NONE) || (psDroid->order == DORDER_TEMP_HOLD)
|
|| (order->type == DORDER_NONE) || (order->type == DORDER_TEMP_HOLD)
|
||||||
|| (psDroid->order == DORDER_RTR))
|
|| (order->type == DORDER_RTR))
|
||||||
{
|
{
|
||||||
// don't move if on hold or firesupport for a sensor tower
|
// don't move if on hold or firesupport for a sensor tower
|
||||||
// also don't move if we're holding position or waiting for repair
|
// also don't move if we're holding position or waiting for repair
|
||||||
|
@ -1408,7 +1409,7 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
//'hack' to make the droid to check the primary turrent instead of all
|
//'hack' to make the droid to check the primary turrent instead of all
|
||||||
WEAPON_STATS* const psWeapStats = &asWeaponStats[psDroid->asWeaps[0].nStat];
|
WEAPON_STATS* const psWeapStats = &asWeaponStats[psDroid->asWeaps[0].nStat];
|
||||||
|
|
||||||
if (psDroid->order == DORDER_ATTACKTARGET
|
if (order->type == DORDER_ATTACKTARGET
|
||||||
&& secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_HOLD)
|
&& secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_HOLD)
|
||||||
{
|
{
|
||||||
psDroid->action = DACTION_NONE; // on hold, give up.
|
psDroid->action = DACTION_NONE; // on hold, give up.
|
||||||
|
@ -1459,15 +1460,15 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DACTION_MOVETOBUILD:
|
case DACTION_MOVETOBUILD:
|
||||||
if (!psDroid->psTarStats)
|
if (!order->psStats)
|
||||||
{
|
{
|
||||||
psDroid->action = DACTION_NONE;
|
psDroid->action = DACTION_NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// moving to a location to build a structure
|
// moving to a location to build a structure
|
||||||
if (actionReachedBuildPos(psDroid, psDroid->orderX, psDroid->orderY, psDroid->orderDirection, psDroid->psTarStats))
|
if (actionReachedBuildPos(psDroid, order->pos.x, order->pos.y, order->direction, order->psStats))
|
||||||
{
|
{
|
||||||
bool buildPosEmpty = actionRemoveDroidsFromBuildPos(psDroid->player, Vector2i(psDroid->orderX, psDroid->orderY), psDroid->orderDirection, psDroid->psTarStats);
|
bool buildPosEmpty = actionRemoveDroidsFromBuildPos(psDroid->player, order->pos, order->direction, order->psStats);
|
||||||
if (!buildPosEmpty)
|
if (!buildPosEmpty)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -1475,14 +1476,14 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
|
|
||||||
bool helpBuild = false;
|
bool helpBuild = false;
|
||||||
// Got to destination - start building
|
// Got to destination - start building
|
||||||
STRUCTURE_STATS* const psStructStats = (STRUCTURE_STATS*)psDroid->psTarStats;
|
STRUCTURE_STATS* const psStructStats = order->psStats;
|
||||||
uint16_t dir = psDroid->orderDirection;
|
uint16_t dir = order->direction;
|
||||||
moveStopDroid(psDroid);
|
moveStopDroid(psDroid);
|
||||||
objTrace(psDroid->id, "Halted in our tracks - at construction site");
|
objTrace(psDroid->id, "Halted in our tracks - at construction site");
|
||||||
if (psDroid->order == DORDER_BUILD && psDroid->psTarget == NULL)
|
if (order->type == DORDER_BUILD && order->psObj == NULL)
|
||||||
{
|
{
|
||||||
// Starting a new structure
|
// Starting a new structure
|
||||||
const Vector2i pos(psDroid->orderX, psDroid->orderY);
|
const Vector2i pos(order->pos.x, order->pos.y);
|
||||||
|
|
||||||
//need to check if something has already started building here?
|
//need to check if something has already started building here?
|
||||||
//unless its a module!
|
//unless its a module!
|
||||||
|
@ -1492,12 +1493,12 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
debug( LOG_NEVER, "DACTION_MOVETOBUILD: setUpBuildModule");
|
debug( LOG_NEVER, "DACTION_MOVETOBUILD: setUpBuildModule");
|
||||||
setUpBuildModule(psDroid);
|
setUpBuildModule(psDroid);
|
||||||
}
|
}
|
||||||
else if (TileHasStructure(mapTile(map_coord(psDroid->orderX), map_coord(psDroid->orderY))))
|
else if (TileHasStructure(mapTile(map_coord(order->pos.x), map_coord(order->pos.y))))
|
||||||
{
|
{
|
||||||
// structure on the build location - see if it is the same type
|
// structure on the build location - see if it is the same type
|
||||||
STRUCTURE* const psStruct = getTileStructure(map_coord(psDroid->orderX), map_coord(psDroid->orderY));
|
STRUCTURE* const psStruct = getTileStructure(map_coord(order->pos.x), map_coord(order->pos.y));
|
||||||
if (psStruct->pStructureType == (STRUCTURE_STATS *)psDroid->psTarStats ||
|
if (psStruct->pStructureType == order->psStats ||
|
||||||
(((STRUCTURE_STATS *)psDroid->psTarStats)->type == REF_WALL && psStruct->pStructureType->type == REF_WALLCORNER))
|
(order->psStats->type == REF_WALL && psStruct->pStructureType->type == REF_WALLCORNER))
|
||||||
{
|
{
|
||||||
// same type - do a help build
|
// same type - do a help build
|
||||||
syncDebug("Reached build target: do-help");
|
syncDebug("Reached build target: do-help");
|
||||||
|
@ -1506,8 +1507,8 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
}
|
}
|
||||||
else if ((psStruct->pStructureType->type == REF_WALL ||
|
else if ((psStruct->pStructureType->type == REF_WALL ||
|
||||||
psStruct->pStructureType->type == REF_WALLCORNER) &&
|
psStruct->pStructureType->type == REF_WALLCORNER) &&
|
||||||
(((STRUCTURE_STATS *)psDroid->psTarStats)->type == REF_DEFENSE ||
|
(order->psStats->type == REF_DEFENSE ||
|
||||||
((STRUCTURE_STATS *)psDroid->psTarStats)->type == REF_GATE))
|
order->psStats->type == REF_GATE))
|
||||||
{
|
{
|
||||||
// building a gun tower or gate over a wall - OK
|
// building a gun tower or gate over a wall - OK
|
||||||
if (droidStartBuild(psDroid))
|
if (droidStartBuild(psDroid))
|
||||||
|
@ -1529,7 +1530,7 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
cancelBuild(psDroid);
|
cancelBuild(psDroid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!validLocation(psDroid->psTarStats, pos, dir, psDroid->player, false))
|
else if (!validLocation(order->psStats, pos, dir, psDroid->player, false))
|
||||||
{
|
{
|
||||||
syncDebug("Reached build target: invalid");
|
syncDebug("Reached build target: invalid");
|
||||||
objTrace(psDroid->id, "DACTION_MOVETOBUILD: !validLocation");
|
objTrace(psDroid->id, "DACTION_MOVETOBUILD: !validLocation");
|
||||||
|
@ -1543,29 +1544,29 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
psDroid->actionPoints = 0;
|
psDroid->actionPoints = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((psDroid->order == DORDER_LINEBUILD || psDroid->order==DORDER_BUILD)
|
else if ((order->type == DORDER_LINEBUILD || order->type==DORDER_BUILD)
|
||||||
&& (psStructStats->type == REF_WALL || psStructStats->type == REF_WALLCORNER || psStructStats->type == REF_GATE ||
|
&& (psStructStats->type == REF_WALL || psStructStats->type == REF_WALLCORNER || psStructStats->type == REF_GATE ||
|
||||||
psStructStats->type == REF_DEFENSE || psStructStats->type == REF_REARM_PAD))
|
psStructStats->type == REF_DEFENSE || psStructStats->type == REF_REARM_PAD))
|
||||||
{
|
{
|
||||||
// building a wall.
|
// building a wall.
|
||||||
MAPTILE* const psTile = mapTile(map_coord(psDroid->orderX), map_coord(psDroid->orderY));
|
MAPTILE* const psTile = mapTile(map_coord(order->pos.x), map_coord(order->pos.y));
|
||||||
syncDebug("Reached build target: wall");
|
syncDebug("Reached build target: wall");
|
||||||
if (psDroid->psTarget == NULL
|
if (order->psObj == NULL
|
||||||
&& (TileHasStructure(psTile)
|
&& (TileHasStructure(psTile)
|
||||||
|| TileHasFeature(psTile)))
|
|| TileHasFeature(psTile)))
|
||||||
{
|
{
|
||||||
if (TileHasStructure(psTile))
|
if (TileHasStructure(psTile))
|
||||||
{
|
{
|
||||||
// structure on the build location - see if it is the same type
|
// structure on the build location - see if it is the same type
|
||||||
STRUCTURE* const psStruct = getTileStructure(map_coord(psDroid->orderX), map_coord(psDroid->orderY));
|
STRUCTURE* const psStruct = getTileStructure(map_coord(order->pos.x), map_coord(order->pos.y));
|
||||||
if (psStruct->pStructureType == (STRUCTURE_STATS *)psDroid->psTarStats)
|
if (psStruct->pStructureType == order->psStats)
|
||||||
{
|
{
|
||||||
// same type - do a help build
|
// same type - do a help build
|
||||||
setDroidTarget(psDroid, psStruct);
|
setDroidTarget(psDroid, psStruct);
|
||||||
helpBuild = true;
|
helpBuild = true;
|
||||||
}
|
}
|
||||||
else if ((psStruct->pStructureType->type == REF_WALL || psStruct->pStructureType->type == REF_WALLCORNER) &&
|
else if ((psStruct->pStructureType->type == REF_WALL || psStruct->pStructureType->type == REF_WALLCORNER) &&
|
||||||
(((STRUCTURE_STATS *)psDroid->psTarStats)->type == REF_DEFENSE || ((STRUCTURE_STATS *)psDroid->psTarStats)->type == REF_GATE))
|
(order->psStats->type == REF_DEFENSE || order->psStats->type == REF_GATE))
|
||||||
{
|
{
|
||||||
// building a gun tower over a wall - OK
|
// building a gun tower over a wall - OK
|
||||||
if (droidStartBuild(psDroid))
|
if (droidStartBuild(psDroid))
|
||||||
|
@ -1627,22 +1628,22 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DACTION_BUILD:
|
case DACTION_BUILD:
|
||||||
if (!psDroid->psTarStats)
|
if (!order->psStats)
|
||||||
{
|
{
|
||||||
objTrace(psDroid->id, "No target stats for build order - resetting");
|
objTrace(psDroid->id, "No target stats for build order - resetting");
|
||||||
psDroid->action = DACTION_NONE;
|
psDroid->action = DACTION_NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (DROID_STOPPED(psDroid) &&
|
if (DROID_STOPPED(psDroid) &&
|
||||||
!actionReachedBuildPos(psDroid, psDroid->orderX, psDroid->orderY, psDroid->orderDirection, psDroid->psTarStats))
|
!actionReachedBuildPos(psDroid, order->pos.x, order->pos.y, order->direction, order->psStats))
|
||||||
{
|
{
|
||||||
objTrace(psDroid->id, "DACTION_BUILD: Starting to drive toward construction site");
|
objTrace(psDroid->id, "DACTION_BUILD: Starting to drive toward construction site");
|
||||||
moveDroidToNoFormation(psDroid, psDroid->orderX, psDroid->orderY);
|
moveDroidToNoFormation(psDroid, order->pos.x, order->pos.y);
|
||||||
}
|
}
|
||||||
else if (!DROID_STOPPED(psDroid) &&
|
else if (!DROID_STOPPED(psDroid) &&
|
||||||
psDroid->sMove.Status != MOVETURNTOTARGET &&
|
psDroid->sMove.Status != MOVETURNTOTARGET &&
|
||||||
psDroid->sMove.Status != MOVESHUFFLE &&
|
psDroid->sMove.Status != MOVESHUFFLE &&
|
||||||
actionReachedBuildPos(psDroid, psDroid->orderX, psDroid->orderY, psDroid->orderDirection, psDroid->psTarStats))
|
actionReachedBuildPos(psDroid, order->pos.x, order->pos.y, order->direction, order->psStats))
|
||||||
{
|
{
|
||||||
objTrace(psDroid->id, "DACTION_BUILD: Stopped - at construction site");
|
objTrace(psDroid->id, "DACTION_BUILD: Stopped - at construction site");
|
||||||
moveStopDroid(psDroid);
|
moveStopDroid(psDroid);
|
||||||
|
@ -1661,13 +1662,13 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
case DACTION_MOVETODEMOLISH:
|
case DACTION_MOVETODEMOLISH:
|
||||||
case DACTION_MOVETOREPAIR:
|
case DACTION_MOVETOREPAIR:
|
||||||
case DACTION_MOVETORESTORE:
|
case DACTION_MOVETORESTORE:
|
||||||
if (!psDroid->psTarStats)
|
if (!order->psStats)
|
||||||
{
|
{
|
||||||
psDroid->action = DACTION_NONE;
|
psDroid->action = DACTION_NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// see if the droid is at the edge of what it is moving to
|
// see if the droid is at the edge of what it is moving to
|
||||||
if (actionReachedBuildPos(psDroid, psDroid->actionPos.x, psDroid->actionPos.y, ((STRUCTURE *)psDroid->psActionTarget[0])->rot.direction, psDroid->psTarStats))
|
if (actionReachedBuildPos(psDroid, psDroid->actionPos.x, psDroid->actionPos.y, ((STRUCTURE *)psDroid->psActionTarget[0])->rot.direction, order->psStats))
|
||||||
{
|
{
|
||||||
moveStopDroid(psDroid);
|
moveStopDroid(psDroid);
|
||||||
|
|
||||||
|
@ -1696,7 +1697,7 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
case DACTION_DEMOLISH:
|
case DACTION_DEMOLISH:
|
||||||
case DACTION_REPAIR:
|
case DACTION_REPAIR:
|
||||||
case DACTION_RESTORE:
|
case DACTION_RESTORE:
|
||||||
if (!psDroid->psTarStats)
|
if (!order->psStats)
|
||||||
{
|
{
|
||||||
psDroid->action = DACTION_NONE;
|
psDroid->action = DACTION_NONE;
|
||||||
break;
|
break;
|
||||||
|
@ -1721,10 +1722,10 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// now do the action update
|
// now do the action update
|
||||||
if (DROID_STOPPED(psDroid) && !actionReachedBuildPos(psDroid, psDroid->actionPos.x, psDroid->actionPos.y, ((STRUCTURE *)psDroid->psActionTarget[0])->rot.direction, psDroid->psTarStats))
|
if (DROID_STOPPED(psDroid) && !actionReachedBuildPos(psDroid, psDroid->actionPos.x, psDroid->actionPos.y, ((STRUCTURE *)psDroid->psActionTarget[0])->rot.direction, order->psStats))
|
||||||
{
|
{
|
||||||
if (secondaryGetState(psDroid, DSO_HALTTYPE) != DSS_HALT_HOLD ||
|
if (secondaryGetState(psDroid, DSO_HALTTYPE) != DSS_HALT_HOLD ||
|
||||||
(psDroid->order != DORDER_NONE && psDroid->order != DORDER_TEMP_HOLD))
|
(order->type != DORDER_NONE && order->type != DORDER_TEMP_HOLD))
|
||||||
{
|
{
|
||||||
objTrace(psDroid->id, "Secondary order: Go to construction site");
|
objTrace(psDroid->id, "Secondary order: Go to construction site");
|
||||||
moveDroidToNoFormation(psDroid, psDroid->actionPos.x, psDroid->actionPos.y);
|
moveDroidToNoFormation(psDroid, psDroid->actionPos.x, psDroid->actionPos.y);
|
||||||
|
@ -1737,7 +1738,7 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
else if (!DROID_STOPPED(psDroid) &&
|
else if (!DROID_STOPPED(psDroid) &&
|
||||||
psDroid->sMove.Status != MOVETURNTOTARGET &&
|
psDroid->sMove.Status != MOVETURNTOTARGET &&
|
||||||
psDroid->sMove.Status != MOVESHUFFLE &&
|
psDroid->sMove.Status != MOVESHUFFLE &&
|
||||||
actionReachedBuildPos(psDroid, psDroid->actionPos.x, psDroid->actionPos.y, ((STRUCTURE *)psDroid->psActionTarget[0])->rot.direction, psDroid->psTarStats))
|
actionReachedBuildPos(psDroid, psDroid->actionPos.x, psDroid->actionPos.y, ((STRUCTURE *)psDroid->psActionTarget[0])->rot.direction, order->psStats))
|
||||||
{
|
{
|
||||||
objTrace(psDroid->id, "Stopped - reached build position");
|
objTrace(psDroid->id, "Stopped - reached build position");
|
||||||
moveStopDroid(psDroid);
|
moveStopDroid(psDroid);
|
||||||
|
@ -1775,23 +1776,23 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DACTION_BUILD_FOUNDATION:
|
case DACTION_BUILD_FOUNDATION:
|
||||||
if (!psDroid->psTarStats)
|
if (!order->psStats)
|
||||||
{
|
{
|
||||||
psDroid->action = DACTION_NONE;
|
psDroid->action = DACTION_NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//building a structure's foundation - flattening the ground for now
|
//building a structure's foundation - flattening the ground for now
|
||||||
{
|
{
|
||||||
MAPTILE* const psTile = mapTile(map_coord(psDroid->orderX), map_coord(psDroid->orderY));
|
MAPTILE* const psTile = mapTile(map_coord(order->pos.x), map_coord(order->pos.y));
|
||||||
if ((psDroid->psTarget == NULL) &&
|
if ((order->psObj == NULL) &&
|
||||||
(TileHasStructure(psTile) ||
|
(TileHasStructure(psTile) ||
|
||||||
TileHasFeature(psTile)))
|
TileHasFeature(psTile)))
|
||||||
{
|
{
|
||||||
if (TileHasStructure(psTile))
|
if (TileHasStructure(psTile))
|
||||||
{
|
{
|
||||||
// structure on the build location - see if it is the same type
|
// structure on the build location - see if it is the same type
|
||||||
STRUCTURE* const psStruct = getTileStructure(map_coord(psDroid->orderX), map_coord(psDroid->orderY));
|
STRUCTURE* const psStruct = getTileStructure(map_coord(order->pos.x), map_coord(order->pos.y));
|
||||||
if (psStruct->pStructureType == (STRUCTURE_STATS *)psDroid->psTarStats)
|
if (psStruct->pStructureType == order->psStats)
|
||||||
{
|
{
|
||||||
// same type - do a help build
|
// same type - do a help build
|
||||||
setDroidTarget(psDroid, psStruct);
|
setDroidTarget(psDroid, psStruct);
|
||||||
|
@ -1801,10 +1802,7 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
psDroid->action = DACTION_NONE;
|
psDroid->action = DACTION_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!validLocation(psDroid->psTarStats,
|
else if (!validLocation(order->psStats, order->pos, order->direction, psDroid->player, false))
|
||||||
Vector2i(psDroid->orderX, psDroid->orderY), psDroid->orderDirection,
|
|
||||||
psDroid->player,
|
|
||||||
false))
|
|
||||||
{
|
{
|
||||||
psDroid->action = DACTION_NONE;
|
psDroid->action = DACTION_NONE;
|
||||||
}
|
}
|
||||||
|
@ -1847,7 +1845,7 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
|| xdiff * xdiff + ydiff * ydiff >= rangeSq)
|
|| xdiff * xdiff + ydiff * ydiff >= rangeSq)
|
||||||
{
|
{
|
||||||
if (secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_HOLD &&
|
if (secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_HOLD &&
|
||||||
(psDroid->order == DORDER_NONE || psDroid->order == DORDER_TEMP_HOLD))
|
(order->type == DORDER_NONE || order->type == DORDER_TEMP_HOLD))
|
||||||
{
|
{
|
||||||
psDroid->action = DACTION_NONE;
|
psDroid->action = DACTION_NONE;
|
||||||
}
|
}
|
||||||
|
@ -1883,22 +1881,22 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DACTION_FIRESUPPORT:
|
case DACTION_FIRESUPPORT:
|
||||||
if (!psDroid->psTarget)
|
if (!order->psObj)
|
||||||
{
|
{
|
||||||
psDroid->action = DACTION_NONE;
|
psDroid->action = DACTION_NONE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//can be either a droid or a structure now - AB 7/10/98
|
//can be either a droid or a structure now - AB 7/10/98
|
||||||
ASSERT_OR_RETURN(, (psDroid->psTarget->type == OBJ_DROID || psDroid->psTarget->type == OBJ_STRUCTURE)
|
ASSERT_OR_RETURN(, (order->psObj->type == OBJ_DROID || order->psObj->type == OBJ_STRUCTURE)
|
||||||
&& (psDroid->psTarget->player == psDroid->player), "DACTION_FIRESUPPORT: incorrect target type" );
|
&& (order->psObj->player == psDroid->player), "DACTION_FIRESUPPORT: incorrect target type" );
|
||||||
|
|
||||||
//don't move VTOL's
|
//don't move VTOL's
|
||||||
// also don't move closer to sensor towers
|
// also don't move closer to sensor towers
|
||||||
if (!isVtolDroid(psDroid) &&
|
if (!isVtolDroid(psDroid) &&
|
||||||
(psDroid->psTarget->type != OBJ_STRUCTURE))
|
(order->psObj->type != OBJ_STRUCTURE))
|
||||||
{
|
{
|
||||||
//move droids to within short range of the sensor now!!!!
|
//move droids to within short range of the sensor now!!!!
|
||||||
Vector2i diff = removeZ(psDroid->pos - psDroid->psTarget->pos);
|
Vector2i diff = removeZ(psDroid->pos - order->psObj->pos);
|
||||||
int rangeSq = asWeaponStats[psDroid->asWeaps[0].nStat].shortRange;
|
int rangeSq = asWeaponStats[psDroid->asWeaps[0].nStat].shortRange;
|
||||||
rangeSq = rangeSq * rangeSq;
|
rangeSq = rangeSq * rangeSq;
|
||||||
if (diff*diff < rangeSq)
|
if (diff*diff < rangeSq)
|
||||||
|
@ -1912,7 +1910,7 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
{
|
{
|
||||||
if (!DROID_STOPPED(psDroid))
|
if (!DROID_STOPPED(psDroid))
|
||||||
{
|
{
|
||||||
diff = removeZ(psDroid->psTarget->pos) - psDroid->sMove.destination;
|
diff = removeZ(order->psObj->pos) - psDroid->sMove.destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DROID_STOPPED(psDroid) || diff*diff > rangeSq)
|
if (DROID_STOPPED(psDroid) || diff*diff > rangeSq)
|
||||||
|
@ -1925,7 +1923,7 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// move in range
|
// move in range
|
||||||
moveDroidTo(psDroid, psDroid->psTarget->pos.x,psDroid->psTarget->pos.y);
|
moveDroidTo(psDroid, order->psObj->pos.x,order->psObj->pos.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1991,7 +1989,7 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
// Just self-repairing.
|
// Just self-repairing.
|
||||||
// See if there's anything to shoot.
|
// See if there's anything to shoot.
|
||||||
else if (psDroid->numWeaps > 0 && !isVtolDroid(psDroid)
|
else if (psDroid->numWeaps > 0 && !isVtolDroid(psDroid)
|
||||||
&& (psDroid->order == DORDER_NONE || psDroid->order == DORDER_TEMP_HOLD || psDroid->order == DORDER_RTR))
|
&& (order->type == DORDER_NONE || order->type == DORDER_TEMP_HOLD || order->type == DORDER_RTR))
|
||||||
{
|
{
|
||||||
for (i = 0;i < psDroid->numWeaps;i++)
|
for (i = 0;i < psDroid->numWeaps;i++)
|
||||||
{
|
{
|
||||||
|
@ -2021,7 +2019,7 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
ydiff = (SDWORD)psDroid->pos.y - (SDWORD)psDroid->psActionTarget[0]->pos.y;
|
ydiff = (SDWORD)psDroid->pos.y - (SDWORD)psDroid->psActionTarget[0]->pos.y;
|
||||||
if (xdiff * xdiff + ydiff * ydiff > REPAIR_RANGE)
|
if (xdiff * xdiff + ydiff * ydiff > REPAIR_RANGE)
|
||||||
{
|
{
|
||||||
if (secondaryGetState(psDroid, DSO_HALTTYPE) != DSS_HALT_HOLD || psDroid->order == DORDER_REPAIR)
|
if (secondaryGetState(psDroid, DSO_HALTTYPE) != DSS_HALT_HOLD || order->type == DORDER_REPAIR)
|
||||||
{
|
{
|
||||||
/*once started - don't allow the Repair droid to follow the
|
/*once started - don't allow the Repair droid to follow the
|
||||||
damaged droid for too long*/
|
damaged droid for too long*/
|
||||||
|
@ -2185,6 +2183,8 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
|
||||||
syncDebugDroid(psDroid, '-');
|
syncDebugDroid(psDroid, '-');
|
||||||
syncDebug("%d does %s", psDroid->id, getDroidActionName(psAction->action));
|
syncDebug("%d does %s", psDroid->id, getDroidActionName(psAction->action));
|
||||||
|
|
||||||
|
DROID_ORDER_DATA *order = &psDroid->order;
|
||||||
|
|
||||||
switch (psAction->action)
|
switch (psAction->action)
|
||||||
{
|
{
|
||||||
case DACTION_NONE:
|
case DACTION_NONE:
|
||||||
|
@ -2252,10 +2252,10 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
|
||||||
psDroid->actionPos = psDroid->pos;
|
psDroid->actionPos = psDroid->pos;
|
||||||
setDroidActionTarget(psDroid, psAction->psObj, 0);
|
setDroidActionTarget(psDroid, psAction->psObj, 0);
|
||||||
|
|
||||||
if (((psDroid->order == DORDER_ATTACKTARGET
|
if (((order->type == DORDER_ATTACKTARGET
|
||||||
|| psDroid->order == DORDER_NONE
|
|| order->type == DORDER_NONE
|
||||||
|| psDroid->order == DORDER_TEMP_HOLD
|
|| order->type == DORDER_TEMP_HOLD
|
||||||
|| psDroid->order == DORDER_FIRESUPPORT)
|
|| order->type == DORDER_FIRESUPPORT)
|
||||||
&& secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_HOLD)
|
&& secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_HOLD)
|
||||||
|| (!isVtolDroid(psDroid)
|
|| (!isVtolDroid(psDroid)
|
||||||
&& (psTarget = orderStateObj(psDroid, DORDER_FIRESUPPORT))
|
&& (psTarget = orderStateObj(psDroid, DORDER_FIRESUPPORT))
|
||||||
|
@ -2340,13 +2340,13 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DACTION_BUILD:
|
case DACTION_BUILD:
|
||||||
if (!psDroid->psTarStats)
|
if (!order->psStats)
|
||||||
{
|
{
|
||||||
psDroid->action = DACTION_NONE;
|
psDroid->action = DACTION_NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ASSERT(psDroid->order == DORDER_BUILD || psDroid->order == DORDER_HELPBUILD ||
|
ASSERT(order->type == DORDER_BUILD || order->type == DORDER_HELPBUILD ||
|
||||||
psDroid->order == DORDER_LINEBUILD,
|
order->type == DORDER_LINEBUILD,
|
||||||
"cannot start build action without a build order");
|
"cannot start build action without a build order");
|
||||||
ASSERT_OR_RETURN( , psAction->x > 0 && psAction->y > 0, "Bad build order position");
|
ASSERT_OR_RETURN( , psAction->x > 0 && psAction->y > 0, "Bad build order position");
|
||||||
psDroid->action = DACTION_MOVETOBUILD;
|
psDroid->action = DACTION_MOVETOBUILD;
|
||||||
|
@ -2355,19 +2355,19 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
|
||||||
moveDroidToNoFormation(psDroid, psDroid->actionPos.x, psDroid->actionPos.y);
|
moveDroidToNoFormation(psDroid, psDroid->actionPos.x, psDroid->actionPos.y);
|
||||||
break;
|
break;
|
||||||
case DACTION_DEMOLISH:
|
case DACTION_DEMOLISH:
|
||||||
ASSERT(psDroid->order == DORDER_DEMOLISH,
|
ASSERT(order->type == DORDER_DEMOLISH,
|
||||||
"cannot start demolish action without a demolish order");
|
"cannot start demolish action without a demolish order");
|
||||||
psDroid->action = DACTION_MOVETODEMOLISH;
|
psDroid->action = DACTION_MOVETODEMOLISH;
|
||||||
psDroid->actionPos.x = psAction->x;
|
psDroid->actionPos.x = psAction->x;
|
||||||
psDroid->actionPos.y = psAction->y;
|
psDroid->actionPos.y = psAction->y;
|
||||||
ASSERT((psDroid->psTarget != NULL) && (psDroid->psTarget->type == OBJ_STRUCTURE),
|
ASSERT((order->psObj != NULL) && (order->psObj->type == OBJ_STRUCTURE),
|
||||||
"invalid target for demolish order" );
|
"invalid target for demolish order" );
|
||||||
psDroid->psTarStats = ((STRUCTURE *)psDroid->psTarget)->pStructureType;
|
order->psStats = ((STRUCTURE *)order->psObj)->pStructureType;
|
||||||
setDroidActionTarget(psDroid, psAction->psObj, 0);
|
setDroidActionTarget(psDroid, psAction->psObj, 0);
|
||||||
moveDroidTo(psDroid, psAction->x, psAction->y);
|
moveDroidTo(psDroid, psAction->x, psAction->y);
|
||||||
break;
|
break;
|
||||||
case DACTION_REPAIR:
|
case DACTION_REPAIR:
|
||||||
//ASSERT( psDroid->order == DORDER_REPAIR,
|
//ASSERT( order->type == DORDER_REPAIR,
|
||||||
// "actionDroidBase: cannot start repair action without a repair order" );
|
// "actionDroidBase: cannot start repair action without a repair order" );
|
||||||
psDroid->action = DACTION_MOVETOREPAIR;
|
psDroid->action = DACTION_MOVETOREPAIR;
|
||||||
psDroid->actionPos.x = psAction->x;
|
psDroid->actionPos.x = psAction->x;
|
||||||
|
@ -2376,9 +2376,9 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
|
||||||
setDroidActionTarget(psDroid, psAction->psObj, 0);
|
setDroidActionTarget(psDroid, psAction->psObj, 0);
|
||||||
ASSERT((psDroid->psActionTarget[0] != NULL) && (psDroid->psActionTarget[0]->type == OBJ_STRUCTURE),
|
ASSERT((psDroid->psActionTarget[0] != NULL) && (psDroid->psActionTarget[0]->type == OBJ_STRUCTURE),
|
||||||
"invalid target for demolish order" );
|
"invalid target for demolish order" );
|
||||||
psDroid->psTarStats = ((STRUCTURE *)psDroid->psActionTarget[0])->pStructureType;
|
order->psStats = ((STRUCTURE *)psDroid->psActionTarget[0])->pStructureType;
|
||||||
if (secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_HOLD &&
|
if (secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_HOLD &&
|
||||||
(psDroid->order == DORDER_NONE || psDroid->order == DORDER_TEMP_HOLD))
|
(order->type == DORDER_NONE || order->type == DORDER_TEMP_HOLD))
|
||||||
{
|
{
|
||||||
psDroid->action = DACTION_REPAIR;
|
psDroid->action = DACTION_REPAIR;
|
||||||
}
|
}
|
||||||
|
@ -2393,7 +2393,7 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
|
||||||
psDroid->actionPos.x = psDroid->pos.x;
|
psDroid->actionPos.x = psDroid->pos.x;
|
||||||
psDroid->actionPos.y = psDroid->pos.y;
|
psDroid->actionPos.y = psDroid->pos.y;
|
||||||
if ((secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_HOLD &&
|
if ((secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_HOLD &&
|
||||||
(psDroid->order == DORDER_NONE || psDroid->order == DORDER_TEMP_HOLD)) ||
|
(order->type == DORDER_NONE || order->type == DORDER_TEMP_HOLD)) ||
|
||||||
cbSensorDroid(psDroid) || objRadarDetector(psDroid))
|
cbSensorDroid(psDroid) || objRadarDetector(psDroid))
|
||||||
{
|
{
|
||||||
psDroid->action = DACTION_OBSERVE;
|
psDroid->action = DACTION_OBSERVE;
|
||||||
|
@ -2408,9 +2408,9 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
|
||||||
psDroid->action = DACTION_FIRESUPPORT;
|
psDroid->action = DACTION_FIRESUPPORT;
|
||||||
if(!isVtolDroid(psDroid) &&
|
if(!isVtolDroid(psDroid) &&
|
||||||
(secondaryGetState(psDroid, DSO_HALTTYPE) != DSS_HALT_HOLD) && // check hold
|
(secondaryGetState(psDroid, DSO_HALTTYPE) != DSS_HALT_HOLD) && // check hold
|
||||||
(psDroid->psTarget->type != OBJ_STRUCTURE))
|
(order->psObj->type != OBJ_STRUCTURE))
|
||||||
{
|
{
|
||||||
moveDroidTo(psDroid, psDroid->psTarget->pos.x, psDroid->psTarget->pos.y); // movetotarget.
|
moveDroidTo(psDroid, order->psObj->pos.x, order->psObj->pos.y); // movetotarget.
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -2453,7 +2453,7 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
|
||||||
ensureRearmPadClear((STRUCTURE *)psAction->psObj, psDroid);
|
ensureRearmPadClear((STRUCTURE *)psAction->psObj, psDroid);
|
||||||
break;
|
break;
|
||||||
case DACTION_DROIDREPAIR:
|
case DACTION_DROIDREPAIR:
|
||||||
// ASSERT( psDroid->order == DORDER_DROIDREPAIR,
|
// ASSERT( order->type == DORDER_DROIDREPAIR,
|
||||||
// "actionDroidBase: cannot start droid repair action without a repair order" );
|
// "actionDroidBase: cannot start droid repair action without a repair order" );
|
||||||
psDroid->action = DACTION_MOVETODROIDREPAIR;
|
psDroid->action = DACTION_MOVETODROIDREPAIR;
|
||||||
psDroid->actionPos.x = psAction->x;
|
psDroid->actionPos.x = psAction->x;
|
||||||
|
@ -2463,7 +2463,7 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
|
||||||
psDroid->actionPoints = 0;
|
psDroid->actionPoints = 0;
|
||||||
psDroid->actionStarted = gameTime;
|
psDroid->actionStarted = gameTime;
|
||||||
if (secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_HOLD &&
|
if (secondaryGetState(psDroid, DSO_HALTTYPE) == DSS_HALT_HOLD &&
|
||||||
(psDroid->order == DORDER_NONE || psDroid->order == DORDER_TEMP_HOLD))
|
(order->type == DORDER_NONE || order->type == DORDER_TEMP_HOLD))
|
||||||
{
|
{
|
||||||
psDroid->action = DACTION_DROIDREPAIR;
|
psDroid->action = DACTION_DROIDREPAIR;
|
||||||
}
|
}
|
||||||
|
@ -2474,14 +2474,14 @@ static void actionDroidBase(DROID *psDroid, DROID_ACTION_DATA *psAction)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DACTION_RESTORE:
|
case DACTION_RESTORE:
|
||||||
ASSERT( psDroid->order == DORDER_RESTORE,
|
ASSERT( order->type == DORDER_RESTORE,
|
||||||
"cannot start restore action without a restore order" );
|
"cannot start restore action without a restore order" );
|
||||||
psDroid->action = DACTION_MOVETORESTORE;
|
psDroid->action = DACTION_MOVETORESTORE;
|
||||||
psDroid->actionPos.x = psAction->x;
|
psDroid->actionPos.x = psAction->x;
|
||||||
psDroid->actionPos.y = psAction->y;
|
psDroid->actionPos.y = psAction->y;
|
||||||
ASSERT( (psDroid->psTarget != NULL) && (psDroid->psTarget->type == OBJ_STRUCTURE),
|
ASSERT( (order->psObj != NULL) && (order->psObj->type == OBJ_STRUCTURE),
|
||||||
"invalid target for restore order" );
|
"invalid target for restore order" );
|
||||||
psDroid->psTarStats = ((STRUCTURE *)psDroid->psTarget)->pStructureType;
|
order->psStats = ((STRUCTURE *)order->psObj)->pStructureType;
|
||||||
setDroidActionTarget(psDroid, psAction->psObj, 0);
|
setDroidActionTarget(psDroid, psAction->psObj, 0);
|
||||||
moveDroidTo(psDroid, psAction->x, psAction->y);
|
moveDroidTo(psDroid, psAction->x, psAction->y);
|
||||||
break;
|
break;
|
||||||
|
@ -2576,7 +2576,7 @@ void moveToRearm(DROID *psDroid)
|
||||||
}
|
}
|
||||||
|
|
||||||
//return to re-arming pad
|
//return to re-arming pad
|
||||||
if (psDroid->order == DORDER_NONE)
|
if (psDroid->order.type == DORDER_NONE)
|
||||||
{
|
{
|
||||||
// no order set - use the rearm order to ensure the unit goes back
|
// no order set - use the rearm order to ensure the unit goes back
|
||||||
// to the landing pad
|
// to the landing pad
|
||||||
|
|
10
src/ai.cpp
10
src/ai.cpp
|
@ -186,7 +186,7 @@ static BASE_OBJECT *aiSearchSensorTargets(BASE_OBJECT *psObj, int weapon_slot, W
|
||||||
DROID *psDroid = (DROID *)psSensor;
|
DROID *psDroid = (DROID *)psSensor;
|
||||||
|
|
||||||
ASSERT_OR_RETURN(false, psDroid->droidType == DROID_SENSOR, "A non-sensor droid in a sensor list is non-sense");
|
ASSERT_OR_RETURN(false, psDroid->droidType == DROID_SENSOR, "A non-sensor droid in a sensor list is non-sense");
|
||||||
psTemp = psDroid->psTarget;
|
psTemp = psDroid->order.psObj;
|
||||||
isCB = cbSensorDroid(psDroid);
|
isCB = cbSensorDroid(psDroid);
|
||||||
isRD = objRadarDetector((BASE_OBJECT *)psDroid);
|
isRD = objRadarDetector((BASE_OBJECT *)psDroid);
|
||||||
}
|
}
|
||||||
|
@ -465,7 +465,7 @@ static SDWORD targetAttackWeight(BASE_OBJECT *psTarget, BASE_OBJECT *psAttacker,
|
||||||
for(weaponSlot = 0; weaponSlot < psGroupDroid->numWeaps; weaponSlot++)
|
for(weaponSlot = 0; weaponSlot < psGroupDroid->numWeaps; weaponSlot++)
|
||||||
{
|
{
|
||||||
//see if this droid is currently targeting current target
|
//see if this droid is currently targeting current target
|
||||||
if(psGroupDroid->psTarget == psTarget ||
|
if(psGroupDroid->order.psObj == psTarget ||
|
||||||
psGroupDroid->psActionTarget[weaponSlot] == psTarget)
|
psGroupDroid->psActionTarget[weaponSlot] == psTarget)
|
||||||
{
|
{
|
||||||
//we prefer targets that are already targeted and hence will be destroyed faster
|
//we prefer targets that are already targeted and hence will be destroyed faster
|
||||||
|
@ -545,7 +545,7 @@ int aiBestNearestTarget(DROID *psDroid, BASE_OBJECT **ppsObj, int weapon_slot, i
|
||||||
if(friendlyDroid->numWeaps > 0)
|
if(friendlyDroid->numWeaps > 0)
|
||||||
{
|
{
|
||||||
// make sure this target wasn't assigned explicitly to this droid
|
// make sure this target wasn't assigned explicitly to this droid
|
||||||
if(friendlyDroid->order != DORDER_ATTACK)
|
if (friendlyDroid->order.type != DORDER_ATTACK)
|
||||||
{
|
{
|
||||||
targetInQuestion = tempTarget; //consider this target
|
targetInQuestion = tempTarget; //consider this target
|
||||||
}
|
}
|
||||||
|
@ -1058,7 +1058,7 @@ void aiUpdateDroid(DROID *psDroid)
|
||||||
updateTarget = true;
|
updateTarget = true;
|
||||||
}
|
}
|
||||||
if ((orderState(psDroid, DORDER_OBSERVE) || orderState(psDroid, DORDER_ATTACKTARGET)) &&
|
if ((orderState(psDroid, DORDER_OBSERVE) || orderState(psDroid, DORDER_ATTACKTARGET)) &&
|
||||||
psDroid->psTarget && aiObjectIsProbablyDoomed(psDroid->psTarget))
|
psDroid->order.psObj && aiObjectIsProbablyDoomed(psDroid->order.psObj))
|
||||||
{
|
{
|
||||||
lookForTarget = true;
|
lookForTarget = true;
|
||||||
updateTarget = false;
|
updateTarget = false;
|
||||||
|
@ -1066,7 +1066,7 @@ void aiUpdateDroid(DROID *psDroid)
|
||||||
|
|
||||||
/* Don't update target if we are sent to attack and reached
|
/* Don't update target if we are sent to attack and reached
|
||||||
attack destination (attacking our target) */
|
attack destination (attacking our target) */
|
||||||
if (orderState(psDroid, DORDER_ATTACK) && psDroid->psActionTarget[0] == psDroid->psTarget)
|
if (orderState(psDroid, DORDER_ATTACK) && psDroid->psActionTarget[0] == psDroid->order.psObj)
|
||||||
{
|
{
|
||||||
updateTarget = false;
|
updateTarget = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1670,7 +1670,7 @@ static void dealWithLMBDroid(DROID* psDroid, SELECTION_TYPE selection)
|
||||||
{
|
{
|
||||||
CONPRINTF(ConsoleString, (ConsoleString, "(Enemy!) %s - Damage %d%% - ID %d - experience %f, %s - order %s - action %s - sensor range %hu - ECM %u - pitch %.0f",
|
CONPRINTF(ConsoleString, (ConsoleString, "(Enemy!) %s - Damage %d%% - ID %d - experience %f, %s - order %s - action %s - sensor range %hu - ECM %u - pitch %.0f",
|
||||||
droidGetName(psDroid), 100 - clip(PERCENT(psDroid->body, psDroid->originalBody), 0, 100), psDroid->id,
|
droidGetName(psDroid), 100 - clip(PERCENT(psDroid->body, psDroid->originalBody), 0, 100), psDroid->id,
|
||||||
psDroid->experience/65536.f, getDroidLevelName(psDroid), getDroidOrderName(psDroid->order), getDroidActionName(psDroid->action),
|
psDroid->experience/65536.f, getDroidLevelName(psDroid), getDroidOrderName(psDroid->order.type), getDroidActionName(psDroid->action),
|
||||||
droidSensorRange(psDroid), droidConcealment(psDroid), UNDEG(psDroid->rot.pitch)));
|
droidSensorRange(psDroid), droidConcealment(psDroid), UNDEG(psDroid->rot.pitch)));
|
||||||
FeedbackOrderGiven();
|
FeedbackOrderGiven();
|
||||||
}
|
}
|
||||||
|
@ -1819,7 +1819,7 @@ static void dealWithLMBDroid(DROID* psDroid, SELECTION_TYPE selection)
|
||||||
"%s - Damage %d%% - ID %d - experience %f, %s - order %s - action %s - sensor range %hu - ECM %u - pitch %.0f",
|
"%s - Damage %d%% - ID %d - experience %f, %s - order %s - action %s - sensor range %hu - ECM %u - pitch %.0f",
|
||||||
droidGetName(psDroid),
|
droidGetName(psDroid),
|
||||||
100 - clip(PERCENT(psDroid->body, psDroid->originalBody), 0, 100), psDroid->id,
|
100 - clip(PERCENT(psDroid->body, psDroid->originalBody), 0, 100), psDroid->id,
|
||||||
psDroid->experience/65536.f, getDroidLevelName(psDroid), getDroidOrderName(psDroid->order), getDroidActionName(psDroid->action),
|
psDroid->experience/65536.f, getDroidLevelName(psDroid), getDroidOrderName(psDroid->order.type), getDroidActionName(psDroid->action),
|
||||||
droidSensorRange(psDroid), droidConcealment(psDroid), UNDEG(psDroid->rot.pitch)));
|
droidSensorRange(psDroid), droidConcealment(psDroid), UNDEG(psDroid->rot.pitch)));
|
||||||
FeedbackOrderGiven();
|
FeedbackOrderGiven();
|
||||||
}
|
}
|
||||||
|
@ -1831,7 +1831,7 @@ static void dealWithLMBDroid(DROID* psDroid, SELECTION_TYPE selection)
|
||||||
"%s - Damage %d%% - Serial ID %d - Experience %f order %d action %d, %s",
|
"%s - Damage %d%% - Serial ID %d - Experience %f order %d action %d, %s",
|
||||||
droidGetName(psDroid),
|
droidGetName(psDroid),
|
||||||
100 - clip(PERCENT(psDroid->body, psDroid->originalBody), 0, 100),
|
100 - clip(PERCENT(psDroid->body, psDroid->originalBody), 0, 100),
|
||||||
psDroid->id, psDroid->experience/65536.f, psDroid->order,
|
psDroid->id, psDroid->experience/65536.f, psDroid->order.type,
|
||||||
psDroid->action, getDroidLevelName(psDroid)));
|
psDroid->action, getDroidLevelName(psDroid)));
|
||||||
|
|
||||||
FeedbackOrderGiven();
|
FeedbackOrderGiven();
|
||||||
|
@ -2020,11 +2020,11 @@ static void dealWithLMBFeature(FEATURE* psFeature)
|
||||||
|
|
||||||
if (ctrlShiftDown())
|
if (ctrlShiftDown())
|
||||||
{
|
{
|
||||||
orderDroidStatsLocDirAdd(psCurr, DORDER_BUILD, (BASE_STATS*) &asStructureStats[i], psFeature->pos.x, psFeature->pos.y, player.r.y);
|
orderDroidStatsLocDirAdd(psCurr, DORDER_BUILD, &asStructureStats[i], psFeature->pos.x, psFeature->pos.y, player.r.y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
orderDroidStatsLocDir(psCurr, DORDER_BUILD, (BASE_STATS*) &asStructureStats[i], psFeature->pos.x, psFeature->pos.y, player.r.y, ModeQueue);
|
orderDroidStatsLocDir(psCurr, DORDER_BUILD, &asStructureStats[i], psFeature->pos.x, psFeature->pos.y, player.r.y, ModeQueue);
|
||||||
}
|
}
|
||||||
FeedbackOrderGiven();
|
FeedbackOrderGiven();
|
||||||
}
|
}
|
||||||
|
@ -2382,7 +2382,7 @@ static void dealWithRMB( void )
|
||||||
"%s - Damage %d%% - ID %d - experience %f, %s - order %s - action %s - sensor range %hu - ECM %u",
|
"%s - Damage %d%% - ID %d - experience %f, %s - order %s - action %s - sensor range %hu - ECM %u",
|
||||||
droidGetName(psDroid),
|
droidGetName(psDroid),
|
||||||
100 - clip(PERCENT(psDroid->body, psDroid->originalBody), 0, 100), psDroid->id,
|
100 - clip(PERCENT(psDroid->body, psDroid->originalBody), 0, 100), psDroid->id,
|
||||||
psDroid->experience/65536.f, getDroidLevelName(psDroid), getDroidOrderName(psDroid->order), getDroidActionName(psDroid->action),
|
psDroid->experience/65536.f, getDroidLevelName(psDroid), getDroidOrderName(psDroid->order.type), getDroidActionName(psDroid->action),
|
||||||
droidSensorRange(psDroid), droidConcealment(psDroid)));
|
droidSensorRange(psDroid), droidConcealment(psDroid)));
|
||||||
FeedbackOrderGiven();
|
FeedbackOrderGiven();
|
||||||
}
|
}
|
||||||
|
@ -2394,7 +2394,7 @@ static void dealWithRMB( void )
|
||||||
"%s - Damage %d%% - Serial ID %d - Experience %f order %d action %d, %s",
|
"%s - Damage %d%% - Serial ID %d - Experience %f order %d action %d, %s",
|
||||||
droidGetName(psDroid),
|
droidGetName(psDroid),
|
||||||
100 - clip(PERCENT(psDroid->body, psDroid->originalBody), 0, 100),
|
100 - clip(PERCENT(psDroid->body, psDroid->originalBody), 0, 100),
|
||||||
psDroid->id, psDroid->experience/65536.f, psDroid->order,
|
psDroid->id, psDroid->experience/65536.f, psDroid->order.type,
|
||||||
psDroid->action, getDroidLevelName(psDroid)));
|
psDroid->action, getDroidLevelName(psDroid)));
|
||||||
|
|
||||||
FeedbackOrderGiven();
|
FeedbackOrderGiven();
|
||||||
|
|
|
@ -1585,35 +1585,46 @@ static void drawLineBuild(STRUCTURE_STATS const *psStats, int left, int right, i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void renderBuildOrder(int32_t order, void *statsOrStructure, int32_t x, int32_t y, int32_t x2, int32_t y2, uint16_t dir, STRUCT_STATES state)
|
static void renderBuildOrder(DROID_ORDER_DATA const &order, STRUCT_STATES state)
|
||||||
{
|
{
|
||||||
if (!statsOrStructure) return;
|
STRUCTURE_STATS const *stats;
|
||||||
|
Vector2i pos = order.pos;
|
||||||
STRUCTURE_STATS const *stats = (STRUCTURE_STATS const *)statsOrStructure;
|
if (order.type == DORDER_BUILDMODULE)
|
||||||
if (order == DORDER_BUILDMODULE)
|
|
||||||
{
|
{
|
||||||
STRUCTURE const *structure = (STRUCTURE const *)statsOrStructure;
|
STRUCTURE const *structure = castStructure(order.psObj);
|
||||||
|
if (structure == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
stats = getModuleStat(structure);
|
stats = getModuleStat(structure);
|
||||||
x = structure->pos.x;
|
pos = removeZ(structure->pos);
|
||||||
y = structure->pos.y;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stats = order.psStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stats == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw the current build site if its a line of structures
|
//draw the current build site if its a line of structures
|
||||||
if (order == DORDER_LINEBUILD)
|
if (order.type == DORDER_LINEBUILD)
|
||||||
{
|
{
|
||||||
int left, right, up, down;
|
int left, right, up, down;
|
||||||
// a wall (or something like that)
|
// a wall (or something like that)
|
||||||
|
|
||||||
left = MIN(map_coord(x), map_coord(x2));
|
left = MIN(map_coord(pos.x), map_coord(order.pos2.x));
|
||||||
right = MAX(map_coord(x), map_coord(x2));
|
right = MAX(map_coord(pos.x), map_coord(order.pos2.x));
|
||||||
up = MIN(map_coord(y), map_coord(y2));
|
up = MIN(map_coord(pos.y), map_coord(order.pos2.y));
|
||||||
down = MAX(map_coord(y), map_coord(y2));
|
down = MAX(map_coord(pos.y), map_coord(order.pos2.y));
|
||||||
|
|
||||||
drawLineBuild(stats, left, right, up, down, dir, state);
|
drawLineBuild(stats, left, right, up, down, order.direction, state);
|
||||||
}
|
}
|
||||||
if ((order == DORDER_BUILD || order == DORDER_BUILDMODULE) && !tileHasIncompatibleStructure(mapTile(map_coord(x), map_coord(y)), stats))
|
if ((order.type == DORDER_BUILD || order.type == DORDER_BUILDMODULE) && !tileHasIncompatibleStructure(mapTile(map_coord(pos)), stats))
|
||||||
{
|
{
|
||||||
Blueprint blueprint(stats, Vector2i(x, y), dir, state);
|
Blueprint blueprint(stats, pos, order.direction, state);
|
||||||
blueprints.push_back(blueprint);
|
blueprints.push_back(blueprint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1699,12 +1710,11 @@ void displayBlueprints(void)
|
||||||
{
|
{
|
||||||
if (psDroid->droidType == DROID_CONSTRUCT || psDroid->droidType == DROID_CYBORG_CONSTRUCT)
|
if (psDroid->droidType == DROID_CONSTRUCT || psDroid->droidType == DROID_CYBORG_CONSTRUCT)
|
||||||
{
|
{
|
||||||
renderBuildOrder(psDroid->order, psDroid->psTarStats, psDroid->orderX, psDroid->orderY, psDroid->orderX2, psDroid->orderY2, psDroid->orderDirection, state);
|
renderBuildOrder(psDroid->order, state);
|
||||||
//now look thru' the list of orders to see if more building sites
|
//now look thru' the list of orders to see if more building sites
|
||||||
for (int order = psDroid->listPendingBegin; order < (int)psDroid->asOrderList.size(); order++)
|
for (int order = psDroid->listPendingBegin; order < (int)psDroid->asOrderList.size(); order++)
|
||||||
{
|
{
|
||||||
OrderListEntry const *o = &psDroid->asOrderList[order];
|
renderBuildOrder(psDroid->asOrderList[order], state);
|
||||||
renderBuildOrder(o->order, o->psOrderTarget, o->x, o->y, o->x2, o->y2, o->direction, state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4270,11 +4280,11 @@ static void doConstructionLines( void )
|
||||||
{
|
{
|
||||||
if(psDroid->action == DACTION_BUILD)
|
if(psDroid->action == DACTION_BUILD)
|
||||||
{
|
{
|
||||||
if (psDroid->psTarget)
|
if (psDroid->order.psObj)
|
||||||
{
|
{
|
||||||
if (psDroid->psTarget->type == OBJ_STRUCTURE)
|
if (psDroid->order.psObj->type == OBJ_STRUCTURE)
|
||||||
{
|
{
|
||||||
addConstructionLine(psDroid, (STRUCTURE*)psDroid->psTarget);
|
addConstructionLine(psDroid, (STRUCTURE*)psDroid->order.psObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -459,7 +459,7 @@ static void driveMoveFollower(DROID *psDroid)
|
||||||
//psDroid->secondaryOrder&=~DSS_MOVEHOLD_SET; // Remove secondary order ... this stops the droid from jumping back to GUARD mode ... see order.c #111 - tjc
|
//psDroid->secondaryOrder&=~DSS_MOVEHOLD_SET; // Remove secondary order ... this stops the droid from jumping back to GUARD mode ... see order.c #111 - tjc
|
||||||
secondarySetState(psDroid, DSO_HALTTYPE, DSS_HALT_GUARD);
|
secondarySetState(psDroid, DSO_HALTTYPE, DSS_HALT_GUARD);
|
||||||
// if the droid is currently guarding we need to change the order to a move
|
// if the droid is currently guarding we need to change the order to a move
|
||||||
if (psDroid->order==DORDER_GUARD)
|
if (psDroid->order.type == DORDER_GUARD)
|
||||||
{
|
{
|
||||||
orderDroidLoc(psDroid, DORDER_MOVE, psDrivenDroid->pos.x, psDrivenDroid->pos.y, ModeQueue);
|
orderDroidLoc(psDroid, DORDER_MOVE, psDrivenDroid->pos.x, psDrivenDroid->pos.y, ModeQueue);
|
||||||
}
|
}
|
||||||
|
@ -508,7 +508,7 @@ void driveUpdate(void)
|
||||||
if(psDrivenDroid != NULL) {
|
if(psDrivenDroid != NULL) {
|
||||||
if(bMultiMessages && (driveBumpTime < gameTime)) // send latest info about driven droid.
|
if(bMultiMessages && (driveBumpTime < gameTime)) // send latest info about driven droid.
|
||||||
{
|
{
|
||||||
sendDroidInfo(psDrivenDroid, DORDER_MOVE, psDrivenDroid->pos.x, psDrivenDroid->pos.y, NULL, NULL, 0, 0, 0, false);
|
sendDroidInfo(psDrivenDroid, DroidOrder(DORDER_MOVE, removeZ(psDrivenDroid->pos)), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TO BE DONE:
|
//TO BE DONE:
|
||||||
|
|
|
@ -117,13 +117,13 @@ void cancelBuild(DROID *psDroid)
|
||||||
{
|
{
|
||||||
objTrace(psDroid->id, "Droid build order cancelled");
|
objTrace(psDroid->id, "Droid build order cancelled");
|
||||||
psDroid->action = DACTION_NONE;
|
psDroid->action = DACTION_NONE;
|
||||||
psDroid->order = DORDER_NONE;
|
psDroid->order.type = DORDER_NONE;
|
||||||
setDroidTarget(psDroid, NULL);
|
setDroidTarget(psDroid, NULL);
|
||||||
setDroidActionTarget(psDroid, NULL, 0);
|
setDroidActionTarget(psDroid, NULL, 0);
|
||||||
|
|
||||||
/* Notify scripts we just became idle */
|
/* Notify scripts we just became idle */
|
||||||
psScrCBOrderDroid = psDroid;
|
psScrCBOrderDroid = psDroid;
|
||||||
psScrCBOrder = psDroid->order;
|
psScrCBOrder = psDroid->order.type;
|
||||||
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_DROID_REACH_LOCATION);
|
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_DROID_REACH_LOCATION);
|
||||||
psScrCBOrderDroid = NULL;
|
psScrCBOrderDroid = NULL;
|
||||||
psScrCBOrder = DORDER_NONE;
|
psScrCBOrder = DORDER_NONE;
|
||||||
|
@ -266,7 +266,7 @@ bool droidCheckReferences(DROID *psVictimDroid)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
ASSERT_OR_RETURN(false, (DROID *)psDroid->psTarget != psVictimDroid || psVictimDroid == psDroid, DROIDREF(psDroid->targetFunc, psDroid->targetLine));
|
ASSERT_OR_RETURN(false, psDroid->order.psObj != psVictimDroid || psVictimDroid == psDroid, DROIDREF(psDroid->targetFunc, psDroid->targetLine));
|
||||||
for (i = 0; i < psDroid->numWeaps; i++)
|
for (i = 0; i < psDroid->numWeaps; i++)
|
||||||
{
|
{
|
||||||
ASSERT_OR_RETURN(false, (DROID *)psDroid->psActionTarget[i] != psVictimDroid || psVictimDroid == psDroid,
|
ASSERT_OR_RETURN(false, (DROID *)psDroid->psActionTarget[i] != psVictimDroid || psVictimDroid == psDroid,
|
||||||
|
@ -283,18 +283,19 @@ DROID::DROID(uint32_t id, unsigned player)
|
||||||
, droidType(DROID_ANY)
|
, droidType(DROID_ANY)
|
||||||
, psGroup(NULL)
|
, psGroup(NULL)
|
||||||
, psGrpNext(NULL)
|
, psGrpNext(NULL)
|
||||||
, order(DORDER_NONE)
|
|
||||||
, orderX(0), orderY(0)
|
|
||||||
, orderX2(0), orderY2(0)
|
|
||||||
, orderDirection(0)
|
|
||||||
, psTarget(NULL)
|
|
||||||
, psTarStats(NULL)
|
|
||||||
, secondaryOrder(DSS_ARANGE_DEFAULT | DSS_REPLEV_NEVER | DSS_ALEV_ALWAYS | DSS_HALT_GUARD)
|
, secondaryOrder(DSS_ARANGE_DEFAULT | DSS_REPLEV_NEVER | DSS_ALEV_ALWAYS | DSS_HALT_GUARD)
|
||||||
, action(DACTION_NONE)
|
, action(DACTION_NONE)
|
||||||
, actionPos(0, 0)
|
, actionPos(0, 0)
|
||||||
, psCurAnim(NULL)
|
, psCurAnim(NULL)
|
||||||
, gameCheckDroid(NULL)
|
, gameCheckDroid(NULL)
|
||||||
{
|
{
|
||||||
|
order.type = DORDER_NONE;
|
||||||
|
order.pos = Vector2i(0, 0);
|
||||||
|
order.pos2 = Vector2i(0, 0);
|
||||||
|
order.direction = 0;
|
||||||
|
order.psObj = NULL;
|
||||||
|
order.psStats = NULL;
|
||||||
|
|
||||||
sMove.asPath = NULL;
|
sMove.asPath = NULL;
|
||||||
sMove.Status = MOVEINACTIVE;
|
sMove.Status = MOVEINACTIVE;
|
||||||
}
|
}
|
||||||
|
@ -411,7 +412,7 @@ void removeDroidBase(DROID *psDel)
|
||||||
//ajl, inform others of destruction.
|
//ajl, inform others of destruction.
|
||||||
// Everyone else should be doing this at the same time, assuming it's in synch (so everyone sends a GAME_DROIDDEST message at once)...
|
// Everyone else should be doing this at the same time, assuming it's in synch (so everyone sends a GAME_DROIDDEST message at once)...
|
||||||
if (!isInSync() && bMultiMessages
|
if (!isInSync() && bMultiMessages
|
||||||
&& !(psDel->player != selectedPlayer && psDel->order == DORDER_RECYCLE))
|
&& !(psDel->player != selectedPlayer && psDel->order.type == DORDER_RECYCLE))
|
||||||
{
|
{
|
||||||
ASSERT_OR_RETURN( , droidOnMap(psDel), "Asking other players to destroy droid driving off the map");
|
ASSERT_OR_RETURN( , droidOnMap(psDel), "Asking other players to destroy droid driving off the map");
|
||||||
SendDestroyDroid(psDel);
|
SendDestroyDroid(psDel);
|
||||||
|
@ -521,7 +522,7 @@ static void removeDroidFX(DROID *psDel, unsigned impactTime)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (psDel->droidType == DROID_PERSON && psDel->order != DORDER_RUNBURN)
|
if (psDel->droidType == DROID_PERSON && psDel->order.type != DORDER_RUNBURN)
|
||||||
{
|
{
|
||||||
/* blow person up into blood and guts */
|
/* blow person up into blood and guts */
|
||||||
compPersonToBits(psDel);
|
compPersonToBits(psDel);
|
||||||
|
@ -529,7 +530,7 @@ static void removeDroidFX(DROID *psDel, unsigned impactTime)
|
||||||
|
|
||||||
/* if baba and not running (on fire) then squish */
|
/* if baba and not running (on fire) then squish */
|
||||||
if (psDel->droidType == DROID_PERSON
|
if (psDel->droidType == DROID_PERSON
|
||||||
&& psDel->order != DORDER_RUNBURN
|
&& psDel->order.type != DORDER_RUNBURN
|
||||||
&& psDel->visible[selectedPlayer])
|
&& psDel->visible[selectedPlayer])
|
||||||
{
|
{
|
||||||
// The babarian has been run over ...
|
// The babarian has been run over ...
|
||||||
|
@ -662,7 +663,7 @@ void droidBurn(DROID *psDroid)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (psDroid->order != DORDER_RUNBURN)
|
if (psDroid->order.type != DORDER_RUNBURN)
|
||||||
{
|
{
|
||||||
/* set droid running */
|
/* set droid running */
|
||||||
orderDroid(psDroid, DORDER_RUNBURN, ModeImmediate);
|
orderDroid(psDroid, DORDER_RUNBURN, ModeImmediate);
|
||||||
|
@ -719,7 +720,7 @@ void _syncDebugDroid(const char *function, DROID const *psDroid, char ch)
|
||||||
psDroid->player,
|
psDroid->player,
|
||||||
psDroid->pos.x, psDroid->pos.y, psDroid->pos.z,
|
psDroid->pos.x, psDroid->pos.y, psDroid->pos.z,
|
||||||
psDroid->rot.direction, psDroid->rot.pitch, psDroid->rot.roll,
|
psDroid->rot.direction, psDroid->rot.pitch, psDroid->rot.roll,
|
||||||
psDroid->order, psDroid->orderX, psDroid->orderY, psDroid->listSize,
|
psDroid->order.type, psDroid->order.pos.x, psDroid->order.pos.y, psDroid->listSize,
|
||||||
psDroid->action, actTar,
|
psDroid->action, actTar,
|
||||||
psDroid->secondaryOrder,
|
psDroid->secondaryOrder,
|
||||||
psDroid->body,
|
psDroid->body,
|
||||||
|
@ -998,11 +999,11 @@ bool droidStartBuild(DROID *psDroid)
|
||||||
CHECK_DROID(psDroid);
|
CHECK_DROID(psDroid);
|
||||||
|
|
||||||
/* See if we are starting a new structure */
|
/* See if we are starting a new structure */
|
||||||
if ((psDroid->psTarget == NULL) &&
|
if ((psDroid->order.psObj == NULL) &&
|
||||||
(psDroid->order == DORDER_BUILD ||
|
(psDroid->order.type == DORDER_BUILD ||
|
||||||
psDroid->order == DORDER_LINEBUILD))
|
psDroid->order.type == DORDER_LINEBUILD))
|
||||||
{
|
{
|
||||||
STRUCTURE_STATS *psStructStat = (STRUCTURE_STATS *)psDroid->psTarStats;
|
STRUCTURE_STATS *psStructStat = psDroid->order.psStats;
|
||||||
STRUCTURE_LIMITS *structLimit = &asStructLimits[psDroid->player][psStructStat - asStructureStats];
|
STRUCTURE_LIMITS *structLimit = &asStructLimits[psDroid->player][psStructStat - asStructureStats];
|
||||||
|
|
||||||
//need to check structLimits have not been exceeded
|
//need to check structLimits have not been exceeded
|
||||||
|
@ -1013,14 +1014,14 @@ bool droidStartBuild(DROID *psDroid)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Can't build on burning oil derricks.
|
// Can't build on burning oil derricks.
|
||||||
if (psStructStat->type == REF_RESOURCE_EXTRACTOR && fireOnLocation(psDroid->orderX,psDroid->orderY))
|
if (psStructStat->type == REF_RESOURCE_EXTRACTOR && fireOnLocation(psDroid->order.pos.x,psDroid->order.pos.y))
|
||||||
{
|
{
|
||||||
intBuildFinished(psDroid);
|
intBuildFinished(psDroid);
|
||||||
cancelBuild(psDroid);
|
cancelBuild(psDroid);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//ok to build
|
//ok to build
|
||||||
psStruct = buildStructureDir(psStructStat, psDroid->orderX,psDroid->orderY, psDroid->orderDirection, psDroid->player,false);
|
psStruct = buildStructureDir(psStructStat, psDroid->order.pos.x, psDroid->order.pos.y, psDroid->order.direction, psDroid->player,false);
|
||||||
if (!psStruct)
|
if (!psStruct)
|
||||||
{
|
{
|
||||||
intBuildFinished(psDroid);
|
intBuildFinished(psDroid);
|
||||||
|
@ -1032,7 +1033,7 @@ bool droidStartBuild(DROID *psDroid)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Check the structure is still there to build (joining a partially built struct) */
|
/* Check the structure is still there to build (joining a partially built struct) */
|
||||||
psStruct = (STRUCTURE *)psDroid->psTarget;
|
psStruct = (STRUCTURE *)psDroid->order.psObj;
|
||||||
if (!droidNextToStruct(psDroid, (BASE_OBJECT *)psStruct))
|
if (!droidNextToStruct(psDroid, (BASE_OBJECT *)psStruct))
|
||||||
{
|
{
|
||||||
/* Nope - stop building */
|
/* Nope - stop building */
|
||||||
|
@ -1100,10 +1101,10 @@ bool droidUpdateBuild(DROID *psDroid)
|
||||||
|
|
||||||
CHECK_DROID(psDroid);
|
CHECK_DROID(psDroid);
|
||||||
ASSERT_OR_RETURN(false, psDroid->action == DACTION_BUILD, "%s (order %s) has wrong action for construction: %s",
|
ASSERT_OR_RETURN(false, psDroid->action == DACTION_BUILD, "%s (order %s) has wrong action for construction: %s",
|
||||||
droidGetName(psDroid), getDroidOrderName(psDroid->order), getDroidActionName(psDroid->action));
|
droidGetName(psDroid), getDroidOrderName(psDroid->order.type), getDroidActionName(psDroid->action));
|
||||||
ASSERT_OR_RETURN(false, psDroid->psTarget != NULL, "Trying to update a construction, but no target!");
|
ASSERT_OR_RETURN(false, psDroid->order.psObj != NULL, "Trying to update a construction, but no target!");
|
||||||
|
|
||||||
psStruct = (STRUCTURE *)psDroid->psTarget;
|
psStruct = (STRUCTURE *)psDroid->order.psObj;
|
||||||
ASSERT_OR_RETURN(false, psStruct->type == OBJ_STRUCTURE, "target is not a structure" );
|
ASSERT_OR_RETURN(false, psStruct->type == OBJ_STRUCTURE, "target is not a structure" );
|
||||||
ASSERT_OR_RETURN(false, psDroid->asBits[COMP_CONSTRUCT].nStat < numConstructStats, "Invalid construct pointer for unit" );
|
ASSERT_OR_RETURN(false, psDroid->asBits[COMP_CONSTRUCT].nStat < numConstructStats, "Invalid construct pointer for unit" );
|
||||||
|
|
||||||
|
@ -1113,8 +1114,8 @@ bool droidUpdateBuild(DROID *psDroid)
|
||||||
// Update the interface
|
// Update the interface
|
||||||
intBuildFinished(psDroid);
|
intBuildFinished(psDroid);
|
||||||
// Check if line order build is completed, or we are not carrying out a line order build
|
// Check if line order build is completed, or we are not carrying out a line order build
|
||||||
if ((map_coord(psDroid->orderX) == map_coord(psDroid->orderX2) && map_coord(psDroid->orderY) == map_coord(psDroid->orderY2))
|
if ((map_coord(psDroid->order.pos) == map_coord(psDroid->order.pos2))
|
||||||
|| psDroid->order != DORDER_LINEBUILD)
|
|| psDroid->order.type != DORDER_LINEBUILD)
|
||||||
{
|
{
|
||||||
cancelBuild(psDroid);
|
cancelBuild(psDroid);
|
||||||
}
|
}
|
||||||
|
@ -1165,7 +1166,7 @@ bool droidUpdateDemolishing( DROID *psDroid )
|
||||||
CHECK_DROID(psDroid);
|
CHECK_DROID(psDroid);
|
||||||
|
|
||||||
ASSERT_OR_RETURN(false, psDroid->action == DACTION_DEMOLISH, "unit is not demolishing");
|
ASSERT_OR_RETURN(false, psDroid->action == DACTION_DEMOLISH, "unit is not demolishing");
|
||||||
psStruct = (STRUCTURE *)psDroid->psTarget;
|
psStruct = (STRUCTURE *)psDroid->order.psObj;
|
||||||
ASSERT_OR_RETURN(false, psStruct->type == OBJ_STRUCTURE, "target is not a structure");
|
ASSERT_OR_RETURN(false, psStruct->type == OBJ_STRUCTURE, "target is not a structure");
|
||||||
|
|
||||||
//constructPoints = (asConstructStats + psDroid->asBits[COMP_CONSTRUCT].nStat)->
|
//constructPoints = (asConstructStats + psDroid->asBits[COMP_CONSTRUCT].nStat)->
|
||||||
|
@ -1254,8 +1255,8 @@ bool droidStartRestore( DROID *psDroid )
|
||||||
|
|
||||||
CHECK_DROID(psDroid);
|
CHECK_DROID(psDroid);
|
||||||
|
|
||||||
ASSERT_OR_RETURN(false, psDroid->order == DORDER_RESTORE, "unit is not restoring");
|
ASSERT_OR_RETURN(false, psDroid->order.type == DORDER_RESTORE, "unit is not restoring");
|
||||||
psStruct = (STRUCTURE *)psDroid->psTarget;
|
psStruct = (STRUCTURE *)psDroid->order.psObj;
|
||||||
ASSERT_OR_RETURN(false, psStruct->type == OBJ_STRUCTURE, "target is not a structure");
|
ASSERT_OR_RETURN(false, psStruct->type == OBJ_STRUCTURE, "target is not a structure");
|
||||||
|
|
||||||
psDroid->actionStarted = gameTime;
|
psDroid->actionStarted = gameTime;
|
||||||
|
@ -1277,7 +1278,7 @@ bool droidUpdateRestore( DROID *psDroid )
|
||||||
CHECK_DROID(psDroid);
|
CHECK_DROID(psDroid);
|
||||||
|
|
||||||
ASSERT_OR_RETURN(false, psDroid->action == DACTION_RESTORE, "unit is not restoring");
|
ASSERT_OR_RETURN(false, psDroid->action == DACTION_RESTORE, "unit is not restoring");
|
||||||
psStruct = (STRUCTURE *)psDroid->psTarget;
|
psStruct = (STRUCTURE *)psDroid->order.psObj;
|
||||||
ASSERT_OR_RETURN(false, psStruct->type == OBJ_STRUCTURE, "target is not a structure");
|
ASSERT_OR_RETURN(false, psStruct->type == OBJ_STRUCTURE, "target is not a structure");
|
||||||
ASSERT_OR_RETURN(false, psStruct->pStructureType->resistance != 0, "invalid structure for EW");
|
ASSERT_OR_RETURN(false, psStruct->pStructureType->resistance != 0, "invalid structure for EW");
|
||||||
|
|
||||||
|
@ -2851,20 +2852,16 @@ bool buildModule(STRUCTURE *psStruct)
|
||||||
- if so, helping to build the current one*/
|
- if so, helping to build the current one*/
|
||||||
void setUpBuildModule(DROID *psDroid)
|
void setUpBuildModule(DROID *psDroid)
|
||||||
{
|
{
|
||||||
UDWORD tileX, tileY;
|
Vector2i tile = map_coord(psDroid->order.pos);
|
||||||
STRUCTURE *psStruct;
|
|
||||||
|
|
||||||
tileX = map_coord(psDroid->orderX);
|
|
||||||
tileY = map_coord(psDroid->orderY);
|
|
||||||
|
|
||||||
//check not another Truck started
|
//check not another Truck started
|
||||||
psStruct = getTileStructure(tileX,tileY);
|
STRUCTURE *psStruct = getTileStructure(tile.x, tile.y);
|
||||||
if (psStruct)
|
if (psStruct)
|
||||||
{ // if a droid is currently building, or building is in progress of being built/upgraded the droid's order should be DORDER_HELPBUILD
|
{ // if a droid is currently building, or building is in progress of being built/upgraded the droid's order should be DORDER_HELPBUILD
|
||||||
if (checkDroidsBuilding(psStruct) || !psStruct->status )
|
if (checkDroidsBuilding(psStruct) || !psStruct->status )
|
||||||
{
|
{
|
||||||
//set up the help build scenario
|
//set up the help build scenario
|
||||||
psDroid->order = DORDER_HELPBUILD;
|
psDroid->order.type = DORDER_HELPBUILD;
|
||||||
setDroidTarget(psDroid, (BASE_OBJECT *)psStruct);
|
setDroidTarget(psDroid, (BASE_OBJECT *)psStruct);
|
||||||
if (droidStartBuild(psDroid))
|
if (droidStartBuild(psDroid))
|
||||||
{
|
{
|
||||||
|
@ -2970,10 +2967,9 @@ bool droidUnderRepair(DROID *psDroid)
|
||||||
//look thru the list of players droids to see if any are repairing this droid
|
//look thru the list of players droids to see if any are repairing this droid
|
||||||
for (psCurr = apsDroidLists[psDroid->player]; psCurr != NULL; psCurr = psCurr->psNext)
|
for (psCurr = apsDroidLists[psDroid->player]; psCurr != NULL; psCurr = psCurr->psNext)
|
||||||
{
|
{
|
||||||
//if (psCurr->droidType == DROID_REPAIR && psCurr->action ==
|
|
||||||
if ((psCurr->droidType == DROID_REPAIR || psCurr->droidType ==
|
if ((psCurr->droidType == DROID_REPAIR || psCurr->droidType ==
|
||||||
DROID_CYBORG_REPAIR) && psCurr->action ==
|
DROID_CYBORG_REPAIR) && psCurr->action ==
|
||||||
DACTION_DROIDREPAIR && psCurr->psTarget == (BASE_OBJECT *)psDroid)
|
DACTION_DROIDREPAIR && psCurr->order.psObj == psDroid)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3177,8 +3173,8 @@ bool allVtolsRearmed(DROID *psDroid)
|
||||||
for (psCurr=apsDroidLists[psDroid->player]; psCurr; psCurr=psCurr->psNext)
|
for (psCurr=apsDroidLists[psDroid->player]; psCurr; psCurr=psCurr->psNext)
|
||||||
{
|
{
|
||||||
if (vtolRearming(psCurr) &&
|
if (vtolRearming(psCurr) &&
|
||||||
psCurr->order == psDroid->order &&
|
psCurr->order.type == psDroid->order.type &&
|
||||||
psCurr->psTarget == psDroid->psTarget)
|
psCurr->order.psObj == psDroid->order.psObj)
|
||||||
{
|
{
|
||||||
stillRearming = true;
|
stillRearming = true;
|
||||||
break;
|
break;
|
||||||
|
@ -3552,7 +3548,7 @@ DROID * giftSingleDroid(DROID *psD, UDWORD to)
|
||||||
|
|
||||||
for (psCurr = apsDroidLists[them]; psCurr != NULL; psCurr = psCurr->psNext)
|
for (psCurr = apsDroidLists[them]; psCurr != NULL; psCurr = psCurr->psNext)
|
||||||
{
|
{
|
||||||
if (psCurr->psTarget == (BASE_OBJECT *)psD || psCurr->psActionTarget[0] == (BASE_OBJECT *)psD)
|
if (psCurr->order.psObj == psD || psCurr->psActionTarget[0] == psD)
|
||||||
{
|
{
|
||||||
orderDroid(psCurr, DORDER_STOP, ModeQueue);
|
orderDroid(psCurr, DORDER_STOP, ModeQueue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,7 +420,7 @@ static inline Rotation getInterpolatedWeaponRotation(DROID *psDroid, int weaponS
|
||||||
#define setDroidTarget(_psDroid, _psNewTarget) _setDroidTarget(_psDroid, _psNewTarget, __LINE__, __FUNCTION__)
|
#define setDroidTarget(_psDroid, _psNewTarget) _setDroidTarget(_psDroid, _psNewTarget, __LINE__, __FUNCTION__)
|
||||||
static inline void _setDroidTarget(DROID *psDroid, BASE_OBJECT *psNewTarget, int line, const char *func)
|
static inline void _setDroidTarget(DROID *psDroid, BASE_OBJECT *psNewTarget, int line, const char *func)
|
||||||
{
|
{
|
||||||
psDroid->psTarget = psNewTarget;
|
psDroid->order.psObj = psNewTarget;
|
||||||
ASSERT(psNewTarget == NULL || !psNewTarget->died, "setDroidTarget: Set dead target");
|
ASSERT(psNewTarget == NULL || !psNewTarget->died, "setDroidTarget: Set dead target");
|
||||||
ASSERT(psNewTarget == NULL || !psNewTarget->died || (psNewTarget->died == NOT_CURRENT_LIST && psDroid->died == NOT_CURRENT_LIST),
|
ASSERT(psNewTarget == NULL || !psNewTarget->died || (psNewTarget->died == NOT_CURRENT_LIST && psDroid->died == NOT_CURRENT_LIST),
|
||||||
"setDroidTarget: Set dead target");
|
"setDroidTarget: Set dead target");
|
||||||
|
@ -467,7 +467,7 @@ static inline void _setDroidBase(DROID *psDroid, STRUCTURE *psNewBase, int line,
|
||||||
|
|
||||||
static inline void setSaveDroidTarget(DROID *psSaveDroid, BASE_OBJECT *psNewTarget)
|
static inline void setSaveDroidTarget(DROID *psSaveDroid, BASE_OBJECT *psNewTarget)
|
||||||
{
|
{
|
||||||
psSaveDroid->psTarget = psNewTarget;
|
psSaveDroid->order.psObj = psNewTarget;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
psSaveDroid->targetLine = 0;
|
psSaveDroid->targetLine = 0;
|
||||||
sstrcpy(psSaveDroid->targetFunc, "savegame");
|
sstrcpy(psSaveDroid->targetFunc, "savegame");
|
||||||
|
|
|
@ -83,14 +83,7 @@ struct COMPONENT
|
||||||
UBYTE nStat; ///< Allowing a maximum of 255 stats per file
|
UBYTE nStat; ///< Allowing a maximum of 255 stats per file
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OrderListEntry
|
typedef std::vector<DROID_ORDER_DATA> OrderList;
|
||||||
{
|
|
||||||
DROID_ORDER order;
|
|
||||||
UWORD x, y, x2, y2; ///< line build requires two sets of coords
|
|
||||||
uint16_t direction; ///< Needed to align structures with viewport.
|
|
||||||
void* psOrderTarget; ///< this needs to cope with objects and stats
|
|
||||||
};
|
|
||||||
typedef std::vector<OrderListEntry> OrderList;
|
|
||||||
|
|
||||||
struct DROID_TEMPLATE : public BASE_STATS
|
struct DROID_TEMPLATE : public BASE_STATS
|
||||||
{
|
{
|
||||||
|
@ -174,13 +167,8 @@ struct DROID : public BASE_OBJECT
|
||||||
unsigned listPendingBegin; ///< Index of first order which will not be erased by a pending order. After all messages are processed, the orders in the range [listPendingBegin; listPendingEnd - 1] will remain.
|
unsigned listPendingBegin; ///< Index of first order which will not be erased by a pending order. After all messages are processed, the orders in the range [listPendingBegin; listPendingEnd - 1] will remain.
|
||||||
|
|
||||||
/* Order data */
|
/* Order data */
|
||||||
DROID_ORDER order;
|
DROID_ORDER_DATA order;
|
||||||
UWORD orderX, orderY;
|
|
||||||
UWORD orderX2, orderY2;
|
|
||||||
uint16_t orderDirection;
|
|
||||||
|
|
||||||
BASE_OBJECT* psTarget; ///< Order target
|
|
||||||
BASE_STATS* psTarStats; ///< What to build etc
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// these are to help tracking down dangling pointers
|
// these are to help tracking down dangling pointers
|
||||||
char targetFunc[MAX_EVENT_NAME_LEN];
|
char targetFunc[MAX_EVENT_NAME_LEN];
|
||||||
|
|
|
@ -487,7 +487,7 @@ FPATH_RETVAL fpathDroidRoute(DROID* psDroid, SDWORD tX, SDWORD tY, FPATH_MOVETYP
|
||||||
}
|
}
|
||||||
objTrace(psDroid->id, "Want to go to (%d, %d) -> (%d, %d), going (%d, %d) -> (%d, %d)", map_coord(psDroid->pos.x), map_coord(psDroid->pos.y), map_coord(tX), map_coord(tY), map_coord(startPos.x), map_coord(startPos.y), map_coord(endPos.x), map_coord(endPos.y));
|
objTrace(psDroid->id, "Want to go to (%d, %d) -> (%d, %d), going (%d, %d) -> (%d, %d)", map_coord(psDroid->pos.x), map_coord(psDroid->pos.y), map_coord(tX), map_coord(tY), map_coord(startPos.x), map_coord(startPos.y), map_coord(endPos.x), map_coord(endPos.y));
|
||||||
}
|
}
|
||||||
switch (psDroid->order)
|
switch (psDroid->order.type)
|
||||||
{
|
{
|
||||||
case DORDER_BUILD:
|
case DORDER_BUILD:
|
||||||
case DORDER_HELPBUILD: // help to build a structure
|
case DORDER_HELPBUILD: // help to build a structure
|
||||||
|
|
|
@ -98,6 +98,8 @@ bool fpathBlockingTile(SDWORD x, SDWORD y, PROPULSION_TYPE propulsion);
|
||||||
bool fpathDroidBlockingTile(DROID *psDroid, int x, int y, FPATH_MOVETYPE moveType);
|
bool fpathDroidBlockingTile(DROID *psDroid, int x, int y, FPATH_MOVETYPE moveType);
|
||||||
bool fpathBaseBlockingTile(SDWORD x, SDWORD y, PROPULSION_TYPE propulsion, int player, FPATH_MOVETYPE moveType);
|
bool fpathBaseBlockingTile(SDWORD x, SDWORD y, PROPULSION_TYPE propulsion, int player, FPATH_MOVETYPE moveType);
|
||||||
|
|
||||||
|
static inline bool fpathBlockingTile(Vector2i tile, PROPULSION_TYPE propulsion) { return fpathBlockingTile(tile.x, tile.y, propulsion); }
|
||||||
|
|
||||||
/** Set a direct path to position.
|
/** Set a direct path to position.
|
||||||
*
|
*
|
||||||
* Plan a path from @c psDroid's current position to given position without
|
* Plan a path from @c psDroid's current position to given position without
|
||||||
|
|
34
src/game.cpp
34
src/game.cpp
|
@ -4009,7 +4009,7 @@ static bool loadSaveDroidPointers(const QString &pFileName, DROID **ppsCurrentDr
|
||||||
OBJECT_TYPE ttype = (OBJECT_TYPE)ini.value("target/type", 0).toInt();
|
OBJECT_TYPE ttype = (OBJECT_TYPE)ini.value("target/type", 0).toInt();
|
||||||
ASSERT(tid >= 0 && tplayer >= 0, "Bad ID");
|
ASSERT(tid >= 0 && tplayer >= 0, "Bad ID");
|
||||||
setSaveDroidTarget(psDroid, getBaseObjFromData(tid, tplayer, ttype));
|
setSaveDroidTarget(psDroid, getBaseObjFromData(tid, tplayer, ttype));
|
||||||
ASSERT(psDroid->psTarget, "Failed to find target");
|
ASSERT(psDroid->order.psObj, "Failed to find target");
|
||||||
}
|
}
|
||||||
if (ini.contains("baseStruct/id"))
|
if (ini.contains("baseStruct/id"))
|
||||||
{
|
{
|
||||||
|
@ -4154,13 +4154,9 @@ static bool loadSaveDroid(const char *pFileName, DROID **ppsCurrentDroidLists)
|
||||||
psDroid->burnDamage = ini.value("burnDamage", 0).toInt();
|
psDroid->burnDamage = ini.value("burnDamage", 0).toInt();
|
||||||
psDroid->burnStart = ini.value("burnStart", 0).toInt();
|
psDroid->burnStart = ini.value("burnStart", 0).toInt();
|
||||||
psDroid->experience = ini.value("experience", 0).toInt();
|
psDroid->experience = ini.value("experience", 0).toInt();
|
||||||
psDroid->order = (DROID_ORDER)ini.value("order/type", DORDER_NONE).toInt();
|
psDroid->order.type = (DROID_ORDER)ini.value("order/type", DORDER_NONE).toInt();
|
||||||
tmp = ini.vector2i("order/pos");
|
psDroid->order.pos = ini.vector2i("order/pos");
|
||||||
psDroid->orderX = tmp.x;
|
psDroid->order.pos2 = ini.vector2i("order/pos2");
|
||||||
psDroid->orderY = tmp.y;
|
|
||||||
tmp = ini.vector2i("order/pos2");
|
|
||||||
psDroid->orderX2 = tmp.x;
|
|
||||||
psDroid->orderY2 = tmp.y;
|
|
||||||
psDroid->timeLastHit = ini.value("timeLastHit", UDWORD_MAX).toInt();
|
psDroid->timeLastHit = ini.value("timeLastHit", UDWORD_MAX).toInt();
|
||||||
psDroid->secondaryOrder = ini.value("secondaryOrder", DSS_NONE).toInt();
|
psDroid->secondaryOrder = ini.value("secondaryOrder", DSS_NONE).toInt();
|
||||||
psDroid->action = (DROID_ACTION)ini.value("action", DACTION_NONE).toInt();
|
psDroid->action = (DROID_ACTION)ini.value("action", DACTION_NONE).toInt();
|
||||||
|
@ -4184,8 +4180,8 @@ static bool loadSaveDroid(const char *pFileName, DROID **ppsCurrentDroidLists)
|
||||||
{
|
{
|
||||||
QString targetStat = ini.value("targetStats").toString();
|
QString targetStat = ini.value("targetStats").toString();
|
||||||
int tid = getStructStatFromName(targetStat.toUtf8().constData());
|
int tid = getStructStatFromName(targetStat.toUtf8().constData());
|
||||||
psDroid->psTarStats = (BASE_STATS*)&asStructureStats[tid];
|
psDroid->order.psStats = &asStructureStats[tid];
|
||||||
ASSERT(psDroid->psTarStats, "Target stats not found %s", targetStat.toUtf8().constData());
|
ASSERT(psDroid->order.psStats, "Target stats not found %s", targetStat.toUtf8().constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
psDroid->group = ini.value("group", UBYTE_MAX).toInt();
|
psDroid->group = ini.value("group", UBYTE_MAX).toInt();
|
||||||
|
@ -4318,15 +4314,15 @@ static bool writeDroid(WzConfig &ini, DROID *psCurr, bool onMission)
|
||||||
ini.setValue("born", psCurr->born);
|
ini.setValue("born", psCurr->born);
|
||||||
if (psCurr->lastFrustratedTime > 0) ini.setValue("lastFrustratedTime", psCurr->lastFrustratedTime);
|
if (psCurr->lastFrustratedTime > 0) ini.setValue("lastFrustratedTime", psCurr->lastFrustratedTime);
|
||||||
if (psCurr->experience > 0) ini.setValue("experience", psCurr->experience);
|
if (psCurr->experience > 0) ini.setValue("experience", psCurr->experience);
|
||||||
ini.setValue("order/type", psCurr->order);
|
ini.setValue("order/type", psCurr->order.type);
|
||||||
ini.setVector2i("order/pos", Vector2i(psCurr->orderX, psCurr->orderY));
|
ini.setVector2i("order/pos", Vector2i(psCurr->order.pos));
|
||||||
ini.setVector2i("order/pos2", Vector2i(psCurr->orderX2, psCurr->orderY2));
|
ini.setVector2i("order/pos2", Vector2i(psCurr->order.pos2));
|
||||||
if (psCurr->timeLastHit != UDWORD_MAX) ini.setValue("timeLastHit", psCurr->timeLastHit);
|
if (psCurr->timeLastHit != UDWORD_MAX) ini.setValue("timeLastHit", psCurr->timeLastHit);
|
||||||
if (psCurr->psTarget != NULL)
|
if (psCurr->order.psObj != NULL)
|
||||||
{
|
{
|
||||||
ini.setValue("target/id", psCurr->psTarget->id);
|
ini.setValue("target/id", psCurr->order.psObj->id);
|
||||||
ini.setValue("target/player", psCurr->psTarget->player);
|
ini.setValue("target/player", psCurr->order.psObj->player);
|
||||||
ini.setValue("target/type", psCurr->psTarget->type);
|
ini.setValue("target/type", psCurr->order.psObj->type);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
ini.setValue("target/debugfunc", QString::fromUtf8(psCurr->targetFunc));
|
ini.setValue("target/debugfunc", QString::fromUtf8(psCurr->targetFunc));
|
||||||
ini.setValue("target/debugline", psCurr->targetLine);
|
ini.setValue("target/debugline", psCurr->targetLine);
|
||||||
|
@ -4337,9 +4333,9 @@ static bool writeDroid(WzConfig &ini, DROID *psCurr, bool onMission)
|
||||||
ini.setVector2i("action/pos", psCurr->actionPos);
|
ini.setVector2i("action/pos", psCurr->actionPos);
|
||||||
ini.setValue("actionStarted", psCurr->actionStarted);
|
ini.setValue("actionStarted", psCurr->actionStarted);
|
||||||
ini.setValue("actionPoints", psCurr->actionPoints);
|
ini.setValue("actionPoints", psCurr->actionPoints);
|
||||||
if (psCurr->psTarStats != NULL)
|
if (psCurr->order.psStats != NULL)
|
||||||
{
|
{
|
||||||
ini.setValue("targetStats", psCurr->psTarStats->pName);
|
ini.setValue("targetStats", psCurr->order.psStats->pName);
|
||||||
}
|
}
|
||||||
if (psCurr->psBaseStruct != NULL)
|
if (psCurr->psBaseStruct != NULL)
|
||||||
{
|
{
|
||||||
|
|
19
src/hci.cpp
19
src/hci.cpp
|
@ -1837,11 +1837,11 @@ INT_RETVAL intRunWidgets(void)
|
||||||
&& intNumSelectedDroids(DROID_CYBORG_CONSTRUCT) == 0
|
&& intNumSelectedDroids(DROID_CYBORG_CONSTRUCT) == 0
|
||||||
&& psObjSelected != NULL && isConstructionDroid(psObjSelected))
|
&& psObjSelected != NULL && isConstructionDroid(psObjSelected))
|
||||||
{
|
{
|
||||||
orderDroidStatsTwoLocDir((DROID *)psObjSelected, DORDER_LINEBUILD, psPositionStats, structX, structY, structX2, structY2, player.r.y, ModeQueue);
|
orderDroidStatsTwoLocDir((DROID *)psObjSelected, DORDER_LINEBUILD, (STRUCTURE_STATS *)psPositionStats, structX, structY, structX2, structY2, player.r.y, ModeQueue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
orderSelectedStatsTwoLocDir(selectedPlayer, DORDER_LINEBUILD, psPositionStats, structX, structY, structX2, structY2, player.r.y, ctrlShiftDown());
|
orderSelectedStatsTwoLocDir(selectedPlayer, DORDER_LINEBUILD, (STRUCTURE_STATS *)psPositionStats, structX, structY, structX2, structY2, player.r.y, ctrlShiftDown());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1882,11 +1882,11 @@ INT_RETVAL intRunWidgets(void)
|
||||||
&& intNumSelectedDroids(DROID_CYBORG_CONSTRUCT) == 0
|
&& intNumSelectedDroids(DROID_CYBORG_CONSTRUCT) == 0
|
||||||
&& psObjSelected != NULL)
|
&& psObjSelected != NULL)
|
||||||
{
|
{
|
||||||
orderDroidStatsLocDir((DROID *)psObjSelected, DORDER_BUILD, psPositionStats, structX, structY, player.r.y, ModeQueue);
|
orderDroidStatsLocDir((DROID *)psObjSelected, DORDER_BUILD, (STRUCTURE_STATS *)psPositionStats, structX, structY, player.r.y, ModeQueue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
orderSelectedStatsLocDir(selectedPlayer, DORDER_BUILD, psPositionStats, structX, structY, player.r.y, ctrlShiftDown());
|
orderSelectedStatsLocDir(selectedPlayer, DORDER_BUILD, (STRUCTURE_STATS *)psPositionStats, structX, structY, player.r.y, ctrlShiftDown());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3067,8 +3067,7 @@ void intBuildStarted(DROID *psDroid)
|
||||||
{
|
{
|
||||||
if (psCurr == psDroid)
|
if (psCurr == psDroid)
|
||||||
{
|
{
|
||||||
intSetStats(droidID + IDOBJ_STATSTART, ((BASE_STATS *)(
|
intSetStats(droidID + IDOBJ_STATSTART, ((STRUCTURE *)psCurr->order.psObj)->pStructureType);
|
||||||
(STRUCTURE *)psCurr->psTarget)->pStructureType));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
droidID++;
|
droidID++;
|
||||||
|
@ -5328,13 +5327,13 @@ static BASE_STATS *getConstructionStats(BASE_OBJECT *psObj)
|
||||||
return Stats;
|
return Stats;
|
||||||
}
|
}
|
||||||
else if ((Structure = orderStateObj(psDroid, DORDER_BUILD))
|
else if ((Structure = orderStateObj(psDroid, DORDER_BUILD))
|
||||||
&& psDroid->order == DORDER_BUILD) // Is building
|
&& psDroid->order.type == DORDER_BUILD) // Is building
|
||||||
{
|
{
|
||||||
return psDroid->psTarStats;
|
return psDroid->order.psStats;
|
||||||
}
|
}
|
||||||
else if ((Structure = orderStateObj(psDroid, DORDER_HELPBUILD))
|
else if ((Structure = orderStateObj(psDroid, DORDER_HELPBUILD))
|
||||||
&& (psDroid->order == DORDER_HELPBUILD
|
&& (psDroid->order.type == DORDER_HELPBUILD
|
||||||
|| psDroid->order == DORDER_LINEBUILD)) // Is helping
|
|| psDroid->order.type == DORDER_LINEBUILD)) // Is helping
|
||||||
{
|
{
|
||||||
return (BASE_STATS*)((STRUCTURE*)Structure)->pStructureType;
|
return (BASE_STATS*)((STRUCTURE*)Structure)->pStructureType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3092,7 +3092,7 @@ void missionDestroyObjects(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (psDroid->psTarget && psDroid->psTarget->died)
|
if (psDroid->order.psObj && psDroid->order.psObj->died)
|
||||||
{
|
{
|
||||||
setDroidTarget(psDroid, NULL);
|
setDroidTarget(psDroid, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1736,7 +1736,7 @@ static void moveUpdatePersonModel(DROID *psDroid, SDWORD speed, uint16_t directi
|
||||||
if ( moveDroidStopped( psDroid, speed ) == true )
|
if ( moveDroidStopped( psDroid, speed ) == true )
|
||||||
{
|
{
|
||||||
if ( psDroid->droidType == DROID_PERSON &&
|
if ( psDroid->droidType == DROID_PERSON &&
|
||||||
psDroid->order != DORDER_RUNBURN &&
|
psDroid->order.type != DORDER_RUNBURN &&
|
||||||
(psDroid->action == DACTION_ATTACK ||
|
(psDroid->action == DACTION_ATTACK ||
|
||||||
psDroid->action == DACTION_ROTATETOATTACK) )
|
psDroid->action == DACTION_ROTATETOATTACK) )
|
||||||
{
|
{
|
||||||
|
@ -1791,7 +1791,7 @@ static void moveUpdatePersonModel(DROID *psDroid, SDWORD speed, uint16_t directi
|
||||||
|
|
||||||
/* update anim if moving and not on fire */
|
/* update anim if moving and not on fire */
|
||||||
if ( psDroid->droidType == DROID_PERSON && speed != 0 &&
|
if ( psDroid->droidType == DROID_PERSON && speed != 0 &&
|
||||||
psDroid->order != DORDER_RUNBURN )
|
psDroid->order.type != DORDER_RUNBURN )
|
||||||
{
|
{
|
||||||
/* remove previous anim */
|
/* remove previous anim */
|
||||||
if ( psDroid->psCurAnim != NULL &&
|
if ( psDroid->psCurAnim != NULL &&
|
||||||
|
@ -2157,7 +2157,7 @@ bool moveCheckDroidMovingAndVisible( void *psObj )
|
||||||
|
|
||||||
/* check for dead, not moving or invisible to player */
|
/* check for dead, not moving or invisible to player */
|
||||||
if ( psDroid->died || moveDroidStopped( psDroid, 0 ) ||
|
if ( psDroid->died || moveDroidStopped( psDroid, 0 ) ||
|
||||||
(psDroid->droidType == DROID_TRANSPORTER && psDroid->order == DORDER_NONE) ||
|
(psDroid->droidType == DROID_TRANSPORTER && psDroid->order.type == DORDER_NONE) ||
|
||||||
!(psDroid->visible[selectedPlayer]) )
|
!(psDroid->visible[selectedPlayer]) )
|
||||||
{
|
{
|
||||||
psDroid->iAudioID = NO_SOUND;
|
psDroid->iAudioID = NO_SOUND;
|
||||||
|
|
|
@ -79,8 +79,8 @@ struct QueuedDroidInfo
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (x != z.x) return x < z.x ? -1 : 1;
|
if (pos.x != z.pos.x) return pos.x < z.pos.x ? -1 : 1;
|
||||||
if (y != z.y) return y < z.y ? -1 : 1;
|
if (pos.y != z.pos.y) return pos.y < z.pos.y ? -1 : 1;
|
||||||
}
|
}
|
||||||
if (order == DORDER_BUILD || order == DORDER_LINEBUILD)
|
if (order == DORDER_BUILD || order == DORDER_LINEBUILD)
|
||||||
{
|
{
|
||||||
|
@ -89,8 +89,8 @@ struct QueuedDroidInfo
|
||||||
}
|
}
|
||||||
if (order == DORDER_LINEBUILD)
|
if (order == DORDER_LINEBUILD)
|
||||||
{
|
{
|
||||||
if (x2 != z.x2) return x2 < z.x2 ? -1 : 1;
|
if (pos2.x != z.pos2.x) return pos2.x < z.pos2.x ? -1 : 1;
|
||||||
if (y2 != z.y2) return y2 < z.y2 ? -1 : 1;
|
if (pos2.y != z.pos2.y) return pos2.y < z.pos2.y ? -1 : 1;
|
||||||
}
|
}
|
||||||
if (add != z.add) return add < z.add ? -1 : 1;
|
if (add != z.add) return add < z.add ? -1 : 1;
|
||||||
break;
|
break;
|
||||||
|
@ -109,12 +109,11 @@ struct QueuedDroidInfo
|
||||||
DROID_ORDER order;
|
DROID_ORDER order;
|
||||||
uint32_t destId; // if (subType == ObjOrder)
|
uint32_t destId; // if (subType == ObjOrder)
|
||||||
OBJECT_TYPE destType; // if (subType == ObjOrder)
|
OBJECT_TYPE destType; // if (subType == ObjOrder)
|
||||||
uint32_t x; // if (subType == LocOrder)
|
Vector2i pos; // if (subType == LocOrder)
|
||||||
uint32_t y; // if (subType == LocOrder)
|
uint32_t y; // if (subType == LocOrder)
|
||||||
uint32_t structRef; // if (order == DORDER_BUILD || order == DORDER_LINEBUILD)
|
uint32_t structRef; // if (order == DORDER_BUILD || order == DORDER_LINEBUILD)
|
||||||
uint16_t direction; // if (order == DORDER_BUILD || order == DORDER_LINEBUILD)
|
uint16_t direction; // if (order == DORDER_BUILD || order == DORDER_LINEBUILD)
|
||||||
uint32_t x2; // if (order == DORDER_LINEBUILD)
|
Vector2i pos2; // if (order == DORDER_LINEBUILD)
|
||||||
uint32_t y2; // if (order == DORDER_LINEBUILD)
|
|
||||||
bool add;
|
bool add;
|
||||||
// subType == SecondaryOrder
|
// subType == SecondaryOrder
|
||||||
SECONDARY_ORDER secOrder;
|
SECONDARY_ORDER secOrder;
|
||||||
|
@ -231,9 +230,9 @@ bool recvDroidEmbark(NETQUEUE queue)
|
||||||
bDroidRemoved = droidRemove(psDroid, apsDroidLists);
|
bDroidRemoved = droidRemove(psDroid, apsDroidLists);
|
||||||
|
|
||||||
// Init the order for when disembark
|
// Init the order for when disembark
|
||||||
psDroid->order = DORDER_NONE;
|
psDroid->order.type = DORDER_NONE;
|
||||||
setDroidTarget(psDroid, NULL);
|
setDroidTarget(psDroid, NULL);
|
||||||
psDroid->psTarStats = NULL;
|
psDroid->order.psStats = NULL;
|
||||||
|
|
||||||
if (bDroidRemoved)
|
if (bDroidRemoved)
|
||||||
{
|
{
|
||||||
|
@ -479,8 +478,7 @@ static void NETQueuedDroidInfo(QueuedDroidInfo *info)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NETuint32_t(&info->x);
|
NETauto(&info->pos);
|
||||||
NETuint32_t(&info->y);
|
|
||||||
}
|
}
|
||||||
if (info->order == DORDER_BUILD || info->order == DORDER_LINEBUILD)
|
if (info->order == DORDER_BUILD || info->order == DORDER_LINEBUILD)
|
||||||
{
|
{
|
||||||
|
@ -489,8 +487,7 @@ static void NETQueuedDroidInfo(QueuedDroidInfo *info)
|
||||||
}
|
}
|
||||||
if (info->order == DORDER_LINEBUILD)
|
if (info->order == DORDER_LINEBUILD)
|
||||||
{
|
{
|
||||||
NETuint32_t(&info->x2);
|
NETauto(&info->pos2);
|
||||||
NETuint32_t(&info->y2);
|
|
||||||
}
|
}
|
||||||
NETbool(&info->add);
|
NETbool(&info->add);
|
||||||
break;
|
break;
|
||||||
|
@ -538,26 +535,22 @@ void sendQueuedDroidInfo()
|
||||||
queuedOrders.clear();
|
queuedOrders.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
DROID_ORDER_DATA infoToOrderData(QueuedDroidInfo const &info, BASE_STATS const *psStats)
|
DROID_ORDER_DATA infoToOrderData(QueuedDroidInfo const &info, STRUCTURE_STATS const *psStats)
|
||||||
{
|
{
|
||||||
DROID_ORDER_DATA sOrder;
|
DROID_ORDER_DATA sOrder;
|
||||||
|
sOrder.type = info.order;
|
||||||
memset(&sOrder, 0x00, sizeof(sOrder));
|
sOrder.pos = info.pos;
|
||||||
sOrder.order = info.order;
|
sOrder.pos2 = info.pos2;
|
||||||
sOrder.x = info.x;
|
|
||||||
sOrder.y = info.y;
|
|
||||||
sOrder.x2 = info.x2;
|
|
||||||
sOrder.y2 = info.y2;
|
|
||||||
sOrder.direction = info.direction;
|
sOrder.direction = info.direction;
|
||||||
sOrder.psObj = processDroidTarget(info.destType, info.destId);
|
sOrder.psObj = processDroidTarget(info.destType, info.destId);
|
||||||
sOrder.psStats = const_cast<BASE_STATS *>(psStats);
|
sOrder.psStats = const_cast<STRUCTURE_STATS *>(psStats);
|
||||||
|
|
||||||
return sOrder;
|
return sOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////////////////////
|
||||||
// Droid update information
|
// Droid update information
|
||||||
void sendDroidInfo(DROID *psDroid, DROID_ORDER order, uint32_t x, uint32_t y, const BASE_OBJECT *psObj, const BASE_STATS *psStats, uint32_t x2, uint32_t y2, uint16_t direction, bool add)
|
void sendDroidInfo(DROID *psDroid, DroidOrder const &order, bool add)
|
||||||
{
|
{
|
||||||
if (!myResponsibility(psDroid->player))
|
if (!myResponsibility(psDroid->player))
|
||||||
{
|
{
|
||||||
|
@ -569,31 +562,29 @@ void sendDroidInfo(DROID *psDroid, DROID_ORDER order, uint32_t x, uint32_t y, co
|
||||||
|
|
||||||
info.player = psDroid->player;
|
info.player = psDroid->player;
|
||||||
info.droidId = psDroid->id;
|
info.droidId = psDroid->id;
|
||||||
info.subType = psObj != NULL? ObjOrder : LocOrder;
|
info.subType = order.psObj != NULL? ObjOrder : LocOrder;
|
||||||
info.order = order;
|
info.order = order.type;
|
||||||
if (info.subType == ObjOrder)
|
if (info.subType == ObjOrder)
|
||||||
{
|
{
|
||||||
info.destId = psObj->id;
|
info.destId = order.psObj->id;
|
||||||
info.destType = psObj->type;
|
info.destType = order.psObj->type;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info.x = x;
|
info.pos = order.pos;
|
||||||
info.y = y;
|
|
||||||
}
|
}
|
||||||
if (order == DORDER_BUILD || order == DORDER_LINEBUILD)
|
if (order.type == DORDER_BUILD || order.type == DORDER_LINEBUILD)
|
||||||
{
|
{
|
||||||
info.structRef = psStats->ref;
|
info.structRef = order.psStats->ref;
|
||||||
info.direction = direction;
|
info.direction = order.direction;
|
||||||
if (!isConstructionDroid(psDroid))
|
if (!isConstructionDroid(psDroid))
|
||||||
{
|
{
|
||||||
return; // No point ordering things to build if they can't build anything.
|
return; // No point ordering things to build if they can't build anything.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (order == DORDER_LINEBUILD)
|
if (order.type == DORDER_LINEBUILD)
|
||||||
{
|
{
|
||||||
info.x2 = x2;
|
info.pos2 = order.pos2;
|
||||||
info.y2 = y2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
info.add = add;
|
info.add = add;
|
||||||
|
@ -602,7 +593,7 @@ void sendDroidInfo(DROID *psDroid, DROID_ORDER order, uint32_t x, uint32_t y, co
|
||||||
queuedOrders.push_back(info);
|
queuedOrders.push_back(info);
|
||||||
|
|
||||||
// Update pending orders, so the UI knows it happened.
|
// Update pending orders, so the UI knows it happened.
|
||||||
DROID_ORDER_DATA sOrder = infoToOrderData(info, psStats);
|
DROID_ORDER_DATA sOrder = infoToOrderData(info, order.psStats);
|
||||||
if (!add)
|
if (!add)
|
||||||
{
|
{
|
||||||
psDroid->listPendingBegin = psDroid->asOrderList.size();
|
psDroid->listPendingBegin = psDroid->asOrderList.size();
|
||||||
|
@ -637,7 +628,7 @@ bool recvDroidInfo(NETQUEUE queue)
|
||||||
switch (info.subType)
|
switch (info.subType)
|
||||||
{
|
{
|
||||||
case ObjOrder: syncDebug("Order=%s,%d(%d)", getDroidOrderName(info.order), info.destId, info.destType); break;
|
case ObjOrder: syncDebug("Order=%s,%d(%d)", getDroidOrderName(info.order), info.destId, info.destType); break;
|
||||||
case LocOrder: syncDebug("Order=%s,(%d,%d)", getDroidOrderName(info.order), info.x, info.y); break;
|
case LocOrder: syncDebug("Order=%s,(%d,%d)", getDroidOrderName(info.order), info.pos.x, info.pos.y); break;
|
||||||
case SecondaryOrder: syncDebug("SecondaryOrder=%d,%08X", (int)info.secOrder, (int)info.secState); break;
|
case SecondaryOrder: syncDebug("SecondaryOrder=%d,%08X", (int)info.secOrder, (int)info.secState); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -444,18 +444,18 @@ void formAlliance(uint8_t p1, uint8_t p2, bool prop, bool allowAudio, bool allow
|
||||||
// Clear out any attacking orders
|
// Clear out any attacking orders
|
||||||
for (psDroid = apsDroidLists[p1]; psDroid; psDroid = psDroid->psNext) // from -> to
|
for (psDroid = apsDroidLists[p1]; psDroid; psDroid = psDroid->psNext) // from -> to
|
||||||
{
|
{
|
||||||
if (psDroid->order == DORDER_ATTACK
|
if (psDroid->order.type == DORDER_ATTACK
|
||||||
&& psDroid->psTarget
|
&& psDroid->order.psObj
|
||||||
&& psDroid->psTarget->player == p2)
|
&& psDroid->order.psObj->player == p2)
|
||||||
{
|
{
|
||||||
orderDroid(psDroid, DORDER_STOP, ModeImmediate);
|
orderDroid(psDroid, DORDER_STOP, ModeImmediate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (psDroid = apsDroidLists[p2]; psDroid; psDroid = psDroid->psNext) // to -> from
|
for (psDroid = apsDroidLists[p2]; psDroid; psDroid = psDroid->psNext) // to -> from
|
||||||
{
|
{
|
||||||
if (psDroid->order == DORDER_ATTACK
|
if (psDroid->order.type == DORDER_ATTACK
|
||||||
&& psDroid->psTarget
|
&& psDroid->order.psObj
|
||||||
&& psDroid->psTarget->player == p1)
|
&& psDroid->order.psObj->player == p1)
|
||||||
{
|
{
|
||||||
orderDroid(psDroid, DORDER_STOP, ModeImmediate);
|
orderDroid(psDroid, DORDER_STOP, ModeImmediate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,7 @@ extern bool SendDroid (const DROID_TEMPLATE* pTemplate, uint32
|
||||||
extern bool SendDestroyDroid (const DROID* psDroid);
|
extern bool SendDestroyDroid (const DROID* psDroid);
|
||||||
extern bool SendDemolishFinished(STRUCTURE *psS,DROID *psD);
|
extern bool SendDemolishFinished(STRUCTURE *psS,DROID *psD);
|
||||||
void sendQueuedDroidInfo(void); ///< Actually sends the droid orders which were queued by SendDroidInfo.
|
void sendQueuedDroidInfo(void); ///< Actually sends the droid orders which were queued by SendDroidInfo.
|
||||||
void sendDroidInfo(DROID *psDroid, DROID_ORDER order, uint32_t x, uint32_t y, const BASE_OBJECT *psObj, const BASE_STATS *psStats, uint32_t x2, uint32_t y2, uint16_t direction, bool add);
|
void sendDroidInfo(DROID *psDroid, DroidOrder const &order, bool add);
|
||||||
extern bool SendCmdGroup (DROID_GROUP *psGroup, UWORD x, UWORD y, BASE_OBJECT *psObj);
|
extern bool SendCmdGroup (DROID_GROUP *psGroup, UWORD x, UWORD y, BASE_OBJECT *psObj);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -184,10 +184,10 @@ bool recvDemolishFinished(NETQUEUE queue)
|
||||||
// Demolish it
|
// Demolish it
|
||||||
// Should never get here, if in synch.
|
// Should never get here, if in synch.
|
||||||
removeStruct(psStruct, true);
|
removeStruct(psStruct, true);
|
||||||
if (psDroid && psDroid->psTarStats)
|
if (psDroid && psDroid->order.psStats)
|
||||||
{
|
{
|
||||||
// Update droid if reqd
|
// Update droid if reqd
|
||||||
psDroid->psTarStats = NULL;
|
psDroid->order.psStats = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -293,7 +293,7 @@ static PACKAGED_CHECK packageCheck(const DROID *pD)
|
||||||
|
|
||||||
pc.player = pD->player;
|
pc.player = pD->player;
|
||||||
pc.droidID = pD->id;
|
pc.droidID = pD->id;
|
||||||
pc.order = pD->order;
|
pc.order = pD->order.type;
|
||||||
pc.secondaryOrder = pD->secondaryOrder;
|
pc.secondaryOrder = pD->secondaryOrder;
|
||||||
pc.body = pD->body;
|
pc.body = pD->body;
|
||||||
if (pD->body > pD->originalBody)
|
if (pD->body > pD->originalBody)
|
||||||
|
@ -303,14 +303,14 @@ static PACKAGED_CHECK packageCheck(const DROID *pD)
|
||||||
pc.experience = pD->experience;
|
pc.experience = pD->experience;
|
||||||
pc.pos = pD->pos;
|
pc.pos = pD->pos;
|
||||||
pc.rot = pD->rot;
|
pc.rot = pD->rot;
|
||||||
if (pD->order == DORDER_ATTACK)
|
if (pD->order.type == DORDER_ATTACK)
|
||||||
{
|
{
|
||||||
pc.targetID = pD->psTarget->id;
|
pc.targetID = pD->order.psObj->id;
|
||||||
}
|
}
|
||||||
else if (pD->order == DORDER_MOVE)
|
else if (pD->order.type == DORDER_MOVE)
|
||||||
{
|
{
|
||||||
pc.orderX = pD->orderX;
|
pc.orderX = pD->order.pos.x;
|
||||||
pc.orderY = pD->orderY;
|
pc.orderY = pD->order.pos.y;
|
||||||
}
|
}
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
|
@ -422,7 +422,7 @@ bool recvDroidCheck(NETQUEUE queue)
|
||||||
{
|
{
|
||||||
DROID_ORDER_DATA sOrder;
|
DROID_ORDER_DATA sOrder;
|
||||||
memset(&sOrder, 0, sizeof(DROID_ORDER_DATA));
|
memset(&sOrder, 0, sizeof(DROID_ORDER_DATA));
|
||||||
sOrder.order = (DROID_ORDER)pc.order;
|
sOrder.type = (DROID_ORDER)pc.order;
|
||||||
|
|
||||||
debug(LOG_SYNC, "Droid %u out of synch, changing order from %s to %s.", pc.droidID, getDroidOrderName((DROID_ORDER)pc2.order), getDroidOrderName((DROID_ORDER)pc.order));
|
debug(LOG_SYNC, "Droid %u out of synch, changing order from %s to %s.", pc.droidID, getDroidOrderName((DROID_ORDER)pc2.order), getDroidOrderName((DROID_ORDER)pc.order));
|
||||||
turnOffMultiMsg(true);
|
turnOffMultiMsg(true);
|
||||||
|
|
775
src/order.cpp
775
src/order.cpp
File diff suppressed because it is too large
Load Diff
12
src/order.h
12
src/order.h
|
@ -72,16 +72,16 @@ void orderDroidObj(DROID *psDroid, DROID_ORDER order, BASE_OBJECT *psObj, QUEUE_
|
||||||
extern BASE_OBJECT* orderStateObj(DROID *psDroid, DROID_ORDER order);
|
extern BASE_OBJECT* orderStateObj(DROID *psDroid, DROID_ORDER order);
|
||||||
|
|
||||||
/** \brief Sends an order with a location and a stat to a droid. */
|
/** \brief Sends an order with a location and a stat to a droid. */
|
||||||
void orderDroidStatsLocDir(DROID *psDroid, DROID_ORDER order, BASE_STATS *psStats, UDWORD x, UDWORD y, uint16_t direction, QUEUE_MODE mode);
|
void orderDroidStatsLocDir(DROID *psDroid, DROID_ORDER order, STRUCTURE_STATS *psStats, UDWORD x, UDWORD y, uint16_t direction, QUEUE_MODE mode);
|
||||||
|
|
||||||
/** \brief Gets the state of a droid order with a location and a stat. */
|
/** \brief Gets the state of a droid order with a location and a stat. */
|
||||||
extern bool orderStateStatsLoc(DROID *psDroid, DROID_ORDER order, BASE_STATS **ppsStats, UDWORD *pX, UDWORD *pY);
|
extern bool orderStateStatsLoc(DROID *psDroid, DROID_ORDER order, BASE_STATS **ppsStats, UDWORD *pX, UDWORD *pY);
|
||||||
|
|
||||||
/** \brief Sends an order with a location and a stat to a droid. */
|
/** \brief Sends an order with a location and a stat to a droid. */
|
||||||
void orderDroidStatsTwoLocDir(DROID *psDroid, DROID_ORDER order, BASE_STATS *psStats, UDWORD x1, UDWORD y1, UDWORD x2, UDWORD y2, uint16_t direction, QUEUE_MODE mode);
|
void orderDroidStatsTwoLocDir(DROID *psDroid, DROID_ORDER order, STRUCTURE_STATS *psStats, UDWORD x1, UDWORD y1, UDWORD x2, UDWORD y2, uint16_t direction, QUEUE_MODE mode);
|
||||||
|
|
||||||
/** \brief Sends an order with two locations and a stat to a droid. */
|
/** \brief Sends an order with two locations and a stat to a droid. */
|
||||||
void orderDroidStatsTwoLocDirAdd(DROID *psDroid, DROID_ORDER order, BASE_STATS *psStats, UDWORD x1, UDWORD y1, UDWORD x2, UDWORD y2, uint16_t direction);
|
void orderDroidStatsTwoLocDirAdd(DROID *psDroid, DROID_ORDER order, STRUCTURE_STATS *psStats, UDWORD x1, UDWORD y1, UDWORD x2, UDWORD y2, uint16_t direction);
|
||||||
|
|
||||||
/** \brief Sends an order with a location target to all selected droids. add = true queues the order. */
|
/** \brief Sends an order with a location target to all selected droids. add = true queues the order. */
|
||||||
extern void orderSelectedLoc(uint32_t player, uint32_t x, uint32_t y, bool add);
|
extern void orderSelectedLoc(uint32_t player, uint32_t x, uint32_t y, bool add);
|
||||||
|
@ -100,13 +100,13 @@ void orderDroidAddPending(DROID *psDroid, DROID_ORDER_DATA *psOrder);
|
||||||
extern bool orderDroidList(DROID *psDroid);
|
extern bool orderDroidList(DROID *psDroid);
|
||||||
|
|
||||||
/** \brief Sends an order with a location and a stat to all selected droids. add = true queues the order. */
|
/** \brief Sends an order with a location and a stat to all selected droids. add = true queues the order. */
|
||||||
void orderSelectedStatsLocDir(UDWORD player, DROID_ORDER order, BASE_STATS *psStats, UDWORD x, UDWORD y, uint16_t direction, bool add);
|
void orderSelectedStatsLocDir(UDWORD player, DROID_ORDER order, STRUCTURE_STATS *psStats, UDWORD x, UDWORD y, uint16_t direction, bool add);
|
||||||
|
|
||||||
/** \brief Sends an order with a location and a stat to all selected droids. add = true queues the order. */
|
/** \brief Sends an order with a location and a stat to all selected droids. add = true queues the order. */
|
||||||
void orderDroidStatsLocDirAdd(DROID *psDroid, DROID_ORDER order, BASE_STATS *psStats, UDWORD x, UDWORD y, uint16_t direction, bool add = true);
|
void orderDroidStatsLocDirAdd(DROID *psDroid, DROID_ORDER order, STRUCTURE_STATS *psStats, UDWORD x, UDWORD y, uint16_t direction, bool add = true);
|
||||||
|
|
||||||
/** \brief Sends an order with two a locations and a stat to all selected droids. add = true queues the order. */
|
/** \brief Sends an order with two a locations and a stat to all selected droids. add = true queues the order. */
|
||||||
void orderSelectedStatsTwoLocDir(UDWORD player, DROID_ORDER order, BASE_STATS *psStats, UDWORD x1, UDWORD y1, UDWORD x2, UDWORD y2, uint16_t direction, bool add);
|
void orderSelectedStatsTwoLocDir(UDWORD player, DROID_ORDER order, STRUCTURE_STATS *psStats, UDWORD x1, UDWORD y1, UDWORD x2, UDWORD y2, uint16_t direction, bool add);
|
||||||
|
|
||||||
/** \brief Sees if a droid supports a given secondary order. */
|
/** \brief Sees if a droid supports a given secondary order. */
|
||||||
extern bool secondarySupported(DROID *psDroid, SECONDARY_ORDER sec);
|
extern bool secondarySupported(DROID *psDroid, SECONDARY_ORDER sec);
|
||||||
|
|
|
@ -76,6 +76,7 @@ enum DROID_ORDER
|
||||||
DORDER_CIRCLE = 40, /**< circles target location and engage. */
|
DORDER_CIRCLE = 40, /**< circles target location and engage. */
|
||||||
DORDER_TEMP_HOLD, /**< hold position until given next order. */
|
DORDER_TEMP_HOLD, /**< hold position until given next order. */
|
||||||
};
|
};
|
||||||
|
typedef DROID_ORDER DroidOrderType;
|
||||||
|
|
||||||
/** All the possible secondary orders for droids. */
|
/** All the possible secondary orders for droids. */
|
||||||
enum SECONDARY_ORDER
|
enum SECONDARY_ORDER
|
||||||
|
@ -150,18 +151,28 @@ struct RUN_DATA
|
||||||
uint8_t leadership; /**< basic value that will be used on calculations of the flee probability. */
|
uint8_t leadership; /**< basic value that will be used on calculations of the flee probability. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct STRUCTURE_STATS;
|
||||||
|
|
||||||
/** Struct that stores data of an order.
|
/** Struct that stores data of an order.
|
||||||
* This struct is needed to send orders that comes with information, such as position, target, etc.
|
* This struct is needed to send orders that comes with information, such as position, target, etc.
|
||||||
* This struct is used to issue orders to droids.
|
* This struct is used to issue orders to droids.
|
||||||
*/
|
*/
|
||||||
struct DROID_ORDER_DATA
|
struct DROID_ORDER_DATA
|
||||||
{
|
{
|
||||||
DROID_ORDER order; /**< the actual order. */
|
explicit DROID_ORDER_DATA(DroidOrderType type = DORDER_NONE) : type(type), pos(0, 0), pos2(0, 0), direction(0), psObj(NULL), psStats(NULL) {}
|
||||||
UWORD x,y; /**< the order's position. */
|
DROID_ORDER_DATA(DroidOrderType type, Vector2i pos) : type(type), pos(pos), pos2(0, 0), direction(0), psObj(NULL), psStats(NULL) {}
|
||||||
UWORD x2,y2; /**< the order's second position, in case those exist. */
|
DROID_ORDER_DATA(DroidOrderType type, STRUCTURE_STATS *psStats, Vector2i pos, uint16_t direction) : type(type), pos(pos), pos2(0, 0), direction(direction), psObj(NULL), psStats(psStats) {}
|
||||||
uint16_t direction; /**< the order's direction, in case it exist. */
|
DROID_ORDER_DATA(DroidOrderType type, STRUCTURE_STATS *psStats, Vector2i pos, Vector2i pos2, uint16_t direction) : type(type), pos(pos), pos2(pos2), direction(direction), psObj(NULL), psStats(psStats) {}
|
||||||
BASE_OBJECT *psObj; /**< the order's target, in case it exist. */
|
DROID_ORDER_DATA(DroidOrderType type, BASE_OBJECT *psObj) : type(type), pos(0, 0), pos2(0, 0), direction(0), psObj(psObj), psStats(NULL) {}
|
||||||
BASE_STATS *psStats; /**< order base stats. */
|
|
||||||
|
DroidOrderType type; /**< the actual order. */
|
||||||
|
Vector2i pos; /**< the order's position. */
|
||||||
|
Vector2i pos2; /**< the order's second position, in case those exist. */
|
||||||
|
uint16_t direction; /**< the order's direction, in case it exist. */
|
||||||
|
BASE_OBJECT * psObj; /**< the order's target, in case it exist. */
|
||||||
|
STRUCTURE_STATS *psStats; /**< order structure stats. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef DROID_ORDER_DATA DroidOrder;
|
||||||
|
|
||||||
#endif // __INCLUDED_SRC_ORDERDEF_H__
|
#endif // __INCLUDED_SRC_ORDERDEF_H__
|
||||||
|
|
|
@ -1116,7 +1116,7 @@ static void proj_ImpactFunc( PROJECTILE *psObj )
|
||||||
switch (psObj->psSource->type)
|
switch (psObj->psSource->type)
|
||||||
{
|
{
|
||||||
case OBJ_DROID:
|
case OBJ_DROID:
|
||||||
((DROID *) psObj->psSource)->order = DORDER_NONE;
|
((DROID *)psObj->psSource)->order.type = DORDER_NONE;
|
||||||
actionDroid((DROID *) (psObj->psSource), DACTION_NONE);
|
actionDroid((DROID *) (psObj->psSource), DACTION_NONE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ QScriptValue convDroid(DROID *psDroid, QScriptEngine *engine)
|
||||||
{
|
{
|
||||||
QScriptValue value = convObj(psDroid, engine);
|
QScriptValue value = convObj(psDroid, engine);
|
||||||
value.setProperty("action", (int)psDroid->action, QScriptValue::ReadOnly);
|
value.setProperty("action", (int)psDroid->action, QScriptValue::ReadOnly);
|
||||||
value.setProperty("order", (int)psDroid->order, QScriptValue::ReadOnly);
|
value.setProperty("order", (int)psDroid->order.type, QScriptValue::ReadOnly);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,7 @@ bool scrIdleGroup(void)
|
||||||
|
|
||||||
for(psDroid = psGroup->psList;psDroid; psDroid = psDroid->psGrpNext)
|
for(psDroid = psGroup->psList;psDroid; psDroid = psDroid->psGrpNext)
|
||||||
{
|
{
|
||||||
if (psDroid->order == DORDER_NONE || (psDroid->order == DORDER_GUARD && psDroid->psTarget == NULL))
|
if (psDroid->order.type == DORDER_NONE || (psDroid->order.type == DORDER_GUARD && psDroid->order.psObj == NULL))
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
@ -608,7 +608,6 @@ bool scrOrderDroidStatsLoc(void)
|
||||||
DROID *psDroid;
|
DROID *psDroid;
|
||||||
DROID_ORDER order;
|
DROID_ORDER order;
|
||||||
SDWORD x,y, statIndex;
|
SDWORD x,y, statIndex;
|
||||||
BASE_STATS *psStats;
|
|
||||||
|
|
||||||
if (!stackPopParams(5, ST_DROID, &psDroid, VAL_INT, &order, ST_STRUCTURESTAT, &statIndex,
|
if (!stackPopParams(5, ST_DROID, &psDroid, VAL_INT, &order, ST_STRUCTURESTAT, &statIndex,
|
||||||
VAL_INT, &x, VAL_INT, &y))
|
VAL_INT, &x, VAL_INT, &y))
|
||||||
|
@ -623,7 +622,7 @@ bool scrOrderDroidStatsLoc(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_OR_RETURN( false, statIndex < numStructureStats, "Invalid range referenced for numStructureStats, %d > %d", statIndex, numStructureStats);
|
ASSERT_OR_RETURN( false, statIndex < numStructureStats, "Invalid range referenced for numStructureStats, %d > %d", statIndex, numStructureStats);
|
||||||
psStats = (asStructureStats + statIndex);
|
STRUCTURE_STATS *psStats = asStructureStats + statIndex;
|
||||||
|
|
||||||
ASSERT_OR_RETURN( false, psDroid != NULL, "Invalid Unit pointer" );
|
ASSERT_OR_RETURN( false, psDroid != NULL, "Invalid Unit pointer" );
|
||||||
ASSERT_OR_RETURN( false, psStats != NULL, "Invalid object pointer" );
|
ASSERT_OR_RETURN( false, psStats != NULL, "Invalid object pointer" );
|
||||||
|
@ -1780,7 +1779,6 @@ static bool defenseLocation(bool variantB)
|
||||||
UDWORD x,y,gX,gY,dist,player,nearestSoFar,count;
|
UDWORD x,y,gX,gY,dist,player,nearestSoFar,count;
|
||||||
GATEWAY *psGate,*psChosenGate;
|
GATEWAY *psGate,*psChosenGate;
|
||||||
DROID *psDroid;
|
DROID *psDroid;
|
||||||
BASE_STATS *psWStats;
|
|
||||||
UDWORD x1,x2,x3,x4,y1,y2,y3,y4;
|
UDWORD x1,x2,x3,x4,y1,y2,y3,y4;
|
||||||
bool noWater;
|
bool noWater;
|
||||||
UDWORD minCount;
|
UDWORD minCount;
|
||||||
|
@ -1807,7 +1805,7 @@ static bool defenseLocation(bool variantB)
|
||||||
ASSERT_OR_RETURN( false, statIndex < numStructureStats, "Invalid range referenced for numStructureStats, %d > %d", statIndex, numStructureStats);
|
ASSERT_OR_RETURN( false, statIndex < numStructureStats, "Invalid range referenced for numStructureStats, %d > %d", statIndex, numStructureStats);
|
||||||
|
|
||||||
ASSERT_OR_RETURN( false, statIndex2 < numStructureStats, "Invalid range referenced for numStructureStats, %d > %d", statIndex2, numStructureStats);
|
ASSERT_OR_RETURN( false, statIndex2 < numStructureStats, "Invalid range referenced for numStructureStats, %d > %d", statIndex2, numStructureStats);
|
||||||
psWStats = (asStructureStats + statIndex2);
|
STRUCTURE_STATS *psWStats = (asStructureStats + statIndex2);
|
||||||
|
|
||||||
// check for wacky coords.
|
// check for wacky coords.
|
||||||
if( *pX < 0
|
if( *pX < 0
|
||||||
|
|
|
@ -9593,9 +9593,9 @@ SDWORD getNumRepairedBy(DROID *psDroidToCheck, SDWORD player)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (psDroid->psTarget != NULL && psDroid->psTarget->type == OBJ_DROID)
|
if (psDroid->order.psObj != NULL && psDroid->order.psObj->type == OBJ_DROID)
|
||||||
{
|
{
|
||||||
if ((DROID *)psDroid->psTarget == psDroidToCheck)
|
if ((DROID *)psDroid->order.psObj == psDroidToCheck)
|
||||||
{
|
{
|
||||||
numRepaired++;
|
numRepaired++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,8 +109,8 @@ bool scrBaseObjGet(UDWORD index)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
type = VAL_INT;
|
type = VAL_INT;
|
||||||
scrFunctionResult.v.ival = (SDWORD)((DROID *)psObj)->order;
|
scrFunctionResult.v.ival = ((DROID *)psObj)->order.type;
|
||||||
if (scrFunctionResult.v.ival == DORDER_GUARD && ((DROID *)psObj)->psTarget == NULL)
|
if (scrFunctionResult.v.ival == DORDER_GUARD && ((DROID *)psObj)->order.psObj == NULL)
|
||||||
{
|
{
|
||||||
scrFunctionResult.v.ival = DORDER_NONE;
|
scrFunctionResult.v.ival = DORDER_NONE;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ bool scrBaseObjGet(UDWORD index)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
type = VAL_INT;
|
type = VAL_INT;
|
||||||
scrFunctionResult.v.ival = (SDWORD)((DROID *)psObj)->orderX;
|
scrFunctionResult.v.ival = ((DROID *)psObj)->order.pos.x;
|
||||||
break;
|
break;
|
||||||
case OBJID_ORDERY:
|
case OBJID_ORDERY:
|
||||||
if (psObj->type != OBJ_DROID)
|
if (psObj->type != OBJ_DROID)
|
||||||
|
@ -163,7 +163,7 @@ bool scrBaseObjGet(UDWORD index)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
type = VAL_INT;
|
type = VAL_INT;
|
||||||
scrFunctionResult.v.ival = (SDWORD)((DROID *)psObj)->orderY;
|
scrFunctionResult.v.ival = ((DROID *)psObj)->order.pos.y;
|
||||||
break;
|
break;
|
||||||
case OBJID_DROIDTYPE:
|
case OBJID_DROIDTYPE:
|
||||||
if (psObj->type != OBJ_DROID)
|
if (psObj->type != OBJ_DROID)
|
||||||
|
@ -268,7 +268,7 @@ bool scrBaseObjGet(UDWORD index)
|
||||||
else if (psObj->type == OBJ_DROID)
|
else if (psObj->type == OBJ_DROID)
|
||||||
{
|
{
|
||||||
type = (INTERP_TYPE)ST_STRUCTURESTAT;
|
type = (INTERP_TYPE)ST_STRUCTURESTAT;
|
||||||
scrFunctionResult.v.ival = (SDWORD)((STRUCTURE_STATS *)(((DROID *)psObj)->psTarStats) - asStructureStats);
|
scrFunctionResult.v.ival = ((DROID *)psObj)->order.psStats - asStructureStats;
|
||||||
}
|
}
|
||||||
else //Nothing else supported
|
else //Nothing else supported
|
||||||
{
|
{
|
||||||
|
@ -286,7 +286,7 @@ bool scrBaseObjGet(UDWORD index)
|
||||||
else if (psObj->type == OBJ_DROID)
|
else if (psObj->type == OBJ_DROID)
|
||||||
{
|
{
|
||||||
type = (INTERP_TYPE)ST_BASEOBJECT;
|
type = (INTERP_TYPE)ST_BASEOBJECT;
|
||||||
scrFunctionResult.v.oval = ((DROID *)psObj)->psTarget;
|
scrFunctionResult.v.oval = ((DROID *)psObj)->order.psObj;
|
||||||
}
|
}
|
||||||
else //Nothing else supported
|
else //Nothing else supported
|
||||||
{
|
{
|
||||||
|
|
|
@ -830,9 +830,8 @@ void structureBuild(STRUCTURE *psStruct, DROID *psDroid, int buildPoints, int bu
|
||||||
//only play the sound if selected player
|
//only play the sound if selected player
|
||||||
if (psDroid &&
|
if (psDroid &&
|
||||||
psStruct->player == selectedPlayer
|
psStruct->player == selectedPlayer
|
||||||
&& (psDroid->order != DORDER_LINEBUILD
|
&& (psDroid->order.type != DORDER_LINEBUILD
|
||||||
|| (map_coord(psDroid->orderX) == map_coord(psDroid->orderX2)
|
|| map_coord(psDroid->order.pos) == map_coord(psDroid->order.pos2)))
|
||||||
&& map_coord(psDroid->orderY) == map_coord(psDroid->orderY2))))
|
|
||||||
{
|
{
|
||||||
audio_QueueTrackPos( ID_SOUND_STRUCTURE_COMPLETED,
|
audio_QueueTrackPos( ID_SOUND_STRUCTURE_COMPLETED,
|
||||||
psStruct->pos.x, psStruct->pos.y, psStruct->pos.z );
|
psStruct->pos.x, psStruct->pos.y, psStruct->pos.z );
|
||||||
|
@ -848,18 +847,15 @@ void structureBuild(STRUCTURE *psStruct, DROID *psDroid, int buildPoints, int bu
|
||||||
// Clear all orders for helping hands. Needed for AI script which runs next frame.
|
// Clear all orders for helping hands. Needed for AI script which runs next frame.
|
||||||
for (psIter = apsDroidLists[psDroid->player]; psIter; psIter = psIter->psNext)
|
for (psIter = apsDroidLists[psDroid->player]; psIter; psIter = psIter->psNext)
|
||||||
{
|
{
|
||||||
if ((psIter->order == DORDER_BUILD || psIter->order == DORDER_HELPBUILD || psIter->order == DORDER_LINEBUILD)
|
if ((psIter->order.type == DORDER_BUILD || psIter->order.type == DORDER_HELPBUILD || psIter->order.type == DORDER_LINEBUILD)
|
||||||
&& psIter->psTarget == psStruct
|
&& psIter->order.psObj == psStruct
|
||||||
&& (psIter->order != DORDER_LINEBUILD || (map_coord(psIter->orderX) == map_coord(psIter->orderX2)
|
&& (psIter->order.type != DORDER_LINEBUILD || map_coord(psIter->order.pos) == map_coord(psIter->order.pos2)))
|
||||||
&& map_coord(psIter->orderY) == map_coord(psIter->orderY2))))
|
|
||||||
{
|
{
|
||||||
objTrace(psIter->id, "Construction order %s complete (%d, %d -> %d, %d)", getDroidOrderName(psDroid->order),
|
objTrace(psIter->id, "Construction order %s complete (%d, %d -> %d, %d)", getDroidOrderName(psDroid->order.type),
|
||||||
(int)psIter->orderX, (int)psIter->orderY, (int)psIter->orderX2, (int)psIter->orderY2);
|
psIter->order.pos2.x, psIter->order.pos.y, psIter->order.pos2.x, psIter->order.pos2.y);
|
||||||
psIter->action = DACTION_NONE;
|
psIter->action = DACTION_NONE;
|
||||||
psIter->order = DORDER_NONE;
|
psIter->order = DroidOrder(DORDER_NONE);
|
||||||
setDroidTarget(psIter, NULL);
|
|
||||||
setDroidActionTarget(psIter, NULL, 0);
|
setDroidActionTarget(psIter, NULL, 0);
|
||||||
psIter->psTarStats = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2774,7 +2770,7 @@ static void aiUpdateStructure(STRUCTURE *psStructure, bool isMission)
|
||||||
// skip droids that are trying to get to other repair factories
|
// skip droids that are trying to get to other repair factories
|
||||||
if (psDroid != NULL
|
if (psDroid != NULL
|
||||||
&& (!orderState(psDroid, DORDER_RTR)
|
&& (!orderState(psDroid, DORDER_RTR)
|
||||||
|| psDroid->psTarget != psStructure))
|
|| psDroid->order.psObj != psStructure))
|
||||||
{
|
{
|
||||||
psDroid = (DROID *)psChosenObj;
|
psDroid = (DROID *)psChosenObj;
|
||||||
xdiff = (SDWORD)psDroid->pos.x - (SDWORD)psStructure->pos.x;
|
xdiff = (SDWORD)psDroid->pos.x - (SDWORD)psStructure->pos.x;
|
||||||
|
@ -2791,7 +2787,7 @@ static void aiUpdateStructure(STRUCTURE *psStructure, bool isMission)
|
||||||
// select next droid if none being repaired,
|
// select next droid if none being repaired,
|
||||||
// or look for a better droid if not repairing one with repair orders
|
// or look for a better droid if not repairing one with repair orders
|
||||||
if (psChosenObj == NULL ||
|
if (psChosenObj == NULL ||
|
||||||
(((DROID *)psChosenObj)->order != DORDER_RTR && ((DROID *)psChosenObj)->order != DORDER_RTR_SPECIFIED))
|
(((DROID *)psChosenObj)->order.type != DORDER_RTR && ((DROID *)psChosenObj)->order.type != DORDER_RTR_SPECIFIED))
|
||||||
{
|
{
|
||||||
//FIX ME: (doesn't look like we need this?)
|
//FIX ME: (doesn't look like we need this?)
|
||||||
ASSERT(psRepairFac->psGroup != NULL, "invalid repair facility group pointer");
|
ASSERT(psRepairFac->psGroup != NULL, "invalid repair facility group pointer");
|
||||||
|
@ -2815,7 +2811,7 @@ static void aiUpdateStructure(STRUCTURE *psStructure, bool isMission)
|
||||||
// Take any droid with orders to Return to Repair (DORDER_RTR),
|
// Take any droid with orders to Return to Repair (DORDER_RTR),
|
||||||
// or that have been ordered to this repair facility (DORDER_RTR_SPECIFIED),
|
// or that have been ordered to this repair facility (DORDER_RTR_SPECIFIED),
|
||||||
// or any "lost" unit with one of those two orders.
|
// or any "lost" unit with one of those two orders.
|
||||||
if (((psDroid->order == DORDER_RTR || (psDroid->order == DORDER_RTR_SPECIFIED
|
if (((psDroid->order.type == DORDER_RTR || (psDroid->order.type == DORDER_RTR_SPECIFIED
|
||||||
&& (!psTarget || psTarget == psStructure)))
|
&& (!psTarget || psTarget == psStructure)))
|
||||||
&& psDroid->action != DACTION_WAITFORREPAIR && psDroid->action != DACTION_MOVETOREPAIRPOINT
|
&& psDroid->action != DACTION_WAITFORREPAIR && psDroid->action != DACTION_MOVETOREPAIRPOINT
|
||||||
&& psDroid->action != DACTION_WAITDURINGREPAIR)
|
&& psDroid->action != DACTION_WAITDURINGREPAIR)
|
||||||
|
@ -2923,11 +2919,11 @@ static void aiUpdateStructure(STRUCTURE *psStructure, bool isMission)
|
||||||
psDroid = (DROID *)psChosenObj;
|
psDroid = (DROID *)psChosenObj;
|
||||||
if (psDroid)
|
if (psDroid)
|
||||||
{
|
{
|
||||||
if (psDroid->order == DORDER_RTR || psDroid->order == DORDER_RTR_SPECIFIED)
|
if (psDroid->order.type == DORDER_RTR || psDroid->order.type == DORDER_RTR_SPECIFIED)
|
||||||
{
|
{
|
||||||
// Hey, droid, it's your turn! Stop what you're doing and get ready to get repaired!
|
// Hey, droid, it's your turn! Stop what you're doing and get ready to get repaired!
|
||||||
psDroid->action = DACTION_WAITFORREPAIR;
|
psDroid->action = DACTION_WAITFORREPAIR;
|
||||||
psDroid->psTarget = psStructure;
|
psDroid->order.psObj = psStructure;
|
||||||
}
|
}
|
||||||
objTrace(psStructure->id, "Chose to repair droid %d", (int)psDroid->id);
|
objTrace(psStructure->id, "Chose to repair droid %d", (int)psDroid->id);
|
||||||
objTrace(psDroid->id, "Chosen to be repaired by repair structure %d", (int)psStructure->id);
|
objTrace(psDroid->id, "Chosen to be repaired by repair structure %d", (int)psStructure->id);
|
||||||
|
@ -3303,8 +3299,8 @@ static void aiUpdateStructure(STRUCTURE *psStructure, bool isMission)
|
||||||
/* set droid points to max */
|
/* set droid points to max */
|
||||||
psDroid->body = psDroid->originalBody;
|
psDroid->body = psDroid->originalBody;
|
||||||
|
|
||||||
if ((psDroid->order == DORDER_RTR || psDroid->order == DORDER_RTR_SPECIFIED)
|
if ((psDroid->order.type == DORDER_RTR || psDroid->order.type == DORDER_RTR_SPECIFIED)
|
||||||
&& psDroid->psTarget == psStructure)
|
&& psDroid->order.psObj == psStructure)
|
||||||
{
|
{
|
||||||
// if completely repaired reset order
|
// if completely repaired reset order
|
||||||
secondarySetState(psDroid, DSO_RETURN_TO_LOC, DSS_NONE);
|
secondarySetState(psDroid, DSO_RETURN_TO_LOC, DSS_NONE);
|
||||||
|
@ -5511,8 +5507,8 @@ static unsigned int countAssignedDroids(const STRUCTURE* psStructure)
|
||||||
num = 0;
|
num = 0;
|
||||||
for (psCurr = apsDroidLists[selectedPlayer]; psCurr; psCurr = psCurr->psNext)
|
for (psCurr = apsDroidLists[selectedPlayer]; psCurr; psCurr = psCurr->psNext)
|
||||||
{
|
{
|
||||||
if (psCurr->psTarget
|
if (psCurr->order.psObj
|
||||||
&& psCurr->psTarget->id == psStructure->id
|
&& psCurr->order.psObj->id == psStructure->id
|
||||||
&& psCurr->player == psStructure->player)
|
&& psCurr->player == psStructure->player)
|
||||||
{
|
{
|
||||||
const MOVEMENT_MODEL weapontype = asWeaponStats[psCurr->asWeaps[0].nStat].movementModel;
|
const MOVEMENT_MODEL weapontype = asWeaponStats[psCurr->asWeaps[0].nStat].movementModel;
|
||||||
|
@ -7139,7 +7135,7 @@ STRUCTURE * giftSingleStructure(STRUCTURE *psStructure, UBYTE attackPlayer, bool
|
||||||
//check through the 'attackPlayer' players list of droids to see if any are targetting it
|
//check through the 'attackPlayer' players list of droids to see if any are targetting it
|
||||||
for (psCurr = apsDroidLists[attackPlayer]; psCurr != NULL; psCurr = psCurr->psNext)
|
for (psCurr = apsDroidLists[attackPlayer]; psCurr != NULL; psCurr = psCurr->psNext)
|
||||||
{
|
{
|
||||||
if (psCurr->psTarget == psStructure)
|
if (psCurr->order.psObj == psStructure)
|
||||||
{
|
{
|
||||||
orderDroid(psCurr, DORDER_STOP, ModeImmediate);
|
orderDroid(psCurr, DORDER_STOP, ModeImmediate);
|
||||||
break;
|
break;
|
||||||
|
@ -7487,7 +7483,7 @@ bool structureCheckReferences(STRUCTURE *psVictimStruct)
|
||||||
}
|
}
|
||||||
for (psDroid = apsDroidLists[plr]; psDroid != NULL; psDroid = psDroid->psNext)
|
for (psDroid = apsDroidLists[plr]; psDroid != NULL; psDroid = psDroid->psNext)
|
||||||
{
|
{
|
||||||
if ((STRUCTURE *)psDroid->psTarget == psVictimStruct)
|
if ((STRUCTURE *)psDroid->order.psObj == psVictimStruct)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
ASSERT(!"Illegal reference to structure", "Illegal reference to structure from %s line %d",
|
ASSERT(!"Illegal reference to structure", "Illegal reference to structure from %s line %d",
|
||||||
|
|
|
@ -1622,9 +1622,7 @@ bool updateTransporter(DROID *psTransporter)
|
||||||
triggerEvent(TRIGGER_START_LEVEL);
|
triggerEvent(TRIGGER_START_LEVEL);
|
||||||
|
|
||||||
// clear order
|
// clear order
|
||||||
psTransporter->order = DORDER_NONE;
|
psTransporter->order = DroidOrder(DORDER_NONE);
|
||||||
setDroidTarget(psTransporter, NULL);
|
|
||||||
psTransporter->psTarStats = NULL;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1815,23 +1813,16 @@ bool transporterFlying(DROID *psTransporter)
|
||||||
ASSERT( psTransporter->droidType == DROID_TRANSPORTER,
|
ASSERT( psTransporter->droidType == DROID_TRANSPORTER,
|
||||||
"transporterFlying: Droid is not a Transporter" );
|
"transporterFlying: Droid is not a Transporter" );
|
||||||
|
|
||||||
if (psTransporter->order == DORDER_TRANSPORTOUT ||
|
return psTransporter->order.type == DORDER_TRANSPORTOUT ||
|
||||||
psTransporter->order == DORDER_TRANSPORTIN ||
|
psTransporter->order.type == DORDER_TRANSPORTIN ||
|
||||||
psTransporter->order == DORDER_TRANSPORTRETURN ||
|
psTransporter->order.type == DORDER_TRANSPORTRETURN ||
|
||||||
//in multiPlayer mode the Transporter can be moved around
|
//in multiPlayer mode the Transporter can be moved around
|
||||||
(bMultiPlayer && psTransporter->order == DORDER_MOVE) ||
|
(bMultiPlayer && psTransporter->order.type == DORDER_MOVE) ||
|
||||||
//in multiPlayer mode the Transporter can be moved and emptied!
|
//in multiPlayer mode the Transporter can be moved and emptied!
|
||||||
(bMultiPlayer && psTransporter->order == DORDER_DISEMBARK) ||
|
(bMultiPlayer && psTransporter->order.type == DORDER_DISEMBARK) ||
|
||||||
//in multiPlayer, descending still counts as flying
|
//in multiPlayer, descending still counts as flying
|
||||||
(bMultiPlayer && psTransporter->order == DORDER_NONE &&
|
(bMultiPlayer && psTransporter->order.type == DORDER_NONE &&
|
||||||
psTransporter->sMove.iVertSpeed != 0))
|
psTransporter->sMove.iVertSpeed != 0);
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//initialise the flag to indicate the first transporter has arrived - set in startMission()
|
//initialise the flag to indicate the first transporter has arrived - set in startMission()
|
||||||
|
|
|
@ -344,7 +344,7 @@ int visibleObject(const BASE_OBJECT* psViewer, const BASE_OBJECT* psTarget, bool
|
||||||
{
|
{
|
||||||
DROID *psDroid = (DROID *)psViewer;
|
DROID *psDroid = (DROID *)psViewer;
|
||||||
|
|
||||||
if (psDroid->psTarget == psTarget && cbSensorDroid(psDroid))
|
if (psDroid->order.psObj == psTarget && cbSensorDroid(psDroid))
|
||||||
{
|
{
|
||||||
// if it is targetted by a counter battery sensor, it is seen
|
// if it is targetted by a counter battery sensor, it is seen
|
||||||
return UBYTE_MAX;
|
return UBYTE_MAX;
|
||||||
|
|
Loading…
Reference in New Issue