Implemented sneaking animation

pull/37/head
scrawl 12 years ago
parent e7e8bd655f
commit 268bb23590

@ -365,11 +365,10 @@ namespace MWClass
fSwimRunAthleticsMult->getFloat();
moveSpeed = swimSpeed;
}
else if(Npc::getStance(ptr, Run, false))
else if(Npc::getStance(ptr, Run, false) && !Npc::getStance(ptr, Sneak, false))
moveSpeed = runSpeed;
else
moveSpeed = walkSpeed;
if(getMovementSettings(ptr).mLeftRight != 0 && getMovementSettings(ptr).mForwardBackward == 0)
moveSpeed *= 0.75f;

@ -193,9 +193,6 @@ namespace MWInput
case A_AutoMove:
toggleAutoMove ();
break;
case A_ToggleSneak:
/// \todo implement
break;
case A_ToggleWalk:
toggleWalking ();
break;
@ -308,13 +305,13 @@ namespace MWInput
else
mPlayer.setForwardBackward (0);
mPlayer.setSneak(actionIsActive(A_Sneak));
if (actionIsActive(A_Jump) && mControlSwitch["playerjumping"])
{
mPlayer.setUpDown (1);
triedToMove = true;
}
else if (actionIsActive(A_Crouch))
mPlayer.setUpDown (-1);
else
mPlayer.setUpDown (0);
@ -364,7 +361,7 @@ namespace MWInput
actionIsActive(A_MoveLeft) ||
actionIsActive(A_MoveRight) ||
actionIsActive(A_Jump) ||
actionIsActive(A_Crouch) ||
actionIsActive(A_Sneak) ||
actionIsActive(A_TogglePOV))
{
resetIdleTime();
@ -749,7 +746,7 @@ namespace MWInput
defaultKeyBindings[A_QuickKeysMenu] = OIS::KC_F1;
defaultKeyBindings[A_Console] = OIS::KC_F2;
defaultKeyBindings[A_Run] = OIS::KC_LSHIFT;
defaultKeyBindings[A_Crouch] = OIS::KC_LCONTROL;
defaultKeyBindings[A_Sneak] = OIS::KC_LCONTROL;
defaultKeyBindings[A_AutoMove] = OIS::KC_Q;
defaultKeyBindings[A_Jump] = OIS::KC_E;
defaultKeyBindings[A_Journal] = OIS::KC_J;
@ -816,7 +813,7 @@ namespace MWInput
descriptions[A_ToggleSpell] = "sReady_Magic";
descriptions[A_Console] = "sConsoleTitle";
descriptions[A_Run] = "sRun";
descriptions[A_Crouch] = "sCrouch_Sneak";
descriptions[A_Sneak] = "sCrouch_Sneak";
descriptions[A_AutoMove] = "sAuto_Run";
descriptions[A_Jump] = "sJump";
descriptions[A_Journal] = "sJournal";
@ -865,7 +862,7 @@ namespace MWInput
ret.push_back(A_MoveRight);
ret.push_back(A_TogglePOV);
ret.push_back(A_Run);
ret.push_back(A_Crouch);
ret.push_back(A_Sneak);
ret.push_back(A_Activate);
ret.push_back(A_ToggleWeapon);
ret.push_back(A_ToggleSpell);

@ -216,9 +216,9 @@ namespace MWInput
A_CycleSpellRight,
A_CycleWeaponLeft,//Cycling through weapons
A_CycleWeaponRight,
A_ToggleSneak, //Toggles Sneak, add Push-Sneak later
A_ToggleSneak, //Toggles Sneak
A_ToggleWalk, //Toggle Walking/Running
A_Crouch,
A_Sneak,
A_QuickSave,
A_QuickLoad,

@ -46,6 +46,7 @@ static const struct {
{ CharState_Idle8, "idle8" },
{ CharState_Idle9, "idle9" },
{ CharState_IdleSwim, "idleswim" },
{ CharState_IdleSneak, "idlesneak" },
{ CharState_WalkForward, "walkforward" },
{ CharState_WalkBack, "walkback" },
@ -67,6 +68,11 @@ static const struct {
{ CharState_SwimRunLeft, "swimrunleft" },
{ CharState_SwimRunRight, "swimrunright" },
{ CharState_SneakForward, "sneakforward" },
{ CharState_SneakBack, "sneakback" },
{ CharState_SneakLeft, "sneakleft" },
{ CharState_SneakRight, "sneakright" },
{ CharState_Jump, "jump" },
{ CharState_Death1, "death1" },
@ -176,6 +182,7 @@ Ogre::Vector3 CharacterController::update(float duration)
bool onground = world->isOnGround(mPtr);
bool inwater = world->isSwimming(mPtr);
bool isrunning = cls.getStance(mPtr, MWWorld::Class::Run);
bool sneak = cls.getStance(mPtr, MWWorld::Class::Sneak);
speed = cls.getSpeed(mPtr);
/* FIXME: The state should be set to Jump, and X/Y movement should be disallowed except
@ -201,31 +208,30 @@ Ogre::Vector3 CharacterController::update(float duration)
if(std::abs(vec.x/2.0f) > std::abs(vec.y) && speed > 0.0f)
{
if(vec.x > 0.0f)
setState(isrunning ?
(inwater ? CharState_SwimRunRight : CharState_RunRight) :
(inwater ? CharState_SwimWalkRight : CharState_WalkRight), true);
setState(inwater ? (isrunning ? CharState_SwimRunRight : CharState_SwimWalkRight)
: (sneak ? CharState_SneakRight : (isrunning ? CharState_RunRight : CharState_WalkRight)), true);
else if(vec.x < 0.0f)
setState(isrunning ?
(inwater ? CharState_SwimRunLeft: CharState_RunLeft) :
(inwater ? CharState_SwimWalkLeft : CharState_WalkLeft), true);
setState(inwater ? (isrunning ? CharState_SwimRunLeft : CharState_SwimWalkLeft)
: (sneak ? CharState_SneakLeft : (isrunning ? CharState_RunLeft : CharState_WalkLeft)), true);
// Apply any forward/backward movement manually
movement.y += vec.y * (speed*duration);
}
else if(vec.y != 0.0f && speed > 0.0f)
{
if(vec.y > 0.0f)
setState(isrunning ?
(inwater ? CharState_SwimRunForward : CharState_RunForward) :
(inwater ? CharState_SwimWalkForward : CharState_WalkForward), true);
setState(inwater ? (isrunning ? CharState_SwimRunForward : CharState_SwimWalkForward)
: (sneak ? CharState_SneakForward : (isrunning ? CharState_RunForward : CharState_WalkForward)), true);
else if(vec.y < 0.0f)
setState(isrunning ?
(inwater ? CharState_SwimRunBack : CharState_RunBack) :
(inwater ? CharState_SwimWalkBack : CharState_WalkBack), true);
setState(inwater ? (isrunning ? CharState_SwimRunBack : CharState_SwimWalkBack)
: (sneak ? CharState_SneakBack : (isrunning ? CharState_RunBack : CharState_WalkBack)), true);
// Apply any sideways movement manually
movement.x += vec.x * (speed*duration);
}
else if(mAnimQueue.size() == 0)
setState((inwater ? CharState_IdleSwim : CharState_Idle), true);
setState((inwater ? CharState_IdleSwim : (sneak ? CharState_IdleSneak : CharState_Idle)), true);
}
if(mAnimation && !mSkipAnim)

@ -25,6 +25,7 @@ enum CharacterState {
CharState_Idle8,
CharState_Idle9,
CharState_IdleSwim,
CharState_IdleSneak,
CharState_WalkForward,
CharState_WalkBack,
@ -46,6 +47,11 @@ enum CharacterState {
CharState_SwimRunLeft,
CharState_SwimRunRight,
CharState_SneakForward,
CharState_SneakBack,
CharState_SneakLeft,
CharState_SneakRight,
CharState_Jump,
/* Death states must be last! */

@ -86,6 +86,13 @@ namespace MWWorld
MWWorld::Class::get (ptr).setStance (ptr, MWWorld::Class::Run, !running);
}
void Player::setSneak(bool sneak)
{
MWWorld::Ptr ptr = getPlayer();
MWWorld::Class::get (ptr).setStance (ptr, MWWorld::Class::Sneak, sneak);
}
MWMechanics::DrawState_ Player::getDrawState()
{
MWWorld::Ptr ptr = getPlayer();

@ -67,6 +67,7 @@ namespace MWWorld
void setRunState(bool run);
void toggleRunning();
void setSneak(bool sneak);
};
}
#endif

Loading…
Cancel
Save