Skip to content

Commit

Permalink
Merge pull request #14 from fortressforever/features/id-defenders-obj…
Browse files Browse the repository at this point in the history
…ective

Fixed defender's objective tracking flag carrier ID
  • Loading branch information
squeek502 committed Mar 9, 2015
2 parents cf74cf2 + e1902e6 commit b219f4d
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 51 deletions.
18 changes: 9 additions & 9 deletions maps/ff_ksour.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ FLAG_RETURN_TIME = 60;
INITIAL_ROUND_DELAY = 45;
TEAM_SWITCH_DELAY = 4
NUM_PHASES = 4

DEFENDERS_OBJECTIVE_ONCAP = true
DEFENDERS_OBJECTIVE_ONCARRIER = false --set to true to follow flag when carried
DEFENDERS_OBJECTIVE_ONFLAG = false --set to true to follow flag ALWAYS
-----------------------------------------------------------------------------

-- sounds, right?
Expand Down Expand Up @@ -94,9 +98,8 @@ function startup()
flags_set_team( attackers )

ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" )
DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_cap" )
UpdateDefendersObjective()
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )
end

-- overwriting these functions so that there aren't repeat messages
Expand All @@ -105,7 +108,7 @@ function round_10secwarn() end

function base_id_cap:oncapture(player, item)
SmartSound(player, "yourteam.flagcap", "yourteam.flagcap", "otherteam.flagcap")
--SmartSound(player, "vox.yourcap", "vox.yourcap", "vox.enemycap")
--SmartSound(player, "vox.yourcap", "vox.yourcap", "vox.enemycap")
SmartSpeak(player, "CTF_YOUCAP", "CTF_TEAMCAP", "CTF_THEYCAP")
SmartMessage(player, "#FF_YOUCAP", "#FF_TEAMCAP", "#FF_OTHERTEAMCAP", Color.kGreen, Color.kGreen, Color.kRed)

Expand Down Expand Up @@ -134,12 +137,10 @@ function base_id_cap:oncapture(player, item)
if ROUND_DELAY > 30 then AddSchedule("flag_30secwarn", ROUND_DELAY-30, flag_30secwarn) end
if ROUND_DELAY > 10 then AddSchedule("flag_10secwarn", ROUND_DELAY-10, flag_10secwarn) end

-- change objective icon
-- clear objective icon
ATTACKERS_OBJECTIVE_ENTITY = nil
if DEFENDERS_OBJECTIVE_ONFLAG or DEFENDERS_OBJECTIVE_ONCARRIER then DEFENDERS_OBJECTIVE_ENTITY = nil
else DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_cap" ) end
UpdateDefendersObjective()
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )

setup_tobase_timer()
update_hud()
Expand Down Expand Up @@ -188,9 +189,8 @@ function switch_teams()

-- change objective icon
ATTACKERS_OBJECTIVE_ENTITY = flag
DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_cap" )
UpdateDefendersObjective()
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )

-- reset the timer on points
AddScheduleRepeating("addpoints", PERIOD_TIME, addpoints)
Expand Down
20 changes: 9 additions & 11 deletions maps/ff_napoli.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ TEAM_SWITCH_DELAY = 4
NUM_PHASES = 3
NONINITIAL_ROUND_DELAY = 45;
RESPAWN_AFTER_CAP = false

DEFENDERS_OBJECTIVE_ONCAP = true
DEFENDERS_OBJECTIVE_ONCARRIER = false --set to true to follow flag when carried
DEFENDERS_OBJECTIVE_ONFLAG = false --set to true to follow flag ALWAYS
-----------------------------------------------------------------------------
function respawnall()
BroadCastMessage( "Area Captured. Respawning..." )
Expand Down Expand Up @@ -99,9 +103,8 @@ function startup()
flags_set_team( attackers )

ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" )
DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_cap" )
UpdateDefendersObjective()
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )
end

-- overwriting these functions so that there aren't repeat messages
Expand Down Expand Up @@ -143,7 +146,7 @@ end

function base_id_cap:oncapture(player, item)
SmartSound(player, "yourteam.flagcap", "yourteam.flagcap", "otherteam.flagcap")
--SmartSound(player, "vox.yourcap", "vox.yourcap", "vox.enemycap")
--SmartSound(player, "vox.yourcap", "vox.yourcap", "vox.enemycap")
SmartSpeak(player, "CTF_YOUCAP", "CTF_TEAMCAP", "CTF_THEYCAP")
SmartMessage(player, "#FF_YOUCAP", "#FF_TEAMCAP", "#FF_OTHERTEAMCAP", Color.kGreen, Color.kGreen, Color.kRed)

Expand Down Expand Up @@ -189,10 +192,8 @@ function base_id_cap:oncapture(player, item)

-- clear objective icon
ATTACKERS_OBJECTIVE_ENTITY = nil
if DEFENDERS_OBJECTIVE_ONFLAG or DEFENDERS_OBJECTIVE_ONCARRIER then DEFENDERS_OBJECTIVE_ENTITY = nil
else DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_cap" ) end
UpdateDefendersObjective()
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )

setup_tobase_timer()
update_hud()
Expand Down Expand Up @@ -227,9 +228,8 @@ function switch_teams()

-- change objective icon
ATTACKERS_OBJECTIVE_ENTITY = flag
DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_cap" )
UpdateDefendersObjective()
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )

-- reset the timer on points
AddScheduleRepeating("addpoints", PERIOD_TIME, addpoints)
Expand Down Expand Up @@ -420,6 +420,4 @@ end

-- Don't want any body touching/triggering it except the detpack
function trigger_detpackable_door:allowed( trigger_entity ) return EVENT_DISALLOWED
end


end
19 changes: 12 additions & 7 deletions maps/ff_palermo.lua
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@

-- ff_palermo.lua

-----------------------------------------------------------------------------
-- includes
-----------------------------------------------------------------------------

IncludeScript("base_id_new");
IncludeScript("base_id");
IncludeScript("base_respawnturret");
IncludeScript("base_location");

-----------------------------------------------------------------------------

-- globals
-----------------------------------------------------------------------------

DEFENDERS_OBJECTIVE_ONCAP = true
DEFENDERS_OBJECTIVE_ONCARRIER = false --set to true to follow flag when carried
DEFENDERS_OBJECTIVE_ONFLAG = false --set to true to follow flag ALWAYS

-- custom startup
local startup_base = startup

function startup()
id_startup()

startup_base()

-- palermo specific stuff
-- lower trigger_hurt damage in water
OutputEvent( "trigger_hurt", "SetDamage", "42" )
end
Expand Down Expand Up @@ -103,8 +110,6 @@ function onroundreset()

attackers_palammotypeone.team = attackers
attackers_palgrenadepackone.team = attackers


end

bellbutton = func_button:new({})
Expand Down
54 changes: 30 additions & 24 deletions maps/includes/base_id.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ if onroundreset == nil then onroundreset = function() end end
if FLAG_RETURN_TIME == nil then FLAG_RETURN_TIME = 60; end
if ATTACKERS_OBJECTIVE_ENTITY == nil then ATTACKERS_OBJECTIVE_ENTITY = nil end
if DEFENDERS_OBJECTIVE_ENTITY == nil then DEFENDERS_OBJECTIVE_ENTITY = nil end
if DEFENDERS_OBJECTIVE_ONFLAG == nil then DEFENDERS_OBJECTIVE_ONFLAG = true end
if DEFENDERS_OBJECTIVE_ONCARRIER == nil then DEFENDERS_OBJECTIVE_ONCARRIER = true end
-- _ONCAP set to true; Defenders should always point to cap
if DEFENDERS_OBJECTIVE_ONCAP == nil then DEFENDERS_OBJECTIVE_ONCAP = true end
-- _OBJECTIVE_ONCARRIER and _ONFLAG set to false to keep objective on cap
if DEFENDERS_OBJECTIVE_ONFLAG == nil then DEFENDERS_OBJECTIVE_ONFLAG = false end
if DEFENDERS_OBJECTIVE_ONCARRIER == nil then DEFENDERS_OBJECTIVE_ONCARRIER = false end
if TEAM_SWITCH_DELAY == nil then TEAM_SWITCH_DELAY = 2 end
if RESPAWN_AFTER_CAP == nil then RESPAWN_AFTER_CAP = false end
if RESPAWN_DELAY == nil then RESPAWN_DELAY = 2 end
Expand Down Expand Up @@ -139,6 +142,7 @@ function baseflag:spawn()

self.status = 0

UpdateDefendersObjective()
update_hud()
end

Expand All @@ -155,9 +159,8 @@ function baseflag:ownercloak( owner_entity )

-- objective icon
ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" )
if DEFENDERS_OBJECTIVE_ONFLAG then DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" ) end
UpdateDefendersObjective()
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )

setup_return_timer()
update_hud()
Expand All @@ -182,9 +185,8 @@ function baseflag:dropitemcmd( owner_entity )

-- objective icon
ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" )
if DEFENDERS_OBJECTIVE_ONFLAG then DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" ) end
UpdateDefendersObjective()
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )

setup_return_timer()
update_hud()
Expand All @@ -203,9 +205,8 @@ function baseflag:onownerforcerespawn( owner_entity )

-- objective icon
ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" )
if DEFENDERS_OBJECTIVE_ONFLAG then DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" ) end
UpdateDefendersObjective()
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )

update_hud()
end
Expand All @@ -225,9 +226,8 @@ function baseflag:onreturn( )

-- objective icon
ATTACKERS_OBJECTIVE_ENTITY = flag
if DEFENDERS_OBJECTIVE_ONFLAG then DEFENDERS_OBJECTIVE_ENTITY = flag end
UpdateDefendersObjective()
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )

destroy_return_timer()
update_hud()
Expand Down Expand Up @@ -290,9 +290,8 @@ function startup()
flags_set_team( attackers )

ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" )
DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_cap" )
UpdateDefendersObjective()
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )
end

-- Give everyone a full resupply, but strip secondary grenades
Expand Down Expand Up @@ -434,10 +433,8 @@ function base_id_flag:touch( touch_entity )

-- change objective icons
ATTACKERS_OBJECTIVE_ENTITY = player
if DEFENDERS_OBJECTIVE_ONFLAG then DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..self.phase.."_cap" ) end
if DEFENDERS_OBJECTIVE_ONCARRIER then DEFENDERS_OBJECTIVE_ENTITY = player end
UpdateDefendersObjective()
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )
UpdateObjectiveIcon( player, GetEntityByName( "cp"..self.phase.."_cap" ) )

carried_by = player:GetName()
Expand Down Expand Up @@ -465,9 +462,8 @@ function base_id_flag:onownerdie( owner_entity )

-- change objective icon
ATTACKERS_OBJECTIVE_ENTITY = flag
if DEFENDERS_OBJECTIVE_ONFLAG then DEFENDERS_OBJECTIVE_ENTITY = flag end
UpdateDefendersObjective()
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )
UpdateObjectiveIcon( player, nil )

self.status = 2
Expand Down Expand Up @@ -543,10 +539,8 @@ function base_id_cap:oncapture(player, item)

-- clear objective icon
ATTACKERS_OBJECTIVE_ENTITY = nil
if DEFENDERS_OBJECTIVE_ONFLAG or DEFENDERS_OBJECTIVE_ONCARRIER then DEFENDERS_OBJECTIVE_ENTITY = nil
else DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_cap" ) end
UpdateDefendersObjective()
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )

setup_tobase_timer()
update_hud()
Expand Down Expand Up @@ -589,9 +583,8 @@ function round_end()

-- change objective icon
ATTACKERS_OBJECTIVE_ENTITY = flag
DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_cap" )
UpdateDefendersObjective()
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )

-- reset the timer on points
AddScheduleRepeating("addpoints", PERIOD_TIME, addpoints)
Expand Down Expand Up @@ -632,9 +625,8 @@ function flag_start(flagname)

-- change objective icon
ATTACKERS_OBJECTIVE_ENTITY = flag
if DEFENDERS_OBJECTIVE_ONFLAG then DEFENDERS_OBJECTIVE_ENTITY = flag end
UpdateDefendersObjective()
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )
update_hud()
end
function flag_30secwarn() BroadCastMessage("#AD_30SecReturn") end
Expand Down Expand Up @@ -667,6 +659,20 @@ function destroy_tobase_timer()
RemoveSchedule( "timer_tobase_schedule" )
end

function UpdateDefendersObjective()
-- Check to see what Defenders should be focused on and update
local flag = GetInfoScriptByName("cp"..phase.."_flag")
local carried = flag:IsCarried()
if (not carried and DEFENDERS_OBJECTIVE_ONFLAG) or (carried and DEFENDERS_OBJECTIVE_ONCARRIER) then
DEFENDERS_OBJECTIVE_ENTITY = flag
elseif DEFENDERS_OBJECTIVE_ONCAP then
DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName("cp"..phase.."_cap")
else
DEFENDERS_OBJECTIVE_ENTITY = nil
end
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )
end

------------------------------------------------
-- instanciate them
------------------------------------------------
Expand Down

0 comments on commit b219f4d

Please sign in to comment.