Skip to content

Commit 64cec0d

Browse files
committed
footstep audio
1 parent a747240 commit 64cec0d

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

MGS3CrouchWalk/dllmain.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ uintptr_t ActSquatStillOffset = 0;
1111
MovementWork* plWorkGlobal = NULL;
1212
MotionControl* mCtrlGlobal = NULL;
1313
mINI::INIStructure Config;
14+
bool CrouchWalkEnabled = false;
15+
bool CrouchMoving = false;
16+
bool CrouchMovingSlow = false;
17+
bool IgnoreButtonHold = false;
1418

19+
// config values
1520
float CamoIndexModifier = 1.0f;
1621
float CrouchWalkSpeed = 6.0f;
1722
float CrouchStalkSpeed = 3.0f;
1823
int CamoIndexValue = 0;
19-
bool CrouchWalkEnabled = false;
20-
bool CrouchMoving = false;
21-
bool CrouchMovingSlow = false;
22-
bool IgnoreButtonHold = false;
2324

2425
InitializeCamoIndexDelegate* InitializeCamoIndex;
2526
CalculateCamoIndexDelegate* CalculateCamoIndex;
@@ -56,7 +57,7 @@ void __fastcall SetMotionDataHook(MotionControl* motionControl, int layer, Playe
5657
if (motionControl->mtcmControl->mtarName == 0x6891CC)
5758
mCtrlGlobal = motionControl;
5859

59-
if (motion == PlayerMotion::StandMoveStalk && CrouchWalkEnabled)
60+
if (motionControl == mCtrlGlobal && motion == PlayerMotion::StandMoveStalk && CrouchWalkEnabled)
6061
{
6162
float* currentTime = (float*)((uintptr_t)motionControl + 0x128);
6263

@@ -126,14 +127,22 @@ int* __fastcall ActionSquatStillHook(int64_t work, MovementWork* plWork, int64_t
126127

127128
if (CrouchMoving && !PlayerStatusCheck(0xDE)) // 0xDE seems to make sure we aren't in first person mode
128129
{
129-
if (!CrouchWalkEnabled)
130-
plWork->motion = PlayerSetMotion(work, PlayerMotion::RunUpwards); // we must set the motion to something unusable on the first run, otherwise the anim won't reset properly
131-
else
132-
plWork->motion = PlayerSetMotion(work, PlayerMotion::StandMoveStalk); // hijack the stalking motion
130+
plWork->motion = PlayerSetMotion(work, CrouchWalkEnabled ? PlayerMotion::StandMoveStalk : PlayerMotion::RunUpwards);
133131

134132
if (mCtrlGlobal != NULL)
133+
{
135134
mCtrlGlobal->mtcmControl->motionTimeBase = CrouchMovingSlow ? CrouchStalkSpeed : CrouchWalkSpeed;
136135

136+
auto mtsq_cntrl = *((uintptr_t*)(uintptr_t)mCtrlGlobal + 15);
137+
auto sound = (uint8_t*)mtsq_cntrl + 0x3C;
138+
auto soundType = (uint8_t*)mtsq_cntrl + 0x48;
139+
auto soundLevel = (uint8_t*)mtsq_cntrl + 0x40;
140+
141+
*sound = 5;
142+
*soundType = CrouchMovingSlow ? 0x20 : 0x40;
143+
*soundLevel = CrouchMovingSlow ? 12 : 150;
144+
}
145+
137146
CrouchWalkEnabled = true;
138147
}
139148

0 commit comments

Comments
 (0)