1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-30 19:15:41 +00:00

ESSImport: convert selected spell / selected enchant item

This commit is contained in:
scrawl 2015-01-24 00:18:17 +01:00
parent 8e5c8aa562
commit 09f11fbff2
3 changed files with 29 additions and 6 deletions

View file

@ -226,7 +226,28 @@ public:
ESM::NpcStats& npcStats = mContext->mPlayer.mObject.mNpcStats; ESM::NpcStats& npcStats = mContext->mPlayer.mObject.mNpcStats;
convertNpcData(refr.mActorData, npcStats); convertNpcData(refr.mActorData, npcStats);
mSelectedSpell = refr.mActorData.mSelectedSpell;
if (!refr.mActorData.mSelectedEnchantItem.empty())
{
ESM::InventoryState& invState = mContext->mPlayer.mObject.mInventory;
for (unsigned int i=0; i<invState.mItems.size(); ++i)
{
// FIXME: in case of conflict (multiple items with this refID) use the already equipped one?
if (Misc::StringUtils::ciEqual(invState.mItems[i].mRef.mRefID, refr.mActorData.mSelectedEnchantItem))
invState.mSelectedEnchantItem = i;
}
}
} }
virtual void write(ESM::ESMWriter& esm)
{
esm.startRecord(ESM::REC_ASPL);
esm.writeHNString("ID__", mSelectedSpell);
esm.endRecord(ESM::REC_ASPL);
}
private:
std::string mSelectedSpell;
}; };
class ConvertPCDT : public Converter class ConvertPCDT : public Converter

View file

@ -62,17 +62,16 @@ namespace ESSImport
// unsure at which point between LSTN and CHRD // unsure at which point between LSTN and CHRD
if (esm.isNextSub("APUD")) if (esm.isNextSub("APUD"))
esm.skipHSub(); // 40 bytes, starts with string "ancestor guardian"... esm.skipHSub(); // 40 bytes, starts with string "ancestor guardian". maybe spellcasting in progress?
if (esm.isNextSub("WNAM")) if (esm.isNextSub("WNAM"))
{ {
esm.skipHSub(); // seen values: "ancestor guardian", "bound dagger_en". Summoned creature / bound weapons? std::string id = esm.getHString();
if (esm.isNextSub("XNAM")) if (esm.isNextSub("XNAM"))
{ mSelectedEnchantItem = esm.getHString();
// "demon tanto", probably the ID of spell/item that created the bound weapon/crature? else
esm.skipHSub(); mSelectedSpell = id;
}
if (esm.isNextSub("YNAM")) if (esm.isNextSub("YNAM"))
esm.skipHSub(); // 4 byte, 0 esm.skipHSub(); // 4 byte, 0

View file

@ -52,6 +52,9 @@ namespace ESSImport
// to change them ingame // to change them ingame
int mCombatStats[3][2]; int mCombatStats[3][2];
std::string mSelectedSpell;
std::string mSelectedEnchantItem;
SCRI mSCRI; SCRI mSCRI;
void load(ESM::ESMReader& esm); void load(ESM::ESMReader& esm);