-
Notifications
You must be signed in to change notification settings - Fork 4
/
Monster.h
172 lines (155 loc) · 3.6 KB
/
Monster.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#ifndef __MONSTER_H__
#define __MONSTER_H__
#include "JMDefs.h"
#include "JLinkList.h"
#include "AIMgr.h"
#define COLOR_CHANGE_TIMEOUT 0.266f
class CAttack
{
public:
CAttack():m_dwType(-1),m_dwEffect(-1),m_szDamage(NULL){};
~CAttack(){};
int m_dwType;
int m_dwEffect;
char *m_szDamage;
};
// There will be 1 instance of CMonsterTileDef for each line in Monsters.dat
class CMonsterDef
{
// Member Variables
public:
CMonsterDef()
:m_dwFlags(0),
m_dwType(0),
m_dwIndex(0),
m_dwLevel(0),
m_fExpValue(0),
m_dwMoveType(0),
m_fBaseHP(0.0f),
m_fBaseAC(0.0f),
m_fSpeed(0.0f),
m_szName(NULL),
m_szPlural(NULL),
m_szAppear(NULL),
m_szHD(NULL)
{
m_llAttacks = new JLinkList<CAttack>;
m_Colors = new JLinkList<JColor>;
m_szAppear = new char[10];
sprintf(m_szAppear, "1d1");
};
~CMonsterDef()
{
if(m_szName)
{
delete [] m_szName;
m_szName = NULL;
}
if(m_szPlural)
{
delete [] m_szPlural;
m_szPlural = NULL;
}
if(m_szAppear)
{
delete [] m_szAppear;
m_szAppear = NULL;
}
if(m_szHD)
{
delete [] m_szHD;
m_szHD = NULL;
}
if( m_llAttacks )
{
m_llAttacks->Terminate();
m_llAttacks = NULL;
}
if( m_Colors )
{
m_Colors->Terminate();
m_Colors = NULL;
}
}
int m_dwFlags;
int m_dwType; // MT_KOBOLD, MT_DRAGON, etc.
int m_dwIndex; // index into the monster tileset for this monster type
float m_fBaseHP; // how many HP does this monster start with?
float m_fBaseAC; // what AC does this monster start with?
char *m_szName; // What do we call this thing?
JColor m_Color; // What color do we draw this thing? (Make it appropriate to the monster name...)
JLinkList<JColor> *m_Colors; // for multi-hued
float m_fSpeed; // speed of monster (affects update rate)
int m_dwMoveType; // movement type of monster
char *m_szPlural; // how to refer to more than one of this monster
char *m_szAppear; // how many copies of this monster show up at first
char *m_szHD; // NdM form of this monster's hit dice.
JLinkList <CAttack> *m_llAttacks; // this monster's attacks
int m_dwLevel; // earliest dungeon level to place this monster
float m_fExpValue; // how much XP do you get for killing this monster
protected:
private:
// Member Functions
public:
protected:
private:
};
// There will be 1 instance of CMonster for each monster on the current dungeon level
class CMonster
{
// Member Variables
public:
float m_fHP;
float m_fCurHP;
float m_fLastHPTime;
float m_fCurAC;
// JVector m_vPos;
float m_fColorChangeInterval;
CMonsterDef *m_md;
CLink <CMonster> *m_pllLink;
CAIBrain *m_pBrain; // this is the place to get info for the AI.
char *GetName()
{
if( !m_md )
{
return NULL;
}
return m_md->m_szName;
};
float Attack();
float Damage( float fDamageMult );
bool Hit( float &fRoll );
int TakeDamage( float fDamageMult );
JVector GetPos()
{
if( m_pBrain != NULL )
{
return m_pBrain->m_vPos;
}
return JVector(-9999,-9999);
}
void SetPos(JVector vNewPos)
{
if( m_pBrain != NULL )
{
m_pBrain->m_vPos = vNewPos;
}
}
protected:
void SetColor();
private:
// Member Functions
public:
CMonster();
~CMonster();
static JResult CreateMonster(CMonsterDef *pmd);
JResult SpawnMonster();
void PreDraw();
void Draw();
void PostDraw();
protected:
void Init(CMonsterDef *pmd);
void InitBrain(CMonsterDef *pmd);
private:
};
#endif // __MONSTER_H__