-
Notifications
You must be signed in to change notification settings - Fork 1
/
MonsterInfo.cpp
222 lines (174 loc) · 7.3 KB
/
MonsterInfo.cpp
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/// --------------------------------------------------------------------------------------------------------------------------------
// DEMISERL
// Copyright 2014 Corremn
//
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
// $HeadURL: $
// --------------------------------------------------------------------------------------------------------------------------------
#include "WorldBuilder.h"
#include "MonsterInfo.h"
#include "EffectManager.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
void MonsterInfo::ShowMonsterInfo(MonsterData* monster)
{
//#ifdef _DEBUG
// ShowCompleteMonsterInfo(monster);
//#else
ShowNormalMonsterInfo(monster);
//#endif
}
void MonsterInfo::ShowNormalMonsterInfo(MonsterData* monster)
{
World.getTextManager().ClearDisplayLines();
World.getTextManager().SetDisplayLine(0, "%s", monster->monster.name.c_str());
World.getTextManager().SetDisplayLine(1, "==============");
World.getTextManager().SetDisplayLine(3, "%s", World.getMonsterManager().getDescription(monster->monster).c_str());
float max_stamina = (float)monster->monster.MaxStamina();
float cur_stamina = (float)monster->monster.stamina;
int state = monster->GetState();
float wounded = (max_stamina - cur_stamina) / max_stamina * 100;
char health[32];
char status[32];
if (wounded < 20)
strcpy(health, "healthy");
else if (wounded < 50)
strcpy(health, "wounded");
else if (wounded < 80)
strcpy(health, "very wounded");
else
strcpy(health, "almost dead");
if (monster->isPlayer())
strcpy(status, "You are ready for anything.");
else
{
switch (state)
{
case normal: strcpy(status, "It has not seen you."); break;
case sentry: strcpy(status, "It appears asleep."); break;
case hostile: strcpy(status, "It is hostile."); break;
case waking: strcpy(status, "It looked annoyed."); break;
case asleep: strcpy(status, "It is asleep."); break;
}
}
if (monster->isPlayer())
World.getTextManager().SetDisplayLine(5, "You look %s.", health);
else
World.getTextManager().SetDisplayLine(5, "It looks %s.", health);
//sprintf(buf,"%s",status);
World.getTextManager().SetDisplayLine(6, "%s", status);
int pSkill = World.getMonsterManager().Player()->Skill();
int tSkill = monster->Skill();
if (tSkill < 6) //0-5
World.getTextManager().SetDisplayLine(7, "Experience: Low");
else if (tSkill < 7) //6
World.getTextManager().SetDisplayLine(7, "Experience: Average");
else if (tSkill < 9) //6-7
World.getTextManager().SetDisplayLine(7, "Experience: Medium");
else if (tSkill < 11) //8-9
World.getTextManager().SetDisplayLine(7, "Experience: High");
else //>=10
World.getTextManager().SetDisplayLine(7, "Experience: Very High");
//inventory
World.getTextManager().SetDisplayLine(9, "Equipment");
ITEMLIST::iterator it;
int i = 10;
for (it = monster->inventory.begin(); it != monster->inventory.end(); it++, i++)
{
#ifdef _DEBUG
World.getTextManager().SetDisplayLine(i, "%s", it->GetName().c_str());
#else
if (it->equipped)
{
World.getTextManager().SetDisplayLine(i, "%s", it->GetName().c_str());
}
else
i--;
#endif
}
i++;
if (monster->monster.effectList.size() > 0)
World.getTextManager().SetDisplayLine(i++, "Active Effects"); i++;
EffectManager effectManager;
EFFECTLIST::iterator eff;
for (eff = monster->monster.effectList.begin(); eff != monster->monster.effectList.end(); eff++, i++)
{
if (eff->strength > 0)
{
std::string eff_msg = effectManager.EffectName(eff->type);
for (int e = 1; e < eff->strength; e++)
eff_msg.append("!");
World.getTextManager().SetDisplayLine(i, (char *)eff_msg.c_str());
}
}
i++;
if (monster->monster.hasResistance() > 0)
World.getTextManager().SetDisplayLine(i++, "Resistances and vulnerabilities"); i++;
BRANDMAP::iterator resist_it;
for (resist_it = monster->monster.resistanceMap.begin(); resist_it != monster->monster.resistanceMap.end(); resist_it++, i++)
{
World.getTextManager().SetDisplayLine(i, " %s (%d)", ResistanceBrands::GetResistanceName(resist_it->first), resist_it->second);
}
World.getTextManager().SetDisplayLine(39, "[x] to Return to looking.");
}
void MonsterInfo::ShowCompleteMonsterInfo(MonsterData* monster)
{
int i;
for (i = 3; i < 30; i++)
World.getTextManager().SetDisplayLine(i, "");
char buf[128];
World.getTextManager().SetDisplayLine(0, "%s", monster->monster.name.c_str());
World.getTextManager().SetDisplayLine(1, "==========");
World.getTextManager().SetDisplayLine(3, "");
sprintf(buf, "Stamina: %d", monster->Stamina());
World.getTextManager().SetDisplayLine(5, buf);
sprintf(buf, "Skill: %d(+%d)", monster->AdjustedSkill(), monster->AdjustedSkill() - monster->Skill());
World.getTextManager().SetDisplayLine(6, buf);
switch (monster->GetState())
{
case asleep: sprintf(buf, "State: asleep"); break;
case sentry: sprintf(buf, "State: sentry"); break;
case normal: sprintf(buf, "State: normal"); break;
case hostile: sprintf(buf, "State: hostile"); break;
case dead: sprintf(buf, "State: dead"); break;
}
World.getTextManager().SetDisplayLine(7, buf);
sprintf(buf, "Experience: %d", monster->experience);
World.getTextManager().SetDisplayLine(8, buf);
sprintf(buf, "Experience Level: %d", monster->experience_level);
World.getTextManager().SetDisplayLine(9, buf);
sprintf(buf, "Kills: %d", monster->Kills());
World.getTextManager().SetDisplayLine(10, buf);
sprintf(buf, "Dungeon Level: %d", monster->level);
World.getTextManager().SetDisplayLine(11, buf);
sprintf(buf, "Inventory Items %d", monster->inventory.size());
World.getTextManager().SetDisplayLine(13, buf);
ITEMLIST::iterator it;
i = 15;
for (it = monster->inventory.begin(); it != monster->inventory.end(); it++, i++)
{
// if(it->equipped)
{
World.getTextManager().SetDisplayLine(i, "%s", it->GetName().c_str());
}
}
i++;
World.getTextManager().SetDisplayLine(i++, "Effects");
EffectManager effectManager;
EFFECTLIST::iterator eff;
for (eff = monster->monster.effectList.begin(); eff != monster->monster.effectList.end(); eff++, i++)
{
if (eff->strength > 0)
World.getTextManager().SetDisplayLine(i, (char*)effectManager.EffectName(eff->type).c_str());
}
/*EFFECTMAP_CITERATOR eff;
for(eff=monster->monster.effectMap.begin();eff != monster->monster.effectMap.end();it++,i++)
{
if(eff->second > 0)
World.getTextManager().SetDisplayLine(i,(char*)effectManager.EffectName(eff->first).c_str());
}*/
World.getTextManager().SetDisplayLine(39, "[x] to Exit");
}