forked from EasyRPG/Player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_enemy.h
430 lines (338 loc) · 9.22 KB
/
game_enemy.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
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
/*
* This file is part of EasyRPG Player.
*
* EasyRPG Player 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 3 of the License, or
* (at your option) any later version.
*
* EasyRPG Player 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 EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EP_GAME_ENEMY_H
#define EP_GAME_ENEMY_H
// Headers
#include "game_battler.h"
#include "sprite_enemy.h"
#include "player.h"
#include <lcf/rpg/enemy.h>
#include <lcf/rpg/enemyaction.h>
#include <lcf/rpg/troopmember.h>
/**
* Represents a single enemy in the battle scene
*/
class Game_Enemy final : public Game_Battler
{
public:
explicit Game_Enemy(const lcf::rpg::TroopMember* tm);
const std::vector<int16_t>& GetStates() const override;
std::vector<int16_t>& GetStates() override;
int MaxHpValue() const override;
int MaxSpValue() const override;
int MaxStatBattleValue() const override;
int MaxStatBaseValue() const override;
Point GetOriginalPosition() const override;
void ResetBattle() override;
/**
* Gets probability that a state can be inflicted on this actor.
*
* @param state_id State to test
* @return Probability of state infliction
*/
int GetStateProbability(int state_id) const override;
/**
* Gets the base attribute rate when actor is damaged.
*
* @param attribute_id Attribute to query
* @return Attribute rate
*/
int GetBaseAttributeRate(int attribute_id) const override;
/**
* Checks if the enemy is immune to attribute downshifts.
*
* @return if the enemy is immune to attribute downshifts.
*/
bool IsImmuneToAttributeDownshifts() const override;
/**
* Gets the enemy ID.
*
* @return Enemy ID
*/
int GetId() const override;
/**
* Gets the characters name
*
* @return Character name
*/
StringView GetName() const override;
/** @return The troop member id in the battle lineup */
int GetTroopMemberId() const;
/**
* Gets the filename of the enemy sprite
*
* @return Filename of enemy sprite
*/
StringView GetSpriteName() const override;
/**
* Gets the maximum HP for the current level.
*
* @return maximum HP.
*/
int GetBaseMaxHp() const override;
/**
* Gets the maximum SP for the current level.
*
* @return maximum SP.
*/
int GetBaseMaxSp() const override;
/**
* Gets the attack for the current level.
*
* @param weapon which weapons to include in calculating result.
* @return attack.
*/
int GetBaseAtk(Weapon = WeaponAll) const override;
/**
* Gets the defense for the current level.
*
* @param weapon which weapons to include in calculating result.
* @return defense.
*/
int GetBaseDef(Weapon = WeaponAll) const override;
/**
* Gets the spirit for the current level.
*
* @param weapon which weapons to include in calculating result.
* @return spirit.
*/
int GetBaseSpi(Weapon = WeaponAll) const override;
/**
* Gets the agility for the current level.
*
* @param weapon which weapons to include in calculating result.
* @return agility.
*/
int GetBaseAgi(Weapon = WeaponAll) const override;
int GetHue() const;
int GetHp() const override;
int SetHp(int _hp) override;
int GetSp() const override;
int SetSp(int _sp) override;
void Transform(int new_enemy_id);
/**
* Gets the chance to hit for a normal attack.
*
* @param weapon Which weapons to include in calculating result.
* @return hit rate. [0-100]
*/
int GetHitChance(Weapon = WeaponAll) const override;
/**
* Gets the chance to hit for a normal attack.
*
* @param weapon Which weapons to include in calculating result.
* @return hit rate. [0-100]
*/
float GetCriticalHitChance(Weapon = WeaponAll) const override;
/**
* Tests if the enemy has a weapon that grants attack all
*
* @param weapon Which weapons to include in calculating result.
* @return true if a weapon is having attack all attribute
*/
bool HasAttackAll(Weapon weapon = WeaponAll) const override;
/**
* Tests if the enemy has a weapon which ignores evasion.
*
* @param weapon Which weapons to include in calculating result.
* @return If the actor has weapon that ignores evasion
*/
bool AttackIgnoresEvasion(Weapon weapon = WeaponAll) const override;
/**
* @return If the enemy is protected against critical hits.
*/
bool PreventsCritical() const override;
/**
* @return If the enemy has an increased physical evasion rate.
*/
bool HasPhysicalEvasionUp() const override;
int GetBattleAnimationId() const override;
int GetExp() const;
int GetMoney() const;
int GetFlyingOffset() const override;
void UpdateBattle() override;
bool IsTransparent() const;
/**
* Get's the ID of the item the enemy drops when defeated.
*
* @return Dropped item ID, or 0 if no drop
*/
int GetDropId() const;
/**
* Get's the probability that the enemy's item will be
* dropped.
*
* @return Probability of drop as a percent (0-100)
*/
int GetDropProbability() const;
BattlerType GetType() const override;
bool IsInParty() const override;
/** @return database enemy struct */
const lcf::rpg::Enemy& GetDbEnemy() const;
/** @return the blink animation timer */
int GetBlinkTimer() const;
/**
* Set the blink animation timer
*
* @param t the value to set.
*/
void SetBlinkTimer(int t = 20);
/** @return the explode animation timer */
int GetExplodeTimer() const;
/**
* Set the explode animation timer
*
* @param t the value to set.
*/
void SetExplodeTimer(int t = 20);
/** @return the death animation timer */
int GetDeathTimer() const;
/**
* Set the death animation timer
*
* @param t the value to set.
*/
void SetDeathTimer(int t = 36);
/** @return true if enemy is flying */
bool IsFlying() const;
/** @return the id of the enemy's unarmed battle animation */
int GetUnarmedBattleAnimationId() const;
Sprite_Enemy* GetEnemyBattleSprite() const;
int GetEnemyAi() const;
/**
* Checks if the enemies defense skill is stronger the usual.
*
* @return true if strong defense
*/
bool HasStrongDefense() const override;
protected:
const lcf::rpg::Enemy* enemy = nullptr;
const lcf::rpg::TroopMember* troop_member = nullptr;
std::vector<int16_t> states;
int hp = 0;
int sp = 0;
int blink_timer = 0;
int death_timer = 0;
int explode_timer = 0;
};
inline Game_Battler::BattlerType Game_Enemy::GetType() const {
return Game_Battler::Type_Enemy;
}
inline int Game_Enemy::GetExp() const {
return enemy->exp;
}
inline int Game_Enemy::GetMoney() const {
return enemy->gold;
}
inline int Game_Enemy::GetDropId() const {
return enemy->drop_id;
}
inline int Game_Enemy::GetDropProbability() const {
return enemy->drop_prob;
}
inline bool Game_Enemy::IsTransparent() const {
return enemy->transparent;
}
inline int Game_Enemy::GetBattleAnimationId() const {
return 0;
}
inline int Game_Enemy::GetHue() const {
return enemy->battler_hue;
}
inline int Game_Enemy::GetId() const {
return enemy->ID;
}
inline int Game_Enemy::GetTroopMemberId() const {
return troop_member->ID;
}
inline int Game_Enemy::GetBaseMaxHp() const {
return enemy->max_hp;
}
inline int Game_Enemy::GetBaseMaxSp() const {
return enemy->max_sp;
}
inline int Game_Enemy::GetBaseAtk(Weapon) const {
return enemy->attack;
}
inline int Game_Enemy::GetBaseDef(Weapon) const {
return enemy->defense;
}
inline int Game_Enemy::GetBaseSpi(Weapon) const {
return enemy->spirit;
}
inline int Game_Enemy::GetBaseAgi(Weapon) const {
return enemy->agility;
}
inline int Game_Enemy::GetHp() const {
return hp;
}
inline int Game_Enemy::GetSp() const {
return sp;
}
inline const std::vector<int16_t>& Game_Enemy::GetStates() const {
return states;
}
inline std::vector<int16_t>& Game_Enemy::GetStates() {
return states;
}
inline StringView Game_Enemy::GetName() const {
return enemy->name;
}
inline StringView Game_Enemy::GetSpriteName() const {
return enemy->battler_name;
}
inline bool Game_Enemy::IsInParty() const {
// Enemies can never be removed from enemy party
return true;
}
inline const lcf::rpg::Enemy& Game_Enemy::GetDbEnemy() const {
return *enemy;
}
inline int Game_Enemy::GetBlinkTimer() const {
return blink_timer;
}
inline void Game_Enemy::SetBlinkTimer(int t) {
blink_timer = t;
}
inline int Game_Enemy::GetExplodeTimer() const {
return explode_timer;
}
inline void Game_Enemy::SetExplodeTimer(int t) {
explode_timer = t;
}
inline int Game_Enemy::GetDeathTimer() const {
return death_timer;
}
inline void Game_Enemy::SetDeathTimer(int t) {
death_timer = t;
}
inline bool Game_Enemy::IsFlying() const {
return enemy->levitate;
}
inline int Game_Enemy::GetUnarmedBattleAnimationId() const {
return enemy->maniac_unarmed_animation;
}
inline Sprite_Enemy* Game_Enemy::GetEnemyBattleSprite() const {
return static_cast<Sprite_Enemy*>(Game_Battler::GetBattleSprite());
}
inline int Game_Enemy::GetEnemyAi() const {
return enemy->easyrpg_enemyai;
}
inline bool Game_Enemy::HasStrongDefense() const {
return enemy->easyrpg_super_guard;
}
#endif