39 lines
981 B
C++
39 lines
981 B
C++
class Destructible : public Persistent {
|
|
|
|
public :
|
|
float maxHp;
|
|
float hp;
|
|
float defense;
|
|
char *corpseName;
|
|
int xp; // XP gained when killing this monster (or player xp)
|
|
|
|
Destructible(float maxHp, float defense, const char *corpseName, int xp);
|
|
~Destructible();
|
|
|
|
inline bool isDead() { return hp <= 0; }
|
|
float takeDamage(Actor *owner, float damage);
|
|
virtual void die(Actor *owner);
|
|
float heal(float amount);
|
|
void load(TCODZip &zip);
|
|
void save(TCODZip &zip);
|
|
static Destructible *create(TCODZip &zip);
|
|
protected:
|
|
enum DestructibleType {
|
|
MONSTER, PLAYER
|
|
};
|
|
};
|
|
|
|
class MonsterDestructible : public Destructible {
|
|
public :
|
|
MonsterDestructible(float maxHp, float defense, const char *corpseName, int xp);
|
|
void die(Actor *owner);
|
|
void save(TCODZip &zip);
|
|
};
|
|
|
|
class PlayerDestructible : public Destructible {
|
|
public :
|
|
PlayerDestructible(float maxHp, float defense, const char *corpseName);
|
|
void die(Actor *owner);
|
|
void save(TCODZip &zip);
|
|
};
|