Modified CPad::DuckJustDown to use a frame counter for a 1-second delay.

This commit is contained in:
mark wallace
2025-03-30 18:35:13 +00:00
parent 24114d9a07
commit f7d23f3bb3

View File

@@ -3881,36 +3881,49 @@ bool CPad::CollectPickupJustDown(void)
return false; return false;
} }
bool CPad::DuckJustDown(void) bool CPad::DuckJustDown(void)
{ {
if (ArePlayerControlsDisabled()) if (ArePlayerControlsDisabled()) {
duckFrameCounter = 0;
return false; return false;
}
#ifdef RW_DC #ifdef RW_DC
switch (CPad::GetPad(0)->Mode) bool buttonPressed = false;
{ switch (CPad::GetPad(0)->Mode) {
case 0: //Xbox Mode case 0: // Xbox Mode
if (CPad::GetPad(0)->IsDualAnalog) buttonPressed = NewState.X;
{ break;
return !!(NewState.X&& !OldState.X); case 1: // PS2 Mode
} buttonPressed = NewState.X;
else break;
{ }
return !!(NewState.X&& !OldState.X);
} if (buttonPressed) {
case 1: //PS2 Mode duckFrameCounter++;
if (CPad::GetPad(0)->IsDualAnalog) if (duckFrameCounter >= DUCK_DELAY_FRAMES && !isDucking) {
{ isDucking = true;
return !!(NewState.X&& !OldState.X); return true; // Trigger ducking after delay
} }
else } else {
{ duckFrameCounter = 0;
return !!(NewState.X&& !OldState.X); isDucking = false;
}
} }
return false; return false;
#else #else
return !!(NewState.LeftShock && !OldState.LeftShock); bool buttonPressed = NewState.Square;
if (buttonPressed) {
duckFrameCounter++;
if (duckFrameCounter >= DUCK_DELAY_FRAMES && !isDucking) {
isDucking = true;
return true;
}
} else {
duckFrameCounter = 0;
isDucking = false;
}
return false;
#endif #endif
} }