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; 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) void convertNpcData (const ActorData& actorData, ESM::NpcStats& npcStats)
{ {
for (int i=0; i<ESM::Skill::Length; ++i) for (int i=0; i<ESM::Skill::Length; ++i)

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

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

@ -104,10 +104,10 @@ public:
npc.load(esm); npc.load(esm);
if (id != "player") if (id != "player")
{ {
// TODO: // Handles changes to the NPC struct, but since there is no index here
// this should handle 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 // 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. // "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 else
{ {
@ -139,6 +139,7 @@ public:
ESM::Creature creature; ESM::Creature creature;
std::string id = esm.getHNString("NAME"); std::string id = esm.getHNString("NAME");
creature.load(esm); creature.load(esm);
mContext->mCreatures[Misc::StringUtils::lowerCase(id)] = creature;
} }
}; };

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

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

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

Loading…
Cancel
Save