0 votes

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...

in Engine by (87 points)

1 Answer

0 votes
Best answer

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
by (334 points)
selected by

Thank you very much, works like a charm !

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.