Armor/Damage Type Calculation issue

xDragonxDragon Join Date: 2012-04-04 Member: 149948Members, NS2 Playtester, Squad Five Gold, NS2 Map Tester, Reinforced - Shadow
edited May 2012 in NS2 General Discussion
In working on various things within NS2 i noticed an issue with damage types and how they damage armor. It appears that when you take damage, a fixed value is used to calculate the hp/armor split, which is .7. The problem with that is that for damage types other that normal, like light, is that you will take too much HP damage compared to armor. Lerk spikes/shotgun are good examples, where if a marine has A3 they will run out of health before armor due to lerk spikes. I looked over the code from DamageTypes.lua, which is as shown below:

kBaseArmorUseFraction = 0.7

// Each point of armor blocks a point of health but is only destroyed at half that rate (like NS1)
// Thanks Harimau!
local healthPointsBlocked = math.min(healthPerArmor * target.armor, armorFractionUsed * damage)
armorUsed = healthPointsBlocked / healthPerArmor

// Anything left over comes off of health
healthUsed = damage - healthPointsBlocked

Which works correctly (somewhat) for normal damage where armor is worth 2 points of HP, however it does not attempt to calculate for any differences. I ended up modifying it to dynamically calculate the ArmorUseFraction based on healthPerArmor, which seems to work correctly for any type that Ive tested sofar.

// Each point of armor blocks a point of health but is only destroyed at half that rate (like NS1)
// This can account for varying amounts of health per point of armor correctly (like hive 3 armor bonus in NS1, or light/heavy damage in NS2).
local healthPointsBlocked = math.min(healthPerArmor * target.armor, ((healthPerArmor)/(healthPerArmor + 1)) * damage)

// Round value here to prevent issues later.
healthPointsBlocked = math.ceil(healthPointsBlocked)
armorUsed = healthPointsBlocked / healthPerArmor

// Anything left over comes off of health
healthUsed = damage - healthPointsBlocked

This however may not work correctly for the exo, which may have a much different distribution of HP to armor.
Sign In or Register to comment.