dofile("Scripts/mission.lua");
dofile("Scripts/msl.lua");

function PostCreate()
	mission_lua.BasicMissionInitialize()
	AIparts:AddOneTime("005a. 6th Airborne Paradrop", 40, func_005a__6th_Airborne_Paradrop)
	AIparts:AddPeriodic("005b. Pegasus1 Cleared", 40, func_005b__Pegasus1_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("005c. Pegasus2 Cleared", 40, func_005c__Pegasus2_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("005d. MervilleBattery cleared", 40, func_005d__MervilleBattery_cleared, 0 + RandomHalf(40))
	AIparts:AddOneTime("000. Effects", 290, func_000__Effects)
	AIparts:AddPeriodic("103. Landing 3rd Brit Inf Div LVT", 40, func_103__Landing_3rd_Brit_Inf_Div_LVT, 0 + RandomHalf(40))
	AIparts:AddPeriodic("101. Landing 3rd Brit Inf Div LVP", 10, func_101__Landing_3rd_Brit_Inf_Div_LVP, 0 + RandomHalf(10))
	AIparts:AddPeriodic("000. Presets airplanes", 40, func_000__Presets_airplanes, 0 + RandomHalf(40))
	AIparts:AddPeriodic("102. Landing 3rd Brit Inf Div Firefly", 40, func_102__Landing_3rd_Brit_Inf_Div_Firefly, 0 + RandomHalf(40))
	AIparts:AddPeriodic("097. Arty active in Merville", 40, func_097__Arty_active_in_Merville, 0 + RandomHalf(40))
	AIparts:AddPeriodic("104. Landing 3rd Brit Inf Div Counter", 40, func_104__Landing_3rd_Brit_Inf_Div_Counter, 0 + RandomHalf(40))
	AIparts:AddPeriodic("105a. Landing Brit 1st SSB LVP", 40, func_105a__Landing_Brit_1st_SSB_LVP, 0 + RandomHalf(40))
	AIparts:AddOneTime("000. Timer", 40, func_000__Timer)
	AIparts:AddPeriodic("005e. Objectives Bures Troarn", 40, func_005e__Objectives_Bures_Troarn, 0 + RandomHalf(40))
	AIparts:AddPeriodic("006a. Bures Cleared", 40, func_006a__Bures_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("007a. Troarn Cleared", 40, func_007a__Troarn_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("008a. Counterattack Pegasus1", 40, func_008a__Counterattack_Pegasus1, 0 + RandomHalf(40))
	AIparts:AddPeriodic("009. Ranville Cleared", 40, func_009__Ranville_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("100. Objectives villages coastline", 40, func_100__Objectives_villages_coastline, 0 + RandomHalf(40))
	AIparts:AddPeriodic("110c. Objective Lion-sur-Mer Cleared", 40, func_110c__Objective_Lion_sur_Mer_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("110a. Objective La Breche Cleared", 40, func_110a__Objective_La_Breche_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("110e. Objective Quistreham Cleared", 40, func_110e__Objective_Quistreham_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("106. Landing Brit 4th SSB LVT Firefly", 40, func_106__Landing_Brit_4th_SSB_LVT_Firefly, 0 + RandomHalf(40))
	AIparts:AddPeriodic("010. Benouville Cleared", 10, func_010__Benouville_Cleared, 0 + RandomHalf(10))
	AIparts:AddPeriodic("112a. Objectives  Aubin - La Breche - Quis_clear", 40, func_112a__Objectives__Aubin___La_Breche___Quis_clear, 0 + RandomHalf(40))
	AIparts:AddPeriodic("114a. Objective Caen Canal Orne cleared", 40, func_114a__Objective_Caen_Canal_Orne_cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("114b. Objective Franceville cleared", 40, func_114b__Objective_Franceville_cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("114c. Objective FrancevilleCoast Cleared", 40, func_114c__Objective_FrancevilleCoast_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("110b. Landing 27th Armoured Brig.", 40, func_110b__Landing_27th_Armoured_Brig_, 0 + RandomHalf(40))
	AIparts:AddPeriodic("110f. Objective QuistrehamCoast Cleared", 40, func_110f__Objective_QuistrehamCoast_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("113a. Objective PeriersRidge Cleared", 40, func_113a__Objective_PeriersRidge_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("008b. Counterattack Pegasus1", 40, func_008b__Counterattack_Pegasus1, 0 + RandomHalf(40))
	AIparts:AddPeriodic("011. Colleville Cleared", 40, func_011__Colleville_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("012. Hermanville Cleared", 40, func_012__Hermanville_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("099a. Bombing at 57min", 40, func_099a__Bombing_at_57min, 0 + RandomHalf(40))
	AIparts:AddPeriodic("112b. Landing 185th  Brig. see script 112a", 40, func_112b__Landing_185th__Brig__see_script_112a, 0 + RandomHalf(40))
	AIparts:AddPeriodic("113b. Landing 9th  Brig. see script 113a", 40, func_113b__Landing_9th__Brig__see_script_113a, 0 + RandomHalf(40))
	AIparts:AddPeriodic("013. Periers Cleared", 40, func_013__Periers_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("014. Douvres Cleared", 40, func_014__Douvres_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("007b. Troarn Counterattack", 40, func_007b__Troarn_Counterattack, 0 + RandomHalf(40))
	AIparts:AddPeriodic("006b. Bures Counterattack", 40, func_006b__Bures_Counterattack, 0 + RandomHalf(40))
	AIparts:AddPeriodic("000. Minefield1", 40, func_000__Minefield1, 0 + RandomHalf(40))
	AIparts:AddPeriodic("000. Minefield2", 40, func_000__Minefield2, 0 + RandomHalf(40))
	AIparts:AddPeriodic("200. Objectives cleared activate Caen", 40, func_200__Objectives_cleared_activate_Caen, 0 + RandomHalf(40))
	AIparts:AddPeriodic("120. Counterattack 192PanzerGrenReg", 40, func_120__Counterattack_192PanzerGrenReg, 0 + RandomHalf(40))
	AIparts:AddPeriodic("000. Defeat or Win", 40, func_000__Defeat_or_Win, 0 + RandomHalf(40))
	AIparts:AddPeriodic("002a. Maj John Howard Arrived", 40, func_002a__Maj_John_Howard_Arrived, 0 + RandomHalf(40))
	AIparts:AddPeriodic("001a. Lt Col Terence Otway Arrived", 40, func_001a__Lt_Col_Terence_Otway_Arrived, 0 + RandomHalf(40))
	AIparts:AddOneTime("000. Camera", 40, func_000__Camera)
	AIparts:AddPeriodic("110d. Objective St Aubin Cleared", 40, func_110d__Objective_St_Aubin_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("098. Mortars at La breche", 40, func_098__Mortars_at_La_breche, 0 + RandomHalf(40))
	AIparts:AddPeriodic("114d. Landing 3rd Div Arty", 40, func_114d__Landing_3rd_Div_Arty, 0 + RandomHalf(40))
	AIparts:AddPeriodic("500. Reserve 27th Armoured Brig. 14400", 40, func_500__Reserve_27th_Armoured_Brig__14400, 0 + RandomHalf(40))
	AIparts:AddPeriodic("130. German airplanes to beach", 40, func_130__German_airplanes_to_beach, 0 + RandomHalf(40))
	AIparts:AddPeriodic("000.Carpiquet_airfield taken", 200, func_000_Carpiquet_airfield_taken, 100 + RandomHalf(100))
	AIparts:AddPeriodic("015. Beuville Cleared", 40, func_015__Beuville_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("016. Lebisey Cleared", 40, func_016__Lebisey_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("017. Carpiquet Cleared", 40, func_017__Carpiquet_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("000. Minefield3", 40, func_000__Minefield3, 0 + RandomHalf(40))
	AIparts:AddPeriodic("201. Set behaviour AA groups", 40, func_201__Set_behaviour_AA_groups, 0 + RandomHalf(40))
	AIparts:AddPeriodic("303. Caen cleared", 40, func_303__Caen_cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("302. CarpiquetAirfield cleared", 10, func_302__CarpiquetAirfield_cleared, 0 + RandomHalf(10))
	AIparts:AddPeriodic("301. Colombelles cleared", 40, func_301__Colombelles_cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("202. Airstrike Colombelles", 40, func_202__Airstrike_Colombelles, 0 + RandomHalf(40))
	AIparts:AddPeriodic("203. Airstrike Caen", 40, func_203__Airstrike_Caen, 0 + RandomHalf(40))
	AIparts:AddPeriodic("150. What if Troarn / Bures not taken", 40, func_150__What_if_Troarn___Bures_not_taken, 0 + RandomHalf(40))
	AIparts:AddPeriodic("018. Bieville Cleared", 40, func_018__Bieville_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("175. Counterattack Colombelles", 40, func_175__Counterattack_Colombelles, 0 + RandomHalf(40))
	AIparts:AddPeriodic("000. Minefield4", 40, func_000__Minefield4, 0 + RandomHalf(40))
	AIparts:AddPeriodic("176. Counterattack Carpiquet_airfield", 40, func_176__Counterattack_Carpiquet_airfield, 0 + RandomHalf(40))
	AIparts:AddPeriodic("177. Counterattack Carpiquet_village", 40, func_177__Counterattack_Carpiquet_village, 0 + RandomHalf(40))
	AIparts:AddPeriodic("178. Counterattack Merville Gun 1", 40, func_178__Counterattack_Merville_Gun_1, 0 + RandomHalf(40))
	AIparts:AddPeriodic("501. Reserve 51 Div and 4th Arm ", 40, func_501__Reserve_51_Div_and_4th_Arm_, 0 + RandomHalf(40))
	AIparts:AddPeriodic("181. Counterattack Herouvillette", 40, func_181__Counterattack_Herouvillette, 0 + RandomHalf(40))
	AIparts:AddPeriodic("019. Herouvillette Cleared", 40, func_019__Herouvillette_Cleared, 0 + RandomHalf(40))
	AIparts:AddPeriodic("304. Caen1 invaded", 40, func_304__Caen1_invaded, 0 + RandomHalf(40))
	AIparts:AddPeriodic("305. Caen reinforcements", 40, func_305__Caen_reinforcements, 0 + RandomHalf(40))
	AIparts:AddPeriodic("179. Counterattack Merville Gun 2", 40, func_179__Counterattack_Merville_Gun_2, 0 + RandomHalf(40))
	AIparts:AddPeriodic("180. Counterattack Merville Gun 3", 40, func_180__Counterattack_Merville_Gun_3, 0 + RandomHalf(40))
	AIparts:AddPeriodic("182b. Counterattack 12SS 1", 40, func_182b__Counterattack_12SS_1, 0 + RandomHalf(40))
	AIparts:AddPeriodic("183. Counterattack 12SS 2", 40, func_183__Counterattack_12SS_2, 0 + RandomHalf(40))
	AIparts:AddPeriodic("184. Counterattack 12SS 3", 40, func_184__Counterattack_12SS_3, 0 + RandomHalf(40))
	AIparts:AddPeriodic("305. Colombelles invaded 1", 40, func_305__Colombelles_invaded_1, 0 + RandomHalf(40))
	AIparts:AddPeriodic("306. Colombelles invaded 2", 40, func_306__Colombelles_invaded_2, 0 + RandomHalf(40))
	AIparts:AddPeriodic("307. Nebelwerferzone 1", 40, func_307__Nebelwerferzone_1, 0 + RandomHalf(40))
	AIparts:AddPeriodic("308. Nebelwerferzone 2", 40, func_308__Nebelwerferzone_2, 0 + RandomHalf(40))
	AIparts:AddPeriodic("309. Arty outpost", 40, func_309__Arty_outpost, 0 + RandomHalf(40))
	AIparts:AddPeriodic("185. Counterattack Colombelles right defence", 40, func_185__Counterattack_Colombelles_right_defence, 0 + RandomHalf(40))
	AIparts:AddPeriodic("186. Colombelles right defence", 40, func_186__Colombelles_right_defence, 0 + RandomHalf(40))
	AIparts:AddPeriodic("008c. Counterattack Pegasus1", 40, func_008c__Counterattack_Pegasus1, 0 + RandomHalf(40))
	AIparts:AddPeriodic("310. Patrol enemy seen", 40, func_310__Patrol_enemy_seen, 0 + RandomHalf(40))
	AIparts:AddOneTime("000. Presets Patrol", 10, func_000__Presets_Patrol)
	AIparts:AddPeriodic("311. Beuville_Artillery", 40, func_311__Beuville_Artillery, 0 + RandomHalf(40))
	AIparts:AddPeriodic("182a. Message arrival 12SS ", 40, func_182a__Message_arrival_12SS_, 0 + RandomHalf(40))
	AIparts:AddPeriodic("151. What if Franceville / Beach Fr. not taken", 40, func_151__What_if_Franceville___Beach_Fr__not_taken, 0 + RandomHalf(40))
	AIparts:AddPeriodic("187. Counterattack Beuville", 40, func_187__Counterattack_Beuville, 0 + RandomHalf(40))
	AIparts:AddPeriodic("121. Counterattack 192PanzerGrenReg", 40, func_121__Counterattack_192PanzerGrenReg, 0 + RandomHalf(40))
	AIparts:AddPeriodic("020. Merville Cleared", 10, func_020__Merville_Cleared, 0 + RandomHalf(10))
	AIparts:AddPeriodic("502. 3 Div Heavy Arty ", 40, func_502__3_Div_Heavy_Arty_, 0 + RandomHalf(40))
	AIparts:AddPeriodic("New Sound all 12000 time digits", 12000, func_New_Sound_all_12000_time_digits, 1200 + RandomHalf(100))
	AIparts:AddPeriodic("001b. Lt Col Terence Otway Dead", 50, func_001b__Lt_Col_Terence_Otway_Dead, 50 + RandomHalf(50))
	AIparts:AddPeriodic("001c. Lt Col Terence Otway Dead", 40, func_001c__Lt_Col_Terence_Otway_Dead, 0 + RandomHalf(40))
	AIparts:AddPeriodic("002b. Maj John Howard dead", 50, func_002b__Maj_John_Howard_dead, 50 + RandomHalf(50))
	AIparts:AddPeriodic("002c. Maj John Howard dead", 40, func_002c__Maj_John_Howard_dead, 0 + RandomHalf(40))
	AIparts:AddPeriodic("105b. Landing Lord Lovat", 40, func_105b__Landing_Lord_Lovat, 0 + RandomHalf(40))
	AIparts:AddPeriodic("105c. Landing Capt Kieffer", 40, func_105c__Landing_Capt_Kieffer, 0 + RandomHalf(40))
	AIparts:AddPeriodic("003a. Lord Lovat Arrived", 40, func_003a__Lord_Lovat_Arrived, 0 + RandomHalf(40))
	AIparts:AddPeriodic("003b. Lord Lovat Dead", 50, func_003b__Lord_Lovat_Dead, 50 + RandomHalf(50))
	AIparts:AddPeriodic("003c. Lord Lovat Dead", 40, func_003c__Lord_Lovat_Dead, 0 + RandomHalf(40))
	AIparts:AddPeriodic("004a. Capt. Kieffer Arrived", 40, func_004a__Capt__Kieffer_Arrived, 0 + RandomHalf(40))
	AIparts:AddPeriodic("004b. Capt. Kieffer Dead", 50, func_004b__Capt__Kieffer_Dead, 50 + RandomHalf(50))
	AIparts:AddPeriodic("004c. Capt. Kieffer Dead", 40, func_004c__Capt__Kieffer_Dead, 0 + RandomHalf(40))
	AIparts:AddOneTime("005a. 6th Airborne Paradrop LZV", 40, func_005a__6th_Airborne_Paradrop_LZV)
	AIparts:AddOneTime("005a. 6th Airborne Paradrop LZW", 40, func_005a__6th_Airborne_Paradrop_LZW)
	AIparts:AddPeriodic("099b. Navalstrike at 60min", 40, func_099b__Navalstrike_at_60min, 0 + RandomHalf(40))
	AIparts:AddPeriodic("021. Lebisey Forest Cleared", 40, func_021__Lebisey_Forest_Cleared, 0 + RandomHalf(40))
	msd_vars = {
		varEffect = 0,
		varHoward_ID = 0,
		varHowardAlive = true,
		varKieffer_ID = 0,
		varKiefferAlive = true,
		varLovat_ID = 0,
		varLovatAlive = true,
		varOtway_ID = 0,
		varOtwayAlive = true,
	}
end

function func_005a__6th_Airborne_Paradrop()
	do
		 dofile("Missions/Single/Sword Beach/para.lua") 
		SendPlane("Player", "Merville1", "extra", "N", 1, -1, "")
		SendPlane("Player", "Merville3", "extra", "N", 1, -1, "")
		SendPlane("Player", "Merville2", "extra", "N", 1, -1, "")
		SendPlane("Player", "Merville4", "extra", "N", 1, -1, "")
		para.ParaPlane("Player", "Waypoint_Y", "N", "W", 5, 0, "6thAirborne")
		para.ParaPlane("Player", "Waypoint_X", "N", "W", 5, 0, "6thAirborne")
		para.ParaPlane("Player", "Waypoint_K", "N", "W", 5, 0, "6thAirborne")
		para.ParaPlane("Player", "Waypoint_K", "N", "W", 5, 0, "6thAirborne")
		para.ParaPlane("Player", "Waypoint_N", "N", "W", 5, 0, "6thAirborne")
	end
end

function func_005b__Pegasus1_Cleared()
	if NumPlayerUnitsInZone("Enemy", "PegasusBridge1") < 1 then
		SetObjectiveComplete("PegasusBridge1", "Player")
		mission.OutScreenMessage(100000, 10, "0xFF00CC00")
		AIparts:RemovePeriodic("005b. Pegasus1 Cleared")
	end
end

function func_005c__Pegasus2_Cleared()
	if NumPlayerUnitsInZone("Enemy", "PegasusBridge2") < 1 then
		SetObjectiveComplete("PegasusBridge2", "Player")
		mission.OutScreenMessage(100001, 10, "0xFF00CC00")
		AIparts:RemovePeriodic("005c. Pegasus2 Cleared")
	end
end

function func_005d__MervilleBattery_cleared()
	if NumPlayerUnitsInZone("Enemy", "MervilleBattery") < 1 then
		SetObjectiveComplete("MervilleBattery", "Player")
		mission.OutScreenMessage(100002, 10, "0xFF00CC00")
		AIparts:RemovePeriodic("005d. MervilleBattery cleared")
	end
end

function func_000__Effects()
	do
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 3600*10, function()   msd_vars.varEffect = CreateFXObject("soundfx/sword_beach.dsc", "Beach_LaBreche", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 3640*10, function()   RemoveObject(msd_vars.varEffect) end)
	end
end

function func_103__Landing_3rd_Brit_Inf_Div_LVT()
	if GetGameTime() > 3720 then
		RunSpawn("Player", {"British_3rd_LVT", }, "Landing_LaBreche", "3rd_British", "3rd_British", true, true, {{unload=false, }, }, true, 10)
		AIparts:RemovePeriodic("103. Landing 3rd Brit Inf Div LVT")
	end
end

function func_101__Landing_3rd_Brit_Inf_Div_LVP()
	if GetGameTime() > 3605 then
		RunSpawn("Player", {"British_3rd_Div", }, "Landing_LaBreche", "3rd_British", "3rd_British", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50)
		mission.CameraLock(true)
		mission.CameraAt({-291.638641, 3.306434, 538.965637}, 45.000000, -86.248909, 63.458237, 5.00)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  mission.OutScreenMessage(100003, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  mission.CameraLock(false) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  AddBonus(1, 3, 3, -1, -1) end)
		AIparts:RemovePeriodic("101. Landing 3rd Brit Inf Div LVP")
	end
end

function func_000__Presets_airplanes()
	do
		SetPlaneSide(1, "N")
		SetPlaneDesc("uk", "bomber", "british/tempest_mk_ii.dsc")
		SetPlaneDesc("uk", "extra", "british/avro_683_lancaster.dsc")
		SetPlaneDesc("uk", "fighter", "british/spitfire_mk_i.dsc")
		SetPlaneDesc("germany", "fighter", "German/fw_190.dsc")
		SetPlaneDesc("germany", "bomber", "German/ju_88s.dsc")
		SetPlaneDesc("germany", "scout", "German/fw_189.dsc")
	end
end

function func_102__Landing_3rd_Brit_Inf_Div_Firefly()
	if GetGameTime() > 3680 then
		RunSpawn("Player", {"British_3rd_Div Firefly8d", }, "Landing_LaBreche", "3rd_British", "3rd_British", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 10)
		AIparts:RemovePeriodic("102. Landing 3rd Brit Inf Div Firefly")
	end
end

function func_097__Arty_active_in_Merville()
	if NumGroupUnits("MervilleGuns", 2, true, true, true) > 0 and NumPlayerUnitsInZone("Player", "Beach_La_Breche") > 10 then
		Bombardment("Beach_LaBreche", 60, 4, 6, 30)
		Bombardment("Beach_LaBreche", 60, 4, 6, 150)
		Bombardment("Beach_LaBreche", 60, 4, 6, 300)
		Bombardment("Beach_LaBreche", 60, 4, 6, 450)
		Bombardment("Beach_LaBreche", 60, 4, 6, 600)
		Bombardment("Beach_LaBreche", 60, 4, 6, 750)
		Bombardment("Beach_LaBreche", 60, 4, 6, 900)
		Bombardment("Beach_LaBreche", 60, 4, 6, 1050)
		Bombardment("Beach_LaBreche", 60, 4, 6, 1200)
		Bombardment("Beach_LaBreche", 60, 4, 6, 1350)
		Bombardment("Beach_LaBreche", 60, 4, 6, 1500)
		AIparts:RemovePeriodic("097. Arty active in Merville")
	end
end

function func_104__Landing_3rd_Brit_Inf_Div_Counter()
	if NumPlayerUnitsInZones("Player", {"Village_LaBreche", }) > 5 then
		MoveGroupToZone("LaBrecheForce2", "Beach_La_Breche", true, false)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  AddBonus(1, 2, 1, -1, -1) end)
		AIparts:RemovePeriodic("104. Landing 3rd Brit Inf Div Counter")
	end
end

function func_105a__Landing_Brit_1st_SSB_LVP()
	if GetGameTime() > 4200 then
		RunSpawn("Player", {"British_1_ SSB", "British_1_ SSB", "British_1_ SSB", "British_1_ SSB", "British_1_ SSB", }, "Landing_ 1_SSB", "3rd_British", "SpecialService", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  mission.OutScreenMessage(100011, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  RunSpawn("Player", {"French_1_SBB", }, "Landing_ 1_SSB", "3rd_British", "French", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:RemovePeriodic("105a. Landing Brit 1st SSB LVP")
	end
end

function func_000__Timer()
	do
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  AcivateObjective("timer") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  ProceedObjective("timer", "Player") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  AcivateObjective("timer2") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  ProceedObjective("timer2", "Player") end)
	end
end

function func_005e__Objectives_Bures_Troarn()
	if IsObjectiveCompleted("MervilleBattery", "Player") and IsObjectiveCompleted("PegasusBridge1", "Player") and IsObjectiveCompleted("PegasusBridge2", "Player") then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  AcivateObjective("Village_Bures") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  AcivateObjective("Village_Troarn") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  NewObjectiveMessage(100013, "Village_Bures", 10, "0xFF00CC00") end)
		AIparts:RemovePeriodic("005e. Objectives Bures Troarn")
	end
end

function func_006a__Bures_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_Bures") < 1 and IsObjectiveActive("Village_Bures") then
		SetObjectiveComplete("Village_Bures", "Player")
		mission.OutScreenMessage(100014, 10, "0xFF00CC00")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  Bombardment("Village_Bures", 0, 8, 6, 30) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 64*10, function()  CreateFXObject("buildings/bridge_broken_05.dsc", "Village_Bures", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 65*10, function()  Bombardment("Village_Bures2", 0, 8, 6, 30) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 68*10, function()  CreateFXObject("buildings/bridge_broken_05.dsc", "Village_Bures2", 0) end)
		AIparts:RemovePeriodic("006a. Bures Cleared")
	end
end

function func_007a__Troarn_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_Troarn") < 1 and IsObjectiveActive("Village_Troarn") then
		SetObjectiveComplete("Village_Troarn", "Player")
		mission.OutScreenMessage(100015, 10, "0xFF00CC00")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  Bombardment("Village_Troarn", 0, 8, 6, 30) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 64*10, function()  CreateFXObject("buildings/bridge_broken_05.dsc", "Village_Troarn", 0) end)
		AIparts:RemovePeriodic("007a. Troarn Cleared")
	end
end

function func_008a__Counterattack_Pegasus1()
	if GetGameTime() > 1800 and NumPlayerUnitsInZone("Enemy", "PegasusBridge1") < 1 then
		MoveGroupToZone("PegagsusForce", "PegasusBridge1", true, true)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  mission.OutScreenMessage(100016, 10, "0xFFFF0000") end)
		AIparts:RemovePeriodic("008a. Counterattack Pegasus1")
	end
end

function func_009__Ranville_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_Ranville") < 1 then
		mission.OutScreenMessage(100017, 10, "0xFF00CC00")
		AIparts:RemovePeriodic("009. Ranville Cleared")
	end
end

function func_100__Objectives_villages_coastline()
	if GetGameTime() > 3601 then
		AcivateObjective("La Breche")
		AcivateObjective("Saint_Aubin-sur-Mer")
		AcivateObjective("Lion-sur-Mer")
		AcivateObjective("Quistreham")
		AcivateObjective("Quistreham_Coast")
		AIparts:RemovePeriodic("100. Objectives villages coastline")
	end
end

function func_110c__Objective_Lion_sur_Mer_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_Lion") < 1 and IsObjectiveActive("Lion-sur-Mer") then
		SetObjectiveComplete("Lion-sur-Mer", "Player")
		mission.OutScreenMessage(100020, 10, "0xFF00CC00")
		AIparts:RemovePeriodic("110c. Objective Lion-sur-Mer Cleared")
	end
end

function func_110a__Objective_La_Breche_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_LaBreche") < 1 and IsObjectiveActive("La Breche") then
		SetObjectiveComplete("La Breche", "Player")
		mission.OutScreenMessage(100019, 10, "0xFF00CC00")
		AddBonus(1, 2, 2, -1, -1)
		AddBonus(1, 3, 1, -1, -1)
		AIparts:RemovePeriodic("110a. Objective La Breche Cleared")
	end
end

function func_110e__Objective_Quistreham_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_Quistreham") < 1 and IsObjectiveActive("Quistreham") then
		SetObjectiveComplete("Quistreham", "Player")
		mission.OutScreenMessage(100021, 10, "0xFF00CC00")
		AIparts:RemovePeriodic("110e. Objective Quistreham Cleared")
	end
end

function func_106__Landing_Brit_4th_SSB_LVT_Firefly()
	if GetGameTime() > 4280 then
		RunSpawn("Player", {"British_27_Firefly", "British_27_Firefly", }, "Landing_ 1_SSB", "3rd_British", "3rd_British", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50)
		AIparts:RemovePeriodic("106. Landing Brit 4th SSB LVT Firefly")
	end
end

function func_010__Benouville_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_Benouville") < 1 then
		mission.OutScreenMessage(100022, 10, "0xFF00CC00")
		AIparts:RemovePeriodic("010. Benouville Cleared")
	end
end

function func_112a__Objectives__Aubin___La_Breche___Quis_clear()
	if ( IsObjectiveCompleted("Saint_Aubin-sur-Mer", "Player") and IsObjectiveCompleted("La Breche", "Player") and IsObjectiveCompleted("Quistreham", "Player") and IsObjectiveCompleted("Quistreham_Coast", "Player") and IsObjectiveCompleted("Lion-sur-Mer", "Player")  ) then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 20*10, function()  mission.OutScreenMessage(100040, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 25*10, function()  AcivateObjective("Periers Ridge") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  AddBonus(1, 8, 3, -1, -1) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 90*10, function()  AddBonus(1, 3, 1, -1, -1) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 120*10, function()  AddBonus(1, 2, 2, -1, -1) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 150*10, function()  mission.OutScreenMessage(100034, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 210*10, function()  RunSpawn("Player", {"British_3rd_Matador", "British_3rd_Matador", "British_3rd_Matador", "British_3rd_Matador", }, "Landing_LaBreche", "3rd_British", "3rd_British", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 310*10, function()  RunSpawn("Player", {"British_3rd_Matador", "British_3rd_Matador", "British_3rd_Matador", "British_3rd_Matador", }, "Landing_LaBreche", "3rd_British", "3rd_British", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:RemovePeriodic("112a. Objectives  Aubin - La Breche - Quis_clear")
	end
end

function func_114a__Objective_Caen_Canal_Orne_cleared()
	if NumPlayerUnitsInZone("Enemy", "Orne_Canal") < 1 and IsObjectiveActive("Orne_Canal") then
		SetObjectiveComplete("Orne_Canal", "Player")
		mission.OutScreenMessage(100024, 10, "0xFF00CC00")
		AddBonus(2, 2, 2, -1, -1)
		AIparts:RemovePeriodic("114a. Objective Caen Canal Orne cleared")
	end
end

function func_114b__Objective_Franceville_cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_Franceville") < 1 and IsObjectiveActive("Franceville") then
		SetObjectiveComplete("Franceville", "Player")
		mission.OutScreenMessage(100025, 10, "0xFF00CC00")
		AddBonus(2, 2, 2, -1, -1)
		AIparts:RemovePeriodic("114b. Objective Franceville cleared")
	end
end

function func_114c__Objective_FrancevilleCoast_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Beach_Franceville") < 1 and IsObjectiveActive("Beach_Franceville") then
		SetObjectiveComplete("Beach_Franceville", "Player")
		mission.OutScreenMessage(100026, 10, "0xFF00CC00")
		AddBonus(2, 2, 2, -1, -1)
		AIparts:RemovePeriodic("114c. Objective FrancevilleCoast Cleared")
	end
end

function func_110b__Landing_27th_Armoured_Brig_()
	if IsObjectiveCompleted("La Breche", "Player") then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  mission.OutScreenMessage(100027, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  RunSpawn("Player", {"British_27_Firefly", "British_27_Firefly", "British_27_Churchill", "British_27_Churchill", "British_27_Churchill", }, "Landing_LaBreche", "27th_Arm_Brig", "27th_Arm_Brig", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 70*10, function()  SendPlaneFromMap(135, "fighter", "Beach_LaBreche", 15) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 180*10, function()  RunSpawn("Player", {"British_27_Sherman", "British_27_Sherman", "British_27_Sherman", "British_27_Sherman", "British_27_Sherman", }, "Landing_LaBreche", "27th_Arm_Brig", "27th_Arm_Brig", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 300*10, function()  RunSpawn("Player", {"British_27_achilles", "British_27_achilles", "British_27_achilles", "British_27_centaur", "British_27_centaur", }, "Landing_LaBreche", "27th_Arm_Brig", "27th_Arm_Brig", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 420*10, function()  RunSpawn("Player", {"British_27_sexton", "British_27_sexton", "British_27_sexton", "British_27_Fuel", "British_27_Fuel", }, "Landing_LaBreche", "27th_Arm_Brig", "27th_Arm_Brig", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 540*10, function()  RunSpawn("Player", {"British_27_stuart", "British_27_stuart", "British_27_stuart", "British_27_Fuel", }, "Landing_LaBreche", "27th_Arm_Brig", "27th_Arm_Brig", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 660*10, function()  RunSpawn("Player", {"British_27_Supply", "British_27_Supply", "British_27_crusader", "British_27_crusader", "British_27_Supply", }, "Landing_LaBreche", "27th_Arm_Brig", "27th_Arm_Brig", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 700*10, function()  RunSpawn("Player", {"British_27_Sherman_mine", "British_27_Sherman_mine", "British_27_Sherman_mine", "British_27_Sherman_mine", }, "Landing_LaBreche", "27th_Arm_Brig", "27th_Arm_Brig", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 780*10, function()  RunSpawn("Player", {"British_27_Daimler", "British_27_Daimler", "British_27_Daimler", "British_27_crew", "British_27_crew", }, "Landing_LaBreche", "27th_Arm_Brig", "27th_Arm_Brig", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 1200*10, function()  RunSpawn("Player", {"British_1_ SSB", }, "Landing_4_SSB", "3rd_British", "3rd_British", false, true, {{unload=true, }, {dislocation="British_4th_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 1210*10, function()  mission.OutScreenMessage(100012, 5, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 1270*10, function()  RunSpawn("Player", {"British_27_Firefly", "British_27_Firefly", }, "Landing_4_SSB", "3rd_British", "3rd_British", false, true, {{unload=true, }, {dislocation="British_4th_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 1350*10, function()  RunSpawn("Player", {"British_1_ SSB", "British_1_ SSB", "British_1_ SSB", "British_1_ SSB", "British_1_ SSB", }, "Landing_4_SSB", "3rd_British", "3rd_British", false, true, {{unload=true, }, {dislocation="British_4th_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:RemovePeriodic("110b. Landing 27th Armoured Brig.")
	end
end

function func_110f__Objective_QuistrehamCoast_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Quistreham_Coast") < 1 and IsObjectiveActive("Quistreham_Coast") then
		SetObjectiveComplete("Quistreham_Coast", "Player")
		mission.OutScreenMessage(100028, 10, "0xFF00CC00")
		AIparts:RemovePeriodic("110f. Objective QuistrehamCoast Cleared")
	end
end

function func_113a__Objective_PeriersRidge_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Periers_Ridge") < 1 and IsObjectiveActive("Periers Ridge") then
		SetObjectiveComplete("Periers Ridge", "")
		mission.OutScreenMessage(100030, 10, "0xFF00CC00")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  mission.OutScreenMessage(100023, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 20*10, function()  AcivateObjective("Beach_Franceville") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 20*10, function()  AcivateObjective("Franceville") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 20*10, function()  AcivateObjective("Orne_Canal") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 25*10, function()  AddBonus(1, 8, 3, -1, -1) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  SendPlane("Player", "Francevillestrike1", "bomber", "N", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 31*10, function()  SendPlane("Player", "Francevillestrike1", "bomber", "N", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 32*10, function()  SendPlane("Player", "Francevillestrike2", "bomber", "N", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 33*10, function()  SendPlane("Player", "Francevillestrike2", "bomber", "N", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 34*10, function()  SendPlane("Player", "Francevillestrike3", "bomber", "N", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 35*10, function()  SendPlane("Player", "Francevillestrike3", "bomber", "N", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 36*10, function()  SendPlane("Player", "Francevillestrike4", "bomber", "N", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 37*10, function()  SendPlane("Player", "Francevillestrike4", "bomber", "N", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 40*10, function()  mission.OutScreenMessage(100036, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 90*10, function()  RunSpawn("Player", {"British_3rd_Matador", "British_3rd_Matador", "British_3rd_Matador", "British_3rd_Matador", "British_3rd_Matador", }, "Landing_LaBreche", "3rd_British", "3rd_British", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 100*10, function()  SendPlaneFromMap(135, "fighter", "Beach_LaBreche", 15) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 180*10, function()  RunSpawn("Player", {"British_3rd_Matador", "British_3rd_Matador", "British_3rd_Matador", "British_3rd_Matador", "British_3rd_Matador", }, "Landing_LaBreche", "3rd_British", "3rd_British", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:RemovePeriodic("113a. Objective PeriersRidge Cleared")
	end
end

function func_008b__Counterattack_Pegasus1()
	if IsObjectiveCompleted("PegasusBridge1", "Player") and GetGameTime() > 1800 and GetGameTime() < 3599 and NumPlayerUnitsInZone("Enemy", "PegasusBridge1") > 0 and NumPlayerUnitsInZone("Player", "PegasusBridge1") < 1 then
		MoveGroupToZone("PegagsusForce", "Village_Benouville", true, true)
		mission.OutScreenMessage(100031, 10, "0xFFFF0000")
		Bombardment("PegasusBridge", 0, 10, 6, 200)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 22*10, function()  CreateFXObject("buildings/bridge_broken_05.dsc", "PegasusBridge", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  PlayerDefeat("Player") end)
		AIparts:RemovePeriodic("008b. Counterattack Pegasus1")
	end
	if GetGameTime() > 1800 and GetGameTime() < 3599 and NumPlayerUnitsInZone("Enemy", "PegasusBridge1") > 0 and NumPlayerUnitsInZone("Player", "PegasusBridge1") < 1 then
		MoveGroupToZone("PegagsusForce", "Village_Benouville", true, true)
		mission.OutScreenMessage(100031, 10, "0xFFFF0000")
		Bombardment("PegasusBridge", 0, 10, 6, 200)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 22*10, function()  CreateFXObject("buildings/bridge_broken_05.dsc", "PegasusBridge", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  PlayerDefeat("Player") end)
		AIparts:RemovePeriodic("008b. Counterattack Pegasus1")
	end
end

function func_011__Colleville_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_Colleville") < 1 then
		mission.OutScreenMessage(100032, 10, "0xFF00CC00")
		AIparts:RemovePeriodic("011. Colleville Cleared")
	end
end

function func_012__Hermanville_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_Hermanville") < 1 then
		mission.OutScreenMessage(100033, 10, "0xFF00CC00")
		SendPlane("Player", "PeriersRidge", "fighter", "N", 15, -1, "")
		SendPlane("Player", "PeriersRidge", "fighter", "N", 15, -1, "")
		AIparts:RemovePeriodic("012. Hermanville Cleared")
	end
end

function func_099a__Bombing_at_57min()
	if GetGameTime() > 3420 then
		SendPlane("Player", "Village_St_Aubin", "extra", "N", 15, -1, "")
		SendPlane("Player", "Village_St_Aubin", "extra", "N", 15, -1, "")
		SendPlane("Player", "Village_Lion", "extra", "N", 15, -1, "")
		SendPlane("Player", "Village_Lion", "extra", "N", 15, -1, "")
		SendPlane("Player", "Village_Lion_Bunker", "extra", "N", 15, -1, "")
		SendPlane("Player", "Village_LaBreche", "extra", "N", 15, -1, "")
		SendPlane("Player", "Village_LaBreche", "extra", "N", 15, -1, "")
		SendPlane("Player", "Village_Quistreham1", "extra", "N", 15, -1, "")
		SendPlane("Player", "Village_Quistreham2", "extra", "N", 15, -1, "")
		SendPlane("Player", "Village_Quistreham_Coast1", "extra", "N", 15, -1, "")
		SendPlane("Player", "Village_Quistreham_Coast2", "extra", "N", 15, -1, "")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 4*10, function()  SendPlane("Player", "Village_Quistreham3", "extra", "N", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 4*10, function()  SendPlane("Player", "Village_Quistreham4", "extra", "N", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  mission.OutScreenMessage(100035, 5, "0xFF00CC00") end)
		AIparts:RemovePeriodic("099a. Bombing at 57min")
	end
end

function func_112b__Landing_185th__Brig__see_script_112a()
	
end

function func_113b__Landing_9th__Brig__see_script_113a()
	
end

function func_013__Periers_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_Periers") < 1 then
		mission.OutScreenMessage(100029, 10, "0xFF00CC00")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  mission.OutScreenMessage(100078, 5, "0xFFFF0000") end)
		Bombardment("Village_Periers", 50, 8, 6, 200)
		AIparts:RemovePeriodic("013. Periers Cleared")
	end
end

function func_014__Douvres_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_Douvres") < 1 then
		mission.OutScreenMessage(100038, 10, "0xFF00CC00")
		AIparts:RemovePeriodic("014. Douvres Cleared")
	end
end

function func_007b__Troarn_Counterattack()
	if ( NumPlayerUnitsInZone("Player", "Village_Troarn") > 3 and not IsObjectiveActive("Village_Troarn") and not IsObjectiveCompleted("Village_Troarn", "Player")  ) then
		RunSpawn("Enemy", {"German_TroarnForce", "German_TroarnForce", "German_TroarnForce", }, "TroarnForce", "TroarnForce", "TroarnForce", true, true, {{unload_to="Village_Troarn", }, {assault="Village_Troarn", }, }, false, 50)
		mission.OutScreenMessage(100039, 10, "0xFFFF0000")
		AIparts:RemovePeriodic("007b. Troarn Counterattack")
	end
end

function func_006b__Bures_Counterattack()
	if ( NumPlayerUnitsInZone("Player", "Village_Bures") > 3 and not IsObjectiveCompleted("Village_Bures", "Player") and not IsObjectiveActive("Village_Bures")  ) then
		RunSpawn("Enemy", {"German_TroarnForce", "German_TroarnForce", "German_TroarnForce", }, "BuresForce", "BuresForce", "BuresForce", true, true, {{unload_to="Village_Bures", }, {assault="Village_Bures", }, }, false, 50)
		mission.OutScreenMessage(100039, 10, "0xFFFF0000")
		AIparts:RemovePeriodic("006b. Bures Counterattack")
	end
end

function func_000__Minefield1()
	if NumPlayerUnitsInZone("Player", "Minefield1") > 0 then
		mission.OutScreenMessage(251, 10, "0xFFFF0000")
		AIparts:RemovePeriodic("000. Minefield1")
	end
end

function func_000__Minefield2()
	if NumPlayerUnitsInZone("Player", "Minefield2") > 0 then
		mission.OutScreenMessage(251, 10, "0xFFFF0000")
		AIparts:RemovePeriodic("000. Minefield2")
	end
end

function func_200__Objectives_cleared_activate_Caen()
	if IsObjectiveCompleted("Beuville", "Player") and IsObjectiveCompleted("LebiseyForest", "Player") then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  AcivateObjective("Caen") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 11*10, function()  AcivateObjective("Carpiquet_Airfield") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 12*10, function()  AcivateObjective("Colombelles") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 180*10, function()  mission.OutScreenMessage(100053, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 210*10, function()  RunSpawn("Player", {"Canadian_Daimler", "Canadian_2_Churchill_Fl", "Canadian_2_Churchill_Fl", "Canadian_Sherman_II", "Canadian_Sherman_II", "Canadian_Sherman_II", }, "Canadian_reinforcement", "3rd_Canadian", "3rd_Canadian", true, true, {}, false, 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 240*10, function()  RunSpawn("Player", {"Canadian_M3a1", "Canadian_M3a1", "Canadian_M3a1", }, "Canadian_indantry", "3rd_Canadian", "3rd_Canadian", true, true, {}, false, 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 1200*10, function()  mission.OutScreenMessage(100054, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 1210*10, function()  RunSpawn("Player", {"Canadian_Achilles", "Canadian_Achilles", "Canadian_Achilles", "Canadian_Firefly", "Canadian_Firefly", "Canadian_Firefly", "Canadian_Daimler", "Canadian_Daimler", "Canadian_Daimler", }, "Canadian_indantry", "3rd_Canadian", "3rd_Canadian", true, true, {}, false, 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 1240*10, function()  RunSpawn("Player", {"Canadian_Cromwell", "Canadian_Cromwell", "Canadian_Cromwell", "Canadian_Sherman_II", "Canadian_Sherman_II", "Canadian_Sherman_II", "Canadian_2_Churchill_Fl", "Canadian_2_Churchill_Fl", "Canadian_2_Churchill_Fl", }, "Canadian_indantry", "3rd_Canadian", "3rd_Canadian", true, true, {}, false, 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2400*10, function()  mission.OutScreenMessage(100055, 20, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2410*10, function()  RunSpawn("Player", {"Canadian_Carrier_Antitank", "Canadian_Carrier_Antitank", "Canadian_Carrier_Antitank", "Canadian_Carrier_Antitank", }, "Canadian_indantry", "3rd_Canadian", "3rd_Canadian", true, true, {}, false, 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2470*10, function()  RunSpawn("Player", {"Canadian_M3a1_Arty", "Canadian_M3a1_Arty", "Canadian_M3a1_Arty", }, "Canadian_reinforcement", "3rd_Canadian", "3rd_Canadian", true, true, {}, false, 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2530*10, function()  RunSpawn("Player", {"Canadian_Willy_Sup", "Canadian_Willy_Sup", "Canadian_Willy_Sup", "Canadian_Willy_Sup", }, "Canadian_indantry", "3rd_Canadian", "3rd_Canadian", true, true, {}, false, 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2560*10, function()  RunSpawn("Player", {"Canadian_M3a1", "Canadian_M3a1", }, "Canadian_reinforcement", "3rd_Canadian", "3rd_Canadian", true, true, {}, false, 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2620*10, function()  RunSpawn("Player", {"Canadian_M3a1", "Canadian_M3a1", "Canadian_M3a1", }, "Canadian_reinforcement", "3rd_Canadian", "3rd_Canadian", true, true, {}, false, 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2680*10, function()  RunSpawn("Player", {"Canadian_M3a1", "Canadian_M3a1", "Canadian_M3a1", }, "Canadian_reinforcement", "3rd_Canadian", "3rd_Canadian", true, true, {}, false, 0) end)
		AIparts:RemovePeriodic("200. Objectives cleared activate Caen")
	end
end

function func_120__Counterattack_192PanzerGrenReg()
	if GetGameTime() > 12001 or IsObjectiveCompleted("Periers Ridge", "Player") then
		RunSpawn("Enemy", {"German_21st_Inf", }, "21PanzerCounter", "192ndPanzerGrenReg", "192ndPanzerGrenReg", true, true, {{dislocation="192PanzerGrenReg", }, }, false, 100)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  RunSpawn("Enemy", {"German_21st_Tks", }, "21PanzerCounter", "192ndPanzerGrenReg", "192ndPanzerGrenReg", false, false, {}, false, 100) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 180*10, function()  MoveGroupToZone("192ndPanzerGrenReg", "Village_Lion", true, false) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 185*10, function()  mission.OutScreenMessage(100041, 10, "0xFFFF0000") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 480*10, function()  MoveGroupToZone("192ndPanzerGrenReg", "Village_Lion", true, false) end)
		AIparts:RemovePeriodic("120. Counterattack 192PanzerGrenReg")
	end
end

function func_000__Defeat_or_Win()
	if GetGameTime() > 9000 and NumPlayerUnitsInZone("Enemy", "Village_Lion") > 5 and NumPlayerUnitsInZone("Player", "Village_Lion") < 5 then
		mission.OutScreenMessage(100042, 10, "0xFFFF0000")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  PlayerDefeat("Player") end)
		AIparts:RemovePeriodic("000. Defeat or Win")
	end
	if GetGameTime() > 3700 and NumPlayerUnits("Player") < 20 then
		mission.OutScreenMessage(100050, 10, "0xFFFF0000")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  PlayerDefeat("Player") end)
		AIparts:RemovePeriodic("000. Defeat or Win")
	end
	if IsObjectiveCompleted("Caen", "Player") and IsObjectiveCompleted("Colombelles", "Player") and IsObjectiveCompleted("Carpiquet_Airfield", "Player") then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  mission.OutScreenMessage(100062, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 25*10, function()  PlayerWin("Player") end)
		AIparts:RemovePeriodic("000. Defeat or Win")
	end
end

function func_002a__Maj_John_Howard_Arrived()
	do
		dofile("Missions/Single/Sword Beach/para2.lua")
		msd_vars.varHoward_ID = (77422)
		LogVariable("varHoward_ID = ", msd_vars.varHoward_ID)
		SetEvent("EvHowardArrived")
		AIparts:RemovePeriodic("002a. Maj John Howard Arrived")
	end
end

function func_001a__Lt_Col_Terence_Otway_Arrived()
	do
		dofile("Missions/Single/Sword Beach/para2.lua")
		msd_vars.varOtway_ID = (77481)
		LogVariable("varOtway_ID = ", msd_vars.varOtway_ID)
		SetEvent("EvOtwayArrived")
		AIparts:RemovePeriodic("001a. Lt Col Terence Otway Arrived")
	end
end

function func_000__Camera()
	do
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 1*10, function()  mission.CameraLock(true) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2*10, function()  mission.OutScreenMessage(100045, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 3*10, function()  AcivateObjective("PegasusBridge1") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  AcivateObjective("PegasusBridge2") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 7*10, function()  AcivateObjective("MervilleBattery") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 12*10, function()  mission.CameraAt({681.544495, 2.998398, 276.853973}, 45.000000, 94.042969, 95.863541, 5.00) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 17*10, function()  mission.OutScreenMessage(100046, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 27*10, function()  mission.CameraAt({478.684387, 3.003723, 15.644147}, 45.000000, 94.042969, 62.211922, 5.00) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 32*10, function()  mission.OutScreenMessage(100047, 5, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 37*10, function()  mission.CameraAt({245.375137, 4.393005, 17.378223}, 45.000000, 94.042969, 60.247131, 5.00) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 42*10, function()  mission.OutScreenMessage(100048, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 52*10, function()  mission.CameraLock(false) end)
	end
end

function func_110d__Objective_St_Aubin_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_St_Aubin") < 1 and IsObjectiveActive("Saint_Aubin-sur-Mer") then
		SetObjectiveComplete("Saint_Aubin-sur-Mer", "Player")
		mission.OutScreenMessage(100010, 10, "0xFF00CC00")
		AIparts:RemovePeriodic("110d. Objective St Aubin Cleared")
	end
end

function func_098__Mortars_at_La_breche()
	if NumPlayerUnitsInZone("Player", "Beach_La_Breche") > 5 then
		GroupAttackPlace("LaBrecheForceMortars", "Beach_LaBreche", 60)
		AIparts:UpdatePeriodic("098. Mortars at La breche", 150)
	end
end

function func_114d__Landing_3rd_Div_Arty()
	if IsObjectiveCompleted("Beach_Franceville", "Player") and IsObjectiveCompleted("Orne_Canal", "Player") and IsObjectiveCompleted("Franceville", "Player") then
		AcivateObjective("Beuville")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  AcivateObjective("LebiseyForest") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  mission.OutScreenMessage(100037, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 20*10, function()  RunSpawn("Player", {"Britsh_LandingShip", }, "Landing_LaBreche", "3rd_British", "3rd_British", false, true, {{unload=true, }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 170*10, function()  RunSpawn("Player", {"British_3rd_Artillery_Antitk", }, "Arty", "3rd_British", "3rd_British", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 190*10, function()  RunSpawn("Player", {"British_3rd_Artillery_Antitk", }, "Arty", "3rd_British", "3rd_British", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 210*10, function()  RunSpawn("Player", {"British_3rd_Artillery_Antitk", }, "Arty", "3rd_British", "3rd_British", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 230*10, function()  RunSpawn("Player", {"British_3rd_Artillery_Antitk", }, "Arty", "3rd_British", "3rd_British", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 250*10, function()  RunSpawn("Player", {"British_3rd_Artillery", }, "Arty", "3rd_British", "3rd_British", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 270*10, function()  RunSpawn("Player", {"British_3rd_Artillery", }, "Arty", "3rd_British", "3rd_British", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 290*10, function()  RunSpawn("Player", {"British_3rd_Artillery", }, "Arty", "3rd_British", "3rd_British", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 330*10, function()  RunSpawn("Player", {"British_3rd_AA", }, "Arty", "3rd_British", "3rd_British", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 350*10, function()  RunSpawn("Player", {"British_3rd_AA", }, "Arty", "3rd_British", "3rd_British", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 370*10, function()  RunSpawn("Player", {"British_3rd_AA", }, "Arty", "3rd_British", "3rd_British", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 385*10, function()  SendPlaneFromMap(135, "fighter", "Beach_LaBreche", 15) end)
		AIparts:RemovePeriodic("114d. Landing 3rd Div Arty")
	end
end

function func_500__Reserve_27th_Armoured_Brig__14400()
	if GetGameTime() > 14400 and NumGroupUnits("27th_Arm_Brig", 16, false, false, false) < 8 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  mission.OutScreenMessage(100049, 5, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  RunSpawn("Player", {"British_27_Sherman", "British_27_Sherman", "British_27_Sherman", "British_27_Sherman", "British_27_Sherman", }, "Landing_LaBreche", "27th_Arm_Brig", "27th_Arm_Brig", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 90*10, function()  RunSpawn("Player", {"British_27_achilles", "British_27_achilles", "British_27_achilles", "British_27_centaur", "British_27_centaur", }, "Landing_LaBreche", "27th_Arm_Brig", "27th_Arm_Brig", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  RunSpawn("Player", {"British_27_Firefly", "British_27_Firefly", "British_27_Churchill", "British_27_Churchill", "British_27_Churchill", }, "Landing_LaBreche", "27th_Arm_Brig", "27th_Arm_Brig", false, true, {{unload=true, }, {dislocation="British_3rd_Out", }, {disappear=true, }, }, false, 50) end)
		AIparts:RemovePeriodic("500. Reserve 27th Armoured Brig. 14400")
	end
end

function func_130__German_airplanes_to_beach()
	if NumPlayerUnitsInZone("Player", "Beach_La_Breche") > 10 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  SendPlaneFromMap(135, "fighter", "Beach_LaBreche", 15) end)
		AIparts:RemovePeriodic("130. German airplanes to beach")
	end
end

function func_000_Carpiquet_airfield_taken()
	if NumGroupUnits("Carpiquet_Enemy", 0, false, false, false) > 0 and NumPlayerUnitsInZones("Player", {"Airfield_Carpiquet", }) > 0 and NumGroupUnits("Carpiquet_AirfieldForce", 0, false, false, false) < 1 then
		TransferUnits("Carpiquet_Enemy", 0, "Carpiquet_Player", 0)
		UpdateGroupCounters("Carpiquet_Player")
	end
	if NumGroupUnits("Carpiquet_Player", 0, false, false, false) > 0 and NumPlayerUnitsInZones("Player", {"Airfield_Carpiquet", }) > 0 and NumGroupUnits("Carpiquet_AirfieldForce", 0, false, false, false) < 1 then
		TransferUnits("Carpiquet_Player", 0, "Carpiquet_Enemy", 0)
		UpdateGroupCounters("Carpiquet_Enemy")
	end
end

function func_015__Beuville_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_Beuville") < 1 and IsObjectiveActive("Beuville") then
		SetObjectiveComplete("Beuville", "Player")
		mission.OutScreenMessage(100051, 10, "0xFF00CC00")
		AIparts:RemovePeriodic("015. Beuville Cleared")
	end
end

function func_016__Lebisey_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_Lebisey") < 1 then
		mission.OutScreenMessage(100057, 10, "0xFF00CC00")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 25*10, function()  AddBonus(1, 8, 1, -1, -1) end)
		AIparts:RemovePeriodic("016. Lebisey Cleared")
	end
end

function func_017__Carpiquet_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_Carpiquet") < 1 then
		mission.OutScreenMessage(100058, 10, "0xFF00CC00")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 25*10, function()  AddBonus(1, 8, 1, -1, -1) end)
		AIparts:RemovePeriodic("017. Carpiquet Cleared")
	end
end

function func_000__Minefield3()
	if NumPlayerUnitsInZone("Player", "Minefield3") > 0 then
		mission.OutScreenMessage(251, 10, "0xFFFF0000")
		AIparts:RemovePeriodic("000. Minefield3")
	end
end

function func_201__Set_behaviour_AA_groups()
	if IsObjectiveActive("Caen") then
		SetGroupBehaviour("AA_Battery_1", false, false, true, nil, false, true, true, true, nil, nil)
		SetGroupBehaviour("AA_Battery_SS", false, false, true, nil, false, true, true, true, nil, nil)
		AIparts:RemovePeriodic("201. Set behaviour AA groups")
	end
end

function func_303__Caen_cleared()
	if NumPlayerUnitsInZone("Enemy", "Caen1") < 1 and NumPlayerUnitsInZone("Enemy", "Caen2") < 1 and NumPlayerUnitsInZone("Enemy", "Caen3") < 1 and NumPlayerUnitsInZone("Enemy", "Caen4") < 1 and NumPlayerUnitsInZone("Enemy", "Caen5") < 1 and IsObjectiveActive("Caen") then
		SetObjectiveComplete("Caen", "Player")
		mission.OutScreenMessage(100059, 10, "0xFF00CC00")
		AIparts:RemovePeriodic("303. Caen cleared")
	end
end

function func_302__CarpiquetAirfield_cleared()
	if NumPlayerUnitsInZone("Enemy", "Airfield_Carpiquet") < 1 and IsObjectiveActive("Carpiquet_Airfield") then
		SetObjectiveComplete("Carpiquet_Airfield", "Player")
		mission.OutScreenMessage(100060, 10, "0xFF00CC00")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  SendPlane("Player", "Carpiquet_Airfield", "transport", "N", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  SendPlane("Player", "Carpiquet_Airfield", "transport", "N", 15, -1, "") end)
		AIparts:RemovePeriodic("302. CarpiquetAirfield cleared")
	end
end

function func_301__Colombelles_cleared()
	if NumPlayerUnitsInZone("Enemy", "Town_Colombelles") < 1 and IsObjectiveActive("Colombelles") then
		SetObjectiveComplete("Colombelles", "Player")
		mission.OutScreenMessage(100061, 10, "0xFF00CC00")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 25*10, function()  AddBonus(1, 8, 1, -1, -1) end)
		AIparts:RemovePeriodic("301. Colombelles cleared")
	end
end

function func_202__Airstrike_Colombelles()
	if IsObjectiveActive("Colombelles") then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  SendPlane("Player", "ColombellesStrike1", "extra", "N", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  SendPlane("Player", "ColombellesStrike1", "extra", "N", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  SendPlane("Player", "ColombellesStrike1", "extra", "N", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 61*10, function()  mission.OutScreenMessage(100063, 10, "0xFF00CC00") end)
		AIparts:RemovePeriodic("202. Airstrike Colombelles")
	end
end

function func_203__Airstrike_Caen()
	if NumPlayerUnitsInZone("Player", "LebiseyForest") > 0 and NumPlayerUnitsInZone("Player", "Caen1") < 1 and NumPlayerUnitsInZone("Player", "Caen2") < 1 and NumPlayerUnitsInZone("Player", "Caen3") < 1 and NumPlayerUnitsInZone("Player", "Caen4") < 1 and NumPlayerUnitsInZone("Player", "Caen5") < 1 then
		SendPlane("Player", "CaenStrike1", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike1", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike2", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike2", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike3", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike3", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike4", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike4", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike5", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike5", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike6", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike6", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike7", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike7", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike8", "extra", "N", 25, -1, "")
		SendPlane("Player", "CaenStrike8", "extra", "N", 25, -1, "")
		SendPlane("Player", "CaenStrike9", "extra", "N", 25, -1, "")
		SendPlane("Player", "CaenStrike9", "extra", "N", 25, -1, "")
		SendPlane("Player", "CaenStrike0", "extra", "N", 25, -1, "")
		SendPlane("Player", "CaenStrike0", "extra", "N", 25, -1, "")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2*10, function()  mission.OutScreenMessage(100064, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  SetEvent("EvCaen_Reinforcements") end)
		AIparts:RemovePeriodic("203. Airstrike Caen")
	end
	if NumPlayerUnitsInZone("Player", "Town_Colombelles") > 0 and NumPlayerUnitsInZone("Player", "Caen1") < 1 and NumPlayerUnitsInZone("Player", "Caen2") < 1 and NumPlayerUnitsInZone("Player", "Caen3") < 1 and NumPlayerUnitsInZone("Player", "Caen4") < 1 and NumPlayerUnitsInZone("Player", "Caen5") < 1 then
		SendPlane("Player", "CaenStrike1", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike1", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike2", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike2", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike3", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike3", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike4", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike4", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike5", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike5", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike6", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike6", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike7", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike7", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike8", "extra", "N", 25, -1, "")
		SendPlane("Player", "CaenStrike8", "extra", "N", 25, -1, "")
		SendPlane("Player", "CaenStrike9", "extra", "N", 25, -1, "")
		SendPlane("Player", "CaenStrike9", "extra", "N", 25, -1, "")
		SendPlane("Player", "CaenStrike0", "extra", "N", 25, -1, "")
		SendPlane("Player", "CaenStrike0", "extra", "N", 25, -1, "")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2*10, function()  mission.OutScreenMessage(100064, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  SetEvent("EvCaen_Reinforcements") end)
		AIparts:RemovePeriodic("203. Airstrike Caen")
	end
	if NumPlayerUnitsInZone("Player", "Village_Carpiquet") > 0 and NumPlayerUnitsInZone("Player", "Caen1") < 1 and NumPlayerUnitsInZone("Player", "Caen2") < 1 and NumPlayerUnitsInZone("Player", "Caen3") < 1 and NumPlayerUnitsInZone("Player", "Caen4") < 1 and NumPlayerUnitsInZone("Player", "Caen5") < 1 then
		SendPlane("Player", "CaenStrike1", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike1", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike2", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike2", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike3", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike3", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike5", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike5", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike6", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike6", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike7", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike7", "extra", "N", 15, -1, "")
		SendPlane("Player", "CaenStrike8", "extra", "N", 25, -1, "")
		SendPlane("Player", "CaenStrike8", "extra", "N", 25, -1, "")
		SendPlane("Player", "CaenStrike9", "extra", "N", 25, -1, "")
		SendPlane("Player", "CaenStrike9", "extra", "N", 25, -1, "")
		SendPlane("Player", "CaenStrike0", "extra", "N", 25, -1, "")
		SendPlane("Player", "CaenStrike0", "extra", "N", 25, -1, "")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2*10, function()  mission.OutScreenMessage(100064, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  SetEvent("EvCaen_Reinforcements") end)
		AIparts:RemovePeriodic("203. Airstrike Caen")
	end
end

function func_150__What_if_Troarn___Bures_not_taken()
	if GetGameTime() > 4800 and IsObjectiveActive("Village_Troarn") then
		RunSpawn("Enemy", {"German_711_ID", }, "TroarnForce", "711_ID", "711_ID", true, true, {}, false, 50)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  mission.OutScreenMessage(100065, 10, "0xFFFF0000") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 50*10, function()  MoveGroupToZone("711_ID", "PegasusBridge1", true, false) end)
		AIparts:RemovePeriodic("150. What if Troarn / Bures not taken")
	end
	if GetGameTime() > 4850 and IsObjectiveActive("Village_Bures") then
		RunSpawn("Enemy", {"German_711_ID", }, "BuresForce", "711_ID", "711_ID", true, true, {}, false, 50)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  mission.OutScreenMessage(100066, 10, "0xFFFF0000") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 50*10, function()  MoveGroupToZone("711_ID", "PegasusBridge1", true, false) end)
		AIparts:RemovePeriodic("150. What if Troarn / Bures not taken")
	end
end

function func_018__Bieville_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_Bieville") < 1 then
		mission.OutScreenMessage(100067, 10, "0xFF00CC00")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 20*10, function()  mission.OutScreenMessage(100068, 10, "0xFFFF0000") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 25*10, function()  AddBonus(1, 8, 1, -1, -1) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  Bombardment("Village_Bieville", 100, 8, 6, 30) end)
		AIparts:RemovePeriodic("018. Bieville Cleared")
	end
end

function func_175__Counterattack_Colombelles()
	if NumPlayerUnitsInZone("Player", "Town_Colombelles") > 5 then
		RunSpawn("Enemy", {"German_ColombellesForce", }, "ColombellesForce", "ColombellesForce", "ColombellesForce", true, true, {{unload_to="Town_Colombelles", }, }, false, 30)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 300*10, function()  RunSpawn("Enemy", {"German_ColombellesForce", }, "ColombellesForce", "ColombellesForce", "ColombellesForce", true, true, {{unload_all=true, }, {unload_to="Town_Colombelles", }, }, false, 30) end)
		AIparts:RemovePeriodic("175. Counterattack Colombelles")
	end
end

function func_000__Minefield4()
	if NumPlayerUnitsInZone("Player", "Minefield4") > 0 then
		mission.OutScreenMessage(251, 10, "0xFFFF0000")
		AIparts:RemovePeriodic("000. Minefield4")
	end
end

function func_176__Counterattack_Carpiquet_airfield()
	if NumPlayerUnitsInZone("Player", "Airfield_Carpiquet") > 1 then
		RunSpawn("Enemy", {"German_Carpiquet_airfield", }, "Carpiquet_airfield", "Carpiquet_AirfieldForce", "Carpiquet_AirfieldForce", true, true, {}, false, 50)
		AIparts:RemovePeriodic("176. Counterattack Carpiquet_airfield")
	end
end

function func_177__Counterattack_Carpiquet_village()
	if NumPlayerUnitsInZone("Player", "Village_Carpiquet") > 1 then
		RunSpawn("Enemy", {"German_CarpiquetForce", "German_CarpiquetForce", "German_CarpiquetForce", "German_CarpiquetForce", "German_CarpiquetForce", }, "CarpiquetForce", "CarpiquetForce", "CarpiquetForce", true, true, {{unload_to="Village_Carpiquet", }, }, false, 50)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 250*10, function()  UnloadTransports("CarpiquetForce") end)
		AIparts:RemovePeriodic("177. Counterattack Carpiquet_village")
	end
end

function func_178__Counterattack_Merville_Gun_1()
	if IsObjectiveActive("Franceville") then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 290*10, function()  RunSpawn("Enemy", {"German_TroarnForce", "German_TroarnForce", "German_TroarnForce", }, "FrancevilleRoad", "MervilleForce", "MervilleForce", true, true, {{assault="Merville0", }, {unload_to="Merville0", }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 330*10, function()  RunSpawn("Enemy", {"German_TroarnForce", "German_Sturmgeschutz", }, "FrancevilleRoad", "MervilleForce", "MervilleForce", true, true, {{assault="Merville0", }, {unload_to="Merville0", }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 340*10, function()  mission.OutScreenMessage(100069, 10, "0xFFFF0000") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 380*10, function()  MoveGroupToZone("MervilleForce", "MervilleBattery", true, false) end)
		AIparts:RemovePeriodic("178. Counterattack Merville Gun 1")
	end
end

function func_501__Reserve_51_Div_and_4th_Arm_()
	if GetGameTime() > 21600 and NumPlayerUnits("Player") < 100 then
		mission.OutScreenMessage(100070, 10, "0xFF00CC00")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  RunSpawn("Player", {"British_51th_antitank", "British_51th_antitank", "British_51th_antitank", "British_51th_antitank", }, "Canadian_reinforcement", "51st_Highland_Div", "51st_Highland_Div", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 40*10, function()  RunSpawn("Player", {"British_51th_artillery", "British_51th_artillery", "British_51th_artillery", }, "Canadian_reinforcement", "51st_Highland_Div", "51st_Highland_Div", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 80*10, function()  RunSpawn("Player", {"British_51th_AA", "British_51th_AA", "British_51th_AA", "British_51th_AA", }, "Canadian_reinforcement", "51st_Highland_Div", "51st_Highland_Div", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 120*10, function()  RunSpawn("Player", {"British_51th_supply", }, "Canadian_reinforcement", "51st_Highland_Div", "51st_Highland_Div", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 270*10, function()  mission.OutScreenMessage(100072, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 290*10, function()  RunSpawn("Player", {"British_4th_Sherman", "British_4th_Sherman", "British_4th_Sherman", "British_4th_Sherman", }, "Canadian_indantry", "4th_Arm_Brig", "4th_Arm_Brig", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 320*10, function()  RunSpawn("Player", {"British_4th_Firefly", "British_4th_Firefly", "British_4th_Firefly", "British_4th_Firefly", }, "Canadian_indantry", "4th_Arm_Brig", "4th_Arm_Brig", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 350*10, function()  RunSpawn("Player", {"British_4th_Centaur", "British_4th_Centaur", "British_4th_Centaur", "British_4th_Centaur", }, "Canadian_indantry", "4th_Arm_Brig", "4th_Arm_Brig", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 380*10, function()  RunSpawn("Player", {"British_4th_Churchill", "British_4th_Churchill", "British_4th_Churchill", "British_51th_supply", }, "Canadian_indantry", "4th_Arm_Brig", "4th_Arm_Brig", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 410*10, function()  AddBonus(1, 8, 3, -1, -1) end)
		AIparts:RemovePeriodic("501. Reserve 51 Div and 4th Arm ")
	end
end

function func_181__Counterattack_Herouvillette()
	if GetGameTime() > 3600 and NumPlayerUnitsInZone("Player", "Village_Herouvilette") > 1 then
		RunSpawn("Enemy", {"German_HerouviletteForce", }, "HerouviletteForce", "HerouviletteForce", "HerouviletteForce", true, true, {}, false, 50)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 50*10, function()  UnloadTransports("HerouviletteForce") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  MoveGroupToZone("HerouviletteForce", "Village_Herouvilette", true, false) end)
		AIparts:RemovePeriodic("181. Counterattack Herouvillette")
	end
end

function func_019__Herouvillette_Cleared()
	if NumPlayerUnitsInZone("Enemy", "Village_Herouvilette") < 1 then
		mission.OutScreenMessage(100071, 10, "0xFF00CC00")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  SendPlaneFromMap(135, "fighter", "Beach_LaBreche", 15) end)
		AIparts:RemovePeriodic("019. Herouvillette Cleared")
	end
end

function func_304__Caen1_invaded()
	if NumPlayerUnitsInZone("Player", "Caen1") > 0 then
		UnloadTransports("Caen1Force")
		SetGroupBehaviour("Caen1Force", true, true, true, false, false, true, true, true, true, false)
		AIparts:RemovePeriodic("304. Caen1 invaded")
	end
end

function func_305__Caen_reinforcements()
	if IsEventPresent("EvCaen_Reinforcements") then
		RunSpawn("Enemy", {"German_CaenForce_Inf", "German_CaenForce_Inf", "German_CaenForce_Inf", "German_CaenForce_markIV", "German_CaenForce_markIV", }, "Caen_4", "Caen4Force", "Caen4Force", true, true, {}, false, 0)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  SetObjectiveComplete("Caen_reinforcements", "Player") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  RunSpawn("Enemy", {"German_CaenForce_Inf", "German_CaenForce_Inf", "German_CaenForce_Inf", "German_CaenForce_markIV", "German_CaenForce_markIV", }, "Caen_3", "Caen3Force", "Caen3Force", true, true, {}, false, 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  RunSpawn("Enemy", {"German_CaenForce_Inf", "German_CaenForce_Inf", "German_CaenForce_Inf", "German_CaenForce_markIV", "German_CaenForce_markIV", }, "Caen_2", "Caen2Force", "Caen2Force", true, true, {}, false, 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 20*10, function()  RunSpawn("Enemy", {"German_CaenForce_Inf", "German_CaenForce_Inf", "German_CaenForce_Inf", "German_CaenForce_markIV", "German_CaenForce_markIV", }, "Caen_5", "Caen5Force", "Caen5Force", true, true, {}, false, 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  UnloadTransports("Caen4Force") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 61*10, function()  UnloadTransports("Caen3Force") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 62*10, function()  UnloadTransports("Caen2Force") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 63*10, function()  UnloadTransports("Caen5Force") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 80*10, function()  UnloadTransports("Caen4Force") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 81*10, function()  UnloadTransports("Caen3Force") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 82*10, function()  UnloadTransports("Caen2Force") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 83*10, function()  UnloadTransports("Caen5Force") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 100*10, function()  SetGroupBehaviour("Caen4Force", true, true, nil, nil, nil, true, true, nil, nil, nil) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 101*10, function()  SetGroupBehaviour("Caen3Force", true, true, nil, nil, nil, true, true, nil, nil, nil) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 102*10, function()  SetGroupBehaviour("Caen2Force", true, true, nil, nil, nil, true, true, nil, nil, nil) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 103*10, function()  SetGroupBehaviour("Caen5Force", true, true, nil, nil, nil, true, true, nil, nil, nil) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 104*10, function()  MoveGroupToZone("Caen3Force", "Caen3", false, false) end)
		AIparts:RemovePeriodic("305. Caen reinforcements")
	end
end

function func_179__Counterattack_Merville_Gun_2()
	if GetGameTime() > 3600 and IsObjectiveCompleted("MervilleBattery", "Player") and NumPlayerUnitsInZone("Player", "MervilleBattery") < 1 and NumPlayerUnitsInZone("Enemy", "MervilleBattery") > 0 then
		AcivateObjective("Merville_Battery")
		mission.OutScreenMessage(100073, 10, "0xFFFF0000")
		SetGroupBehaviour("MervilleForce", true, true, true, nil, nil, true, true, true, true, nil)
		AIparts:RemovePeriodic("179. Counterattack Merville Gun 2")
	end
end

function func_180__Counterattack_Merville_Gun_3()
	if IsObjectiveActive("Merville_Battery") and NumPlayerUnitsInZone("Enemy", "MervilleBattery") < 1 and NumPlayerUnitsInZone("Player", "MervilleBattery") > 0 then
		SetObjectiveComplete("Merville_Battery", "Player")
		mission.OutScreenMessage(100074, 10, "0xFF00CC00")
		AIparts:RemovePeriodic("180. Counterattack Merville Gun 3")
	end
end

function func_182b__Counterattack_12SS_1()
	if IsObjectiveCompleted("Beach_Franceville", "Player") then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2500*10, function()  RunSpawn("Enemy", {"German_Panther", "German_Jagdpanther", "German_Sturmgeschutz", }, "CarpiquetForce", "12SS_KG", "12SS_KG", false, false, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2600*10, function()  RunSpawn("Enemy", {"German_Panther", "German_Jagdpanther", "German_Sturmgeschutz", }, "CarpiquetForce", "12SS_KG", "12SS_KG", false, false, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2700*10, function()  RunSpawn("Enemy", {"German_Panther", "German_Jagdpanther", "German_Sturmgeschutz", }, "CarpiquetForce", "12SS_KG", "12SS_KG", false, false, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2710*10, function()  RunSpawn("Enemy", {"German_Panther", "German_Jagdpanther", "German_Sturmgeschutz", }, "CarpiquetForce", "12SS_KG", "12SS_KG", false, false, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2720*10, function()  RunSpawn("Enemy", {"German_Panther", "German_Jagdpanther", "German_Sturmgeschutz", }, "CarpiquetForce", "12SS_KG", "12SS_KG", false, false, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2730*10, function()  RunSpawn("Enemy", {"German_Panther", "German_Jagdpanther", "German_Sturmgeschutz", }, "CarpiquetForce", "12SS_KG", "12SS_KG", false, false, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2740*10, function()  RunSpawn("Enemy", {"German_Panther", "German_Jagdpanther", "German_Sturmgeschutz", }, "CarpiquetForce", "12SS_KG", "12SS_KG", false, false, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2750*10, function()  MoveGroupToZone("12SS_KG", "12SS", false, false) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2810*10, function()  MoveGroupToZone("12SS_KG", "Village_Douvres", true, false) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2811*10, function()  mission.OutScreenMessage(100075, 10, "0xFFFF0000") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2812*10, function()  GroupSetMicroAIBehaviour("12SS_KG", "Agressive") end)
		AIparts:RemovePeriodic("182b. Counterattack 12SS 1")
	end
end

function func_183__Counterattack_12SS_2()
	if GroupSeeEnemyNow("12SS_KG") then
		UnloadTransports("12SS_KG")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  MoveGroupToZone("12SS_KG", "Village_Douvres", true, false) end)
		AIparts:RemovePeriodic("183. Counterattack 12SS 2")
	end
end

function func_184__Counterattack_12SS_3()
	if NumGroupUnitsInZone("12SS_KG", "Village_Douvres") > 0 and NumPlayerUnitsInZone("Player", "Village_Douvres") < 1 then
		mission.OutScreenMessage(100076, 10, "0xFFFF0000")
		SetGroupBehaviour("12SS_KG", true, true, true, true, nil, true, true, nil, true, nil)
		AIparts:RemovePeriodic("184. Counterattack 12SS 3")
	end
end

function func_305__Colombelles_invaded_1()
	if NumPlayerUnitsInZone("Player", "Town_Colombelles") > 1 then
		SetGroupBehaviour("21_pzr_arty", false, false, true, false, false, true, true, true, false, false)
		AIparts:RemovePeriodic("305. Colombelles invaded 1")
	end
end

function func_306__Colombelles_invaded_2()
	if NumPlayerUnitsInZone("Player", "Town_Colombelles") > 2 then
		GroupAttackPlace("21_pzr_arty", "Colombelles_21pzr_arty", 100)
		AIparts:UpdatePeriodic("306. Colombelles invaded 2", 600)
	end
end

function func_307__Nebelwerferzone_1()
	if NumPlayerUnitsInZone("Player", "Nebelwerfer_zone") > 3 then
		SetGroupBehaviour("Nebelwerfer_battery_SS", false, false, true, false, false, true, true, true, false, false)
		AIparts:RemovePeriodic("307. Nebelwerferzone 1")
	end
end

function func_308__Nebelwerferzone_2()
	if NumPlayerUnitsInZone("Player", "Nebelwerfer_zone") > 5 then
		GroupAttackPlace("Nebelwerfer_battery_SS", "Nebelwerfer_zone", 100)
		mission.OutScreenMessage(100078, 5, "0xFFFF0000")
		AIparts:UpdatePeriodic("308. Nebelwerferzone 2", 300)
	end
end

function func_309__Arty_outpost()
	if NumPlayerUnitsInZone("Player", "Outpost") > 2 then
		SetGroupBehaviour("716_arty", false, false, true, false, false, true, true, true, false, false)
		GroupAttackPlace("716_arty", "outpost", 50)
		AIparts:UpdatePeriodic("309. Arty outpost", 150)
	end
end

function func_185__Counterattack_Colombelles_right_defence()
	if NumPlayerUnitsInZone("Player", "Colombelles_right_defence") > 1 then
		RunSpawn("Enemy", {"German_CaenForce_Inf", "German_CaenForce_markIV", "German_CaenForce_markIV", }, "HerouviletteForce", "LaBrecheForce2", "LaBrecheForce2", true, true, {}, false, 50)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  MoveGroupToZone("LaBrecheForce2", "Colombelles_right_defence", true, false) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 120*10, function()  SetGroupBehaviour("LaBrecheForce2", nil, true, true, nil, nil, true, true, nil, nil, nil) end)
		AIparts:RemovePeriodic("185. Counterattack Colombelles right defence")
	end
end

function func_186__Colombelles_right_defence()
	if GetGameTime() > 3600 and GroupSeeEnemyNow("LaBrecheForce2") then
		UnloadTransports("LaBrecheForce2")
		AIparts:RemovePeriodic("186. Colombelles right defence")
	end
end

function func_008c__Counterattack_Pegasus1()
	if NumPlayerUnitsInZone("Player", "PegasusBridge1") > 0 and GetGameTime() < 1800 then
		GroupSetMicroAIBehaviour("PegagsusForce3", "Agressive")
		MoveGroupToZone("PegagsusForce3", "PegasusBridge1", true, false)
		AIparts:RemovePeriodic("008c. Counterattack Pegasus1")
	end
end

function func_310__Patrol_enemy_seen()
	if GroupSeeEnemyNow("Patrol_Group1") then
		UnloadTransports("Patrol_Group1")
		RunSpawn("Enemy", {"German_Panther", "German_Sturmgeschutz", "German_Sturmgeschutz", "German_Jagdpanther", "German_Jagdpanther", }, "21PanzerCounter", "Patrol_Group1", "Patrol_Group1", true, true, {}, true, 0)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  UnloadTransports("Patrol_Group1") end)
		AIparts:RemovePeriodic("310. Patrol enemy seen")
	end
end

function func_000__Presets_Patrol()
	do
		groups.CreateTemplate("Patrol_Group1", groups.ttypes.patrol,
			{ call_for_help = true, call_for_howitzer = true, reinf_lost = 20,
			points = {"Patrol1","Patrol2","Patrol3","Patrol4", }, wait_time = {2,2,2,2, },
			spread_rad = 10, assault = false, group_move = false, circle = true })
		groups.AssignTemplate("Patrol_Group1", "Patrol_Group1")
	end
end

function func_311__Beuville_Artillery()
	if NumPlayerUnitsInZone("Player", "Village_Beuville_Arty") > 5 then
		mission.OutScreenMessage(100078, 5, "0xFFFF0000")
		Bombardment("Village_Beuville_Arty", 50, 8, 6, 30)
		AIparts:RemovePeriodic("311. Beuville_Artillery")
	end
end

function func_182a__Message_arrival_12SS_()
	if NumPlayerUnitsInZone("Player", "Beach_Franceville") > 0 or NumPlayerUnitsInZone("Player", "Village_Franceville") > 0 then
		mission.OutScreenMessage(100052, 20, "0xFFFF0000")
		AIparts:RemovePeriodic("182a. Message arrival 12SS ")
	end
end

function func_151__What_if_Franceville___Beach_Fr__not_taken()
	if not IsObjectiveCompleted("Beach_Franceville", "Player") and IsObjectiveCompleted("Beuville", "Player") then
		RunSpawn("Enemy", {"German_711_ID", }, "FrancevilleRoad", "711_ID", "711_ID", true, true, {}, false, 50)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  mission.OutScreenMessage(100056, 10, "0xFFFF0000") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 40*10, function()  RunSpawn("Enemy", {"German_711_ID", }, "FrancevilleRoad", "711_ID", "711_ID", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 90*10, function()  MoveGroupToZone("711_ID", "PegasusBridge1", true, false) end)
		AIparts:RemovePeriodic("151. What if Franceville / Beach Fr. not taken")
	end
end

function func_187__Counterattack_Beuville()
	if NumPlayerUnitsInZone("Player", "Village_Beuville") > 0 and NumPlayerUnitsInZone("Enemy", "Village_Beuville") < 10 then
		MoveGroupToZone("BeuvilleForce", "Village_Beuville", true, false)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  UnloadTransports("BeuvilleForce") end)
		AIparts:RemovePeriodic("187. Counterattack Beuville")
	end
end

function func_121__Counterattack_192PanzerGrenReg()
	if GetGameTime() > 12185 and GroupSeeEnemyNow("192ndPanzerGrenReg") then
		UnloadTransports("192ndPanzerGrenReg")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  MoveGroupToZone("192ndPanzerGrenReg", "Village_Lion", true, false) end)
		AIparts:RemovePeriodic("121. Counterattack 192PanzerGrenReg")
	end
end

function func_020__Merville_Cleared()
	if NumPlayerUnitsInZone("Player", "Village_Merville") > 0 then
		mission.OutScreenMessage(100094, 10, "0xFF00CC00")
		AIparts:RemovePeriodic("020. Merville Cleared")
	end
end

function func_502__3_Div_Heavy_Arty_()
	if NumPlayerUnitsInZone("Player", "Caen1") > 0 or NumPlayerUnitsInZone("Player", "Caen2") > 0 or NumPlayerUnitsInZone("Player", "Caen3") > 0 or NumPlayerUnitsInZone("Player", "Caen4") > 0 or NumPlayerUnitsInZone("Player", "Caen5") > 0 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  mission.OutScreenMessage(100095, 10, "0xFF00CC00") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  RunSpawn("Player", {"British_3rd_Heavy_Artillery", }, "Arty", "3rd_British", "3rd_British", true, true, {}, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 75*10, function()  RunSpawn("Player", {"British_3rd_Heavy_Artillery", }, "Arty", "3rd_British", "3rd_British", true, true, {}, false, 50) end)
		AIparts:RemovePeriodic("502. 3 Div Heavy Arty ")
	end
end

function func_New_Sound_all_12000_time_digits()
	do
		mission.OutScreenMessage(100096, 5, "0xFF000000")
	end
end

function func_001b__Lt_Col_Terence_Otway_Dead()
	if IsEventPresent("EvOtwayArrived") then
		dofile("Missions/Single/Sword Beach/para2.lua")
		msd_vars.varOtwayAlive = para.IsUnitDead(msd_vars.varOtway_ID, "Player")
		LogVariable("varOtwayAlive = ", msd_vars.varOtwayAlive)
	end
	if IsEventPresent("EvOtwayArrived") and not msd_vars.varOtwayAlive then
		log("OtwayDead")
		SetEvent("EvOtwayKilled")
		AIparts:RemovePeriodic("001b. Lt Col Terence Otway Dead")
	end
end

function func_001c__Lt_Col_Terence_Otway_Dead()
	if IsEventPresent("EvOtwayKilled") then
		mission.OutScreenMessage(100044, 10, "0xFFFF0000")
		TransferUnits("LZV", 0, "Otwaymen", 0)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 3600*10, function()  TransferUnits("Otwaymen", 0, "LZV", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 3601*10, function()  mission.OutScreenMessage(100104, 5, "0xFF00CC00") end)
		AIparts:RemovePeriodic("001c. Lt Col Terence Otway Dead")
	end
end

function func_002b__Maj_John_Howard_dead()
	if IsEventPresent("EvHowardArrived") then
		dofile("Missions/Single/Sword Beach/para2.lua")
		msd_vars.varHowardAlive = para.IsUnitDead(msd_vars.varHoward_ID, "Player")
		LogVariable("varHowardAlive = ", msd_vars.varHowardAlive)
	end
	if IsEventPresent("EvHowardArrived") and not msd_vars.varHowardAlive then
		log("HowardDead")
		SetEvent("EvHowardKilled")
	end
end

function func_002c__Maj_John_Howard_dead()
	if IsEventPresent("EvHowardKilled") then
		mission.OutScreenMessage(100043, 10, "0xFFFF0000")
		TransferUnits("LZW", 0, "Howardmen", 0)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 3600*10, function()  TransferUnits("Howardmen", 0, "LZW", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 3601*10, function()  mission.OutScreenMessage(100103, 5, "0xFF00CC00") end)
		AIparts:RemovePeriodic("002c. Maj John Howard dead")
	end
end

function func_105b__Landing_Lord_Lovat()
	if NumGroupUnitsInZone("SpecialService", "Beach_Ouistreham") > 20 then
		SetEvent("EvLovatLanded")
		AIparts:RemovePeriodic("105b. Landing Lord Lovat")
	end
end

function func_105c__Landing_Capt_Kieffer()
	if NumGroupUnitsInZone("French", "Beach_Ouistreham") > 20 then
		SetEvent("EvKiefferLanded")
		AIparts:RemovePeriodic("105c. Landing Capt Kieffer")
	end
end

function func_003a__Lord_Lovat_Arrived()
	if IsEventPresent("EvLovatLanded") then
		msd_vars.varLovat_ID = Spawn({desc = "Mods/Sword Beach/british_officer_Lovat.dsc", position = {-95, 0, 656}, player = "Player"})
		LogVariable("varLovat_ID = ", msd_vars.varLovat_ID)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 3*10, function()  SetEvent("EvLovatArrived") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  mission.OutScreenMessage(100097, 5, "0xFF00CC00") end)
		AIparts:RemovePeriodic("003a. Lord Lovat Arrived")
	end
end

function func_003b__Lord_Lovat_Dead()
	if IsEventPresent("EvLovatArrived") then
		dofile("Missions/Single/Sword Beach/para2.lua")
		msd_vars.varLovatAlive = para.IsUnitDead(msd_vars.varLovat_ID, "Player")
		LogVariable("varLovatAlive = ", msd_vars.varLovatAlive)
	end
	if IsEventPresent("EvLovatArrived") and not msd_vars.varLovatAlive then
		log("LovatDead")
		SetEvent("EvLovatKilled")
		AIparts:RemovePeriodic("003b. Lord Lovat Dead")
	end
end

function func_003c__Lord_Lovat_Dead()
	if IsEventPresent("EvLovatKilled") then
		mission.OutScreenMessage(100100, 10, "0xFFFF0000")
		TransferUnits("SpecialService", 0, "Lovatmen", 0)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 3600*10, function()  TransferUnits("Lovatmen", 0, "SpecialService", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 3601*10, function()  mission.OutScreenMessage(100101, 5, "0xFF00CC00") end)
		AIparts:RemovePeriodic("003c. Lord Lovat Dead")
	end
end

function func_004a__Capt__Kieffer_Arrived()
	if IsEventPresent("EvKiefferLanded") then
		msd_vars.varKieffer_ID = Spawn({desc = "Mods/Sword Beach/french_airborne_officer_Kieffer.dsc", position = {-95, 0, 656}, player = "Player"})
		LogVariable("varKieffer_ID = ", msd_vars.varKieffer_ID)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 3*10, function()  SetEvent("EvKiefferArrived") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  mission.OutScreenMessage(100098, 5, "0xFF00CC00") end)
		AIparts:RemovePeriodic("004a. Capt. Kieffer Arrived")
	end
end

function func_004b__Capt__Kieffer_Dead()
	if IsEventPresent("EvKiefferArrived") then
		dofile("Missions/Single/Sword Beach/para2.lua")
		msd_vars.varKiefferAlive = para.IsUnitDead(msd_vars.varKieffer_ID, "Player")
		LogVariable("varKiefferAlive = ", msd_vars.varKiefferAlive)
	end
	if IsEventPresent("EvKiefferArrived") and not msd_vars.varKiefferAlive then
		log("KiefferDead")
		SetEvent("EvKiefferKilled")
		AIparts:RemovePeriodic("004b. Capt. Kieffer Dead")
	end
end

function func_004c__Capt__Kieffer_Dead()
	if IsEventPresent("EvKiefferKilled") then
		mission.OutScreenMessage(100099, 10, "0xFFFF0000")
		TransferUnits("French", 0, "Kieffermen", 0)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 3600*10, function()  TransferUnits("Kieffermen", 0, "French", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 3601*10, function()  mission.OutScreenMessage(100102, 5, "0xFF00CC00") end)
		AIparts:RemovePeriodic("004c. Capt. Kieffer Dead")
	end
end

function func_005a__6th_Airborne_Paradrop_LZV()
	do
		 dofile("Missions/Single/Sword Beach/para.lua") 
		para.ParaPlane("Player", "Waypoint_V", "N", "W", 5, 0, "LZV")
		para.ParaPlane("Player", "Waypoint_V", "N", "W", 5, 0, "LZV")
		para.ParaPlane("Player", "Waypoint_V", "N", "W", 5, 0, "LZV")
	end
end

function func_005a__6th_Airborne_Paradrop_LZW()
	do
		 dofile("Missions/Single/Sword Beach/para.lua") 
		para.ParaPlane("Player", "Waypoint_W", "N", "W", 5, 0, "LZW")
		para.ParaPlane("Player", "Waypoint_W", "N", "W", 5, 0, "LZW")
	end
end

function func_099b__Navalstrike_at_60min()
	if GetGameTime() > 3625 then
		Bombardment("Navalstrike1", 75, 8, 6, 50)
		Bombardment("Navalstrike2", 75, 8, 6, 100)
		Bombardment("Navalstrike3", 75, 8, 6, 150)
		Bombardment("Navalstrike4", 75, 8, 6, 200)
		Bombardment("Navalstrike4", 75, 8, 6, 250)
		AIparts:RemovePeriodic("099b. Navalstrike at 60min")
	end
end

function func_021__Lebisey_Forest_Cleared()
	if NumPlayerUnitsInZone("Enemy", "LebiseyForest") < 1 and IsObjectiveActive("LebiseyForest") then
		SetObjectiveComplete("LebiseyForest", "Player")
		mission.OutScreenMessage(100105, 10, "0xFF00CC00")
		AIparts:RemovePeriodic("021. Lebisey Forest Cleared")
	end
end

