Don't restart the legs animation from the beginning in the same state

This prevent walking silently by switching weapons indefinitely
This commit is contained in:
smallmodel 2025-01-05 02:20:43 +01:00
parent a14a2c9684
commit 8801834804
No known key found for this signature in database
GPG key ID: A96F163ED4891440

View file

@ -5530,7 +5530,23 @@ void Player::EvaluateState(State *forceTorso, State *forceLegs)
StopPartAnimating(legs);
animdone_Legs = true;
} else if (legsAnim != "") {
SetPartAnim(legsAnim, legs);
float oldTime;
if (currentState_Legs == laststate_Legs) {
//
// Added in OPM
// This allows different animations in the same state
// to be continued at the same moment.
// This is used to avoid "ghost walking" where the player
// would switch weapons indefinitely to avoid footstep sounds
//
oldTime = GetTime(m_iPartSlot[legs]);
SetPartAnim(legsAnim, legs);
SetTime(m_iPartSlot[legs], oldTime);
} else {
SetPartAnim(legsAnim, legs);
}
}
} else {
currentState_Legs = laststate_Legs;