Skip to content

Commit

Permalink
Fix weapon pickup through walls (#1662)
Browse files Browse the repository at this point in the history
Add check for trace start solid to prevent teleporting weapon through
walls.

Edgecases can occur where weapons can be picked up through walls (even
thick 16 unit walls didn't prevent this). This is because the trace can
start solid (most likely if the weapon is too large for the space its
resting, in my case a relatively small func_detail shelf) and then the
tr.Fraction will return 1.0 through a solid wall, causing weapons the be
teleported and picked up.
  • Loading branch information
MrXonte authored Oct 8, 2024
1 parent 7cd15ac commit d3801d6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel
- Fixed the loadingscreen disable causing an error (by @TimGoll)
- Fixed the rounds left always displaying one less than actually left (by @TimGoll)
- Fixed rendering glitches in the loading screen (by @TimGoll)
- Fixed weapon pickup through walls (by @MrXonte)

### Changed

Expand Down
2 changes: 1 addition & 1 deletion gamemodes/terrortown/gamemode/server/sv_weaponry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function GM:PlayerCanPickupWeapon(ply, wep, dropBlockingWeapon, isPickupProbe)
mask = MASK_SOLID,
}, wep)

if tr.Fraction == 1.0 or tr.Entity == ply then
if (tr.Fraction == 1.0 or tr.Entity == ply) and not tr.StartSolid then
wep:SetPos(ply:GetShootPos())
end
end
Expand Down

0 comments on commit d3801d6

Please sign in to comment.