From 1174b85ac8de0cb15e7f2d9c8079dc80494d6974 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 27 Jul 2013 00:14:55 -0700 Subject: [PATCH] Implement Disable/EnableTeleporting script functions --- apps/openmw/mwbase/world.hpp | 6 ++++++ apps/openmw/mwscript/docs/vmformat.txt | 4 +++- apps/openmw/mwscript/miscextensions.cpp | 19 +++++++++++++++++++ apps/openmw/mwworld/worldimp.cpp | 13 ++++++++++++- apps/openmw/mwworld/worldimp.hpp | 8 ++++++++ 5 files changed, 48 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index b9033daac..dd069bfa9 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -376,6 +376,12 @@ namespace MWBase /// Find default position inside interior cell specified by name /// \return false if interior with given name not exists, true otherwise virtual bool findInteriorPosition(const std::string &name, ESM::Position &pos) = 0; + + /// Enables or disables use of teleport spell effects (recall, intervention, etc). + virtual void enableTeleporting(bool enable) = 0; + + /// Returns true if teleport spell effects are allowed. + virtual bool isTeleportingEnabled() const = 0; }; } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 1b8682542..772069d05 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -340,5 +340,7 @@ op 0x2000211: GetStartingAngle, explicit op 0x2000212: GetWindSpeed op 0x2000213: HitOnMe op 0x2000214: HitOnMe, explicit +op 0x2000215: DisableTeleporting +op 0x2000216: EnableTeleporting -opcodes 0x2000215-0x3ffffff unused +opcodes 0x2000217-0x3ffffff unused diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 453f6fbba..6b1adc938 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -616,6 +616,18 @@ namespace MWScript } }; + template + class OpEnableTeleporting : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWBase::World *world = MWBase::Environment::get().getWorld(); + world->enableTeleporting(Enable); + } + }; + const int opcodeXBox = 0x200000c; const int opcodeOnActivate = 0x200000d; const int opcodeActivate = 0x2000075; @@ -670,6 +682,9 @@ namespace MWScript const int opcodeHitOnMe = 0x2000213; const int opcodeHitOnMeExplicit = 0x2000214; + const int opcodeDisableTeleporting = 0x2000215; + const int opcodeEnableTeleporting = 0x2000216; + void registerExtensions (Compiler::Extensions& extensions) { extensions.registerFunction ("xbox", 'l', "", opcodeXBox); @@ -713,6 +728,8 @@ namespace MWScript extensions.registerFunction ("getstandingactor", 'l', "", opcodeGetStandingActor, opcodeGetStandingActorExplicit); extensions.registerFunction ("getwindspeed", 'f', "", opcodeGetWindSpeed); extensions.registerFunction ("hitonme", 'l', "S", opcodeHitOnMe, opcodeHitOnMeExplicit); + extensions.registerInstruction ("disableteleporting", "", opcodeDisableTeleporting); + extensions.registerInstruction ("enableteleporting", "", opcodeEnableTeleporting); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -768,6 +785,8 @@ namespace MWScript interpreter.installSegment5 (opcodeGetWindSpeed, new OpGetWindSpeed); interpreter.installSegment5 (opcodeHitOnMe, new OpHitOnMe); interpreter.installSegment5 (opcodeHitOnMeExplicit, new OpHitOnMe); + interpreter.installSegment5 (opcodeDisableTeleporting, new OpEnableTeleporting); + interpreter.installSegment5 (opcodeEnableTeleporting, new OpEnableTeleporting); } } } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index cf651a2e7..70eda2429 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -166,7 +166,7 @@ namespace MWWorld : mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0), mSky (true), mCells (mStore, mEsm), mNumFacing(0), mActivationDistanceOverride (mActivationDistanceOverride), - mFallback(fallbackMap), mPlayIntro(0) + mFallback(fallbackMap), mPlayIntro(0), mTeleportEnabled(true) { mPhysics = new PhysicsSystem(renderer); mPhysEngine = mPhysics->getEngine(); @@ -1844,4 +1844,15 @@ namespace MWWorld } return false; } + + void World::enableTeleporting(bool enable) + { + mTeleportEnabled = enable; + } + + bool World::isTeleportingEnabled() const + { + return mTeleportEnabled; + } + } diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 45cb1f61e..8a30e970d 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -117,6 +117,8 @@ namespace MWWorld int mPlayIntro; + bool mTeleportEnabled; + public: World (OEngine::Render::OgreRenderer& renderer, @@ -425,6 +427,12 @@ namespace MWWorld /// Find position in interior cell near door entrance /// \return false if interior with given name not exists, true otherwise virtual bool findInteriorPosition(const std::string &name, ESM::Position &pos); + + /// Enables or disables use of teleport spell effects (recall, intervention, etc). + virtual void enableTeleporting(bool enable); + + /// Returns true if teleport spell effects are allowed. + virtual bool isTeleportingEnabled() const; }; }