V-Gears 0
Free Final Fantasy VII engine.
Enemy.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include <OgreString.h>
19#include "ScriptManager.h"
20
24class Enemy{
25
26 public:
27
28 struct Element{
29
33 unsigned int id;
34
46 float factor;
47 };
48
52 struct Attack{
53
57 unsigned int id;
58
64 int camera;
65 };
66
70 struct Item{
71
75 unsigned int id;
76
80 float rate;
81 };
82
86 struct Immunity{
87
91 unsigned int status;
92
99 float rate;
100 };
101
107 Enemy(const unsigned int id);
108
120 Enemy(
121 const unsigned int id, const Ogre::Vector3 pos, const bool front, const bool visible,
122 const bool targeteable, const bool active, const std::string cover
123 );
124
128 virtual ~Enemy();
129
135 const int GetId() const;
136
142 void SetId(const int id);
143
151 const std::string GetModel() const;
152
160 void SetModel(const std::string model);
161
167 const std::string GetName() const;
168
174 void SetName(const Ogre::String& name);
175
181 unsigned int GetLevel() const;
182
188 void SetLevel(const unsigned int level);
189
195 unsigned int GetAp() const;
196
202 void SetAp(unsigned int ap);
203
209 unsigned int GetExp() const;
210
216 void SetExp(const unsigned int exp);
217
223 unsigned int GetMoney() const;
224
230 void SetMoney(const unsigned int money);
231
237 std::vector<unsigned int> GetAnimations() const;
238
244 void AddAnimation(const unsigned int animation);
245
251 std::vector<Attack> GetAttacks() const;
252
258 void AddAttack(const Attack attack);
259
265 std::vector<Item> GetDrop() const;
266
272 void AddDrop(const Item item);
273
279 std::vector<Element> GetElements() const;
280
286 void AddElement(const Element element);
287
293 std::vector<Immunity> GetImmunities() const;
294
300 void AddImmunity(const Immunity immunity);
301
310 std::vector<unsigned int> GetManipulateAttacks() const;
311
317 void AddManipulateAttack(const unsigned int attack);
318
324 std::vector<Item> GetSteal() const;
325
331 void AddSteal(const Item item);
332
338 unsigned int GetMorph() const;
339
345 void SetMorph(const int morph);
346
352 float GetBackDamage() const;
353
359 void SetBackDamage(const float back_damage);
360
366 unsigned int GetStr() const;
367
373 void SetStr(const unsigned int str);
374
380 unsigned int GetDef() const;
381
387 void SetDef(const unsigned int def);
388
394 unsigned int GetMag() const;
395
401 void SetMag(const unsigned int mag);
402
408 unsigned int GetSpr() const;
409
415 void SetSpr(const unsigned int spr);
416
422 unsigned int GetDex() const;
423
429 void SetDex(const unsigned int dex);
430
436 unsigned int GetLck() const;
437
443 void SetLck(const unsigned int lck);
444
450 unsigned int GetEva() const;
451
457 void SetEva(const unsigned int eva);
458
464 unsigned int GetMeva() const;
465
471 void SetMeva(const unsigned int meva);
472
478 unsigned int GetHp() const;
479
488 void SetHp(const unsigned int hp);
489
495 unsigned int GetHpMax() const;
496
505 void SetHpMax(const unsigned int hp_max);
506
512 unsigned int GetMp() const;
513
522 void SetMp(const unsigned int mp);
523
529 unsigned int GetMpMax() const;
530
539 void SetMpMax(const unsigned int mp_max);
540
546 Ogre::Vector3& GetPos();
547
553 void SetPos(const Ogre::Vector3 &pos);
554
561 void ScriptGetPos() const;
562
568 bool IsFront() const;
569
575 void SetFront(bool front);
576
582 bool IsVisible() const;
583
589 void SetVisible(bool visible);
590
596 bool IsTargeteable() const;
597
603 void SetTargeteable(bool targeteable);
604
610 bool IsActive() const;
611
617 void SetActive(bool active);
618
627 std::string GetCover() const;
628
637 void SetCover(std::string cover);
638
647
657 int ScriptGetAttack(const unsigned int index);
658
669 int ScriptGetCameraForAttack(const unsigned int index);
670
671 private:
672
676 void ReadFromXml();
677
681 int id_;
682
686 std::string model_;
687
692
696 unsigned int level_;
697
701 unsigned int exp_;
702
706 unsigned int ap_;
707
711 unsigned int money_;
712
716 std::vector<unsigned int> animations_;
717
721 std::vector<Element> elements_;
722
726 std::vector<Immunity> immunities_;
727
731 std::vector<Attack> attacks_;
732
739 std::vector<unsigned int> manipulate_attacks_;
740
744 std::vector<Item> steal_;
745
749 std::vector<Item> drop_;
750
755
760
764 unsigned int str_;
765
769 unsigned int def_;
770
774 unsigned int mag_;
775
779 unsigned int spr_;
780
784 unsigned int dex_;
785
789 unsigned int lck_;
790
794 unsigned int eva_;
795
799 unsigned int meva_;
800
804 unsigned int hp_;
805
809 unsigned int mp_;
810
814 unsigned int hp_max_;
815
819 unsigned int mp_max_;
820
824 Ogre::Vector3 pos_;
825
829 bool front_;
830
835
840
845
849 std::string cover_;
850
851};
852
Any enemy in a battle.
Definition: Enemy.h:24
unsigned int GetDef() const
Retrieves the enemy's defense stat.
Definition: Enemy.cpp:165
unsigned int mag_
Enemy magic stat.
Definition: Enemy.h:774
std::vector< Immunity > immunities_
Status immunities and resistances.
Definition: Enemy.h:726
void AddElement(const Element element)
Adds an elemental affinity to the monster.
Definition: Enemy.cpp:136
void SetMp(const unsigned int mp)
Sets the enemy's current MP.
Definition: Enemy.cpp:206
bool IsFront() const
Checks if the enemy is in the front row.
Definition: Enemy.cpp:225
u8 level
The enemy level.
Definition: Enemy.h:112
std::vector< Immunity > GetImmunities() const
Retrieves the list of status immunities.
Definition: Enemy.cpp:138
std::string model_
NAme of the enemy model file.
Definition: Enemy.h:686
float back_damage
Back damage multiplier.
Definition: Enemy.h:177
std::string GetCover() const
Retrieves the flags for enemy covering.
Definition: Enemy.cpp:241
void SetMorph(const int morph)
Sets the ID of the item the monster can be morphed into.
Definition: Enemy.cpp:152
unsigned int GetSpr() const
Retrieves the enemy's spirit stat.
Definition: Enemy.cpp:173
u32 hp
The enemy HP.
Definition: Enemy.h:152
Ogre::Vector3 pos_
Enemy position in the battlefield (x, y, z).
Definition: Enemy.h:824
const int GetId() const
Retrieves the enemy ID.
Definition: Enemy.cpp:94
unsigned int GetMpMax() const
Retrieves the enemy's max MP.
Definition: Enemy.cpp:208
void SetHpMax(const unsigned int hp_max)
Sets the enemy's max HP.
Definition: Enemy.cpp:199
void SetMag(const unsigned int mag)
Sets the enemy's magic stat.
Definition: Enemy.cpp:171
void AddAnimation(const unsigned int animation)
Adds an animation for the enemy.
Definition: Enemy.cpp:124
void ReadFromXml()
Reads enemy data from the xml file.
Definition: Enemy.cpp:257
unsigned int GetHp() const
Retrieves the enemy's current HP.
Definition: Enemy.cpp:193
unsigned int hp_max_
Enemy's max HP.
Definition: Enemy.h:814
unsigned int GetMeva() const
Retrieves the enemy's magic evasion stat.
Definition: Enemy.cpp:189
bool IsActive() const
Checks whether the enemy's main script is active.
Definition: Enemy.cpp:237
unsigned int GetLevel() const
Retrieves the enemy level.
Definition: Enemy.cpp:106
std::vector< Item > drop_
List of the items that can be dropped from the enemy.
Definition: Enemy.h:749
void SetStr(const unsigned int str)
Sets the enemy's strength stat.
Definition: Enemy.cpp:163
std::vector< Item > GetDrop() const
Retrieves the enemy possible item drops.
Definition: Enemy.cpp:130
unsigned int GetDex() const
Retrieves the enemy's dexterity stat.
Definition: Enemy.cpp:177
void ScriptGetPos() const
Retrieves the enemy position.
Definition: Enemy.cpp:219
void SetBackDamage(const float back_damage)
Sets the multiplier for the damage the enemy receives when attacked from the back.
Definition: Enemy.cpp:156
unsigned int mp_max_
Enemy's max MP.
Definition: Enemy.h:819
u8 mag
The enemy magic stat.
Definition: Enemy.h:122
std::vector< unsigned int > animations_
List of animations.
Definition: Enemy.h:716
bool IsVisible() const
Checks the enemy visibility.
Definition: Enemy.cpp:229
unsigned int dex_
Enemy dexterity stat.
Definition: Enemy.h:784
unsigned int spr_
Enemy spirit stat.
Definition: Enemy.h:779
void SetMeva(const unsigned int meva)
Sets the enemy's magic evasion stat.
Definition: Enemy.cpp:191
void SetMoney(const unsigned int money)
Sets the money gain upon defeating the enemy.
Definition: Enemy.cpp:120
std::vector< Item > steal_
List of the items that can be stolen from the enemy.
Definition: Enemy.h:744
std::vector< unsigned int > GetManipulateAttacks() const
Retrieves the list of attacks that can be used during the manipulated state.
Definition: Enemy.cpp:142
u32 money
Money given upon defeat.
Definition: Enemy.h:172
u8 eva
The enemy evasion stat.
Definition: Enemy.h:147
void SetHp(const unsigned int hp)
Sets the enemy's current HP.
Definition: Enemy.cpp:195
bool targeteable_
Indicates if the enemy can be targeted.
Definition: Enemy.h:839
u8 def
The enemy defense stat.
Definition: Enemy.h:127
unsigned int GetExp() const
Retrieves the EXP gain upon defeating the enemy.
Definition: Enemy.cpp:114
std::string name
The enemy name.
Definition: Enemy.h:107
void SetName(const Ogre::String &name)
Sets the enemy name.
Definition: Enemy.cpp:104
std::vector< Attack > GetAttacks() const
Retrieves the enemy attacks.
Definition: Enemy.cpp:126
u8 lck
The enemy luck stat.
Definition: Enemy.h:142
void AddDrop(const Item item)
Adds an item drop for the enemy.
Definition: Enemy.cpp:132
unsigned int GetAp() const
Retrieves the AP gain upon defeating the enemy.
Definition: Enemy.cpp:110
bool active_
Indicates if the enemy's main script is active.
Definition: Enemy.h:844
void SetFront(bool front)
Sets the enemy in or out the front row.
Definition: Enemy.cpp:227
const std::string GetName() const
Retrieves the enemy name.
Definition: Enemy.cpp:102
unsigned int level_
The enemy level.
Definition: Enemy.h:696
void AddManipulateAttack(const unsigned int attack)
Adds an attack usable during manipulation.
Definition: Enemy.cpp:144
unsigned int hp_
Enemy's current HP.
Definition: Enemy.h:804
bool IsTargeteable() const
Checks whether the enemy can be targeted.
Definition: Enemy.cpp:233
unsigned int mp_
Enemy's current MP.
Definition: Enemy.h:809
u32 ap
AP given upon defeat.
Definition: Enemy.h:167
bool visible_
Indicates if the enemy is visible.
Definition: Enemy.h:834
std::vector< unsigned int > GetAnimations() const
Retrieves the enemy animation IDs.
Definition: Enemy.cpp:122
u32 exp
Experience given upon defeat.
Definition: Enemy.h:162
int id_
The enemy ID.
Definition: Enemy.h:681
void SetExp(const unsigned int exp)
Sets the EXP gain upon defeating the enemy.
Definition: Enemy.cpp:116
void SetAp(unsigned int ap)
Sets the AP gain upon defeating the enemy.
Definition: Enemy.cpp:112
unsigned int GetMp() const
Retrieves the enemy's current MP.
Definition: Enemy.cpp:204
unsigned int str_
Enemy strength stat.
Definition: Enemy.h:764
u32 mp
The enemy MP.
Definition: Enemy.h:157
std::string model
Two-letter model code.
Definition: Enemy.h:220
unsigned int def_
Enemy defense stat.
Definition: Enemy.h:769
float GetBackDamage() const
Retrieves the multiplier for the damage the enemy receives when attacked from the back.
Definition: Enemy.cpp:154
unsigned int ap_
AP given upon defeating the enemy.
Definition: Enemy.h:706
unsigned int money_
Money given upon defeating the enemy.
Definition: Enemy.h:711
Enemy()
Constructor.
Definition: Enemy.h:234
unsigned int lck_
Enemy luck stat.
Definition: Enemy.h:789
int morph_
ID of the item the enemy can be morphed into.
Definition: Enemy.h:754
unsigned int GetMorph() const
Retrieves the ID of the item the monster can be morphed into.
Definition: Enemy.cpp:150
bool front_
Indicates if the enmy is in the frontline.
Definition: Enemy.h:829
void SetLck(const unsigned int lck)
Sets the enemy's luck stat.
Definition: Enemy.cpp:183
void SetDef(const unsigned int def)
Sets the enemy's defense stat.
Definition: Enemy.cpp:167
void SetModel(const std::string model)
Sets the enemy model.
Definition: Enemy.cpp:100
void SetTargeteable(bool targeteable)
Determines whether the enemy can be targeted.
Definition: Enemy.cpp:235
unsigned int exp_
EXP given upon defeating the enemy.
Definition: Enemy.h:701
void SetId(const int id)
Sets the enemy ID.
Definition: Enemy.cpp:96
int ScriptGetAttack(const unsigned int index)
Retrieves an attack.
Definition: Enemy.cpp:247
int ScriptGetAttackCount()
Retrieves the number of attacks of the enemy.
Definition: Enemy.cpp:245
Ogre::Vector3 & GetPos()
Retrieves the enemy position in the battlefield.
Definition: Enemy.cpp:215
void AddAttack(const Attack attack)
Adds an attack for the enemy.
Definition: Enemy.cpp:128
void SetActive(bool active)
Activates or deactivates the enemy main script.
Definition: Enemy.cpp:239
std::vector< Attack > attacks_
Enemy attacks.
Definition: Enemy.h:731
std::vector< Item > GetSteal() const
Retrieves the enemy possible item stelas.
Definition: Enemy.cpp:146
std::vector< Element > GetElements() const
Retrieves the list of the enemy elemental affinities.
Definition: Enemy.cpp:134
const std::string GetModel() const
Retrieves the enemy model.
Definition: Enemy.cpp:98
unsigned int eva_
Enemy evasion stat.
Definition: Enemy.h:794
virtual ~Enemy()
Destructor.
Definition: Enemy.cpp:89
int ScriptGetCameraForAttack(const unsigned int index)
Retrieves the camera for an attack.
Definition: Enemy.cpp:252
void SetCover(std::string cover)
Sets the flags for enemy covering.
Definition: Enemy.cpp:243
unsigned int morph
ID of the item the enemy can be morphed into.
Definition: Enemy.h:227
void AddSteal(const Item item)
Adds an item steal to the enemy.
Definition: Enemy.cpp:148
unsigned int GetEva() const
Retrieves the enemy's evasion stat.
Definition: Enemy.cpp:185
std::string cover_
Cover binary flags.
Definition: Enemy.h:849
void SetDex(const unsigned int dex)
Sets the enemy's dexterity stat.
Definition: Enemy.cpp:179
void SetVisible(bool visible)
Toggles the enemy visibility.
Definition: Enemy.cpp:231
unsigned int GetLck() const
Retrieves the enemy's luck stat.
Definition: Enemy.cpp:181
void SetMpMax(const unsigned int mp_max)
Sets the enemy's max MP.
Definition: Enemy.cpp:210
unsigned int meva_
Enemy magic evasion stat.
Definition: Enemy.h:799
void SetLevel(const unsigned int level)
Sets the enemy level.
Definition: Enemy.cpp:108
void SetPos(const Ogre::Vector3 &pos)
Sets the enemy position in the battlefield.
Definition: Enemy.cpp:217
void SetSpr(const unsigned int spr)
Sets the enemy's spirit stat.
Definition: Enemy.cpp:175
unsigned int GetStr() const
Retrieves the enemy's strength stat.
Definition: Enemy.cpp:161
unsigned int GetMoney() const
Retrieves the money gain upon defeating the enemy.
Definition: Enemy.cpp:118
std::vector< Element > elements_
Elemental affinities.
Definition: Enemy.h:721
void AddImmunity(const Immunity immunity)
Adds an immunity to the monster.
Definition: Enemy.cpp:140
unsigned int GetHpMax() const
Retrieves the enemy's max HP.
Definition: Enemy.cpp:197
u8 str
The enemy strength stat.
Definition: Enemy.h:117
Ogre::String name_
The name of the enemy.
Definition: Enemy.h:691
unsigned int GetMag() const
Retrieves the enemy's magic stat.
Definition: Enemy.cpp:169
void SetEva(const unsigned int eva)
Sets the enemy's evasion stat.
Definition: Enemy.cpp:187
float back_damage_
Multiplier for back damage.
Definition: Enemy.h:759
std::vector< unsigned int > manipulate_attacks_
List of attacks that can be used while manipulated.
Definition: Enemy.h:739
Ogre::String String
Definition: TypeDefine.h:37
Enemy attack data.
Definition: Enemy.h:52
int camera
Camera ID to use during the attack.
Definition: Enemy.h:64
unsigned int id
Attack ID.
Definition: Enemy.h:57
Definition: Enemy.h:28
unsigned int id
The element ID.
Definition: Enemy.h:33
float factor
Damage modification factor when attacked by the element.
Definition: Enemy.h:46
Status immunity.
Definition: Enemy.h:86
float rate
Immunity rate.
Definition: Enemy.h:99
unsigned int status
Status ID.
Definition: Enemy.h:91
Data for drop and steal items.
Definition: Enemy.h:70
unsigned int id
Item ID.
Definition: Enemy.h:75
float rate
Steal or drop rate.
Definition: Enemy.h:80