Jump to content
  • Advertisement
Sign in to follow this  
muntahu

Armor, Health, Damages

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!