mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 12:53:51 +00:00
GetSpellEffects, GetRace
This commit is contained in:
parent
4b830e5c7a
commit
0db48b29c7
5 changed files with 73 additions and 2 deletions
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
#include <components/esm/loadalch.hpp>
|
#include <components/esm/loadalch.hpp>
|
||||||
#include <components/esm/loadspel.hpp>
|
#include <components/esm/loadspel.hpp>
|
||||||
#include <components/esm/loadingr.hpp>
|
#include <components/esm/loadingr.hpp>
|
||||||
|
@ -258,4 +260,18 @@ namespace MWMechanics
|
||||||
|
|
||||||
return scaledDuration-usedUp;
|
return scaledDuration-usedUp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ActiveSpells::isSpellActive(std::string id) const
|
||||||
|
{
|
||||||
|
boost::algorithm::to_lower(id);
|
||||||
|
for (TContainer::iterator iter = mSpells.begin(); iter != mSpells.end(); ++iter)
|
||||||
|
{
|
||||||
|
std::string left = iter->first;
|
||||||
|
boost::algorithm::to_lower(left);
|
||||||
|
|
||||||
|
if (iter->first == id)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,9 @@ namespace MWMechanics
|
||||||
|
|
||||||
void removeSpell (const std::string& id);
|
void removeSpell (const std::string& id);
|
||||||
|
|
||||||
|
bool isSpellActive (std::string id) const;
|
||||||
|
///< case insensitive
|
||||||
|
|
||||||
const MagicEffects& getMagicEffects() const;
|
const MagicEffects& getMagicEffects() const;
|
||||||
|
|
||||||
TIterator begin() const;
|
TIterator begin() const;
|
||||||
|
|
|
@ -266,5 +266,9 @@ op 0x20001d5: HasItemEquipped
|
||||||
op 0x20001d6: HasItemEquipped, explicit
|
op 0x20001d6: HasItemEquipped, explicit
|
||||||
op 0x20001d7: GetWeaponDrawn
|
op 0x20001d7: GetWeaponDrawn
|
||||||
op 0x20001d8: GetWeaponDrawn, explicit
|
op 0x20001d8: GetWeaponDrawn, explicit
|
||||||
opcodes 0x20001d9-0x3ffffff unused
|
op 0x20001d9: GetRace
|
||||||
|
op 0x20001da: GetRace, explicit
|
||||||
|
op 0x20001db: GetSpellEffects
|
||||||
|
op 0x20001dc: GetSpellEffects, explicit
|
||||||
|
opcodes 0x20001dd-0x3ffffff unused
|
||||||
|
|
||||||
|
|
|
@ -332,6 +332,21 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class R>
|
||||||
|
class OpGetSpellEffects : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
std::string id = runtime.getStringLiteral(runtime[0].mInteger);
|
||||||
|
runtime.pop();
|
||||||
|
|
||||||
|
runtime.push(MWWorld::Class::get(ptr).getCreatureStats(ptr).getActiveSpells().isSpellActive(id));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const int opcodeXBox = 0x200000c;
|
const int opcodeXBox = 0x200000c;
|
||||||
const int opcodeOnActivate = 0x200000d;
|
const int opcodeOnActivate = 0x200000d;
|
||||||
const int opcodeActivate = 0x2000075;
|
const int opcodeActivate = 0x2000075;
|
||||||
|
@ -359,6 +374,8 @@ namespace MWScript
|
||||||
const int opcodeGetAttackedExplicit = 0x20001d4;
|
const int opcodeGetAttackedExplicit = 0x20001d4;
|
||||||
const int opcodeGetWeaponDrawn = 0x20001d7;
|
const int opcodeGetWeaponDrawn = 0x20001d7;
|
||||||
const int opcodeGetWeaponDrawnExplicit = 0x20001d8;
|
const int opcodeGetWeaponDrawnExplicit = 0x20001d8;
|
||||||
|
const int opcodeGetSpellEffects = 0x20001db;
|
||||||
|
const int opcodeGetSpellEffectsExplicit = 0x20001dc;
|
||||||
|
|
||||||
void registerExtensions (Compiler::Extensions& extensions)
|
void registerExtensions (Compiler::Extensions& extensions)
|
||||||
{
|
{
|
||||||
|
@ -389,6 +406,7 @@ namespace MWScript
|
||||||
extensions.registerFunction ("geteffect", 'l', "l", opcodeGetEffect, opcodeGetEffectExplicit);
|
extensions.registerFunction ("geteffect", 'l', "l", opcodeGetEffect, opcodeGetEffectExplicit);
|
||||||
extensions.registerFunction ("getattacked", 'l', "", opcodeGetAttacked, opcodeGetAttackedExplicit);
|
extensions.registerFunction ("getattacked", 'l', "", opcodeGetAttacked, opcodeGetAttackedExplicit);
|
||||||
extensions.registerFunction ("getweapondrawn", 'l', "", opcodeGetWeaponDrawn, opcodeGetWeaponDrawnExplicit);
|
extensions.registerFunction ("getweapondrawn", 'l', "", opcodeGetWeaponDrawn, opcodeGetWeaponDrawnExplicit);
|
||||||
|
extensions.registerFunction ("getspelleffects", 'l', "c", opcodeGetSpellEffects, opcodeGetSpellEffectsExplicit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
|
@ -418,8 +436,10 @@ namespace MWScript
|
||||||
interpreter.installSegment5 (opcodeGetEffectExplicit, new OpGetEffect<ExplicitRef>);
|
interpreter.installSegment5 (opcodeGetEffectExplicit, new OpGetEffect<ExplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetAttacked, new OpGetAttacked<ImplicitRef>);
|
interpreter.installSegment5 (opcodeGetAttacked, new OpGetAttacked<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetAttackedExplicit, new OpGetAttacked<ExplicitRef>);
|
interpreter.installSegment5 (opcodeGetAttackedExplicit, new OpGetAttacked<ExplicitRef>);
|
||||||
|
interpreter.installSegment5 (opcodeGetWeaponDrawn, new OpGetWeaponDrawn<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetWeaponDrawnExplicit, new OpGetWeaponDrawn<ExplicitRef>);
|
interpreter.installSegment5 (opcodeGetWeaponDrawnExplicit, new OpGetWeaponDrawn<ExplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetWeaponDrawnExplicit, new OpGetWeaponDrawn<ExplicitRef>);
|
interpreter.installSegment5 (opcodeGetSpellEffects, new OpGetSpellEffects<ImplicitRef>);
|
||||||
|
interpreter.installSegment5 (opcodeGetSpellEffectsExplicit, new OpGetSpellEffects<ExplicitRef>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -780,6 +780,25 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
|
class OpGetRace : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
|
std::string race = runtime.getStringLiteral(runtime[0].mInteger);
|
||||||
|
boost::algorithm::to_lower(race);
|
||||||
|
runtime.pop();
|
||||||
|
|
||||||
|
std::string npcRace = ptr.get<ESM::NPC>()->mBase->mRace;
|
||||||
|
boost::algorithm::to_lower(npcRace);
|
||||||
|
|
||||||
|
runtime.push (npcRace == race);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const int numberOfAttributes = 8;
|
const int numberOfAttributes = 8;
|
||||||
|
|
||||||
|
@ -850,6 +869,9 @@ namespace MWScript
|
||||||
const int opcodeGetBlightDisease = 0x20001aa;
|
const int opcodeGetBlightDisease = 0x20001aa;
|
||||||
const int opcodeGetBlightDiseaseExplicit = 0x20001ab;
|
const int opcodeGetBlightDiseaseExplicit = 0x20001ab;
|
||||||
|
|
||||||
|
const int opcodeGetRace = 0x20001d9;
|
||||||
|
const int opcodeGetRaceExplicit = 0x20001da;
|
||||||
|
|
||||||
void registerExtensions (Compiler::Extensions& extensions)
|
void registerExtensions (Compiler::Extensions& extensions)
|
||||||
{
|
{
|
||||||
static const char *attributes[numberOfAttributes] =
|
static const char *attributes[numberOfAttributes] =
|
||||||
|
@ -950,6 +972,9 @@ namespace MWScript
|
||||||
opcodeGetCommonDiseaseExplicit);
|
opcodeGetCommonDiseaseExplicit);
|
||||||
extensions.registerFunction ("getblightdisease", 'l', "", opcodeGetBlightDisease,
|
extensions.registerFunction ("getblightdisease", 'l', "", opcodeGetBlightDisease,
|
||||||
opcodeGetBlightDiseaseExplicit);
|
opcodeGetBlightDiseaseExplicit);
|
||||||
|
|
||||||
|
extensions.registerFunction ("getrace", 'l', "c", opcodeGetRace,
|
||||||
|
opcodeGetRaceExplicit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
|
@ -1045,6 +1070,9 @@ namespace MWScript
|
||||||
interpreter.installSegment5 (opcodeGetCommonDiseaseExplicit, new OpGetCommonDisease<ExplicitRef>);
|
interpreter.installSegment5 (opcodeGetCommonDiseaseExplicit, new OpGetCommonDisease<ExplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetBlightDisease, new OpGetBlightDisease<ImplicitRef>);
|
interpreter.installSegment5 (opcodeGetBlightDisease, new OpGetBlightDisease<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetBlightDiseaseExplicit, new OpGetBlightDisease<ExplicitRef>);
|
interpreter.installSegment5 (opcodeGetBlightDiseaseExplicit, new OpGetBlightDisease<ExplicitRef>);
|
||||||
|
|
||||||
|
interpreter.installSegment5 (opcodeGetRace, new OpGetRace<ImplicitRef>);
|
||||||
|
interpreter.installSegment5 (opcodeGetRaceExplicit, new OpGetRace<ExplicitRef>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue