Skip to content

Commit

Permalink
Merge pull request #308 from GMLambda/ssplayerdeath
Browse files Browse the repository at this point in the history
ep1_c17_00a: Fix scripted_sequence cancellation on player death
  • Loading branch information
ZehMatt authored Jul 21, 2024
2 parents a1d20b3 + 6712ae8 commit 8971123
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
0.9.26 (in development)
- Improved: Going in and out of the settings no longer clips into the player model.
- Fixed: NPC makers not respecting the spawn frequency -1 causing a lot of NPCs being spawned in some cases.
- Fixed: ep1_c17_00a: Don't cancel scripted_sequence on player death.

0.9.25
- Improved: Hints will no longer show duplicates, instead it will renew the existing hint that has the same text.
Expand Down
4 changes: 4 additions & 0 deletions gamemode/gametypes/hl2ep1/mapscripts/ep1_c17_00a.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ function MAPSCRIPT:PostInit()
ent:Remove()
end)

ents.WaitForEntityByName("ss_alyx_elevator_lean", function(ent)
ent:SetKeyValue("onplayerdeath", "0")
end)

-- Add a new one with a teamwait value
local elevTrigger = ents.Create("trigger_once")
elevTrigger:SetupTrigger(Vector(4644, 3584, 481.5), Angle(0, 0, 0), Vector(-100, -100, -50), Vector(100, 100, 50))
Expand Down
34 changes: 23 additions & 11 deletions gamemode/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,18 @@ local function ReplaceFuncTankVolume(ent, volname)
return newName
end

local function CheckScriptedSequence(ent)
if not IsValid(ent) then return end
local val = ent:GetInternalVariable("onplayerdeath")
if tonumber(val) ~= 1 then
return
end
local msg = "Found scripted_sequence with onplayerdeath set to " .. tostring(val) .. ": " .. tostring(ent) .. " (" .. ent:GetName() .. ")"
msg = msg .. " at " .. tostring(ent:GetPos()) .. " for map " .. game.GetMap()
msg = msg .. "\nIf you see this message please submit a new issue on https://github.com/GMLambda/Lambda/issues\n"
ErrorNoHalt(msg)
end

function GM:EntityKeyValue(ent, key, val)
self:ConflictRecovery()

Expand Down Expand Up @@ -576,16 +588,6 @@ function GM:EntityKeyValue(ent, key, val)
return newTriggerName
end

if SERVER then
-- In case a map has a scripted_sequence with onplayerdeath set to 1, we want to know about it.
if key == "onplayerdeath" and entClass == "scripted_sequence" and tostring(val) ~= "0" then
local msg = "Found scripted_sequence with onplayerdeath set to " .. tostring(val) .. ": " .. tostring(ent) .. " (" .. ent:GetName() .. ")"
msg = msg .. " at " .. tostring(ent:GetPos()) .. " for map " .. game.GetMap()
msg = msg .. "\nIf you see this message please submit a new issue on https://github.com/GMLambda/Lambda/issues\n"
ErrorNoHalt(msg)
end
end

if util.IsOutputValue(key) then
ent.EntityOutputs = ent.EntityOutputs or {}
ent.EntityOutputs[key] = ent.EntityOutputs[key] or {}
Expand All @@ -594,10 +596,20 @@ function GM:EntityKeyValue(ent, key, val)
ent.LambdaKeyValues[key] = val
end

if self.MapScript.EntityKeyValue then
if self.MapScript ~= nil and self.MapScript.EntityKeyValue then
res = self.MapScript:EntityKeyValue(ent, key, val)
if res ~= nil then return res end
end

if SERVER then
-- In case a map has a scripted_sequence with onplayerdeath set to 1, we want to know about it.
if key == "onplayerdeath" and entClass == "scripted_sequence" and tostring(val) ~= "0" then
-- Delay this check to make sure the map script had time to run.
timer.Simple(1, function()
CheckScriptedSequence(ent)
end)
end
end
end

function GM:ApplyCorrectedDamage(dmginfo)
Expand Down

0 comments on commit 8971123

Please sign in to comment.