Skip to content

Commit

Permalink
TTT: fix instant reload of dropped weapon
Browse files Browse the repository at this point in the history
  • Loading branch information
svdm committed Feb 21, 2021
1 parent 6c391c4 commit 9d3ba42
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions garrysmod/gamemodes/terrortown/gamemode/weaponry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,22 @@ function WEPS.DropNotifiedWeapon(ply, wep, death_drop)
-- auto-pickup when nearby.
wep.IsDropped = true

-- After dropping a weapon, always switch to holstered, so that traitors
-- will never accidentally pull out a traitor weapon.
--
-- Perform this *before* the drop in order to abuse the fact that this
-- holsters the weapon, which in turn aborts any reload that's in
-- progress. We don't want a dropped weapon to be in a reloading state
-- because the relevant timer is reset when picking it up, making the
-- reload happen instantly. This allows one to dodge the delay by dropping
-- during reload. All of this is a workaround for not having access to
-- CBaseWeapon::AbortReload() (and that not being handled in
-- CBaseWeapon::Drop in the first place).
ply:SelectWeapon("weapon_ttt_unarmed")

ply:DropWeapon(wep)

wep:PhysWake()

-- After dropping a weapon, always switch to holstered, so that traitors
-- will never accidentally pull out a traitor weapon
ply:SelectWeapon("weapon_ttt_unarmed")
end
end

Expand Down

0 comments on commit 9d3ba42

Please sign in to comment.