diff --git a/apps/essimporter/convertacdt.cpp b/apps/essimporter/convertacdt.cpp index d3b70d1f58..718403a8c3 100644 --- a/apps/essimporter/convertacdt.cpp +++ b/apps/essimporter/convertacdt.cpp @@ -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; imCreatures/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); diff --git a/apps/essimporter/converter.hpp b/apps/essimporter/converter.hpp index c80ccb951a..886983aab3 100644 --- a/apps/essimporter/converter.hpp +++ b/apps/essimporter/converter.hpp @@ -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; } }; diff --git a/apps/essimporter/importacdt.cpp b/apps/essimporter/importacdt.cpp index 4cd994b927..9d881515dd 100644 --- a/apps/essimporter/importacdt.cpp +++ b/apps/essimporter/importacdt.cpp @@ -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? diff --git a/apps/essimporter/importacdt.hpp b/apps/essimporter/importacdt.hpp index 4876602bcd..1e0317049d 100644 --- a/apps/essimporter/importacdt.hpp +++ b/apps/essimporter/importacdt.hpp @@ -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 diff --git a/apps/essimporter/importercontext.hpp b/apps/essimporter/importercontext.hpp index a466770d0d..3b010cb8ff 100644 --- a/apps/essimporter/importercontext.hpp +++ b/apps/essimporter/importercontext.hpp @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include "importnpcc.hpp" #include "importcrec.hpp" @@ -15,6 +17,7 @@ + namespace ESSImport { @@ -42,6 +45,9 @@ namespace ESSImport std::map, NPCC> mNpcChanges; std::map, CNTC> mContainerChanges; + std::map mCreatures; + std::map mNpcs; + Context() { mPlayer.mAutoMove = 0;