Reset the player state when using a turret

This prevents the player from using the turret + hold their weapon to crouch and become impossible to hit
This commit is contained in:
smallmodel 2024-10-02 14:50:11 +02:00
parent 88ac49c0c9
commit dfd04f0d41
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512

View file

@ -3400,6 +3400,7 @@ void Player::DoUse(Event *ev)
int touch[MAX_GENTITIES];
int num;
int i;
bool bWasInTurretOrVehicle;
if (g_gametype->integer != GT_SINGLE_PLAYER && IsSpectator()) {
// Prevent using stuff while spectating
@ -3411,7 +3412,9 @@ void Player::DoUse(Event *ev)
return;
}
if (m_pVehicle || m_pTurret) {
bWasInTurretOrVehicle = m_pVehicle || m_pTurret;
if (bWasInTurretOrVehicle) {
RemoveFromVehiclesAndTurretsInternal();
return;
}
@ -3469,7 +3472,7 @@ void Player::DoUse(Event *ev)
}
}
if (i < num && m_pVehicle) {
if (!bWasInTurretOrVehicle && m_pVehicle) {
//
// Added in 2.30
// Make the vehicle also invincible if the player is invincible
@ -3480,6 +3483,16 @@ void Player::DoUse(Event *ev)
m_pVehicle->flags &= ~FL_GODMODE;
}
}
if (!bWasInTurretOrVehicle && (m_pVehicle || m_pTurret)) {
//
// Added in OPM
// Reset the legs and torso state.
// This prevents players from using a turret and hold the weapon fire
// to crouch with their weapon and become impossible to hit
currentState_Legs = statemap_Legs->FindState("STAND");
currentState_Torso = statemap_Torso->FindState("STAND");
}
}
void Player::TouchStuff(pmove_t *pm)