• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Damage formula help

Status
Not open for further replies.
Level 11
Joined
Sep 14, 2009
Messages
284
Hi. I have remade the hero attributes to 3 stats: Spell Power, Resistance and Crit Chance (instead of str, agi and int).
The one I have a problem with is Resistance. This stat is supposed to reduce magic damage the same way as armor reduces physical dmg.
The problem is that when enemies have < 0 resistance, they do not take bonus dmg, but instead take reduced dmg. ?.?

Lets say an enemy with -2 Resistance. A spell is cast that deals 60 magic damage. The enemy is supposed to take 61,2 damage. But for some reason instead recieves 58,8 damage.

Here is the trigger for reducing magic dmg:
Take in mind that it uses the same formula as armor, and the constant factor is 0.01. Agility is Resistance. (I use Bribe dmg detection system).

  • GetResistance
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • AbilityMagical Equal to (==) True
    • Actions
      • Set GetResistanceReductionAmount = (((Real((Agility of DamageEventTarget (Include bonuses)))) x 0.01) / (1.00 + ((Real((Agility of DamageEventTarget (Include bonuses)))) x 0.01)))
      • Set DamageEventAmount = (DamageEventAmount x (1.00 - GetResistanceReductionAmount))
 
Level 12
Joined
Oct 16, 2010
Messages
680
well x/1+x always will be 0<=a<1

1-a always be positive but below or equal 1

if you multiplicate d(damage) with somthing lower than 1 than it will be lowered
but u telling that a unit has -2 resist but how? with this formula it can not happen
not even with 0 agi:/
 
Level 19
Joined
Jul 14, 2011
Messages
875
So thats (-2*0.01)/(1+(-2)*0.01) = -0.02/(1-0.02) = -0.02/0.88 = -1/44
... which means DamageEventAmount = DamageEventAmount * (1.00 - (-1/44)) = DamageEventAmount * 45/44 (An increase in damage)

I dont see anything wrong with the maths, although in this case it would be simpler to do:
  • Set DamageEventAmount = (DamageEventAmount - DamageEventAmount * (Real((Agility of DamageEventTarget (Include bonuses))))/100))
 
Level 11
Joined
Sep 14, 2009
Messages
284
Nvm I fixed it. It appears that armor uses a totally different formula for negative armor values:

"Damage Reduction or Increases for Armor
For positive Armor, damage reduction =((armor)*0.06)/(1+0.06*(armor))
For negative Armor, it is damage increase = 2-0.94^(-armor) since you take more damage for negative armor scores."

http://classic.battle.net/war3/basics/armorandweapontypes.shtml

So I used that one instead, and it works somewhat correctly but not exactly since it converts the real number down to 3 commas.
 
Level 12
Joined
Oct 16, 2010
Messages
680
umm... so you weren't talking about magic res?...ok it's good that you solved it:D

but how does armor interferes with your damage calculation? u use a dds right? (think of DamageEventAmount) Bribe's damage engine i think

Or maybe i misunderstand u again:D
 
Level 11
Joined
Sep 14, 2009
Messages
284
Ok so I need some help again. The trigger editor is getting on my nerves. Ignore the previous of my post (different formulas).

So I have this trigger:

  • GetResistance
    • Events
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Agility of GetResistanceReductionUnit (Include bonuses)) Less than or equal to (<=) 0
        • Then - Actions
          • Set GetResistanceReductionAmount = (2.00 - (100.00 / (100.00 - (Real((Agility of GetResistanceReductionUnit (Include bonuses)))))))
        • Else - Actions
          • Set GetResistanceReductionAmount = (100.00 / (100.00 + (Real((Agility of GetResistanceReductionUnit (Include bonuses))))))
Agility is the stat for Magic Resistance.
This trigger runs everytime before a unit deals magic damage.
GetResistanceReductionUnit = Unit that will take damage.
GetResistanceReductionAmount = Multiplier of the amount of damage dealt.

Formula for negative Magic Resistance:
GetResistanceReductionAmount = 2 - (100/100-(Agility))
Damage = GetResistanceReductionAmount x Damage

Two examples of the problem:
Example 1:
A unit has -1 Resistance(Agility). The unit will take 60 damage.
2 - (100/100-(-1)) = 1,01
1,01 x 60 = 60,6
In the game this unit only takes 56,106 damage.

Example 2:
A unit has -10 Resistance. The unit will take 60 damage.
2 - (100/100-(-10)) = 1,091
1,091 x 60 = 65,46
In the game this unit only takes 61,750 damage.

EDIT: Omfg, I'm so stupid. I accidently used damage type "normal" instead of "unknown", cuasing the enemy's armor to reduce the damage as well.

Solved.
 
Last edited:
Status
Not open for further replies.
Top