mirror of
https://github.com/fortressforever/fortressforever-scripts.git
synced 2024-11-25 05:50:58 +00:00
Merge pull request #13 from fortressforever/features/avd-defenders-objective
Fixed defender's objective tracking flag carrier AvD
This commit is contained in:
commit
0e52fbc505
1 changed files with 31 additions and 9 deletions
|
@ -20,6 +20,12 @@ if DEFENDERS == nil then DEFENDERS = Team.kRed; end
|
|||
--if MAP_LENGTH == nil then MAP_LENGTH = 1436; end -- 23 minutes 56 seconds, 4 seconds less than the default timelimit of 24 minutes.
|
||||
|
||||
if ATTACKERS_OBJECTIVE_ENTITY == nil then ATTACKERS_OBJECTIVE_ENTITY = nil end
|
||||
if DEFENDERS_OBJECTIVE_ENTITY == nil then DEFENDERS_OBJECTIVE_ENTITY = nil 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
|
||||
|
||||
INITIAL_FUSE_TIMER = 80
|
||||
BLOW_CP1_ROUTE_TIMER = 300
|
||||
|
@ -94,8 +100,8 @@ function startup( )
|
|||
AddSchedule("blow_cp2_extra_route", BLOW_CP2_ROUTE_TIMER, blow_cp2_extra_route )
|
||||
|
||||
ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" )
|
||||
UpdateDefendersObjective()
|
||||
UpdateTeamObjectiveIcon( GetTeam(ATTACKERS), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
UpdateTeamObjectiveIcon( GetTeam(DEFENDERS), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
end
|
||||
|
||||
function blow_first_gate( )
|
||||
|
@ -168,11 +174,11 @@ function player_spawn( player_entity )
|
|||
player:AddAmmo( Ammo.kCells, 200 )
|
||||
end
|
||||
|
||||
-- if player:GetTeamId() == ATTACKERS then
|
||||
if player:GetTeamId() == ATTACKERS then
|
||||
UpdateObjectiveIcon( player, ATTACKERS_OBJECTIVE_ENTITY )
|
||||
-- elseif player:GetTeamId() == DEFENDERS then
|
||||
-- UpdateObjectiveIcon( player, nil )
|
||||
-- end
|
||||
elseif player:GetTeamId() == DEFENDERS then
|
||||
UpdateObjectiveIcon( player, DEFENDERS_OBJECTIVE_ENTITY )
|
||||
end
|
||||
end
|
||||
|
||||
function addpoints( )
|
||||
|
@ -272,8 +278,8 @@ function base_ad_flag:touch( touch_entity )
|
|||
|
||||
-- change objective icons
|
||||
ATTACKERS_OBJECTIVE_ENTITY = player
|
||||
UpdateDefendersObjective()
|
||||
UpdateTeamObjectiveIcon( GetTeam(ATTACKERS), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
UpdateTeamObjectiveIcon( GetTeam(DEFENDERS), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
UpdateObjectiveIcon( player, GetEntityByName( "cp"..self.phase.."_cap" ) )
|
||||
|
||||
LogLuaEvent(player:GetId(), 0, "flag_touch", "flag_name", flag:GetName(), "player_origin", (string.format("%0.2f",player:GetOrigin().x) .. ", " .. string.format("%0.2f",player:GetOrigin().y) .. ", " .. string.format("%0.1f",player:GetOrigin().z) ), "player_health", "" .. player:GetHealth());
|
||||
|
@ -304,9 +310,9 @@ function base_ad_flag:onownerdie( owner_entity )
|
|||
|
||||
-- change objective icon
|
||||
ATTACKERS_OBJECTIVE_ENTITY = flag
|
||||
UpdateDefendersObjective()
|
||||
UpdateObjectiveIcon( player, nil )
|
||||
UpdateTeamObjectiveIcon( GetTeam(ATTACKERS), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
UpdateTeamObjectiveIcon( GetTeam(DEFENDERS), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
|
||||
-- remove flag icon from hud
|
||||
RemoveHudItem( player, flag:GetName() )
|
||||
|
@ -334,8 +340,8 @@ function base_ad_flag:onreturn( )
|
|||
|
||||
-- change objective icon
|
||||
ATTACKERS_OBJECTIVE_ENTITY = flag
|
||||
UpdateDefendersObjective()
|
||||
UpdateTeamObjectiveIcon( GetTeam(ATTACKERS), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
UpdateTeamObjectiveIcon( GetTeam(DEFENDERS), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
|
||||
LogLuaEvent(0, 0, "flag_returned","flag_name",flag:GetName());
|
||||
|
||||
|
@ -403,8 +409,9 @@ function base_ad_cap:oncapture( player, item )
|
|||
|
||||
-- remove objective icon
|
||||
ATTACKERS_OBJECTIVE_ENTITY = nil
|
||||
DEFENDERS_OBJECTIVE_ENTITY = nil
|
||||
UpdateTeamObjectiveIcon( GetTeam(ATTACKERS), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
UpdateTeamObjectiveIcon( GetTeam(DEFENDERS), ATTACKERS_OBJECTIVE_ENTITY )
|
||||
UpdateTeamObjectiveIcon( GetTeam(DEFENDERS), DEFENDERS_OBJECTIVE_ENTITY )
|
||||
|
||||
-- Remove previous phase flag
|
||||
flag_remove( item )
|
||||
|
@ -438,6 +445,7 @@ function cap_delay_timer( cap )
|
|||
|
||||
-- update objective icon
|
||||
ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" )
|
||||
UpdateDefendersObjective()
|
||||
|
||||
setup_door_timer( cap.doorname, cap.duration)
|
||||
ApplyToAll( { AT.kRemovePacks, AT.kRemoveProjectiles, AT.kRespawnPlayers, AT.kRemoveBuildables, AT.kRemoveRagdolls, AT.kStopPrimedGrens, AT.kReloadClips } )
|
||||
|
@ -621,6 +629,20 @@ function final_allowedmethod( self, player_entity )
|
|||
return (teamId == DEFENDERS and phase == 3)
|
||||
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 everything
|
||||
|
|
Loading…
Reference in a new issue