Skip to content

Commit

Permalink
Allow EMP weapon subclasses to do actual damage
Browse files Browse the repository at this point in the history
Also create a new stat "empRadius" to set the EMP blast radius instead of being reliant on "radius" which is for splash damage.

The EMP radius will only determine the area where the EMP effect will take place.
  • Loading branch information
KJeff01 committed Aug 27, 2023
1 parent f410d02 commit fa72ffe
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 102 deletions.
14 changes: 10 additions & 4 deletions data/mp/stats/weapons.json
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,10 @@
"Bomb6-VTOL-EMP": {
"buildPoints": 1000,
"buildPower": 225,
"damage": 200,
"designable": 1,
"effectSize": 100,
"empRadius": 512,
"facePlayer": 1,
"firePause": 10,
"flightGfx": "FXLBMBE2.PIE",
Expand All @@ -662,7 +664,8 @@
"name": "VTOL EMP Missile Launcher",
"numAttackRuns": 1,
"numExplosions": 1,
"radius": 512,
"radius": 256,
"radiusDamage": 200,
"radiusLife": 10,
"recoilValue": 10,
"rotate": 180,
Expand Down Expand Up @@ -1867,6 +1870,7 @@
"damage": 70,
"designable": 1,
"effectSize": 100,
"empRadius": 192,
"facePlayer": 1,
"firePause": 130,
"flightGfx": "FXBeam.PIE",
Expand All @@ -1887,7 +1891,8 @@
"muzzleGfx": "FXHBLas.PIE",
"name": "EMP Cannon",
"numExplosions": 1,
"radius": 192,
"radius": 128,
"radiusDamage": 20,
"recoilValue": 150,
"rotate": 180,
"shortHit": 70,
Expand Down Expand Up @@ -3463,9 +3468,10 @@
"MortarEMP": {
"buildPoints": 1000,
"buildPower": 200,
"damage": 60,
"damage": 40,
"designable": 1,
"effectSize": 100,
"empRadius": 160,
"facePlayer": 1,
"fireOnMove": 0,
"firePause": 90,
Expand All @@ -3488,7 +3494,7 @@
"name": "EMP Mortar",
"numExplosions": 1,
"radius": 160,
"radiusDamage": 60,
"radiusDamage": 30,
"radiusLife": 10,
"recoilValue": 150,
"shortHit": 40,
Expand Down
12 changes: 3 additions & 9 deletions src/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ int objArmour(const BASE_OBJECT *psObj, WEAPON_CLASS weaponClass)
* \param weaponSubClass the subclass of the weapon that deals the damage
* \return < 0 when the dealt damage destroys the object, > 0 when the object survives
*/
int32_t objDamage(BASE_OBJECT *psObj, unsigned damage, unsigned originalhp, WEAPON_CLASS weaponClass, WEAPON_SUBCLASS weaponSubClass, bool isDamagePerSecond, int minDamage)
int32_t objDamage(BASE_OBJECT *psObj, unsigned damage, unsigned originalhp, WEAPON_CLASS weaponClass, WEAPON_SUBCLASS weaponSubClass, bool isDamagePerSecond, int minDamage, bool empRadiusHit)
{
int level = 1;
int armour = objArmour(psObj, weaponClass);
Expand All @@ -415,8 +415,8 @@ int32_t objDamage(BASE_OBJECT *psObj, unsigned damage, unsigned originalhp, WEAP
psObj->lastHitWeapon = weaponSubClass;
}

// EMP cannons do no damage, if we are one return now
if (weaponSubClass == WSC_EMP)
// EMP weapon radius should not do actual damage
if (weaponSubClass == WSC_EMP && empRadiusHit)
{
return 0;
}
Expand Down Expand Up @@ -508,12 +508,6 @@ unsigned int objGuessFutureDamage(WEAPON_STATS *psStats, unsigned int player, BA

damage = calcDamage(weaponDamage(psStats, player), psStats->weaponEffect, psTarget);

// EMP cannons do no damage, if we are one return now
if (psStats->weaponSubClass == WSC_EMP)
{
return 0;
}

// apply game difficulty setting
damage = modifyForDifficultyLevel(damage, psTarget->player != selectedPlayer);
armour = objArmour(psTarget, psStats->weaponClass);
Expand Down
2 changes: 1 addition & 1 deletion src/combat.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool combFire(WEAPON *psWeap, BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget, in
if any support a counter battery sensor*/
void counterBatteryFire(BASE_OBJECT *psAttacker, BASE_OBJECT *psTarget);

int32_t objDamage(BASE_OBJECT *psObj, unsigned damage, unsigned originalhp, WEAPON_CLASS weaponClass, WEAPON_SUBCLASS weaponSubClass, bool isDamagePerSecond, int minDamage);
int32_t objDamage(BASE_OBJECT *psObj, unsigned damage, unsigned originalhp, WEAPON_CLASS weaponClass, WEAPON_SUBCLASS weaponSubClass, bool isDamagePerSecond, int minDamage, bool empRadiusHit);

unsigned int objGuessFutureDamage(WEAPON_STATS *psStats, unsigned int player, BASE_OBJECT *psTarget);

Expand Down
6 changes: 3 additions & 3 deletions src/droid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ void addDroidDeathAnimationEffect(DROID *psDroid)
* \return > 0 when the dealt damage destroys the droid, < 0 when the droid survives
*
*/
int32_t droidDamage(DROID *psDroid, unsigned damage, WEAPON_CLASS weaponClass, WEAPON_SUBCLASS weaponSubClass, unsigned impactTime, bool isDamagePerSecond, int minDamage)
int32_t droidDamage(DROID *psDroid, unsigned damage, WEAPON_CLASS weaponClass, WEAPON_SUBCLASS weaponSubClass, unsigned impactTime, bool isDamagePerSecond, int minDamage, bool empRadiusHit)
{
int32_t relativeDamage;

Expand All @@ -286,7 +286,7 @@ int32_t droidDamage(DROID *psDroid, unsigned damage, WEAPON_CLASS weaponClass, W
damage *= 3;
}

relativeDamage = objDamage(psDroid, damage, psDroid->originalBody, weaponClass, weaponSubClass, isDamagePerSecond, minDamage);
relativeDamage = objDamage(psDroid, damage, psDroid->originalBody, weaponClass, weaponSubClass, isDamagePerSecond, minDamage, empRadiusHit);

if (relativeDamage > 0)
{
Expand Down Expand Up @@ -862,7 +862,7 @@ void droidUpdate(DROID *psDroid)
else
{
// do hardcoded burn damage (this damage automatically applied after periodical damage finished)
droidDamage(psDroid, BURN_DAMAGE, WC_HEAT, WSC_FLAME, gameTime - deltaGameTime / 2 + 1, true, BURN_MIN_DAMAGE);
droidDamage(psDroid, BURN_DAMAGE, WC_HEAT, WSC_FLAME, gameTime - deltaGameTime / 2 + 1, true, BURN_MIN_DAMAGE, false);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/droid.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ UDWORD calcTemplatePower(const DROID_TEMPLATE *psTemplate);
bool idfDroid(DROID *psDroid);

/* Do damage to a droid */
int32_t droidDamage(DROID *psDroid, unsigned damage, WEAPON_CLASS weaponClass, WEAPON_SUBCLASS weaponSubClass, unsigned impactTime, bool isDamagePerSecond, int minDamage);
int32_t droidDamage(DROID *psDroid, unsigned damage, WEAPON_CLASS weaponClass, WEAPON_SUBCLASS weaponSubClass, unsigned impactTime, bool isDamagePerSecond, int minDamage, bool empRadiusHit);

/* The main update routine for all droids */
void droidUpdate(DROID *psDroid);
Expand Down
4 changes: 2 additions & 2 deletions src/feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void featureStatsShutDown()
* \param weaponClass,weaponSubClass the class and subclass of the weapon that deals the damage
* \return < 0 never, >= 0 always
*/
int32_t featureDamage(FEATURE *psFeature, unsigned damage, WEAPON_CLASS weaponClass, WEAPON_SUBCLASS weaponSubClass, unsigned impactTime, bool isDamagePerSecond, int minDamage)
int32_t featureDamage(FEATURE *psFeature, unsigned damage, WEAPON_CLASS weaponClass, WEAPON_SUBCLASS weaponSubClass, unsigned impactTime, bool isDamagePerSecond, int minDamage, bool empRadiusHit)
{
int32_t relativeDamage;

Expand All @@ -164,7 +164,7 @@ int32_t featureDamage(FEATURE *psFeature, unsigned damage, WEAPON_CLASS weaponCl
debug(LOG_ATTACK, "feature (id %d): body %d armour %d damage: %d",
psFeature->id, psFeature->body, psFeature->psStats->armourValue, damage);

relativeDamage = objDamage(psFeature, damage, psFeature->psStats->body, weaponClass, weaponSubClass, isDamagePerSecond, minDamage);
relativeDamage = objDamage(psFeature, damage, psFeature->psStats->body, weaponClass, weaponSubClass, isDamagePerSecond, minDamage, empRadiusHit);

// If the shell did sufficient damage to destroy the feature
if (relativeDamage < 0)
Expand Down
2 changes: 1 addition & 1 deletion src/feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bool destroyFeature(FEATURE *psDel, unsigned impactTime);
/* get a feature stat id from its name */
SDWORD getFeatureStatFromName(const WzString &name);

int32_t featureDamage(FEATURE *psFeature, unsigned damage, WEAPON_CLASS weaponClass, WEAPON_SUBCLASS weaponSubClass, unsigned impactTime, bool isDamagePerSecond, int minDamage);
int32_t featureDamage(FEATURE *psFeature, unsigned damage, WEAPON_CLASS weaponClass, WEAPON_SUBCLASS weaponSubClass, unsigned impactTime, bool isDamagePerSecond, int minDamage, bool empRadiusHit);

void featureInitVars();

Expand Down
Loading

0 comments on commit fa72ffe

Please sign in to comment.