diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index bd87f8b4b..37981acf8 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -1053,10 +1053,12 @@ namespace MWMechanics //KnockedOutOneFrameLogic //Used for "OnKnockedOut" command //Put here to ensure that it's run for PRECISELY one frame. - if (stats.getKnockedDown() && !stats.getKnockedDownOneFrame() && !stats.getKnockedDownOverOneFrame()) { //Start it for one frame if nessesary + if (stats.getKnockedDown() && !stats.getKnockedDownOneFrame() && !stats.getKnockedDownOverOneFrame()) + { //Start it for one frame if nessesary stats.setKnockedDownOneFrame(true); } - else if (stats.getKnockedDownOneFrame() && !stats.getKnockedDownOverOneFrame()) { //Turn off KnockedOutOneframe + else if (stats.getKnockedDownOneFrame() && !stats.getKnockedDownOverOneFrame()) + { //Turn off KnockedOutOneframe stats.setKnockedDownOneFrame(false); stats.setKnockedDownOverOneFrame(true); } diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 0809cd640..0e2acacd9 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1174,6 +1174,37 @@ void CharacterController::update(float duration) bool isrunning = cls.getCreatureStats(mPtr).getStance(MWMechanics::CreatureStats::Stance_Run); bool sneak = cls.getCreatureStats(mPtr).getStance(MWMechanics::CreatureStats::Stance_Sneak); bool flying = world->isFlying(mPtr); + CreatureStats &stats = cls.getCreatureStats(mPtr); + + //Force Jump Logic + + bool isMoving = (std::abs(cls.getMovementSettings(mPtr).mPosition[0]) > .5 || abs(cls.getMovementSettings(mPtr).mPosition[1]) > .5); + if(!inwater && !flying) + { + //Force Jump + if(stats.getMovementFlag(MWMechanics::CreatureStats::Flag_ForceJump)) + { + if(onground) + { + cls.getMovementSettings(mPtr).mPosition[2] = 1; + } + else + cls.getMovementSettings(mPtr).mPosition[2] = 0; + } + //Force Move Jump, only jump if they're otherwise moving + std::cout << isMoving << std::endl; + if(stats.getMovementFlag(MWMechanics::CreatureStats::Flag_ForceMoveJump) && isMoving) + { + + if(onground) + { + cls.getMovementSettings(mPtr).mPosition[2] = 1; + } + else + cls.getMovementSettings(mPtr).mPosition[2] = 0; + } + } + //Ogre::Vector3 vec = cls.getMovementVector(mPtr); Ogre::Vector3 vec(cls.getMovementSettings(mPtr).mPosition); if(vec.z > 0.0f) // to avoid slow-down when jumping @@ -1183,7 +1214,7 @@ void CharacterController::update(float duration) vec.x = vecXY.x; vec.y = vecXY.y; } - else + else vec.normalise(); if(mHitState != CharState_None && mJumpState == JumpState_None) @@ -1352,8 +1383,7 @@ void CharacterController::update(float duration) } else { - if(!(vec.z > 0.0f)) - mJumpState = JumpState_None; + mJumpState = JumpState_None; vec.z = 0.0f; inJump = false; diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index 4ee994de5..a36d28fd3 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -227,7 +227,9 @@ namespace MWMechanics Flag_ForceRun = 1, Flag_ForceSneak = 2, Flag_Run = 4, - Flag_Sneak = 8 + Flag_Sneak = 8, + Flag_ForceJump = 16, + Flag_ForceMoveJump = 32 }; enum Stance { diff --git a/apps/openmw/mwscript/controlextensions.cpp b/apps/openmw/mwscript/controlextensions.cpp index d2e774859..fb6b73be6 100644 --- a/apps/openmw/mwscript/controlextensions.cpp +++ b/apps/openmw/mwscript/controlextensions.cpp @@ -121,6 +121,34 @@ namespace MWScript } }; + template + class OpGetForceJump : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats (ptr); + runtime.push (stats.getMovementFlag (MWMechanics::CreatureStats::Flag_ForceJump)); + } + }; + + template + class OpGetForceMoveJump : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats (ptr); + runtime.push (stats.getMovementFlag (MWMechanics::CreatureStats::Flag_ForceMoveJump)); + } + }; + template class OpGetForceSneak : public Interpreter::Opcode0 { @@ -169,27 +197,54 @@ namespace MWScript interpreter.installSegment5 (Compiler::Control::opcodeToggleCollision, new OpToggleCollision); + //Force Run interpreter.installSegment5 (Compiler::Control::opcodeClearForceRun, new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceRun)); - interpreter.installSegment5 (Compiler::Control::opcodeForceRun, - new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceRun)); - interpreter.installSegment5 (Compiler::Control::opcodeClearForceSneak, - new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceSneak)); - interpreter.installSegment5 (Compiler::Control::opcodeForceSneak, - new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceSneak)); - interpreter.installSegment5 (Compiler::Control::opcodeClearForceRunExplicit, new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceRun)); + interpreter.installSegment5 (Compiler::Control::opcodeForceRun, + new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceRun)); interpreter.installSegment5 (Compiler::Control::opcodeForceRunExplicit, new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceRun)); + + //Force Jump + interpreter.installSegment5 (Compiler::Control::opcodeClearForceJump, + new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceJump)); + interpreter.installSegment5 (Compiler::Control::opcodeClearForceJumpExplicit, + new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceJump)); + interpreter.installSegment5 (Compiler::Control::opcodeForceJump, + new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceJump)); + interpreter.installSegment5 (Compiler::Control::opcodeForceJumpExplicit, + new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceJump)); + + //Force MoveJump + interpreter.installSegment5 (Compiler::Control::opcodeClearForceMoveJump, + new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceMoveJump)); + interpreter.installSegment5 (Compiler::Control::opcodeClearForceMoveJumpExplicit, + new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceMoveJump)); + interpreter.installSegment5 (Compiler::Control::opcodeForceMoveJump, + new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceMoveJump)); + interpreter.installSegment5 (Compiler::Control::opcodeForceMoveJumpExplicit, + new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceMoveJump)); + + //Force Sneak + interpreter.installSegment5 (Compiler::Control::opcodeClearForceSneak, + new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceSneak)); interpreter.installSegment5 (Compiler::Control::opcodeClearForceSneakExplicit, new OpClearMovementFlag (MWMechanics::CreatureStats::Flag_ForceSneak)); + interpreter.installSegment5 (Compiler::Control::opcodeForceSneak, + new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceSneak)); interpreter.installSegment5 (Compiler::Control::opcodeForceSneakExplicit, new OpSetMovementFlag (MWMechanics::CreatureStats::Flag_ForceSneak)); + interpreter.installSegment5 (Compiler::Control::opcodeGetPcRunning, new OpGetPcRunning); interpreter.installSegment5 (Compiler::Control::opcodeGetPcSneaking, new OpGetPcSneaking); interpreter.installSegment5 (Compiler::Control::opcodeGetForceRun, new OpGetForceRun); interpreter.installSegment5 (Compiler::Control::opcodeGetForceRunExplicit, new OpGetForceRun); + interpreter.installSegment5 (Compiler::Control::opcodeGetForceJump, new OpGetForceJump); + interpreter.installSegment5 (Compiler::Control::opcodeGetForceJumpExplicit, new OpGetForceJump); + interpreter.installSegment5 (Compiler::Control::opcodeGetForceMoveJump, new OpGetForceMoveJump); + interpreter.installSegment5 (Compiler::Control::opcodeGetForceMoveJumpExplicit, new OpGetForceMoveJump); interpreter.installSegment5 (Compiler::Control::opcodeGetForceSneak, new OpGetForceSneak); interpreter.installSegment5 (Compiler::Control::opcodeGetForceSneakExplicit, new OpGetForceSneak); } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 4b501b20f..f600117a9 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -413,5 +413,13 @@ op 0x2000254: HurtStandingActor op 0x2000255: HurtStandingActor, explicit op 0x2000256: HurtCollidingActor op 0x2000257: HurtCollidingActor, explicit +op 0x2000258: ClearForceJump +op 0x2000259: ClearForceJump, explicit reference +op 0x200025a: ForceJump +op 0x200025b: ForceJump, explicit reference +op 0x200025c: ClearForceMoveJump +op 0x200025d: ClearForceMoveJump, explicit reference +op 0x200025e: ForceMoveJump +op 0x200025f: ForceMoveJump, explicit reference -opcodes 0x2000258-0x3ffffff unused +opcodes 0x2000260-0x3ffffff unused diff --git a/components/compiler/extensions0.cpp b/components/compiler/extensions0.cpp index bb377a0dc..1aa50249e 100644 --- a/components/compiler/extensions0.cpp +++ b/components/compiler/extensions0.cpp @@ -148,6 +148,16 @@ namespace Compiler extensions.registerInstruction ("forcerun", "", opcodeForceRun, opcodeForceRunExplicit); + extensions.registerInstruction ("clearforcejump", "", opcodeClearForceJump, + opcodeClearForceJumpExplicit); + extensions.registerInstruction ("forcejump", "", opcodeForceJump, + opcodeForceJumpExplicit); + + extensions.registerInstruction ("clearforcemovejump", "", opcodeClearForceMoveJump, + opcodeClearForceMoveJumpExplicit); + extensions.registerInstruction ("forcemovejump", "", opcodeForceMoveJump, + opcodeForceMoveJumpExplicit); + extensions.registerInstruction ("clearforcesneak", "", opcodeClearForceSneak, opcodeClearForceSneakExplicit); extensions.registerInstruction ("forcesneak", "", opcodeForceSneak, @@ -155,6 +165,8 @@ namespace Compiler extensions.registerFunction ("getpcrunning", 'l', "", opcodeGetPcRunning); extensions.registerFunction ("getpcsneaking", 'l', "", opcodeGetPcSneaking); extensions.registerFunction ("getforcerun", 'l', "", opcodeGetForceRun, opcodeGetForceRunExplicit); + extensions.registerFunction ("getforcejump", 'l', "", opcodeGetForceJump, opcodeGetForceJumpExplicit); + extensions.registerFunction ("getforcemovejump", 'l', "", opcodeGetForceMoveJump, opcodeGetForceMoveJumpExplicit); extensions.registerFunction ("getforcesneak", 'l', "", opcodeGetForceSneak, opcodeGetForceSneakExplicit); } } diff --git a/components/compiler/opcodes.hpp b/components/compiler/opcodes.hpp index 828d736c4..c09ec9f94 100644 --- a/components/compiler/opcodes.hpp +++ b/components/compiler/opcodes.hpp @@ -123,6 +123,14 @@ namespace Compiler const int opcodeClearForceRunExplicit = 0x2000155; const int opcodeForceRun = 0x2000156; const int opcodeForceRunExplicit = 0x2000157; + const int opcodeClearForceJump = 0x2000258; + const int opcodeClearForceJumpExplicit = 0x2000259; + const int opcodeForceJump = 0x200025a; + const int opcodeForceJumpExplicit = 0x200025b; + const int opcodeClearForceMoveJump = 0x200025c; + const int opcodeClearForceMoveJumpExplicit = 0x200025d; + const int opcodeForceMoveJump = 0x200025e; + const int opcodeForceMoveJumpExplicit = 0x200025f; const int opcodeClearForceSneak = 0x2000158; const int opcodeClearForceSneakExplicit = 0x2000159; const int opcodeForceSneak = 0x200015a; @@ -134,6 +142,10 @@ namespace Compiler const int opcodeGetForceSneak = 0x20001cc; const int opcodeGetForceRunExplicit = 0x20001cd; const int opcodeGetForceSneakExplicit = 0x20001ce; + const int opcodeGetForceJump = 0x2000260; + const int opcodeGetForceMoveJump = 0x2000262; + const int opcodeGetForceJumpExplicit = 0x2000261; + const int opcodeGetForceMoveJumpExplicit = 0x2000263; } namespace Dialogue