How do I properly script a conquest objective?

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
User avatar
wishihadaname
Captain
Captain
Posts: 493
Joined: Fri Dec 28, 2007 2:10 pm
Projects :: The Corellian Resistance
Games I'm Playing :: Halo Reach and LOTRO
Location: Look to your left.... no, your other left....

How do I properly script a conquest objective?

Post by wishihadaname »

I think i have the code correct but maybe i'm missing something ingame. Could someone tell me exactly how to script a conquest objective for campaign mode? Here is my script for referance.
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

-- load the gametype script
ScriptCB_DoFile("MultiObjectiveContainer")
ScriptCB_DoFile("ObjectiveAssault")
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("ObjectiveGoto")
ScriptCB_DoFile("ObjectiveCTF")
ScriptCB_DoFile("ObjectiveTDM")
ScriptCB_DoFile("Ambush")
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()

SetAIDifficulty(0, 2, "hard")
EnableSPScriptedHeroes()
ScriptCB_SetGameRules("campaign")
DisableAIAutoBalance()
KillObject ("cp3")
KillObject ("cp1")
KillObject ("cp2")
KillObject ("tankdrop1")

onfirstspawn = OnCharacterSpawn(
function(character)
if character == 0 then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
BeginObjectivesTimer()
ScriptCB_EnableCommandPostVO(0)
ShowMessageText("changeme", ATT)

end
end)

--Get to the rally becon
Objective1 = ObjectiveGoto:New{TeamATT = ATT, TeamDEF = DEF,
text = "level.LPR.campaign.regroup1", popupText = "level.LPR.campaign.popup1",
regionName = "goto1", mapIcon = "hud_objective_icon_circle", AIGoalWeight = 0}


Objective1.OnStart = function(self)
AllowAISpawn(ATT, false)
AllowAISpawn(DEF, false)
att_obj1_aigoal = AddAIGoal(ATT, "Deathmatch", 100)
def_obj1_aigoal = AddAIGoal(DEF, "Deathmatch", 100)
MapAddEntityMarker("rep_walk_atte_beacon", "hud_objective_icon_circle", 3.0, 1, "YELLOW", true)

end

Objective1.OnComplete = function(self)
DeleteAIGoal(att_obj1_aigoal)
DeleteAIGoal(def_obj1_aigoal)
RespawnObject("cp3")
RespawnObject("cp2")
ShowMessageText("game.objectives.complete", ATT)
MapRemoveEntityMarker("rep_walk_atte_beacon")
ATTReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATTReinforcementCount + 15)


end

--Hold the rally point--


Objective2CP = CommandPost:New{name = "cp3"}
Objective2 = ObjectiveConquest:New{teamATT = DEF, teamDEF = ATT, textDEF = "level.LPR.campaign.regroupend1", popupText = "level.LPR.campaign.popup2", timeLimit = 120}
Objective2:AddCommandPost(Objective2CP)


Objective2.OnStart = function (self)

DEFGoal = AddAIGoal (DEF,"Conquest", 100, "cp3")
ATTGoal = AddAIGoal (ATT,"Defend", 100, "cp3")

MapAddEntityMarker("cp3", "hud_objective_icon_circle", 4.0, ATT, "YELLOW", true)

SetProperty ("cp3", "AISpawnWeight", 100)
SetProperty ("cp2", "AISpawnWeight", 100)
KillObject ("cp4")
AllowAISpawn(ATT, true)
AllowAISpawn(DEF, true)

end

Objective2.OnComplete = function (self)
MapRemoveEntityMarker("cp3")

ATTReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATTReinforcementCount + 15)
DeleteAIGoal(DEFGoal)
DeleteAIGoal(ATTGoal)

end

-- Aquire Objective 3 -------------------------------------------------------------
-- Get the radio working and call for backup--

Objective3 = ObjectiveCTF:New{teamATT = ATT, teamDEF = DEF, captureLimit = 1, text = "level.LPR.campaign.capture1", popupText = "level.LPR.campaign.popup3"}

Objective3:AddFlag{name = "pol_icon_disk", captureRegion = "Team1_Capture",
capRegionMarker = "hud_objective_icon_circle", capRegionMarkerScale = 3.0}

Objective3.OnStart = function (self)

AICanCaptureCP("cp3", DEF, false)

disk_capture_on = OnFlagPickUp(
function(flag, carrier)
if IsCharacterHuman(carrier) then
MapAddEntityMarker("cp3", "hud_objective_icon_circle", 4.0, ATT, "YELLOW", true)
end
end,
"pol_icon_disk"
)

disk_capture_off = OnFlagDrop(
function(flag, carrier)
if IsCharacterHuman(carrier) then
MapRemoveEntityMarker("cp3")
end
end,
"pol_icon_disk"
)
SetProperty ("cp3", "AISpawnWeight", 100)

DEFGoal = AddAIGoal (DEF, "Deathmatch" , 100)
ATTGoal = AddAIGoal (ATT, "Defend" , 100, "cp3")

AMBGoal = AddAIGoal (AMB, "Deathmatch", 1)
-- spawn Holodisk
Holocron1Spawn = GetPathPoint("HolodiskSpawn", 0) --gets the path point
CreateEntity("pol_icon_disk", Holocron1Spawn, "pol_icon_disk") --spawns the disk
SetProperty ("pol_icon_disk", "AllowAIPickUp", 0)

end
Objective3.OnComplete = function (self)
DeleteAIGoal(DEFGoal)
DeleteAIGoal(ATTGoal)
ReleaseFlagPickUp(disk_capture_on)
ReleaseFlagDrop(disk_capture_off)
OBJ2_ReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, OBJ2_ReinforcementCount + 40)
ShowMessageText("game.objectives.complete", ATT)
if self.winningTeam == self.teamDEF then

end
end
end

function BeginObjectivesTimer()
beginobjectivestimer = CreateTimer("beginobjectivestimer")
OnTimerElapse(BeginObjectives, beginobjectivestimer)
SetTimerValue(beginobjectivestimer, 2)
StartTimer(beginobjectivestimer)
end

function BeginObjectives()
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 5}
objectiveSequence:AddObjectiveSet(Objective1)
objectiveSequence:AddObjectiveSet(Objective2)
objectiveSequence:AddObjectiveSet(Objective3)

objectiveSequence:Start()

end
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: How do I properly script a conquest objective?

Post by [RDH]Zerted »

We don't write tutorials on creating campaign maps as every campaign tends to be different. Is there a certain issue you are having with your script? What do you think is missing?
User avatar
wishihadaname
Captain
Captain
Posts: 493
Joined: Fri Dec 28, 2007 2:10 pm
Projects :: The Corellian Resistance
Games I'm Playing :: Halo Reach and LOTRO
Location: Look to your left.... no, your other left....

Re: How do I properly script a conquest objective?

Post by wishihadaname »

I can't pin it down... There is some sort of issue with ctf and conquest objectives. Go to objectives work just fine but when i try to do anything else my game crashes without so much as a relavant error. Those timer messages I got apartently happend with every campaign map so that must mean something is really not working right. Ill just write exactly what I did, tell me if I missed something.

1) created a standard cp in the base layer, named it cp3 and labeled it cp3.
2) added a typical spawn path and capture region also in the base layer
3) created an objective to defend cp3 using code taken from the polis mesa campaign script and edited it.
4) munged it
5) tested it and it never works or gives a relevant error

Its worth noting that I killed and respawned cp3, its mostly designed so the player has to spawn a specific crash sight and doesn't spawn at the rally point (cp3).
User avatar
lucasfart
Sith
Sith
Posts: 1440
Joined: Tue Feb 24, 2009 5:32 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: Australia

Re: How do I properly script a conquest objective?

Post by lucasfart »

you should try using the mission scripter. its a really helpful program that does most of the work for you, without making any errors, making things a lot easier and quicker.

Download Link:
http://starwarsbattlefront.filefront.co ... pter;84754
User avatar
wishihadaname
Captain
Captain
Posts: 493
Joined: Fri Dec 28, 2007 2:10 pm
Projects :: The Corellian Resistance
Games I'm Playing :: Halo Reach and LOTRO
Location: Look to your left.... no, your other left....

Re: How do I properly script a conquest objective?

Post by wishihadaname »

I have it, and I used tried using code exported from it. Still doesn't work.

*edit* this... is....wierd.... I've tested it out and it turns out its not the conquest script thats not working, its something called a ditty timer. I replaced the conquest objective with an assault objective and behold! it works... the ctf objective #3 still doesn't work though... so does anyone see a common denominator here because i don't...
CTF and Conquest don't work
Goto and Assault do work
The coding is not to blame
I always get this as the last message of the log.
release self.dittyTimerResponse
What does that mean anyways?
Post Reply