Add ECM range parameter. Clean up ECM code. Remove cyborg stealth hack from

trunk in anticipation of future ECM work.


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3854 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2008-02-22 19:13:13 +00:00
parent 69e71c5778
commit 548653d0d0
9 changed files with 42 additions and 99 deletions

View File

@ -1,2 +1,2 @@
ZNULLECM,Level All,0,0,0,0,0,0,0,0,DEFAULT,50,0
RepairCentre,Level All,0,0,0,0,0,0,GNHREPAR.PIE,0,TURRET,0,0
ZNULLECM,Level All,0,0,0,0,0,0,0,0,DEFAULT,50,0,0
RepairCentre,Level All,0,0,0,0,0,0,GNHREPAR.PIE,0,TURRET,0,0,0

View File

@ -1,2 +1,2 @@
ZNULLECM,Level All,0,0,0,0,0,0,0,0,DEFAULT,50,0
RepairCentre,Level All,0,0,0,0,0,0,GNHREPAR.PIE,0,TURRET,0,0
ZNULLECM,Level All,0,0,0,0,0,0,0,0,DEFAULT,50,0,0
RepairCentre,Level All,0,0,0,0,0,0,GNHREPAR.PIE,0,TURRET,0,0,0

View File

@ -92,7 +92,6 @@ SDWORD aiBestNearestTarget(DROID *psDroid, BASE_OBJECT **ppsObj, int weapon_slot
BOOL electronic = FALSE;
STRUCTURE *targetStructure;
WEAPON_EFFECT weaponEffect;
DROID *friendlyDroid;
//don't bother looking if empty vtol droid
if (vtolEmpty(psDroid))
@ -135,7 +134,7 @@ SDWORD aiBestNearestTarget(DROID *psDroid, BASE_OBJECT **ppsObj, int weapon_slot
{
if(friendlyObj->type == OBJ_DROID)
{
friendlyDroid = ((DROID *)friendlyObj);
DROID *friendlyDroid = (DROID *)friendlyObj;
/* See if friendly droid has a target */
tempTarget = friendlyDroid->psActionTarget[0];

View File

@ -448,10 +448,7 @@ void counterBatteryFire(BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget)
{
psDroid = (DROID *)psViewer;
//must be a CB sensor
/*if (asSensorStats[psDroid->asBits[COMP_SENSOR].nStat].type ==
INDIRECT_CB_SENSOR || asSensorStats[psDroid->asBits[COMP_SENSOR].
nStat].type == VTOL_CB_SENSOR)*/
if (cbSensorDroid(psDroid))
if (cbSensorDroid(psDroid))
{
sensorRange = asSensorStats[psDroid->asBits[COMP_SENSOR].
nStat].range;

View File

@ -3176,7 +3176,6 @@ DROID* buildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD player,
//don't worry if not on homebase cos not being drawn yet
if (!onMission)
{
// psDroid->lastTile = mapTile(mapX,mapY);
//set droid height
psDroid->pos.z = map_Height(psDroid->pos.x, psDroid->pos.y);
}
@ -3219,7 +3218,6 @@ DROID* buildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD player,
psDroid->asWeaps[i].hitPoints = 0;
}
// ffs je
psDroid->listSize = 0;
memset(psDroid->asOrderList, 0, sizeof(ORDER_LIST)*ORDER_LIST_MAX);
@ -3300,7 +3298,6 @@ DROID* buildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD player,
{
for (impact_side = 0;impact_side < NUM_HIT_SIDES;impact_side=impact_side+1)
{
//psDroid->armour[inc] = (asBodyStats + pTemplate->asParts[COMP_BODY])->armourValue[inc];
psDroid->armour[impact_side][inc] = bodyArmour(asBodyStats + pTemplate->
asParts[COMP_BODY], (UBYTE)player, CYBORG_BODY_UPGRADE, (WEAPON_CLASS)inc, impact_side);
}
@ -3323,15 +3320,10 @@ DROID* buildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD player,
memset(psDroid->visible, 0, sizeof(psDroid->visible));
psDroid->visible[psDroid->player] = UBYTE_MAX;
//psDroid->damage = droidDamage;
psDroid->died = 0;
psDroid->inFire = FALSE;
psDroid->burnStart = 0;
psDroid->burnDamage = 0;
// psDroid->sAI.state = AI_PAUSE;
// psDroid->sAI.psTarget = NULL;
// psDroid->sAI.psSelectedWeapon = NULL;
// psDroid->sAI.psStructToBuild = NULL;
psDroid->sDisplay.screenX = OFF_SCREEN;
psDroid->sDisplay.screenY = OFF_SCREEN;
psDroid->sDisplay.screenR = 0;
@ -3366,7 +3358,7 @@ DROID* buildDroid(DROID_TEMPLATE *pTemplate, UDWORD x, UDWORD y, UDWORD player,
if (psDroid->droidType == DROID_TRANSPORTER)
{
//add transporter launch button if selected player and not a reinforcable situation
if ( player == selectedPlayer && !missionCanReEnforce())
if ( player == selectedPlayer && !missionCanReEnforce())
{
(void)intAddTransporterLaunch(psDroid);
}
@ -3414,8 +3406,6 @@ void droidSetBits(DROID_TEMPLATE *pTemplate,DROID *psDroid)
psDroid->turretPitch[inc] = 0;
}
// psDroid->ECMMod = (asECMStats + pTemplate->asParts[COMP_ECM])->power;
psDroid->body = calcTemplateBody(pTemplate, psDroid->player);
psDroid->originalBody = psDroid->body;
@ -3423,7 +3413,7 @@ void droidSetBits(DROID_TEMPLATE *pTemplate,DROID *psDroid)
if (pTemplate->numWeaps > 0)
{
for (inc=0; inc < pTemplate->numWeaps; inc++)
for (inc=0; inc < pTemplate->numWeaps; inc++)
{
psDroid->asWeaps[inc].lastFired=0;
psDroid->asWeaps[inc].nStat = pTemplate->asWeaps[inc];
@ -3442,37 +3432,18 @@ void droidSetBits(DROID_TEMPLATE *pTemplate,DROID *psDroid)
}
//allocate the components hit points
psDroid->asBits[COMP_BODY].nStat = (UBYTE)pTemplate->asParts[COMP_BODY];
//psDroid->asBits[COMP_BODY].hitPoints =
// (asBodyStats + pTemplate->asParts[COMP_BODY])->hitPoints;
// ajl - changed this to init brains for all droids (crashed)
psDroid->asBits[COMP_BRAIN].nStat = 0;
// This is done by the Command droid stuff - John.
// Not any more - John.
psDroid->asBits[COMP_BRAIN].nStat = (UBYTE)pTemplate->asParts[COMP_BRAIN];
// psDroid->asBits[COMP_BRAIN].hitPoints =
// (asBrainStats + pTemplate->asParts[COMP_BRAIN])->hitPoints;
psDroid->asBits[COMP_PROPULSION].nStat = (UBYTE)pTemplate->asParts[COMP_PROPULSION];
//psDroid->asBits[COMP_PROPULSION].hitPoints =
// (asPropulsionStats + pTemplate->asParts[COMP_PROPULSION])->hitPoints;
psDroid->asBits[COMP_SENSOR].nStat = (UBYTE)pTemplate->asParts[COMP_SENSOR];
//psDroid->asBits[COMP_SENSOR].hitPoints =
// (asSensorStats + pTemplate->asParts[COMP_SENSOR])->hitPoints;
psDroid->asBits[COMP_ECM].nStat = (UBYTE)pTemplate->asParts[COMP_ECM];
//psDroid->asBits[COMP_ECM].hitPoints =
// (asECMStats + pTemplate->asParts[COMP_ECM])->hitPoints;
psDroid->asBits[COMP_REPAIRUNIT].nStat = (UBYTE)pTemplate->asParts[COMP_REPAIRUNIT];
//psDroid->asBits[COMP_REPAIRUNIT].hitPoints =
// (asRepairStats + pTemplate->asParts[COMP_REPAIRUNIT])->hitPoints;
psDroid->asBits[COMP_CONSTRUCT].nStat = (UBYTE)pTemplate->asParts[COMP_CONSTRUCT];
//psDroid->asBits[COMP_CONSTRUCT].hitPoints =
// (asConstructStats + pTemplate->asParts[COMP_CONSTRUCT])->hitPoints;
psDroid->asBits[COMP_BRAIN].nStat = pTemplate->asParts[COMP_BRAIN];
psDroid->asBits[COMP_PROPULSION].nStat = pTemplate->asParts[COMP_PROPULSION];
psDroid->asBits[COMP_SENSOR].nStat = pTemplate->asParts[COMP_SENSOR];
psDroid->asBits[COMP_ECM].nStat = pTemplate->asParts[COMP_ECM];
psDroid->asBits[COMP_REPAIRUNIT].nStat = pTemplate->asParts[COMP_REPAIRUNIT];
psDroid->asBits[COMP_CONSTRUCT].nStat = pTemplate->asParts[COMP_CONSTRUCT];
}

View File

@ -82,6 +82,7 @@ static UDWORD maxBodyPoints;
static UDWORD maxSensorRange;
static UDWORD maxSensorPower;
static UDWORD maxECMPower;
static UDWORD maxECMRange;
static UDWORD maxConstPoints;
static UDWORD maxRepairPoints;
static UDWORD maxWeaponRange;
@ -105,6 +106,7 @@ static void setMaxBodyPower(UDWORD power);
static void setMaxBodyPoints(UDWORD points);
static void setMaxSensorRange(UDWORD range);
static void setMaxSensorPower(UDWORD power);
static void setMaxECMRange(UDWORD power);
static void setMaxECMPower(UDWORD power);
static void setMaxConstPoints(UDWORD points);
static void setMaxRepairPoints(UDWORD repair);
@ -193,7 +195,7 @@ void statsInitVars(void)
// init the max values
maxComponentWeight = maxBodyArmour = maxBodyPower =
maxBodyPoints = maxSensorRange = maxSensorPower = maxECMPower =
maxBodyPoints = maxSensorRange = maxSensorPower = maxECMPower = maxECMRange =
maxConstPoints = maxRepairPoints = maxWeaponRange = maxWeaponDamage =
maxPropulsionSpeed = 0;
}
@ -1306,11 +1308,11 @@ BOOL loadECMStats(const char *pECMData, UDWORD bufferSize)
location[0] = '\0';
//read the data into the storage - the data is delimeted using comma's
sscanf(pECMData,"%[^','],%[^','],%d,%d,%d,%d,%d,%d,%[^','],%[^','],\
%[^','],%d,%d",
%[^','],%d,%d,%d",
(char*)&ECMName, (char*)&techLevel, &psStats->buildPower,&psStats->buildPoints,
&psStats->weight, &psStats->hitPoints, &psStats->systemPoints,
&psStats->body, (char*)&GfxFile, (char*)&mountGfx, (char*)&location, &psStats->power,
&designable);
&psStats->range, &designable);
// set a default ECM range for now
psStats->range = TILE_UNITS * 8;
@ -1383,6 +1385,7 @@ BOOL loadECMStats(const char *pECMData, UDWORD bufferSize)
if (psStats->design)
{
setMaxECMPower(psStats->power);
setMaxECMRange(psStats->range);
setMaxComponentWeight(psStats->weight);
}
@ -3088,6 +3091,12 @@ UDWORD ecmPower(ECM_STATS *psStats, UBYTE player)
return (UWORD)(psStats->power + (psStats->power * asECMUpgrade[player].power)/100);
}
/*Access functions for the upgradeable stats of a ECM*/
UDWORD ecmRange(ECM_STATS *psStats, UBYTE player)
{
return (UWORD)(psStats->range + (psStats->range * asECMUpgrade[player].range)/100);
}
/*Access functions for the upgradeable stats of a repair*/
UDWORD repairPoints(REPAIR_STATS *psStats, UBYTE player)
{
@ -3246,6 +3255,18 @@ UDWORD getMaxECMPower(void)
return maxECMPower;
}
void setMaxECMRange(UDWORD power)
{
if (power > maxECMRange)
{
maxECMPower = power;
}
}
UDWORD getMaxECMRange(void)
{
return maxECMRange;
}
void setMaxConstPoints(UDWORD points)
{
if (points > maxConstPoints)

View File

@ -304,6 +304,7 @@ extern UDWORD sensorPower(SENSOR_STATS *psStats, UBYTE player);
extern UDWORD sensorRange(SENSOR_STATS *psStats, UBYTE player);
/*Access functions for the upgradeable stats of a ECM*/
extern UDWORD ecmPower(ECM_STATS *psStats, UBYTE player);
extern UDWORD ecmRange(ECM_STATS *psStats, UBYTE player);
/*Access functions for the upgradeable stats of a repair*/
extern UDWORD repairPoints(REPAIR_STATS *psStats, UBYTE player);
/*Access functions for the upgradeable stats of a constructor*/
@ -326,6 +327,7 @@ extern UDWORD getMaxBodyPoints(void);
extern UDWORD getMaxSensorRange(void);
extern UDWORD getMaxSensorPower(void);
extern UDWORD getMaxECMPower(void);
extern UDWORD getMaxECMRange(void);
extern UDWORD getMaxConstPoints(void);
extern UDWORD getMaxRepairPoints(void);
extern UDWORD getMaxWeaponRange(void);

View File

@ -441,6 +441,7 @@ typedef struct _sensor_upgrade
typedef struct _ecm_upgrade
{
UWORD power;
UDWORD range;
} ECM_UPGRADE;
/*repair stats which can be upgraded by research*/

View File

@ -498,61 +498,13 @@ found:
/* Find out what can see this object */
void processVisibility(BASE_OBJECT *psObj)
{
DROID *psDroid;
STRUCTURE *psBuilding;
UDWORD i, maxPower, ecmPoints;
ECM_STATS *psECMStats;
UDWORD i;
BOOL prevVis[MAX_PLAYERS], currVis[MAX_PLAYERS];
SDWORD visLevel;
BASE_OBJECT *psViewer;
MESSAGE *psMessage;
UDWORD player, ally;
// calculate the ecm power for the object based on other ECM's in the area
maxPower = 0;
// set the current ecm power
switch (psObj->type)
{
case OBJ_DROID:
psDroid = (DROID *)psObj;
psECMStats = asECMStats + psDroid->asBits[COMP_ECM].nStat;
ecmPoints = ecmPower(psECMStats, psDroid->player);
if (ecmPoints < maxPower)
{
psDroid->ECMMod = maxPower;
}
else
{
psDroid->ECMMod = ecmPoints;
maxPower = psDroid->ECMMod;
}
// innate cyborg bonus
if (cyborgDroid((DROID*)psObj))
{
psDroid->ECMMod += 500;
}
break;
case OBJ_STRUCTURE:
psBuilding = (STRUCTURE *)psObj;
psECMStats = psBuilding->pStructureType->pECM;
if (psECMStats && psECMStats->power > maxPower)
{
psBuilding->ecmPower = (UWORD)psECMStats->power;
}
else
{
psBuilding->ecmPower = (UWORD)maxPower;
maxPower = psBuilding->ecmPower;
}
break;
case OBJ_FEATURE:
default:
// no ecm's on features
break;
}
// initialise the visibility array
for (i=0; i<MAX_PLAYERS; i++)
{