Merge pull request #1470 from MiroslavR/convertmprj
ESS-Importer: Convert magic projectilespull/298/head
commit
2494c22d66
@ -0,0 +1,43 @@
|
||||
#include "importsplm.h"
|
||||
|
||||
#include <components/esm/esmreader.hpp>
|
||||
|
||||
namespace ESSImport
|
||||
{
|
||||
|
||||
void SPLM::load(ESM::ESMReader& esm)
|
||||
{
|
||||
while (esm.isNextSub("NAME"))
|
||||
{
|
||||
ActiveSpell spell;
|
||||
esm.getHT(spell.mIndex);
|
||||
esm.getHNT(spell.mSPDT, "SPDT");
|
||||
spell.mTarget = esm.getHNOString("TNAM");
|
||||
|
||||
while (esm.isNextSub("NPDT"))
|
||||
{
|
||||
ActiveEffect effect;
|
||||
esm.getHT(effect.mNPDT);
|
||||
|
||||
// Effect-specific subrecords can follow:
|
||||
// - INAM for disintegration and bound effects
|
||||
// - CNAM for summoning and command effects
|
||||
// - VNAM for vampirism
|
||||
// NOTE: There can be multiple INAMs per effect.
|
||||
// TODO: Needs more research.
|
||||
|
||||
esm.skipHSubUntil("NAM0"); // sentinel
|
||||
esm.getSubName();
|
||||
esm.skipHSub();
|
||||
|
||||
spell.mActiveEffects.push_back(effect);
|
||||
}
|
||||
|
||||
unsigned char xnam; // sentinel
|
||||
esm.getHNT(xnam, "XNAM");
|
||||
|
||||
mActiveSpells.push_back(spell);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
#ifndef OPENMW_ESSIMPORT_IMPORTSPLM_H
|
||||
#define OPENMW_ESSIMPORT_IMPORTSPLM_H
|
||||
|
||||
#include <vector>
|
||||
#include <components/esm/esmcommon.hpp>
|
||||
#include <components/esm/util.hpp>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class ESMReader;
|
||||
}
|
||||
|
||||
namespace ESSImport
|
||||
{
|
||||
|
||||
struct SPLM
|
||||
{
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
struct SPDT // 160 bytes
|
||||
{
|
||||
int mType; // 1 = spell, 2 = enchantment, 3 = potion
|
||||
ESM::NAME32 mId; // base ID of a spell/enchantment/potion
|
||||
unsigned char mUnknown[4*4];
|
||||
ESM::NAME32 mCasterId;
|
||||
ESM::NAME32 mSourceId; // empty for spells
|
||||
unsigned char mUnknown2[4*11];
|
||||
};
|
||||
|
||||
struct NPDT // 56 bytes
|
||||
{
|
||||
ESM::NAME32 mAffectedActorId;
|
||||
unsigned char mUnknown[4*2];
|
||||
int mMagnitude;
|
||||
float mSecondsActive;
|
||||
unsigned char mUnknown2[4*2];
|
||||
};
|
||||
|
||||
struct INAM // 40 bytes
|
||||
{
|
||||
int mUnknown;
|
||||
unsigned char mUnknown2;
|
||||
ESM::FIXED_STRING<35> mItemId; // disintegrated item / bound item / item to re-equip after expiration
|
||||
};
|
||||
|
||||
struct CNAM // 36 bytes
|
||||
{
|
||||
int mUnknown; // seems to always be 0
|
||||
ESM::NAME32 mSummonedOrCommandedActor[32];
|
||||
};
|
||||
|
||||
struct VNAM // 4 bytes
|
||||
{
|
||||
int mUnknown;
|
||||
};
|
||||
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
struct ActiveEffect
|
||||
{
|
||||
NPDT mNPDT;
|
||||
};
|
||||
|
||||
struct ActiveSpell
|
||||
{
|
||||
int mIndex;
|
||||
SPDT mSPDT;
|
||||
std::string mTarget;
|
||||
std::vector<ActiveEffect> mActiveEffects;
|
||||
};
|
||||
|
||||
std::vector<ActiveSpell> mActiveSpells;
|
||||
|
||||
void load(ESM::ESMReader& esm);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue