From 5b669b3f9d1185d6bc2b7e0f852f9c38f889d7d3 Mon Sep 17 00:00:00 2001 From: alaswell Date: Mon, 22 Dec 2014 02:34:54 -0700 Subject: [PATCH 1/3] Added DEFENDERS_OBJECTIVE_ENTITY to base_ad.lua - defenders objective should point to cap always to avoid tracing the flag carrier (see issue #58) --- maps/includes/base_ad.lua | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/maps/includes/base_ad.lua b/maps/includes/base_ad.lua index a31e7de..74c5dff 100644 --- a/maps/includes/base_ad.lua +++ b/maps/includes/base_ad.lua @@ -1,5 +1,6 @@ -- base_ad.lua -- Attack / Defend gametype +-- Edited Last: Dr.Satan - 22/12/2014 ----------------------------------------------------------------------------- -- includes @@ -20,6 +21,7 @@ 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 INITIAL_FUSE_TIMER = 80 BLOW_CP1_ROUTE_TIMER = 300 @@ -94,8 +96,10 @@ function startup( ) AddSchedule("blow_cp2_extra_route", BLOW_CP2_ROUTE_TIMER, blow_cp2_extra_route ) ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" ) + -- Satan: Defenders should always point to the cap and NOT the flag + DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_cap" ) UpdateTeamObjectiveIcon( GetTeam(ATTACKERS), ATTACKERS_OBJECTIVE_ENTITY ) - UpdateTeamObjectiveIcon( GetTeam(DEFENDERS), ATTACKERS_OBJECTIVE_ENTITY ) + UpdateTeamObjectiveIcon( GetTeam(DEFENDERS), DEFENDERS_OBJECTIVE_ENTITY ) end function blow_first_gate( ) @@ -168,11 +172,12 @@ function player_spawn( player_entity ) player:AddAmmo( Ammo.kCells, 200 ) end --- if player:GetTeamId() == ATTACKERS then + -- Satan: We need this to keep the DEFENDERS pointing at the cap + 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( ) @@ -273,7 +278,6 @@ function base_ad_flag:touch( touch_entity ) -- change objective icons ATTACKERS_OBJECTIVE_ENTITY = player 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()); @@ -306,7 +310,6 @@ function base_ad_flag:onownerdie( owner_entity ) ATTACKERS_OBJECTIVE_ENTITY = flag UpdateObjectiveIcon( player, nil ) UpdateTeamObjectiveIcon( GetTeam(ATTACKERS), ATTACKERS_OBJECTIVE_ENTITY ) - UpdateTeamObjectiveIcon( GetTeam(DEFENDERS), ATTACKERS_OBJECTIVE_ENTITY ) -- remove flag icon from hud RemoveHudItem( player, flag:GetName() ) @@ -335,7 +338,6 @@ function base_ad_flag:onreturn( ) -- change objective icon ATTACKERS_OBJECTIVE_ENTITY = flag UpdateTeamObjectiveIcon( GetTeam(ATTACKERS), ATTACKERS_OBJECTIVE_ENTITY ) - UpdateTeamObjectiveIcon( GetTeam(DEFENDERS), ATTACKERS_OBJECTIVE_ENTITY ) LogLuaEvent(0, 0, "flag_returned","flag_name",flag:GetName()); @@ -403,8 +405,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 +441,8 @@ function cap_delay_timer( cap ) -- update objective icon ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" ) + -- Satan: Defenders should always point to the cap and NOT the flag + DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_cap" ) setup_door_timer( cap.doorname, cap.duration) ApplyToAll( { AT.kRemovePacks, AT.kRemoveProjectiles, AT.kRespawnPlayers, AT.kRemoveBuildables, AT.kRemoveRagdolls, AT.kStopPrimedGrens, AT.kReloadClips } ) From 0ed27a40b057637e91a711d2ae9ca60c8305232d Mon Sep 17 00:00:00 2001 From: alaswell Date: Fri, 26 Dec 2014 20:07:49 -0700 Subject: [PATCH 2/3] Removed unnecessary/redundant info I added (thanks squeek :D) --- maps/includes/base_ad.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/maps/includes/base_ad.lua b/maps/includes/base_ad.lua index 74c5dff..c997969 100644 --- a/maps/includes/base_ad.lua +++ b/maps/includes/base_ad.lua @@ -1,6 +1,5 @@ -- base_ad.lua -- Attack / Defend gametype --- Edited Last: Dr.Satan - 22/12/2014 ----------------------------------------------------------------------------- -- includes @@ -96,7 +95,7 @@ function startup( ) AddSchedule("blow_cp2_extra_route", BLOW_CP2_ROUTE_TIMER, blow_cp2_extra_route ) ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" ) - -- Satan: Defenders should always point to the cap and NOT the flag + -- Defenders should always point to the cap and NOT the flag DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_cap" ) UpdateTeamObjectiveIcon( GetTeam(ATTACKERS), ATTACKERS_OBJECTIVE_ENTITY ) UpdateTeamObjectiveIcon( GetTeam(DEFENDERS), DEFENDERS_OBJECTIVE_ENTITY ) @@ -172,7 +171,7 @@ function player_spawn( player_entity ) player:AddAmmo( Ammo.kCells, 200 ) end - -- Satan: We need this to keep the DEFENDERS pointing at the cap + -- We need this to keep the DEFENDERS pointing at the cap if player:GetTeamId() == ATTACKERS then UpdateObjectiveIcon( player, ATTACKERS_OBJECTIVE_ENTITY ) elseif player:GetTeamId() == DEFENDERS then @@ -441,7 +440,7 @@ function cap_delay_timer( cap ) -- update objective icon ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" ) - -- Satan: Defenders should always point to the cap and NOT the flag + -- Defenders should always point to the cap and NOT the flag DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_cap" ) setup_door_timer( cap.doorname, cap.duration) From dd72eaa6fb41950468dfdbbdb8142befa64a4e06 Mon Sep 17 00:00:00 2001 From: alaswell Date: Fri, 26 Dec 2014 20:33:12 -0700 Subject: [PATCH 3/3] May as well add this functionality to here too: Added DEFENDERS_OBJECTIVE_ONCAP, _ONFLAG, AND _ONCARRIER globals to allow for different objectives on D Added UpdateDefendersObjective() function - makes it easier to change objective and removes some redundancy --- maps/includes/base_ad.lua | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/maps/includes/base_ad.lua b/maps/includes/base_ad.lua index c997969..1c6ca14 100644 --- a/maps/includes/base_ad.lua +++ b/maps/includes/base_ad.lua @@ -21,6 +21,11 @@ if DEFENDERS == nil then DEFENDERS = Team.kRed; end 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 @@ -95,10 +100,8 @@ function startup( ) AddSchedule("blow_cp2_extra_route", BLOW_CP2_ROUTE_TIMER, blow_cp2_extra_route ) ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" ) - -- Defenders should always point to the cap and NOT the flag - DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_cap" ) + UpdateDefendersObjective() UpdateTeamObjectiveIcon( GetTeam(ATTACKERS), ATTACKERS_OBJECTIVE_ENTITY ) - UpdateTeamObjectiveIcon( GetTeam(DEFENDERS), DEFENDERS_OBJECTIVE_ENTITY ) end function blow_first_gate( ) @@ -171,7 +174,6 @@ function player_spawn( player_entity ) player:AddAmmo( Ammo.kCells, 200 ) end - -- We need this to keep the DEFENDERS pointing at the cap if player:GetTeamId() == ATTACKERS then UpdateObjectiveIcon( player, ATTACKERS_OBJECTIVE_ENTITY ) elseif player:GetTeamId() == DEFENDERS then @@ -276,6 +278,7 @@ function base_ad_flag:touch( touch_entity ) -- change objective icons ATTACKERS_OBJECTIVE_ENTITY = player + UpdateDefendersObjective() UpdateTeamObjectiveIcon( GetTeam(ATTACKERS), ATTACKERS_OBJECTIVE_ENTITY ) UpdateObjectiveIcon( player, GetEntityByName( "cp"..self.phase.."_cap" ) ) @@ -307,6 +310,7 @@ function base_ad_flag:onownerdie( owner_entity ) -- change objective icon ATTACKERS_OBJECTIVE_ENTITY = flag + UpdateDefendersObjective() UpdateObjectiveIcon( player, nil ) UpdateTeamObjectiveIcon( GetTeam(ATTACKERS), ATTACKERS_OBJECTIVE_ENTITY ) @@ -336,6 +340,7 @@ function base_ad_flag:onreturn( ) -- change objective icon ATTACKERS_OBJECTIVE_ENTITY = flag + UpdateDefendersObjective() UpdateTeamObjectiveIcon( GetTeam(ATTACKERS), ATTACKERS_OBJECTIVE_ENTITY ) LogLuaEvent(0, 0, "flag_returned","flag_name",flag:GetName()); @@ -440,8 +445,7 @@ function cap_delay_timer( cap ) -- update objective icon ATTACKERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_flag" ) - -- Defenders should always point to the cap and NOT the flag - DEFENDERS_OBJECTIVE_ENTITY = GetEntityByName( "cp"..phase.."_cap" ) + UpdateDefendersObjective() setup_door_timer( cap.doorname, cap.duration) ApplyToAll( { AT.kRemovePacks, AT.kRemoveProjectiles, AT.kRespawnPlayers, AT.kRemoveBuildables, AT.kRemoveRagdolls, AT.kStopPrimedGrens, AT.kReloadClips } ) @@ -625,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