Skip to content

Commit e40dfa5

Browse files
Gave physical projectiles radius limit a server convar (#1436)
* Gave physical projectiles radius limit a server convar * Update projectiles.lua revert quad spaces to tabs --------- Co-authored-by: pingu7867 <[email protected]>
1 parent ad24088 commit e40dfa5

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

lua/pac3/extra/shared/projectiles.lua

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ local pac_sv_projectile_max_speed = CreateConVar("pac_sv_projectile_max_speed",
66
local pac_sv_projectile_max_damage = CreateConVar("pac_sv_projectile_max_damage", 100000, CLIENT and {FCVAR_REPLICATED} or {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "maximum damage for physical projectiles")
77
local pac_sv_projectile_max_mass = CreateConVar("pac_sv_projectile_max_mass", 50000, CLIENT and {FCVAR_REPLICATED} or {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "maximum speed for physical projectiles")
88
local pac_sv_projectile_allow_custom_collision_mesh = CreateConVar("pac_sv_projectile_allow_custom_collision_mesh", "1", CLIENT and {FCVAR_REPLICATED} or {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Whether to allow other models' collision mesh as a physical projectile, rather than just box and sphere")
9+
local pac_sv_projectile_max_spawn_radius = CreateConVar("pac_sv_projectile_max_spawn_radius", 2000, CLIENT and {FCVAR_REPLICATED} or {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Whether to limit how far away physical projectiles should be able to spawn, set to 0 to disable this limit altogether.")
910

1011
do -- projectile entity
1112
local ENT = {}
@@ -587,22 +588,24 @@ if SERVER then
587588
part.AttractRadius = net.ReadUInt(10)
588589
part.Bounce = net.ReadInt(15) / 100
589590

590-
local radius_limit = 2000
591+
local radius_limit = pac_sv_projectile_max_spawn_radius:GetFloat()
591592

592-
if pos:Distance(ply:EyePos()) > radius_limit * ply:GetModelScale() then
593-
local ok = false
593+
if radius_limit > 0 then
594+
if pos:Distance(ply:EyePos()) > radius_limit * ply:GetModelScale() then
595+
local ok = false
594596

595-
for _, ent in ipairs(ents.FindInSphere(pos, radius_limit)) do
596-
if (ent.CPPIGetOwner and ent:CPPIGetOwner() == ply) or ent.projectile_owner == ply or ent:GetOwner() == ply then
597-
ok = true
598-
break
597+
for _, ent in ipairs(ents.FindInSphere(pos, radius_limit)) do
598+
if (ent.CPPIGetOwner and ent:CPPIGetOwner() == ply) or ent.projectile_owner == ply or ent:GetOwner() == ply then
599+
ok = true
600+
break
601+
end
599602
end
600-
end
601603

602-
if not ok then
603-
pos = ply:EyePos()
604-
end
605-
end
604+
if not ok then
605+
pos = ply:EyePos()
606+
end
607+
end
608+
end
606609

607610
local function spawn()
608611
if not ply:IsValid() then return end

0 commit comments

Comments
 (0)