mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 14:56:38 +00:00 
			
		
		
		
	first try of the Position script instruction. Still missing: check if overlapp with an object.
This commit is contained in:
		
							parent
							
								
									d850a3ee49
								
							
						
					
					
						commit
						8a485e213b
					
				
					 1 changed files with 36 additions and 0 deletions
				
			
		|  | @ -196,6 +196,37 @@ namespace MWScript | |||
|                 } | ||||
|         }; | ||||
| 
 | ||||
|         template<class R> | ||||
|         class OpPosition : public Interpreter::Opcode0 | ||||
|         { | ||||
|             public: | ||||
| 
 | ||||
|                 virtual void execute (Interpreter::Runtime& runtime) | ||||
|                 { | ||||
|                     MWWorld::Ptr ptr = R()(runtime); | ||||
| 
 | ||||
|                     Interpreter::Type_Float x = runtime[0].mFloat; | ||||
|                     runtime.pop(); | ||||
|                     Interpreter::Type_Float y = runtime[0].mFloat; | ||||
|                     runtime.pop(); | ||||
|                     Interpreter::Type_Float z = runtime[0].mFloat; | ||||
|                     runtime.pop(); | ||||
|                     Interpreter::Type_Float zRot = runtime[0].mFloat; | ||||
|                     runtime.pop(); | ||||
| 
 | ||||
|                     MWBase::Environment::get().getWorld()->moveObject(ptr,x,y,z); | ||||
|                     float ax = Ogre::Radian(ptr.getRefData().getPosition().rot[0]).valueDegrees(); | ||||
|                     float ay = Ogre::Radian(ptr.getRefData().getPosition().rot[1]).valueDegrees(); | ||||
|                     if(ptr.getTypeName() == "struct ESM::NPC")//some morrowind oddity
 | ||||
|                     { | ||||
|                         ax = ax/60.; | ||||
|                         ay = ay/60.; | ||||
|                         zRot = zRot/60.; | ||||
|                     } | ||||
|                     MWBase::Environment::get().getWorld()->rotateObject(ptr,ax,ay,zRot); | ||||
|                 } | ||||
|         }; | ||||
| 
 | ||||
|         const int opcodeSetScale = 0x2000164; | ||||
|         const int opcodeSetScaleExplicit = 0x2000165; | ||||
|         const int opcodeSetAngle = 0x2000166; | ||||
|  | @ -210,6 +241,8 @@ namespace MWScript | |||
|         const int opcodeSetPosExplicit = 0x200016f; | ||||
|         const int opcodeGetStartingPos = 0x2000170; | ||||
|         const int opcodeGetStartingPosExplicit = 0x2000171; | ||||
|         const int opcodePosition = 0x2000172; | ||||
|         const int opcodePositionExplicit = 0x2000173; | ||||
| 
 | ||||
|         void registerExtensions (Compiler::Extensions& extensions) | ||||
|         { | ||||
|  | @ -220,6 +253,7 @@ namespace MWScript | |||
|             extensions.registerInstruction("setpos","cf",opcodeSetPos,opcodeSetPosExplicit); | ||||
|             extensions.registerFunction("getpos",'f',"c",opcodeGetPos,opcodeGetPosExplicit); | ||||
|             extensions.registerFunction("getstartingpos",'f',"c",opcodeGetStartingPos,opcodeGetStartingPosExplicit); | ||||
|             extensions.registerInstruction("position","ffff",opcodePosition,opcodePositionExplicit); | ||||
|         } | ||||
| 
 | ||||
|         void installOpcodes (Interpreter::Interpreter& interpreter) | ||||
|  | @ -238,6 +272,8 @@ namespace MWScript | |||
|             interpreter.installSegment5(opcodeSetPosExplicit,new OpSetPos<ExplicitRef>); | ||||
|             interpreter.installSegment5(opcodeGetStartingPos,new OpGetStartingPos<ImplicitRef>); | ||||
|             interpreter.installSegment5(opcodeGetStartingPosExplicit,new OpGetStartingPos<ExplicitRef>); | ||||
|             interpreter.installSegment5(opcodePosition,new OpPosition<ImplicitRef>); | ||||
|             interpreter.installSegment5(opcodePositionExplicit,new OpPosition<ExplicitRef>); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue