xoreos  0.0.5
chargenchoices.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 
27 #include "src/aurora/2dareg.h"
28 #include "src/aurora/2dafile.h"
29 #include "src/aurora/gff3file.h"
30 #include "src/aurora/talkman.h"
31 
33 #include "src/engines/nwn/item.h"
34 #include "src/engines/nwn/module.h"
35 
37 
38 namespace Engines {
39 
40 namespace NWN {
41 
42 FeatItem::FeatItem() : featId(Aurora::kFieldIDInvalid), list(0), isMasterFeat(false),
43  masterFeat(Aurora::kFieldIDInvalid) {
44 }
45 
46 CharGenChoices::CharGenChoices() : _characterUsed(false) {
47  _creature = new Creature();
48 
49  init();
50 }
51 
53  if (!_characterUsed)
54  delete _creature;
55 }
56 
58  _classId = 0;
59 
60  _goodness = 101;
61  _lawfulness = 101;
62 
63  _soundSet = 0;
64  _notUsedSkills = 0;
65 
66  _abilities.assign(6, 8);
67  _racialAbilities.assign(6, 0);
68 
69  resetPackage();
70 }
71 
73  // Rise level
75 
76  // Set Alignment
79 
80  // Set Abilities
81  size_t ab = 0;
82  for (; ab < 6; ++ab) {
83  Ability ability = static_cast<Ability>(ab);
84  _creature->setAbility(ability, _abilities[ab] + _racialAbilities[ab]);
85  }
86 
87  // Set skills
88  size_t skillID = 0;
89  for (std::vector<uint8>::iterator s = _skills.begin(); s != _skills.end(); ++s, ++skillID)
90  _creature->setSkillRank(skillID, *s);
91 
92  // Set feats
93  for (std::vector<uint32>::iterator f = _classFeats.begin(); f != _classFeats.end(); ++f)
94  _creature->setFeat(*f);
95 
96  for (std::vector<uint32>::iterator f = _racialFeats.begin(); f != _racialFeats.end(); ++f)
97  _creature->setFeat(*f);
98 
99  for (std::vector<uint32>::iterator f = _normalFeats.begin(); f != _normalFeats.end(); ++f)
100  _creature->setFeat(*f);
101 
102  // Set domains if any.
103  if (_domain1 != UINT8_MAX && _domain2 != UINT8_MAX)
105 
106  // Set spells if any.
107  if (!_spells.empty()) {
108  for (size_t lvl = 0; lvl < _spells.size(); ++lvl) {
109  for (size_t s = 0; s < _spells[lvl].size(); ++s)
110  _creature->setKnownSpell(_classId, lvl, _spells[lvl][s]);
111  }
112 
113  if (_spellSchool != UINT8_MAX)
115  }
116 
117  // Set sound set.
119 
120  // Set appearance.
121  // TODO: Apply choices from user and not default values.
123  Aurora::GFF3File gff("NW_CLOTH001", Aurora::kFileTypeUTI);
124  Item *armor = new Item(gff.getTopLevel());
125  _creature->addEquippedItem(armor);
126 
132  _creature->setHead(1);
133 }
134 
136  delete _creature;
137  _creature = new Creature();
138 
139  init();
140 
141  _racialFeats.clear();
142  _classFeats.clear();
143 
144  resetPackage();
145 }
146 
149 
150  _skills.assign(28, 0);
151 
152  _normalFeats.clear();
153 
154  _spells.clear();
156 
159 }
160 
162  return *_creature;
163 }
164 
166  _creature->setGender(gender);
167 }
168 
170  if (race == kRaceInvalid) {
171  warning("Setting invalid race: %d", race);
172  return;
173  }
174 
175  _creature->setRace(race);
176 
177  _racialFeats.clear();
178 
179  const Aurora::TwoDAFile &twodaRace = TwoDAReg.get2DA("racialtypes");
180  const Aurora::TwoDAFile &twodaFeatRace = TwoDAReg.get2DA(
181  twodaRace.getRow(race).getString("FeatsTable"));
182 
183  for (size_t it = 0; it < twodaFeatRace.getRowCount(); ++it) {
184  const Aurora::TwoDARow &rowFeatRace = twodaFeatRace.getRow(it);
185  _racialFeats.push_back(rowFeatRace.getInt("FeatIndex"));
186  }
187 }
188 
190  _creature->setPortrait(portrait);
191 }
192 
194  _classId = classId;
195 
196  // Add granted class feats.
197  _classFeats.clear();
198  const Aurora::TwoDAFile &twodaClasses = TwoDAReg.get2DA("classes");
199  const Aurora::TwoDAFile &twodaClsFeat = TwoDAReg.get2DA(twodaClasses.getRow(classId).getString("FeatsTable"));
200  for (size_t it = 0; it < twodaClsFeat.getRowCount(); ++it) {
201  const Aurora::TwoDARow &rowFeat = twodaClsFeat.getRow(it);
202  if (rowFeat.getInt("List") != 3)
203  continue;
204 
205  if (rowFeat.getInt("GrantedOnLevel") != _creature->getHitDice() + 1)
206  continue;
207 
208  if (!hasFeat(rowFeat.getInt("FeatIndex")))
209  _classFeats.push_back(rowFeat.getInt("FeatIndex"));
210  }
211 }
212 
213 void CharGenChoices::setAlign(uint8 goodness, uint8 lawfulness) {
214  _goodness = goodness;
215  _lawfulness = lawfulness;
216 }
217 
218 void CharGenChoices::setAbilities(std::vector<uint8> abilities,
219  std::vector<uint8> racialAbilities) {
220 
221  _abilities = abilities;
222  _racialAbilities = racialAbilities;
223 
224  // Exchange intelligence and wisdom to be consistent with kAbility.
225  _abilities[4] = abilities[3];
226  _abilities[3] = abilities[4];
227 }
228 
230  _package = package;
231 
232  if (_package == UINT8_MAX)
233  return;
234 
235  // Set package
237 
238  if (_package != UINT8_MAX) {
239  // Set Skills
241 
242  // Set Feats
243  std::vector<uint32> packFeats;
244  getPrefFeats(packFeats);
245  std::list<FeatItem> availFeats;
246  uint8 normalFeats, bonusFeats;
247  getFeatItems(availFeats, normalFeats, bonusFeats);
248  while (normalFeats + bonusFeats != 0) {
249  for (std::vector<uint32>::iterator pF = packFeats.begin(); pF != packFeats.end(); ++pF) {
250  if (normalFeats + bonusFeats == 0)
251  break;
252  for (std::list<FeatItem>::iterator aF = availFeats.begin(); aF != availFeats.end(); ++aF) {
253  if (*pF != (*aF).featId)
254  continue;
255 
256  // For bonus feats and bonus feats that can be chosen as a general feat.
257  if (bonusFeats > 0 && (*aF).list > 0) {
258  --bonusFeats;
259  _normalFeats.push_back(*pF);
260  }
261 
262  // For general feat and bonus feats that can be chosen as a general feat.
263  if ((normalFeats > 0 && (*aF).list == 0) ||
264  (normalFeats > 0 && (*aF).list < 2 && bonusFeats == 0)) {
265  --normalFeats;
266  _normalFeats.push_back(*pF);
267  }
268 
269  break;
270  }
271  }
272  }
273 
274  // For spell casters
275  const Aurora::TwoDAFile &twodaClasses = TwoDAReg.get2DA("classes");
276  const Aurora::TwoDARow &rowClass = twodaClasses.getRow(_classId);
277  if (rowClass.getInt("SpellCaster") > 0) {
278  if (rowClass.getString("SpellGainTable") == "CLS_SPGN_WIZ" &&
279  _creature->getHitDice() == 0) {
280  // Set school
282 
283  // Set spells
285 
286  } else if (rowClass.getString("SpellGainTable") == "CLS_SPGN_CLER" &&
287  _creature->getHitDice() == 0) {
288  // Set domains.
290  } else if (!rowClass.empty("SpellKnownTable")) {
291  // Set spells
293  }
294  }
295  }
296 }
297 
298 void CharGenChoices::setSkill(size_t skillIndex, uint8 rank) {
299  _skills[skillIndex] = rank;
300 }
301 
303  _notUsedSkills = notUsedSkills;
304 }
305 
307  _normalFeats.push_back(feat);
308 }
309 
311  _spellSchool = spellSchool;
312 }
313 
314 void CharGenChoices::setDomains(uint8 domain1, uint8 domain2) {
315  _domain1 = domain1;
316  _domain2 = domain2;
317 }
318 
319 void CharGenChoices::setSpell(size_t spellLevel, uint16 spell) {
320  if (_spells.size() < spellLevel + 1)
321  _spells.resize(spellLevel + 1);
322 
323  _spells[spellLevel].push_back(spell);
324 }
325 
327  _soundSet = soundSetID;
328 }
329 
331  module->usePC(_creature);
332  _characterUsed = true;
333 }
334 
335 bool CharGenChoices::hasFeat(uint32 featId) const {
336  for (std::vector<uint32>::const_iterator f = _normalFeats.begin(); f != _normalFeats.end(); ++f)
337  if (*f == featId)
338  return true;
339 
340  for (std::vector<uint32>::const_iterator f = _racialFeats.begin(); f != _racialFeats.end(); ++f)
341  if (*f == featId)
342  return true;
343 
344  for (std::vector<uint32>::const_iterator f = _classFeats.begin(); f != _classFeats.end(); ++f)
345  if (*f == featId)
346  return true;
347 
348  return _creature->hasFeat(featId);
349 }
350 
351 bool CharGenChoices::hasPrereqFeat(uint32 featId, bool isClassFeat) {
352  const Aurora::TwoDAFile &twodaFeats = TwoDAReg.get2DA("feat");
353  const Aurora::TwoDARow &row = twodaFeats.getRow(featId);
354 
355  // Some feats have been removed. Check if it's the case.
356  if (row.empty("FEAT"))
357  return false;
358 
359  if (!row.getInt("ALLCLASSESCANUSE") && !isClassFeat)
360  return false;
361 
362  // Check abilities.
363  if ((uint32) row.getInt("MINSTR") > getAbility(kAbilityStrength))
364  return false;
365  if ((uint32) row.getInt("MINDEX") > getAbility(kAbilityDexterity))
366  return false;
367  if ((uint32) row.getInt("MININT") > getAbility(kAbilityIntelligence))
368  return false;
369  if ((uint32) row.getInt("MINWIS") > getAbility(kAbilityWisdom))
370  return false;
371  if ((uint32) row.getInt("MINCHA") > getAbility(kAbilityCharisma))
372  return false;
373  if ((uint32) row.getInt("MINCON") > getAbility(kAbilityConstitution))
374  return false;
375 
376  // Check if the character has the prerequisite feats.
377  if (!row.empty("PREREQFEAT1") && !hasFeat(row.getInt("PREREQFEAT1")))
378  return false;
379  if (!row.empty("PREREQFEAT2") && !hasFeat(row.getInt("PREREQFEAT2")))
380  return false;
381 
382  if (!row.empty("OrReqFeat0")) {
383  bool OrReqFeat = hasFeat(row.getInt("OrReqFeat0"));
384  if (!row.empty("OrReqFeat1")) {
385  OrReqFeat = OrReqFeat || hasFeat(row.getInt("OrReqFeat1"));
386  if (!row.empty("OrReqFeat2")) {
387  OrReqFeat = OrReqFeat || hasFeat(row.getInt("OrReqFeat2"));
388  if (!row.empty("OrReqFeat3")) {
389  OrReqFeat = OrReqFeat || hasFeat(row.getInt("OrReqFeat3"));
390  if (!row.empty("OrReqFeat4"))
391  OrReqFeat = OrReqFeat || hasFeat(row.getInt("OrReqFeat4"));
392  }
393  }
394  }
395 
396  if (!OrReqFeat)
397  return false;
398  }
399 
400  // TODO Check base bonus attack
401  if (row.getInt("PreReqEpic") > 0 && _creature->getHitDice() < 21)
402  return false;
403 
404  // Check minimun level.
405  if ((_creature->getClassLevel(row.getInt("MinLevelClass")) < row.getInt("MinLevel")) && !row.empty("MinLevel"))
406  return false;
407 
408  // Check maximum level.
409  if ((_creature->getHitDice() >= row.getInt("MaxLevel")) && !row.empty("MaxLevel"))
410  return false;
411 
412  // Check skill rank.
413  if (!row.empty("REQSKILL")) {
414  if (_skills[row.getInt("REQSKILL")] == 0)
415  return false;
416  if ((row.getInt("ReqSkillMinRanks") > _skills[row.getInt("REQSKILL")]) && !row.empty("ReqSkillMinRanks"))
417  return false;
418  }
419  if (!row.empty("REQSKILL2")) {
420  if (_skills[row.getInt("REQSKILL2")] == 0)
421  return false;
422  if ((row.getInt("ReqSkillMinRanks2") > _skills[row.getInt("REQSKILL2")]) && !row.empty("ReqSkillMinRanks2"))
423  return false;
424  }
425 
426  // Check if the character already has the feat.
427  if (hasFeat(featId)) {
428  if (!row.getInt("GAINMULTIPLE"))
429  return false;
430  }
431 
432  // TODO Check spell level
433  // TODO Check saving throw
434  return true;
435 }
436 
438  return _classId;
439 }
440 
442  return _creature->getRace();
443 }
444 
445 bool CharGenChoices::getAlign(uint8 &goodness, uint8 &lawfulness) const {
446  // Check if alignment has been previously set.
447  if (_goodness > 100)
448  return false;
449 
450  goodness = _goodness;
451  lawfulness = _lawfulness;
452  return true;
453 }
454 
456  return _abilities[ability];
457 }
458 
460  return _abilities[ability] + _racialAbilities[ability];
461 }
462 
464  uint8 totalAbility = getTotalAbility(ability);
465  int8 modifier = (totalAbility - totalAbility % 2) / 2;
466  modifier -= 5;
467  return modifier;
468 }
469 
471  return _package;
472 }
473 
475  return _spellSchool;
476 }
477 
478 void CharGenChoices::getFeats(std::vector<uint32> &feats) {
479  feats = _racialFeats;
480  feats.insert(feats.end(), _classFeats.begin(), _classFeats.end());
481 }
482 
484  const Aurora::TwoDAFile &twodaPackage = TwoDAReg.get2DA("packages");
485  const Aurora::TwoDARow &row = twodaPackage.getRow(_package == UINT8_MAX ? _classId : _package);
486 
487  if (row.empty("School"))
488  return UINT8_MAX;
489 
490  return static_cast<uint8>(row.getInt("School"));
491 }
492 
493 void CharGenChoices::getPrefFeats(std::vector<uint32> &feats) {
494  const Aurora::TwoDAFile &twodaPackage = TwoDAReg.get2DA("packages");
495  const Aurora::TwoDARow &rowPck = twodaPackage.getRow(_package == UINT8_MAX ? _classId : _package);
496  const Aurora::TwoDAFile &twodaPckFeats = TwoDAReg.get2DA(rowPck.getString("FeatPref2DA"));
497 
498  feats.clear();
499  size_t rowIdx = 0;
500  while (rowIdx < twodaPckFeats.getRowCount()) {
501  const Aurora::TwoDARow &rowFeat = twodaPckFeats.getRow(rowIdx);
502  ++rowIdx;
503  uint32 featID = rowFeat.getInt("FEATINDEX");
504  if (hasFeat(featID))
505  continue;
506 
507  if (!hasPrereqFeat(featID, true))
508  continue;
509 
510  feats.push_back(featID);
511  }
512 }
513 
514 void CharGenChoices::getPrefSkills(std::vector<uint8> &skills) {
515  const Aurora::TwoDAFile &twodaPackage = TwoDAReg.get2DA("packages");
516  const Aurora::TwoDARow &rowPck = twodaPackage.getRow(_package == UINT8_MAX ? _classId : _package);
517  const Aurora::TwoDAFile &twodaPckSkills = TwoDAReg.get2DA(rowPck.getString("SkillPref2DA"));
518 
519  skills.clear();
520  for (size_t r = 0; r < twodaPckSkills.getRowCount(); ++r)
521  skills.push_back((uint8) twodaPckSkills.getRow(r).getInt("SKILLINDEX"));
522 }
523 
524 void CharGenChoices::getPrefDomains(uint8 &domain1, uint8 &domain2) {
525  const Aurora::TwoDAFile &twodaPackage = TwoDAReg.get2DA("packages");
526  const Aurora::TwoDARow &rowPck = twodaPackage.getRow(_package == UINT8_MAX ? _classId : _package);
527 
528  domain1 = (uint8) rowPck.getInt("Domain1");
529  domain2 = (uint8) rowPck.getInt("Domain2");
530 }
531 
532 void CharGenChoices::getPrefSpells(std::vector<std::vector<uint16> > &spells) {
533  const Aurora::TwoDAFile &twodaSpells = TwoDAReg.get2DA("spells");
534  const Aurora::TwoDAFile &twodaPackage = TwoDAReg.get2DA("packages");
535  const Aurora::TwoDARow &rowPck = twodaPackage.getRow(_package == UINT8_MAX ? _classId : _package);
536  const Aurora::TwoDAFile &twodaPckSpells = TwoDAReg.get2DA(rowPck.getString("SpellPref2DA"));
537 
538  std::map<uint32, Common::UString> spellCasterClass;
539  spellCasterClass[1] = "Bard";
540  spellCasterClass[2] = "Cleric";
541  spellCasterClass[3] = "Druid";
542  spellCasterClass[6] = "Paladin";
543  spellCasterClass[7] = "Ranger";
544  spellCasterClass[9] = "Wiz_Sorc";
545  spellCasterClass[10] = "Wiz_Sorc";
546 
547  spells.clear();
548  for (size_t r = 0; r < twodaPckSpells.getRowCount(); ++r) {
549  uint16 spellIndex = twodaPckSpells.getRow(r).getInt("SpellIndex");
550  const Aurora::TwoDARow &rowSpell = twodaSpells.getRow(spellIndex);
551 
552  size_t spellLevel = rowSpell.getInt(spellCasterClass[_classId]);
553  if (spells.size() < spellLevel + 1)
554  spells.resize(spellLevel + 1);
555 
556  spells[spellLevel].push_back(spellIndex);
557  }
558 }
559 
562  if (availRank < 0)
563  availRank = 0;
564 
565  const Aurora::TwoDAFile &twodaPackage = TwoDAReg.get2DA("classes");
566  const Aurora::TwoDARow &rowClass = twodaPackage.getRow(_classId);
567  availRank += (int8) rowClass.getInt("SkillPointBase");
568 
569  // If human (have Quick to master feat), add an extra point.
570  if (hasFeat(258))
571  ++availRank;
572 
573  if (_creature->getHitDice() == 0)
574  availRank *= 4;
575 
576  return (uint8) availRank;
577 }
578 
579 void CharGenChoices::getSkillItems(std::vector<SkillItem> &skills) {
580  skills.clear();
581 
582  const Aurora::TwoDAFile &twodaClasses = TwoDAReg.get2DA("classes");
583  const Aurora::TwoDAFile &twodaSkills = TwoDAReg.get2DA("skills");
584  const Aurora::TwoDARow &rowClasses = twodaClasses.getRow(_classId);
585  const Common::UString skillsClassFile = rowClasses.getString("SkillsTable");
586  const Aurora::TwoDAFile &twoDaSkillsClass = TwoDAReg.get2DA(skillsClassFile);
587 
588  for (size_t s = 0; s < twoDaSkillsClass.getRowCount(); ++s) {
589  const Aurora::TwoDARow &skillsClassRow = twoDaSkillsClass.getRow(s);
590  size_t skillIndex = skillsClassRow.getInt("SkillIndex");
591  const Aurora::TwoDARow &skillRow = twodaSkills.getRow(skillIndex);
592 
593  Common::UString skillName = TalkMan.getString(skillRow.getInt("Name"));
594  Common::UString icon = skillRow.getString("Icon");
595  Common::UString helpText = TalkMan.getString(skillRow.getInt("Description"));
596 
597  bool classSkill = skillsClassRow.getInt("ClassSkill") != 0;
598 
599  uint8 maxRank = 4 + _creature->getHitDice();
600 
601  if (classSkill) {
602  // Add information about wether it is a skill class.
603  skillName += " " + TalkMan.getString(52951);
604  } else {
605  maxRank = (maxRank - maxRank % 2) / 2;
606  }
607 
608  SkillItem skill;
609  skill.rank = 0;
610  skill.maxRank = maxRank;
611  skill.minRank = 0;
612  skill.skillID = skillIndex;
613  skill.isClassSkill = classSkill;
614  skill.name = skillName;
615  skill.icon = icon;
616  skill.help = helpText;
617 
618  skills.push_back(skill);
619  }
620 }
621 
622 void CharGenChoices::getFeatItems(std::list<FeatItem> &feats, uint8 &normalFeats, uint8 &bonusFeats) {
623  uint8 level = _creature->getHitDice();
624  normalFeats = 0;
625  bonusFeats = 0;
626 
627  // Get an additional feat each new level multiple of 3.
628  if ((level + 1) % 3)
629  ++normalFeats;
630  // Get an additional feat at level 1.
631  if (level == 0)
632  ++normalFeats;
633 
634  // Bonus feat
635  const Aurora::TwoDAFile &twodaClass = TwoDAReg.get2DA("classes");
636  if (twodaClass.headerToColumn("BonusFeatsTable") != Aurora::kFieldIDInvalid) {
637  const Aurora::TwoDAFile &twodaBonusFeats =
638  TwoDAReg.get2DA(twodaClass.getRow(_classId).getString("BonusFeatsTable"));
639 
640  bonusFeats = twodaBonusFeats.getRow(_creature->getHitDice()).getInt("Bonus");
641  } else {
642  // The number of bonus feats is hardcoded before HotU.
643  // TODO: Hardcoded bonus feats.
644  }
645 
646  // Build list from all possible feats.
647  const Aurora::TwoDAFile &twodaFeats = TwoDAReg.get2DA("feat");
648 
649  feats.clear();
650  for (size_t it = 0; it < twodaFeats.getRowCount(); ++it) {
651  if (!hasPrereqFeat(it, false))
652  continue;
653 
654  const Aurora::TwoDARow &featRow = twodaFeats.getRow(it);
655 
656  FeatItem feat;
657  feat.featId = it;
658  feat.name = TalkMan.getString(featRow.getInt("FEAT"));
659  feat.icon = featRow.getString("ICON");
660  feat.description = TalkMan.getString(featRow.getInt("DESCRIPTION"));
661  feat.masterFeat = 0xFFFFFFFF;
662  feat.isMasterFeat = false;
663 
664  // Check is the feat belongs to a masterfeat.
665  if (!featRow.empty("MASTERFEAT"))
666  feat.masterFeat = featRow.getInt("MASTERFEAT");
667 
668  feats.push_back(feat);
669  }
670 
671  // Add class feats.
672  const Aurora::TwoDAFile &twodaClsFeat = TwoDAReg.get2DA(twodaClass.getRow(_classId).getString("FeatsTable"));
673  for (size_t it = 0; it < twodaClsFeat.getRowCount(); ++it) {
674  const Aurora::TwoDARow &clsFeatRow = twodaClsFeat.getRow(it);
675 
676  int32 list = clsFeatRow.getInt("List");
677  // Check if it is automatically granted.
678  if (list == 3)
679  continue;
680 
681  if (!hasPrereqFeat(clsFeatRow.getInt("FeatIndex"), true))
682  continue;
683 
684  // When list=1, the feat can be both in the general and bonus feat list.
685  uint32 id = clsFeatRow.getInt("FeatIndex");
686  if (list == 1) {
687  for (std::list<FeatItem>::iterator f = feats.begin(); f != feats.end(); ++f) {
688  if (id != (*f).featId)
689  continue;
690 
691  (*f).list = 1;
692  break;
693  }
694  continue;
695  }
696 
697  const Aurora::TwoDARow &featRow = twodaFeats.getRow(id);
698  FeatItem feat;
699  feat.featId = id;
700  feat.name = TalkMan.getString(featRow.getInt("FEAT"));
701  feat.icon = featRow.getString("ICON");
702  feat.description = TalkMan.getString(featRow.getInt("DESCRIPTION"));
703  feat.list = list;
704  feat.masterFeat = 0xFFFFFFFF;
705  feat.isMasterFeat = false;
706 
707  // Check is the feat belongs to a masterfeat.
708  if (!featRow.empty("MASTERFEAT"))
709  feat.masterFeat = featRow.getInt("MASTERFEAT");
710 
711  feats.push_back(feat);
712  }
713 }
714 
715 } // End of namespace NWN
716 
717 } // End of namespace Engines
An inventory item in Neverwinter Nights.
Class to hold the two-dimensional array of a 2DA file.
Definition: 2dafile.h:124
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).
void setSkill(size_t skillIndex, uint8 rank)
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
Common::UString icon
#define TalkMan
Shortcut for accessing the talk manager.
Definition: talkman.h:111
const Common::UString & getString(size_t column) const
Return the contents of a cell as a string.
Definition: 2dafile.cpp:59
void getPrefDomains(uint8 &domain1, uint8 &domain2)
std::vector< std::vector< uint16 > > _spells
Common::UString help
A class holding an UTF-8 string.
Definition: ustring.h:48
bool getAlign(uint8 &goodness, uint8 &lawfulness) const
void setSoundSet(uint32 soundSet)
Set the creature&#39;s sound set.
Definition: creature.cpp:1019
void setRace(uint32 race)
Set the creature&#39;s race.
Definition: creature.cpp:209
void setAlign(uint8 goodness, uint8 lawfulness)
std::vector< uint32 > _classFeats
Common::UString description
uint8_t uint8
Definition: types.h:200
const Creature & getCharacter()
void setNotUsedSkills(uint8 notUsedSkills)
bool hasFeat(uint32 feat) const
Does the creature have this feat?
Definition: creature.cpp:1068
Common::UString icon
void setPackage(uint8 package)
void setColorTatto1(uint32 colorTattoo1)
Set the creature&#39;s color tattoo 1.
Definition: creature.cpp:356
const GFF3Struct & getTopLevel() const
Returns the top-level struct.
Definition: gff3file.cpp:91
void setColorHair(uint32 colorHair)
Set the creature&#39;s color hair.
Definition: creature.cpp:352
size_t getRowCount() const
Return the number of rows in the array.
Definition: 2dafile.cpp:400
void setSoundSet(uint32 soundSetID)
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
uint8 getTotalAbility(Ability ability) const
std::vector< uint32 > _normalFeats
The context needed to run a Neverwinter Nights module.
Common::UString name
void setColorSkin(uint32 colorSkin)
Set the creature&#39;s color skin.
Definition: creature.cpp:348
uint16_t uint16
Definition: types.h:202
void setClass(uint32 classId)
Common::UString name
uint8 getAbility(Ability ability) const
Utility templates and functions.
void getPrefFeats(std::vector< uint32 > &feats)
void setSchool(uint32 classID, uint8 school)
Set the creature&#39;s school.
Definition: creature.cpp:296
Handling BioWare&#39;s 2DAs (two-dimensional array).
void setPortrait(const Common::UString &portrait)
Set the creature&#39;s portrait.
Definition: creature.cpp:216
int8 getAbilityModifier(Ability ability)
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
void getPrefSkills(std::vector< uint8 > &skills)
void setFeat(uint32 feat)
Append a feat to the creature.
Definition: creature.cpp:1061
void setDomains(uint32 classID, uint8 domain1, uint8 domain2)
Set clerical domains.
Definition: creature.cpp:270
uint16 getClassLevel(uint32 classID) const
Get the creature&#39;s level for this class.
Definition: creature.cpp:949
#define TwoDAReg
Shortcut for accessing the 2da registry.
Definition: 2dareg.h:101
void setHead(uint32 headID)
Set the creature&#39;s head.
Definition: creature.cpp:364
The global 2DA registry.
bool hasPrereqFeat(uint32 featId, bool isClassFeat)
void useCharacter(Module *module)
bool hasFeat(uint32 featId) const
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
int32 getInt(size_t column) const
Return the contents of a cell as an int.
Definition: 2dafile.cpp:75
void getFeatItems(std::list< FeatItem > &feats, uint8 &normalFeats, uint8 &bonusFeats)
std::vector< uint8 > _abilities
void setSpell(size_t spellLevel, uint16 spell)
void usePC(const Common::UString &bic, bool local)
Use this character as the player character.
Definition: module.cpp:268
static const uint32 kRaceInvalid
Definition: types.h:278
void setKnownSpell(uint32 classID, size_t spellLevel, uint16 spell)
Set a creature&#39;s known spell.
Definition: creature.cpp:304
void setPortrait(const Common::UString &portrait)
void getPrefSpells(std::vector< std::vector< uint16 > > &spells)
bool empty(size_t column) const
Check if the cell is empty.
Definition: 2dafile.cpp:107
std::vector< uint8 > _racialAbilities
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
void setGender(Gender gender)
int8_t int8
Definition: types.h:199
void setGoodEvil(uint8 goodness)
Set the creature&#39;s good-evil alignment.
Definition: creature.cpp:1007
uint32_t uint32
Definition: types.h:204
The global talk manager for Aurora strings.
A creature in a Neverwinter Nights area.
Item template (user), GFF.
Definition: types.h:91
void setDomains(uint8 domain1, uint8 domain2)
static const uint32 kFieldIDInvalid
Definition: types.h:443
std::vector< uint32 > _racialFeats
void setColorTatto2(uint32 colorTattoo2)
Set the creature&#39;s color tatto 2.
Definition: creature.cpp:360
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 setSpellSchool(uint8 spellSchool)
uint8 list
The kind of list the feat belongs to: 0 (general feat), 2 (bonus feat), 1 (both)
void setAppearance(uint32 appearanceID)
Set the creature&#39;s appearance.
Definition: creature.cpp:340
The character choices in the character generator.
std::vector< uint8 > _skills
void addEquippedItem(Item *item)
Add an equippement to the creature.
Definition: creature.cpp:368
void setAbilities(std::vector< uint8 > abilities, std::vector< uint8 > racialAbilities)
void getSkillItems(std::vector< SkillItem > &skills)
size_t headerToColumn(const Common::UString &header) const
Translate a column header to a column index.
Definition: 2dafile.cpp:412
void getFeats(std::vector< uint32 > &feats)
void setSkillRank(size_t skill, uint8 rank)
Set the creature&#39;s skill rank.
Definition: creature.cpp:1054
int32_t int32
Definition: types.h:203