From d7811624d53b49ce7b018ccb0e2f4b39c08c1c2d Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 24 Nov 2012 02:15:55 +0100 Subject: [PATCH] GetEffect --- apps/openmw/mwscript/docs/vmformat.txt | 4 +++- apps/openmw/mwscript/miscextensions.cpp | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 11405cbcbb..365779a9a3 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -256,5 +256,7 @@ op 0x20001cb: GetForceRun op 0x20001cc: GetForceSneak op 0x20001cd: GetForceRun, explicit op 0x20001ce: GetForceSneak, explicit -opcodes 0x20001cd-0x3ffffff unused +op 0x20001cf: GetEffect +op 0x20001d0: GetEffect, explicit +opcodes 0x20001d1-0x3ffffff unused diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 60451c03f7..5a342026e9 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -16,6 +16,7 @@ #include "../mwworld/player.hpp" #include "../mwmechanics/npcstats.hpp" +#include "../mwmechanics/creaturestats.hpp" #include "interpretercontext.hpp" #include "ref.hpp" @@ -340,6 +341,23 @@ namespace MWScript } }; + template + class OpGetEffect : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + int key = runtime[0].mInteger; + runtime.pop(); + + runtime.push (MWWorld::Class::get(ptr).getCreatureStats (ptr).getMagicEffects ().get ( + MWMechanics::EffectKey(key)).mMagnitude > 0); + } + }; + const int opcodeXBox = 0x200000c; const int opcodeOnActivate = 0x200000d; const int opcodeActivate = 0x2000075; @@ -367,6 +385,8 @@ namespace MWScript const int opcodeGetForceSneak = 0x20001cc; const int opcodeGetForceRunExplicit = 0x20001cd; const int opcodeGetForceSneakExplicit = 0x20001ce; + const int opcodeGetEffect = 0x20001cf; + const int opcodeGetEffectExplicit = 0x20001d0; void registerExtensions (Compiler::Extensions& extensions) { @@ -398,6 +418,7 @@ namespace MWScript extensions.registerFunction ("getpcsneaking", 'l', "", opcodeGetPcSneaking); extensions.registerFunction ("getforcerun", 'l', "", opcodeGetForceRun, opcodeGetForceRunExplicit); extensions.registerFunction ("getforcesneak", 'l', "", opcodeGetForceSneak, opcodeGetForceSneakExplicit); + extensions.registerFunction ("geteffect", 'l', "l", opcodeGetEffect, opcodeGetEffectExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -429,6 +450,8 @@ namespace MWScript interpreter.installSegment5 (opcodeGetForceRunExplicit, new OpGetForceRun); interpreter.installSegment5 (opcodeGetForceSneak, new OpGetForceSneak); interpreter.installSegment5 (opcodeGetForceSneakExplicit, new OpGetForceSneak); + interpreter.installSegment5 (opcodeGetEffect, new OpGetEffect); + interpreter.installSegment5 (opcodeGetEffectExplicit, new OpGetEffect); } } }