mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-06 10:45:33 +00:00
Implement RemoveEffects instruction
This commit is contained in:
parent
7d8ca91286
commit
b4230f716e
5 changed files with 30 additions and 3 deletions
|
@ -34,13 +34,14 @@ namespace MWMechanics
|
||||||
random.resize(spell->mEffects.mList.size());
|
random.resize(spell->mEffects.mList.size());
|
||||||
for (unsigned int i=0; i<random.size();++i)
|
for (unsigned int i=0; i<random.size();++i)
|
||||||
random[i] = static_cast<float> (std::rand()) / RAND_MAX;
|
random[i] = static_cast<float> (std::rand()) / RAND_MAX;
|
||||||
mSpells.insert (std::make_pair (spellId, random));
|
mSpells.insert (std::make_pair (Misc::StringUtils::lowerCase(spellId), random));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spells::remove (const std::string& spellId)
|
void Spells::remove (const std::string& spellId)
|
||||||
{
|
{
|
||||||
TContainer::iterator iter = mSpells.find (spellId);
|
std::string lower = Misc::StringUtils::lowerCase(spellId);
|
||||||
|
TContainer::iterator iter = mSpells.find (lower);
|
||||||
|
|
||||||
if (iter!=mSpells.end())
|
if (iter!=mSpells.end())
|
||||||
mSpells.erase (iter);
|
mSpells.erase (iter);
|
||||||
|
|
|
@ -364,4 +364,6 @@ op 0x2000229: ExplodeSpell
|
||||||
op 0x200022a: ExplodeSpell, explicit
|
op 0x200022a: ExplodeSpell, explicit
|
||||||
op 0x200022b: RemoveSpellEffects
|
op 0x200022b: RemoveSpellEffects
|
||||||
op 0x200022c: RemoveSpellEffects, explicit
|
op 0x200022c: RemoveSpellEffects, explicit
|
||||||
opcodes 0x200022d-0x3ffffff unused
|
op 0x200022d: RemoveEffects
|
||||||
|
op 0x200022e: RemoveEffects, explicit
|
||||||
|
opcodes 0x200022f-0x3ffffff unused
|
||||||
|
|
|
@ -475,6 +475,22 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
|
class OpRemoveEffects : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
|
Interpreter::Type_Integer effectId = runtime[0].mInteger;
|
||||||
|
runtime.pop();
|
||||||
|
|
||||||
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).getActiveSpells().purgeEffect(effectId);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template<class R>
|
template<class R>
|
||||||
class OpGetSpell : public Interpreter::Opcode0
|
class OpGetSpell : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
|
@ -1155,6 +1171,10 @@ namespace MWScript
|
||||||
interpreter.installSegment5 (Compiler::Stats::opcodeRemoveSpellEffectsExplicit,
|
interpreter.installSegment5 (Compiler::Stats::opcodeRemoveSpellEffectsExplicit,
|
||||||
new OpRemoveSpellEffects<ExplicitRef>);
|
new OpRemoveSpellEffects<ExplicitRef>);
|
||||||
|
|
||||||
|
interpreter.installSegment5 (Compiler::Stats::opcodeRemoveEffects, new OpRemoveEffects<ImplicitRef>);
|
||||||
|
interpreter.installSegment5 (Compiler::Stats::opcodeRemoveEffectsExplicit,
|
||||||
|
new OpRemoveEffects<ExplicitRef>);
|
||||||
|
|
||||||
interpreter.installSegment5 (Compiler::Stats::opcodeGetSpell, new OpGetSpell<ImplicitRef>);
|
interpreter.installSegment5 (Compiler::Stats::opcodeGetSpell, new OpGetSpell<ImplicitRef>);
|
||||||
interpreter.installSegment5 (Compiler::Stats::opcodeGetSpellExplicit, new OpGetSpell<ExplicitRef>);
|
interpreter.installSegment5 (Compiler::Stats::opcodeGetSpellExplicit, new OpGetSpell<ExplicitRef>);
|
||||||
|
|
||||||
|
|
|
@ -393,6 +393,8 @@ namespace Compiler
|
||||||
opcodeRemoveSpellExplicit);
|
opcodeRemoveSpellExplicit);
|
||||||
extensions.registerInstruction ("removespelleffects", "c", opcodeRemoveSpellEffects,
|
extensions.registerInstruction ("removespelleffects", "c", opcodeRemoveSpellEffects,
|
||||||
opcodeRemoveSpellEffectsExplicit);
|
opcodeRemoveSpellEffectsExplicit);
|
||||||
|
extensions.registerInstruction ("removeeffects", "l", opcodeRemoveEffects,
|
||||||
|
opcodeRemoveEffectsExplicit);
|
||||||
extensions.registerFunction ("getspell", 'l', "c", opcodeGetSpell, opcodeGetSpellExplicit);
|
extensions.registerFunction ("getspell", 'l', "c", opcodeGetSpell, opcodeGetSpellExplicit);
|
||||||
|
|
||||||
extensions.registerInstruction("pcraiserank","/S",opcodePCRaiseRank);
|
extensions.registerInstruction("pcraiserank","/S",opcodePCRaiseRank);
|
||||||
|
|
|
@ -372,6 +372,8 @@ namespace Compiler
|
||||||
|
|
||||||
const int opcodeRemoveSpellEffects = 0x200022b;
|
const int opcodeRemoveSpellEffects = 0x200022b;
|
||||||
const int opcodeRemoveSpellEffectsExplicit = 0x200022c;
|
const int opcodeRemoveSpellEffectsExplicit = 0x200022c;
|
||||||
|
const int opcodeRemoveEffects = 0x200022d;
|
||||||
|
const int opcodeRemoveEffectsExplicit = 0x200022e;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Transformation
|
namespace Transformation
|
||||||
|
|
Loading…
Reference in a new issue