Skip to content

Commit 708833b

Browse files
committed
adjustments to is_touching_scalable event
add world_only option rename extra_radius to radius (it was a mistake to not include the base entity bounds in the core event code, but backward compatibility must prevail on that one) and reflect the real radius in the part's nicename builder and the extra properties tester
1 parent 8325af1 commit 708833b

File tree

2 files changed

+50
-14
lines changed

2 files changed

+50
-14
lines changed

lua/pac3/core/client/parts/event.lua

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,9 +1295,9 @@ PART.OldEvents = {
12951295
operator_type = "none",
12961296
tutorial_explanation = "is_touching_life checks in a stretchable box (util.TraceHull) around the host model to see if there's something inside it.\nusually the center is the parent model or root owner entity,\nbut you can force it to use the nearest pac3 model as an owner to override the old root owner setting,\nin case of issues when stacking this event inside others",
12971297

1298-
arguments = {{extra_radius = "number"}, {x_stretch = "number"}, {y_stretch = "number"}, {z_stretch = "number"}, {nearest_model = "boolean"}},
1299-
userdata = {{editor_panel = "is_touching", default = 0}, {x = "x_stretch", default = 1}, {y = "y_stretch", default = 1}, {z = "z_stretch", default = 1}, {default = false}},
1300-
callback = function(self, ent, extra_radius, x_stretch, y_stretch, z_stretch, nearest_model)
1298+
arguments = {{extra_radius = "number"}, {x_stretch = "number"}, {y_stretch = "number"}, {z_stretch = "number"}, {nearest_model = "boolean"}, {world_only = "boolean"}},
1299+
userdata = {{editor_panel = "is_touching", default = 15, editor_friendly = "radius"}, {x = "x_stretch", default = 1}, {y = "y_stretch", default = 1}, {z = "z_stretch", default = 1}, {default = false}, {default = false}},
1300+
callback = function(self, ent, extra_radius, x_stretch, y_stretch, z_stretch, nearest_model, world_only)
13011301
if nearest_model then ent = self:GetOwner() end
13021302
if not IsValid(ent) then return false end
13031303
extra_radius = extra_radius or 15
@@ -1314,25 +1314,36 @@ PART.OldEvents = {
13141314
mins = mins * radius
13151315
maxs = maxs * radius
13161316

1317-
local tr = util.TraceHull( {
1318-
start = startpos,
1319-
endpos = startpos,
1320-
maxs = maxs,
1321-
mins = mins,
1322-
filter = {self:GetRootPart():GetOwner(),ent}
1323-
} )
1324-
return tr.Hit
1317+
if world_only then
1318+
local tr = util.TraceHull( {
1319+
start = startpos,
1320+
endpos = startpos,
1321+
maxs = maxs,
1322+
mins = mins,
1323+
filter = function(ent) return ent:IsWorld() end
1324+
} )
1325+
return tr.Hit
1326+
else
1327+
local tr = util.TraceHull( {
1328+
start = startpos,
1329+
endpos = startpos,
1330+
maxs = maxs,
1331+
mins = mins,
1332+
filter = {self:GetRootPart():GetOwner(),ent}
1333+
} )
1334+
return tr.Hit
1335+
end
13251336
end,
13261337
nice = function(self, ent, extra_radius, x_stretch, y_stretch, z_stretch, nearest_model)
13271338
if nearest_model then ent = self:GetOwner() end
13281339
if not IsValid(ent) then return "" end
1329-
local radius = ent:BoundingRadius()
1340+
local radius = extra_radius
13301341

13311342
if radius == 0 and IsValid(ent.pac_projectile) then
13321343
radius = ent.pac_projectile:GetRadius()
13331344
end
13341345

1335-
radius = math.Round(math.max(radius + extra_radius + 1, 1))
1346+
radius = math.Round(math.max(extra_radius, 1),1)
13361347

13371348
local str = self.Event .. " [radius: " .. radius .. ", stretch: " .. x_stretch .. "*" .. y_stretch .. "*" .. z_stretch .. "]"
13381349
return str

lua/pac3/editor/client/panels/extra_properties.lua

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ do -- event is_touching
14161416

14171417
local startpos = ent:WorldSpaceCenter()
14181418
local b = false
1419-
if part:GetEvent() == "is_touching" or part:GetEvent() == "is_touching_scalable" then
1419+
if part:GetEvent() == "is_touching" then
14201420
local tr = util.TraceHull( {
14211421
start = startpos,
14221422
endpos = startpos,
@@ -1425,6 +1425,31 @@ do -- event is_touching
14251425
filter = {part:GetRootPart():GetOwner(),ent}
14261426
} )
14271427
b = tr.Hit
1428+
elseif part:GetEvent() == "is_touching_scalable" then
1429+
radius = math.max(extra_radius, 1) --oops, extra_radius is not accounted. but we need to keep backward compatibility
1430+
mins = Vector(-x_stretch,-y_stretch,-z_stretch)
1431+
maxs = Vector(x_stretch,y_stretch,z_stretch)
1432+
mins = mins * radius
1433+
maxs = maxs * radius
1434+
if part:GetProperty("world_only") then
1435+
local tr = util.TraceHull( {
1436+
start = startpos,
1437+
endpos = startpos,
1438+
maxs = maxs,
1439+
mins = mins,
1440+
filter = function(ent) return ent:IsWorld() end
1441+
} )
1442+
b = tr.Hit
1443+
else
1444+
local tr = util.TraceHull( {
1445+
start = startpos,
1446+
endpos = startpos,
1447+
maxs = maxs,
1448+
mins = mins,
1449+
filter = {part:GetRootPart():GetOwner(),ent}
1450+
} )
1451+
b = tr.Hit
1452+
end
14281453
elseif part:GetEvent() == "is_touching_life" then
14291454
local found = false
14301455
local ents_hits = ents.FindInBox(startpos + mins, startpos + maxs)

0 commit comments

Comments
 (0)