Page 1 of 1

[Tutorial] Adding captureable command posts to your CTF mode

Posted: Tue Nov 17, 2009 7:48 pm
by biohazard
This doesn't seem like an extremely simple procedure to me, and I don't see any other tutorials on the subject, so here goes. I am assuming that you are familiar with the usage of ZE in writing this tutorial.



First, on your map in ZeroEditor, make sure you're in the ctf layer.

Find one CP that should be capturable, and change its Capture Reigon on the right of the window to cpX_capture (X being the number of the CP) Next, create a new reigon and name it cpX_capture and make its property cpX_capture, and position it where you want your CPs capture reigon to be. Now, repeat this process for every CP you want capturable.

This is all fine and dandy; you are able to capture the CPs when you play on the map. However, the AI will not even try to capture them. Now you need to make the AI realize that there are some CPS, ripe for the taking.


So now you need to go to your DATA_ABC\Common\Scripts\ABC folder and find ABCc_ctf.lua

The first several lines of the file will look like this:
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

-- load the gametype script
Conquest = ScriptCB_DoFile("ObjectiveCTF")
ScriptCB_DoFile("setup_teams")

-- REP Attacking (attacker is always #1)
REP = 1;
CIS = 2;
-- These variables do not change
ATT = REP;
DEF = CIS;


function ScriptPostLoad()

SoundEvent_SetupTeams( REP, 'rep', CIS, 'cis' )

SetProperty("flag1", "GeometryName", "com_icon_republic_flag")
SetProperty("flag1", "CarriedGeometryName", "com_icon_republic_flag_carried")
SetProperty("flag2", "GeometryName", "com_icon_cis_flag")
SetProperty("flag2", "CarriedGeometryName", "com_icon_cis_flag_carried")

--This makes sure the flag is colorized when it has been dropped on the ground
SetClassProperty("com_item_flag", "DroppedColorize", 1)

--This is all the actual ctf objective setup
ctf = ObjectiveCTF:New{teamATT = REP, teamDEF = CIS, captureLimit = 5, textATT = "game.modes.ctf", textDEF = "game.modes.ctf2", hideCPs = true, multiplayerRules = true}
ctf:AddFlag{name = "flag1", homeRegion = "team1_capture", captureRegion = "team2_capture",
capRegionMarker = "hud_objective_icon_circle", capRegionMarkerScale = 3.0,
icon = "", mapIcon = "flag_icon", mapIconScale = 3.0}
ctf:AddFlag{name = "flag2", homeRegion = "team2_capture", captureRegion = "team1_capture",
capRegionMarker = "hud_objective_icon_circle", capRegionMarkerScale = 3.0,
icon = "", mapIcon = "flag_icon", mapIconScale = 3.0}

ctf:Start()

EnableSPHeroRules()

end


---------------------------------------------------------------------------
But our focus is on these lines:

Code: Select all

function ScriptPostLoad()

	SoundEvent_SetupTeams( REP, 'rep', CIS, 'cis' )
    
    SetProperty("flag1", "GeometryName", "com_icon_republic_flag")
    SetProperty("flag1", "CarriedGeometryName", "com_icon_republic_flag_carried")
    SetProperty("flag2", "GeometryName", "com_icon_cis_flag")
    SetProperty("flag2", "CarriedGeometryName", "com_icon_cis_flag_carried")

                --This makes sure the flag is colorized when it has been dropped on the ground
    SetClassProperty("com_item_flag", "DroppedColorize", 1)

    --This is all the actual ctf objective setup
    ctf = ObjectiveCTF:New{teamATT = REP, teamDEF = CIS, captureLimit = 5, textATT = "game.modes.ctf", textDEF = "game.modes.ctf2", hideCPs = true, multiplayerRules = true}
    ctf:AddFlag{name = "flag1", homeRegion = "team1_capture", captureRegion = "team2_capture",
                capRegionMarker = "hud_objective_icon_circle", capRegionMarkerScale = 3.0, 
                icon = "", mapIcon = "flag_icon", mapIconScale = 3.0}
    ctf:AddFlag{name = "flag2", homeRegion = "team2_capture", captureRegion = "team1_capture",
                capRegionMarker = "hud_objective_icon_circle", capRegionMarkerScale = 3.0, 
                icon = "", mapIcon = "flag_icon", mapIconScale = 3.0}
    
	ctf:Start()
	
    EnableSPHeroRules()
    
 end



It's difficult to explain well what needs to be done, so here's an example, where CPs 1 and 2 are uncapturable (these are home CPs, this is CTF, after all) and CPs 3 and 4 can be captured.

Code: Select all

function ScriptPostLoad()

	SoundEvent_SetupTeams( REP, 'rep', CIS, 'cis' )
    
    SetProperty("flag1", "GeometryName", "com_icon_republic_flag")
    SetProperty("flag1", "CarriedGeometryName", "com_icon_republic_flag_carried")
    SetProperty("flag2", "GeometryName", "com_icon_cis_flag")
    SetProperty("flag2", "CarriedGeometryName", "com_icon_cis_flag_carried")

                --This makes sure the flag is colorized when it has been dropped on the ground
    SetClassProperty("com_item_flag", "DroppedColorize", 1)

    --This is all the actual ctf objective setup
    ctf = ObjectiveCTF:New{teamATT = REP, teamDEF = CIS, captureLimit = 5, textATT = "game.modes.ctf", textDEF = "game.modes.ctf2", hideCPs = true, multiplayerRules = true}
    ctf:AddFlag{name = "flag1", homeRegion = "team1_capture", captureRegion = "team2_capture",
                capRegionMarker = "hud_objective_icon_circle", capRegionMarkerScale = 3.0, 
                icon = "", mapIcon = "flag_icon", mapIconScale = 3.0}
    ctf:AddFlag{name = "flag2", homeRegion = "team2_capture", captureRegion = "team1_capture",
                capRegionMarker = "hud_objective_icon_circle", capRegionMarkerScale = 3.0, 
                icon = "", mapIcon = "flag_icon", mapIconScale = 3.0}




    --This defines the CPs.  These need to happen first
    cp3 = CommandPost:New{name = "ctf_cp3"}
    cp4 = CommandPost:New{name = "ctf_cp4"}
    
    
    
    --This sets up the actual objective.  This needs to happen after cp's are defined
    ctf = Objectivectf:New{teamATT = ATT, teamDEF = DEF, 
                                     textATT = "game.modes.con", 
                                     textDEF = "game.modes.con2",
                                     multiplayerRules = true}
    
    --This adds the CPs to the objective.  This needs to happen after the objective is set up
    ctf:AddCommandPost(cp3)
    ctf:AddCommandPost(cp4)    



    
	ctf:Start()
	
    EnableSPHeroRules()
    
 end
As you can see, you must add the lines

Code: Select all

    cp3 = CommandPost:New{name = "ctf_cp3"}
    cp4 = CommandPost:New{name = "ctf_cp4"}
for each CP

And these lines next

Code: Select all

    ctf = Objectivectf:New{teamATT = ATT, teamDEF = DEF, 
                                     textATT = "game.modes.con", 
                                     textDEF = "game.modes.con2",
                                     multiplayerRules = true}
and then these

Code: Select all

    ctf:AddCommandPost(cp3)
    ctf:AddCommandPost(cp4)   
for each CP.


Note that, though the AI will go for the CPs using this, the flags seem to be a bit more of a priority.

Re: [Tutorial] Adding captureable command posts to your CTF mode

Posted: Tue Nov 17, 2009 7:52 pm
by YaNkFaN
there's only one problem with this...if you set all the cps to be capturable, then there is the possibility that all the cps on your team get captured ( which is 2 if you do normal ctf), you will not be able to spawn and thus the game will end stupidly.

Though I do have to say that your idea looks interesting (ie there are multiple goals with capturing cps and flags) try it out see if it works and get back to us on how you think the gameplay is cause i may want to try this out

Re: [Tutorial] Adding captureable command posts to your CTF mode

Posted: Tue Nov 17, 2009 7:55 pm
by biohazard
On my Dee'ja Peak map, it seems to be working well; 2 CPs (where the flags are located) are uncapturable while two CPs between them are capturable. This makes the battle much more dynamic and enjoyable, and makes walking from one CP to another much less bland and repetitive.

Re: [Tutorial] Adding captureable command posts to your CTF mode

Posted: Wed Nov 18, 2009 2:47 pm
by 501st_commander
biohazard wrote:On my Dee'ja Peak map, it seems to be working well; 2 CPs (where the flags are located) are uncapturable while two CPs between them are capturable. This makes the battle much more dynamic and enjoyable, and makes walking from one CP to another much less bland and repetitive.
i like that idea, i must try out that map

Re: [Tutorial] Adding captureable command posts to your CTF mode

Posted: Fri Nov 20, 2009 7:50 am
by biohazard
I found a mistake in my tutorial - CTF CPs are called ctf_cpX as opposed to conquest's being just cpX