Damage Calculation
KCE
Join Date: 2004-10-13 Member: 32247Members
<div class="IPBDescription">How to calculate damage</div> How do I calculate in general, how much damage a weapon will do to a player in regards to armor and distance (for gl)?
I need it for an amxmodx plugin I'm making. <!--emo&:D--><img src='http://www.unknownworlds.com/forums/html/emoticons/biggrin-fix.gif' border='0' style='vertical-align:middle' alt='biggrin-fix.gif' /><!--endemo-->
I need it for an amxmodx plugin I'm making. <!--emo&:D--><img src='http://www.unknownworlds.com/forums/html/emoticons/biggrin-fix.gif' border='0' style='vertical-align:middle' alt='biggrin-fix.gif' /><!--endemo-->
Comments
ninja edit - Your brackets eluded me. I'm not sure about the distance/gl thing. <!--emo&???--><img src='http://www.unknownworlds.com/forums/html/emoticons/confused-fix.gif' border='0' style='vertical-align:middle' alt='confused-fix.gif' /><!--endemo-->
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->adjdamage = (damage * distance) / maxdistance<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
Really like to know the formula for damage over health and armor, though...
You are asking how much damage is done to health, and how much to armor, right?
For marines, 30% of damage goes to health, and 70% goes to armor. The part that goes to armor is divided by 2 before taking away armor points. For a HA marine, 95% of damage goes to armor, and that is divided by 2 before taking away armor points. A JP marine works the same as a vanilla marine.
For aliens, it depends on the number of hives. At one hive, 70% goes to armor, and that is divided by 2 before taking away armor points. At two hives, 80% goes to armor, and that is divided by <b>2.5</b> before taking away armor points. At three hives, 90% goes to armor, and that is divided by <b>3</b> before taking away armor points.
I need it for an amxmodx plugin I'm making.<!--QuoteEnd--></td></tr></table><div class='postcolor'><!--QuoteEEnd-->
Well if you're dead,I presume the creature has done enough damage to kill you. <!--emo&:)--><img src='http://www.unknownworlds.com/forums/html/emoticons/smile-fix.gif' border='0' style='vertical-align:middle' alt='smile-fix.gif' /><!--endemo-->
Alternatively,each weapon interface on the 1-4 screen does show e.g:
Skulk- Weapon 1- Bite: "info about it" Damage: 75
Marine- Weapon 1- LMG: "info about it" Damage: 20 per shot
Or just set up a fun server and get each thing to attack you.
Btw,what mod are you planning?
The LMG actually does 10 damage per shot, so that isn't correct.
Most numbers can be found in Balance.txt in your 'ns' folder.
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
#define ARMOR_RATIO 0.3 // Armor Takes 80% of the damage (was .2 in the SDK)
#define ARMOR_BONUS 0.5 // Each Point of Armor is work 1/x points of health
//??
new Float:flNew = float(damage) * ARMOR_RATIO
new Float:flArmor = (float(damage) - flNew) * ARMOR_BONUS
new Float:armor = float(get_user_armor(victim))
// Does this use more armor than we have?
if( flArmor > armor ){
flArmor = armor;
flArmor *= (1/ARMOR_BONUS)
flNew = float(damage) - flArmor
set_user_armor(victim, 0)
}
else
set_user_armor(victim, floatround(armor - flArmor))
damage = floatround(flNew)
<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
<!--c1--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>CODE</b> </td></tr><tr><td id='CODE'><!--ec1-->
dist = get_distance(origin,vExplodeAt)//DISTANCE BETWEEN PLAYER AND EXPLOSION
maxdamage = 125 //MAX DAMAGE GL CAN DO
damradius = 350 //RADIUS OF GL EXPLOSION
dRatio = floatdiv(float(dist),float(damradius)) //CALCULATE DAMAGE RATIO
damage = maxdamage - floatround( maxdamage * dRatio) ///CALCUALTE MAX DAMAGE
<!--c2--></td></tr></table><div class='postcolor'><!--ec2-->
I have no idea who ninja is, but i coded that. Thanks to a civilian and TheAdj on the inner workings on armor absorptions/hives/etc.
The code is pretty straightforward. And it's right there for you to peruse.
And what i'm lost said is what i used.
What does this mean in balance.txt:
#define kArmorValueBase 0.50