mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 15:35:23 +00:00
added GetSpell script function
This commit is contained in:
parent
37f478b69a
commit
e16daeed23
@ -133,4 +133,6 @@ op 0x2000147: AddSpell
|
||||
op 0x2000148: AddSpell, explicit reference
|
||||
op 0x2000149: RemoveSpell
|
||||
op 0x200014a: RemoveSpell, explicit reference
|
||||
opcodes 0x200014b-0x3ffffff unused
|
||||
op 0x200014b: GetSpell
|
||||
op 0x200014c: GetSpell, explicit reference
|
||||
opcodes 0x200014d-0x3ffffff unused
|
||||
|
@ -312,6 +312,33 @@ namespace MWScript
|
||||
}
|
||||
};
|
||||
|
||||
template<class R>
|
||||
class OpGetSpell : 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();
|
||||
|
||||
Interpreter::Type_Integer value = 0;
|
||||
|
||||
for (MWMechanics::Spells::TIterator iter (
|
||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mSpells.begin());
|
||||
iter!=MWWorld::Class::get (ptr).getCreatureStats (ptr).mSpells.end(); ++iter)
|
||||
if (*iter==id)
|
||||
{
|
||||
value = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
runtime.push (value);
|
||||
}
|
||||
};
|
||||
|
||||
const int numberOfAttributes = 8;
|
||||
|
||||
const int opcodeGetAttribute = 0x2000027;
|
||||
@ -347,6 +374,8 @@ namespace MWScript
|
||||
const int opcodeAddSpellExplicit = 0x2000148;
|
||||
const int opcodeRemoveSpell = 0x2000149;
|
||||
const int opcodeRemoveSpellExplicit = 0x200014a;
|
||||
const int opcodeGetSpell = 0x200014b;
|
||||
const int opcodeGetSpellExplicit = 0x200014c;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
@ -422,6 +451,7 @@ namespace MWScript
|
||||
extensions.registerInstruction ("addspell", "c", opcodeAddSpell, opcodeAddSpellExplicit);
|
||||
extensions.registerInstruction ("removespell", "c", opcodeRemoveSpell,
|
||||
opcodeRemoveSpellExplicit);
|
||||
extensions.registerFunction ("getspell", 'l', "c", opcodeGetSpell, opcodeGetSpellExplicit);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
@ -483,6 +513,8 @@ namespace MWScript
|
||||
interpreter.installSegment5 (opcodeRemoveSpell, new OpRemoveSpell<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeRemoveSpellExplicit,
|
||||
new OpRemoveSpell<ExplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetSpell, new OpGetSpell<ImplicitRef>);
|
||||
interpreter.installSegment5 (opcodeGetSpellExplicit, new OpGetSpell<ExplicitRef>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user