X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FHero.cpp;h=a3361c6045e0e368bfcbde718d51e80cfcde96ea;hb=8639675fbf1d232ab8188dd283149ab650e10336;hp=4bcc6d30175b9372170288cf0d3c3e6551d1b2da;hpb=fa3de7178227b9cc7f11c92208b5904cee3ae4c4;p=l2e.git diff --git a/src/battle/Hero.cpp b/src/battle/Hero.cpp index 4bcc6d3..a3361c6 100644 --- a/src/battle/Hero.cpp +++ b/src/battle/Hero.cpp @@ -20,18 +20,15 @@ Hero::Hero() , ring(0) , jewel(0) +, meleeAnimation(0) +, attackAnimation(0) +, spellAnimation(0) + , maxHealth(0) , health(0) , maxMana(0) , mana(0) -, attack(0) -, defense(0) -, agility(0) -, intelligence(0) -, gut(0) -, magicResistance(0) - , level(0) , ip(0) { @@ -41,4 +38,19 @@ Hero::~Hero() { } + +void Hero::SubtractHealth(int amount) { + if (amount > Health()) { + health = 0; + } else { + health -= amount; + int ipGain(amount * 255 / health); + if (ip + ipGain > 255) { + ip = 255; + } else { + ip += ipGain; + } + } +} + }