base_shutdown: Fix security clips not being defined and add support for toggling multiple clips with the same name

This commit is contained in:
squeek 2014-12-01 17:39:07 -08:00
parent 076b54ebf4
commit 3c7a7e7426

View file

@ -41,14 +41,18 @@ function security_off( team )
OutputEvent(team.."_security_hurt", "Disable")
OutputEvent(team.."_laser_hurt", "Disable") -- a possible alias
-- get the clip entity
local clip = GetEntityByName(team.."_security_clip")
-- get the clip entities
local clips = Collection()
local clipname = team.."_security_clip"
clips:GetByName({clipname})
if clip then
for clip in clips.items do
clip = CastToTriggerClip(clip)
if clip and _G[clipname] and _G[clipname].clipflags then
-- clear flags, but send a dummy flag (for some reason with zero flags it blocks everything)
clip:SetClipFlags({ClipFlags.kClipTeamBlue})
end
end
end
-- called when security gets turned on (team is a string prefix, like "red")
@ -59,14 +63,18 @@ function security_on( team )
OutputEvent(team.."_security_hurt", "Enable")
OutputEvent(team.."_laser_hurt", "Enable") -- a possible alias
-- get the clip entity
local clip = GetEntityByName(team.."_security_clip")
-- get the clip entities
local clips = Collection()
local clipname = team.."_security_clip"
clips:GetByName({clipname})
if clip then
for clip in clips.items do
clip = CastToTriggerClip(clip)
if clip and _G[clipname] and _G[clipname].clipflags then
-- reset flags to normal
clip:SetClipFlags(_G[clipname].clipflags)
end
end
end
-----------------------------------------------------------------------------
@ -234,6 +242,13 @@ blue_security_hurt = not_blue_trigger:new({})
red_laser_hurt = red_security_hurt
blue_laser_hurt = blue_security_hurt
-----------------------------------------------------------------------------
-- Clips
-----------------------------------------------------------------------------
red_security_clip = clip_red:new()
blue_security_clip = clip_blue:new()
-------------------------
-- flaginfo
-------------------------