6 #include "../graphics/fwd.h"
7 #include "../map/Entity.h"
16 static const int TYPE_ID = 301;
33 const char *Name() const { return name; }
35 Uint16 MaxHealth() const { return maxHealth; }
36 Uint16 Health() const { return health; }
37 int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
38 void SubtractHealth(int amount);
40 Uint16 MaxMana() const { return maxMana; }
41 Uint16 Mana() const { return mana; }
42 int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
43 bool CanUseMagic() const { return MaxMana() > 0; }
45 Uint8 MaxIP() const { return 255; }
46 Uint8 IP() const { return ip; }
47 int RelativeIP(int max) const { return IP() * max / MaxIP(); }
49 Stats &GetStats() { return stats; }
50 const Stats &GetStats() const { return stats; }
52 Uint8 Level() const { return level; }
53 int Experience() const { return experience; }
54 int NextLevel() const;
56 bool CanEquip(const Item &) const;
57 bool CanInvoke(const Spell &) const;
59 const Item *Equipment(EquipSlot i) const { return equipment[i]; }
60 bool Equipped(EquipSlot i) const { return equipment[i]; }
61 void RemoveEquipment(EquipSlot i) { equipment[i] = 0; }
62 void SetEquipment(EquipSlot i, const Item *item) { equipment[i] = item; }
64 std::vector<const Spell *> &Spells() { return spells; }
65 const std::vector<const Spell *> &Spells() const { return spells; }
67 graphics::Sprite *BattleSprite() { return battleSprite; }
68 const graphics::Sprite *BattleSprite() const { return battleSprite; }
69 graphics::Animation *MeleeAnimation() { return meleeAnimation; }
70 graphics::Animation *AttackAnimation() { return attackAnimation; }
71 graphics::Animation *SpellAnimation() { return spellAnimation; }
73 map::Entity &MapEntity() { return mapEntity; }
74 const map::Entity &MapEntity() const { return mapEntity; }
76 static void CreateTypeDescription();
77 static void Construct(void *);
81 void AddSpell(Spell *s) { spells.push_back(s); }
86 int maxHealth, health;
100 const Item *equipment[EQUIP_COUNT];
102 // TODO: vector does not seem to be a good choice
103 std::vector<const Spell *> spells;
105 graphics::Sprite *battleSprite;
106 graphics::Animation *meleeAnimation;
107 graphics::Animation *attackAnimation;
108 graphics::Animation *spellAnimation;
110 map::Entity mapEntity;
116 #endif /* COMMON_HERO_H_ */