Implement IsWerewolf script function

This commit is contained in:
Chris Robinson 2013-03-30 13:20:51 -07:00
parent ee5d0277e8
commit c8606d2f63
2 changed files with 23 additions and 1 deletions

View file

@ -316,5 +316,7 @@ op 0x20001f9: Drop, explicit reference
op 0x20001fa: DropSoulGem op 0x20001fa: DropSoulGem
op 0x20001fb: DropSoulGem, explicit reference op 0x20001fb: DropSoulGem, explicit reference
op 0x20001fc: OnDeath op 0x20001fc: OnDeath
op 0x20001fd: IsWerewolf
op 0x20001fe: IsWerewolf, explicit reference
opcodes 0x20001fd-0x3ffffff unused opcodes 0x20001ff-0x3ffffff unused

View file

@ -1046,6 +1046,18 @@ namespace MWScript
} }
}; };
template <class R>
class OpIsWerewolf : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
MWWorld::Ptr ptr = R()(runtime);
runtime.push(MWWorld::Class::get(ptr).getNpcStats(ptr).isWerewolf());
}
};
const int numberOfAttributes = 8; const int numberOfAttributes = 8;
const int opcodeGetAttribute = 0x2000027; const int opcodeGetAttribute = 0x2000027;
@ -1137,6 +1149,9 @@ namespace MWScript
const int opcodeOnDeath = 0x20001fc; const int opcodeOnDeath = 0x20001fc;
const int opcodeIsWerewolf = 0x20001fd;
const int opcodeIsWerewolfExplicit = 0x20001fe;
void registerExtensions (Compiler::Extensions& extensions) void registerExtensions (Compiler::Extensions& extensions)
{ {
static const char *attributes[numberOfAttributes] = static const char *attributes[numberOfAttributes] =
@ -1252,6 +1267,8 @@ namespace MWScript
extensions.registerInstruction ("lowerrank", "", opcodeLowerRank, opcodeLowerRankExplicit); extensions.registerInstruction ("lowerrank", "", opcodeLowerRank, opcodeLowerRankExplicit);
extensions.registerFunction ("ondeath", 'l', "", opcodeOnDeath); extensions.registerFunction ("ondeath", 'l', "", opcodeOnDeath);
extensions.registerFunction ("iswerewolf", 'l', "", opcodeIsWerewolf, opcodeIsWerewolfExplicit);
} }
void installOpcodes (Interpreter::Interpreter& interpreter) void installOpcodes (Interpreter::Interpreter& interpreter)
@ -1368,6 +1385,9 @@ namespace MWScript
interpreter.installSegment5 (opcodeLowerRankExplicit, new OpLowerRank<ExplicitRef>); interpreter.installSegment5 (opcodeLowerRankExplicit, new OpLowerRank<ExplicitRef>);
interpreter.installSegment5 (opcodeOnDeath, new OpOnDeath); interpreter.installSegment5 (opcodeOnDeath, new OpOnDeath);
interpreter.installSegment5 (opcodeIsWerewolf, new OpIsWerewolf<ImplicitRef>);
interpreter.installSegment5 (opcodeIsWerewolfExplicit, new OpIsWerewolf<ExplicitRef>);
} }
} }
} }