From b2ce1dfd1ab10f1a12f42576d9611cca8a570b29 Mon Sep 17 00:00:00 2001 From: gugus Date: Fri, 3 Aug 2012 18:20:51 +0200 Subject: [PATCH] getStartingPos --- .../mwscript/transformationextensions.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index 42ef16ed9..1eb53e8f3 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -169,6 +169,33 @@ namespace MWScript } }; + template + class OpGetStartingPos : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + std::string axis = runtime.getStringLiteral (runtime[0].mInteger); + runtime.pop(); + + if(axis == "X") + { + runtime.push(ptr.getCellRef().pos.pos[0]); + } + if(axis == "Y") + { + runtime.push(ptr.getCellRef().pos.pos[1]); + } + if(axis == "Z") + { + runtime.push(ptr.getCellRef().pos.pos[2]); + } + } + }; + const int opcodeSetScale = 0x2000164; const int opcodeSetScaleExplicit = 0x2000165; const int opcodeSetAngle = 0x2000166; @@ -181,6 +208,8 @@ namespace MWScript const int opcodeGetPosExplicit = 0x200016d; const int opcodeSetPos = 0x200016e; const int opcodeSetPosExplicit = 0x200016f; + const int opcodeGetStartingPos = 0x2000170; + const int opcodeGetStartingPosExplicit = 0x2000171; void registerExtensions (Compiler::Extensions& extensions) { @@ -190,6 +219,7 @@ namespace MWScript extensions.registerFunction("getangle",'f',"S",opcodeGetAngle,opcodeGetAngleExplicit); extensions.registerInstruction("setpos","Sf",opcodeSetPos,opcodeSetPosExplicit); extensions.registerFunction("getpos",'f',"S",opcodeGetPos,opcodeGetPosExplicit); + extensions.registerFunction("getstartingpos",'f',"S",opcodeGetStartingPos,opcodeGetStartingPosExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -206,6 +236,8 @@ namespace MWScript interpreter.installSegment5(opcodeGetPosExplicit,new OpGetPos); interpreter.installSegment5(opcodeSetPos,new OpSetPos); interpreter.installSegment5(opcodeSetPosExplicit,new OpSetPos); + interpreter.installSegment5(opcodeGetStartingPos,new OpGetStartingPos); + interpreter.installSegment5(opcodeGetStartingPosExplicit,new OpGetStartingPos); } } }