diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index dcd97f377a..7e3776e189 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -34,5 +34,6 @@ op 0x2000009: PlayLoopSound3DVP op 0x200000a: StopSound op 0x200000b: GetSoundPlaying op 0x200000c: XBox (always 0) -opcodes 0x200000d-0x3ffffff unused +op 0x200000d: OnActivate +opcodes 0x200000e-0x3ffffff unused diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index b06401a3a9..a2f6663f3b 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -154,6 +154,11 @@ namespace MWScript return std::sqrt (diff[0]*diff[0] + diff[1]*diff[1] + diff[2]*diff[2]); } + bool InterpreterContext::hasBeenActivated() const + { + return false; + } + MWWorld::World& InterpreterContext::getWorld() { return *mEnvironment.mWorld; diff --git a/apps/openmw/mwscript/interpretercontext.hpp b/apps/openmw/mwscript/interpretercontext.hpp index 22cb14e459..21fb35d044 100644 --- a/apps/openmw/mwscript/interpretercontext.hpp +++ b/apps/openmw/mwscript/interpretercontext.hpp @@ -69,6 +69,8 @@ namespace MWScript virtual float getDistance (const std::string& name); + virtual bool hasBeenActivated() const; + MWWorld::World& getWorld(); MWSound::SoundManager& getSoundManager(); diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index e7956c3ad1..3d865d56fa 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -7,6 +7,8 @@ #include #include +#include "interpretercontext.hpp" + namespace MWScript { namespace Misc @@ -21,18 +23,30 @@ namespace MWScript } }; + class OpOnActivate : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + runtime.push (static_cast ( + runtime.getContext()).hasBeenActivated()); + } + }; + const int opcodeXBox = 0x200000c; - - + const int opcodeOnActivate = 0x200000d; void registerExtensions (Compiler::Extensions& extensions) { extensions.registerFunction ("xbox", 'l', "", opcodeXBox); + extensions.registerFunction ("onactivate", 'l', "", opcodeOnActivate); } void installOpcodes (Interpreter::Interpreter& interpreter) { interpreter.installSegment5 (opcodeXBox, new OpXBox); + interpreter.installSegment5 (opcodeOnActivate, new OpOnActivate); } } }