Page 1 of 1

Whats the LUA function for increasing units (totally lost)

Posted: Fri Aug 19, 2011 4:45 pm
by wishihadaname
I must be having a brainfart and a temporary onset of blindness because I can't seem to figure out how to increase unit counts for a team in campaign mode. Anyone know off the top of their head what the line is? SetUnitCount (team, #of dudes) doesn't work.

Re: Whats the LUA function for increasing units

Posted: Fri Aug 19, 2011 4:54 pm
by CalvaryCptMike
Check the stock campaign scripts for reference. How many units are you trying to add? The code you're using should work.

Re: Whats the LUA function for increasing units

Posted: Fri Aug 19, 2011 5:19 pm
by wishihadaname
The only stock campaign that uses that line to boost numbers is geonosis and that line is commented out. I know there is another function that I used regularly in making landing at point rain but I can't remmember it and the computer the source files were on has long since gone the way of the dodo. I think it may have been AddUnitCount, i'll try it out and see what happens.

doesn't work, has anyone else gotten this to work before?

Re: Whats the LUA function for increasing units

Posted: Fri Aug 19, 2011 7:11 pm
by AQT
wishihadaname wrote:SetUnitCount (team, #of dudes) doesn't work.
It does work, as long as you keep all such lines for a team before function ScriptInit().

Re: Whats the LUA function for increasing units

Posted: Fri Aug 19, 2011 8:55 pm
by wishihadaname
Oddly it doesn't seem to work for me for some reason, I have it added in the on start function of objective 5 which is the first objective to be loaded in my current testing build, the add unit count and block path functions don't work but the rest plays out just fine. Here is the entire objective for reference.
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)
Imbgoal5a = AddAIGoal (5, "Defend", 2, "cp5")
DRKgoal5 = AddAIGoal (6, "Deathmatch", 1)
Impgoal5b = AddAIGoal (ATT, "Defend" , 2, "cp5")
Allgoal5a = AddAIGoal (DEF, "Conquest" , 2, "cp5")
MapAddEntityMarker("cp5", "hud_objective_icon_circle", 3.0, 1, "YELLOW", true)
SetProperty("cp7", "Team", 2)
SetUnitCount (2, 25)
BlockPlanningGraphArcs("Baseroad")
Ambush("Darktrooper_drop1", 3, 6)
ScriptCB_PlayInGameMusic("rep_kas_amb_obj1_3_explore")
--KillObject ("cp4") UNCOMMENT IN FINAL BUILD

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

Re: Whats the LUA function for increasing units

Posted: Sat Aug 20, 2011 4:11 am
by AQT
Is the maximum spawn count per available unit class for team 2 high enough to allow 25 units to spawn?

Re: Whats the LUA function for increasing units

Posted: Sat Aug 20, 2011 11:14 am
by wishihadaname
Yes, here is the ALL team setup.
Hidden/Spoiler:
all = {
team = ALL,
units = 5,
reinforcements = -1,
soldier = { "all_inf_civillian",1, 20},
assault = { "all_inf_rifleman",1, 30},
sniper = { "all_inf_engineer",1, 15},
engineer = { "all_inf_sniper",1, 15},

},
Strangely, when I was experimenting with the AddUnitCount line that doesn't actually do anything, the AI started following their objectives better, they actually sat on the CP instead of charging off like usual. I'll try adding the defunct line now and see what happens. Its an odd notion but maybe it will do something.

--edit, no good the alliance still has 5 units.

Re: Whats the LUA function for increasing units

Posted: Sat Aug 20, 2011 12:40 pm
by THEWULFMAN
Hidden/Spoiler:
all = {
team = ALL,
units = 5,
reinforcements = -1,
soldier = { "all_inf_civillian",1, 20},
assault = { "all_inf_rifleman",1, 30},
sniper = { "all_inf_engineer",1, 15},
engineer = { "all_inf_sniper",1, 15},

},
Try raising these numbers.

Re: Whats the LUA function for increasing units, still need

Posted: Wed Aug 24, 2011 10:00 pm
by wishihadaname
tried it and still no good. I think i'll make a test map and see if I can't get an AI increase working in a simpler enviroment first, will edit this post later with results. Basic script will be objective1 go here, objective 2 defend position with AI increase tied into end of objective 1. We'll see what happens.

ok so I tried it in a test map and it worked fine, but now i've got to figure out how to implement it into this map. I looked it up in my old landing at point rain script and I had all of those functions written the exact same way. I am at a complete loss here. I'll post my whole script if someone could help me look it over, i've read through a couple of times but could find no mistakes. Any and all help would be much appreciated.

EDIT
sorry for bump but i've figured out at least part of the problem. I was setting up ambush teams using the SetUnitCount line to define ambush teams so that probably was part of the problem. I worked over the lua but it didn't seem to fix the problem. The command is simply ignored, no error message generated. Could someone help me look over my lua? There must be a coding mistake I made somewhere along the line, conventions or something like that I would guess. Here is an updated copy could one of you guys please help me out here? this blasted script is the only thing keeping me from releasing TCR V1.1.
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--


ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("ObjectiveAssault")
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("ObjectiveCTF")
ScriptCB_DoFile("ObjectiveTDM")
ScriptCB_DoFile("ObjectiveGoto")
ScriptCB_DoFile("MultiObjectiveContainer")
ScriptCB_DoFile("Ambush")


-- Empire Attacking (attacker is always #1)
local ALL = 2
local IMP = 1
AMB = 3
SMB = 4
IMB = 5
DRK = 6
CIV = 7

-- These variables do not change
local ATT = 1
local DEF = 2

function ScriptPostLoad()
SetAIDifficulty(1, -3, "medium")
ScriptCB_SetGameRules("campaign")
DisableAIAutoBalance()
SetUberMode(1);
AddDeathRegion("dead1")
AddDeathRegion("dead2")
AllowAISpawn(ALL, false)
KillObject ("ATST")
SetUnitCount (ATT, 30)


------------------------------------------------------------
--This is code for cycling rifleman models
------------------------------------------------------------
--KinetosImpetus

SetClassProperty("all_inf_rifleman", "GeometryName", "all_inf_rebel_saboteur")
SetClassProperty("all_inf_rifleman", "GeometryLowRes", "all_inf_soldier_low1")
--this little part ^ was for debugging really, it isn't necessary

-- Timer for skins--

--interval is the number of seconds between model changes
--maxskin is the number of versions to use

interval = 10 --i had been testing this at 10 second waves, but it could be changed
--in MP, it will probably cause each 15 second spawn-wave to be the same model
skintimer = CreateTimer("timeout") -- i don't know what significance "timeout" has, copied from hoth campaign this way
SetTimerValue(skintimer , interval )
--ShowTimer(skintimer ) --uncomment this line to see the timer onscreen
skin = 1
maxskin = 3

OnTimerElapse(
function(timer)


if (skin == 1) then
SetClassProperty("all_inf_rifleman", "GeometryName", "all_inf_rebel_saboteur")
SetClassProperty("all_inf_rifleman", "GeometryLowRes", "all_inf_soldier_low1")
SetClassProperty("all_inf_civillian", "GeometryName", "all_inf_tatooinehansolo")
SetClassProperty("all_inf_civillian", "GeometryLowRes", "all_inf_tatooinehansolo_low1")
SetClassProperty("all_inf_engineer", "GeometryName", "mlt_inf_lancemen")
SetClassProperty("all_inf_engineer", "GeometryLowRes", "all_inf_vanguard_low1")
SetClassProperty("all_inf_sniper", "GeometryName", "Tython_inf_Cultist")
SetClassProperty("all_inf_sniper", "GeometryLowRes", "all_inf_soldier_low1")
end
if (skin == 2) then
SetClassProperty("all_inf_rifleman", "GeometryName", "mlt_inf_lancemen")
SetClassProperty("all_inf_rifleman", "GeometryLowRes", "all_inf_vanguard_low1")
SetClassProperty("all_inf_civillian", "GeometryName", "Tython_inf_Cultist")
SetClassProperty("all_inf_civillian", "GeometryLowRes", "all_inf_soldier_low1")
SetClassProperty("all_inf_engineer", "GeometryName", "all_inf_rebel_saboteur")
SetClassProperty("all_inf_engineer", "GeometryLowRes", "all_inf_soldier_low1")
SetClassProperty("all_inf_sniper", "GeometryName", "ilm_inf_scout")
SetClassProperty("all_inf_sniper", "GeometryLowRes", "all_inf_soldier_low1")
end
if (skin == 3) then
SetClassProperty("all_inf_rifleman", "GeometryName", "ilm_inf_scout")
SetClassProperty("all_inf_rifleman", "GeometryLowRes", "all_inf_soldier_low1")
SetClassProperty("all_inf_civillian", "GeometryName", "all_inf_vanguard")
SetClassProperty("all_inf_civillian", "GeometryLowRes", "all_inf_vanguard_low1")
SetClassProperty("all_inf_engineer", "GeometryName", "all_inf_engineer")
SetClassProperty("all_inf_engineer", "GeometryLowRes", "all_inf_engineer_low1")
SetClassProperty("all_inf_sniper", "GeometryName", "all_inf_rebel_saboteur")
SetClassProperty("all_inf_sniper", "GeometryLowRes", "all_inf_soldier_low1")
end




skin = skin + 1

if (skin > maxskin) then
skin = 1
end

--ShowTimer(nil)
--DestroyTimer(timer)



SetTimerValue(skintimer , interval )
StartTimer(skintimer)


end,
skintimer
)

-------------------------------------------------------------------------
--resume normal conquest script, or whatever gamemode...
--------------------------------------------------------------------------

StartTimer(skintimer) --starts the timer the first time, after it starts, it will restart itself one ending.

--------------wait start the timer first! ok, now go...
-----------------------------------------------------------------------

--CP removal for mission start-- MODIFIED FOR TESTING
--------------------------------
KillObject ("cp2")
KillObject ("cp3")
--KillObject ("cp5")
KillObject ("cp6")
--KillObject ("cp7")
KillObject ("cp8")
KillObject ("cp9")
KillObject ("cp10")
KillObject ("cp11")


-----------------------------------------------
--TESTING SPECIFIC MODS, DELETE BEFORE SHIPPING
-----------------------------------------------
-- SetProperty("cp4", "Team", 1)
-- KillObject ("cp1")
-- -- spawn Holodisk for objective 4
-- 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)
-- SetProperty("cp5", "Team", 1)
-- KillObject("cp4")
-- SetProperty("cp7", "Team", 2)
-- AllowAISpawn(DEF, true)
-- ATTReinforcementCount = GetReinforcementCount(ATT)
-- SetReinforcementCount(ATT, ATTReinforcementCount + 30)
------------------------------------------------------------

onfirstspawn = OnCharacterSpawn(
function(character)
if character == 0 then
ShowPopup("level.geo1.hints.hints")
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
BeginObjectivesTimer()
ScriptCB_EnableCommandPostVO(0)

end
end)

----------------------------------------
--OBJECTIVE 1: LINK UP WITH SCOUT TEAM
------------------------------------------
Objective1 = ObjectiveGoto:New{TeamATT = ATT, --Make a new objective for the attacking team.
text = "level.TCR.objectives.smalltext.1", popupText = "level.TCR.objectives.bigtext.1",
--above we tell the game to show the objective we typed in the localisation tool, near the map and in the upperscreen.
regionName = "goto1", mapIcon = "hud_objective_icon_circle", AIGoalWeight = 0}
-- we just told the game to wich region(wich we placed and named in zeroeditor we want the player to go and that the game should indicate this place on the map with a yellow marker. The A.I. Will have no interest in going here(AIGoalWeight = 0)
Objective1.OnStart = function(self)

ActivateRegion("Info1")
infopopup1 = OnEnterRegion(
function(region, player)
if IsCharacterHuman(player) then
ShowObjectiveTextPopup("level.TCR.objectives.info.1")
DeactivateRegion("Info1")
end
end,
"Info1"
)
PlayAnimation("ImpTrans1")
AttGoal1 = AddAIGoal (ATT, "Conquest", 1, "cp4")
MapAddEntityMarker("goto", "hud_objective_icon", 3.0, 1, "YELLOW", true)
-- here we told the A.I. what to do.
end

Objective1.OnComplete = function(self)
SetUnitCount (ATT, 30) --testing line
KillObject ("cp1")
DeleteAIGoal(AttGoal1)
ShowMessageText("game.objectives.complete")
--when the objective is completed, we don't need the A.I. goal anymore, and we want to inform the player that the objective is completed by showing this in the top of the screen and with a popup.
MapRemoveEntityMarker("goto")
-- we don't need that marker anymore so we delete that.
end

------------------------------------
--OBJECTIVE 2: KILL THE SNIPERS
------------------------------------
Snipers = TargetType:New{classname = "all_inf_sniper", killLimit = 6, icon = "hud_objective_icon_circle"}

Objective2 = ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.TCR.objectives.smalltext.2", popupText = "level.TCR.objectives.bigtext.2", AIGoalWeight = 0}
Objective2:AddTarget(Snipers)


Objective2.OnStart = function(self)
Ambush("sniper_ambush_spawn1", 6, 3)
--Ambush("soldier_ambush_spawn1", 20, 4)
imp_goal2 = AddAIGoal(ATT, "Defend", 1, "cp4")
soldier_goal = AddAIGoal(ATT, "Deathmatch", 1)
scouts_goal = AddAIGoal(3, "Conquest", 1, "cp4")
end

Objective2.OnComplete = function(self)
SetUnitCount (IMP, 12)
ATTReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATTReinforcementCount + 20)
AllowAISpawn(ALL, true)
RespawnObject ("cp2")
RespawnObject ("cp3")
SetUnitCount(ALL, 10)
ShowMessageText("game.objectives.complete", ATT)
DeleteAIGoal(scouts_goal)
DeleteAIGoal(soldier_goal)
DeleteAIGoal(imp_goal2)

end

------------------------------------
--OBJECTIVE 3: RE-CAPTURE THE FLANK
------------------------------------
Objective3CP1 = CommandPost:New{name = "cp2"}
Objective3CP2 = CommandPost:New{name = "cp3"}
Objective3 = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, text = "level.TCR.objectives.smalltext.3", popupText = "level.TCR.objectives.bigtext.3"}
Objective3:AddCommandPost(Objective3CP1)
Objective3:AddCommandPost(Objective3CP2)

Objective3.OnStart = function(self)
SetProperty("cp3", "Team", 2)
SetProperty("cp2", "Team", 2)
PlayAnimation("RebTrans1")
AICanCaptureCP("cp3", ATT, true)
AICanCaptureCP("cp3", DEF, false)
AICanCaptureCP("cp2", ATT, true)
AICanCaptureCP("cp2", DEF, false)
Imp_goal3a = AddAIGoal(ATT, "Conquest", 2, "cp3")
All_goal3a = AddAIGoal(DEF, "Defend", 2, "cp3")
Imp_goal3b = AddAIGoal(ATT, "Conquest", 2, "cp2")
All_goal3b = AddAIGoal(DEF, "Defend", 2, "cp2")
end

Objective3.OnComplete = function(self)

-- spawn Holodisk for objective 4
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)
SetProperty("cp7", "Team", 2)
SetProperty("cp7", "CaptureRegion", "")
ATTReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATTReinforcementCount + 15)
ShowMessageText("game.objectives.complete", ATT)
DeleteAIGoal(Imp_goal3a)
DeleteAIGoal(Imp_goal3b)
DeleteAIGoal(All_goal3a)
DeleteAIGoal(All_goal3b)
KillObject ("cp2")
KillObject ("cp3")
RespawnObject ("cp5")
RespawnObject ("cp7")
SetProperty("cp7", "Team", 2)

end

-----------------------------------------------
--OBJECTIVE 4: CAPTURE SIGNAL ENCRIPTION CODES
-----------------------------------------------

Objective4 = ObjectiveCTF:New{teamATT = ATT, teamDEF = DEF, captureLimit = 1, text = "level.TCR.objectives.smalltext.4", popupText = "level.TCR.objectives.bigtext.4"}

Objective4:AddFlag{name = "pol_icon_disk", captureRegion = "cp4_disk_capture",
capRegionMarker = "hud_objective_icon_circle", capRegionMarkerScale = 3.0,
mapIcon = "flag_icon", mapIconScale = 2.0}

Objective4.OnStart = function (self)

ActivateRegion("Info2")
infopopup2 = OnEnterRegion(
function(region, player)
if IsCharacterHuman(player) then
ShowObjectiveTextPopup("level.TCR.objectives.info.2")
SetProperty("cp5", "Team", 1)
Ambush("civ_ambush_spawn2", 20, 7)
DeactivateRegion("Info2")
end
end,
"Info2"
)

BlockPlanningGraphArcs("Baseroad")
SetupAmbushTrigger("Battletrip1", "soldier_ambush_spawn1", 20, 4)
SetupAmbushTrigger("Battletrip2", "Imp_ambush_spawn1", 15, 5)
SetupAmbushTrigger("Snipertrip1", "sniper_ambush_spawn2", 6, 3)
ImpGoal4 = AddAIGoal (ATT, "Defend" , 2, "pol_icon_disk")
RebGoal4 = AddAIGoal (DEF, "Defend" , 2, "pol_icon_disk")
ImpAmbGoal4 = AddAIGoal (5, "Conquest" , 2, "cp7")
CivAmbGoal4 = AddAIGoal (7, "Deathmatch" , 2)
RebAmbGoal4a = AddAIGoal (4, "Deathmatch" , 2)
RebAmbGoal4b = AddAIGoal (3, "Deathmatch" , 2)

end

Objective4.OnComplete = function (self)
ATTReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATTReinforcementCount + 15)
DeleteAIGoal(Impgoal4)
DeleteAIGoal(ImpAmbgoal4)
--SetUnitCount (2, 30)
DeleteAIGoal(Allgoal4)
DeleteAIGoal(CivAmbGoal4)
DeleteAIGoal(AllAmbgoal4a)
DeleteAIGoal(AllAmbgoal4b)

end

-----------------------------------------
--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, timeLimitWiningTeam = ATT}
Objective5:AddCommandPost(Objective5CP)

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

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


--------------------------------------
--OBJECTIVE 6: CAPTURE THE REBEL BASE
--------------------------------------
Objective6CP1 = CommandPost:New{name = "cp8"}
Objective6CP2 = CommandPost:New{name = "cp9"}
Objective6CP3 = CommandPost:New{name = "cp10"}
Objective6 = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, text = "level.TCR.objectives.smalltext.6", popupText = "level.TCR.objectives.bigtext.6"}
Objective6:AddCommandPost(Objective6CP1)
Objective6:AddCommandPost(Objective6CP2)
Objective6:AddCommandPost(Objective6CP3)

Objective6.OnStart = function(self)

--Region to trip transport takeoff

ActivateRegion("takeoff")
rebelrun = OnEnterRegion(
function(region, player)
if IsCharacterHuman(player) then
PlayAnimation("RebRun")
DeactivateRegion("takeoff")
end
end,
"rebelrun"
)
-------------------------------------------
--Timer to get troopers to deploy as needed from gunships
gundrop= CreateTimer("gundrop")
SetTimerValue(gundrop, (20))
StartTimer(gundrop)
OnTimerElapse(
function(gundrop)
Ambush("gunship_spawn1", 15, 5)

DestroyTimer(gundrop)
end,
gundrop
)
---------------------------------------------
---everyday scipt stuff continued

SetUnitCount(IMP, 30)
SetUnitCount(ALL, 45)
PlayAnimation("Imptrans2")
SetupAmbushTrigger("Ridgetrap1", "sniper_ambush_spawn3", 6, 3)
SetupAmbushTrigger("Citytrap1", "soldier_ambush_spawn2", 20, 4)
SetupAmbushTrigger("civamb1", "civ_ambush_spawn1", 20, 7)
Imp_goal6a = AddAIGoal(ATT, "Conquest", 2, "cp8")
All_goal6a = AddAIGoal(DEF, "Defend", 2, "cp8")
Imp_goal6b = AddAIGoal(ATT, "Conquest", 2, "cp9")
All_goal6b = AddAIGoal(DEF, "Defend", 2, "cp9")
Imp_goal6c = AddAIGoal(ATT, "Conquest", 2, "cp10")
All_goal6c = AddAIGoal(DEF, "Defend", 2, "cp10")
IMB_goal6 = AddAIGoal(5, "Conquest", 2, "cp10")
SNI_goal6 = AddAIGoal(3, "Deathmatch", 2)
AMB_goal6 = AddAIGoal(4, "Defend", 2, "cp9")
CIV_goal6 = AddAIGoal(7, "Deathmatch", 2)
end

Objective6.OnComplete = function(self)
RespawnObject ("cp11")
ShowMessageText("game.objectives.complete", ATT)
DeleteAIGoal(Imp_goal6a)
DeleteAIGoal(Imp_goal6b)
DeleteAIGoal(Imp_goal6c)
DeleteAIGoal(All_goal6a)
DeleteAIGoal(All_goal6b)
DeleteAIGoal(All_goal6c)
DeleteAIGoal(IMB_goal6)
DeleteAIGoal(SNI_goal6)
DeleteAIGoal(AMB_goal6)
DeleteAIGoal(CIV_goal6)

end




end

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

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

objectiveSequence:Start()

end




---------------------------------------------------------------------------
-- FUNCTION: ScriptInit
-- PURPOSE: This function is only run once
-- INPUT:
-- OUTPUT:
-- NOTES: The name, 'ScriptInit' is a chosen convention, and each
-- mission script must contain a version of this function, as
-- it is called from C to start the mission.
---------------------------------------------------------------------------

function ScriptInit()

ReadDataFile("dc:Load\\loadscreen2.lvl")

ReadDataFile("ingame.lvl")



SetMaxFlyHeight(0)
SetMaxPlayerFlyHeight(0)

SetMinFlyHeight(-300)
SetMinPlayerFlyHeight(-300)


SetMemoryPoolSize ("ClothData",20)
SetMemoryPoolSize ("Combo",50) -- should be ~ 2x number of jedi classes
SetMemoryPoolSize ("Combo::State",650) -- should be ~12x #Combo
SetMemoryPoolSize ("Combo::Transition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Condition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Attack",550) -- should be ~8-12x #Combo
SetMemoryPoolSize ("Combo::DamageSample",6000) -- should be ~8-12x #Combo::Attack
SetMemoryPoolSize ("Combo::Deflect",100) -- should be ~1x #combo


ReadDataFile("sound\\kas.lvl;kas2gcw")
ReadDataFile("sound\\spa.lvl;spa1gcw")
ReadDataFile("dc:SIDE\\all.lvl",
"all_inf_rifleman",
"all_inf_civillian",
"all_inf_sniper",
"all_inf_engineer",
"rep_hover_swampspeeder_2man",
"all_hero_hansolo_tat")

ReadDataFile("dc:SIDE\\imp.lvl",
"imp_inf_rifleman",
"imp_inf_rocketeer",
"imp_inf_engineer",
"imp_inf_sniper",
"imp_fly_tiebomber_sc",
"imp_inf_officer",
"imp_inf_dark_trooper",
"imp_hero_bobafett",
"imp_hover_fightertank",
"imp_walk_atst",
"imp_hover_speederbike",
"imp_fly_destroyer_dome" )

ReadDataFile("dc:SIDE\\tur.lvl",
"tur_bldg_tat_barge",
"tur_bldg_recoilless_nab_auto",
"tur_bldg_laser")

SetupTeams{
all = {
team = ALL,
units = 5,
reinforcements = -1,
soldier = { "all_inf_civillian",2, 20},
assault = { "all_inf_rifleman",1, 30},
sniper = { "all_inf_engineer",1, 15},
engineer = { "all_inf_sniper",1, 15},

},
imp = {
team = IMP,
units = 10,
reinforcements = 15,
soldier = { "imp_inf_rifleman",1, 100},
assault = { "imp_inf_rocketeer",1,15},
engineer = { "imp_inf_engineer",1,7},
sniper = { "imp_inf_sniper",1,7},
officer = { "imp_inf_officer",1,7},
--special = { "imp_inf_dark_trooper",1,3},
},
AMB = {
team = AMB,
units = 6,
reinforcements = -1,
soldier = { "all_inf_sniper", 6, 6},
},
SMB = {
team = SMB,
units = 20,
reinforcements = -1,
soldier = {"all_inf_civillian", 10, 10},
engineer = {"all_inf_engineer", 5, 5},
officer = {"all_inf_rifleman", 5, 5},
},
IMB = {
team = IMB,
units = 15,
reinforcements = -1,
soldier = {"imp_inf_rifleman", 5, 5},
assault = {"imp_inf_rocketeer", 4, 4},
sniper = {"imp_inf_sniper", 2, 2},
engineer = {"imp_inf_engineer", 3, 3},
officer = {"imp_inf_officer", 1, 1},
},
DRK = {
team = DRK,
units = 3,
reinforcements = -1,
soldier = {"imp_inf_dark_trooper", 3, 3},
},
CIV = {
team = CIV,
units = 20,
reinforcements = -1,
soldier = {"all_inf_civillian", 20, 20},
}
}

--Setup sniper ambush team
SetTeamAsEnemy(3, ATT)
SetTeamAsEnemy(ATT, 3)
SetTeamAsFriend(3, DEF)
SetTeamAsFriend(DEF, 3)

--setup soldier ambush team

SetTeamAsEnemy(4, ATT)
SetTeamAsEnemy(ATT, 4)
SetTeamAsFriend(4, DEF)
SetTeamAsFriend(DEF, 4)
SetTeamAsFriend(4, 3)
SetTeamAsFriend(3, 4)

--setup imperial soldier ambush team

SetTeamAsEnemy(5, DEF)
SetTeamAsEnemy(DEF, 5)
SetTeamAsFriend(5, ATT)
SetTeamAsFriend(ATT, 5)
SetTeamAsEnemy(4, 5)
SetTeamAsEnemy(5, 4)
SetTeamAsEnemy(3, 5)
SetTeamAsEnemy(5, 3)

--setup darktrooper ambush team
SetTeamAsEnemy(6, DEF)
SetTeamAsEnemy(DEF, 6)
SetTeamAsFriend(6, ATT)
SetTeamAsFriend(ATT, 6)
SetTeamAsEnemy(4, 6)
SetTeamAsEnemy(6, 4)
SetTeamAsEnemy(3, 6)
SetTeamAsEnemy(6, 3)
SetTeamAsFriend(6, 5)
SetTeamAsFriend(5, 6)

--Setup Civillian Mob
SetTeamAsEnemy(7, ATT)
SetTeamAsEnemy(ATT, 7)
SetTeamAsFriend(7, DEF)
SetTeamAsFriend(DEF, 7)
SetTeamAsEnemy(6, 7)
SetTeamAsEnemy(7, 6)
SetTeamAsEnemy(5, 7)
SetTeamAsEnemy(7, 5)
SetTeamAsFriend(4, 7)
SetTeamAsFriend(7, 4)
SetTeamAsFriend(3, 7)
SetTeamAsFriend(7, 3)



-- SetHeroClass(ALL, "all_hero_hansolo_tat")
-- SetHeroClass(IMP, "imp_hero_bobafett")

-- Level Stats
ClearWalkers()
AddWalkerType(0, 0) -- special -> droidekas
AddWalkerType(1, 4) -- 1x2 (1 pair of legs)
AddWalkerType(2, 0) -- 2x2 (2 pairs of legs)
AddWalkerType(3, 0) -- 3x2 (3 pairs of legs)

local weaponCnt = 1024
SetMemoryPoolSize("Aimer", 75)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 1024)
SetMemoryPoolSize("EnergyBar", weaponCnt)
SetMemoryPoolSize("EntityCloth", 32)
SetMemoryPoolSize("EntityFlyer", 32)
SetMemoryPoolSize("CommandFlyer", 2)
SetMemoryPoolSize("EntityHover", 32)
SetMemoryPoolSize("EntityLight", 200)
SetMemoryPoolSize("Music", 50)
SetMemoryPoolSize("EntitySoundStream", 4)
SetMemoryPoolSize("EntitySoundStatic", 32)
SetMemoryPoolSize("MountedTurret", 32)
SetMemoryPoolSize("Navigator", 128)
SetMemoryPoolSize("FlagItem", 2)
SetMemoryPoolSize("Obstacle", 1024)
SetMemoryPoolSize("PathNode", 1024)
SetMemoryPoolSize("SoundSpaceRegion", 64)
SetMemoryPoolSize("TreeGridStack", 1024)
SetMemoryPoolSize("UnitAgent", 128)
SetMemoryPoolSize("SoldierAnimation", 260)
SetMemoryPoolSize("UnitController", 128)
SetMemoryPoolSize("Weapon", weaponCnt)

SetSpawnDelay(30.0, 0.25)
ReadDataFile("dc:TCR\\TCR.lvl", "TCR_campaign")
SetDenseEnvironment("false")


-- Sound

voiceSlow = OpenAudioStream("sound\\global.lvl", "all_unit_vo_slow")
AudioStreamAppendSegments("sound\\global.lvl", "imp_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "wok_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "global_vo_slow", voiceSlow)

voiceQuick = OpenAudioStream("sound\\global.lvl", "all_unit_vo_quick")
AudioStreamAppendSegments("sound\\global.lvl", "imp_unit_vo_quick", voiceQuick)
AudioStreamAppendSegments("sound\\global.lvl", "wok_unit_vo_quick", voiceQuick)

OpenAudioStream("sound\\global.lvl", "gcw_music")
-- OpenAudioStream("sound\\global.lvl", "global_vo_quick")
-- OpenAudioStream("sound\\global.lvl", "global_vo_slow")
OpenAudioStream("sound\\kas.lvl", "kas")
OpenAudioStream("sound\\kas.lvl", "kas")
OpenAudioStream("sound\\spa.lvl", "spa")
OpenAudioStream("sound\\spa.lvl", "spa")

SetBleedingVoiceOver(ALL, ALL, "all_off_com_report_us_overwhelmed", 1)
SetBleedingVoiceOver(ALL, IMP, "all_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(IMP, ALL, "imp_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(IMP, IMP, "imp_off_com_report_us_overwhelmed", 1)

SetLowReinforcementsVoiceOver(ALL, ALL, "all_off_defeat_im", .1, 1)
SetLowReinforcementsVoiceOver(ALL, IMP, "all_off_victory_im", .1, 1)
SetLowReinforcementsVoiceOver(IMP, IMP, "imp_off_defeat_im", .1, 1)
SetLowReinforcementsVoiceOver(IMP, ALL, "imp_off_victory_im", .1, 1)

SetOutOfBoundsVoiceOver(1, "Allleaving")
SetOutOfBoundsVoiceOver(2, "Impleaving")

SetAmbientMusic(ALL, 1.0, "all_kas_amb_start", 0,1)
SetAmbientMusic(ALL, 0.9, "all_spa_amb_middle", 1,1)
SetAmbientMusic(ALL, 0.2, "all_spa_amb_middle", 1,1)
SetAmbientMusic(IMP, 1.0, "imp_kas_amb_start", 0,1)
SetAmbientMusic(IMP, 0.8, "imp_kas_amb_middle", 1,1)
SetAmbientMusic(IMP, 0.2, "imp_spa_amb_start", 0,1)

SetVictoryMusic(ALL, "all_kas_amb_victory")
SetDefeatMusic (ALL, "all_kas_amb_defeat")
SetVictoryMusic(IMP, "imp_kas_amb_victory")
SetDefeatMusic (IMP, "imp_kas_amb_defeat")

SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")
--SetSoundEffect("WeaponUnableSelect", "com_weap_inf_weaponchange_null")
--SetSoundEffect("WeaponModeUnableSelect", "com_weap_inf_modechange_null")
SetSoundEffect("SpawnDisplayUnitChange", "shell_select_unit")
SetSoundEffect("SpawnDisplayUnitAccept", "shell_menu_enter")
SetSoundEffect("SpawnDisplaySpawnPointChange", "shell_select_change")
SetSoundEffect("SpawnDisplaySpawnPointAccept", "shell_menu_enter")
SetSoundEffect("SpawnDisplayBack", "shell_menu_exit")


-- Camera Stats
AddCameraShot(0.746608, -0.112590, -0.648337, -0.097771, -106.239983, -186.641006, 598.420044);
AddCameraShot(-0.196032, 0.013488, -0.978192, -0.067306, -253.046875, -185.839767, 115.891884);
AddCameraShot(0.171247, -0.018277, -0.979496, -0.104540, -321.901672, -192.914230, 367.008118);
AddCameraShot(0.016993, -0.003768, -0.976140, -0.216443, -328.674072, -192.914230, 420.546448);
AddCameraShot(0.806342, -0.049327, -0.588289, -0.035988, -377.091949, -192.914230, 431.436646);
AddCameraShot(0.230994, -0.004211, -0.972784, -0.017733, -18.148893, -175.650681, 432.006714);
end