xoreos  0.0.5
creature.cpp
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 #include "src/common/util.h"
26 #include "src/common/maths.h"
27 #include "src/common/error.h"
28 #include "src/common/ustring.h"
29 #include "src/common/strutil.h"
30 
31 #include "src/aurora/2dafile.h"
32 #include "src/aurora/2dareg.h"
33 #include "src/aurora/gff3file.h"
34 
39 
42 
44 #include "src/engines/kotor/item.h"
45 
47 
48 namespace Engines {
49 
50 namespace KotOR {
51 
54  _walkRate(0.0f),
55  _runRate(0.0f) {
56 
57  init();
58 
60  if (!utc)
61  throw Common::Exception("Creature \"%s\" has no blueprint", resRef.c_str());
62 
63  load(utc->getTopLevel());
64 }
65 
68  _walkRate(0.0f),
69  _runRate(0.0f) {
70 
71  init();
72  load(creature);
73 }
74 
77  _walkRate(0.0f),
78  _runRate(0.0f) {
79 
80  init();
81 }
82 
84 }
85 
87  _isPC = false;
88 
90 
94  _skin = kSkinMAX;
95  _face = 0;
96 
97  _headModel = 0;
98  _visible = false;
99 }
100 
102  if (_visible)
103  return;
104 
105  _visible = true;
106 
107  if (_model)
108  _model->show();
109 }
110 
112  if (!_visible)
113  return;
114 
115  if (_model)
116  _model->hide();
117 
118  _visible = false;
119 }
120 
121 bool Creature::isVisible() const {
122  return _visible;
123 }
124 
125 bool Creature::isPC() const {
126  return _isPC;
127 }
128 
130  return _isPC;
131 }
132 
134  return _gender;
135 }
136 
137 int Creature::getLevel(const Class &c) const {
138  for (size_t i = 0; i < _levels.size(); ++i) {
139  if (_levels[i].characterClass == c)
140  return _levels[i].level;
141  }
142 
143  return 0;
144 }
145 
146 int Creature::getLevelByPosition(int position) const {
147  if (_levels.size() >= static_cast<unsigned int>(position + 1))
148  return _levels[position].level;
149 
150  return 0;
151 }
152 
153 Class Creature::getClassByPosition(int position) const {
154  if (_levels.size() >= static_cast<unsigned int>(position + 1))
155  return _levels[position].characterClass;
156 
157  return kClassInvalid;
158 }
159 
161  return _race;
162 }
163 
165  return _subRace;
166 }
167 
168 float Creature::getWalkRate() const {
169  return _walkRate;
170 }
171 
172 float Creature::getRunRate() const {
173  return _runRate;
174 }
175 
176 void Creature::setPosition(float x, float y, float z) {
177  Object::setPosition(x, y, z);
178  Object::getPosition(x, y, z);
179 
180  if (_model)
181  _model->setPosition(x, y, z);
182 }
183 
184 void Creature::setOrientation(float x, float y, float z, float angle) {
185  Object::setOrientation(x, y, z, angle);
186  Object::getOrientation(x, y, z, angle);
187 
188  if (_model)
189  _model->setOrientation(x, y, z, angle);
190 }
191 
192 void Creature::load(const Aurora::GFF3Struct &creature) {
193  Common::UString temp = creature.getString("TemplateResRef");
194 
196  if (!temp.empty())
197  utc.reset(loadOptionalGFF3(temp, Aurora::kFileTypeUTC, MKTAG('U', 'T', 'C', ' ')));
198 
199  load(creature, utc ? &utc->getTopLevel() : 0);
200 
201  if (!utc)
202  warning("Creature \"%s\" has no blueprint", _tag.c_str());
203 }
204 
205 void Creature::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) {
206  // General properties
207 
208  if (blueprint)
209  loadProperties(*blueprint); // Blueprint
210  loadProperties(instance); // Instance
211 
212 
213  // Appearance
214 
216  throw Common::Exception("Creature without an appearance");
217 
218  loadAppearance();
219 
220  // Position
221 
222  setPosition(instance.getDouble("XPosition"),
223  instance.getDouble("YPosition"),
224  instance.getDouble("ZPosition"));
225 
226  // Orientation
227 
228  float bearingX = instance.getDouble("XOrientation");
229  float bearingY = instance.getDouble("YOrientation");
230 
231  setOrientation(0.0f, 0.0f, 1.0f, -Common::rad2deg(atan2(bearingX, bearingY)));
232 }
233 
235  // Tag
236  _tag = gff.getString("Tag", _tag);
237 
238  // Name
239  _name = gff.getString("LocName", _name);
240 
241  // Description
242  _description = gff.getString("Description", _description);
243 
244  // Portrait
245  loadPortrait(gff);
246 
247  // Appearance
248  _appearance = gff.getUint("Appearance_Type", _appearance);
249 
250  // Static
251  _static = gff.getBool("Static", _static);
252 
253  // Usable
254  _usable = gff.getBool("Useable", _usable);
255 
256  // PC
257  _isPC = gff.getBool("IsPC", _isPC);
258 
259  // Gender
260  _gender = Gender(gff.getUint("Gender"));
261 
262  // Race
263  _race = Race(gff.getSint("Race", _race));
264  _subRace = SubRace(gff.getSint("SubraceIndex", _subRace));
265 
266  // Hit Points
267  _currentHitPoints = gff.getSint("CurrentHitPoints", _maxHitPoints);
268  _maxHitPoints = gff.getSint("MaxHitPoints", _currentHitPoints);
269 
270  _minOneHitPoint = gff.getBool("Min1HP", _minOneHitPoint);
271 
272  // Class Levels
273  if (gff.hasField("ClassList")) {
274  Aurora::GFF3List classList = gff.getList("ClassList");
275  for (Aurora::GFF3List::const_iterator iter = classList.begin(); iter != classList.end(); iter++) {
276  const Aurora::GFF3Struct &charClass = **iter;
277 
278  ClassLevel classLevel;
279  classLevel.characterClass = Class(charClass.getSint("Class"));
280  classLevel.level = charClass.getSint("ClassLevel");
281 
282  _levels.push_back(classLevel);
283  }
284  }
285 
286  // Scripts
287  readScripts(gff);
288 
289  _conversation = gff.getString("Conversation", _conversation);
290 }
291 
293  uint32 portraitID = gff.getUint("PortraitId");
294  if (portraitID != 0) {
295  const Aurora::TwoDAFile &twoda = TwoDAReg.get2DA("portraits");
296 
297  Common::UString portrait = twoda.getRow(portraitID).getString("BaseResRef");
298  if (!portrait.empty()) {
299  if (portrait.beginsWith("po_"))
300  _portrait = portrait;
301  else
302  _portrait = "po_" + portrait;
303  }
304  }
305 
306  _portrait = gff.getString("Portrait", _portrait);
307 }
308 
310  PartModels parts;
311 
312  getPartModels(parts);
313 
314  if ((_modelType == "P") || parts.body.empty()) {
315  warning("TODO: Model \"%s\": ModelType \"%s\" (\"%s\")",
316  _tag.c_str(), _modelType.c_str(), parts.body.c_str());
317  return;
318  }
319 
320  loadBody(parts);
321  loadHead(parts);
322 
324 }
325 
327  const Aurora::TwoDARow &appearance = TwoDAReg.get2DA("appearance").getRow(_appearance);
328 
329  _modelType = appearance.getString("modeltype");
330 
331  // TODO: load state based on character equipment
332  if (appearance.getString("label").beginsWith("Party_"))
333  state = 'b';
334 
335  if (_modelType == "B") {
336  parts.body = appearance.getString(Common::UString("model") + state);
337  parts.bodyTexture = appearance.getString(Common::UString("tex") + state) + "01";
338  } else {
339  parts.body = appearance.getString("race");
340  parts.bodyTexture = appearance.getString("racetex");
341  }
342 
343  if ((_modelType == "B") || (_modelType == "P")) {
344  const int headNormalID = appearance.getInt("normalhead");
345  const int headBackupID = appearance.getInt("backuphead");
346 
347  const Aurora::TwoDAFile &heads = TwoDAReg.get2DA("heads");
348 
349  if (headNormalID >= 0)
350  parts.head = heads.getRow(headNormalID).getString("head");
351  else if (headBackupID >= 0)
352  parts.head = heads.getRow(headBackupID).getString("head");
353  }
354 
355  loadMovementRate(appearance.getString("moverate"));
356 }
357 
358 void Creature::getPartModelsPC(PartModels &parts, uint32 state, uint8 textureVariation) {
359  parts.body = getBodyMeshString(_gender, getClassByPosition(0), state);
361  parts.bodyTexture = "p";
362 
363  switch (_gender) {
364  case kGenderMale:
365  parts.bodyTexture += "m";
366  break;
367  case kGenderFemale:
368  parts.bodyTexture += "f";
369  break;
370  default:
371  throw Common::Exception("Unknown gender");
372  }
373 
374  parts.bodyTexture += Common::UString("b") + state;
375 
376  switch (state) {
377  case 'a':
378  case 'b':
379  switch (_levels.back().characterClass) {
380  case kClassSoldier:
381  parts.bodyTexture += "l";
382  break;
383  case kClassScout:
384  parts.bodyTexture += "m";
385  break;
386  default:
387  case kClassScoundrel:
388  parts.bodyTexture += "s";
389  break;
390  }
391  if (state == 'a') {
392  switch (_skin) {
393  case kSkinA:
394  parts.bodyTexture += "A";
395  break;
396  case kSkinB:
397  parts.bodyTexture += "B";
398  break;
399  default:
400  break;
401  }
402  }
403  break;
404  default:
405  switch (_gender) {
406  case kGenderMale:
407  parts.body += "l";
408  break;
409  case kGenderFemale:
410  parts.body += "s";
411  break;
412  default:
413  return;
414  }
415  break;
416  }
417 
418  parts.portrait = "po_" + parts.head;
419  parts.portrait.replaceAll("0", "");
420  parts.bodyTexture += Common::UString::format("%02u", textureVariation);
421 
422  loadMovementRate("PLAYER");
423 }
424 
426  // Model "P_BastilaBB" has broken animations. Replace it with the
427  // correct one.
428  if (parts.body.stricmp("P_BastilaBB") == 0)
429  parts.body = "P_BastilaBB02";
430 
432  if (!_model)
433  return;
434 
435  _ids.clear();
436  _ids.push_back(_model->getID());
437 
438  _model->setTag(_tag);
439  _model->setClickable(isClickable());
440 
441  if (_modelType != "B" && _modelType != "P")
442  _model->addAnimationChannel(Graphics::Aurora::kAnimationChannelHead);
443 }
444 
446  if (!_model || parts.head.empty())
447  return;
448 
450  if (!_headModel)
451  return;
452 
453  _model->attachModel("headhook", _headModel);
454 }
455 
457  const Aurora::TwoDARow &speed = TwoDAReg.get2DA("creaturespeed").getRow("2daname", name);
458 
459  _walkRate = speed.getFloat("walkrate");
460  _runRate = speed.getFloat("runrate");
461 }
462 
464  uint32 state = 'a';
465  uint8 textureVariation = 1;
466 
468  if (i != _equipment.end()) {
469  Item *item = i->second;
470  state += item->getBodyVariation() - 1;
471  textureVariation = item->getTextureVariation();
472  }
473 
474  PartModels parts;
475  getPartModelsPC(parts, state, textureVariation);
476 
477  loadBody(parts);
478  loadHead(parts);
479 
480  if (!_model)
481  return;
482 
485 
487 
488  if (_visible) {
489  float x, y, z;
490  getPosition(x, y, z);
491  _model->setPosition(x, y, z);
492 
493  float angle;
494  getOrientation(x, y, z, angle);
495  _model->setOrientation(x, y, z, angle);
496 
497  _model->show();
498  }
499 }
500 
502  assert((slot == kEquipmentSlotWeaponL) || (slot == kEquipmentSlotWeaponR));
503 
504  Graphics::Aurora::Model *weaponModel = 0;
505 
507  if (i != _equipment.end()) {
508  Item *item = i->second;
509  weaponModel = loadModelObject(item->getModelName());
510  }
511 
512  Common::UString hookNode;
513 
514  switch (slot) {
516  hookNode = "lhand";
517  break;
519  hookNode = "rhand";
520  break;
521  default:
522  throw Common::Exception("Unsupported equip slot");
523  }
524 
525  _model->attachModel(hookNode, weaponModel);
526 }
527 
529  _name = "Fakoo McFakeston";
530  _tag = Common::UString::format("[PC: %s]", _name.c_str());
531 
532  _isPC = true;
533 }
534 
536  _name = info.getName();
537  _isPC = true;
538 
539  _race = kRaceHuman;
541 
542  _gender = info.getGender();
543 
544  switch (_gender) {
545  case kGenderMale:
546  case kGenderFemale:
547  break;
548  default:
549  throw Common::Exception("Unknown gender");
550  }
551 
552  // set the specific class to level 1
553  _levels.resize(1);
554  _levels[0].level = 1;
555  _levels[0].characterClass = info.getClass();
556 
557  _skin = info.getSkin();
558  _face = info.getFace();
559 
560  PartModels parts;
561  getPartModelsPC(parts, 'a', 1);
562 
563  _portrait = parts.portrait;
564 
565  loadBody(parts);
566  loadHead(parts);
567 
569 }
570 
572  CursorMan.setGroup("talk");
573  highlight(true);
574 }
575 
577  CursorMan.set();
578  highlight(false);
579 }
580 
581 void Creature::highlight(bool enabled) {
582  _model->drawBound(enabled);
583 }
584 
585 bool Creature::click(Object *triggerer) {
586  // Try the onDialog script first
588  return runScript(kScriptDialogue, this, triggerer);
589 
590  // Next, look we have a generic onClick script
591  if (hasScript(kScriptClick))
592  return runScript(kScriptClick, this, triggerer);
593 
594  return false;
595 }
596 
598  return _conversation;
599 }
600 
602  float height = 1.8f;
603  if (_model) {
604  Graphics::Aurora::ModelNode *node = _model->getNode("camerahook");
605  if (node) {
606  float x, y, z;
607  node->getPosition(x, y, z);
608  height = z;
609  }
610  }
611  return height;
612 }
613 
616  if (i != _equipment.end()) {
617  _inventory.addItem(i->second->getTag());
618  _equipment.erase(i);
619  }
620  if (!tag.empty()) {
621  _inventory.removeItem(tag);
622  try {
623  Item *item = new Item(tag);
624  _equipment.insert(std::pair<EquipmentSlot, Item *>(slot, item));
625  } catch (Common::Exception &e) {
626  e.add("Failed to load item: %s", tag.c_str());
627  Common::printException(e, "WARNING: ");
628  }
629  }
630  switch (slot) {
631  case kEquipmentSlotBody:
632  changeBody();
633  break;
636  changeWeapon(slot);
637  break;
638  default:
639  break;
640  }
641 }
642 
644  return _inventory;
645 }
646 
649  return i == _equipment.end() ? 0 : i->second;
650 }
651 
653  if (_model)
654  _model->playDefaultAnimation();
655 }
656 
658  if (!_model)
659  return;
660 
661  Graphics::Aurora::AnimationChannel *headChannel = 0;
662 
663  if (_modelType == "B" || _modelType == "P") {
664  Graphics::Aurora::Model *head = _model->getAttachedModel("headhook");
665  if (head)
667  } else
668  headChannel = _model->getAnimationChannel(Graphics::Aurora::kAnimationChannelHead);
669 
670  if (headChannel)
671  headChannel->playDefaultAnimation();
672 }
673 
674 void Creature::playAnimation(const Common::UString &anim, bool restart, float length, float speed) {
675  if (_model)
676  _model->playAnimation(anim, restart, length, speed);
677 }
678 
679 void Creature::playHeadAnimation(const Common::UString &anim, bool restart, float length, float speed) {
680  if (!_model)
681  return;
682 
683  Graphics::Aurora::AnimationChannel *headChannel = 0;
684 
685  if (_modelType == "B" || _modelType == "P") {
686  Graphics::Aurora::Model *head = _model->getAttachedModel("headhook");
687  if (head)
689  } else
690  headChannel = _model->getAnimationChannel(Graphics::Aurora::kAnimationChannelHead);
691 
692  if (headChannel)
693  headChannel->playAnimation(anim, restart, length, speed);
694 }
695 
696 Common::UString Creature::getBodyMeshString(Gender gender, Class charClass, char state) {
697  Common::UString body, head;
698 
699  body = "p";
700 
701  switch (gender) {
702  case kGenderMale:
703  body += "m";
704  break;
705  case kGenderFemale:
706  body += "f";
707  break;
708  default:
709  throw Common::Exception("Unknown gender");
710  }
711 
712  body += "b";
713  body += state;
714 
715  switch (charClass) {
716  case kClassSoldier:
717  body += "l";
718  break;
719  case kClassScout:
720  body += "m";
721  break;
722  default:
723  case kClassScoundrel:
724  body += "s";
725  break;
726  }
727 
728  return body;
729 }
730 
732  Common::UString head;
733 
734  head = "p";
735 
736  switch (gender) {
737  case kGenderMale:
738  head += "m";
739  break;
740  case kGenderFemale:
741  head += "f";
742  break;
743  default:
744  throw Common::Exception("Unknown gender");
745  }
746 
747  head += "h";
748 
749  switch (skin) {
750  case kSkinA:
751  head += "a";
752  break;
753  case kSkinB:
754  head += "b";
755  break;
756  default:
757  case kSkinC:
758  head += "c";
759  break;
760  }
761 
762  head += "0";
763  head += Common::composeString(faceId + 1);
764 
765  return head;
766 }
767 
769  _actionQueue.clear();
770 }
771 
772 void Creature::enqueueAction(const Action &action) {
773  _actionQueue.push_back(action);
774 }
775 
776 const Action *Creature::peekAction() const {
777  if (_actionQueue.empty())
778  return 0;
779 
780  return &_actionQueue.front();
781 }
782 
784  Action *action = _actionQueue.empty() ? 0 : &_actionQueue.front();
785  if (action)
786  _actionQueue.erase(_actionQueue.begin());
787  return action;
788 }
789 
791  if (!_model)
792  return;
793 
794  if (_modelType == "S" || _modelType == "L")
795  _model->addDefaultAnimation("cpause1", 100);
796  else
797  _model->addDefaultAnimation("pause1", 100);
798 }
799 
800 } // End of namespace KotOR
801 
802 } // End of namespace Engines
A creature in a Star Wars: Knights of the Old Republic area.
int64 getSint(const Common::UString &field, int64 def=0) const
Definition: gff3file.cpp:473
Class to hold the two-dimensional array of a 2DA file.
Definition: 2dafile.h:124
void show()
Show the creature&#39;s model.
Definition: creature.cpp:101
Handling version V3.2/V3.3 of BioWare&#39;s GFFs (generic file format).
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like &#39;DATA&#39;, to ensure portability.
Definition: endianness.h:140
void createPC(const CharacterGenerationInfo &info)
Create a player character creature from a character info class.
Definition: creature.cpp:535
const Common::UString getModelName() const
Definition: item.cpp:87
void add(const char *s,...) GCC_PRINTF(2
Definition: error.cpp:58
void playAnimation(const Common::UString &anim, bool restart=true, float length=0.0f, float speed=1.0f)
Play a named animation.
bool _static
Is the object static?
Definition: object.h:147
const Common::UString & getString(size_t column) const
Return the contents of a cell as a string.
Definition: 2dafile.cpp:59
void loadBody(PartModels &parts)
Definition: creature.cpp:425
bool getBool(const Common::UString &field, bool def=false) const
Definition: gff3file.cpp:510
A class holding an UTF-8 string.
Definition: ustring.h:48
uint8 _face
The face of the creature.
Definition: creature.h:175
void reset(PointerType o=0)
Resets the pointer with the new value.
Definition: scopedptr.h:87
void equipItem(Common::UString tag, EquipmentSlot slot)
Definition: creature.cpp:614
void enqueueAction(const Action &action)
Append action to the character&#39;s action queue.
Definition: creature.cpp:772
UString composeString(T value)
Convert any POD integer, float/double or bool type into a string.
Definition: strutil.cpp:276
uint8_t uint8
Definition: types.h:200
bool beginsWith(const UString &with) const
Definition: ustring.cpp:295
bool hasField(const Common::UString &field) const
Does this specific field exist?
Definition: gff3file.cpp:400
Mathematical helpers.
bool isPartyMember() const
Definition: creature.cpp:129
const Common::UString & getConversation() const
Definition: creature.cpp:597
std::vector< Action > _actionQueue
Definition: creature.h:187
Skin _skin
The skin type of the creature.
Definition: creature.h:174
Common::ScopedPtr< Graphics::Aurora::Model > _model
The creature&#39;s model.
Definition: creature.h:178
bool isPC() const
Is the creature a player character?
Definition: creature.cpp:125
Common::UString _modelType
Definition: creature.h:177
void loadPortrait(const Aurora::GFF3Struct &gff)
Definition: creature.cpp:292
const Action * peekAction() const
Definition: creature.cpp:776
uint64 getUint(const Common::UString &field, uint64 def=0) const
Definition: gff3file.cpp:436
void getPosition(float &x, float &y, float &z) const
Get the position of the node.
Definition: modelnode.cpp:181
Aurora::GFF3File * loadOptionalGFF3(const Common::UString &gff3, Aurora::FileType type, uint32 id, bool repairNWNPremium)
Load a GFF3, but return 0 instead of throwing on error.
Definition: util.cpp:150
void changeWeapon(EquipmentSlot slot)
Definition: creature.cpp:501
Inventory & getInventory()
Definition: creature.cpp:643
Common::UString _description
The object&#39;s description.
Definition: object.h:143
Class getClassByPosition(int position) const
Get the class by its position in the level vector.
Definition: creature.cpp:153
uint32 _appearance
The creature&#39;s general appearance.
Definition: creature.h:167
bool _isPC
Is the creature a PC?
Definition: creature.h:165
void playHeadAnimation(const Common::UString &anim, bool restart=true, float length=0.0f, float speed=1.0f)
Definition: creature.cpp:679
Utility templates and functions for working with strings and streams.
Exception that provides a stack of explanations.
Definition: error.h:36
int getTextureVariation() const
Definition: item.cpp:76
bool click(Object *triggerer=0)
The creature was clicked.
Definition: creature.cpp:585
Race getRace() const
Get the race of the creature.
Definition: creature.cpp:160
void load(const Aurora::GFF3Struct &creature)
Definition: creature.cpp:192
Basic exceptions to throw.
const char * c_str() const
Return the (utf8 encoded) string data.
Definition: ustring.cpp:249
void replaceAll(uint32 what, uint32 with)
Replace all occurrences of a character with another character.
Definition: ustring.cpp:435
static UString format(const char *s,...) GCC_PRINTF(1
Print formatted data into an UString object, similar to sprintf().
Definition: ustring.cpp:718
Common::UString _portrait
The object&#39;s portrait.
Definition: object.h:145
bool isClickable() const
Can the player click the object?
Definition: object.cpp:130
void leave()
The cursor left the creature.
Definition: creature.cpp:576
Utility templates and functions.
Common::UString _name
The object&#39;s display name.
Definition: object.h:142
void getPartModelsPC(PartModels &parts, uint32 state, uint8 textureVariation)
Definition: creature.cpp:358
double getDouble(const Common::UString &field, double def=0.0) const
Definition: gff3file.cpp:514
virtual void setOrientation(float x, float y, float z, float angle)
Set the object&#39;s orientation.
Definition: object.cpp:158
Handling BioWare&#39;s 2DAs (two-dimensional array).
void loadProperties(const Aurora::GFF3Struct &gff)
Definition: creature.cpp:234
void info(const char *s,...)
Definition: util.cpp:69
A node within a 3D model.
SubRace _subRace
The subrace of the creature.
Definition: creature.h:170
A 3D model of an object.
void loadMovementRate(const Common::UString &name)
Definition: creature.cpp:456
bool empty() const
Is the string empty?
Definition: ustring.cpp:245
#define TwoDAReg
Shortcut for accessing the 2da registry.
Definition: 2dareg.h:101
bool runScript(Script script, const Aurora::NWScript::ObjectReference owner=Aurora::NWScript::ObjectReference(), const Aurora::NWScript::ObjectReference triggerer=Aurora::NWScript::ObjectReference())
Definition: container.cpp:158
Gender getGender() const
Get the gender of the creature.
Definition: creature.cpp:133
int _currentHitPoints
The current hitpoints of the object.
Definition: object.h:150
StackException Exception
Definition: error.h:59
Graphics::Aurora::Model * _headModel
The creature&#39;s head model.
Definition: creature.h:179
The global 2DA registry.
void playAnimation(const Common::UString &anim, bool restart=true, float length=0.0f, float speed=1.0f)
Definition: creature.cpp:674
int getLevelByPosition(int position) const
Get the level by its position in the level vector.
Definition: creature.cpp:146
virtual void getOrientation(float &x, float &y, float &z, float &angle) const
Return the object&#39;s orientation.
Definition: object.cpp:144
void warning(const char *s,...)
Definition: util.cpp:33
#define CursorMan
Shortcut for accessing the cursor manager.
Definition: cursorman.h:129
int32 getInt(size_t column) const
Return the contents of a cell as an int.
Definition: 2dafile.cpp:75
AnimationChannel * getAnimationChannel(AnimationChannelName name)
Definition: model.cpp:537
std::vector< const GFF3Struct * > GFF3List
Definition: types.h:449
bool _minOneHitPoint
If the object should have at least one hitpoint.
Definition: object.h:152
static Common::UString getBodyMeshString(Gender gender, Class charClass, char state='b')
Generate a string for the body mesh.
Definition: creature.cpp:696
Creature()
Create a dummy creature instance.
Definition: creature.cpp:75
float getWalkRate() const
Definition: creature.cpp:168
The Aurora cursor manager.
void addItem(const Common::UString &tag, int count=1)
Definition: inventory.cpp:31
Unicode string handling.
std::list< uint32 > _ids
The object&#39;s model IDs.
Definition: object.h:154
const GFF3List & getList(const Common::UString &field) const
Definition: gff3file.cpp:741
Common::PtrMap< EquipmentSlot, Item > _equipment
Definition: creature.h:185
float getRunRate() const
Definition: creature.cpp:172
const Action * dequeueAction()
Definition: creature.cpp:783
int _maxHitPoints
The maximum hitpoints of the object.
Definition: object.h:151
const TwoDARow & getRow(size_t row) const
Get a row.
Definition: 2dafile.cpp:421
virtual void setPosition(float x, float y, float z)
Set the object&#39;s position within its area.
Definition: object.cpp:152
void hide()
Hide the creature&#39;s model.
Definition: creature.cpp:111
A struct within a GFF3.
Definition: gff3file.h:164
uint32_t uint32
Definition: types.h:204
void highlight(bool enabled)
(Un)Highlight the creature.
Definition: creature.cpp:581
bool hasScript(Script script) const
Definition: container.cpp:125
Parts of a creature&#39;s body.
Definition: creature.h:149
Common::UString _tag
Definition: object.h:56
static const uint32 kFieldIDInvalid
Definition: types.h:443
void loadHead(PartModels &parts)
Definition: creature.cpp:445
void getPartModels(PartModels &parts, uint32 state='a')
Definition: creature.cpp:326
void setPosition(float x, float y, float z)
Set the creature&#39;s position.
Definition: creature.cpp:176
Item * getEquipedItem(EquipmentSlot slot) const
Definition: creature.cpp:647
Common::UString getString(const Common::UString &field, const Common::UString &def="") const
Definition: gff3file.cpp:527
int getBodyVariation() const
Definition: item.cpp:72
static float rad2deg(float rad)
Definition: maths.h:93
Generic Aurora engines utility functions.
An item in a Star Wars: Knights of the Old Republic area.
void readScripts(const Aurora::GFF3Struct &gff, bool clear=true)
Definition: container.cpp:134
SubRace getSubRace() const
Get the subrace of the creature.
Definition: creature.cpp:164
float getCameraHeight() const
Definition: creature.cpp:601
Animation channel.
virtual void getPosition(float &x, float &y, float &z) const
Return the object&#39;s position within its area.
Definition: object.cpp:138
A map of pointer to objects, with automatic deletion.
Definition: ptrmap.h:42
Graphics::Aurora::Model * loadModelObject(const Common::UString &resref, const Common::UString &texture)
Definition: model.cpp:47
A row within a 2DA file.
Definition: 2dafile.h:61
bool _usable
Is the object usable?
Definition: object.h:148
std::vector< ClassLevel > _levels
The levels of the creature.
Definition: creature.h:173
static Common::UString getHeadMeshString(Gender gender, Skin skin, uint32 faceId)
Generate a string for the head mesh.
Definition: creature.cpp:731
The class for storing character information for generation.
bool isVisible() const
Is the creature&#39;s model visible?
Definition: creature.cpp:121
void printException(Exception &e, const UString &prefix)
Print a whole exception stack to stderr and the log.
Definition: error.cpp:95
Creature template (user), GFF.
Definition: types.h:93
int getLevel(const Class &c) const
Get the level of the creature regarding a specific class.
Definition: creature.cpp:137
Race _race
The race of the creature.
Definition: creature.h:169
void removeItem(const Common::UString &tag, int count=1)
Definition: inventory.cpp:47
Common::UString _conversation
Definition: creature.h:182
void createFakePC()
Create a fake player character creature for testing purposes.
Definition: creature.cpp:528
void enter()
The cursor entered the creature.
Definition: creature.cpp:571
void setOrientation(float x, float y, float z, float angle)
Set the creature&#39;s orientation.
Definition: creature.cpp:184
int stricmp(const UString &str) const
Definition: ustring.cpp:192
float getFloat(size_t column) const
Return the contents of a cell as a float.
Definition: 2dafile.cpp:91
Generic Aurora engines model functions.