Somebody can explain to me how to solve this or why its failing? Or atleast point me in the right direction towards a solution?
Here is the code. SquadInsertion = function() is the one giving me troubles:
Code: Select all
if Map.Difficulty == "Easy" then
    SpyType = "spy"
    InfiltratedSquad = { "medi", "e3.defendstance", "e3.defendstance", "e1.defendstance", "e1.defendstance" }
    InsertionSquad = { "medi", "e3.defendstance", "e3.defendstance", "e1.defendstance", "e1.defendstance" }
elseif Map.Difficulty == "Normal" then
	SpyType = "spy"
    InfiltratedSquad = { "medi", "e3.defendstance", "e3.defendstance", "e1.defendstance", "e1.defendstance" }
    InsertionSquad = { "medi", "e3.defendstance", "e3.defendstance", "e1.defendstance", "e1.defendstance" }
else 
    SpyType = "spy.unarmed"
    InfiltratedSquad = { "e3.defendstance", "e3.defendstance", "e1.defendstance", "e1.defendstance" }
    InsertionSquad = { "medi", "e3.defendstance", "e3.defendstance", "e1.defendstance", "e1.defendstance" }
end
TranPath = { TranInsertion.Location, Flare.Location }
TransInsertionType = "tran.insertion"
ObjSams = {ObjSam1, ObjSam2, ObjSam3}
PatrolA = {PatrolA00, PatrolA01, PatrolA02, PatrolA03}
PatrolB = {PatrolB00, PatrolB01, PatrolB02}
PatrolC = {PatrolC00, PatrolC01, PatrolC02}
PatrolAPath = { PatrolAWay3.Location, PatrolAWay1.Location, PatrolAWay2.Location, PatrolAWay1.Location }
PatrolBPath = { PatrolBWay1.Location, PatrolBWay2.Location }
PatrolCPath = { PatrolCWay1.Location, PatrolCWay2.Location }
InfiltrationPoint = { InfiltrationSpawn.Location, InfiltrationTarget.Location }
Convoy = {"truk.mission", "truk.mission"}
ConvoyPathA = { ConvoyStart.Location, ConvoyWay01.Location, ConvoyWay02.Location, ConvoyEndA.Location}
ConvoyPathB = { ConvoyStart.Location, ConvoyWay01.Location, ConvoyWay02.Location, ConvoyEndB.Location}
ConvoyPathC = { ConvoyStart.Location, ConvoyWay01.Location, ConvoyWay02.Location, ConvoyEndC.Location}
AlliedConvoy = {"truk.mission"}
AlliedConvoyPath = { ConvoyStart.Location, InfiltrationSpawn.Location}
PowerSupply = 
{ 
    BaseAPower00, BaseAPower01, BaseAPower02, BaseAPower03, BaseBPower00, BaseBPower01, 
    BaseBPower02, BaseCPower00, BaseCPower01, BaseCPower02, BaseCPower03, 
    MainBasePower02, MainBasePower03, MainBasePower04, MainBasePower04, MainBasePower05, 
    MainBasePower06, MainBasePower07, MainBasePower08, MainBasePower09 
}
SetupAlliedUnits = function()
	
    Spy = Actor.Create(SpyType, true, { Owner = player, Location = EnglandSpy.Location, Facing = 128 })
	Camera.Position = Spy.CenterPosition
    Trigger.OnKilled(Spy, function() ussr.MarkCompletedObjective(ussrObj) end)
	
    Trigger.AfterDelay(DateTime.Seconds(1), function()
    
    end)
	
    Trigger.AfterDelay(DateTime.Seconds(1), function()USSR00.AttackMove(SpyReturn.Location) end)
    
	FirstCam = Actor.Create("camera", true, { Owner = player, Location = StartingCamera.Location })
    
end
SpyMustSurvive = function()
Trigger.OnKilled(Spy, function() ussr.MarkCompletedObjective(ussrObj) end) 
end
 Trigger.OnAllKilled(ObjSams, function()
		player.MarkCompletedObjective(destroySams)
        
    end)
Trigger.OnEnteredFootprint({ RadardomeVisionTrigger.Location }, function(a, id)
		if a.Owner == player then
            Actor.Create("camera", true, { Owner = player, Location = RadardomeVision.Location }) 
            Trigger.RemoveFootprintTrigger(id) end
    end)
InitTriggers = function()
	Trigger.OnInfiltrated(Radardome, function()
		Trigger.ClearAll(Spy)
        Actor.Create("camera.map", true, { Owner = player, Location = MapCamera1.Location }) 
        Actor.Create("camera.map", true, { Owner = player, Location = MapCamera2.Location })
        player.MarkCompletedObjective(infRadardome)
        SquadInsertion()
       
        Trigger.AfterDelay(DateTime.Seconds(1), function()
            Actor.Create("dome", true, { Owner = player, Location = OffmapRadar.Location })
            Actor.Create("powr", true, { Owner = player, Location = OffmapPower.Location })
            
        local TeslaCams = 
            { 
            Actor.Create("camera.tesla", true, { Owner = player, Location = TeslaCam00.Location }),
            Actor.Create("camera.tesla", true, { Owner = player, Location = TeslaCam01.Location }),
            Actor.Create("camera.tesla", true, { Owner = player, Location = TeslaCam02.Location }),
            Actor.Create("camera.tesla", true, { Owner = player, Location = TeslaCam03.Location }),
            Actor.Create("camera.tesla", true, { Owner = player, Location = TeslaCam04.Location })
            }
            
            Spy = Actor.Create(SpyType, true, { Owner = player, Location = Radardome.Location, Facing = 128  })
            Spy.DisguiseAsType("e1", ussr)
            Spy.Move(SpyReturn.Location)
           
        end)         
            
        Trigger.OnKilled(Spy, function() ussr.MarkCompletedObjective(ussrObj) end)
	end)
    
    
    SquadInsertion = function()
        local flare = Actor.Create("flare", true, { Owner = copter, Location = Flare.Location })
        Trigger.AfterDelay(DateTime.Seconds(21), flare.Destroy)
        Media.PlaySpeechNotification(player, "SignalFlare")
        
        ----Going nuts with this one
        ASDF = Reinforcements.ReinforceWithTransport(player, TransInsertionType, InsertionSquad, TranPath)[1]
        
    end
    
    
	Trigger.OnAllKilled(PowerSupply, function()
		player.MarkCompletedObjective(destroyPowerplants)
	end)
ActivatePatrols = function()
	GroupPatrol(PatrolA, PatrolAPath, DateTime.Seconds(2))
	GroupPatrol(PatrolB, PatrolBPath, DateTime.Seconds(2))
    GroupPatrol(PatrolC, PatrolCPath, DateTime.Seconds(5))
	local units = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(self) return self.Owner == soviets and self.HasProperty("AutoTarget") end)
	Utils.Do(units, function(unit)
		unit.Stance = "Defend"
	end)
end
GroupPatrol = function(units, waypoints, delay)
	local i = 1
	local stop = false
	Utils.Do(units, function(unit)
		Trigger.OnIdle(unit, function()
			if stop then
				return
			end
			if unit.Location == waypoints[i] then
				local bool = Utils.All(units, function(actor) return actor.IsIdle end)
				if bool then
					stop = true
					i = i + 1
					if i > #waypoints then
						i = 1
					end
					Trigger.AfterDelay(delay, function() stop = false end)
				end
			else
				unit.AttackMove(waypoints[i])
			end
		end)
	end)
end
SendConvoy = function()
	Reinforcements.Reinforce(ussr, Convoy, ConvoyPathA, 20 )
    Reinforcements.Reinforce(ussr, Convoy, ConvoyPathB, 20 )
    Reinforcements.Reinforce(ussr, Convoy, ConvoyPathC, 20 )
    
    Trigger.AfterDelay(DateTime.Seconds(2), function()Reinforcements.Reinforce(ussrradar, AlliedConvoy, AlliedConvoyPath, 20) end)
 
    Trigger.AfterDelay(DateTime.Seconds(8), function()Reinforcements.Reinforce(player, InfiltratedSquad, InfiltrationPoint, 5) end)
end
	
	
end
InitObjectives = function()
	Trigger.OnObjectiveAdded(player, function(p, id)
		Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective")
	end)
	ussrObj = ussr.AddPrimaryObjective("Stop Allied infiltration.")
    infRadardome = player.AddPrimaryObjective("Infiltrate radar dome.")
	destroyPowerplants = player.AddPrimaryObjective("Destroy all power plants.")
	spySurvive = player.AddPrimaryObjective("Spy must survive.")
    destroyTruks = player.AddSecondaryObjective("Destroy convoy trucks.")
    destroySams = player.AddSecondaryObjective("Destroy all three sam sites nearby radar dome.")
	
	Trigger.OnObjectiveCompleted(player, function(p, id)
		Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed")
	end)
	Trigger.OnObjectiveFailed(player, function(p, id)
		Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed")
	end)
	
	Trigger.OnPlayerLost(player, function()
		Media.PlaySpeechNotification(player, "Lose")
	end)
	Trigger.OnPlayerWon(player, function()
		Media.PlaySpeechNotification(player, "Win")
	end)
end
	
WorldLoaded = function()
	player = Player.GetPlayer("ENGLAND")
	ussr = Player.GetPlayer("USSR")
	ussrradar = Player.GetPlayer("USSRRADAR")
	copter = Player.GetPlayer("COPTER")
    
	InitObjectives()
	InitTriggers()
	SendConvoy()
	Trigger.AfterDelay(DateTime.Seconds(3), ActivatePatrols)
	SetupAlliedUnits()
end