xoreos  0.0.5
creature.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef ENGINES_NWN2_CREATURE_H
26 #define ENGINES_NWN2_CREATURE_H
27 
28 #include <vector>
29 #include <list>
30 
31 #include "src/common/types.h"
32 #include "src/common/ptrlist.h"
33 #include "src/common/ustring.h"
34 
35 #include "src/aurora/types.h"
36 
38 
39 #include "src/engines/nwn2/types.h"
41 
42 namespace Engines {
43 
44 namespace NWN2 {
45 
46 class Creature : public Object {
47 public:
49  Creature();
51  Creature(const Aurora::GFF3Struct &creature);
53  Creature(const Common::UString &bic, bool local);
54  ~Creature();
55 
56  // Basic visuals
57 
58  void loadModel();
59  void unloadModel();
60 
61  void show();
62  void hide();
63 
64  // Basic properties
65 
67  const Common::UString &getFirstName() const;
69  const Common::UString &getLastName() const;
70 
72  uint32 getGender() const;
74  void setGender(uint32 gender);
76  bool isFemale() const;
77 
79  uint32 getRace() const;
81  void setRace(uint32 race);
82 
84  uint32 getSubRace() const;
86  void setSubRace(uint32 subRace);
87 
89  void getClass(uint32 position, uint32 &classID, uint16 &level) const;
91  uint16 getClassLevel(uint32 classID) const;
92 
94  uint8 getHitDice() const;
95 
97  uint8 getAbility(Ability ability) const;
99  int8 getSkillRank(uint32 skill) const;
101  bool hasFeat(uint32 feat) const;
102 
104  const Common::UString &getDeity() const;
105 
106  uint8 getGoodEvil() const;
107  uint8 getLawChaos() const;
108 
109  bool isPC() const;
110  bool isDM() const;
111 
113  uint32 getAge() const;
114 
116  uint32 getXP() const;
117 
119  int32 getCurrentHP() const;
121  int32 getMaxHP() const;
122 
123  // Positioning
124 
126  void setPosition(float x, float y, float z);
128  void setOrientation(float x, float y, float z, float angle);
129 
130  // Object/Cursor interactions
131 
132  void enter();
133  void leave();
134 
136  void highlight(bool enabled);
137 
139  bool click(Object *triggerer = 0);
140 
141 private:
143 
145  struct Class {
148  };
149 
152 
156 
157  bool _isPC;
158  bool _isDM;
159 
161 
163 
167 
169 
170  std::vector<Class> _classes;
171  std::vector<int8> _skills;
172  std::vector<uint32> _feats;
173 
175 
177 
180 
182 
185 
188 
192 
194 
195 
197  void init();
199  void loadCharacter(const Common::UString &bic, bool local);
201  void load(const Aurora::GFF3Struct &creature);
202 
204  void load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint);
205 
207  void loadProperties(const Aurora::GFF3Struct &gff);
208 
210  static void loadClasses (const Aurora::GFF3Struct &gff,
211  std::vector<Class> &classes, uint8 &hitDice);
212 
213  // Model loaders
214 
216  bool loadArmorModel(const Common::UString &body, const Common::UString &armor,
217  uint8 visualType, uint8 variation);
218  bool loadHeadModel(uint8 appearance);
219  bool loadHairModel(uint8 appearance);
220 
221  static Aurora::GFF3File *openPC(const Common::UString &bic, bool local);
222 };
223 
224 } // End of namespace NWN2
225 
226 } // End of namespace Engines
227 
228 #endif // ENGINES_NWN2_CREATURE_H
uint16 getClassLevel(uint32 classID) const
Get the creature&#39;s level for this class.
Definition: creature.cpp:539
uint8 _appearanceHead
The model variant used for the head.
Definition: creature.h:189
int32 _baseHP
The creature&#39;s base maximum health points.
Definition: creature.h:164
bool hasFeat(uint32 feat) const
Does the creature have this feat?
Definition: creature.cpp:576
A class holding an UTF-8 string.
Definition: ustring.h:48
uint8 getGoodEvil() const
Definition: creature.cpp:551
void init()
Init the creature.
Definition: creature.cpp:71
uint8_t uint8
Definition: types.h:200
static Aurora::GFF3File * openPC(const Common::UString &bic, bool local)
Definition: creature.cpp:584
void load(const Aurora::GFF3Struct &creature)
Load from a creature instance.
Definition: creature.cpp:344
void setSubRace(uint32 subRace)
Set the creature&#39;s subrace.
Definition: creature.cpp:197
uint32 getGender() const
Get the creature&#39;s gender.
Definition: creature.cpp:170
std::vector< uint32 > _feats
The creature&#39;s feats.
Definition: creature.h:172
Common::PtrList< Graphics::Aurora::Model > ModelParts
Definition: creature.h:142
uint32 _appearanceID
The creature&#39;s general appearance.
Definition: creature.h:181
void loadModel()
Load the creature&#39;s model.
Definition: creature.cpp:289
bool click(Object *triggerer=0)
The creature was clicked.
Definition: creature.cpp:150
int32 _currentHP
The creature&#39;s current health points.
Definition: creature.h:166
uint32 classID
Index into classes.2da.
Definition: creature.h:146
An object within a NWN2 area.
Definition: object.h:58
Common::UString _lastName
The creature&#39;s last name.
Definition: creature.h:151
void loadProperties(const Aurora::GFF3Struct &gff)
Load general creature properties.
Definition: creature.cpp:389
bool loadArmorModel(const Common::UString &body, const Common::UString &armor, uint8 visualType, uint8 variation)
Definition: creature.cpp:236
A list storing pointer to objects, with automatic deletion.
uint8 getAbility(Ability ability) const
Return a creature&#39;s ability score.
Definition: creature.cpp:563
void unloadModel()
Unload the creature&#39;s model.
Definition: creature.cpp:338
void leave()
The cursor left the creature.
Definition: creature.cpp:141
uint8 getHitDice() const
Returns the number of hit dice, which is effectively the total number of levels.
Definition: creature.cpp:559
Common::UString getBaseModel(const Common::UString &base)
Definition: creature.cpp:225
uint32 _age
The creature&#39;s age.
Definition: creature.h:160
void highlight(bool enabled)
(Un)Highlight the creature.
Definition: creature.cpp:145
uint16_t uint16
Definition: types.h:202
Basic Aurora graphics types.
uint32 getRace() const
Return the creature&#39;s race value.
Definition: creature.cpp:185
uint16 level
Levels of that class.
Definition: creature.h:147
Basic Neverwinter Nights 2 type definitions.
uint8 _appearanceFHair
The model variant used for female hair.
Definition: creature.h:191
void hide()
Hide the creature&#39;s model.
Definition: creature.cpp:116
void loadCharacter(const Common::UString &bic, bool local)
Load from a character file.
Definition: creature.cpp:354
uint32 getAge() const
Return the creature&#39;s age.
Definition: creature.cpp:209
A GFF (generic file format) V3.2/V3.3 file, found in all Aurora games except Sonic Chronicles: The Da...
Definition: gff3file.h:85
bool _isDM
Is the creature a DM?
Definition: creature.h:158
bool _isPC
Is the creature a PC?
Definition: creature.h:157
Low-level type definitions to handle fixed width types portably.
uint8 _goodEvil
The creature&#39;s good/evil value (0-100).
Definition: creature.h:178
Common::UString _deity
The creature&#39;s deity.
Definition: creature.h:176
int8 getSkillRank(uint32 skill) const
Return the creature&#39;s rank in this skill.
Definition: creature.cpp:569
void setGender(uint32 gender)
Set the creature&#39;s gender.
Definition: creature.cpp:174
uint32 _gender
The creature&#39;s gender.
Definition: creature.h:153
bool isPC() const
Is the creature a player character?
Definition: creature.cpp:201
void getClass(uint32 position, uint32 &classID, uint16 &level) const
Get the creature&#39;s class and level at that class slot position.
Definition: creature.cpp:528
bool isDM() const
Is the creature a dungeon master?
Definition: creature.cpp:205
bool loadHairModel(uint8 appearance)
Definition: creature.cpp:271
Unicode string handling.
uint8 _lawChaos
The creature&#39;s law/chaos value (0-100).
Definition: creature.h:179
uint32 _xp
The creature&#39;s experience.
Definition: creature.h:162
uint8 _hitDice
The creature&#39;s hit dice.
Definition: creature.h:174
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
uint8 _appearanceMHair
The model variant used for male hair.
Definition: creature.h:190
uint32 _subRace
The creature&#39;s subrace.
Definition: creature.h:155
int32 getCurrentHP() const
Return the current HP this creature has.
Definition: creature.cpp:217
int32 _bonusHP
The creature&#39;s bonus health points.
Definition: creature.h:165
int8_t int8
Definition: types.h:199
std::vector< Class > _classes
The creature&#39;s classes.
Definition: creature.h:170
A struct within a GFF3.
Definition: gff3file.h:164
uint32_t uint32
Definition: types.h:204
std::vector< int8 > _skills
The creature&#39;s skills.
Definition: creature.h:171
void enter()
The cursor entered the creature.
Definition: creature.cpp:137
uint8 _abilities[kAbilityMAX]
The creature&#39;s abilities.
Definition: creature.h:168
An object in a Neverwinter Nights 2 area.
const Common::UString & getLastName() const
Return the creature&#39;s last name.
Definition: creature.cpp:166
void show()
Show the creature&#39;s model.
Definition: creature.cpp:111
ModelParts _modelParts
Definition: creature.h:193
void setRace(uint32 race)
Set the creature&#39;s race.
Definition: creature.cpp:189
Common::UString _firstName
The creature&#39;s first name.
Definition: creature.h:150
uint32 getSubRace() const
Return the creature&#39;s subrace value.
Definition: creature.cpp:193
bool loadHeadModel(uint8 appearance)
Definition: creature.cpp:253
void setOrientation(float x, float y, float z, float angle)
Set the creature&#39;s orientation.
Definition: creature.cpp:129
bool isFemale() const
Is the creature female, do we need female dialogs tokens?
Definition: creature.cpp:178
int32 getMaxHP() const
Return the max HP this creature can have.
Definition: creature.cpp:221
uint8 getLawChaos() const
Definition: creature.cpp:555
static void loadClasses(const Aurora::GFF3Struct &gff, std::vector< Class > &classes, uint8 &hitDice)
Load the creature&#39;s classes.
Definition: creature.cpp:506
Creature()
Create a dummy creature instance.
Definition: creature.cpp:52
void setPosition(float x, float y, float z)
Set the creature&#39;s position.
Definition: creature.cpp:121
const Common::UString & getDeity() const
Get the creature&#39;s deity.
Definition: creature.cpp:547
uint32 _race
The creature&#39;s race.
Definition: creature.h:154
int32_t int32
Definition: types.h:203
uint32 getXP() const
Return the creature&#39;s XP.
Definition: creature.cpp:213
const Common::UString & getFirstName() const
Return the creature&#39;s first name.
Definition: creature.cpp:162