Page 1 of 1

AI ignores objectives

Posted: Tue Aug 16, 2011 8:35 pm
by wishihadaname
For some reason when the AI reaches objective #5 in my campaign script they stop following the AI scripts and go into deathmatch mode instead. It can't be anything to do with previous objectives because objective 5 is currently where the script is starting. The AI is also ignoring the set unit count command to increase the number of rebels. I'm rather thorougly confused at this poiint, could anyone point out any mistakes I made in this code and or help me resolve this issue?
Hidden/Spoiler:
-----------------------------------------
--OBJECTIVE 5: DEFEND THE LISTENING POST
-----------------------------------------

Objective5CP = CommandPost:New{name = "cp5"}
Objective5 = ObjectiveConquest:New{teamATT = DEF, teamDEF = ATT,
text = "level.TCR.objectives.smalltext.5", popupText = "level.TCR.objectives.bigtext.5",
timeLimit = 180}
Objective5:AddCommandPost(Objective5CP)

Objective5.OnStart = function (self)
MapAddEntityMarker("cp5", "hud_objective_icon_circle", 3.0, 1, "YELLOW", true)
SetProperty("cp7", "Team", 2)
Ambush("Darktrooper_drop1", 3, 6)
SetUnitCount (ALL, 30)
ScriptCB_PlayInGameMusic("rep_kas_amb_obj1_3_explore")
--KillObject ("cp4") UNCOMMENT IN FINAL BUILD
Imbgoal5a = AddAIGoal (5, "Defend", 2, "cp5")
DRKgoal5 = AddAIGoal (6, "Deathmatch", 1)
Allgoal5b = AddAIGoal (DEF, "Deathmatch", 1)
Impgoal5b = AddAIGoal (ATT, "Defend", 2, "cp5")
Allgoal5a = AddAIGoal (DEF, "Conquest", 2, "cp5")
end

Objective5.OnComplete = function (self)
ATTReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATTReinforcementCount + 50)
ShowMessageText("game.objectives.complete", ATT)
RespawnObject ("cp8")
RespawnObject ("cp9")
RespawnObject ("cp10")
RespawnObject ("ATST")
SetProperty("cp7", "Team", 1)
DeleteAIGoal(Impgoal5)
DeleteAIGoal(Imbgoal5)
DeleteAIGoal(DRKgoal5)
DeleteAIGoal(Allgoal5a)
DeleteAIGoal(Allgoal5b)
UnblockPlanningGraphArcs("Baseroad")

end