Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding position check for SATM teleport #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions gamemodes/terrortown/entities/weapons/weapon_ttt_satm/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ local function ResetTimeScale()
net.Broadcast()
end

local function checkPos(ply, pos, minBound, maxBound)
local filter = {ply}
local tr = util.TraceEntity({
start = pos,
endpos = pos,
filter = filter,
mask = MASK_PLAYERSOLID
},ply)

return !tr.StartSolid || !tr.AllSolid
end

function SWEP:PrimaryAttack()
if not self:CanPrimaryAttack() then return end
if not IsFirstTimePredicted() then return end
Expand Down Expand Up @@ -127,7 +139,8 @@ function SWEP:PrimaryAttack()
timer.Create("ResetSATM", satmduration:GetInt() * self.timescale, 1, ResetTimeScale)
end
elseif self.satmmode == 4 then
if !owner:OnGround() or owner:Crouching() then
local omin, omax = owner:GetHull()
if !owner:OnGround() or checkPos(v, v:GetPos(), omin, omax) then
net.Start("SATMMessage")
net.WriteInt(20, 6)
net.Send(owner)
Expand All @@ -137,7 +150,8 @@ function SWEP:PrimaryAttack()
local aliveplayers = {}

for k, v in pairs(player.GetAll()) do
if v:IsTerror() and v != owner and !v:Crouching() then
local min, max = v:GetHull()
if v:IsTerror() and v != owner and !checkPos(v, v:GetPos(), min, max) then
table.insert(aliveplayers, v)
end
end
Expand Down