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 <cassert>
26 
27 #include "src/common/util.h"
28 #include "src/common/maths.h"
29 #include "src/common/readfile.h"
30 #include "src/common/configman.h"
31 
32 #include "src/aurora/types.h"
33 #include "src/aurora/talkman.h"
34 #include "src/aurora/resman.h"
35 #include "src/aurora/gff3file.h"
36 #include "src/aurora/2dafile.h"
37 #include "src/aurora/2dareg.h"
38 
43 
44 #include "src/events/events.h"
45 
48 
50 #include "src/engines/nwn/item.h"
51 #include "src/engines/nwn/area.h"
52 
53 static const uint32 kBICID = MKTAG('B', 'I', 'C', ' ');
54 
55 namespace Engines {
56 
57 namespace NWN {
58 
59 Creature::Class::Class() : classID(UINT32_MAX), level(UINT16_MAX), domain1(UINT8_MAX),
60  domain2(UINT8_MAX), school(UINT8_MAX) {
61 }
62 
63 Creature::Associate::Associate(AssociateType t, Creature *a) : type(t), associate(a) {
64 }
65 
66 
68 }
69 
71  init();
72 }
73 
75  init();
76 
77  load(creature);
78 }
79 
81  init();
82 
83  loadCharacter(bic, local);
84 }
85 
87  if (_master)
88  _master->removeAssociate(*this);
89 
90  for (std::list<Associate>::iterator a = _associates.begin(); a != _associates.end(); ++a)
91  a->associate->setMaster(0);
92 
93  hide();
94 }
95 
98 
101 
102  _portrait = "gui_po_nwnlogo_";
103 
104  _isPC = false;
105  _isDM = false;
106 
107  _age = 0;
108 
109  _xp = 0;
110 
111  _baseHP = 0;
112  _bonusHP = 0;
113  _currentHP = 0;
114 
115  _hitDice = 0;
116 
117  _goodEvil = 0;
118  _lawChaos = 0;
119 
122 
123  _startingPackage = 0;
124  _skills.assign(28, 0);
125 
130 
137 
138  _master = 0;
139 
140  _isCommandable = true;
141 
142  for (size_t i = 0; i < kAbilityMAX; i++)
143  _abilities[i] = 0;
144 
145  _bodyParts.resize(kBodyPartMAX);
146 }
147 
149  if (_model)
150  _model->show();
151 }
152 
154  leave();
155 
156  hideTooltip();
157 
158  if (_model)
159  _model->hide();
160 }
161 
162 void Creature::setPosition(float x, float y, float z) {
163  Object::setPosition(x, y, z);
164  Object::getPosition(x, y, z);
165 
166  if (_model)
167  _model->setPosition(x, y, z);
168 }
169 
170 void Creature::setOrientation(float x, float y, float z, float angle) {
171  Object::setOrientation(x, y, z, angle);
172  Object::getOrientation(x, y, z, angle);
173 
174  if (_model)
175  _model->setOrientation(x, y, z, angle);
176 }
177 
179  return _lastChangedGUIDisplay;
180 }
181 
183  return _firstName;
184 }
185 
187  return _lastName;
188 }
189 
191  return _gender;
192 }
193 
195  _gender = gender;
196 }
197 
198 bool Creature::isFemale() const {
199  // Male and female are hardcoded. Other genders (none, both, other)
200  // count as male when it comes to tokens in text strings.
201 
202  return _gender == kGenderFemale;
203 }
204 
206  return _race;
207 }
208 
210  if (race >= kRaceInvalid)
211  error("Unable to set race, raceID is invalid.");
212 
213  _race = race;
214 }
215 
216 void Creature::setPortrait(const Common::UString &portrait) {
217  _portrait = portrait;
218 
219  _lastChangedGUIDisplay = EventMan.getTimestamp();
220 }
221 
223  return _portrait;
224 }
225 
226 bool Creature::isPC() const {
227  return _isPC;
228 }
229 
230 bool Creature::isDM() const {
231  return _isDM;
232 }
233 
235  return _age;
236 }
237 
239  return _xp;
240 }
241 
243  return _currentHP + _bonusHP;
244 }
245 
247  return _baseHP + _bonusHP;
248 }
249 
251  return _startingPackage;
252 }
253 
255  _startingPackage = package;
256 }
257 
258 void Creature::getDomains(uint32 classID, uint8 &domain1, uint8 &domain2) {
259  Class *creatureClass = findClass(classID);
260  if (!creatureClass) {
261  domain1 = UINT8_MAX;
262  domain2 = UINT8_MAX;
263  return;
264  }
265 
266  domain1 = creatureClass->domain1;
267  domain2 = creatureClass->domain2;
268 }
269 
270 void Creature::setDomains(uint32 classID, uint8 domain1, uint8 domain2) {
271  Class *creatureClass = findClass(classID);
272  if (!creatureClass)
273  return;
274 
275  creatureClass->domain1 = domain1;
276  creatureClass->domain2 = domain2;
277 }
278 
279 bool Creature::hasSpell(uint32 classID, size_t spellLevel, uint16 spell) {
280  Class *creatureClass = findClass(classID);
281  if (!creatureClass)
282  return false;
283 
284  if (creatureClass->knownList.size() < spellLevel)
285  return false;
286 
287  std::vector<uint16> &spellLvlList = creatureClass->knownList[spellLevel];
288  // Check if the creature already knows the spell.
289  for (std::vector<uint16>::iterator s = spellLvlList.begin(); s != spellLvlList.end(); ++s)
290  if (*s == spell)
291  return true;
292 
293  return false;
294 }
295 
296 void Creature::setSchool(uint32 classID, uint8 school) {
297  Class *creatureClass = findClass(classID);
298  if (!creatureClass)
299  return;
300 
301  creatureClass->school = school;
302 }
303 
304 void Creature::setKnownSpell(uint32 classID, size_t spellLevel, uint16 spell) {
305  Class *creatureClass = findClass(classID);
306  if (!creatureClass)
307  return;
308 
309  if (creatureClass->knownList.size() < spellLevel + 1)
310  creatureClass->knownList.resize(spellLevel + 1);
311 
312  std::vector<uint16> &spellLvlList = creatureClass->knownList[spellLevel];
313  // Check if the creature already knows the spell.
314  for (std::vector<uint16>::iterator s = spellLvlList.begin(); s != spellLvlList.end(); ++s)
315  if (*s == spell)
316  return;
317 
318  spellLvlList.push_back(spell);
319  return;
320 }
321 
322 void Creature::setMemorizedSpell(uint32 classID, size_t spellLevel, uint16 spell) {
323  Class *creatureClass = findClass(classID);
324  if (!creatureClass)
325  return;
326 
327  if (creatureClass->memorizedList.size() < spellLevel + 1)
328  creatureClass->memorizedList.resize(spellLevel + 1);
329 
330  std::vector<uint16> &spellLvlList = creatureClass->memorizedList[spellLevel];
331  // Check if the creature already knows the spell.
332  for (std::vector<uint16>::iterator s = spellLvlList.begin(); s != spellLvlList.end(); ++s)
333  if (*s == spell)
334  return;
335 
336  spellLvlList.push_back(spell);
337  return;
338 }
339 
340 void Creature::setAppearance(uint32 appearanceID) {
341  _appearanceID = appearanceID;
342 }
343 
345  _phenotype = phenotype;
346 }
347 
349  _colorSkin = colorSkin;
350 }
351 
353  _colorHair = colorHair;
354 }
355 
356 void Creature::setColorTatto1(uint32 colorTattoo1) {
357  _colorTattoo1 = colorTattoo1;
358 }
359 
360 void Creature::setColorTatto2(uint32 colorTattoo2) {
361  _colorTattoo2 = colorTattoo2;
362 }
363 
364 void Creature::setHead(uint32 headID) {
365  _bodyParts[kBodyPartHead].id = headID;
366 }
367 
369  _equippedItems.push_back(item);
370 }
371 
372 void Creature::setArea(Area *area) {
373  Object::setArea(area);
374 
375  if (area && _model && _environmentMap.equalsIgnoreCase("default"))
376  _model->setEnvironmentMap(area->getEnvironmentMap());
377 }
378 
380  removeAssociate(henchman);
381 
382  assert(!henchman.getMaster());
383 
384  _associates.push_back(Associate(type, &henchman));
385  henchman.setMaster(this);
386 }
387 
389  for (std::list<Associate>::iterator a = _associates.begin(); a != _associates.end(); ++a) {
390  if (a->associate == &henchman) {
391  assert(a->associate->getMaster() == this);
392 
393  a->associate->setMaster(0);
394  _associates.erase(a);
395  break;
396  }
397  }
398 }
399 
401  if (_associates.empty())
402  return 0;
403 
404  Creature *curAssociate = 0;
405 
406  std::list<Associate>::const_iterator associate = _associates.begin();
407  while (nth-- > 0) {
408  while ((associate != _associates.end()) && (associate->type != type))
409  ++associate;
410 
411  if (associate == _associates.end())
412  return 0;
413 
414  curAssociate = associate->associate;
415  }
416 
417  return curAssociate;
418 }
419 
421  _master = master;
422 }
423 
425  return _master;
426 }
427 
429  return _isCommandable;
430 }
431 
432 void Creature::setCommandable(bool commandable) {
433  _isCommandable = commandable;
434 }
435 
437  const Common::UString &gender, const Common::UString &race,
438  const Common::UString &phenoType, Common::UString &part) {
439 
440  part = Common::UString::format("p%s%s%s_%s%03d",
441  gender.c_str(), race.c_str(), phenoType.c_str(), type.c_str(), id);
442 }
443 
445  const Common::UString &gender, const Common::UString &race,
446  const Common::UString &phenoType, const Common::UString &phenoTypeAlt,
447  Aurora::FileType fileType, Common::UString &part) {
448 
449  constructPartName(type, id, gender, race, phenoType, part);
450  if ((fileType == Aurora::kFileTypeNone) || ResMan.hasResource(part, fileType))
451  return;
452 
453  constructPartName(type, id, gender, race, phenoTypeAlt, part);
454  if (!ResMan.hasResource(part, fileType))
455  part.clear();
456 }
457 
459  const Common::UString &gender, const Common::UString &race,
460  const Common::UString &phenoType, const Common::UString &phenoTypeAlt,
461  Common::UString &model, Common::UString &texture) {
462 
463  constructPartName(type, id, gender, race, phenoType, phenoTypeAlt, Aurora::kFileTypeMDL, model);
464 
465  constructPartName(type, id, gender, race, phenoType, phenoTypeAlt, Aurora::kFileTypePLT, texture);
466 
467  // PLT texture doesn't exist, try a generic human PLT
468  if (texture.empty())
469  constructPartName(type, id, gender, "H", phenoType, phenoTypeAlt, Aurora::kFileTypePLT, texture);
470 
471  // Human PLT texture doesn't exist either, assume it's a non-PLT texture
472  if (texture.empty())
473  constructPartName(type, id, gender, race, phenoType, phenoTypeAlt, Aurora::kFileTypeNone, texture);
474 }
475 
476 // Based on filenames in model2.bif
477 // These should be read from MDLNAME, NODENAME in capart.2da (in 2da.bif)
478 static const char * const kBodyPartModels[] = {
479  "head" ,
480  "neck" ,
481  "chest" ,
482  "pelvis",
483  "belt" ,
484  "footr" , "footl" ,
485  "shinr" , "shinl" ,
486  "legl" , "legr" ,
487  "forer" , "forel" ,
488  "bicepr", "bicepl",
489  "shor" , "shol" ,
490  "handr" , "handl"
491 };
492 
493 // Node names taken from pfa0.mdl
494 static const char * const kBodyPartNodes[] = {
495  "head_g" ,
496  "neck_g" ,
497  "torso_g" ,
498  "pelvis_g" ,
499  "belt_g" ,
500  "rfoot_g" , "lfoot_g" ,
501  "rshin_g" , "lshin_g" ,
502  "lthigh_g" , "rthigh_g" ,
503  "rforearm_g" , "lforearm_g" ,
504  "rbicep_g" , "lbicep_g" ,
505  "rshoulder_g", "lshoulder_g",
506  "rhand_g" , "lhand_g"
507 };
508 
510  const Aurora::TwoDAFile &appearance = TwoDAReg.get2DA("appearance");
511 
512  const Aurora::TwoDARow &gender = TwoDAReg.get2DA("gender").getRow((uint) _gender);
513  const Aurora::TwoDARow &race = TwoDAReg.get2DA("racialtypes").getRow(_race);
514  const Aurora::TwoDARow &raceAp = appearance.getRow(race.getInt("Appearance"));
515  const Aurora::TwoDARow &pheno = TwoDAReg.get2DA("phenotype").getRow(_phenotype);
516 
517  Common::UString genderChar = gender.getString("GENDER");
518  Common::UString raceChar = raceAp.getString("RACE");
520  Common::UString phenoAltChar = pheno.getString("DefaultPhenoType");
521 
522  // Important to capture the supermodel
524  genderChar.c_str(), raceChar.c_str(), phenoChar.c_str());
525 
526  // Fall back to the default phenotype if required
529  genderChar.c_str(), raceChar.c_str(), phenoAltChar.c_str());
530 
531  for (size_t i = 0; i < kBodyPartMAX; i++)
533  _bodyParts[i].idArmor > 0 ? _bodyParts[i].idArmor : _bodyParts[i].id,
534  genderChar, raceChar, phenoChar, phenoAltChar,
535  _bodyParts[i].modelName, _bodyParts[i].textureName);
536 }
537 
539  for (Common::PtrVector<Item>::iterator e = _equippedItems.begin(); e != _equippedItems.end(); ++e) {
540  const Item &item = **e;
541  if (!item.isArmor())
542  continue;
543 
544  status("Equipping armour \"%s\" on model \"%s\"", item.getName().c_str(), _tag.c_str());
545 
546  // Set the body part models
547  for (size_t i = 0; i < kBodyPartMAX; i++) {
548  uint32 id = item.getArmorPart(i);
549  if (id != Aurora::kFieldIDInvalid)
550  _bodyParts[i].idArmor = id;
551  }
552 
553  // Set the armour color channels
560  }
561 }
562 
564  for (std::vector<Class>::iterator c = _classes.begin(); c != _classes.end(); ++c) {
565  if (c->classID != classID)
566  continue;
567 
568  return &(*c);
569  }
570 
571  return 0;
572 }
573 
574 void Creature::finishPLTs(const std::list<Graphics::Aurora::TextureHandle> &plts) {
575  for (std::list<Graphics::Aurora::TextureHandle>::const_iterator p = plts.begin(); p != plts.end(); ++p) {
576  Graphics::Aurora::PLTFile *plt = dynamic_cast<Graphics::Aurora::PLTFile *>(&p->getTexture());
577  if (!plt)
578  continue;
579 
590 
591  plt->rebuild();
592  }
593 }
594 
596  if (_model)
597  return;
598 
600  warning("Creature \"%s\" has no appearance", _tag.c_str());
601  return;
602  }
603 
604  const Aurora::TwoDARow &appearance = TwoDAReg.get2DA("appearance").getRow(_appearanceID);
605 
606  if (_portrait.empty())
607  _portrait = appearance.getString("PORTRAIT");
608 
609  _environmentMap = appearance.getString("ENVMAP");
610 
611  if (appearance.getString("MODELTYPE") == "P") {
612  getArmorModels();
613  getPartModels();
615 
616  for (size_t i = 0; i < kBodyPartMAX; i++) {
617  if (_bodyParts[i].modelName.empty())
618  continue;
619 
620  TextureMan.startRecordNewTextures();
621 
622  // Try to load in the corresponding part model
623  Graphics::Aurora::Model *partModel = loadModelObject(_bodyParts[i].modelName, _bodyParts[i].textureName);
624  if (!partModel)
625  continue;
626 
627  // Add the loaded model to the appropriate part node
628  _model->attachModel(kBodyPartNodes[i], partModel);
629 
630  std::list<Common::UString> newTextures;
631  TextureMan.stopRecordNewTextures(newTextures);
632 
633  for (std::list<Common::UString>::const_iterator t = newTextures.begin(); t != newTextures.end(); ++t) {
634  Graphics::Aurora::TextureHandle texture = TextureMan.getIfExist(*t);
635  if (texture.empty())
636  continue;
637 
638  _bodyParts[i].textures.push_back(texture);
639  }
640 
641  finishPLTs(_bodyParts[i].textures);
642  }
643 
644  } else
645  _model.reset(loadModelObject(appearance.getString("RACE")));
646 
647  // Positioning
648 
649  float x, y, z, angle;
650 
651  getPosition(x, y, z);
652  setPosition(x, y, z);
653 
654  getOrientation(x, y, z, angle);
655  setOrientation(x, y, z, angle);
656 
657  // Clickable
658 
659  if (_model) {
660  _model->setTag(_tag);
661  _model->setClickable(isClickable());
662 
663  _ids.push_back(_model->getID());
664 
665  if (!_environmentMap.empty()) {
666  Common::UString environmentMap = _environmentMap;
667  if (environmentMap.equalsIgnoreCase("default"))
668  environmentMap = _area ? _area->getEnvironmentMap() : "";
669 
670  _model->setEnvironmentMap(environmentMap);
671  }
672  }
673 }
674 
676  hide();
677 
678  destroyTooltip();
679 
680  _model.reset();
681 }
682 
683 void Creature::loadCharacter(const Common::UString &bic, bool local) {
685 
686  load(gff->getTopLevel(), 0);
687 
688  // All BICs should be PCs.
689  _isPC = true;
690 
691  // Set the PC tag to something recognizable for now.
692  // Let's hope no script depends on it being "".
693 
694  _tag = Common::UString::format("[PC: %s]", _name.c_str());
695 
696  _lastChangedGUIDisplay = EventMan.getTimestamp();
697 }
698 
699 void Creature::load(const Aurora::GFF3Struct &creature) {
700  const Common::UString temp = creature.getString("TemplateResRef");
701 
703  if (!temp.empty())
704  utc.reset(loadOptionalGFF3(temp, Aurora::kFileTypeUTC, MKTAG('U', 'T', 'C', ' '), true));
705 
706  load(creature, utc ? &utc->getTopLevel() : 0);
707 
708  _lastChangedGUIDisplay = EventMan.getTimestamp();
709 }
710 
711 void Creature::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) {
712  // General properties
713 
714  if (blueprint)
715  loadProperties(*blueprint); // Blueprint
716  loadProperties(instance); // Instance
717 
718  // Position
719 
720  setPosition(instance.getDouble("XPosition"),
721  instance.getDouble("YPosition"),
722  instance.getDouble("ZPosition"));
723 
724  // Orientation
725 
726  float bearingX = instance.getDouble("XOrientation");
727  float bearingY = instance.getDouble("YOrientation");
728 
729  setOrientation(0.0f, 0.0f, 1.0f, -Common::rad2deg(atan2(bearingX, bearingY)));
730 }
731 
732 static const char * const kBodyPartFields[] = {
733  "Appearance_Head",
734  "BodyPart_Neck" ,
735  "BodyPart_Torso" ,
736  "BodyPart_Pelvis",
737  "BodyPart_Belt" ,
738  "ArmorPart_RFoot", "BodyPart_LFoot" ,
739  "BodyPart_RShin" , "BodyPart_LShin" ,
740  "BodyPart_LThigh", "BodyPart_RThigh",
741  "BodyPart_RFArm" , "BodyPart_LFArm" ,
742  "BodyPart_RBicep", "BodyPart_LBicep",
743  "BodyPart_RShoul", "BodyPart_LShoul",
744  "BodyPart_RHand" , "BodyPart_LHand"
745 };
746 
748  // Tag
749 
750  _tag = gff.getString("Tag", _tag);
751 
752  // Name
753 
754  _firstName = gff.getString("FirstName", _firstName);
755  _lastName = gff.getString("LastName" , _lastName);
756 
757  _name = _firstName + " " + _lastName;
758  _name.trim();
759 
760  // Description
761 
762  _description = gff.getString("Description", _description);
763 
764  // Conversation
765 
766  _conversation = gff.getString("Conversation", _conversation);
767 
768  // Sound Set
769 
770  _soundSet = gff.getUint("SoundSetFile", Aurora::kFieldIDInvalid);
771 
772  // Portrait
773 
774  loadPortrait(gff, _portrait);
775 
776  // Gender
777  _gender = (Gender) gff.getUint("Gender", (uint64) _gender);
778 
779  // Race
780  _race = gff.getUint("Race", _race);
781 
782  // Subrace
783  _subRace = gff.getString("Subrace", _subRace);
784 
785  // PC and DM
786  _isPC = gff.getBool("IsPC", _isPC);
787  _isDM = gff.getBool("IsDM", _isDM);
788 
789  // Age
790  _age = gff.getUint("Age", _age);
791 
792  // Experience
793  _xp = gff.getUint("Experience", _xp);
794 
795  // Abilities
802 
803  // Classes
805 
806  // Package
807  _startingPackage = gff.getUint("StartingPackage", _startingPackage);
808 
809  // Skills
810  if (gff.hasField("SkillList")) {
811  _skills.clear();
812 
813  const Aurora::GFF3List &skills = gff.getList("SkillList");
814  for (Aurora::GFF3List::const_iterator s = skills.begin(); s != skills.end(); ++s) {
815  const Aurora::GFF3Struct &skill = **s;
816 
817  _skills.push_back(skill.getSint("Rank"));
818  }
819  }
820 
821  // Feats
822  if (gff.hasField("FeatList")) {
823  _feats.clear();
824 
825  const Aurora::GFF3List &feats = gff.getList("FeatList");
826  for (Aurora::GFF3List::const_iterator f = feats.begin(); f != feats.end(); ++f) {
827  const Aurora::GFF3Struct &feat = **f;
828 
829  _feats.push_back(feat.getUint("Feat"));
830  }
831  }
832 
833  // Deity
834  _deity = gff.getString("Deity", _deity);
835 
836  // Health
837  if (gff.hasField("HitPoints")) {
838  _baseHP = gff.getSint("HitPoints");
839  _bonusHP = gff.getSint("MaxHitPoints", _baseHP) - _baseHP;
840  _currentHP = gff.getSint("CurrentHitPoints", _baseHP);
841  }
842 
843  // Alignment
844 
845  _goodEvil = gff.getUint("GoodEvil", _goodEvil);
846  _lawChaos = gff.getUint("LawfulChaotic", _lawChaos);
847 
848  // Appearance
849 
850  _appearanceID = gff.getUint("Appearance_Type", _appearanceID);
851  _phenotype = gff.getUint("Phenotype" , _phenotype);
852 
853  // Body parts
854  for (size_t i = 0; i < kBodyPartMAX; i++) {
855  _bodyParts[i].id = gff.getUint(kBodyPartFields[i], _bodyParts[i].id);
856  _bodyParts[i].idArmor = 0;
857  }
858 
859  // Colors
860  _colorSkin = gff.getUint("Color_Skin", _colorSkin);
861  _colorHair = gff.getUint("Color_Hair", _colorHair);
862  _colorTattoo1 = gff.getUint("Color_Tattoo1", _colorTattoo1);
863  _colorTattoo2 = gff.getUint("Color_Tattoo2", _colorTattoo2);
864 
865  // Equipped Items
866  loadEquippedItems(gff);
867 
868  // Scripts
869  readScripts(gff);
870 }
871 
873  uint32 portraitID = gff.getUint("PortraitId");
874  if (portraitID != 0) {
875  const Aurora::TwoDAFile &twoda = TwoDAReg.get2DA("portraits");
876 
877  Common::UString portrait2DA = twoda.getRow(portraitID).getString("BaseResRef");
878  if (!portrait2DA.empty())
879  portrait = "po_" + portrait2DA;
880  }
881 
882  portrait = gff.getString("Portrait", portrait);
883 }
884 
886  if (!gff.hasField("Equip_ItemList"))
887  return;
888 
889  const Aurora::GFF3List &cEquipped = gff.getList("Equip_ItemList");
890  for (Aurora::GFF3List::const_iterator e = cEquipped.begin(); e != cEquipped.end(); ++e)
891  _equippedItems.push_back(new Item(**e));
892 }
893 
895  std::vector<Class> &classes, uint8 &hitDice) {
896 
897  if (!gff.hasField("ClassList"))
898  return;
899 
900  classes.clear();
901  hitDice = 0;
902 
903  const Aurora::GFF3List &cClasses = gff.getList("ClassList");
904  for (Aurora::GFF3List::const_iterator c = cClasses.begin(); c != cClasses.end(); ++c) {
905  classes.push_back(Class());
906 
907  const Aurora::GFF3Struct &cClass = **c;
908 
909  classes.back().classID = cClass.getUint("Class");
910  classes.back().level = cClass.getUint("ClassLevel");
911 
912  hitDice += classes.back().level;
913  }
914 }
915 
917  const uint32 strRef = TwoDAReg.get2DA("racialtypes").getRow(_race).getInt("ConverName");
918 
919  return TalkMan.getString(strRef);
920 }
921 
923  const uint32 strRef = TwoDAReg.get2DA("racialtypes").getRow(_race).getInt("ConverNameLower");
924 
925  return TalkMan.getString(strRef);
926 }
927 
929  const uint32 strRef = TwoDAReg.get2DA("racialtypes").getRow(_race).getInt("NamePlural");
930 
931  return TalkMan.getString(strRef);
932 }
933 
935  return _subRace;
936 }
937 
938 void Creature::getClass(uint32 position, uint32 &classID, uint16 &level) const {
939  if (position >= _classes.size()) {
940  classID = kClassInvalid;
941  level = 0;
942  return;
943  }
944 
945  classID = _classes[position].classID;
946  level = _classes[position].level;
947 }
948 
950  for (std::vector<Class>::const_iterator c = _classes.begin(); c != _classes.end(); ++c)
951  if (c->classID == classID)
952  return c->level;
953 
954  return 0;
955 }
956 
957 void Creature::changeClassLevel(uint32 classID, int16 levelChange) {
958  for (std::vector<Class>::iterator c = _classes.begin(); c != _classes.end(); ++c) {
959  if (c->classID != classID)
960  continue;
961 
962  if (c->level + levelChange >= 0)
963  c->level += levelChange;
964 
965  return;
966  }
967 
968  if (levelChange < 0)
969  return;
970 
971  // If there is no level in the class, create it.
972  Class newClass = Class();
973  newClass.classID = classID;
974  newClass.level = levelChange;
975  _classes.push_back(newClass);
976 }
977 
979  const uint32 classID = _classes.front().classID;
980  const uint32 strRef = TwoDAReg.get2DA("classes").getRow(classID).getInt("Name");
981 
982  return TalkMan.getString(strRef);
983 }
984 
986  const uint32 classID = _classes.front().classID;
987  const uint32 strRef = TwoDAReg.get2DA("classes").getRow(classID).getInt("Lower");
988 
989  return TalkMan.getString(strRef);
990 }
991 
993  const uint32 classID = _classes.front().classID;
994  const uint32 strRef = TwoDAReg.get2DA("classes").getRow(classID).getInt("Plural");
995 
996  return TalkMan.getString(strRef);
997 }
998 
1000  return _deity;
1001 }
1002 
1004  return _goodEvil;
1005 }
1006 
1008  _goodEvil = goodness;
1009 }
1010 
1012  return _lawChaos;
1013 }
1014 
1015 void Creature::setLawChaos(uint8 lawfulness) {
1016  _lawChaos = lawfulness;
1017 }
1018 
1020  _soundSet = soundSet;
1021 }
1022 
1024  Common::UString classString;
1025 
1026  getClassString(_classes, classString);
1027 
1028  return classString;
1029 }
1030 
1032  return _hitDice;
1033 }
1034 
1036  assert((ability >= 0) && (ability < kAbilityMAX));
1037 
1038  return _abilities[ability];
1039 }
1040 
1041 void Creature::setAbility(Ability ability, uint8 score) {
1042  assert((ability >= 0) && ability < kAbilityMAX);
1043 
1044  _abilities[ability] = score;
1045 }
1046 
1048  if (skill >= _skills.size())
1049  return -1;
1050 
1051  return _skills[skill];
1052 }
1053 
1054 void Creature::setSkillRank(size_t skill, uint8 rank) {
1055  if (skill >= _skills.size())
1056  return;
1057 
1058  _skills[skill] = rank;
1059 }
1060 
1062  if (hasFeat(feat))
1063  return;
1064 
1065  _feats.push_back(feat);
1066 }
1067 
1068 bool Creature::hasFeat(uint32 feat) const {
1069  for (std::vector<uint32>::const_iterator f = _feats.begin(); f != _feats.end(); ++f)
1070  if (*f == feat)
1071  return true;
1072 
1073  return false;
1074 }
1075 
1077  highlight(true);
1078 }
1079 
1081  highlight(false);
1082 }
1083 
1084 void Creature::highlight(bool enabled) {
1085  if (_model)
1086  _model->drawBound(enabled);
1087 
1088  if (enabled)
1090  else
1091  hideTooltip();
1092 }
1093 
1094 bool Creature::click(Object *triggerer) {
1095  // Try the onDialog script first
1097  return runScript(kScriptDialogue, this, triggerer);
1098 
1099  // Next, look we have a generic onClick script
1100  if (hasScript(kScriptClick))
1101  return runScript(kScriptClick, this, triggerer);
1102 
1103  // Lastly, try to start a conversation directly
1104  return beginConversation(triggerer);
1105 }
1106 
1108  if (!_model)
1109  return false;
1110 
1111  if (!_tooltip) {
1112  _tooltip.reset(new Tooltip(type, *_model));
1113 
1114  _tooltip->setAlign(0.5f);
1115  _tooltip->setPortrait(_portrait);
1116  }
1117 
1118  return true;
1119 }
1120 
1121 void Creature::playAnimation(const Common::UString &animation, bool restart,
1122  float length, float speed) {
1123  if (!_model)
1124  return;
1125 
1126  if (animation.empty()) {
1127  _model->playDefaultAnimation();
1128  return;
1129  }
1130 
1131  _model->playAnimation(animation, restart, length, speed);
1132 }
1133 
1134 void Creature::playAnimation(Animation animation, bool restart, float length, float speed) {
1135  if (!_model)
1136  return;
1137 
1138  if (!isAnimationLooping(animation))
1139  length = 0.0f;
1140 
1141  Common::UString anim = getCreatureAnimationName(animation, false);
1142  if (_model->hasAnimation(anim))
1143  anim = getCreatureAnimationName(animation, true);
1144 
1145  warning("Creature::playAnimation(%d = \"%s\", %s, %f, %f)", (int) animation, anim.c_str(),
1146  restart ? "true" : "false", length, speed);
1147 
1148  playAnimation(anim, restart, length, speed);
1149 }
1150 
1151 void Creature::getPCListInfo(const Common::UString &bic, bool local,
1152  Common::UString &name, Common::UString &classes,
1153  Common::UString &portrait) {
1154 
1155 
1157 
1158  const Aurora::GFF3Struct &top = gff->getTopLevel();
1159 
1160  // Reading name
1161  const Common::UString firstName = top.getString("FirstName");
1162  const Common::UString lastName = top.getString("LastName");
1163 
1164  name = firstName + " " + lastName;
1165  name.trim();
1166 
1167  // Reading portrait (failure non-fatal)
1168  try {
1169  loadPortrait(top, portrait);
1170  } catch (...) {
1171  portrait.clear();
1172 
1173  Common::exceptionDispatcherWarning("Can't read portrait for PC \"%s\"", bic.c_str());
1174  }
1175 
1176  // Reading classes
1177  std::vector<Class> classLevels;
1178  uint8 hitDice;
1179 
1180  loadClasses(top, classLevels, hitDice);
1181  getClassString(classLevels, classes);
1182 
1183  classes = "(" + classes + ")";
1184 }
1185 
1187  const Common::UString pcDir = ConfigMan.getString(local ? "NWN_localPCDir" : "NWN_serverPCDir");
1188  const Common::UString pcFile = pcDir + "/" + bic + ".bic";
1189 
1190  return new Aurora::GFF3File(new Common::ReadFile(pcFile), kBICID);
1191 }
1192 
1193 void Creature::getClassString(const std::vector<Class> &classes, Common::UString &str) {
1194  for (std::vector<Class>::const_iterator c = classes.begin(); c != classes.end(); ++c) {
1195  if (!str.empty())
1196  str += '/';
1197 
1198  uint32 strRef = TwoDAReg.get2DA("classes").getRow(c->classID).getInt("Name");
1199 
1200  str += TalkMan.getString(strRef);
1201  }
1202 }
1203 
1204 } // End of namespace NWN
1205 
1206 } // End of namespace Engines
An inventory item in Neverwinter Nights.
void setPosition(float x, float y, float z)
Set the creature&#39;s position.
Definition: creature.cpp:162
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 destroyTooltip()
Destroy all tooltips on this object.
Definition: object.cpp:308
void setGender(Gender gender)
Set the creature&#39;s gender.
Definition: creature.cpp:194
Handling version V3.2/V3.3 of BioWare&#39;s GFFs (generic file format).
#define ResMan
Shortcut for accessing the sound manager.
Definition: resman.h:557
uint32 _colorHair
The color of the creature&#39;s hair.
Definition: creature.h:372
uint8 getHitDice() const
Returns the number of hit dice, which is effectively the total number of levels.
Definition: creature.cpp:1031
void setAbility(Ability ability, uint8 score)
Set the creature&#39;s ability score.
Definition: creature.cpp:1041
const Common::UString & getConvclass() const
Return the creature&#39;s class as needed in conversations, e.g.
Definition: creature.cpp:985
#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
Common::UString _partsSuperModelName
The supermodel used for parts-based creatures.
Definition: creature.h:367
virtual void getOrientation(float &x, float &y, float &z, float &angle) const
Return the object&#39;s orientation.
Definition: object.cpp:162
uint32 getArmorPart(size_t index) const
Definition: item.cpp:212
#define UINT16_MAX
Definition: types.h:228
bool hasScript(Script script) const
Definition: container.cpp:114
uint32 _colorCloth1
The 1. color of the creature&#39;s cloth armor.
Definition: creature.h:380
Packed layer texture.
Definition: types.h:63
#define TalkMan
Shortcut for accessing the talk manager.
Definition: talkman.h:111
uint32 getAge() const
Return the creature&#39;s age.
Definition: creature.cpp:234
bool beginConversation(Object *triggerer)
Begin a conversation between the triggerer and this object.
Definition: object.cpp:260
const Common::UString & getString(size_t column) const
Return the contents of a cell as a string.
Definition: 2dafile.cpp:59
void readScripts(const Aurora::GFF3Struct &gff)
Definition: container.cpp:123
bool getBool(const Common::UString &field, bool def=false) const
Definition: gff3file.cpp:510
uint32 _colorCloth2
The 2. color of the creature&#39;s cloth armor.
Definition: creature.h:381
const Common::UString & getEnvironmentMap() const
Return the area&#39;s environment map.
Definition: area.cpp:132
Creature * _master
The creature&#39;s master.
Definition: creature.h:383
void constructModelName(const Common::UString &type, uint32 id, const Common::UString &gender, const Common::UString &race, const Common::UString &phenoType, const Common::UString &phenoTypeAlt, Common::UString &model, Common::UString &texture)
Construct the resource name of a body part files.
Definition: creature.cpp:458
bool _isCommandable
Is the creature commandable (has a modifiable action queue)?
Definition: creature.h:387
A class holding an UTF-8 string.
Definition: ustring.h:48
bool isClickable() const
Can the player click the object?
Definition: object.cpp:120
void hide()
Hide the creature&#39;s model.
Definition: creature.cpp:153
Geometry, BioWare model.
Definition: types.h:73
#define TextureMan
Shortcut for accessing the texture manager.
Definition: textureman.h:127
void setSoundSet(uint32 soundSet)
Set the creature&#39;s sound set.
Definition: creature.cpp:1019
virtual void setOrientation(float x, float y, float z, float angle)
Set the object&#39;s orientation.
Definition: object.cpp:176
void reset(PointerType o=0)
Resets the pointer with the new value.
Definition: scopedptr.h:87
void setRace(uint32 race)
Set the creature&#39;s race.
Definition: creature.cpp:209
The global config manager.
Common::UString getCreatureAnimationName(Animation animation, bool simple)
Return the name (as found in the models) of a specific creature animation.
Definition: types.cpp:61
const Common::UString & getName() const
Return the object&#39;s name.
Definition: object.cpp:90
uint64_t uint64
Definition: types.h:206
uint8_t uint8
Definition: types.h:200
The Aurora texture manager.
virtual bool click(Object *triggerer=0)
The creature was clicked.
Definition: creature.cpp:1094
Common::PtrVector< Item > _equippedItems
The creature&#39;s equipped items.
Definition: creature.h:365
bool hasFeat(uint32 feat) const
Does the creature have this feat?
Definition: creature.cpp:1068
bool hasField(const Common::UString &field) const
Does this specific field exist?
Definition: gff3file.cpp:400
Common::UString _name
The object&#39;s display name.
Definition: object.h:165
Mathematical helpers.
static void loadPortrait(const Aurora::GFF3Struct &gff, Common::UString &portrait)
Load the creature&#39;s portrait.
Definition: creature.cpp:872
bool isArmor() const
Definition: item.cpp:200
uint32 _colorTattoo2
The 2. color of the creature&#39;s tattoo.
Definition: creature.h:374
bool equalsIgnoreCase(const UString &str) const
Definition: ustring.cpp:218
A simple streaming file reading class.
Definition: readfile.h:40
void load(const Aurora::GFF3Struct &creature)
Load from a creature instance.
Definition: creature.cpp:699
bool isPC() const
Is the creature a player character?
Definition: creature.cpp:226
uint8 domain2
Cleric&#39;s domain.
Definition: creature.h:291
void setColorTatto1(uint32 colorTattoo1)
Set the creature&#39;s color tattoo 1.
Definition: creature.cpp:356
void removeAssociate(Creature &ssociate)
Remove an associate (henchman, familiar, ...).
Definition: creature.cpp:388
uint32 _colorSkin
The color of the creature&#39;s skin.
Definition: creature.h:371
void setColorHair(uint32 colorHair)
Set the creature&#39;s color hair.
Definition: creature.cpp:352
uint64 getUint(const Common::UString &field, uint64 def=0) const
Definition: gff3file.cpp:436
std::vector< std::vector< uint16 > > knownList
Known spells list.
Definition: creature.h:295
uint8 getAbility(Ability ability) const
Return a creature&#39;s ability score.
Definition: creature.cpp:1035
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
Common::UString _subRace
The creature&#39;s subrace.
Definition: creature.h:332
An area in Neverwinter Nights, holding all objects and room tiles within, as well as general area pro...
Definition: area.h:63
uint8 getGoodEvil() const
Get the creature&#39;s good-evil alignment.
Definition: creature.cpp:1003
void setPhenotype(uint32 phenotype)
Set the creature&#39;s phenotype.
Definition: creature.cpp:344
void setLawChaos(uint8 lawfulness)
Set the creature&#39;s law-chaos alignment.
Definition: creature.cpp:1015
int16_t int16
Definition: types.h:201
uint32 getColor(Color color) const
Definition: item.cpp:206
static const uint32 kClassInvalid
Definition: types.h:279
static const char *const kBodyPartModels[]
Definition: creature.cpp:478
bool isFemale() const
Is the creature female, do we need female dialogs tokens?
Definition: creature.cpp:198
uint32 _colorMetal2
The 2. color of the creature&#39;s metal armor.
Definition: creature.h:377
A vector of pointer to objects, with automatic deletion.
Definition: ptrvector.h:44
void exceptionDispatcherWarning(const char *s,...)
Exception dispatcher that prints the exception as a warning, and adds another reason on top...
Definition: error.cpp:158
bool _isPC
Is the creature a PC?
Definition: creature.h:334
Class * findClass(uint32 classID)
Find the creature&#39;s class if any.
Definition: creature.cpp:563
uint32 getXP() const
Return the creature&#39;s XP.
Definition: creature.cpp:238
uint8 _goodEvil
The creature&#39;s good/evil value (0-100).
Definition: creature.h:355
static void getPCListInfo(const Common::UString &bic, bool local, Common::UString &name, Common::UString &classes, Common::UString &portrait)
Return the information needed for a character list.
Definition: creature.cpp:1151
The context holding a Neverwinter Nights area.
const char * c_str() const
Return the (utf8 encoded) string data.
Definition: ustring.cpp:249
std::list< uint32 > _ids
The object&#39;s model IDs.
Definition: object.h:178
const Common::UString & getSubRace() const
Get the creature&#39;s subrace.
Definition: creature.cpp:934
int8 getSkillRank(uint32 skill) const
Return the creature&#39;s rank in this skill.
Definition: creature.cpp:1047
virtual void getPosition(float &x, float &y, float &z) const
Return the object&#39;s position within its area.
Definition: object.cpp:156
static void loadClasses(const Aurora::GFF3Struct &gff, std::vector< Class > &classes, uint8 &hitDice)
Load the creature&#39;s classes.
Definition: creature.cpp:894
static UString format(const char *s,...) GCC_PRINTF(1
Print formatted data into an UString object, similar to sprintf().
Definition: ustring.cpp:718
static Aurora::GFF3File * openPC(const Common::UString &bic, bool local)
Definition: creature.cpp:1186
uint32 _lastChangedGUIDisplay
The time a GUI relevant property was changed last.
Definition: creature.h:324
void setColorSkin(uint32 colorSkin)
Set the creature&#39;s color skin.
Definition: creature.cpp:348
uint16_t uint16
Definition: types.h:202
#define ConfigMan
Shortcut for accessing the config manager.
Definition: configman.h:176
const Common::UString & getConvrace() const
Return the creature&#39;s lowercase race as needed in conversations, e.g.
Definition: creature.cpp:922
Common::UString _lastName
The creature&#39;s last name.
Definition: creature.h:327
Utility templates and functions.
Creature * getAssociate(AssociateType type, size_t nth=1) const
Get this creature&#39;s nth&#39;s associate of a specific type.
Definition: creature.cpp:400
bool isCommandable() const
Is this creature commandable (has a modifiable action queue)?
Definition: creature.cpp:428
uint32 _colorLeather2
The 2. color of the creature&#39;s leather armor.
Definition: creature.h:379
void setCommandable(bool commandable)
Set whether this creature commandable (has a modifiable action queue).
Definition: creature.cpp:432
void setSchool(uint32 classID, uint8 school)
Set the creature&#39;s school.
Definition: creature.cpp:296
double getDouble(const Common::UString &field, double def=0.0) const
Definition: gff3file.cpp:514
uint16 level
Levels of that class.
Definition: creature.h:288
Handling BioWare&#39;s 2DAs (two-dimensional array).
void setPortrait(const Common::UString &portrait)
Set the creature&#39;s portrait.
Definition: creature.cpp:216
const Common::UString & getDeity() const
Get the creature&#39;s deity.
Definition: creature.cpp:999
void setArea(Area *area)
Set the area this creature is currently in.
Definition: creature.cpp:372
uint8 school
Wizard&#39;s spell school.
Definition: creature.h:293
const Common::UString & getConvRace() const
Return the creature&#39;s race as needed in conversations, e.g.
Definition: creature.cpp:916
The global events manager.
Common::ScopedPtr< Tooltip > _tooltip
The tooltip displayed over the object.
Definition: object.h:189
uint32 classID
Index into classes.2da.
Definition: creature.h:287
std::vector< std::vector< uint16 > > memorizedList
Memorized spells list.
Definition: creature.h:296
A GFF (generic file format) V3.2/V3.3 file, found in all Aurora games except Sonic Chronicles: The Da...
Definition: gff3file.h:85
#define UINT8_MAX
Definition: types.h:225
uint32 _phenotype
The creature&#39;s phenotype.
Definition: creature.h:359
A node within a 3D model.
uint32 _age
The creature&#39;s age.
Definition: creature.h:337
std::vector< Class > _classes
The creature&#39;s classes.
Definition: creature.h:347
int32 _currentHP
The creature&#39;s current health points.
Definition: creature.h:343
bool createTooltip(Tooltip::Type type)
Create an empty tooltip.
Definition: creature.cpp:1107
A 3D model of an object.
void setFeat(uint32 feat)
Append a feat to the creature.
Definition: creature.cpp:1061
virtual void setPosition(float x, float y, float z)
Set the object&#39;s position within its area.
Definition: object.cpp:170
void setDomains(uint32 classID, uint8 domain1, uint8 domain2)
Set clerical domains.
Definition: creature.cpp:270
Common::UString _description
The object&#39;s description.
Definition: object.h:166
uint16 getClassLevel(uint32 classID) const
Get the creature&#39;s level for this class.
Definition: creature.cpp:949
Area * _area
The area the object is currently in.
Definition: object.h:182
bool showFeedbackTooltip()
Create and show a tooltip with the name and/or portrait of the object.
Definition: object.cpp:314
bool empty() const
Is the string empty?
Definition: ustring.cpp:245
void setLayerColor(Layer layer, uint8 color)
Set the color of one layer within this layer texture.
Definition: pltfile.cpp:91
#define TwoDAReg
Shortcut for accessing the 2da registry.
Definition: 2dareg.h:101
std::vector< uint32 > _feats
The creature&#39;s feats.
Definition: creature.h:349
void setHead(uint32 headID)
Set the creature&#39;s head.
Definition: creature.cpp:364
Creature()
Create a dummy creature instance.
Definition: creature.cpp:70
uint32 _appearanceID
The creature&#39;s general appearance.
Definition: creature.h:358
uint8 _abilities[kAbilityMAX]
The creature&#39;s abilities.
Definition: creature.h:345
The global 2DA registry.
int32 getMaxHP() const
Return the max HP this creature can have.
Definition: creature.cpp:246
const Common::UString & getFirstName() const
Return the creature&#39;s first name.
Definition: creature.cpp:182
virtual void setArea(Area *)
Set the area this object is currently in.
Definition: object.cpp:140
Common::ScopedPtr< Graphics::Aurora::Model > _model
The creature&#39;s model.
Definition: creature.h:389
void init()
Init the creature.
Definition: creature.cpp:96
void warning(const char *s,...)
Definition: util.cpp:33
void changeClassLevel(uint32 classID, int16 levelChange)
Set the creature&#39;s level for this class.
Definition: creature.cpp:957
bool hasSpell(uint32 classID, size_t spellLevel, uint16 spell)
Do the creature know the spell?
Definition: creature.cpp:279
Common::UString _firstName
The creature&#39;s first name.
Definition: creature.h:326
int32 getInt(size_t column) const
Return the contents of a cell as an int.
Definition: 2dafile.cpp:75
Associate(AssociateType t=kAssociateTypeNone, Creature *a=0)
Definition: creature.cpp:63
static const char *const kBodyPartNodes[]
Definition: creature.cpp:494
const Common::UString & getConvRaces() const
Return the creature&#39;s race plural as needed in conversations, e.g.
Definition: creature.cpp:928
std::vector< const GFF3Struct * > GFF3List
Definition: types.h:449
#define EventMan
Shortcut for accessing the events manager.
Definition: events.h:210
uint8 _hitDice
The creature&#39;s hit dice.
Definition: creature.h:351
std::list< Associate > _associates
The creature&#39;s associates.
Definition: creature.h:384
uint8 _startingPackage
The package chosen at creature&#39;s creation.
Definition: creature.h:361
static const uint32 kRaceInvalid
Definition: types.h:278
const Common::UString & getLastName() const
Return the creature&#39;s last name.
Definition: creature.cpp:186
Implementing the stream reading interfaces for files.
void setKnownSpell(uint32 classID, size_t spellLevel, uint16 spell)
Set a creature&#39;s known spell.
Definition: creature.cpp:304
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:938
uint8 _lawChaos
The creature&#39;s law/chaos value (0-100).
Definition: creature.h:356
uint32 _xp
The creature&#39;s experience.
Definition: creature.h:339
Common::UString _portrait
The object&#39;s portrait.
Definition: object.h:168
uint8 domain1
Cleric&#39;s domain.
Definition: creature.h:290
A tooltip.
Definition: tooltip.h:50
void getArmorModels()
Populate the armor info for body parts.
Definition: creature.cpp:538
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
const GFF3List & getList(const Common::UString &field) const
Definition: gff3file.cpp:741
Common::UString getClassString() const
Return the creature&#39;s class description.
Definition: creature.cpp:1023
uint32 _soundSet
The object&#39;s sound set, as an index into soundset.2da.
Definition: object.h:172
uint32 getRace() const
Return the creature&#39;s race value.
Definition: creature.cpp:205
const TwoDARow & getRow(size_t row) const
Get a row.
Definition: 2dafile.cpp:421
bool isAnimationLooping(Animation animation)
Return true if the specified animation allows looping.
Definition: types.cpp:166
uint32 _colorLeather1
The 1. color of the creature&#39;s leather armor.
Definition: creature.h:378
int8_t int8
Definition: types.h:199
uint8 getLawChaos() const
Get the creature&#39;s law-chaos alignment.
Definition: creature.cpp:1011
void loadEquippedItems(const Aurora::GFF3Struct &gff)
Definition: creature.cpp:885
int32 _baseHP
The creature&#39;s base maximum health points.
Definition: creature.h:341
A struct within a GFF3.
Definition: gff3file.h:164
void loadCharacter(const Common::UString &bic, bool local)
Load from a character file.
Definition: creature.cpp:683
void setGoodEvil(uint8 goodness)
Set the creature&#39;s good-evil alignment.
Definition: creature.cpp:1007
void addAssociate(Creature &associate, AssociateType type)
Add an associate (henchman, familiar, ...).
Definition: creature.cpp:379
uint32_t uint32
Definition: types.h:204
uint8 getStartingPackage() const
Return the creature&#39;s starting package.
Definition: creature.cpp:250
uint32 _colorTattoo1
The 1. color of the creature&#39;s tattoo.
Definition: creature.h:373
int32 getCurrentHP() const
Return the current HP this creature has.
Definition: creature.cpp:242
Gender _gender
The creature&#39;s gender.
Definition: creature.h:329
Gender getGender() const
Get the creature&#39;s gender.
Definition: creature.cpp:190
virtual void highlight(bool enabled)
(Un)Highlight the creature.
Definition: creature.cpp:1084
void setOrientation(float x, float y, float z, float angle)
Set the creature&#39;s orientation.
Definition: creature.cpp:170
The global talk manager for Aurora strings.
A creature in a Neverwinter Nights area.
Common::UString _tag
Definition: object.h:56
const Common::UString & getPortrait() const
Get the creature&#39;s portrait.
Definition: creature.cpp:222
static const uint32 kFieldIDInvalid
Definition: types.h:443
void unloadModel()
Unload the creature&#39;s model.
Definition: creature.cpp:675
void loadProperties(const Aurora::GFF3Struct &gff)
Load general creature properties.
Definition: creature.cpp:747
FileType
Various file types used by the Aurora engine and found in archives.
Definition: types.h:56
void status(const char *s,...)
Definition: util.cpp:52
void leave()
The cursor left the creature.
Definition: creature.cpp:1080
#define UINT32_MAX
Definition: types.h:231
Common::UString getString(const Common::UString &field, const Common::UString &def="") const
Definition: gff3file.cpp:527
static float rad2deg(float rad)
Definition: maths.h:93
void show()
Show the creature&#39;s model.
Definition: creature.cpp:148
Generic Aurora engines utility functions.
Common::UString _deity
The creature&#39;s deity.
Definition: creature.h:353
uint32 lastChangedGUIDisplay() const
Last time info was changed that&#39;s displayed in the GUI.
Definition: creature.cpp:178
Creature * getMaster() const
Return the creature&#39;s master.
Definition: creature.cpp:424
Common::UString _environmentMap
The environment map override to use on the model.
Definition: creature.h:369
void loadModel()
Load the creature&#39;s model.
Definition: creature.cpp:595
void playAnimation(const Common::UString &animation="", bool restart=true, float length=0.0f, float speed=1.0f)
Play a creature animation.
Definition: creature.cpp:1121
std::vector< int8 > _skills
The creature&#39;s skills.
Definition: creature.h:348
void setColorTatto2(uint32 colorTattoo2)
Set the creature&#39;s color tatto 2.
Definition: creature.cpp:360
bool isDM() const
Is the creature a dungeon master?
Definition: creature.cpp:230
Graphics::Aurora::Model * loadModelObject(const Common::UString &resref, const Common::UString &texture)
Definition: model.cpp:47
void setMemorizedSpell(uint32 classID, size_t spellLevel, uint16 spell)
Set a creature&#39;s memorized spell.
Definition: creature.cpp:322
A row within a 2DA file.
Definition: 2dafile.h:61
void setStartingPackage(uint8 package)
Set the creature&#39;s starting package.
Definition: creature.cpp:254
void setMaster(Creature *master=0)
Set the creature&#39;s master.
Definition: creature.cpp:420
void NORETURN_PRE error(const char *s,...)
Definition: util.cpp:86
void setAppearance(uint32 appearanceID)
Set the creature&#39;s appearance.
Definition: creature.cpp:340
A handle to a texture.
Definition: texturehandle.h:51
void getDomains(uint32 classID, uint8 &domain1, uint8 &domain2)
Get clerical domains.
Definition: creature.cpp:258
void constructPartName(const Common::UString &type, uint32 id, const Common::UString &gender, const Common::UString &race, const Common::UString &phenoType, Common::UString &part)
Construct the resource name of a body part files.
Definition: creature.cpp:436
void addEquippedItem(Item *item)
Add an equippement to the creature.
Definition: creature.cpp:368
Common::UString _conversation
The object&#39;s default conversation.
Definition: object.h:170
void clear()
Clear the string&#39;s contents.
Definition: ustring.cpp:236
void getPartModels()
Construct all body part models&#39; resource names.
Definition: creature.cpp:509
static const char *const kBodyPartFields[]
Definition: creature.cpp:732
Creature template (user), GFF.
Definition: types.h:93
bool runScript(Script script, const Aurora::NWScript::ObjectReference owner=Aurora::NWScript::ObjectReference(), const Aurora::NWScript::ObjectReference triggerer=Aurora::NWScript::ObjectReference())
Definition: container.cpp:139
uint32 _race
The creature&#39;s race.
Definition: creature.h:330
void enter()
The cursor entered the creature.
Definition: creature.cpp:1076
const Common::UString & getConvClasses() const
Return the creature&#39;s class plural as needed in conversations, e.g.
Definition: creature.cpp:992
void rebuild()
Rebuild the combined texture image.
Definition: pltfile.cpp:97
bool _isDM
Is the creature a DM?
Definition: creature.h:335
int32 _bonusHP
The creature&#39;s bonus health points.
Definition: creature.h:342
BioWare&#39;s Packed Layered Texture.
void hideTooltip()
Hide the tooltip again.
Definition: object.cpp:337
The global resource manager for Aurora resources.
void finishPLTs(const std::list< Graphics::Aurora::TextureHandle > &plts)
Finished those paletted textures.
Definition: creature.cpp:574
const Common::UString & getConvClass() const
Return the creature&#39;s class as needed in conversations, e.g.
Definition: creature.cpp:978
void setSkillRank(size_t skill, uint8 rank)
Set the creature&#39;s skill rank.
Definition: creature.cpp:1054
std::vector< BodyPart > _bodyParts
The creature&#39;s body parts.
Definition: creature.h:363
unsigned int uint
Definition: types.h:211
uint32 _colorMetal1
The 1. color of the creature&#39;s metal armor.
Definition: creature.h:376
static const uint32 kBICID
Definition: creature.cpp:53
int32_t int32
Definition: types.h:203
Generic Aurora engines model functions.