]> git.localhorst.tv Git - l2e.git/blob - src/battle/Hero.cpp
added simple damage calculation formula
[l2e.git] / src / battle / Hero.cpp
1 /*
2  * Hero.cpp
3  *
4  *  Created on: Aug 6, 2012
5  *      Author: holy
6  */
7
8 #include "Hero.h"
9
10 namespace battle {
11
12 Hero::Hero()
13 : name("")
14 , sprite(0)
15
16 , weapon(0)
17 , armor(0)
18 , shield(0)
19 , helmet(0)
20 , ring(0)
21 , jewel(0)
22
23 , meleeAnimation(0)
24 , attackAnimation(0)
25 , spellAnimation(0)
26
27 , maxHealth(0)
28 , health(0)
29 , maxMana(0)
30 , mana(0)
31
32 , level(0)
33 , ip(0) {
34
35 }
36
37 Hero::~Hero() {
38
39 }
40
41
42 void Hero::SubtractHealth(int amount) {
43         if (amount > Health()) {
44                 health = 0;
45         } else {
46                 health -= amount;
47                 int ipGain(amount * 255 / health);
48                 if (ip + ipGain > 255) {
49                         ip = 255;
50                 } else {
51                         ip += ipGain;
52                 }
53         }
54 }
55
56 }