- Home /
Armour / Damage System RPG-like?
Hi all!
I'm currently developing a 3rd person zombie shooter and would like to implement some kind of Clothing / Armour System to the player character.
I know how to put on & put off clothes, but not how for example any Roleplaying-Game is handling it with "the better the armour, the more damage will be absorbed!".
If I damage the player, I just do: "health -= damage;"
Which value do I need to substract from the damage when for example the Helmet has 20 defense points and the T-Shirt 15?
I don't think World of Warcraft is then substracting (20 + 15) from the damagevalue!
Thanks for all your answers!
Mike
Answer by InfiniBuzz · Jun 09, 2013 at 06:30 PM
Hi
there are a lot of ways to do this. I assume that you have a script for your player with a method that takes damage. Now you can add properties for things like armour. To calculate this it is depending on how you want your clothing take effect. To give you a very basic example you could do something like this
damage = hitForce / currentArmor
Where damage
is the value you will substract form the players health, hitForce
is the force (damage) the enemy is hitting the player with and in currentArmor
you sum up your armor values (helmet, t-shirt) (make sure currentArmor is at a minimum of 1, thanks scribe! )
basically there is no limitation to make this more complex if you want to have many types of armor, add poisoning or armour levelling etc.
Good answer,
The only thing I'd add is to make sure currentArmor is clamped at a $$anonymous$$imum of 1 unless you want to take infinite damage when you have no armour!
+1
good point thank you :) you could use this for some sort of poisoning, but it should never be 0 of course
Thanks, this simple calculation actually does the trick :)
Answer by BlackWingsCorp · Jun 09, 2013 at 06:33 PM
hmmm... you can try something like this: public class DefenseSystem : MonoBehaviour{ public static float defense; public static bool isEquip;
void Start(){
defense = 0;
isEquip = false;
}
void Update(){
if(isEquip && isDamaged){//isDamaged is a static bool from the damaging script and damage is a static float value
health -= defense - damage; //make sure health cannot reach higher then it's max value
}
if(isDamaged && health == maxhealth)//if the damage was completly negated
health -=1;//optional
}
}
}
}
I hope this helps. Tell me how it works
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Multiple Cars not working 1 Answer
Melee-hits being recognized too often 1 Answer
Flash player when taking damage 2 Answers