# Armor, Health, Damages

This topic is 2881 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi guys,

I need help on how to calculate armor reduction from damages which will affect health.
So, for example the player is hit by bullet, and gets 20 damages.
if armor is greater than 0, means damages can be reduced by armor.

i have tried manually,
damages - 5
armor - 5
But this is clearly not an algorithm, it's just decreasing the damages with constant number
Random numbers method also sounds silly.

Anyone can help to find the best way?

Thank you

##### Share on other sites
i would say

 int tmpDamageVal = damages -= armor; if ( tmpDamageVal > 0 ) { health -= tmpDamageVal; armor = 0; } else { armor -= tmpDamageVal; } 

that is what i can think of off the top of my head, so it might be wrong.

##### Share on other sites
For starters, a damage system can be as complex as you want it to be.

Some games use armor as an extra health bar that takes dmg 1 to 1, the difference being that it does not kill you when depleted and is recharged by a different item than health.

Armor might be a multiplier factor to damage, for instance, a light armor will take 25% of damage leaving the remaining 75% to hit health, and the absortion changes depending on the armor.

Armor can also perform a change in type of damage, an armor that can absorb energy damage might convert energy to simple blunt damage on the wielder, if 1 energy damage point equals to 5 hp and 1 blunt damage equals to 1 hp, the armor might convert energy into blunt on a given proportion 1 to 1 or 1 to x, thus reducing damage taken to hp.

A simple factor system can be as follows:

 struct Armor { ArmorPoints = 100; ArmorFactor = 0.75; } void ApplyDamage(int Damage) { if(this.Armor.ArmorPoints > 0) { this.Armor.ArmorPoints -= Damage * this.Armor.ArmorFactor; this.HealthPoints -= Damage * (1 - this.Armor.ArmorFactor); } else { this.HealthPoints -= Damage; } } 

This is very simple but serves its purpose, more complex systems can be applied, for instance if your game is an RPG, values would likely be altered by the characters properties such as agility.

##### Share on other sites

For starters, a damage system can be as complex as you want it to be.

Some games use armor as an extra health bar that takes dmg 1 to 1, the difference being that it does not kill you when depleted and is recharged by a different item than health.

Armor might be a multiplier factor to damage, for instance, a light armor will take 25% of damage leaving the remaining 75% to hit health, and the absortion changes depending on the armor.

Armor can also perform a change in type of damage, an armor that can absorb energy damage might convert energy to simple blunt damage on the wielder, if 1 energy damage point equals to 5 hp and 1 blunt damage equals to 1 hp, the armor might convert energy into blunt on a given proportion 1 to 1 or 1 to x, thus reducing damage taken to hp.

A simple factor system can be as follows:

 struct Armor { ArmorPoints = 100; ArmorFactor = 0.75; } void ApplyDamage(int Damage) { if(this.Armor.ArmorPoints > 0) { this.Armor.ArmorPoints -= Damage * this.Armor.ArmorFactor; this.HealthPoints -= Damage * (1 - this.Armor.ArmorFactor); } else { this.HealthPoints -= Damage; } } 

This is very simple but serves its purpose, more complex systems can be applied, for instance if your game is an RPG, values would likely be altered by the characters properties such as agility.

Yes, got it..
it's so simple..
Thanks guys

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633674
• Total Posts
3013277
×