54 using ::Aurora::GFF3File;
55 using ::Aurora::GFF3Struct;
58 using ::Aurora::GFF4File;
59 using ::Aurora::GFF4Struct;
94 for (Models::iterator m =
_models.begin(); m !=
_models.end(); ++m)
95 (*m)->setPosition(x, y, z);
102 for (Models::iterator m =
_models.begin(); m !=
_models.end(); ++m)
103 (*m)->setOrientation(x, y, z, angle);
107 for (Models::iterator m =
_models.begin(); m !=
_models.end(); ++m)
112 for (Models::iterator m =
_models.begin(); m !=
_models.end(); ++m)
130 status(
"Creature \"%s\" (\"%s\"): \"%s\"",
141 for (Models::iterator m =
_models.begin(); m !=
_models.end(); ++m)
142 (*m)->drawBound(enabled);
153 _resRef = creature.getString(
"TemplateResRef");
159 load(creature, utc ? &utc->getTopLevel() : 0);
166 static const char *
const kGenderChars[4] = {
"N",
"M",
"F",
"N" };
170 genderChar = kGenderChars[gender];
174 return modelRace + genderChar;
189 return prefix +
"_" + type +
"_" + subType + variation;
219 bool haveHelm =
false;
233 static const size_t kHairPart = 2;
240 std::vector<Common::UString> parts;
244 for (
size_t i = 0; i < parts.size(); i++) {
245 if ((i == kHairPart) && !loadHair)
257 static const size_t kHairPart = 2;
260 {
"Head_Worksheet",
"Eyes_Worksheet",
"Hair_Worksheet",
"Beard_Worksheet"};
265 const size_t sheetIndex = gda.
getInt(row, kSheetColumns[i]);
269 if ((i == kHairPart) && !loadHair)
291 static const uint32 kNakedTorso = 0;
292 static const uint32 kNakedGloves = 1;
293 static const uint32 kNakedBoots = 2;
310 if (armorType != 5) {
332 bool haveHelm =
false;
348 uint8 *armorType)
const {
354 for (Items::const_iterator item =
_items.begin(); item !=
_items.end(); ++item) {
355 if (item->slot != slot)
360 const GFF3Struct &utiTop = uti.getTopLevel();
363 const uint32 variation = utiTop.getUint(
"ModelVariation", 0xFFFFFFFF);
365 const size_t itemRow = baseItems.
findRow(baseItem);
370 *armorType = baseItems.
getInt(itemRow,
"ArmorType");
372 const uint32 varSheet = (
uint32) baseItems.
getInt(itemRow,
"Variation_Worksheet", -1);
375 const size_t variationRow = variations.
findRow(variation);
388 void Creature::load(
const GFF3Struct &instance,
const GFF3Struct *blueprint = 0) {
398 if (modelType ==
"S")
400 else if (modelType ==
"W")
402 else if (modelType ==
"H")
404 else if (modelType ==
"P")
407 const float scaleX = gda.
getFloat(row,
"ModelScaleX", 1.0f);
408 const float scaleY = gda.
getFloat(row,
"ModelScaleY", 1.0f);
409 const float scaleZ = gda.
getFloat(row,
"ModelScaleZ", 1.0f);
411 for (Models::iterator m =
_models.begin(); m !=
_models.end(); ++m) {
412 (*m)->setScale(scaleX, scaleY, scaleZ);
417 _ids.push_back((*m)->getID());
429 gff.getLocString(
"LocName" ,
_name);
442 if (gff.hasField(
"Appearance Data")) {
443 const GFF3Struct &app = gff.getStruct(
"Appearance Data");
450 if (app.hasField(
"PartList")) {
451 const GFF3List &parts = app.getList(
"PartList");
454 _partVariation[i] = (i < parts.size()) ? parts[i]->getUint(
"PartVariation") : 0xFFFFFFFF;
459 if (gff.hasField(
"Equip_ItemList")) {
460 const GFF3List &itemList = gff.getList(
"Equip_ItemList");
461 _items.resize(itemList.size());
463 for (
size_t i = 0; i < itemList.size(); i++) {
466 _items[i].resRef = itemList[i]->getString(
"TemplateResRef");
468 _items[i].stealable = itemList[i]->getBool(
"Stealable");
469 _items[i].droopable = itemList[i]->getBool(
"Droppable");
471 _items[i].setNumber = itemList[i]->getSint(
"SetNumber", -1);
476 if (gff.hasField(
"XPosition")) {
477 const float position[3] = {
478 (float) gff.getDouble(
"XPosition"),
479 (float) gff.getDouble(
"YPosition"),
480 (float) gff.getDouble(
"ZPosition")
483 setPosition(position[0], position[1], position[2]);
487 if (gff.hasField(
"XOrientation")) {
488 const float orientation[4] = {
489 (float) gff.getDouble(
"XOrientation"),
490 (float) gff.getDouble(
"YOrientation"),
491 (float) gff.getDouble(
"ZOrientation"),
495 setOrientation(orientation[0], orientation[1], orientation[2], orientation[3]);
void loadModelsHead(const Aurora::GDAFile &gda, size_t row)
Models _models
The models making up this creature.
Handling version V3.2/V3.3 of BioWare's GFFs (generic file format).
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like 'DATA', to ensure portability.
void loadModelsHeadMorph(bool loadHair=true)
Handling BioWare's GDAs (2DAs, two-dimensional array, within V4.0 GFFs).
InventorySlot
Slot in a creature's inventory.
int32 getInt(size_t row, uint32 columnHash, int32 def=0) const
void setString(Language language, LanguageGender gender, const Common::UString &str)
Set the string of that language.
void setPosition(float x, float y, float z)
Set the creature's position.
bool _static
Is the object static?
A class holding an UTF-8 string.
float getFloat(size_t row, uint32 columnHash, float def=0.0f) const
uint32 _appearanceID
The creature's appearance; index into the Appearances MGDA.
void reset(PointerType o=0)
Resets the pointer with the new value.
static const uint32 kVersion01
A creature in a Dragon Age: Origins area.
void highlight(bool enabled)
(Un)Highlight the creature.
static Common::UString createModelPrefix(const Aurora::GDAFile &gda, size_t row, uint8 gender)
#define ARRAYSIZE(x)
Macro which determines the number of entries in a fixed size array.
size_t findRow(uint32 id) const
Find a row by its ID value.
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.
void loadModelsParts(const Aurora::GDAFile &gda, size_t row)
Aurora::LocString _description
The object's description.
Utility templates and functions for working with strings and streams.
const Aurora::GDAFile & getMGDA(uint32 id)
const Common::UString & getString(Language language, LanguageGender gender=kLanguageGenderCurrent) const
Get the string of that language.
static Common::UString createModelPart(const Aurora::GDAFile &gda, size_t row, const Common::UString &prefix)
Exception that provides a stack of explanations.
A simple scoped smart pointer template.
bool _isPC
Is the creature a PC?
bool _usable
Is the object usable?
std::vector< const GFF4Struct * > GFF4List
Handling version V4.0/V4.1 of BioWare's GFFs (generic file format).
static const size_t kPartVariationCount
Max number of model parts for a creature's head.
Basic exceptions to throw.
static const uint32 kMORPID
void loadProperties(const Aurora::GFF3Struct &gff)
const char * c_str() const
Return the (utf8 encoded) string data.
uint32 _partVariation[kPartVariationCount]
Indices into the MGDAs describing the creature's head model parts.
static UString format(const char *s,...) GCC_PRINTF(1
Print formatted data into an UString object, similar to sprintf().
static const uint32 kUTIID
Utility templates and functions.
Dragon Age: Origins utility functions.
Types and functions related to language.
bool empty() const
Is the string empty?
void loadModelsHeadList(const Aurora::GDAFile &gda, size_t row, bool loadHair=true)
Creature()
Create a dummy creature instance.
virtual void getOrientation(float &x, float &y, float &z, float &angle) const
Return the object's orientation.
A scoped plain pointer, allowing pointer-y access and normal deletion.
Common::UString _resRef
The object's resource reference.
void loadModelsSimple(const Aurora::GDAFile &gda, size_t row)
std::vector< const GFF3Struct * > GFF3List
Aurora::LocString _name
The object's display name.
void readVarTable(const Aurora::GFF3List &varTable)
Common::UString _headMorph
Name of the morph file describing the creature's head.
Common::UString getString(size_t row, uint32 columnHash, const Common::UString &def="") const
Items _items
All item the creature has currently equipped.
Common::UString findEquipModel(InventorySlot slot, const Common::UString &prefix, uint8 *armorType=0) const
void loadModelsWelded(const Aurora::GDAFile &gda, size_t row)
std::list< uint32 > _ids
The object's model IDs.
static const uint32 kUTCID
void enter()
The cursor entered the creature.
#define LangMan
Shortcut for accessing the language manager.
virtual void setPosition(float x, float y, float z)
Set the object's position within its area.
UString debugTag(uint32 tag, bool trim)
Create an elaborate string from an integer tag, for debugging purposes.
Item template (user), GFF.
static const size_t kInvalidRow
void status(const char *s,...)
bool click(Object *triggerer=0)
The creature was clicked.
void load(const Aurora::GFF3Struct &placeable)
void readScript(const Aurora::GFF3Struct &gff)
static float rad2deg(float rad)
Generic Aurora engines utility functions.
bool isClickable() const
Can the player click the object?
void setOrientation(float x, float y, float z, float angle)
Set the creature's orientation.
Graphics::Aurora::Model * loadModelObject(const Common::UString &resref, const Common::UString &texture)
bool isPC() const
Is the creature a player character?
virtual void getPosition(float &x, float &y, float &z) const
Return the object's position within its area.
Creature template (user), GFF.
Common::UString _conversation
The object's default conversation.
void show()
Show the creature's model.
void createFakePC()
Create a fake player character creature for testing purposes.
uint8 _appearanceGender
The gender of the creature's model files.
bool runScript(EventType event, const Aurora::NWScript::ObjectReference owner=Aurora::NWScript::ObjectReference(), const Aurora::NWScript::ObjectReference triggerer=Aurora::NWScript::ObjectReference())
void leave()
The cursor left the creature.
virtual void setOrientation(float x, float y, float z, float angle)
Set the object's orientation.
void enableEvents(bool enabled)
Enable/Disable the handling of all events.
Class to hold the GFF'd two-dimensional array of a GDA file.
void hide()
Hide the creature's model.
Generic Aurora engines model functions.