Add droid sensor convenience functions, and rename structure ECM modifier to be
the same name as that of droids. git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3932 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
a7c529cce2
commit
cf36c8a87d
43
src/action.c
43
src/action.c
|
@ -2242,22 +2242,13 @@ void actionUpdateDroid(DROID *psDroid)
|
|||
// make sure the target is within sensor range
|
||||
xdiff = (SDWORD)psDroid->pos.x - (SDWORD)psDroid->psActionTarget[0]->pos.x;
|
||||
ydiff = (SDWORD)psDroid->pos.y - (SDWORD)psDroid->psActionTarget[0]->pos.y;
|
||||
//if change this back - change in MOVETOOBSERVE as well
|
||||
//rangeSq = 2 * (SDWORD)psDroid->sensorRange / 3;
|
||||
rangeSq = (SDWORD)psDroid->sensorRange;
|
||||
rangeSq = droidGetSensorRange(psDroid);
|
||||
rangeSq = rangeSq * rangeSq;
|
||||
if (!visibleObject((BASE_OBJECT *)psDroid, psDroid->psActionTarget[0]) ||
|
||||
xdiff*xdiff + ydiff*ydiff >= rangeSq)
|
||||
{
|
||||
/* if (secondaryGetState(psDroid, DSO_HALTTYPE, &state) && (state == DSS_HALT_HOLD))
|
||||
{
|
||||
psDroid->action = DACTION_NONE; // holding, don't move.
|
||||
}
|
||||
else*/
|
||||
{
|
||||
psDroid->action = DACTION_MOVETOOBSERVE;
|
||||
moveDroidTo(psDroid, psDroid->psActionTarget[0]->pos.x,psDroid->psActionTarget[0]->pos.y);
|
||||
}
|
||||
psDroid->action = DACTION_MOVETOOBSERVE;
|
||||
moveDroidTo(psDroid, psDroid->psActionTarget[0]->pos.x, psDroid->psActionTarget[0]->pos.y);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -2272,9 +2263,7 @@ void actionUpdateDroid(DROID *psDroid)
|
|||
// make sure the target is within sensor range
|
||||
xdiff = (SDWORD)psDroid->pos.x - (SDWORD)psDroid->psActionTarget[0]->pos.x;
|
||||
ydiff = (SDWORD)psDroid->pos.y - (SDWORD)psDroid->psActionTarget[0]->pos.y;
|
||||
//if change this back - change in OBSERVE as well
|
||||
//rangeSq = 2 * (SDWORD)psDroid->sensorRange / 3;
|
||||
rangeSq = (SDWORD)psDroid->sensorRange;
|
||||
rangeSq = droidGetSensorRange(psDroid);
|
||||
rangeSq = rangeSq * rangeSq;
|
||||
if ((xdiff*xdiff + ydiff*ydiff < rangeSq) &&
|
||||
!DROID_STOPPED(psDroid))
|
||||
|
@ -2285,14 +2274,7 @@ void actionUpdateDroid(DROID *psDroid)
|
|||
}
|
||||
if (DROID_STOPPED(psDroid) && psDroid->action == DACTION_MOVETOOBSERVE)
|
||||
{
|
||||
/* if (secondaryGetState(psDroid, DSO_HALTTYPE, &state) && (state == DSS_HALT_HOLD))
|
||||
{
|
||||
psDroid->action = DACTION_NONE; // on hold, don't go any further.
|
||||
}
|
||||
else*/
|
||||
{
|
||||
moveDroidTo(psDroid, psDroid->psActionTarget[0]->pos.x,psDroid->psActionTarget[0]->pos.y);
|
||||
}
|
||||
moveDroidTo(psDroid, psDroid->psActionTarget[0]->pos.x, psDroid->psActionTarget[0]->pos.y);
|
||||
}
|
||||
break;
|
||||
case DACTION_FIRESUPPORT:
|
||||
|
@ -2301,19 +2283,6 @@ void actionUpdateDroid(DROID *psDroid)
|
|||
psDroid->psTarget->type == OBJ_STRUCTURE) &&
|
||||
(psDroid->psTarget->player == psDroid->player),
|
||||
"DACTION_FIRESUPPORT: incorrect target type" );
|
||||
/* if (orderState(((DROID *)psDroid->psTarget), DORDER_OBSERVE))
|
||||
{
|
||||
// move to attack
|
||||
psDroid->action = DACTION_MOVETOFSUPP_ATTACK;
|
||||
setDroidActionTarget(psDroid, psDroid->psTarget->psTarget, 0);
|
||||
moveDroidTo(psDroid, psDroid->psActionTarget->pos.x, psDroid->psActionTarget->pos.y);
|
||||
}
|
||||
else
|
||||
{*/
|
||||
//Move droids attached to structures and droids now...AB 13/10/98
|
||||
//move (indirect weapon)droids attached to a sensor
|
||||
//if (psDroid->psTarget->type == OBJ_DROID)
|
||||
//{
|
||||
//don't move VTOL's
|
||||
// also don't move closer to sensor towers
|
||||
if (!vtolDroid(psDroid) &&
|
||||
|
@ -2322,8 +2291,6 @@ void actionUpdateDroid(DROID *psDroid)
|
|||
//move droids to within short range of the sensor now!!!!
|
||||
xdiff = (SDWORD)psDroid->pos.x - (SDWORD)psDroid->psTarget->pos.x;
|
||||
ydiff = (SDWORD)psDroid->pos.y - (SDWORD)psDroid->psTarget->pos.y;
|
||||
// make sure the weapon droid is within 2/3 weapon range of the sensor
|
||||
//rangeSq = 2 * proj_GetLongRange(asWeaponStats + psDroid->asWeaps[0].nStat) / 3;
|
||||
rangeSq = asWeaponStats[psDroid->asWeaps[0].nStat].shortRange;
|
||||
rangeSq = rangeSq * rangeSq;
|
||||
if (xdiff*xdiff + ydiff*ydiff < rangeSq)
|
||||
|
|
21
src/ai.c
21
src/ai.c
|
@ -146,11 +146,9 @@ SDWORD aiBestNearestTarget(DROID *psDroid, BASE_OBJECT **ppsObj, int weapon_slot
|
|||
// make sure this target wasn't assigned explicitly to this droid
|
||||
if(friendlyDroid->order != DORDER_ATTACK)
|
||||
{
|
||||
//(WEAPON_STATS *)(asWeaponStats + ((DROID *)friendlyObj)->asWeaps[0].nStat)->;
|
||||
|
||||
// make sure target is near enough
|
||||
if(dirtySqrt(psDroid->pos.x,psDroid->pos.y,tempTarget->pos.x,tempTarget->pos.y)
|
||||
< (psDroid->sensorRange))
|
||||
if (dirtySqrt(psDroid->pos.x, psDroid->pos.y, tempTarget->pos.x, tempTarget->pos.y)
|
||||
< droidGetSensorRange(psDroid))
|
||||
{
|
||||
targetInQuestion = tempTarget; //consider this target
|
||||
}
|
||||
|
@ -582,8 +580,8 @@ BOOL aiChooseTarget(BASE_OBJECT *psObj, BASE_OBJECT **ppsTarget, int weapon_slot
|
|||
// Can't attack without a weapon
|
||||
return FALSE;
|
||||
}
|
||||
radSquared = ((DROID *)psObj)->sensorRange *
|
||||
((DROID *)psObj)->sensorRange;
|
||||
sensorRange = droidGetSensorRange((DROID *)psObj);
|
||||
radSquared = sensorRange * sensorRange;
|
||||
break;
|
||||
case OBJ_STRUCTURE:
|
||||
if (((STRUCTURE *)psObj)->numWeaps == 0 || ((STRUCTURE *)psObj)->asWeaps[0].nStat == 0)
|
||||
|
@ -797,6 +795,7 @@ BOOL aiChooseTarget(BASE_OBJECT *psObj, BASE_OBJECT **ppsTarget, int weapon_slot
|
|||
/* See if there is a target in range for Sensor objects*/
|
||||
BOOL aiChooseSensorTarget(BASE_OBJECT *psObj, BASE_OBJECT **ppsTarget)
|
||||
{
|
||||
SDWORD sensorRange;
|
||||
UDWORD radSquared;
|
||||
BASE_OBJECT *psCurr,*psTemp = NULL;
|
||||
BASE_OBJECT *psTarget = NULL;
|
||||
|
@ -812,8 +811,8 @@ BOOL aiChooseSensorTarget(BASE_OBJECT *psObj, BASE_OBJECT **ppsTarget)
|
|||
// to be used for Turret Sensors only
|
||||
return FALSE;
|
||||
}
|
||||
radSquared = ((DROID *)psObj)->sensorRange *
|
||||
((DROID *)psObj)->sensorRange;
|
||||
sensorRange = droidGetSensorRange((DROID *)psObj);
|
||||
radSquared = sensorRange * sensorRange;
|
||||
break;
|
||||
case OBJ_STRUCTURE:
|
||||
if (!(structStandardSensor((STRUCTURE *)psObj) ||
|
||||
|
@ -822,11 +821,11 @@ BOOL aiChooseSensorTarget(BASE_OBJECT *psObj, BASE_OBJECT **ppsTarget)
|
|||
// to be used for Standard and VTOL intercept Turret Sensors only
|
||||
return FALSE;
|
||||
}
|
||||
radSquared = ((STRUCTURE *)psObj)->sensorRange *
|
||||
((STRUCTURE *)psObj)->sensorRange;
|
||||
sensorRange = ((STRUCTURE *)psObj)->sensorRange;
|
||||
radSquared = sensorRange * sensorRange;
|
||||
break;
|
||||
default:
|
||||
radSquared = 0;
|
||||
sensorRange = radSquared = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1802,8 +1802,8 @@ static inline void dealWithLMBDroid(DROID* psDroid, SELECTION_TYPE selection)
|
|||
CONPRINTF(ConsoleString, (ConsoleString,
|
||||
"%s - Damage %d%% - ID %d - experience %f, %s - order %s - action %s - sensor range %hu power %hu - ECM %u",
|
||||
droidGetName(psDroid), 100 - PERCENT(psDroid->body, psDroid->originalBody), psDroid->id,
|
||||
psDroid->experience, getDroidLevelName(psDroid), getDroidOrderName(psDroid->order), getDroidActionName(psDroid->action), psDroid->sensorRange,
|
||||
psDroid->sensorPower, psDroid->ECMMod));
|
||||
psDroid->experience, getDroidLevelName(psDroid), getDroidOrderName(psDroid->order), getDroidActionName(psDroid->action),
|
||||
droidGetSensorRange(psDroid), droidGetSensorPower(psDroid), droidGetConcealment(psDroid)));
|
||||
FeedbackClickedOn();
|
||||
}
|
||||
else
|
||||
|
|
25
src/droid.h
25
src/droid.h
|
@ -406,6 +406,31 @@ BOOL droidCheckReferences(DROID *psVictimDroid);
|
|||
/** Check if droid is in a legal world position and is not on its way to drive off the map. */
|
||||
BOOL droidOnMap(DROID *psDroid);
|
||||
|
||||
static inline int droidGetSensorRange(DROID *psDroid)
|
||||
{
|
||||
return psDroid->sensorRange;
|
||||
}
|
||||
|
||||
static inline int droidGetSensorPower(DROID *psDroid)
|
||||
{
|
||||
return psDroid->sensorPower;
|
||||
}
|
||||
|
||||
static inline int droidGetJammerPower(DROID *psDroid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int droidGetJammerRange(DROID *psDroid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int droidGetConcealment(DROID *psDroid)
|
||||
{
|
||||
return psDroid->ECMMod;
|
||||
}
|
||||
|
||||
/*
|
||||
* Component stat helper functions
|
||||
*/
|
||||
|
|
|
@ -1248,12 +1248,11 @@ void structureECMUpgrade(STRUCTURE *psBuilding)
|
|||
//reallocate the sensor range and power since the upgrade
|
||||
if (psBuilding->pStructureType->pECM)
|
||||
{
|
||||
psBuilding->ecmPower = (UWORD)ecmPower(psBuilding->pStructureType->pECM,
|
||||
psBuilding->player);
|
||||
psBuilding->ECMMod = (UWORD)ecmPower(psBuilding->pStructureType->pECM, psBuilding->player);
|
||||
}
|
||||
else
|
||||
{
|
||||
psBuilding->ecmPower = 0;
|
||||
psBuilding->ECMMod = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -603,7 +603,7 @@ static void structureSaveTagged(STRUCTURE *psStruct)
|
|||
/* common groups */
|
||||
|
||||
objectSaveTagged((BASE_OBJECT *)psStruct); /* 0x01 */
|
||||
objectSensorTagged(psStruct->sensorRange, psStruct->sensorPower, 0, psStruct->ecmPower); /* 0x02 */
|
||||
objectSensorTagged(psStruct->sensorRange, psStruct->sensorPower, 0, psStruct->ECMMod); /* 0x02 */
|
||||
objectStatTagged((BASE_OBJECT *)psStruct, psStruct->pStructureType->bodyPoints, psStruct->resistance); /* 0x03 */
|
||||
objectWeaponTagged(psStruct->numWeaps, psStruct->turretRotation, psStruct->turretPitch, psStruct->asWeaps, psStruct->psTarget);
|
||||
|
||||
|
|
15
src/oprint.c
15
src/oprint.c
|
@ -222,17 +222,13 @@ void printDroidInfo(DROID *psDroid)
|
|||
printBaseObjInfo((BASE_OBJECT *)psDroid);
|
||||
|
||||
CONPRINTF(ConsoleString,(ConsoleString," wt %d bSpeed %d sRng %d sPwr %d ECM %d bdy %d\n",
|
||||
psDroid->weight, psDroid->baseSpeed, psDroid->sensorRange,
|
||||
psDroid->sensorPower,psDroid->ECMMod, psDroid->body));
|
||||
psDroid->weight, psDroid->baseSpeed, droidGetSensorRange(psDroid),
|
||||
droidGetSensorPower(psDroid), droidGetConcealment(psDroid), psDroid->body));
|
||||
|
||||
/*for(i=0; i<(SDWORD)psDroid->numWeaps; i++)
|
||||
if (psDroid->asWeaps[0].nStat > 0)
|
||||
{
|
||||
printWeaponInfo(asWeaponStats + psDroid->asWeaps[i].nStat);
|
||||
}*/
|
||||
if (psDroid->asWeaps[0].nStat > 0)
|
||||
{
|
||||
printWeaponInfo(asWeaponStats + psDroid->asWeaps[0].nStat);
|
||||
}
|
||||
printWeaponInfo(asWeaponStats + psDroid->asWeaps[0].nStat);
|
||||
}
|
||||
|
||||
for(i=0; i<DROID_MAXCOMP; i++)
|
||||
{
|
||||
|
@ -289,7 +285,6 @@ void printDroidInfo(DROID *psDroid)
|
|||
psSensStats = asSensorStats + psDroid->asBits[i].nStat;
|
||||
printComponentInfo((COMP_BASE_STATS *)psSensStats);
|
||||
CONPRINTF(ConsoleString,(ConsoleString," rng %d pwr %d loc %d imd %p\n",
|
||||
//psSensStats->range, psSensStats->power,
|
||||
sensorRange(psSensStats,psDroid->player),
|
||||
sensorPower(psSensStats,psDroid->player),
|
||||
psSensStats->location, psSensStats->pMountGraphic));
|
||||
|
|
|
@ -2918,7 +2918,7 @@ void replaceStructureComponent(STRUCTURE *pList, UDWORD oldType, UDWORD oldCompI
|
|||
case COMP_ECM:
|
||||
if (psStructure->pStructureType->pECM == (asECMStats + oldCompInc))
|
||||
{
|
||||
psStructure->ecmPower = (UWORD)(asECMStats + newCompInc)->power;
|
||||
psStructure->ECMMod = (UWORD)(asECMStats + newCompInc)->power;
|
||||
}
|
||||
break;
|
||||
case COMP_SENSOR:
|
||||
|
|
|
@ -1786,12 +1786,12 @@ STRUCTURE* buildStructure(STRUCTURE_STATS* pStructureType, UDWORD x, UDWORD y, U
|
|||
//set up the ecm stat
|
||||
if (psBuilding->pStructureType->pECM)
|
||||
{
|
||||
psBuilding->ecmPower = (UWORD)ecmPower(psBuilding->pStructureType->pECM,
|
||||
psBuilding->ECMMod = (UWORD)ecmPower(psBuilding->pStructureType->pECM,
|
||||
psBuilding->player);
|
||||
}
|
||||
else
|
||||
{
|
||||
psBuilding->ecmPower = 0;
|
||||
psBuilding->ECMMod = 0;
|
||||
}
|
||||
|
||||
/* Store the weapons */
|
||||
|
@ -5925,7 +5925,7 @@ void printStructureInfo(STRUCTURE *psStructure)
|
|||
{
|
||||
CONPRINTF(ConsoleString, (ConsoleString, "%s - %d Units assigned - ID %d - sensor range %hu power %hu - ECM %u",
|
||||
getStatName(psStructure->pStructureType), countAssignedDroids(psStructure),
|
||||
psStructure->id, psStructure->sensorRange, psStructure->sensorPower, psStructure->ecmPower));
|
||||
psStructure->id, psStructure->sensorRange, psStructure->sensorPower, psStructure->ECMMod));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -5947,7 +5947,7 @@ void printStructureInfo(STRUCTURE *psStructure)
|
|||
CONPRINTF(ConsoleString, (ConsoleString, "%s - %d Units assigned - ID %d - armour %d|%d - sensor range %hu power %hu - ECM %u",
|
||||
getStatName(psStructure->pStructureType), countAssignedDroids(psStructure),
|
||||
psStructure->id, psStructure->armour[0][WC_KINETIC], psStructure->armour[0][WC_HEAT],
|
||||
psStructure->sensorRange, psStructure->sensorPower, psStructure->ecmPower));
|
||||
psStructure->sensorRange, psStructure->sensorPower, psStructure->ECMMod));
|
||||
}
|
||||
#endif
|
||||
else
|
||||
|
|
|
@ -304,7 +304,7 @@ typedef struct _structure
|
|||
UDWORD lastHitWeapon;
|
||||
|
||||
//the ecm power needs to be stored since the actual ecm stat can change with research
|
||||
UWORD ecmPower;
|
||||
UWORD ECMMod;
|
||||
|
||||
FUNCTIONALITY *pFunctionality; /* pointer to structure that contains fields
|
||||
necessary for functionality */
|
||||
|
|
|
@ -371,7 +371,7 @@ BOOL visibleObject(BASE_OBJECT *psViewer, BASE_OBJECT *psTarget)
|
|||
ecmPower = ((DROID *)psTarget)->ECMMod;
|
||||
break;
|
||||
case OBJ_STRUCTURE:
|
||||
ecmPower = ((STRUCTURE *)psTarget)->ecmPower;
|
||||
ecmPower = ((STRUCTURE *)psTarget)->ECMMod;
|
||||
range = 4 * range / 3;
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue