* turn some usages of WinAPI types (*WORD) into their native C counterparts (e.g. int, unsigned int, etc.)
* make integers unsigned at places where we never, ever use signed values for their values * move some variables into a more local scope (i.e. the only scope where they're used) * turn some mixed tab/spaces indentation usage into tabs-only * remove unused (and commented out) conditional compilation macro USE_DIRECTPLAY_PROTOCOL git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1798 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
8e2837ab97
commit
dcb2c3350f
|
@ -36,7 +36,6 @@
|
||||||
#define ConnectionSize 255 // max size of a connection description.
|
#define ConnectionSize 255 // max size of a connection description.
|
||||||
#define MaxProtocols 12 // max number of returnable protocols.
|
#define MaxProtocols 12 // max number of returnable protocols.
|
||||||
#define MaxGames 12 // max number of concurrently playable games to allow.
|
#define MaxGames 12 // max number of concurrently playable games to allow.
|
||||||
//#define USE_DIRECTPLAY_PROTOCOL // use DX6 protocol.
|
|
||||||
|
|
||||||
#define SESSION_JOINDISABLED 1
|
#define SESSION_JOINDISABLED 1
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ void cmdDroidMultiExpBoost(BOOL bDoit)
|
||||||
|
|
||||||
|
|
||||||
// get the experience level of a command droid
|
// get the experience level of a command droid
|
||||||
SDWORD cmdDroidGetLevel(DROID *psCommander)
|
unsigned int cmdDroidGetLevel(DROID *psCommander)
|
||||||
{
|
{
|
||||||
SDWORD numKills = psCommander->numKills;
|
SDWORD numKills = psCommander->numKills;
|
||||||
|
|
||||||
|
@ -180,6 +180,7 @@ SDWORD cmdDroidGetLevel(DROID *psCommander)
|
||||||
{
|
{
|
||||||
numKills *= 2;
|
numKills *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numKills > 2047)
|
if (numKills > 2047)
|
||||||
{
|
{
|
||||||
return 8;
|
return 8;
|
||||||
|
@ -217,7 +218,7 @@ SDWORD cmdDroidGetLevel(DROID *psCommander)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the maximum group size for a command droid
|
// get the maximum group size for a command droid
|
||||||
SDWORD cmdDroidMaxGroup(DROID *psCommander)
|
unsigned int cmdDroidMaxGroup(DROID *psCommander)
|
||||||
{
|
{
|
||||||
return cmdDroidGetLevel(psCommander) * 2 + 6;
|
return cmdDroidGetLevel(psCommander) * 2 + 6;
|
||||||
}
|
}
|
||||||
|
@ -239,22 +240,26 @@ void cmdDroidUpdateKills(DROID *psKiller)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the level of a droids commander, if any
|
// get the level of a droids commander, if any
|
||||||
SDWORD cmdGetCommanderLevel(DROID *psDroid)
|
unsigned int cmdGetCommanderLevel(DROID *psDroid)
|
||||||
{
|
{
|
||||||
DROID *psCommander;
|
DROID *psCommander;
|
||||||
|
|
||||||
ASSERT( psDroid != NULL,
|
ASSERT( psDroid != NULL,
|
||||||
"cmdGetCommanderLevel: invalid droid pointer" );
|
"cmdGetCommanderLevel: invalid droid pointer" );
|
||||||
|
|
||||||
if ( (psDroid->psGroup != NULL) &&
|
// If this droid is not the member of a Commander's group
|
||||||
(psDroid->psGroup->type == GT_COMMAND) )
|
// Return an experience level of 0
|
||||||
|
if ((psDroid->psGroup == NULL) ||
|
||||||
|
(psDroid->psGroup->type != GT_COMMAND))
|
||||||
{
|
{
|
||||||
psCommander = psDroid->psGroup->psCommander;
|
return 0;
|
||||||
|
|
||||||
return cmdDroidGetLevel(psCommander);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
// Retrieve this group's commander
|
||||||
|
psCommander = psDroid->psGroup->psCommander;
|
||||||
|
|
||||||
|
// Return the experience level of this commander
|
||||||
|
return cmdDroidGetLevel(psCommander);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Selects all droids for a given commander
|
// Selects all droids for a given commander
|
||||||
|
|
|
@ -57,10 +57,10 @@ extern void cmdDroidClearDesignator(UDWORD player);
|
||||||
extern SDWORD cmdDroidGetIndex(DROID *psCommander);
|
extern SDWORD cmdDroidGetIndex(DROID *psCommander);
|
||||||
|
|
||||||
// get the experience level of a command droid
|
// get the experience level of a command droid
|
||||||
extern SDWORD cmdDroidGetLevel(DROID *psCommander);
|
extern unsigned int cmdDroidGetLevel(DROID *psCommander);
|
||||||
|
|
||||||
// get the maximum group size for a command droid
|
// get the maximum group size for a command droid
|
||||||
extern SDWORD cmdDroidMaxGroup(DROID *psCommander);
|
extern unsigned int cmdDroidMaxGroup(DROID *psCommander);
|
||||||
|
|
||||||
// update the kills of a command droid if psKiller is in a command group
|
// update the kills of a command droid if psKiller is in a command group
|
||||||
extern void cmdDroidUpdateKills(DROID *psKiller);
|
extern void cmdDroidUpdateKills(DROID *psKiller);
|
||||||
|
@ -72,7 +72,7 @@ extern SDWORD cmdDroidHitMod(DROID *psDroid);
|
||||||
extern SDWORD cmdDroidEvasionMod(DROID *psDroid);
|
extern SDWORD cmdDroidEvasionMod(DROID *psDroid);
|
||||||
|
|
||||||
// get the level of a droids commander, if any
|
// get the level of a droids commander, if any
|
||||||
extern SDWORD cmdGetCommanderLevel(DROID *psDroid);
|
extern unsigned int cmdGetCommanderLevel(DROID *psDroid);
|
||||||
|
|
||||||
// Select all droids assigned to the passed in command droids
|
// Select all droids assigned to the passed in command droids
|
||||||
extern void cmdSelectSubDroids(DROID *psDroid);
|
extern void cmdSelectSubDroids(DROID *psDroid);
|
||||||
|
|
110
src/droid.c
110
src/droid.c
|
@ -148,31 +148,31 @@ BOOL droidInit(void)
|
||||||
#define UNIT_LOST_DELAY (5*GAME_TICKS_PER_SEC)
|
#define UNIT_LOST_DELAY (5*GAME_TICKS_PER_SEC)
|
||||||
BOOL droidDamage(DROID *psDroid, UDWORD damage, UDWORD weaponClass, UDWORD weaponSubClass, int angle)
|
BOOL droidDamage(DROID *psDroid, UDWORD damage, UDWORD weaponClass, UDWORD weaponSubClass, int angle)
|
||||||
{
|
{
|
||||||
UDWORD penDamage, armourDamage;
|
UDWORD armourDamage;
|
||||||
BOOL penetrated = FALSE;
|
BOOL penetrated = FALSE;
|
||||||
UDWORD armour=0;
|
UDWORD armour=0;
|
||||||
SECONDARY_STATE state;
|
SECONDARY_STATE state;
|
||||||
SDWORD level, cmdLevel;
|
|
||||||
DROID_HIT_SIDE impact_side;
|
DROID_HIT_SIDE impact_side;
|
||||||
|
|
||||||
check_droid(psDroid);
|
check_droid(psDroid);
|
||||||
|
|
||||||
//EMP cannons do not do body damage
|
//EMP cannons do not do body damage
|
||||||
if (weaponSubClass == WSC_EMP)
|
if (weaponSubClass == WSC_EMP)
|
||||||
{
|
{
|
||||||
//store the time
|
//store the time
|
||||||
psDroid->timeLastHit = gameTime;
|
psDroid->timeLastHit = gameTime;
|
||||||
psDroid->lastHitWeapon = weaponSubClass;
|
psDroid->lastHitWeapon = weaponSubClass;
|
||||||
//quit early
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//only overwrite if the last weapon to hit was not an EMP - need the time value for this
|
//quit early
|
||||||
if (psDroid->lastHitWeapon != WSC_EMP)
|
return FALSE;
|
||||||
{
|
}
|
||||||
psDroid->timeLastHit = gameTime;
|
|
||||||
psDroid->lastHitWeapon = weaponSubClass;
|
//only overwrite if the last weapon to hit was not an EMP - need the time value for this
|
||||||
}
|
if (psDroid->lastHitWeapon != WSC_EMP)
|
||||||
|
{
|
||||||
|
psDroid->timeLastHit = gameTime;
|
||||||
|
psDroid->lastHitWeapon = weaponSubClass;
|
||||||
|
}
|
||||||
|
|
||||||
// if(selectedPlayer==0)
|
// if(selectedPlayer==0)
|
||||||
if(psDroid->player != selectedPlayer)
|
if(psDroid->player != selectedPlayer)
|
||||||
|
@ -262,34 +262,32 @@ BOOL droidDamage(DROID *psDroid, UDWORD damage, UDWORD weaponClass, UDWORD weapo
|
||||||
{
|
{
|
||||||
/* Damage has penetrated - reduce armour and body points */
|
/* Damage has penetrated - reduce armour and body points */
|
||||||
//penDamage = damage - psDroid->armour;
|
//penDamage = damage - psDroid->armour;
|
||||||
penDamage = damage - armour;
|
unsigned int penDamage = damage - armour;
|
||||||
|
|
||||||
level = getDroidLevel(psDroid);
|
// Retrieve highest, applicable, experience level
|
||||||
cmdLevel = cmdGetCommanderLevel(psDroid);
|
unsigned int level = getDroidLevel(psDroid);
|
||||||
if (level > cmdLevel)
|
|
||||||
{
|
{
|
||||||
//penDamage = (penDamage * (100 - 5 * level)) / 100;
|
unsigned int cmdLevel = cmdGetCommanderLevel(psDroid);
|
||||||
penDamage = (penDamage * (100 - 6 * level)) / 100;
|
level = MAX(level, cmdLevel);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//penDamage = (penDamage * (100 - 5 * cmdLevel)) / 100;
|
|
||||||
penDamage = (penDamage * (100 - 6 * cmdLevel)) / 100;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reduce damage taken by 6% for each experience level
|
||||||
|
penDamage = (penDamage * (100 - 6 * level)) / 100;
|
||||||
|
|
||||||
debug( LOG_ATTACK, " penetrated: %d\n", penDamage);
|
debug( LOG_ATTACK, " penetrated: %d\n", penDamage);
|
||||||
if (penDamage >= psDroid->body)
|
if (penDamage >= psDroid->body)
|
||||||
{
|
{
|
||||||
//we don't want this in multiPlayer
|
//we don't want this in multiPlayer
|
||||||
if (!bMultiPlayer)
|
if (!bMultiPlayer)
|
||||||
{
|
{
|
||||||
//hack to prevent Transporter's being blown up
|
//hack to prevent Transporter's being blown up
|
||||||
if (psDroid->droidType == DROID_TRANSPORTER)
|
if (psDroid->droidType == DROID_TRANSPORTER)
|
||||||
{
|
{
|
||||||
psDroid->body = 1;
|
psDroid->body = 1;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Droid destroyed */
|
/* Droid destroyed */
|
||||||
debug( LOG_ATTACK, " DESTROYED\n");
|
debug( LOG_ATTACK, " DESTROYED\n");
|
||||||
if(psDroid->player == selectedPlayer)
|
if(psDroid->player == selectedPlayer)
|
||||||
|
@ -338,17 +336,17 @@ BOOL droidDamage(DROID *psDroid, UDWORD damage, UDWORD weaponClass, UDWORD weapo
|
||||||
}
|
}
|
||||||
if (psDroid->body == 1)
|
if (psDroid->body == 1)
|
||||||
{
|
{
|
||||||
//we don't want this in multiPlayer
|
//we don't want this in multiPlayer
|
||||||
if (!bMultiPlayer)
|
if (!bMultiPlayer)
|
||||||
{
|
{
|
||||||
//hack to prevent Transporter's being blown up
|
//hack to prevent Transporter's being blown up
|
||||||
if (psDroid->droidType == DROID_TRANSPORTER)
|
if (psDroid->droidType == DROID_TRANSPORTER)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(psDroid->player == selectedPlayer)
|
if(psDroid->player == selectedPlayer)
|
||||||
{
|
{
|
||||||
CONPRINTF(ConsoleString,(ConsoleString,_("Unit Lost!")));
|
CONPRINTF(ConsoleString,(ConsoleString,_("Unit Lost!")));
|
||||||
scoreUpdateVar(WD_UNITS_LOST);
|
scoreUpdateVar(WD_UNITS_LOST);
|
||||||
|
@ -386,16 +384,16 @@ BOOL droidDamage(DROID *psDroid, UDWORD damage, UDWORD weaponClass, UDWORD weapo
|
||||||
/* now check for auto return on droid's secondary orders */
|
/* now check for auto return on droid's secondary orders */
|
||||||
secondaryCheckDamageLevel(psDroid);
|
secondaryCheckDamageLevel(psDroid);
|
||||||
|
|
||||||
/* now check for scripted run-away based on health */
|
/* now check for scripted run-away based on health */
|
||||||
orderHealthCheck(psDroid);
|
orderHealthCheck(psDroid);
|
||||||
|
|
||||||
|
|
||||||
//only overwrite if the last weapon to hit was not an EMP - need the time value for this
|
//only overwrite if the last weapon to hit was not an EMP - need the time value for this
|
||||||
if (psDroid->lastHitWeapon != WSC_EMP)
|
if (psDroid->lastHitWeapon != WSC_EMP)
|
||||||
{
|
{
|
||||||
psDroid->timeLastHit = gameTime;
|
psDroid->timeLastHit = gameTime;
|
||||||
psDroid->lastHitWeapon = weaponSubClass;
|
psDroid->lastHitWeapon = weaponSubClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue