|
|
|
@ -8,55 +8,94 @@ namespace ESM {
|
|
|
|
|
|
|
|
|
|
unsigned int Creature::sRecordId = REC_CREA;
|
|
|
|
|
|
|
|
|
|
void Creature::load(ESMReader &esm)
|
|
|
|
|
{
|
|
|
|
|
mPersistent = esm.getRecordFlags() & 0x0400;
|
|
|
|
|
|
|
|
|
|
mModel = esm.getHNString("MODL");
|
|
|
|
|
mOriginal = esm.getHNOString("CNAM");
|
|
|
|
|
mName = esm.getHNOString("FNAM");
|
|
|
|
|
mScript = esm.getHNOString("SCRI");
|
|
|
|
|
|
|
|
|
|
esm.getHNT(mData, "NPDT", 96);
|
|
|
|
|
|
|
|
|
|
esm.getHNT(mFlags, "FLAG");
|
|
|
|
|
mScale = 1.0;
|
|
|
|
|
esm.getHNOT(mScale, "XSCL");
|
|
|
|
|
|
|
|
|
|
mInventory.load(esm);
|
|
|
|
|
mSpells.load(esm);
|
|
|
|
|
|
|
|
|
|
if (esm.isNextSub("AIDT"))
|
|
|
|
|
void Creature::load(ESMReader &esm)
|
|
|
|
|
{
|
|
|
|
|
esm.getHExact(&mAiData, sizeof(mAiData));
|
|
|
|
|
mHasAI = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
mHasAI = false;
|
|
|
|
|
mPersistent = esm.getRecordFlags() & 0x0400;
|
|
|
|
|
|
|
|
|
|
mAiPackage.load(esm);
|
|
|
|
|
esm.skipRecord();
|
|
|
|
|
}
|
|
|
|
|
mAiPackage.mList.clear();
|
|
|
|
|
mInventory.mList.clear();
|
|
|
|
|
mSpells.mList.clear();
|
|
|
|
|
|
|
|
|
|
void Creature::save(ESMWriter &esm) const
|
|
|
|
|
{
|
|
|
|
|
esm.writeHNCString("MODL", mModel);
|
|
|
|
|
esm.writeHNOCString("CNAM", mOriginal);
|
|
|
|
|
esm.writeHNOCString("FNAM", mName);
|
|
|
|
|
esm.writeHNOCString("SCRI", mScript);
|
|
|
|
|
esm.writeHNT("NPDT", mData, 96);
|
|
|
|
|
esm.writeHNT("FLAG", mFlags);
|
|
|
|
|
if (mScale != 1.0) {
|
|
|
|
|
esm.writeHNT("XSCL", mScale);
|
|
|
|
|
mScale = 1.f;
|
|
|
|
|
mHasAI = false;
|
|
|
|
|
bool hasNpdt = false;
|
|
|
|
|
bool hasFlags = false;
|
|
|
|
|
while (esm.hasMoreSubs())
|
|
|
|
|
{
|
|
|
|
|
esm.getSubName();
|
|
|
|
|
uint32_t name = esm.retSubName().val;
|
|
|
|
|
switch (name)
|
|
|
|
|
{
|
|
|
|
|
case ESM::FourCC<'M','O','D','L'>::value:
|
|
|
|
|
mModel = esm.getHString();
|
|
|
|
|
break;
|
|
|
|
|
case ESM::FourCC<'C','N','A','M'>::value:
|
|
|
|
|
mOriginal = esm.getHString();
|
|
|
|
|
break;
|
|
|
|
|
case ESM::FourCC<'F','N','A','M'>::value:
|
|
|
|
|
mName = esm.getHString();
|
|
|
|
|
break;
|
|
|
|
|
case ESM::FourCC<'S','C','R','I'>::value:
|
|
|
|
|
mScript = esm.getHString();
|
|
|
|
|
break;
|
|
|
|
|
case ESM::FourCC<'N','P','D','T'>::value:
|
|
|
|
|
esm.getHT(mData, 96);
|
|
|
|
|
hasNpdt = true;
|
|
|
|
|
break;
|
|
|
|
|
case ESM::FourCC<'F','L','A','G'>::value:
|
|
|
|
|
esm.getHT(mFlags);
|
|
|
|
|
hasFlags = true;
|
|
|
|
|
break;
|
|
|
|
|
case ESM::FourCC<'X','S','C','L'>::value:
|
|
|
|
|
esm.getHT(mScale);
|
|
|
|
|
break;
|
|
|
|
|
case ESM::FourCC<'N','P','C','O'>::value:
|
|
|
|
|
mInventory.add(esm);
|
|
|
|
|
break;
|
|
|
|
|
case ESM::FourCC<'N','P','C','S'>::value:
|
|
|
|
|
mSpells.add(esm);
|
|
|
|
|
break;
|
|
|
|
|
case ESM::FourCC<'A','I','D','T'>::value:
|
|
|
|
|
esm.getHExact(&mAiData, sizeof(mAiData));
|
|
|
|
|
mHasAI = true;
|
|
|
|
|
break;
|
|
|
|
|
case AI_Wander:
|
|
|
|
|
case AI_Activate:
|
|
|
|
|
case AI_Escort:
|
|
|
|
|
case AI_Follow:
|
|
|
|
|
case AI_Travel:
|
|
|
|
|
case AI_CNDT:
|
|
|
|
|
mAiPackage.add(esm);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
esm.fail("Unknown subrecord");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!hasNpdt)
|
|
|
|
|
esm.fail("Missing NPDT subrecord");
|
|
|
|
|
if (!hasFlags)
|
|
|
|
|
esm.fail("Missing FLAG subrecord");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mInventory.save(esm);
|
|
|
|
|
mSpells.save(esm);
|
|
|
|
|
if (mHasAI) {
|
|
|
|
|
esm.writeHNT("AIDT", mAiData, sizeof(mAiData));
|
|
|
|
|
void Creature::save(ESMWriter &esm) const
|
|
|
|
|
{
|
|
|
|
|
esm.writeHNCString("MODL", mModel);
|
|
|
|
|
esm.writeHNOCString("CNAM", mOriginal);
|
|
|
|
|
esm.writeHNOCString("FNAM", mName);
|
|
|
|
|
esm.writeHNOCString("SCRI", mScript);
|
|
|
|
|
esm.writeHNT("NPDT", mData, 96);
|
|
|
|
|
esm.writeHNT("FLAG", mFlags);
|
|
|
|
|
if (mScale != 1.0) {
|
|
|
|
|
esm.writeHNT("XSCL", mScale);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mInventory.save(esm);
|
|
|
|
|
mSpells.save(esm);
|
|
|
|
|
if (mHasAI) {
|
|
|
|
|
esm.writeHNT("AIDT", mAiData, sizeof(mAiData));
|
|
|
|
|
}
|
|
|
|
|
mAiPackage.save(esm);
|
|
|
|
|
}
|
|
|
|
|
mAiPackage.save(esm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Creature::blank()
|
|
|
|
|
{
|
|
|
|
|