forked from otland/forgottenserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonsters.h
190 lines (151 loc) · 4.41 KB
/
monsters.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/**
* The Forgotten Server - a free and open-source MMORPG server emulator
* Copyright (C) 2015 Mark Samman <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef FS_MONSTERS_H_776E8327BCE2450EB7C4A260785E6C0D
#define FS_MONSTERS_H_776E8327BCE2450EB7C4A260785E6C0D
#include "creature.h"
#define MAX_LOOTCHANCE 100000
#define MAX_STATICWALK 100
struct LootBlock {
uint16_t id;
uint32_t countmax;
uint32_t chance;
//optional
int32_t subType;
int32_t actionId;
std::string text;
std::list<LootBlock> childLoot;
LootBlock() {
id = 0;
countmax = 0;
chance = 0;
subType = -1;
actionId = -1;
}
};
struct summonBlock_t {
std::string name;
uint32_t chance;
uint32_t speed;
};
class BaseSpell;
struct spellBlock_t {
BaseSpell* spell;
uint32_t chance;
uint32_t speed;
uint32_t range;
int32_t minCombatValue;
int32_t maxCombatValue;
bool combatSpell;
bool isMelee;
};
struct voiceBlock_t {
std::string text;
bool yellText;
};
class MonsterType
{
public:
MonsterType();
~MonsterType();
// non-copyable
MonsterType(const MonsterType&) = delete;
MonsterType& operator=(const MonsterType&) = delete;
void reset();
std::map<CombatType_t, int32_t> elementMap;
std::vector<voiceBlock_t> voiceVector;
std::list<LootBlock> lootItems;
std::list<std::string> scriptList;
std::list<spellBlock_t> spellAttackList;
std::list<spellBlock_t> spellDefenseList;
std::list<summonBlock_t> summonList;
std::string name;
std::string nameDescription;
LuaScriptInterface* scriptInterface;
uint64_t experience;
Outfit_t outfit;
uint32_t manaCost;
uint32_t yellChance;
uint32_t yellSpeedTicks;
uint32_t staticAttackChance;
uint32_t maxSummons;
uint32_t changeTargetSpeed;
uint32_t conditionImmunities;
uint32_t damageImmunities;
uint32_t baseSpeed;
int32_t creatureAppearEvent;
int32_t creatureDisappearEvent;
int32_t creatureMoveEvent;
int32_t creatureSayEvent;
int32_t thinkEvent;
int32_t targetDistance;
int32_t runAwayHealth;
int32_t health;
int32_t healthMax;
int32_t changeTargetChance;
int32_t defense;
int32_t armor;
RaceType_t race;
uint16_t lookcorpse;
Skulls_t skull;
uint8_t lightLevel;
uint8_t lightColor;
bool canPushItems;
bool canPushCreatures;
bool pushable;
bool isSummonable;
bool isIllusionable;
bool isConvinceable;
bool isAttackable;
bool isHostile;
bool hiddenHealth;
void createLoot(Container* corpse);
bool createLootContainer(Container* parent, const LootBlock& lootblock);
std::list<Item*> createLootItem(const LootBlock& lootblock);
};
class Monsters
{
public:
Monsters();
~Monsters();
// non-copyable
Monsters(const Monsters&) = delete;
Monsters& operator=(const Monsters&) = delete;
bool loadFromXml(bool reloading = false);
bool isLoaded() const {
return loaded;
}
bool reload();
MonsterType* getMonsterType(const std::string& name);
MonsterType* getMonsterType(uint32_t mid);
uint32_t getIdByName(const std::string& name);
static uint32_t getLootRandom();
private:
ConditionDamage* getDamageCondition(ConditionType_t conditionType,
int32_t maxDamage, int32_t minDamage, int32_t startDamage, uint32_t tickInterval);
bool deserializeSpell(const pugi::xml_node& node, spellBlock_t& sb, const std::string& description = "");
bool loadMonster(const std::string& file, const std::string& monster_name, bool reloading = false);
void loadLootContainer(const pugi::xml_node& node, LootBlock&);
bool loadLootItem(const pugi::xml_node& node, LootBlock&);
std::map<std::string, uint32_t> monsterNames;
std::map<MonsterType*, std::string> monsterScriptList;
std::map<uint32_t, MonsterType*> monsters;
LuaScriptInterface* scriptInterface;
bool loaded;
};
#endif