1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 19:49:56 +00:00

added addspell and removespell script instructions

This commit is contained in:
Marc Zinnschlag 2012-04-13 11:12:53 +02:00
parent 52c7ee3b6a
commit b099e1baf5
2 changed files with 52 additions and 1 deletions

View file

@ -129,4 +129,8 @@ op 0x2000143: ModWaterLevel
op 0x2000144: ToggleWater, twa
op 0x2000145: ToggleFogOfWar (tfow)
op 0x2000146: TogglePathgrid
opcodes 0x2000147-0x3ffffff unused
op 0x2000147: AddSpell
op 0x2000148: AddSpell, explicit reference
op 0x2000149: RemoveSpell
op 0x200014a: RemoveSpell, explicit reference
opcodes 0x200014b-0x3ffffff unused

View file

@ -280,6 +280,38 @@ namespace MWScript
}
};
template<class R>
class OpAddSpell : 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();
MWWorld::Class::get (ptr).getCreatureStats (ptr).mSpells.add (id);
}
};
template<class R>
class OpRemoveSpell : 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();
MWWorld::Class::get (ptr).getCreatureStats (ptr).mSpells.remove (id);
}
};
const int numberOfAttributes = 8;
const int opcodeGetAttribute = 0x2000027;
@ -311,6 +343,11 @@ namespace MWScript
const int opcodeModSkill = 0x20000fa;
const int opcodeModSkillExplicit = 0x2000115;
const int opcodeAddSpell = 0x2000147;
const int opcodeAddSpellExplicit = 0x2000148;
const int opcodeRemoveSpell = 0x2000149;
const int opcodeRemoveSpellExplicit = 0x200014a;
void registerExtensions (Compiler::Extensions& extensions)
{
static const char *attributes[numberOfAttributes] =
@ -381,6 +418,10 @@ namespace MWScript
extensions.registerInstruction (mod + skills[i], "l",
opcodeModSkill+i, opcodeModSkillExplicit+i);
}
extensions.registerInstruction ("addspell", "c", opcodeAddSpell, opcodeAddSpellExplicit);
extensions.registerInstruction ("removespell", "c", opcodeRemoveSpell,
opcodeRemoveSpellExplicit);
}
void installOpcodes (Interpreter::Interpreter& interpreter)
@ -436,6 +477,12 @@ namespace MWScript
interpreter.installSegment5 (opcodeModSkill+i, new OpModSkill<ImplicitRef> (i));
interpreter.installSegment5 (opcodeModSkillExplicit+i, new OpModSkill<ExplicitRef> (i));
}
interpreter.installSegment5 (opcodeAddSpell, new OpAddSpell<ImplicitRef>);
interpreter.installSegment5 (opcodeAddSpellExplicit, new OpAddSpell<ExplicitRef>);
interpreter.installSegment5 (opcodeRemoveSpell, new OpRemoveSpell<ImplicitRef>);
interpreter.installSegment5 (opcodeRemoveSpellExplicit,
new OpRemoveSpell<ExplicitRef>);
}
}
}