Merge pull request #1 from fortressforever/features/better-base-shutdown

Better base_shutdown.lua
This commit is contained in:
Ryan Liptak 2014-12-02 20:55:52 -08:00
commit c3dfd19ae1
7 changed files with 293 additions and 684 deletions

View file

@ -8,14 +8,14 @@ SNIPER_LIMIT = 1;
-----------------------------------------------------------------------------
-- includes
-----------------------------------------------------------------------------
IncludeScript("base");
IncludeScript("base_ctf");
IncludeScript("base_shutdown");
IncludeScript("base_location");
-----------------------------------------------------------------------------
-- global overrides
-----------------------------------------------------------------------------
POINTS_PER_CAPTURE = 10;
FLAG_RETURN_TIME = 60;
SECURITY_LENGTH = 30;
-----------------------------------------------------------------------------
-- unique aardvark locations
@ -59,23 +59,14 @@ location_midmap = location_info:new({ text = "Outside", team = NO_TEAM })
-----------------------------------------------------------------------------
-- set class limits
-----------------------------------------------------------------------------
local startup_base = startup or function() end
function startup()
SetGameDescription("Capture the Flag")
startup_base()
-- set up team limits on each team
SetPlayerLimit(Team.kBlue, 0)
SetPlayerLimit(Team.kRed, 0)
SetPlayerLimit(Team.kYellow, -1)
SetPlayerLimit(Team.kGreen, -1)
-- CTF maps generally don't have civilians,
-- so override in map LUA file if you want 'em
local team = GetTeam(Team.kBlue)
team:SetClassLimit(Player.kCivilian, -1)
team:SetClassLimit(Player.kSniper, SNIPER_LIMIT)
team = GetTeam(Team.kRed)
team:SetClassLimit(Player.kCivilian, -1)
team:SetClassLimit(Player.kSniper, SNIPER_LIMIT)
end
@ -160,142 +151,42 @@ red_aardvarkresup = aardvarkresup:new({ team = Team.kRed })
-----------------------------------------------------------------------------
-- aardvark security
-----------------------------------------------------------------------------
red_aardvarksec = trigger_ff_script:new()
blue_aardvarksec = trigger_ff_script:new()
bluesecstatus = 1
redsecstatus = 1
red_aardvarksec = red_security_trigger:new()
blue_aardvarksec = blue_security_trigger:new()
sec_iconx = 60
sec_icony = 30
sec_iconw = 16
sec_iconh = 16
function red_aardvarksec:ontouch( touch_entity )
if IsPlayer( touch_entity ) then
local player = CastToPlayer( touch_entity )
if player:GetTeamId() == Team.kBlue then
if redsecstatus == 1 then
redsecstatus = 0
AddSchedule("aardvarksecup10red",20,aardvarksecup10red)
AddSchedule("aardvarksecupred",30,aardvarksecupred)
OpenDoor("red_aardvarkdoorhack")
BroadCastMessage("#FF_RED_SEC_30")
--BroadCastSound( "otherteam.flagstolen")
SpeakAll( "SD_REDDOWN" )
RemoveHudItemFromAll( "red-sec-up" )
AddHudIconToAll( "hud_secdown.vtf", "red-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
end
end
end
-- utility function for getting the name of the opposite team,
-- where team is a string, like "red"
local function get_opposite_team(team)
if team == "red" then return "blue" else return "red" end
end
function blue_aardvarksec:ontouch( touch_entity )
if IsPlayer( touch_entity ) then
local player = CastToPlayer( touch_entity )
if player:GetTeamId() == Team.kRed then
if bluesecstatus == 1 then
bluesecstatus = 0
AddSchedule("aardvarksecup10blue",20,aardvarksecup10blue)
AddSchedule("aardvarksecupblue",30,aardvarksecupblue)
OpenDoor("blue_aardvarkdoorhack")
BroadCastMessage("#FF_BLUE_SEC_30")
--BroadCastSound( "otherteam.flagstolen")
SpeakAll( "SD_BLUEDOWN" )
RemoveHudItemFromAll( "blue-sec-up" )
AddHudIconToAll( "hud_secdown.vtf", "blue-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
end
end
end
local security_off_base = security_off
function security_off( team )
security_off_base( team )
OpenDoor(team.."_aardvarkdoorhack")
local opposite_team = get_opposite_team(team)
OutputEvent("sec_"..opposite_team.."_slayer", "Disable")
AddSchedule("secup10"..team, SECURITY_LENGTH - 10, function()
BroadCastMessage("#FF_"..team:upper().."_SEC_10")
end)
end
function aardvarksecupred()
redsecstatus = 1
CloseDoor("red_aardvarkdoorhack")
BroadCastMessage("#FF_RED_SEC_ON")
SpeakAll( "SD_REDUP" )
RemoveHudItemFromAll( "red-sec-down" )
AddHudIconToAll( "hud_secup_red.vtf", "red-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
end
local security_on_base = security_on
function security_on( team )
security_on_base( team )
function aardvarksecupblue()
bluesecstatus = 1
CloseDoor("blue_aardvarkdoorhack")
BroadCastMessage("#FF_BLUE_SEC_ON")
SpeakAll( "SD_BLUEUP" )
RemoveHudItemFromAll( "blue-sec-down" )
AddHudIconToAll( "hud_secup_blue.vtf", "blue-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
end
function aardvarksecup10red()
BroadCastMessage("#FF_RED_SEC_10")
end
function aardvarksecup10blue()
BroadCastMessage("#FF_BLUE_SEC_10")
CloseDoor(team.."_aardvarkdoorhack")
local opposite_team = get_opposite_team(team)
OutputEvent("sec_"..opposite_team.."_slayer", "Enable")
end
-----------------------------------------------------------------------------
-- aardvark lasers and respawn shields
-- respawn shields
-----------------------------------------------------------------------------
KILL_KILL_KILL = trigger_ff_script:new({ team = Team.kUnassigned })
lasers_KILL_KILL_KILL = trigger_ff_script:new({ team = Team.kUnassigned })
blue_slayer = not_red_trigger:new()
red_slayer = not_blue_trigger:new()
sec_blue_slayer = not_red_trigger:new()
sec_red_slayer = not_blue_trigger:new()
function KILL_KILL_KILL:allowed( activator )
local player = CastToPlayer( activator )
if player then
if player:GetTeamId() == self.team then
return EVENT_ALLOWED
end
end
return EVENT_DISALLOWED
end
function lasers_KILL_KILL_KILL:allowed( activator )
local player = CastToPlayer( activator )
if player then
if player:GetTeamId() == self.team then
if self.team == Team.kBlue then
if redsecstatus == 1 then
return EVENT_ALLOWED
end
end
if self.team == Team.kRed then
if bluesecstatus == 1 then
return EVENT_ALLOWED
end
end
end
end
return EVENT_DISALLOWED
end
blue_slayer = KILL_KILL_KILL:new({ team = Team.kBlue })
red_slayer = KILL_KILL_KILL:new({ team = Team.kRed })
sec_blue_slayer = lasers_KILL_KILL_KILL:new({ team = Team.kBlue })
sec_red_slayer = lasers_KILL_KILL_KILL:new({ team = Team.kRed })
-------------------------
-- flaginfo
-------------------------
function flaginfo( player_entity )
local player = CastToPlayer( player_entity )
flaginfo_base(player_entity) --basic CTF HUD items
RemoveHudItem( player, "red-sec-down" )
RemoveHudItem( player, "blue-sec-down" )
RemoveHudItem( player, "red-sec-up" )
RemoveHudItem( player, "blue-sec-up" )
if bluesecstatus == 1 then
AddHudIcon( player, "hud_secup_blue.vtf", "blue-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
else
AddHudIcon( player, "hud_secdown.vtf", "blue-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
end
if redsecstatus == 1 then
AddHudIcon( player, "hud_secup_red.vtf", "red-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
else
AddHudIcon( player, "hud_secdown.vtf", "red-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
end
end

View file

@ -4,8 +4,7 @@
-----------------------------------------------------------------------------
-- includes
-----------------------------------------------------------------------------
IncludeScript("base");
IncludeScript("base_ctf");
IncludeScript("base_shutdown");
IncludeScript("base_location");
-----------------------------------------------------------------------------
@ -13,6 +12,7 @@ IncludeScript("base_location");
-----------------------------------------------------------------------------
POINTS_PER_CAPTURE = 10;
FLAG_RETURN_TIME = 60;
SECURITY_LENGTH = 30;
-----------------------------------------------------------------------------
-- locations
@ -37,25 +37,6 @@ location_blueresup = location_info:new({ text = "Resupply", team = Team.kBlue })
location_midmap = location_info:new({ text = "Outside", team = NO_TEAM })
-----------------------------------------------------------------------------
-- remove mirvs (?) and give full resup on spawn
-----------------------------------------------------------------------------
function player_spawn( player_entity )
local player = CastToPlayer( player_entity )
-- if player:GetClass() == Player.kHwguy then
-- player:RemoveAmmo(Ammo.kGren2, 4)
-- end
-- if player:GetClass() == Player.kDemoman then
-- player:RemoveAmmo(Ammo.kGren2, 4)
-- end
player:AddHealth( 400 )
player:AddArmor( 400 )
player:AddAmmo( Ammo.kNails, 400 )
player:AddAmmo( Ammo.kShells, 400 )
player:AddAmmo( Ammo.kRockets, 400 )
player:AddAmmo( Ammo.kCells, 400 )
end
-----------------------------------------------------------------------------
-- bagless resupply
-----------------------------------------------------------------------------
@ -79,147 +60,46 @@ blue_aardvarkresup = aardvarkresup:new({ team = Team.kBlue })
red_aardvarkresup = aardvarkresup:new({ team = Team.kRed })
-----------------------------------------------------------------------------
-- aardvark security
-- security
-----------------------------------------------------------------------------
red_aardvarksec = trigger_ff_script:new()
blue_aardvarksec = trigger_ff_script:new()
bluesecstatus = 1
redsecstatus = 1
red_aardvarksec = red_security_trigger:new()
blue_aardvarksec = blue_security_trigger:new()
sec_iconx = 60
sec_icony = 30
sec_iconw = 16
sec_iconh = 16
function red_aardvarksec:ontouch( touch_entity )
if IsPlayer( touch_entity ) then
local player = CastToPlayer( touch_entity )
if player:GetTeamId() == Team.kBlue then
if redsecstatus == 1 then
redsecstatus = 0
AddSchedule("aardvarksecup10red",20,aardvarksecup10red)
AddSchedule("aardvarksecupred",30,aardvarksecupred)
OpenDoor("red_aardvarkdoorhack")
BroadCastMessage("#FF_RED_SEC_30")
--BroadCastSound( "otherteam.flagstolen")
SpeakAll( "SD_REDDOWN" )
RemoveHudItemFromAll( "red-sec-up" )
AddHudIconToAll( "hud_secdown.vtf", "red-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
end
end
end
-- utility function for getting the name of the opposite team,
-- where team is a string, like "red"
local function get_opposite_team(team)
if team == "red" then return "blue" else return "red" end
end
function blue_aardvarksec:ontouch( touch_entity )
if IsPlayer( touch_entity ) then
local player = CastToPlayer( touch_entity )
if player:GetTeamId() == Team.kRed then
if bluesecstatus == 1 then
bluesecstatus = 0
AddSchedule("aardvarksecup10blue",20,aardvarksecup10blue)
AddSchedule("aardvarksecupblue",30,aardvarksecupblue)
OpenDoor("blue_aardvarkdoorhack")
BroadCastMessage("#FF_BLUE_SEC_30")
--BroadCastSound( "otherteam.flagstolen")
SpeakAll( "SD_BLUEDOWN" )
RemoveHudItemFromAll( "blue-sec-up" )
AddHudIconToAll( "hud_secdown.vtf", "blue-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
end
end
end
local security_off_base = security_off
function security_off( team )
security_off_base( team )
OpenDoor(team.."_aardvarkdoorhack")
local opposite_team = get_opposite_team(team)
OutputEvent("sec_"..opposite_team.."_slayer", "Disable")
AddSchedule("secup10"..team, SECURITY_LENGTH - 10, function()
BroadCastMessage("#FF_"..team:upper().."_SEC_10")
end)
end
function aardvarksecupred()
redsecstatus = 1
CloseDoor("red_aardvarkdoorhack")
BroadCastMessage("#FF_RED_SEC_ON")
SpeakAll( "SD_REDUP" )
RemoveHudItemFromAll( "red-sec-down" )
AddHudIconToAll( "hud_secup_red.vtf", "red-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
end
local security_on_base = security_on
function security_on( team )
security_on_base( team )
function aardvarksecupblue()
bluesecstatus = 1
CloseDoor("blue_aardvarkdoorhack")
BroadCastMessage("#FF_BLUE_SEC_ON")
SpeakAll( "SD_BLUEUP" )
RemoveHudItemFromAll( "blue-sec-down" )
AddHudIconToAll( "hud_secup_blue.vtf", "blue-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
end
function aardvarksecup10red()
BroadCastMessage("#FF_RED_SEC_10")
end
function aardvarksecup10blue()
BroadCastMessage("#FF_BLUE_SEC_10")
CloseDoor(team.."_aardvarkdoorhack")
local opposite_team = get_opposite_team(team)
OutputEvent("sec_"..opposite_team.."_slayer", "Enable")
end
-----------------------------------------------------------------------------
-- aardvark lasers and respawn shields
-- lasers and respawn shields
-----------------------------------------------------------------------------
KILL_KILL_KILL = trigger_ff_script:new({ team = Team.kUnassigned })
lasers_KILL_KILL_KILL = trigger_ff_script:new({ team = Team.kUnassigned })
function KILL_KILL_KILL:allowed( activator )
local player = CastToPlayer( activator )
if player then
if player:GetTeamId() == self.team then
return EVENT_ALLOWED
end
end
return EVENT_DISALLOWED
end
function lasers_KILL_KILL_KILL:allowed( activator )
local player = CastToPlayer( activator )
if player then
if player:GetTeamId() == self.team then
if self.team == Team.kBlue then
if redsecstatus == 1 then
return EVENT_ALLOWED
end
end
if self.team == Team.kRed then
if bluesecstatus == 1 then
return EVENT_ALLOWED
end
end
end
end
return EVENT_DISALLOWED
end
blue_slayer = KILL_KILL_KILL:new({ team = Team.kBlue })
red_slayer = KILL_KILL_KILL:new({ team = Team.kRed })
sec_blue_slayer = lasers_KILL_KILL_KILL:new({ team = Team.kBlue })
sec_red_slayer = lasers_KILL_KILL_KILL:new({ team = Team.kRed })
-------------------------
-- flaginfo
-------------------------
function flaginfo( player_entity )
local player = CastToPlayer( player_entity )
flaginfo_base(player_entity) --basic CTF HUD items
RemoveHudItem( player, "red-sec-down" )
RemoveHudItem( player, "blue-sec-down" )
RemoveHudItem( player, "red-sec-up" )
RemoveHudItem( player, "blue-sec-up" )
if bluesecstatus == 1 then
AddHudIcon( player, "hud_secup_blue.vtf", "blue-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
else
AddHudIcon( player, "hud_secdown.vtf", "blue-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
end
if redsecstatus == 1 then
AddHudIcon( player, "hud_secup_red.vtf", "red-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
else
AddHudIcon( player, "hud_secdown.vtf", "red-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
end
end
blue_slayer = not_red_trigger:new()
red_slayer = not_blue_trigger:new()
sec_blue_slayer = not_red_trigger:new()
sec_red_slayer = not_blue_trigger:new()
-----------------------------------------------------------------------------
-- custom packs

View file

@ -4,8 +4,7 @@
-----------------------------------------------------------------------------
-- includes
-----------------------------------------------------------------------------
IncludeScript("base");
IncludeScript("base_ctf");
IncludeScript("base_shutdown");
IncludeScript("base_location");
-----------------------------------------------------------------------------
@ -13,6 +12,7 @@ IncludeScript("base_location");
-----------------------------------------------------------------------------
POINTS_PER_CAPTURE = 10;
FLAG_RETURN_TIME = 60;
SECURITY_LENGTH = 30;
-----------------------------------------------------------------------------
-- unique openfire locations
@ -56,147 +56,46 @@ blue_aardvarkresup = aardvarkresup:new({ team = Team.kBlue })
red_aardvarkresup = aardvarkresup:new({ team = Team.kRed })
-----------------------------------------------------------------------------
-- aardvark security
-- security
-----------------------------------------------------------------------------
red_aardvarksec = trigger_ff_script:new()
blue_aardvarksec = trigger_ff_script:new()
bluesecstatus = 1
redsecstatus = 1
red_aardvarksec = red_security_trigger:new()
blue_aardvarksec = blue_security_trigger:new()
sec_iconx = 60
sec_icony = 30
sec_iconw = 16
sec_iconh = 16
function red_aardvarksec:ontouch( touch_entity )
if IsPlayer( touch_entity ) then
local player = CastToPlayer( touch_entity )
if player:GetTeamId() == Team.kBlue then
if redsecstatus == 1 then
redsecstatus = 0
AddSchedule("aardvarksecup10red",20,aardvarksecup10red)
AddSchedule("aardvarksecupred",30,aardvarksecupred)
OpenDoor("red_aardvarkdoorhack")
BroadCastMessage("#FF_RED_SEC_30")
--BroadCastSound( "otherteam.flagstolen")
SpeakAll( "SD_REDDOWN" )
RemoveHudItemFromAll( "red-sec-up" )
AddHudIconToAll( "hud_secdown.vtf", "red-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
end
end
end
-- utility function for getting the name of the opposite team,
-- where team is a string, like "red"
local function get_opposite_team(team)
if team == "red" then return "blue" else return "red" end
end
function blue_aardvarksec:ontouch( touch_entity )
if IsPlayer( touch_entity ) then
local player = CastToPlayer( touch_entity )
if player:GetTeamId() == Team.kRed then
if bluesecstatus == 1 then
bluesecstatus = 0
AddSchedule("aardvarksecup10blue",20,aardvarksecup10blue)
AddSchedule("aardvarksecupblue",30,aardvarksecupblue)
OpenDoor("blue_aardvarkdoorhack")
BroadCastMessage("#FF_BLUE_SEC_30")
--BroadCastSound( "otherteam.flagstolen")
SpeakAll( "SD_BLUEDOWN" )
RemoveHudItemFromAll( "blue-sec-up" )
AddHudIconToAll( "hud_secdown.vtf", "blue-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
end
end
end
local security_off_base = security_off
function security_off( team )
security_off_base( team )
OpenDoor(team.."_aardvarkdoorhack")
local opposite_team = get_opposite_team(team)
OutputEvent("sec_"..opposite_team.."_slayer", "Disable")
AddSchedule("secup10"..team, SECURITY_LENGTH - 10, function()
BroadCastMessage("#FF_"..team:upper().."_SEC_10")
end)
end
function aardvarksecupred()
redsecstatus = 1
CloseDoor("red_aardvarkdoorhack")
BroadCastMessage("#FF_RED_SEC_ON")
SpeakAll( "SD_REDUP" )
RemoveHudItemFromAll( "red-sec-down" )
AddHudIconToAll( "hud_secup_red.vtf", "red-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
end
local security_on_base = security_on
function security_on( team )
security_on_base( team )
function aardvarksecupblue()
bluesecstatus = 1
CloseDoor("blue_aardvarkdoorhack")
BroadCastMessage("#FF_BLUE_SEC_ON")
SpeakAll( "SD_BLUEUP" )
RemoveHudItemFromAll( "blue-sec-down" )
AddHudIconToAll( "hud_secup_blue.vtf", "blue-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
end
function aardvarksecup10red()
BroadCastMessage("#FF_RED_SEC_10")
end
function aardvarksecup10blue()
BroadCastMessage("#FF_BLUE_SEC_10")
CloseDoor(team.."_aardvarkdoorhack")
local opposite_team = get_opposite_team(team)
OutputEvent("sec_"..opposite_team.."_slayer", "Enable")
end
-----------------------------------------------------------------------------
-- aardvark lasers and respawn shields
-- lasers and respawn shields
-----------------------------------------------------------------------------
KILL_KILL_KILL = trigger_ff_script:new({ team = Team.kUnassigned })
lasers_KILL_KILL_KILL = trigger_ff_script:new({ team = Team.kUnassigned })
function KILL_KILL_KILL:allowed( activator )
local player = CastToPlayer( activator )
if player then
if player:GetTeamId() == self.team then
return EVENT_ALLOWED
end
end
return EVENT_DISALLOWED
end
function lasers_KILL_KILL_KILL:allowed( activator )
local player = CastToPlayer( activator )
if player then
if player:GetTeamId() == self.team then
if self.team == Team.kBlue then
if redsecstatus == 1 then
return EVENT_ALLOWED
end
end
if self.team == Team.kRed then
if bluesecstatus == 1 then
return EVENT_ALLOWED
end
end
end
end
return EVENT_DISALLOWED
end
blue_slayer = KILL_KILL_KILL:new({ team = Team.kBlue })
red_slayer = KILL_KILL_KILL:new({ team = Team.kRed })
sec_blue_slayer = lasers_KILL_KILL_KILL:new({ team = Team.kBlue })
sec_red_slayer = lasers_KILL_KILL_KILL:new({ team = Team.kRed })
-------------------------
-- flaginfo
-------------------------
function flaginfo( player_entity )
local player = CastToPlayer( player_entity )
flaginfo_base(player_entity) --basic CTF HUD items
RemoveHudItem( player, "red-sec-down" )
RemoveHudItem( player, "blue-sec-down" )
RemoveHudItem( player, "red-sec-up" )
RemoveHudItem( player, "blue-sec-up" )
if bluesecstatus == 1 then
AddHudIcon( player, "hud_secup_blue.vtf", "blue-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
else
AddHudIcon( player, "hud_secdown.vtf", "blue-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
end
if redsecstatus == 1 then
AddHudIcon( player, "hud_secup_red.vtf", "red-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
else
AddHudIcon( player, "hud_secdown.vtf", "red-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
end
end
blue_slayer = not_red_trigger:new()
red_slayer = not_blue_trigger:new()
sec_blue_slayer = not_red_trigger:new()
sec_red_slayer = not_blue_trigger:new()
-----------------------------------------------------------------------------
-- custom openfire pack

View file

@ -99,20 +99,8 @@ red_windowpack = windowpack:new({ touchflags = { AllowFlags.kOnlyPlayers, AllowF
-- kills those who wander into the enemy spawn
-----------------------------------------------------------------------------
spawn_protection = trigger_ff_script:new({ team = Team.kUnassigned })
function spawn_protection:allowed( activator )
local player = CastToPlayer( activator )
if player then
if player:GetTeamId() == self.team then
return EVENT_ALLOWED
end
end
return EVENT_DISALLOWED
end
red_spawn_protection = spawn_protection:new({ team = Team.kBlue })
blue_spawn_protection = spawn_protection:new({ team = Team.kRed })
red_spawn_protection = not_red_trigger:new()
blue_spawn_protection = not_blue_trigger:new()
-----------------------------------------------------------------------------
-- OFFENSIVE AND DEFENSIVE SPAWNS
@ -136,84 +124,38 @@ blue_dspawn = { validspawn = blue_d_only }
-- AND THEN, SOME MORE STUFF...
-----------------------------------------------------------------------------
red_sec = trigger_ff_script:new()
blue_sec = trigger_ff_script:new()
bluesecstatus = 1
redsecstatus = 1
red_sec = red_security_trigger:new()
blue_sec = blue_security_trigger:new()
sec_iconx = 60
sec_icony = 30
sec_iconw = 16
sec_iconh = 16
function red_sec:ontouch( touch_entity )
if IsPlayer( touch_entity ) then
local player = CastToPlayer( touch_entity )
if player:GetTeamId() == Team.kBlue then
if redsecstatus == 1 then
redsecstatus = 0
AddSchedule("secup10red", SECURITY_LENGTH - 10, secup10red)
AddSchedule("beginclosered", SECURITY_LENGTH - 6, beginclosered)
AddSchedule("secupred",SECURITY_LENGTH,secupred)
OpenDoor("red_secdoor")
BroadCastMessage("#FF_RED_SEC_40")
SpeakAll( "SD_REDDOWN" )
RemoveHudItemFromAll( "red-sec-up" )
AddHudIconToAll( "hud_secdown.vtf", "red-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
end
end
end
-- utility function for getting the name of the opposite team,
-- where team is a string, like "red"
local function get_opposite_team(team)
if team == "red" then return "blue" else return "red" end
end
function blue_sec:ontouch( touch_entity )
if IsPlayer( touch_entity ) then
local player = CastToPlayer( touch_entity )
if player:GetTeamId() == Team.kRed then
if bluesecstatus == 1 then
bluesecstatus = 0
AddSchedule("secup10blue", SECURITY_LENGTH - 10, secup10blue)
AddSchedule("begincloseblue", SECURITY_LENGTH - 6, begincloseblue)
AddSchedule("secupblue",SECURITY_LENGTH,secupblue)
OpenDoor("blue_secdoor")
BroadCastMessage("#FF_BLUE_SEC_40")
SpeakAll( "SD_BLUEDOWN" )
RemoveHudItemFromAll( "blue-sec-up" )
AddHudIconToAll( "hud_secdown.vtf", "blue-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
end
end
end
local security_off_base = security_off
function security_off( team )
security_off_base( team )
OpenDoor(team.."_secdoor")
local opposite_team = get_opposite_team(team)
OutputEvent("sec_"..opposite_team.."_slayer", "Disable")
AddSchedule("secup10"..team, SECURITY_LENGTH - 10, function()
BroadCastMessage("#FF_"..team:upper().."_SEC_10")
end)
AddSchedule("beginclose"..team, SECURITY_LENGTH - 6, function()
CloseDoor(team.."_secdoor")
end)
end
function secupred()
redsecstatus = 1
BroadCastMessage("#FF_RED_SEC_ON")
SpeakAll( "SD_REDUP" )
RemoveHudItemFromAll( "red-sec-down" )
AddHudIconToAll( "hud_secup_red.vtf", "red-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
end
local security_on_base = security_on
function security_on( team )
security_on_base( team )
function begincloseblue()
CloseDoor("blue_secdoor")
end
function beginclosered()
CloseDoor("red_secdoor")
end
function secupblue()
bluesecstatus = 1
BroadCastMessage("#FF_BLUE_SEC_ON")
SpeakAll( "SD_BLUEUP" )
RemoveHudItemFromAll( "blue-sec-down" )
AddHudIconToAll( "hud_secup_blue.vtf", "blue-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
end
function secup10red()
BroadCastMessage("#FF_RED_SEC_10")
end
function secup10blue()
BroadCastMessage("#FF_BLUE_SEC_10")
CloseDoor(team.."_secdoor")
local opposite_team = get_opposite_team(team)
OutputEvent("sec_"..opposite_team.."_slayer", "Enable")
end
grp = bigpack:new({
@ -222,29 +164,3 @@ gren1=4,gren2=4,model=
"models/items/backpack/backpack.mdl",
respawntime=1,touchsound="Backpack.Touch"})
function grp:dropatspawn() return false end
-------------------------
-- flaginfo
-------------------------
function flaginfo( player_entity )
local player = CastToPlayer( player_entity )
flaginfo_base(player_entity) --basic CTF HUD items
RemoveHudItem( player, "red-sec-down" )
RemoveHudItem( player, "blue-sec-down" )
RemoveHudItem( player, "red-sec-up" )
RemoveHudItem( player, "blue-sec-up" )
if bluesecstatus == 1 then
AddHudIcon( player, "hud_secup_blue.vtf", "blue-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
else
AddHudIcon( player, "hud_secdown.vtf", "blue-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 2 )
end
if redsecstatus == 1 then
AddHudIcon( player, "hud_secup_red.vtf", "red-sec-up", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
else
AddHudIcon( player, "hud_secdown.vtf", "red-sec-down", sec_iconx, sec_icony, sec_iconw, sec_iconh, 3 )
end
end

View file

@ -5,122 +5,34 @@
-----------------------------------------------------------------------------
IncludeScript("base_shutdown");
-----------------------------------------------------------------------------
-- unique shutdown2 locations
-----------------------------------------------------------------------------
SECURITY_LENGTH = 60
-----------------------------------------------------------------------------
-- aardvark security
-- security
-----------------------------------------------------------------------------
red_aardvarksec = trigger_ff_script:new()
blue_aardvarksec = trigger_ff_script:new()
bluesecstatus = 1
redsecstatus = 1
red_aardvarksec = red_security_trigger:new()
blue_aardvarksec = blue_security_trigger:new()
function red_aardvarksec:ontouch( touch_entity )
if IsPlayer( touch_entity ) then
local player = CastToPlayer( touch_entity )
if player:GetTeamId() == Team.kBlue then
if redsecstatus == 1 then
redsecstatus = 0
AddSchedule("aardvarksecup10red",50,aardvarksecup10red)
AddSchedule("aardvarksecupred",60,aardvarksecupred)
OpenDoor("red_aardvarkdoorhack")
BroadCastMessage("#FF_RED_SEC_60")
--BroadCastSound( "otherteam.flagstolen")
SpeakAll( "SD_REDDOWN" )
RemoveHudItemFromAll( "red-sec-up" )
AddHudIconToAll( "hud_secdown.vtf", "red-sec-down", button_red.iconx, button_red.icony, button_red.iconw, button_red.iconh, 3 )
end
end
end
local security_off_base = security_off
function security_off( team )
security_off_base( team )
OpenDoor(team.."_aardvarkdoorhack")
AddSchedule("secup10"..team, SECURITY_LENGTH - 10, function()
BroadCastMessage("#FF_"..team:upper().."_SEC_10")
end)
end
function blue_aardvarksec:ontouch( touch_entity )
if IsPlayer( touch_entity ) then
local player = CastToPlayer( touch_entity )
if player:GetTeamId() == Team.kRed then
if bluesecstatus == 1 then
bluesecstatus = 0
AddSchedule("aardvarksecup10blue",50,aardvarksecup10blue)
AddSchedule("aardvarksecupblue",60,aardvarksecupblue)
OpenDoor("blue_aardvarkdoorhack")
BroadCastMessage("#FF_BLUE_SEC_60")
--BroadCastSound( "otherteam.flagstolen")
SpeakAll( "SD_BLUEDOWN" )
RemoveHudItemFromAll( "blue-sec-up" )
AddHudIconToAll( "hud_secdown.vtf", "blue-sec-down", button_blue.iconx, button_blue.icony, button_blue.iconw, button_blue.iconh, 2 )
end
end
end
end
local security_on_base = security_on
function security_on( team )
security_on_base( team )
function aardvarksecupred()
redsecstatus = 1
CloseDoor("red_aardvarkdoorhack")
BroadCastMessage("#FF_RED_SEC_ON")
SpeakAll( "SD_REDUP" )
RemoveHudItemFromAll( "red-sec-down" )
AddHudIconToAll( "hud_secup_red.vtf", "red-sec-up", button_red.iconx, button_red.icony, button_red.iconw, button_red.iconh, 3 )
end
function aardvarksecupblue()
bluesecstatus = 1
CloseDoor("blue_aardvarkdoorhack")
BroadCastMessage("#FF_BLUE_SEC_ON")
SpeakAll( "SD_BLUEUP" )
RemoveHudItemFromAll( "blue-sec-down" )
AddHudIconToAll( "hud_secup_blue.vtf", "blue-sec-up", button_blue.iconx, button_blue.icony, button_blue.iconw, button_blue.iconh, 2 )
end
function aardvarksecup10red()
BroadCastMessage("#FF_RED_SEC_10")
end
function aardvarksecup10blue()
BroadCastMessage("#FF_BLUE_SEC_10")
end
-------------------------
-- flaginfo
-------------------------
function flaginfo( player_entity )
local player = CastToPlayer( player_entity )
flaginfo_base(player_entity) --basic CTF HUD items
RemoveHudItem( player, "red-sec-down" )
RemoveHudItem( player, "blue-sec-down" )
RemoveHudItem( player, "red-sec-up" )
RemoveHudItem( player, "blue-sec-up" )
if bluesecstatus == 1 then
AddHudIcon( player, "hud_secup_blue.vtf", "blue-sec-up", button_blue.iconx, button_blue.icony, button_blue.iconw, button_blue.iconh, 2 )
else
AddHudIcon( player, "hud_secdown.vtf", "blue-sec-down", button_blue.iconx, button_blue.icony, button_blue.iconw, button_blue.iconh, 2 )
end
if redsecstatus == 1 then
AddHudIcon( player, "hud_secup_red.vtf", "red-sec-up", button_red.iconx, button_red.icony, button_red.iconw, button_red.iconh, 3 )
else
AddHudIcon( player, "hud_secdown.vtf", "red-sec-down", button_red.iconx, button_red.icony, button_red.iconw, button_red.iconh, 3 )
end
CloseDoor(team.."_aardvarkdoorhack")
end
-----------------------------------------------------------------------------
-- respawn shields
-----------------------------------------------------------------------------
KILL_KILL_KILL = trigger_ff_script:new({ team = Team.kUnassigned })
function KILL_KILL_KILL:allowed( activator )
local player = CastToPlayer( activator )
if player then
if player:GetTeamId() == self.team then
return EVENT_ALLOWED
end
end
return EVENT_DISALLOWED
end
blue_slayer = KILL_KILL_KILL:new({ team = Team.kBlue })
red_slayer = KILL_KILL_KILL:new({ team = Team.kRed })
blue_slayer = not_red_trigger:new()
red_slayer = not_blue_trigger:new()

View file

@ -13,6 +13,69 @@ IncludeScript("base_respawnturret");
-----------------------------------------------------------------------------
POINTS_PER_CAPTURE = 10;
FLAG_RETURN_TIME = 60;
SECURITY_LENGTH = 45;
local base_shutdown_base = {}
base_shutdown_base.startup = startup
function startup()
if type(base_shutdown_base.startup) == "function" then
-- call the saved function
base_shutdown_base.startup()
end
-- this will take care of lights, etc when map loads or round gets restarted/prematch ends
security_on("red")
security_on("blue")
end
-----------------------------------------------------------------------------
-- Security events
-----------------------------------------------------------------------------
-- called when security gets turned off (team is a string prefix, like "red")
function security_off( team )
-- turn off security light, brush, hurt, etc
OutputEvent(team.."_security_light", "TurnOff")
OutputEvent(team.."_security_brush", "Disable")
OutputEvent(team.."_security_hurt", "Disable")
OutputEvent(team.."_laser_hurt", "Disable") -- a possible alias
-- get the clip entities
local clips = Collection()
local clipname = team.."_security_clip"
clips:GetByName({clipname})
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")
function security_on( team )
-- turn on security light, brush, hurt, etc
OutputEvent(team.."_security_light", "TurnOn")
OutputEvent(team.."_security_brush", "Enable")
OutputEvent(team.."_security_hurt", "Enable")
OutputEvent(team.."_laser_hurt", "Enable") -- a possible alias
-- get the clip entities
local clips = Collection()
local clipname = team.."_security_clip"
clips:GetByName({clipname})
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
-----------------------------------------------------------------------------
-- Buttons
@ -32,7 +95,6 @@ function button_common:allowed( allowed_entity )
return EVENT_DISALLOWED
end
-- TODO this doesn't work
function button_common:onfailuse( use_entity )
if IsPlayer( use_entity ) then
local player = CastToPlayer( use_entity )
@ -45,8 +107,6 @@ end
-----------------------------------------------------------------------------
-- red button
--button_red = button_common:new({ team = Team.kBlue, sec_up = true })
button_red = button_common:new({
team = Team.kBlue,
sec_up = true,
@ -63,7 +123,11 @@ button_red = button_common:new({
-- Button responses
-----------------------------------------------------------------------------
function button_red:onin()
BroadCastMessage( "#FF_RED_SECURITY_DEACTIVATED" )
if SECURITY_LENGTH == 60 or SECURITY_LENGTH == 30 then
BroadCastMessage( "#FF_RED_SEC_"..SECURITY_LENGTH )
else
BroadCastMessage( "#FF_RED_SECURITY_DEACTIVATED" )
end
SpeakAll( "SD_REDDOWN" )
self.sec_up = false
@ -72,6 +136,7 @@ function button_red:onin()
AddHudIconToAll( self.sec_down_icon, "red-sec-down", self.iconx, self.icony, self.iconw, self.iconh, self.iconalign )
LogLuaEvent(0, 0, "security_down", "team", "red")
security_off("red")
end
function button_red:onout()
@ -84,6 +149,7 @@ function button_red:onout()
AddHudIconToAll( self.sec_up_icon, "red-sec-up", self.iconx, self.icony, self.iconw, self.iconh, self.iconalign )
LogLuaEvent(0, 0, "security_up", "team", "red")
security_on("red")
end
-----------------------------------------------------------------------------
@ -91,8 +157,6 @@ end
-----------------------------------------------------------------------------
-- blue button
--button_blue = button_common:new({ team = Team.kRed, sec_up = true })
button_blue = button_common:new({
team = Team.kRed,
sec_up = true,
@ -109,7 +173,11 @@ button_blue = button_common:new({
-- Button responses
-----------------------------------------------------------------------------
function button_blue:onin()
BroadCastMessage( "#FF_BLUE_SECURITY_DEACTIVATED" )
if SECURITY_LENGTH == 60 or SECURITY_LENGTH == 30 or SECURITY_LENGTH == 40 then
BroadCastMessage( "#FF_BLUE_SEC_"..SECURITY_LENGTH )
else
BroadCastMessage( "#FF_BLUE_SECURITY_DEACTIVATED" )
end
SpeakAll( "SD_BLUEDOWN" )
self.sec_up = false
@ -118,6 +186,7 @@ function button_blue:onin()
AddHudIconToAll( self.sec_down_icon, "blue-sec-down", self.iconx, self.icony, self.iconw, self.iconh, self.iconalign )
LogLuaEvent(0, 0, "security_down", "team", "blue")
security_off("blue")
end
function button_blue:onout()
@ -128,38 +197,57 @@ function button_blue:onout()
RemoveHudItemFromAll( "blue-sec-down")
AddHudIconToAll( self.sec_up_icon, "blue-sec-up", self.iconx, self.icony, self.iconw, self.iconh, self.iconalign )
LogLuaEvent(0, 0, "security_up", "team", "blue")
LogLuaEvent(0, 0, "security_up", "team", "blue")
security_on("blue")
end
-----------------------------------------------------------------------------
-- Trigger-based security toggling
-----------------------------------------------------------------------------
base_security_trigger = not_team_only_trigger:new({ button = "" })
function base_security_trigger:ontrigger( player )
-- only take sec down if its up currently
local button = _G[self.button]
if button and button.sec_up then
self:onsecuritydown( player )
end
end
function base_security_trigger:onsecuritydown( player )
-- call the button's onin directly
local button = _G[self.button]
button.onin( button )
AddSchedule( self.button.."_security", SECURITY_LENGTH, function() self:onsecurityup() end )
end
function base_security_trigger:onsecurityup()
-- call the button's onout directly
local button = _G[self.button]
button.onout( button )
end
red_security_trigger = base_security_trigger:new( { team = Team.kRed, button = "button_red" } )
blue_security_trigger = base_security_trigger:new( { team = Team.kBlue, button = "button_blue" } )
-----------------------------------------------------------------------------
-- Hurts
-----------------------------------------------------------------------------
hurt = trigger_ff_script:new({ team = Team.kUnassigned })
function hurt:allowed( allowed_entity )
if IsPlayer( allowed_entity ) then
local player = CastToPlayer( allowed_entity )
if player:GetTeamId() == self.team then
return EVENT_ALLOWED
end
end
return EVENT_DISALLOWED
end
-- red lasers hurt blue and vice-versa
red_security_hurt = not_red_trigger:new({})
blue_security_hurt = not_blue_trigger:new({})
-- the trigger_hurts can also be named like this
red_laser_hurt = red_security_hurt
blue_laser_hurt = blue_security_hurt
red_laser_hurt = hurt:new({ team = Team.kBlue })
blue_laser_hurt = hurt:new({ team = Team.kRed })
-- function precache()
-- precache sounds
-- PrecacheSound("vox.blueup")
-- PrecacheSound("vox.bluedown")
-- PrecacheSound("vox.redup")
-- PrecacheSound("vox.reddown")
-- end
-----------------------------------------------------------------------------
-- Clips
-----------------------------------------------------------------------------
red_security_clip = clip_red:new()
blue_security_clip = clip_blue:new()
-------------------------
-- flaginfo
@ -177,15 +265,15 @@ function flaginfo( player_entity )
RemoveHudItem( player, "red-sec-up" )
RemoveHudItem( player, "blue-sec-up" )
if button_blue.sec_up == true then
AddHudIcon( player, button_blue.sec_up_icon, "blue-sec-up", button_blue.iconx, button_blue.icony, button_blue.iconw, button_blue.iconh, button_blue.iconalign )
else
AddHudIcon( player, button_blue.sec_down_icon, "blue-sec-down", button_blue.iconx, button_blue.icony, button_blue.iconw, button_blue.iconh, button_blue.iconalign )
end
if button_blue.sec_up == true then
AddHudIcon( player, button_blue.sec_up_icon, "blue-sec-up", button_blue.iconx, button_blue.icony, button_blue.iconw, button_blue.iconh, button_blue.iconalign )
else
AddHudIcon( player, button_blue.sec_down_icon, "blue-sec-down", button_blue.iconx, button_blue.icony, button_blue.iconw, button_blue.iconh, button_blue.iconalign )
end
if button_red.sec_up == true then
AddHudIcon( player, button_red.sec_up_icon, "red-sec-up", button_red.iconx, button_red.icony, button_red.iconw, button_red.iconh, button_red.iconalign )
else
AddHudIcon( player, button_red.sec_down_icon, "red-sec-down", button_red.iconx, button_red.icony, button_red.iconw, button_red.iconh, button_red.iconalign )
end
if button_red.sec_up == true then
AddHudIcon( player, button_red.sec_up_icon, "red-sec-up", button_red.iconx, button_red.icony, button_red.iconw, button_red.iconh, button_red.iconalign )
else
AddHudIcon( player, button_red.sec_down_icon, "red-sec-down", button_red.iconx, button_red.icony, button_red.iconw, button_red.iconh, button_red.iconalign )
end
end

View file

@ -97,6 +97,29 @@ end
no_annoyances = noannoyances
spawn_protection = noannoyances
-----------------------------------------------------------------------------
-- Useful trigger definitions
-----------------------------------------------------------------------------
-- team only triggers
team_only_trigger = trigger_ff_script:new({ team = Team.kUnassigned, allow = true })
function team_only_trigger:allowed( allowed_entity ) if allowed_entity and IsPlayer(allowed_entity) and CastToPlayer(allowed_entity):GetTeamId() == self.team then return self.allow else return not self.allow end end
-- triggers that allow any team except the given team
not_team_only_trigger = team_only_trigger:new({allow = false})
-- allow only if on the team
red_trigger = team_only_trigger:new({ team = Team.kRed })
blue_trigger = team_only_trigger:new({ team = Team.kBlue })
yellow_trigger = team_only_trigger:new({ team = Team.kYellow })
green_trigger = team_only_trigger:new({ team = Team.kGreen })
-- allow only if not on the team
not_red_trigger = not_team_only_trigger:new({ team = Team.kRed })
not_blue_trigger = not_team_only_trigger:new({ team = Team.kBlue })
not_yellow_trigger = not_team_only_trigger:new({ team = Team.kYellow })
not_green_trigger = not_team_only_trigger:new({ team = Team.kGreen })
-----------------------------------------------------------------------------
-- Trigger_ff_clips
-----------------------------------------------------------------------------