Permalink
Browse files

Remove the distinction between short and long range for accuracy purp…

…oses.

Everything is now shooting at long range accuracy.
  • Loading branch information...
perim committed Jul 28, 2012
1 parent 244c8ec commit 30e0f8e65c475c094ac6032d523c94af38f2522c
Showing with 13 additions and 130 deletions.
  1. +3 −11 src/action.cpp
  2. +1 −6 src/combat.cpp
  3. +2 −12 src/function.cpp
  4. +0 −1 src/functiondef.h
  5. +4 −4 src/oprint.cpp
  6. +0 −22 src/scriptfuncs.cpp
  7. +0 −1 src/scriptfuncs.h
  8. +0 −31 src/scriptobj.cpp
  9. +0 −2 src/scriptobj.h
  10. +0 −12 src/scripttabs.cpp
  11. +3 −27 src/stats.cpp
  12. +0 −1 src/statsdef.h
View
@@ -185,15 +185,8 @@ static bool actionInAttackRange(DROID *psDroid, BASE_OBJECT *psObj, int weapon_s
}
else
{
if (weaponShortHit(psStats, psDroid->player) > weaponLongHit(psStats, psDroid->player))
{
rangeSq = psStats->shortRange * psStats->shortRange;
}
else
{
longRange = proj_GetLongRange(psStats);
rangeSq = longRange * longRange;
}
longRange = proj_GetLongRange(psStats);
rangeSq = longRange * longRange;
}
/* check max range */
@@ -1830,9 +1823,8 @@ void actionUpdateDroid(DROID *psDroid)
if (!isVtolDroid(psDroid) &&
(order->psObj->type != OBJ_STRUCTURE))
{
//move droids to within short range of the sensor now!!!!
Vector2i diff = removeZ(psDroid->pos - order->psObj->pos);
int rangeSq = asWeaponStats[psDroid->asWeaps[0].nStat].shortRange;
int rangeSq = asWeaponStats[psDroid->asWeaps[0].nStat].longRange / 2; // move close to sensor
rangeSq = rangeSq * rangeSq;
if (diff*diff < rangeSq)
{
View
@@ -162,12 +162,7 @@ bool combFire(WEAPON *psWeap, BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget, in
}
int baseHitChance = 0;
if (dist <= psStats->shortRange && dist >= psStats->minRange)
{
// get weapon chance to hit in the short range
baseHitChance = weaponShortHit(psStats,psAttacker->player);
}
else if (dist <= longRange && dist >= psStats->minRange)
if (dist <= longRange && dist >= psStats->minRange)
{
// get weapon chance to hit in the long range
baseHitChance = weaponLongHit(psStats,psAttacker->player);
View
@@ -485,7 +485,7 @@ static bool loadWeaponUpgradeFunction(const char *pData)
WEAPON_UPGRADE_FUNCTION *psFunction;
char functionName[MAX_STR_LENGTH],
weaponSubClass[MAX_STR_LENGTH];
UDWORD firePause, shortHit, longHit, damage,
UDWORD firePause, dummyVal, longHit, damage,
radiusDamage, incenDamage, radiusHit;
//allocate storage
@@ -505,7 +505,7 @@ static bool loadWeaponUpgradeFunction(const char *pData)
functionName[0] = '\0';
weaponSubClass[0] = '\0';
sscanf(pData, "%255[^,'\r\n],%255[^,'\r\n],%d,%d,%d,%d,%d,%d,%d", functionName,
weaponSubClass, &firePause, &shortHit, &longHit, &damage, &radiusDamage,
weaponSubClass, &firePause, &dummyVal, &longHit, &damage, &radiusDamage,
&incenDamage, &radiusHit);
//allocate storage for the name
@@ -518,30 +518,24 @@ static bool loadWeaponUpgradeFunction(const char *pData)
//check none of the %increases are over UBYTE max
if (firePause > UBYTE_MAX ||
shortHit > UWORD_MAX ||
longHit > UWORD_MAX ||
damage > UWORD_MAX ||
radiusDamage > UWORD_MAX ||
incenDamage > UWORD_MAX ||
radiusHit > UWORD_MAX)
{
debug(LOG_ERROR, "A percentage increase for Weapon Upgrade function is too large");
return false;
}
//copy the data across
psFunction->firePause = (UBYTE)firePause;
psFunction->shortHit = (UWORD)shortHit;
psFunction->longHit = (UWORD)longHit;
psFunction->damage = (UWORD)damage;
psFunction->radiusDamage = (UWORD)radiusDamage;
psFunction->incenDamage = (UWORD)incenDamage;
psFunction->radiusHit = (UWORD)radiusHit;
//increment the number of upgrades
//numWeaponUpgrades++;
return true;
}
@@ -1153,10 +1147,6 @@ void weaponUpgrade(FUNCTION *pFunction, UBYTE player)
}
asWeaponUpgrade[player][pUpgrade->subClass].firePause = pUpgrade->firePause;
}
if (asWeaponUpgrade[player][pUpgrade->subClass].shortHit < pUpgrade->shortHit)
{
asWeaponUpgrade[player][pUpgrade->subClass].shortHit = pUpgrade->shortHit;
}
if (asWeaponUpgrade[player][pUpgrade->subClass].longHit < pUpgrade->longHit)
{
asWeaponUpgrade[player][pUpgrade->subClass].longHit = pUpgrade->longHit;
View
@@ -143,7 +143,6 @@ struct WEAPON_UPGRADE_FUNCTION : public FUNCTION
{
WEAPON_SUBCLASS subClass; /*which weapons are affected */
UBYTE firePause; /*The % to decrease the fire pause or reload time */
UWORD shortHit; /*The % to increase the short range accuracy */
UWORD longHit; /*The % to increase the long range accuracy */
UWORD damage; /*The % to increase the damage*/
UWORD radiusDamage; /*The % to increase the radius damage*/
View
@@ -168,11 +168,11 @@ static void printWeaponInfo(const WEAPON_STATS* psStats)
CONPRINTF(ConsoleString,(ConsoleString,"Weapon: "));
printComponentInfo((COMPONENT_STATS *)psStats);
CONPRINTF(ConsoleString,(ConsoleString," sRng %d lRng %d mRng %d %s\n"
" sHt %d lHt %d pause %d dam %d\n",
psStats->shortRange, proj_GetLongRange(psStats), psStats->minRange,
CONPRINTF(ConsoleString,(ConsoleString," lRng %d mRng %d %s\n"
" lHt %d pause %d dam %d\n",
proj_GetLongRange(psStats), psStats->minRange,
proj_Direct(psStats) ? "direct" : "indirect",
weaponShortHit(psStats,(UBYTE)selectedPlayer), weaponLongHit(psStats,
weaponLongHit(psStats,
(UBYTE)selectedPlayer), weaponFirePause(psStats,(UBYTE)selectedPlayer),
weaponDamage(psStats, (UBYTE)selectedPlayer)));
CONPRINTF(ConsoleString,(ConsoleString," rad %d radHt %d radDam %d\n"
View
@@ -10681,27 +10681,6 @@ static DROID_TEMPLATE* scrCheckTemplateExists(SDWORD player, DROID_TEMPLATE *psT
return NULL;
}
bool scrWeaponShortHitUpgrade(void)
{
SDWORD player,weapIndex;
const WEAPON_STATS *psWeapStats;
if (!stackPopParams(2, VAL_INT, &player, ST_WEAPON, &weapIndex))
{
return false;
}
psWeapStats = &asWeaponStats[weapIndex];
scrFunctionResult.v.ival = asWeaponUpgrade[player][psWeapStats->weaponSubClass].shortHit;
if (!stackPushResult(VAL_INT, &scrFunctionResult))
{
return false;
}
return true;
}
bool scrWeaponLongHitUpgrade(void)
{
SDWORD player,weapIndex;
@@ -10723,7 +10702,6 @@ bool scrWeaponLongHitUpgrade(void)
return true;
}
bool scrWeaponDamageUpgrade(void)
{
SDWORD player,weapIndex;
View
@@ -651,7 +651,6 @@ extern bool scrMoveDroidStopped(void);
extern bool scrUpdateVisibleTiles(void);
extern bool scrCheckVisibleTile(void);
extern bool scrAssembleWeaponTemplate(void);
extern bool scrWeaponShortHitUpgrade(void);
extern bool scrWeaponLongHitUpgrade(void);
extern bool scrWeaponDamageUpgrade(void);
extern bool scrWeaponFirePauseUpgrade(void);
View
@@ -456,60 +456,29 @@ bool scrWeaponObjGet(UDWORD index)
switch (index)
{
case WEAPID_SHORT_RANGE:
type = VAL_INT;
scrFunctionResult.v.ival = asWeaponStats[weapIndex].shortRange;
break;
case WEAPID_LONG_RANGE:
type = VAL_INT;
scrFunctionResult.v.ival = asWeaponStats[weapIndex].longRange;
break;
case WEAPID_SHORT_HIT:
type = VAL_INT;
scrFunctionResult.v.ival = asWeaponStats[weapIndex].shortHit;
break;
case WEAPID_LONG_HIT:
type = VAL_INT;
scrFunctionResult.v.ival = asWeaponStats[weapIndex].longHit;
break;
case WEAPID_DAMAGE:
type = VAL_INT;
scrFunctionResult.v.ival = asWeaponStats[weapIndex].damage;
break;
case WEAPID_FIRE_PAUSE:
type = VAL_INT;
scrFunctionResult.v.ival = asWeaponStats[weapIndex].firePause;
break;
case WEAPID_RELOAD_TIME:
type = VAL_INT;
scrFunctionResult.v.ival = asWeaponStats[weapIndex].reloadTime;
break;
case WEAPID_NUM_ROUNDS:
type = VAL_INT;
scrFunctionResult.v.ival = asWeaponStats[weapIndex].numRounds;
break;
default:
ASSERT( false, "unknown variable index" );
View
@@ -51,9 +51,7 @@ enum _objids
OBJID_SELECTED, // if droid is selected (humans only)
OBJID_TARGET, // added object->psTarget
OBJID_GROUP, // group a droid belongs to
WEAPID_SHORT_RANGE, // short range of a weapon
WEAPID_LONG_RANGE, // short range of a weapon
WEAPID_SHORT_HIT, // weapon's chance to hit in the short range
WEAPID_LONG_HIT, // weapon's chance to hit in the long range
WEAPID_FIRE_PAUSE, // weapon's fire pause
WEAPID_RELOAD_TIME, // weapon's reload time
View
@@ -1359,10 +1359,6 @@ FUNC_SYMBOL asFuncTable[] =
4, { VAL_INT, (INTERP_TYPE)ST_BODY, (INTERP_TYPE)ST_PROPULSION, (INTERP_TYPE)ST_WEAPON },
0, 0, NULL, 0, 0, NULL, NULL },
{ "weaponShortHitUpgrade", scrWeaponShortHitUpgrade, VAL_INT,
2, { VAL_INT, (INTERP_TYPE)ST_WEAPON },
0, 0, NULL, 0, 0, NULL, NULL },
{ "weaponLongHitUpgrade", scrWeaponLongHitUpgrade, VAL_INT,
2, { VAL_INT, (INTERP_TYPE)ST_WEAPON },
0, 0, NULL, 0, 0, NULL, NULL },
@@ -1633,18 +1629,10 @@ VAR_SYMBOL asObjTable[] =
/* Weapon Stats */
//weapon short range
{ "shortRange", VAL_INT, ST_OBJECT,
(INTERP_TYPE)ST_WEAPON, WEAPID_SHORT_RANGE, scrWeaponObjGet, NULL, 0, {0}, NULL },
//weapon long range
{ "longRange", VAL_INT, ST_OBJECT,
(INTERP_TYPE)ST_WEAPON, WEAPID_LONG_RANGE, scrWeaponObjGet, NULL, 0, {0}, NULL },
//weapon short hit chance
{ "shortHit", VAL_INT, ST_OBJECT,
(INTERP_TYPE)ST_WEAPON, WEAPID_SHORT_HIT, scrWeaponObjGet, NULL, 0, {0}, NULL },
//weapon long hit chance
{ "longHit", VAL_INT, ST_OBJECT,
(INTERP_TYPE)ST_WEAPON, WEAPID_LONG_HIT, scrWeaponObjGet, NULL, 0, {0}, NULL },
View
@@ -625,7 +625,7 @@ bool loadWeaponStats(const char *pWeaponData, UDWORD bufferSize)
char fireOnMove[MAX_STR_LENGTH], weaponClass[MAX_STR_LENGTH], weaponSubClass[MAX_STR_LENGTH],
weaponEffect[MAX_STR_LENGTH], movement[MAX_STR_LENGTH], facePlayer[MAX_STR_LENGTH], //weaponEffect[15] caused stack corruption. --Qamly
faceInFlight[MAX_STR_LENGTH],lightWorld[MAX_STR_LENGTH];
UDWORD longRange, effectSize, numAttackRuns, designable;
UDWORD effectSize, numAttackRuns, designable;
UDWORD numRounds;
char *StatsName;
@@ -675,8 +675,8 @@ bool loadWeaponStats(const char *pWeaponData, UDWORD bufferSize)
WeaponName, dummy, &psStats->buildPower,&psStats->buildPoints,
&psStats->weight, &weaponsize, &dummyVal,
&psStats->body, GfxFile, mountGfx, muzzleGfx, flightGfx,
hitGfx, missGfx, waterGfx, trailGfx, &psStats->shortRange,
&psStats->longRange,&psStats->shortHit, &psStats->longHit,
hitGfx, missGfx, waterGfx, trailGfx, &dummyVal,
&psStats->longRange, &dummyVal, &psStats->longHit,
&psStats->firePause, &psStats->numExplosions, &numRounds,
&psStats->reloadTime, &psStats->damage, &psStats->radius,
&psStats->radiusHit, &psStats->radiusDamage, &psStats->incenTime,
@@ -997,24 +997,6 @@ bool loadWeaponStats(const char *pWeaponData, UDWORD bufferSize)
psStats->penetrate = false;
}
// error check the ranges
if (psStats->flightSpeed > 0 && !proj_Direct(psStats))
{
longRange = (UDWORD)proj_GetLongRange(psStats);
}
else
{
longRange = UDWORD_MAX;
}
if (psStats->shortRange > longRange)
{
debug( LOG_NEVER, "%s, flight speed is too low to reach short range (max range %d)\n", WeaponName, longRange );
}
else if (psStats->longRange > longRange)
{
debug( LOG_NEVER, "%s, flight speed is too low to reach long range (max range %d)\n", WeaponName, longRange );
}
//set the weapon sounds to default value
psStats->iAudioFireID = NO_SOUND;
psStats->iAudioImpactID = NO_SOUND;
@@ -2851,12 +2833,6 @@ UDWORD weaponReloadTime(WEAPON_STATS *psStats, UBYTE player)
psStats->weaponSubClass].firePause)/100);
}
UDWORD weaponShortHit(const WEAPON_STATS* psStats, UBYTE player)
{
return (psStats->shortHit + (psStats->shortHit * asWeaponUpgrade[player][
psStats->weaponSubClass].shortHit)/100);
}
UDWORD weaponLongHit(const WEAPON_STATS* psStats, UBYTE player)
{
return (psStats->longHit + (psStats->longHit * asWeaponUpgrade[player][
View
@@ -445,7 +445,6 @@ struct REPAIR_STATS : public COMPONENT_STATS
struct WEAPON_STATS : public COMPONENT_STATS
{
UDWORD shortRange; ///< Max distance to target for short range shot
UDWORD longRange; ///< Max distance to target for long range shot
UDWORD minRange; ///< Min distance to target for shot
UDWORD shortHit; ///< Chance to hit at short range

0 comments on commit 30e0f8e

Please sign in to comment.