mirror of
https://github.com/vladtrc/iw4L
synced 2026-10-27 02:32:13 -04:00
Block aiming down sights during weapon reloads
The shared ADS permission check excluded weapon switches, melee and offhand states but omitted the reload family. Holding or requesting ADS during a reload could therefore keep raising the weapon and zooming the view. Reject ADS throughout Reloading, ReloadingInterrupt, ReloadStart, ReloadStartInterrupt and ReloadEnd using the existing weapon-state helper. The normal ADS intent/fraction update then lowers the weapon at its ADS-out rate and prevents re-entry until the reload ends. The same permission check runs in authoritative simulation and client prediction, covering keyboard reload and controller use/reload without changing their bindings. Validation: play build, targeted rustfmt and diff checks passed. A temporary probe reproduced the permissive behavior with the previous implementation, then verified ADS exit and blocked entry for all five reload states with RELOAD and USE_RELOAD inputs. It also checked ADS recovery when ready and preserved firing/rechamber permissions. No in-game visual retest was run.
This commit is contained in:
@@ -38,6 +38,11 @@ pub fn is_ads_allowed(
|
||||
|
||||
let ws = ps.weaponstate_primary;
|
||||
|
||||
// Reload start, magazine/shell insertion, interruption and end all leave ADS.
|
||||
if crate::WeaponState::from_i32(ws).is_ok_and(crate::WeaponState::is_reload_family) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (0x10..=0x15).contains(&ws) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user