forked from mirror/openmw-tes3mp
		
	Implement Disable/EnableTeleporting script functions
This commit is contained in:
		
							parent
							
								
									3298eb1b37
								
							
						
					
					
						commit
						1174b85ac8
					
				
					 5 changed files with 48 additions and 2 deletions
				
			
		|  | @ -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; | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -616,6 +616,18 @@ namespace MWScript | |||
|                 } | ||||
|         }; | ||||
| 
 | ||||
|         template <bool Enable> | ||||
|         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<ImplicitRef>); | ||||
|             interpreter.installSegment5 (opcodeHitOnMeExplicit, new OpHitOnMe<ExplicitRef>); | ||||
|             interpreter.installSegment5 (opcodeDisableTeleporting, new OpEnableTeleporting<false>); | ||||
|             interpreter.installSegment5 (opcodeEnableTeleporting, new OpEnableTeleporting<true>); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -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; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -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; | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue