Skip to content

Commit

Permalink
padForceLimit fixup
Browse files Browse the repository at this point in the history
- was 16 bits not 32
  • Loading branch information
cipherxof committed Nov 15, 2023
1 parent 1299229 commit 922f0d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions MGS3CrouchWalk/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ int* __fastcall ActionSquatStillHook(__int64 work, MovementWork* plWork, __int64
// we store this here so we don't have to hardcode another address that
// needs to be updated with each new game patch
plWorkGlobal = plWork;
IgnoreButtonHold = true;

// process the default squatting logic while ignoring the button hold state check
IgnoreButtonHold = true;
int* result = ActionSquatStill(work, plWork, a3, a4);
int16_t padForce = *(int16_t*)(work + 2016);

IgnoreButtonHold = false;
CrouchMoving = padForce > plWork->padForceLimit;

// detect holding X while crouched to go into prone
if (!PlayerStatusCheck(0xE0u))
Expand All @@ -67,8 +65,11 @@ int* __fastcall ActionSquatStillHook(__int64 work, MovementWork* plWork, __int64
plWork->flag |= MovementFlag::FlagSquatToGround;
}

// 0xDE seems to make sure we aren't in first person mode
if (CrouchMoving && !PlayerStatusCheck(0xDE))
// check that the pad is being held down
int16_t padForce = *(int16_t*)(work + 2016);
CrouchMoving = padForce > plWork->padForceLimit;

if (CrouchMoving && !PlayerStatusCheck(0xDE)) // 0xDE seems to make sure we aren't in first person mode
{
if (!CrouchWalkEnabled)
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
Expand All @@ -94,8 +95,11 @@ void __fastcall SetMotionDataHook(int* m_ctrl, int layer, PlayerMotion motion, i

__int64 __fastcall ActMovementHook(MovementWork* plWork, __int64 work, int flag)
{
if (plWorkGlobal != NULL && plWorkGlobal->action != ActSquatStillOffset)
if (plWorkGlobal != NULL && plWorkGlobal->action != ActSquatStillOffset)
{
CrouchWalkEnabled = false;
CrouchMoving = false;
}

return ActMovement(plWork, work, flag);
}
Expand Down
2 changes: 1 addition & 1 deletion MGS3CrouchWalk/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct MovementWork
uint32_t field80;
uint32_t field84;
uint32_t field88;
uint32_t padForceLimit;
uint16_t padForceLimit;
};

typedef uintptr_t* __fastcall InitializeCamoIndexDelegate(int* a1, int a2);
Expand Down

0 comments on commit 922f0d7

Please sign in to comment.