[Tutorial] Adding captureable command posts to your CTF mode

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
biohazard
Command Sergeant Major
Command Sergeant Major
Posts: 268
Joined: Sun Oct 18, 2009 8:20 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: http://www.youtube.com/watch?v=jWFk0XasQmE
Contact:

[Tutorial] Adding captureable command posts to your CTF mode

Post 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.
Last edited by biohazard on Fri Nov 20, 2009 7:51 am, edited 1 time in total.
YaNkFaN
Field Commander
Field Commander
Posts: 943
Joined: Sat Dec 13, 2008 8:17 am

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

Post 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
biohazard
Command Sergeant Major
Command Sergeant Major
Posts: 268
Joined: Sun Oct 18, 2009 8:20 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: http://www.youtube.com/watch?v=jWFk0XasQmE
Contact:

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

Post 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.
501st_commander
Master Bounty Hunter
Master Bounty Hunter
Posts: 1570
Joined: Wed Dec 10, 2008 7:48 pm

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

Post 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
biohazard
Command Sergeant Major
Command Sergeant Major
Posts: 268
Joined: Sun Oct 18, 2009 8:20 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: http://www.youtube.com/watch?v=jWFk0XasQmE
Contact:

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

Post by biohazard »

I found a mistake in my tutorial - CTF CPs are called ctf_cpX as opposed to conquest's being just cpX
Post Reply