@@ -641,6 +641,26 @@ void __fastcall CPedSA::PlayFootSteps(CPedSAInterface* ped)
641641 ((void (__thiscall*)(CPedSAInterface*, int , bool ))0x5E5380 )(ped, isLeftFoot ? 1 : 0 , doWooble);
642642 };
643643
644+ auto DoFootstepForAnim = [DoFootstep, ComputeVolumeAndFreq](CAnimBlendAssociationSAInterface* anim, CPedSAInterface* ped, float stepInterval)
645+ {
646+ static bool leftStep = true ;
647+ static float lastStepTime = 0 .0f ;
648+
649+ if (anim->fCurrentTime - lastStepTime >= stepInterval)
650+ {
651+ DoFootstep (ped, leftStep, true );
652+
653+ leftStep = !leftStep;
654+ lastStepTime += stepInterval;
655+ }
656+
657+ if (anim->fCurrentTime < lastStepTime)
658+ {
659+ lastStepTime = 0 .0f ;
660+ leftStep = true ;
661+ }
662+ };
663+
644664 auto anim = pGame->GetAnimManager ()->RpAnimBlendClumpGetFirstAssociation (ped->m_pRwObject );
645665 if (!anim)
646666 return ;
@@ -665,7 +685,39 @@ void __fastcall CPedSA::PlayFootSteps(CPedSAInterface* ped)
665685 UpdateAnimBlend (assoc->GetInterface ());
666686
667687 if (!walkAnim || walkcycleBlend <= 0 .5f || partialBlend >= 1 .0f )
668- return ;
688+ {
689+ // Custom bugfix GitHub Issue #4359
690+ // Checking for the TASK_SIMPLE_NAMED_ANIM task is not sufficient, because it usually doesnt exist in the following cases.
691+ // The ped has moveState set to STANDING_STILL, and the walkAnim flag on animations is not set,
692+ auto checkWalkingAnim = [&](const char * animName, float stepInterval) -> bool
693+ {
694+ auto assoc = pGame->GetAnimManager ()->RpAnimBlendClumpGetAssociation (ped->m_pRwObject , animName);
695+ if (assoc)
696+ {
697+ DoFootstepForAnim (assoc->GetInterface (), ped, stepInterval);
698+ return true ;
699+ }
700+ return false ;
701+ };
702+
703+ if (checkWalkingAnim (" cs_wuzi_pt1" , 0 .6f ) || checkWalkingAnim (" wuzi_walk" , 0 .5f ))
704+ return ;
705+
706+ static constexpr const char * partialAnimsWithWalking[] = {" crry_prtial" , " silence_reload" };
707+ bool hasPartialAnimWithWalking = std::any_of (std::begin (partialAnimsWithWalking), std::end (partialAnimsWithWalking), [&](const char * name)
708+ {
709+ return pGame->GetAnimManager ()->RpAnimBlendClumpGetAssociation (ped->m_pRwObject , name);
710+ });
711+
712+ if (!hasPartialAnimWithWalking)
713+ return ;
714+
715+ auto walkAssoc = pGame->GetAnimManager ()->RpAnimBlendClumpGetFirstAssociation (ped->m_pRwObject );
716+ UpdateAnimBlend (walkAssoc->GetInterface ());
717+
718+ if (!walkAnim)
719+ return ;
720+ }
669721
670722 static constexpr float INITIAL_FOOT_LANDED_RATIO = 1 .0f / 15 .0f ;
671723 static constexpr float DUCK_FOOTSTEP_MOVE_TIME = 6 .0f / 30 .0f ;
0 commit comments