ESSImport: convert Dead flag

openmw-35
scrawl 10 years ago
parent 5a9b30a8ca
commit e7056b4e27

@ -32,6 +32,11 @@ namespace ESSImport
cStats.mAttacked = acdt.mFlags & Attacked;
}
void convertACSC (const ACSC& acsc, ESM::CreatureStats& cStats)
{
cStats.mDead = acsc.mFlags & Dead;
}
void convertNpcData (const ActorData& actorData, ESM::NpcStats& npcStats)
{
for (int i=0; i<ESM::Skill::Length; ++i)

@ -15,6 +15,7 @@ namespace ESSImport
void convertACDT (const ACDT& acdt, ESM::CreatureStats& cStats);
void convertACSC (const ACSC& acsc, ESM::CreatureStats& cStats);
void convertNpcData (const ActorData& actorData, ESM::NpcStats& npcStats);
}

@ -274,6 +274,8 @@ namespace ESSImport
const CellRef& cellref = *refIt;
ESM::CellRef out (cellref);
// TODO: use mContext->mCreatures/mNpcs
if (!isIndexedRefId(cellref.mIndexedRefId))
{
// non-indexed RefNum, i.e. no CREC/NPCC/CNTC record associated with it
@ -309,9 +311,12 @@ namespace ESSImport
objstate.blank();
objstate.mRef = out;
objstate.mRef.mRefID = idLower;
// probably need more micromanagement here so we don't overwrite values
// TODO: need more micromanagement here so we don't overwrite values
// from the ESM with default values
convertACDT(cellref.mACDT, objstate.mCreatureStats);
if (cellref.mHasACDT)
convertACDT(cellref.mACDT, objstate.mCreatureStats);
if (cellref.mHasACSC)
convertACSC(cellref.mACSC, objstate.mCreatureStats);
convertNpcData(cellref, objstate.mNpcStats);
convertNPCC(npccIt->second, objstate);
convertCellRef(cellref, objstate);
@ -343,9 +348,12 @@ namespace ESSImport
objstate.blank();
objstate.mRef = out;
objstate.mRef.mRefID = idLower;
convertACDT(cellref.mACDT, objstate.mCreatureStats);
// probably need more micromanagement here so we don't overwrite values
// TODO: need more micromanagement here so we don't overwrite values
// from the ESM with default values
if (cellref.mHasACDT)
convertACDT(cellref.mACDT, objstate.mCreatureStats);
if (cellref.mHasACSC)
convertACSC(cellref.mACSC, objstate.mCreatureStats);
convertCREC(crecIt->second, objstate);
convertCellRef(cellref, objstate);
esm.writeHNT ("OBJE", ESM::REC_CREA);

@ -104,10 +104,10 @@ public:
npc.load(esm);
if (id != "player")
{
// TODO:
// this should handle changes to the NPC struct, but since there is no index here
// Handles changes to the NPC struct, but since there is no index here
// it will apply to ALL instances of the class. seems to be the reason for the
// "feature" in MW where changing AI settings of one guard will change it for all guards of that refID.
mContext->mNpcs[Misc::StringUtils::lowerCase(id)] = npc;
}
else
{
@ -139,6 +139,7 @@ public:
ESM::Creature creature;
std::string id = esm.getHNString("NAME");
creature.load(esm);
mContext->mCreatures[Misc::StringUtils::lowerCase(id)] = creature;
}
};

@ -20,12 +20,22 @@ namespace ESSImport
ESM::CellRef::loadData(esm);
// FIXME: not all actors have this, add flag
esm.getHNOT(mACDT, "ACDT");
mHasACDT = false;
if (esm.isNextSub("ACDT"))
{
mHasACDT = true;
esm.getHT(mACDT);
}
mHasACSC = false;
if (esm.isNextSub("ACSC"))
{
mHasACSC = true;
esm.getHT(mACSC);
}
ACSC acsc;
esm.getHNOT(acsc, "ACSC"); // skill progress?
esm.getHNOT(acsc, "ACSL");
if (esm.isNextSub("ACSL"))
esm.skipHSubSize(112);
if (esm.isNextSub("CSTN"))
esm.skipHSub(); // "PlayerSaveGame", link to some object?

@ -18,7 +18,12 @@ namespace ESSImport
enum ACDTFlags
{
TalkedToPlayer = 0x4,
Attacked = 0x100
Attacked = 0x100,
Unknown = 0x200
};
enum ACSCFlags
{
Dead = 0x2
};
/// Actor data, shared by (at least) REFR and CellRef
@ -35,16 +40,27 @@ namespace ESSImport
float mDynamic[3][2];
unsigned char mUnknown3[16];
float mAttributes[8][2];
unsigned char mUnknown4[112];
float mMagicEffects[27]; // Effect attributes: https://wiki.openmw.org/index.php?title=Research:Magic#Effect_attributes
unsigned char mUnknown4[4];
unsigned int mGoldPool;
unsigned char mUnknown5[4];
};
struct ACSC
{
unsigned char mUnknown1[17];
unsigned char mFlags; // ACSCFlags
unsigned char mUnknown2[94];
};
#pragma pack(pop)
struct ActorData : public ESM::CellRef
{
bool mHasACDT;
ACDT mACDT;
bool mHasACSC;
ACSC mACSC;
int mSkills[27][2];
// creature combat stats, base and modified
@ -60,12 +76,6 @@ namespace ESSImport
void load(ESM::ESMReader& esm);
};
/// Unknown, shared by (at least) REFR and CellRef
struct ACSC
{
unsigned char unknown[112];
};
}
#endif

@ -7,6 +7,8 @@
#include <components/esm/player.hpp>
#include <components/esm/dialoguestate.hpp>
#include <components/esm/globalmap.hpp>
#include <components/esm/loadcrea.hpp>
#include <components/esm/loadnpc.hpp>
#include "importnpcc.hpp"
#include "importcrec.hpp"
@ -15,6 +17,7 @@
namespace ESSImport
{
@ -42,6 +45,9 @@ namespace ESSImport
std::map<std::pair<int, std::string>, NPCC> mNpcChanges;
std::map<std::pair<int, std::string>, CNTC> mContainerChanges;
std::map<std::string, ESM::Creature> mCreatures;
std::map<std::string, ESM::NPC> mNpcs;
Context()
{
mPlayer.mAutoMove = 0;

Loading…
Cancel
Save