2011-04-08 13:58:21 +00:00
|
|
|
#include "loadnpc.hpp"
|
|
|
|
|
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
|
|
|
|
void NPC::load(ESMReader &esm, const std::string& id)
|
|
|
|
{
|
|
|
|
mId = id;
|
|
|
|
|
|
|
|
npdt52.gold = -10;
|
|
|
|
|
|
|
|
model = esm.getHNOString("MODL");
|
|
|
|
name = esm.getHNOString("FNAM");
|
|
|
|
|
|
|
|
race = esm.getHNString("RNAM");
|
|
|
|
cls = esm.getHNString("CNAM");
|
|
|
|
faction = esm.getHNString("ANAM");
|
|
|
|
head = esm.getHNString("BNAM");
|
|
|
|
hair = esm.getHNString("KNAM");
|
|
|
|
|
|
|
|
script = esm.getHNOString("SCRI");
|
|
|
|
|
|
|
|
esm.getSubNameIs("NPDT");
|
|
|
|
esm.getSubHeader();
|
|
|
|
if (esm.getSubSize() == 52)
|
|
|
|
esm.getExact(&npdt52, 52);
|
|
|
|
else if (esm.getSubSize() == 12)
|
|
|
|
esm.getExact(&npdt12, 12);
|
|
|
|
else
|
|
|
|
esm.fail("NPC_NPDT must be 12 or 52 bytes long");
|
|
|
|
|
|
|
|
esm.getHNT(flags, "FLAG");
|
|
|
|
|
|
|
|
inventory.load(esm);
|
|
|
|
spells.load(esm);
|
|
|
|
|
|
|
|
if (esm.isNextSub("AIDT"))
|
|
|
|
{
|
2012-08-29 17:35:06 +00:00
|
|
|
esm.getHExact(&mAiData, sizeof(mAiData));
|
|
|
|
mHasAI= true;
|
2011-04-08 13:58:21 +00:00
|
|
|
}
|
|
|
|
else
|
2012-08-29 17:35:06 +00:00
|
|
|
mHasAI = false;
|
2011-04-08 13:58:21 +00:00
|
|
|
|
2012-08-29 10:01:10 +00:00
|
|
|
while (esm.isNextSub("DODT") || esm.isNextSub("DNAM")) {
|
|
|
|
if (esm.retSubName() == 0x54444f44) { // DODT struct
|
|
|
|
Dest dodt;
|
2012-08-29 17:35:06 +00:00
|
|
|
esm.getHExact(&dodt.mPos, 24);
|
|
|
|
mTransport.push_back(dodt);
|
2012-08-29 10:01:10 +00:00
|
|
|
} else if (esm.retSubName() == 0x4d414e44) { // DNAM struct
|
2012-08-29 17:35:06 +00:00
|
|
|
mTransport.back().mCellName = esm.getHString();
|
2012-08-29 10:01:10 +00:00
|
|
|
}
|
|
|
|
}
|
2012-08-29 17:35:06 +00:00
|
|
|
mAiPackage.load(esm);
|
2011-04-08 13:58:21 +00:00
|
|
|
esm.skipRecord();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|