Fix issues when using turret while charging a grenade or using the mine detector

This commit is contained in:
smallmodel 2024-10-20 22:42:44 +02:00 committed by GitHub
commit 4b25e24a13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 11 deletions

View file

@ -3498,17 +3498,6 @@ void Player::DoUse(Event *ev)
m_pVehicle->flags &= ~FL_GODMODE; 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");
charge_start_time = 0;
}
} }
void Player::TouchStuff(pmove_t *pm) void Player::TouchStuff(pmove_t *pm)
@ -5851,6 +5840,7 @@ void Player::NoclipCheat(Event *ev)
// reset the state machine so that his animations are correct // reset the state machine so that his animations are correct
ResetState(NULL); ResetState(NULL);
charge_start_time = 0;
} else { } else {
client->ps.feetfalling = false; client->ps.feetfalling = false;
movecontrol = MOVECONTROL_LEGS; movecontrol = MOVECONTROL_LEGS;

View file

@ -4624,6 +4624,14 @@ float Weapon::GetSpreadFactor(firemode_t mode)
return fSpreadFactor; return fSpreadFactor;
} }
//======================
//Weapon::GetChargeFraction
//======================
float Weapon::GetChargeFraction(void) const
{
return charge_fraction;
}
//====================== //======================
//Weapon::GetScriptOwner //Weapon::GetScriptOwner
//====================== //======================

View file

@ -454,6 +454,7 @@ public:
Listener *GetScriptOwner(void) override; Listener *GetScriptOwner(void) override;
float GetBulletRange(firemode_t firemode); float GetBulletRange(firemode_t firemode);
float GetSpreadFactor(firemode_t firemode); float GetSpreadFactor(firemode_t firemode);
float GetChargeFraction(void) const;
firemode_t GetFireMode(void); firemode_t GetFireMode(void);
qboolean IsSemiAuto(void); qboolean IsSemiAuto(void);
void DoneAnimating(Event *ev); void DoneAnimating(Event *ev);

View file

@ -1500,6 +1500,10 @@ void TurretGun::P_TurretUsed(Player *player)
m_vUserViewAng = player->GetViewAngles(); m_vUserViewAng = player->GetViewAngles();
if (fabs(AngleSubtract(m_vUserViewAng[1], angles[1])) <= m_fMaxUseAngle) { if (fabs(AngleSubtract(m_vUserViewAng[1], angles[1])) <= m_fMaxUseAngle) {
if (player->charge_start_time) {
return;
}
P_TurretBeginUsed(player); P_TurretBeginUsed(player);
flags &= ~FL_THINK; flags &= ~FL_THINK;