]> git.localhorst.tv Git - l2e.git/blob - src/common/Hero.h
put stat increments in level ladder
[l2e.git] / src / common / Hero.h
1 #ifndef COMMON_HERO_H_
2 #define COMMON_HERO_H_
3
4 namespace common {
5         class Item;
6         class LevelUp;
7         class Spell;
8         class Upgrade;
9 }
10 namespace graphics {
11         class Animation;
12         class Sprite;
13 }
14
15 #include "Stats.h"
16 #include "../map/Entity.h"
17
18 #include <vector>
19
20 namespace common {
21
22 class Hero {
23
24 public:
25         static const int TYPE_ID = 301;
26
27 public:
28         Hero();
29         ~Hero() { }
30
31 public:
32         enum EquipSlot {
33                 EQUIP_WEAPON,
34                 EQUIP_ARMOR,
35                 EQUIP_SHIELD,
36                 EQUIP_HELMET,
37                 EQUIP_RING,
38                 EQUIP_JEWEL,
39                 EQUIP_COUNT,
40         };
41
42         enum UpgradeType {
43                 UPGRADE_LVL,
44                 UPGRADE_MHP,
45                 UPGRADE_MMP,
46                 UPGRADE_ATK,
47                 UPGRADE_DFP,
48                 UPGRADE_STR,
49                 UPGRADE_AGL,
50                 UPGRADE_INT,
51                 UPGRADE_GUT,
52                 UPGRADE_MGR,
53         };
54
55         const char *Name() const { return name; }
56
57         Uint16 MaxHealth() const { return maxHealth; }
58         Uint16 Health() const { return health; }
59         int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
60         void SubtractHealth(int amount);
61
62         Uint16 MaxMana() const { return maxMana; }
63         Uint16 Mana() const { return mana; }
64         int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
65         bool CanUseMagic() const { return MaxMana() > 0; }
66
67         Uint8 MaxIP() const { return 255; }
68         Uint8 IP() const { return ip; }
69         int RelativeIP(int max) const { return IP() * max / MaxIP(); }
70
71         Stats &GetStats() { return stats; }
72         const Stats &GetStats() const { return stats; }
73
74         Uint8 Level() const { return level; }
75         int Experience() const { return experience; }
76         int NextLevel() const;
77
78         void AddExperience(int, std::vector<Upgrade> &);
79
80         bool CanEquip(const Item &) const;
81         bool CanInvoke(const Spell &) const;
82
83         const Item *Equipment(EquipSlot i) const { return equipment[i]; }
84         bool Equipped(EquipSlot i) const { return equipment[i]; }
85         void RemoveEquipment(EquipSlot i) { equipment[i] = 0; }
86         void SetEquipment(EquipSlot i, const Item *item) { equipment[i] = item; }
87
88         std::vector<const Spell *> &Spells() { return spells; }
89         const std::vector<const Spell *> &Spells() const { return spells; }
90
91         graphics::Sprite *BattleSprite() { return battleSprite; }
92         const graphics::Sprite *BattleSprite() const { return battleSprite; }
93         graphics::Animation *MeleeAnimation() { return meleeAnimation; }
94         graphics::Animation *AttackAnimation() { return attackAnimation; }
95         graphics::Animation *SpellAnimation() { return spellAnimation; }
96
97         map::Entity &MapEntity() { return mapEntity; }
98         const map::Entity &MapEntity() const { return mapEntity; }
99
100         static void CreateTypeDescription();
101         static void Construct(void *);
102
103 public:
104         void SetMaxHealth(int h) { maxHealth = h; }
105         void SetHealth(int h) { health = h; }
106         void AddSpell(Spell *s) { spells.push_back(s); }
107
108 private:
109         const char *name;
110
111         int maxHealth, health;
112         int maxMana, mana;
113         int ip;
114
115         Stats stats;
116
117         int level;
118         int experience;
119
120         LevelUp *levelLadder;
121         int numLevels;
122
123         int useMask;
124
125         const Item *equipment[EQUIP_COUNT];
126
127         // TODO: vector does not seem to be a good choice
128         std::vector<const Spell *> spells;
129
130         graphics::Sprite *battleSprite;
131         graphics::Animation *meleeAnimation;
132         graphics::Animation *attackAnimation;
133         graphics::Animation *spellAnimation;
134
135         map::Entity mapEntity;
136
137 };
138
139 }
140
141 #endif