]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/Hero.cpp
put hero into a variable when applying damage for debugging purposes
[l2e.git] / src / battle / Hero.cpp
index faaf841bf7710139b1be6e475913e55d62eae9e7..a3361c6045e0e368bfcbde718d51e80cfcde96ea 100644 (file)
@@ -9,14 +9,48 @@
 
 namespace battle {
 
-Hero::Hero() {
-       // TODO Auto-generated constructor stub
+Hero::Hero()
+: name("")
+, sprite(0)
+
+, weapon(0)
+, armor(0)
+, shield(0)
+, helmet(0)
+, ring(0)
+, jewel(0)
+
+, meleeAnimation(0)
+, attackAnimation(0)
+, spellAnimation(0)
+
+, maxHealth(0)
+, health(0)
+, maxMana(0)
+, mana(0)
+
+, level(0)
+, ip(0) {
 
 }
 
 Hero::~Hero() {
-       // TODO Auto-generated destructor stub
 
 }
 
+
+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;
+               }
+       }
+}
+
 }