46 namespace DragonAge2 {
54 using ::Aurora::GFF3File;
55 using ::Aurora::GFF3Struct;
58 using ::Aurora::GFF4File;
59 using ::Aurora::GFF4Struct;
93 for (Models::iterator m =
_models.begin(); m !=
_models.end(); ++m)
94 (*m)->setPosition(x, y, z);
101 for (Models::iterator m =
_models.begin(); m !=
_models.end(); ++m)
102 (*m)->setOrientation(x, y, z, angle);
106 for (Models::iterator m =
_models.begin(); m !=
_models.end(); ++m)
111 for (Models::iterator m =
_models.begin(); m !=
_models.end(); ++m)
129 status(
"Creature \"%s\" (\"%s\"): \"%s\"",
140 for (Models::iterator m =
_models.begin(); m !=
_models.end(); ++m)
141 (*m)->drawBound(enabled);
152 _resRef = creature.getString(
"TemplateResRef");
158 load(creature, utc ? &utc->getTopLevel() : 0);
186 return modelPath +
"\\" + prefix +
"\\" + model;
190 uint8 *armorType)
const {
196 const size_t variationRow = variations.
findRow(variation);
205 *armorType = variations.
getInt(variationRow,
"MaterialGroup");
235 bool haveHelm =
false;
249 static const size_t kHairPart = 2;
256 std::vector<Common::UString> parts;
260 for (
size_t i = 0; i < parts.size(); i++) {
261 if ((i == kHairPart) && !loadHair)
273 static const size_t kHairPart = 2;
276 {
"Head_Worksheet",
"Eyes_Worksheet",
"Hair_Worksheet",
"Beard_Worksheet"};
281 const size_t sheetIndex = gda.
getInt(row, kSheetColumns[i]);
285 if ((i == kHairPart) && !loadHair)
305 const uint32 chestModel = gda.
getInt(row,
"ChestModelVariation");
306 const uint32 glovesModel = gda.
getInt(row,
"GlovesModelVariation");
307 const uint32 bootsModel = gda.
getInt(row,
"BootsModelVariation");
308 const uint32 helmModel = gda.
getInt(row,
"HelmModelVariation");
310 static const uint32 kNakedTorso = 10;
311 static const uint32 kNakedGloves = 11;
312 static const uint32 kNakedBoots = 12;
331 if (armorType != 5) {
361 bool haveHelm =
false;
377 uint8 *armorType)
const {
383 for (Items::const_iterator item =
_items.begin(); item !=
_items.end(); ++item) {
384 if (item->slot != slot)
389 const GFF3Struct &utiTop = uti.getTopLevel();
392 const uint32 variation = utiTop.getUint(
"ModelVariation", 0xFFFFFFFF);
394 const size_t itemRow = baseItems.
findRow(baseItem);
407 void Creature::load(
const GFF3Struct &instance,
const GFF3Struct *blueprint = 0) {
417 if (modelType ==
"S")
419 else if (modelType ==
"W")
421 else if (modelType ==
"H")
423 else if (modelType ==
"P")
426 const float scaleX = gda.
getFloat(row,
"ModelScaleX", 1.0f);
427 const float scaleY = gda.
getFloat(row,
"ModelScaleY", 1.0f);
428 const float scaleZ = gda.
getFloat(row,
"ModelScaleZ", 1.0f);
430 for (Models::iterator m =
_models.begin(); m !=
_models.end(); ++m) {
431 (*m)->setScale(scaleX, scaleY, scaleZ);
436 _ids.push_back((*m)->getID());
448 gff.getLocString(
"LocName" ,
_name);
461 if (gff.hasField(
"Appearance Data")) {
462 const GFF3Struct &app = gff.getStruct(
"Appearance Data");
468 if (app.hasField(
"PartList")) {
469 const GFF3List &parts = app.getList(
"PartList");
472 _partVariation[i] = (i < parts.size()) ? parts[i]->getUint(
"PartVariation") : 0xFFFFFFFF;
477 if (gff.hasField(
"Equip_ItemList")) {
478 const GFF3List &itemList = gff.getList(
"Equip_ItemList");
479 _items.resize(itemList.size());
481 for (
size_t i = 0; i < itemList.size(); i++) {
484 _items[i].resRef = itemList[i]->getString(
"TemplateResRef");
486 _items[i].stealable = itemList[i]->getBool(
"Stealable");
487 _items[i].droopable = itemList[i]->getBool(
"Droppable");
489 _items[i].setNumber = itemList[i]->getSint(
"SetNumber", -1);
494 if (gff.hasField(
"XPosition")) {
495 const float position[3] = {
496 (float) gff.getDouble(
"XPosition"),
497 (float) gff.getDouble(
"YPosition"),
498 (float) gff.getDouble(
"ZPosition")
501 setPosition(position[0], position[1], position[2]);
505 if (gff.hasField(
"XOrientation")) {
506 const float orientation[4] = {
507 (float) gff.getDouble(
"XOrientation"),
508 (float) gff.getDouble(
"YOrientation"),
509 (float) gff.getDouble(
"ZOrientation"),
513 setOrientation(orientation[0], orientation[1], orientation[2], orientation[3]);
Handling version V3.2/V3.3 of BioWare's GFFs (generic file format).
static const uint32 kVersion01
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like 'DATA', to ensure portability.
void loadModelsParts(const Aurora::GDAFile &gda, size_t row)
void enter()
The cursor entered the creature.
Handling BioWare's GDAs (2DAs, two-dimensional array, within V4.0 GFFs).
int32 getInt(size_t row, uint32 columnHash, int32 def=0) const
void loadModelsSimple(const Aurora::GDAFile &gda, size_t row)
A creature in a Dragon Age II area.
void setString(Language language, LanguageGender gender, const Common::UString &str)
Set the string of that language.
bool _usable
Is the object usable?
A class holding an UTF-8 string.
float getFloat(size_t row, uint32 columnHash, float def=0.0f) const
virtual void setOrientation(float x, float y, float z, float angle)
Set the object's orientation.
void reset(PointerType o=0)
Resets the pointer with the new value.
static const uint32 kUTCID
virtual void setPosition(float x, float y, float z)
Set the object's position within its area.
InventorySlot
Slot in a creature's inventory.
Common::UString findEquipModel(InventorySlot slot, const Common::UString &prefix, uint8 *armorType=0) const
void loadModelsHead(const Aurora::GDAFile &gda, size_t row)
bool click(Object *triggerer=0)
The creature was clicked.
void setPosition(float x, float y, float z)
Set the creature's position.
void enableEvents(bool enabled)
Enable/Disable the handling of all events.
Dragon Age II utility functions.
static const uint32 kMORPID
bool isClickable() const
Can the player click the object?
bool _isPC
Is the creature a PC?
Common::UString _resRef
The object's resource reference.
Common::UString _headMorph
Name of the morph file describing the creature's head.
static const size_t kPartVariationCount
Max number of model parts for a creature's head.
size_t findRow(uint32 id) const
Find a row by its ID value.
const Aurora::GDAFile & getMGDA(uint32 id)
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.
bool runScript(EventType event, const Aurora::NWScript::ObjectReference owner=Aurora::NWScript::ObjectReference(), const Aurora::NWScript::ObjectReference triggerer=Aurora::NWScript::ObjectReference())
void highlight(bool enabled)
(Un)Highlight the creature.
Items _items
All item the creature has currently equipped.
Utility templates and functions for working with strings and streams.
const Common::UString & getString(Language language, LanguageGender gender=kLanguageGenderCurrent) const
Get the string of that language.
bool _static
Is the object static?
Exception that provides a stack of explanations.
A simple scoped smart pointer template.
Common::UString _conversation
The object's default conversation.
std::vector< const GFF4Struct * > GFF4List
Handling version V4.0/V4.1 of BioWare's GFFs (generic file format).
static Common::UString createModelPart(const Aurora::GDAFile &gda, size_t row, const Common::UString &prefix)
Basic exceptions to throw.
void show()
Show the creature's model.
const char * c_str() const
Return the (utf8 encoded) string data.
static UString format(const char *s,...) GCC_PRINTF(1
Print formatted data into an UString object, similar to sprintf().
Models _models
The models making up this creature.
void loadModelsHeadMorph(bool loadHair=true)
Utility templates and functions.
void load(const Aurora::GFF3Struct &placeable)
virtual void getOrientation(float &x, float &y, float &z, float &angle) const
Return the object's orientation.
void loadModelsWelded(const Aurora::GDAFile &gda, size_t row)
Creature()
Create a dummy creature instance.
Types and functions related to language.
bool empty() const
Is the string empty?
void leave()
The cursor left the creature.
static const uint32 kUTIID
void setOrientation(float x, float y, float z, float angle)
Set the creature's orientation.
A scoped plain pointer, allowing pointer-y access and normal deletion.
std::vector< const GFF3Struct * > GFF3List
bool isPC() const
Is the creature a player character?
static Common::UString createModelPrefix(const Aurora::GDAFile &gda, size_t row)
Common::UString getItemModel(uint32 variation, const Common::UString &prefix, uint8 *armorType=0) const
Common::UString getString(size_t row, uint32 columnHash, const Common::UString &def="") const
uint32 _appearanceID
The creature's appearance; index into the Appearances MGDA.
#define LangMan
Shortcut for accessing the language manager.
void loadProperties(const Aurora::GFF3Struct &gff)
UString debugTag(uint32 tag, bool trim)
Create an elaborate string from an integer tag, for debugging purposes.
Item template (user), GFF.
void loadModelsHeadList(const Aurora::GDAFile &gda, size_t row, bool loadHair=true)
static const size_t kInvalidRow
uint32 _partVariation[kPartVariationCount]
Indices into the MGDAs describing the creature's head model parts.
virtual void getPosition(float &x, float &y, float &z) const
Return the object's position within its area.
Aurora::LocString _name
The object's display name.
void status(const char *s,...)
static float rad2deg(float rad)
Aurora::LocString _description
The object's description.
Generic Aurora engines utility functions.
Graphics::Aurora::Model * loadModelObject(const Common::UString &resref, const Common::UString &texture)
void hide()
Hide the creature's model.
Creature template (user), GFF.
void createFakePC()
Create a fake player character creature for testing purposes.
void readVarTable(const Aurora::GFF3List &varTable)
Class to hold the GFF'd two-dimensional array of a GDA file.
std::list< uint32 > _ids
The object's model IDs.
void readScript(const Aurora::GFF3Struct &gff)
Generic Aurora engines model functions.