Skip to content

Commit

Permalink
Distance check to 100
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrb93 committed May 8, 2020
1 parent e49586c commit ee793ef
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lua/entities/gmod_wire_lever.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ if CLIENT then
local isClicking = LocalPlayer():KeyDown(IN_USE) or LocalPlayer():KeyDown(IN_ATTACK)
if isClicking and not self.wasClicking and IsValid(self.csmodel) then
local aimPos = LocalPlayer():GetShootPos()
if aimPos:DistToSqr(self:GetPos())<160^2 then
if aimPos:DistToSqr(self:GetPos())<100^2 then
local rayPos = util.IntersectRayWithOBB(
aimPos,
LocalPlayer():GetAimVector() * 160,
LocalPlayer():GetAimVector() * 100,
self.csmodel:GetPos(),
self.csmodel:GetAngles(),
self.csmodel:OBBMins() - Vector(2,2,2),
Expand Down Expand Up @@ -126,7 +126,7 @@ else
if not IsValid(ply) or not IsValid(ent) or not ent.Use or ent:GetClass() ~= "gmod_wire_lever" then return end
if IsValid(ent.User) then return end

if ply:GetShootPos():DistToSqr(ent:GetPos()) < 160^2 then
if ply:GetShootPos():DistToSqr(ent:GetPos()) < 100^2 then
ent:Use(ply, ply, USE_ON, 1)
end
end)
Expand All @@ -136,8 +136,7 @@ else

if IsValid(self.User) then
local shootPos = self.User:GetShootPos()
local distSqr = shootPos:DistToSqr(self:GetPos())
if distSqr < 160^2 and (self.User:KeyDown(IN_USE) or self.User:KeyDown(IN_ATTACK)) then
if shootPos:DistToSqr(self:GetPos()) < 100^2 and (self.User:KeyDown(IN_USE) or self.User:KeyDown(IN_ATTACK)) then
local shootDir = self.User:GetAimVector()
self:CalcAngle(shootPos, shootDir)
else
Expand Down

0 comments on commit ee793ef

Please sign in to comment.