Settle falling pickups and add coop maps

This commit is contained in:
2026-09-06 22:28:55 +02:00
parent 566d566c64
commit a32c5f9aea
2 changed files with 35 additions and 3 deletions
+10
View File
@@ -1,4 +1,14 @@
COOP_LEVELS = {
"bk_coop_simulation_00",
"coop_bb_deathstar_escape",
"coop_meows_lockdown_v_2",
"coop_mission_rehan_v3",
"coop_ventilation",
"js_coop_lj10_v2",
"js_coop_module700_ttc_b3",
"js_coop_p2_waterworks_ob",
"level09_choose_your_destiny_a1",
"lw_lambdaware_b4",
"syn_deadsimple",
"Poison_Coop_RE1_Beta1",
"oc_systems2B-2",
+25 -3
View File
@@ -130,7 +130,9 @@ local function CaptureTemplate(ent)
keyValues = ent:GetKeyValues(),
bodygroups = bodygroups,
clip1 = isWeapon and ent:Clip1() or nil,
clip2 = isWeapon and ent:Clip2() or nil
clip2 = isWeapon and ent:Clip2() or nil,
homeSettled = false,
stableSince = nil
}
end
@@ -310,12 +312,32 @@ end)
timer.Create("CustomCoopReturnDisplacedItems", 1, 0, function()
local maxDistance = math.max(respawnDistance:GetFloat(), 0)
local maxDistanceSquared = maxDistance * maxDistance
local now = CurTime()
for ent, template in pairs(trackedItems) do
if not IsValid(ent) then
trackedItems[ent] = nil
elseif not IsValid(ent:GetParent()) and ent:GetPos():DistToSqr(template.position) > maxDistanceSquared then
SafeRemoveEntityDelayed(ent, 0)
elseif not IsValid(ent:GetParent()) then
if not template.homeSettled then
local speed = ent:GetVelocity():Length()
if ent:IsOnGround() or speed <= 5 then
template.stableSince = template.stableSince or now
if ent:IsOnGround() or now - template.stableSince >= 1 then
-- Some older coop maps deliberately create pickups high
-- above their destination. Their first stable landing is
-- the intended slot; gravity during that fall is not a
-- displacement that should trigger another respawn.
template.position = ent:GetPos()
template.angles = ent:GetAngles()
template.homeSettled = true
template.stableSince = nil
end
else
template.stableSince = nil
end
elseif ent:GetPos():DistToSqr(template.position) > maxDistanceSquared then
SafeRemoveEntityDelayed(ent, 0)
end
end
end
end)