mirror of
https://github.com/fortressforever/fortressforever-scripts.git
synced 2024-11-10 15:22:07 +00:00
Added DEFENDERS_OBJECTIVE_ONCAP global to allow for easy removal of D objective (completely) if needed
Added UpdateDefendersObjective() function - makes it easier to change objective and removes some redundancy - also fixes some old issues with _onflag and _oncarrier code #58
This commit is contained in:
parent
47d91154c7
commit
6c5357fd3e
1 changed files with 28 additions and 48 deletions
|
@ -20,7 +20,9 @@ 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
|
||||
-- DEFENDERS_OBJECTIVE_ONCARRIER and ONFLAG set to false to keep objective on cap
|
||||
-- _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
|
||||
|
@ -140,6 +142,7 @@ function baseflag:spawn()
|
|||
|
||||
self.status = 0
|
||||
|
||||
UpdateDefendersObjective()
|
||||
update_hud()
|
||||
end
|
||||
|
||||
|
@ -156,11 +159,7 @@ function baseflag:ownercloak( owner_entity )
|
|||
|
||||
-- objective icon
|
||||
ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" )
|
||||
-- Check to see if we want to point to flag and do stuff
|
||||
if DEFENDERS_OBJECTIVE_ONFLAG then
|
||||
DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" )
|
||||
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )
|
||||
end
|
||||
UpdateDefendersObjective()
|
||||
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
|
||||
setup_return_timer()
|
||||
|
@ -186,11 +185,7 @@ function baseflag:dropitemcmd( owner_entity )
|
|||
|
||||
-- objective icon
|
||||
ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" )
|
||||
-- Check to see if we want to point to flag and do stuff
|
||||
if DEFENDERS_OBJECTIVE_ONFLAG then
|
||||
DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" )
|
||||
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )
|
||||
end
|
||||
UpdateDefendersObjective()
|
||||
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
|
||||
setup_return_timer()
|
||||
|
@ -210,11 +205,7 @@ function baseflag:onownerforcerespawn( owner_entity )
|
|||
|
||||
-- objective icon
|
||||
ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" )
|
||||
-- Check to see if we want to point to flag and do stuff
|
||||
if DEFENDERS_OBJECTIVE_ONFLAG then
|
||||
DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" )
|
||||
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )
|
||||
end
|
||||
UpdateDefendersObjective()
|
||||
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
|
||||
update_hud()
|
||||
|
@ -235,11 +226,7 @@ function baseflag:onreturn( )
|
|||
|
||||
-- objective icon
|
||||
ATTACKERS_OBJECTIVE_ENTITY = flag
|
||||
-- Check to see if we want to point to flag and do stuff
|
||||
if DEFENDERS_OBJECTIVE_ONFLAG then
|
||||
DEFENDERS_OBJECTIVE_ENTITY = flag
|
||||
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )
|
||||
end
|
||||
UpdateDefendersObjective()
|
||||
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
|
||||
destroy_return_timer()
|
||||
|
@ -303,10 +290,8 @@ function startup()
|
|||
flags_set_team( attackers )
|
||||
|
||||
ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" )
|
||||
-- Defenders should point to the cap and NOT the flag to avoid tracing the flag holder
|
||||
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
|
||||
|
@ -448,16 +433,7 @@ function base_id_flag:touch( touch_entity )
|
|||
|
||||
-- change objective icons
|
||||
ATTACKERS_OBJECTIVE_ENTITY = player
|
||||
if DEFENDERS_OBJECTIVE_ONFLAG then
|
||||
-- we want to target the flag ONLY when it's not being carried, so show D the cap instead
|
||||
DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..self.phase.."_cap" )
|
||||
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )
|
||||
end
|
||||
if DEFENDERS_OBJECTIVE_ONCARRIER then
|
||||
-- we want to target the flag, even if it's being carried (not suggested as D can wallhack)
|
||||
DEFENDERS_OBJECTIVE_ENTITY = player
|
||||
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )
|
||||
end
|
||||
UpdateDefendersObjective()
|
||||
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
UpdateObjectiveIcon( player, GetEntityByName( "cp"..self.phase.."_cap" ) )
|
||||
|
||||
|
@ -486,11 +462,7 @@ function base_id_flag:onownerdie( owner_entity )
|
|||
|
||||
-- change objective icon
|
||||
ATTACKERS_OBJECTIVE_ENTITY = flag
|
||||
-- Check to see if we want to point to flag and do stuff
|
||||
if DEFENDERS_OBJECTIVE_ONFLAG then
|
||||
DEFENDERS_OBJECTIVE_ENTITY = flag
|
||||
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )
|
||||
end
|
||||
UpdateDefendersObjective()
|
||||
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
UpdateObjectiveIcon( player, nil )
|
||||
|
||||
|
@ -567,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()
|
||||
|
@ -613,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)
|
||||
|
@ -656,10 +625,7 @@ function flag_start(flagname)
|
|||
|
||||
-- change objective icon
|
||||
ATTACKERS_OBJECTIVE_ENTITY = flag
|
||||
if DEFENDERS_OBJECTIVE_ONFLAG then
|
||||
DEFENDERS_OBJECTIVE_ENTITY = flag
|
||||
UpdateTeamObjectiveIcon( GetTeam(defenders), DEFENDERS_OBJECTIVE_ENTITY )
|
||||
end
|
||||
UpdateDefendersObjective()
|
||||
UpdateTeamObjectiveIcon( GetTeam(attackers), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
update_hud()
|
||||
end
|
||||
|
@ -693,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
|
||||
------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue