Simple armor formula

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By wildboar

Looking for simple enough armor (damage restriction) formula for moba like game.

Does not need armor piercing or anything like that, just looking to remove some damage from attacks based on float armor an unit might have…

:bust_in_silhouette: Reply From: bloodsign

I’m not sure if it’s simple, but several games have different ways they implement the interaction between armor and damage.

For example:

damage = 15
hp = 100
armor = 10

#no armor
hp = hp - damage
>hp: 85 

#with armor1
damage = damage - armor
damage = clamp(damage, 0, max_damage) #prevents having negative values
hp = hp - damage
>hp: 95

#with armor2
damage = damage - (damage * (armor/max_armor))  #assuming max_armor = 99
hp = hp - damage
>hp: 86.51

Thank you very much, works like a charm !

wildboar | 2021-02-13 04:47