forked from teamnwah/openmw-tes3coop
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());
|
||||
for (unsigned int i=0; i<random.size();++i)
|
||||
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)
|
||||
{
|
||||
TContainer::iterator iter = mSpells.find (spellId);
|
||||
std::string lower = Misc::StringUtils::lowerCase(spellId);
|
||||
TContainer::iterator iter = mSpells.find (lower);
|
||||
|
||||
if (iter!=mSpells.end())
|
||||
mSpells.erase (iter);
|
||||
|
|
|
@ -364,4 +364,6 @@ op 0x2000229: ExplodeSpell
|
|||
op 0x200022a: ExplodeSpell, explicit
|
||||
op 0x200022b: RemoveSpellEffects
|
||||
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>
|
||||
class OpGetSpell : public Interpreter::Opcode0
|
||||
{
|
||||
|
@ -1155,6 +1171,10 @@ namespace MWScript
|
|||
interpreter.installSegment5 (Compiler::Stats::opcodeRemoveSpellEffectsExplicit,
|
||||
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::opcodeGetSpellExplicit, new OpGetSpell<ExplicitRef>);
|
||||
|
||||
|
|
|
@ -393,6 +393,8 @@ namespace Compiler
|
|||
opcodeRemoveSpellExplicit);
|
||||
extensions.registerInstruction ("removespelleffects", "c", opcodeRemoveSpellEffects,
|
||||
opcodeRemoveSpellEffectsExplicit);
|
||||
extensions.registerInstruction ("removeeffects", "l", opcodeRemoveEffects,
|
||||
opcodeRemoveEffectsExplicit);
|
||||
extensions.registerFunction ("getspell", 'l', "c", opcodeGetSpell, opcodeGetSpellExplicit);
|
||||
|
||||
extensions.registerInstruction("pcraiserank","/S",opcodePCRaiseRank);
|
||||
|
|
|
@ -372,6 +372,8 @@ namespace Compiler
|
|||
|
||||
const int opcodeRemoveSpellEffects = 0x200022b;
|
||||
const int opcodeRemoveSpellEffectsExplicit = 0x200022c;
|
||||
const int opcodeRemoveEffects = 0x200022d;
|
||||
const int opcodeRemoveEffectsExplicit = 0x200022e;
|
||||
}
|
||||
|
||||
namespace Transformation
|
||||
|
|
Loading…
Reference in a new issue