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

function PostCreate()
	mission_lua.BasicMissionInitialize()
	AIparts:AddPeriodic("0", 10, func_0, 0 + RandomHalf(10))
	AIparts:AddPeriodic("1", 10, func_1, 0 + RandomHalf(10))
	AIparts:AddPeriodic("2", 10, func_2, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Player vor Kreuzung", 10, func_Player_vor_Kreuzung, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Konvoi kommt", 10, func_Konvoi_kommt, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Konvoi Kreuzung verloren", 10, func_Konvoi_Kreuzung_verloren, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Konvoi sicher", 10, func_Konvoi_sicher, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Transporter bereit", 10, func_Transporter_bereit, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Spieler verliert", 10, func_Spieler_verliert, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Hinrichtung", 10, func_Hinrichtung, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Befehlshaber erreicht", 10, func_Befehlshaber_erreicht, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Konvoi Stellung 1", 10, func_Konvoi_Stellung_1, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Konvoi Stellung 2", 10, func_Konvoi_Stellung_2, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Konvoi Stellung 3", 10, func_Konvoi_Stellung_3, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Spieler vor Schmitt", 10, func_Spieler_vor_Schmitt, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Aufgabe Verteidigung", 10, func_Aufgabe_Verteidigung, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Spieler verloren", 10, func_Spieler_verloren, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Verteidigung aufstellen", 10, func_Verteidigung_aufstellen, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Ausloeser Sturm Wald 1,2,3", 10, func_Ausloeser_Sturm_Wald_1_2_3, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm auf Wald 1", 10, func_Sturm_auf_Wald_1, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm auf Wald 2", 10, func_Sturm_auf_Wald_2, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm auf Wald 3", 10, func_Sturm_auf_Wald_3, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm Wald Welle1 beendet", 10, func_Sturm_Wald_Welle1_beendet, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Ausloeser Sturm Huegel 1,2", 10, func_Ausloeser_Sturm_Huegel_1_2, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm auf Huegel 1", 10, func_Sturm_auf_Huegel_1, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm auf Huegel 2", 10, func_Sturm_auf_Huegel_2, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Auslöser Sturm Huegel2_2", 10, func_Ausl_ser_Sturm_Huegel2_2, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm auf Huegel 2_2", 10, func_Sturm_auf_Huegel_2_2, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Air Strike Bunker SSW", 10, func_Air_Strike_Bunker_SSW, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm Huegel Welle1 beendet", 10, func_Sturm_Huegel_Welle1_beendet, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Ausloeser Sturm Wald 4,5,6", 10, func_Ausloeser_Sturm_Wald_4_5_6, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Ausloeser Sturm Wald 7", 10, func_Ausloeser_Sturm_Wald_7, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm auf Wald 4", 10, func_Sturm_auf_Wald_4, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm auf Wald 5", 10, func_Sturm_auf_Wald_5, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm auf Wald 6", 10, func_Sturm_auf_Wald_6, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm auf Wald 7", 10, func_Sturm_auf_Wald_7, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm auf Wald 8", 10, func_Sturm_auf_Wald_8, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Air Strike Bunker Mitte", 10, func_Air_Strike_Bunker_Mitte, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm Wald Welle 2 beendet", 10, func_Sturm_Wald_Welle_2_beendet, 0 + RandomHalf(10))
	AIparts:AddPeriodic("WaldWelle2Exit", 10, func_WaldWelle2Exit, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Ausloeser Sturm Vossenack", 10, func_Ausloeser_Sturm_Vossenack, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm auf Vossenack", 10, func_Sturm_auf_Vossenack, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm Vossenack beendet", 10, func_Sturm_Vossenack_beendet, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm Vossenack Abbruch", 10, func_Sturm_Vossenack_Abbruch, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Ausloeser Sturm Schmidt", 10, func_Ausloeser_Sturm_Schmidt, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm auf Schmidt", 10, func_Sturm_auf_Schmidt, 0 + RandomHalf(10))
	AIparts:AddPeriodic("BomberAttackSchmidt", 10, func_BomberAttackSchmidt, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm Schmidt beendet", 10, func_Sturm_Schmidt_beendet, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sturm Schmidt Abbruch", 10, func_Sturm_Schmidt_Abbruch, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Abfrage Verteidigung", 10, func_Abfrage_Verteidigung, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Countdown Panzerverstaerkung", 10, func_Countdown_Panzerverstaerkung, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Start Countdown", 10, func_Start_Countdown, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Verstaerkung Gegenschlag1", 10, func_Verstaerkung_Gegenschlag1, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Verstaerkung Gegenschlag2", 10, func_Verstaerkung_Gegenschlag2, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Verstaerkung Gegenschlag3", 10, func_Verstaerkung_Gegenschlag3, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Verstaerkung Gegenschlag4", 10, func_Verstaerkung_Gegenschlag4, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Auftrag_Gegenschlag1", 10, func_Auftrag_Gegenschlag1, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Auftrag_Gegenschlag2", 10, func_Auftrag_Gegenschlag2, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Auftrag_Gegenschlag3", 10, func_Auftrag_Gegenschlag3, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Auftrag_Gegenschlag4", 10, func_Auftrag_Gegenschlag4, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Auftrag_Gegenschlag5", 10, func_Auftrag_Gegenschlag5, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Player erobert Vossenack", 10, func_Player_erobert_Vossenack, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Player erobert Schmidt  ", 10, func_Player_erobert_Schmidt__, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Ausloeser Sieg", 10, func_Ausloeser_Sieg, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sieg", 10, func_Sieg, 0 + RandomHalf(10))
	AIparts:AddPeriodic("FliegerAttack1", 10, func_FliegerAttack1, 0 + RandomHalf(10))
	AIparts:AddPeriodic("FliegerAttack2", 10, func_FliegerAttack2, 0 + RandomHalf(10))
	AIparts:AddPeriodic("FliegerAttack3", 10, func_FliegerAttack3, 0 + RandomHalf(10))
	AIparts:AddPeriodic("FliegerAttack4", 10, func_FliegerAttack4, 0 + RandomHalf(10))
	AIparts:AddPeriodic("FliegerAttack5", 10, func_FliegerAttack5, 0 + RandomHalf(10))
	AIparts:AddPeriodic("FliegerAttack6", 10, func_FliegerAttack6, 0 + RandomHalf(10))
	AIparts:AddPeriodic("FliegerAttack7", 10, func_FliegerAttack7, 0 + RandomHalf(10))
	AIparts:AddPeriodic("FliegerAttack8", 10, func_FliegerAttack8, 0 + RandomHalf(10))
	AIparts:AddPeriodic("FliegerAttack9", 10, func_FliegerAttack9, 0 + RandomHalf(10))
	AIparts:AddPeriodic("AriAttack1", 10, func_AriAttack1, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Ende", 10, func_Ende, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Countdown1", 10, func_Countdown1, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Countdown2", 10, func_Countdown2, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Countdown3", 10, func_Countdown3, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Countdown4", 10, func_Countdown4, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Countdown5", 10, func_Countdown5, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Countdown6", 10, func_Countdown6, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Countdown7", 10, func_Countdown7, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Countdown8", 10, func_Countdown8, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Countdown9", 10, func_Countdown9, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Gegenschlag_Wald_West", 10, func_Gegenschlag_Wald_West, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Spieler Wald West vor Auftrag", 10, func_Spieler_Wald_West_vor_Auftrag, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Uebergabe Artillerie", 10, func_Uebergabe_Artillerie, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Hinweis Artillerie", 10, func_Hinweis_Artillerie, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Feind in Vossenack", 10, func_Feind_in_Vossenack, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Feind in Schmidt", 10, func_Feind_in_Schmidt, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Infanterie Verstaerkung Gegenschlag", 10, func_Infanterie_Verstaerkung_Gegenschlag, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Feind in Wald1", 10, func_Feind_in_Wald1, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Feind in Wald2", 10, func_Feind_in_Wald2, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Feind in Wald 3", 10, func_Feind_in_Wald_3, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Feind in Huegel1", 10, func_Feind_in_Huegel1, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Feind in Huegel2", 10, func_Feind_in_Huegel2, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Feind in Wald", 10, func_Feind_in_Wald, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Spawn Final Attack1", 10, func_Spawn_Final_Attack1, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Final Attack2", 10, func_Final_Attack2, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Final Attack3", 10, func_Final_Attack3, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Final Attack4", 10, func_Final_Attack4, 0 + RandomHalf(10))
	AIparts:AddPeriodic("cheat", 100, func_cheat, 100 + RandomHalf(100))
	AIparts:AddPeriodic("Fallis", 10, func_Fallis, 0 + RandomHalf(10))
	AIparts:AddPeriodic("Sound", 20000, func_Sound, 2000 + RandomHalf(100))
	msd_vars = {
		AirStrikeSSW = 0,
		cheat = true,
		CountdownPanzer = 0,
		CounterPanzer = 0,
		Gegenschlag2 = 0,
		Gegenschlag3 = 0,
		Gegenschlag4 = 0,
		Hinrichtung = 0,
		Huegel_Counter = 0,
		Huegel1Enemy = 0,
		Huegel1Timer = 1,
		Huegel2Enemy = 0,
		Huegel2Timer = 1,
		Huegel2Timer2 = 1,
		PlayeranKreuzung = 0,
		SchmidtCounter = 0,
		SchmidtEnemy = 0,
		SchmidtTimeout = 0,
		Sieg = 0,
		Spiel_aktiv = 0,
		Spieler_verliert = 0,
		StrumHuegel2_2 = 0,
		Sturm_Schmidt = 0,
		Sturm_Vossenack = 0,
		SturmHuegel1 = 0,
		SturmHuegel2 = 0,
		SturmHuegelWelle1 = 0,
		SturmWald1 = 0,
		SturmWald2 = 0,
		SturmWald3 = 0,
		SturmWald4 = 0,
		SturmWald5 = 0,
		SturmWald6 = 0,
		SturmWald7 = 0,
		SturmWaldWelle1 = 0,
		SturmWaldWelle2 = 0,
		Timer_Gegenschlag2 = 0,
		Timer_Gegenschlag3 = 0,
		Timer_Gegenschlag4 = 0,
		TimerCountdown = 1,
		TimerSchmidt = 1,
		TimerVossenack = 1,
		VerstaerkungGegenschlag = 0,
		Verteidigung = 0,
		VossenackCounter = 0,
		VossenackEnemy = 0,
		VossenackTimeout = 0,
		Wald1_Counter = 0,
		Wald1Enemy = 0,
		Wald1Timer = 1,
		Wald2Enemy = 0,
		Wald2Timer = 1,
		Wald3Enemy = 0,
		Wald3Timer = 1,
		Wald4Enemy = 0,
		Wald4Timer = 1,
		Wald5Enemy = 0,
		Wald5Timer = 1,
		Wald6Enemy = 0,
		Wald6Timer = 1,
		Wald7Enemy = 0,
		Wald7Timer = 1,
	}
end

function func_0()
	do
		mission.CameraAt({-224.174438, 19.735352, -267.456757}, 39.686260, -91.891014, 57.793297, 10.00)
		mission.CameraLock(true)
		mission.OutScreenMessage(100026, 20, "0xFFE0E0E0")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  mission.CameraAt({-453.561829, 19.433395, -408.230377}, 59.999992, -178.494141, 68.998367, 10.00) end)
		AIparts:RemovePeriodic("0")
		DisableObjective("Start")
	end
end

function func_1()
	do
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  RunSpawn("Player", {"Start_Player", }, "Spawn_00", "Spieler", "", true, true, {}, false, 10) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 25*10, function()  mission.CameraAt({-428.521729, 19.309811, -417.391327}, 30.000000, 90.000000, 95.655724, 10.00) end)
		AIparts:RemovePeriodic("1")
	end
end

function func_2()
	do
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  mission.CameraLock(false) end)
		AIparts:RemovePeriodic("2")
	end
end

function func_Player_vor_Kreuzung()
	if NumPlayerUnitsInZone("Player", "Vor_Kreuzung") > 0 then
		AcivateObjective("Kreuzung")
		mission.CameraAt({-237.323471, 21.146656, -320.447449}, 30.000000, 90.000000, 114.063675, 5.00)
		mission.OutScreenMessage(100000, 20, "0xFFE0E0E0")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  RunSpawn("Player", {"Start_Player", }, "Spawn_01", "", "", true, true, {}, false, 50) end)
		msd_vars.PlayeranKreuzung = 1
		ProceedObjective("Kreuzung", "Player")
		RunSpawn("Enemy", {"Kreuzung_Enemy_Infanterie", }, "Spawn_00", "Enemy_Kreuzung", "", true, true, {}, false, 50)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  RunSpawn("Enemy", {"Kreuzung_Enemy_Infanterie", }, "Spawn_00", "Enemy_Kreuzung", "", true, true, {{assault="Kreuzung", }, }, false, 50) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 200*10, function()  RunSpawn("Enemy", {"Kreuzung_Enemy_Infanterie", }, "Spawn_00", "Enemy_Kreuzung", "", true, true, {{assault="Kreuzung", }, }, false, 100) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 150*10, function()  MoveGroupToZone("Enemy_Kreuzung", "Kreuzung", true, false) end)
		msd_vars.Spiel_aktiv = 1
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 300*10, function()  MoveGroupToZone("Enemy_Kreuzung", "Kreuzung", true, false) end)
		AIparts:RemovePeriodic("Player vor Kreuzung")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 500*10, function()  MoveGroupToZone("Enemy_Kreuzung", "Kreuzung", true, false) end)
	end
end

function func_Konvoi_kommt()
	if IsObjectiveCompleted("Kreuzung", "Player") then
		RunSpawn("Friend", {"Konvoi", }, "Spawn_00", "Konvoi", "", true, true, {{dislocation="Konvoi Ende", }, {disappear=true, }, }, false, 0)
		AIparts:RemovePeriodic("Konvoi kommt")
		mission.OutScreenMessage(100002, 20, "0xFFE0E0E0")
		MoveGroupToZone("Enemy_Kreuzung", "Kreuzung", true, false)
	end
end

function func_Konvoi_Kreuzung_verloren()
	if NumGroupUnitsInZone("Konvoi", "Vor_Kreuzung") > 0 and NumPlayerUnitsInZone("Enemy", "Kreuzung") > 0 and msd_vars.Spieler_verliert == 0 then
		mission.OutScreenMessage(100003, 15, "0xFFE0E0E0")
		SetObjectiveTimeout("Kreuzung", 0)
		FailObjective("Kreuzung")
		msd_vars.Spieler_verliert = 1
		msd_vars.Hinrichtung = 1
		AIparts:RemovePeriodic("Konvoi Kreuzung verloren")
	end
end

function func_Konvoi_sicher()
	if NumGroupUnitsInZone("Konvoi", "Kreuzung") > 0 or NumGroupUnitsInZone("Konvoi", "Kreuzung1") > 0 then
		RunSpawn("Friend", {"Transporter", }, "Spawn_01", "Transport", "", true, true, {}, false, 5)
		AIparts:RemovePeriodic("Konvoi sicher")
		AcivateObjective("Befehlshaber")
	end
end

function func_Transporter_bereit()
	if NumGroupUnitsInZone("Transport", "Kreuzung1") > 0 and msd_vars.Spieler_verliert == 0 or NumGroupUnitsInZone("Transport", "Kreuzung") > 0 and msd_vars.Spieler_verliert == 0  then
		TransferUnits("Transport", 0, "Spieler", 0)
		mission.OutScreenMessage(100004, 20, "0xFFE0E0E0")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 100*10, function()  mission.OutScreenMessage(100006, 20, "0xFFE0E0E0") end)
		RunSpawn("Enemy", {"Kreuzung_Enemy_Infanterie", }, "Spawn_01", "Enemy_Kreuzung", "", true, true, {}, false, 50)
		MoveGroupToZone("Enemy_Kreuzung1", "Kreuzung", false, false)
		AIparts:RemovePeriodic("Transporter bereit")
	end
end

function func_Spieler_verliert()
	if msd_vars.Spiel_aktiv == 1 and NumPlayerUnits("Player") < 1 and not IsObjectiveCompleted("Befehlshaber", "Player") and msd_vars.Spieler_verliert == 0 then
		mission.OutScreenMessage(100005, 20, "0xFFE0E0E0")
		msd_vars.Hinrichtung = 1
		msd_vars.Spieler_verliert = 1
		AIparts:RemovePeriodic("Spieler verliert")
	end
end

function func_Hinrichtung()
	if msd_vars.Hinrichtung == 1 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  mission.CameraLock(true) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  mission.CameraAt({303.841217, 26.833395, -198.945190}, 59.999992, 139.691849, 31.032509, 0.00) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  TransferUnits("Schuetzen", 0, "Schuetzen1", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 20*10, function()  mission.OutScreenMessage(100007, 6, "0xFFE0E0E0") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 23*10, function()  TransferUnits("Verlierer", 0, "Verlierer1", 0) end)
		AIparts:RemovePeriodic("Hinrichtung")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  mission.CameraAt({306.587921, 26.531466, -193.881805}, 59.999996, 96.251915, 30.000002, 5.00) end)
	end
end

function func_Befehlshaber_erreicht()
	if NumPlayerUnitsInZone("Player", "Vor_Befehlshaber") > 0 and IsObjectiveCompleted("Kreuzung", "Player") then
		msd_vars.cheat = false
		SetObjectiveComplete("Befehlshaber", "Player")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 20*10, function()  mission.OutScreenMessage(100008, 20, "0xFFE0E0E0") end)
		TransferUnits("Friend_Start", 0, "Uebergabe_Spieler", 0)
		TransferUnits("Konvoi", 0, "Spieler", 0)
		Bombardment("Befehlshaber", 2, 5, 5, 55)
		mission.CameraAt({271.371277, 26.213903, -95.663132}, 60.000000, 69.345703, 32.362770, 2.00)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 25*10, function()  mission.CameraAt({271.371277, 26.213905, -95.663139}, 59.999996, 69.345703, 100.623215, 5.00) end)
		TransferUnits("Stellung1_Friend", 0, "Uebergabe_Spieler", 0)
		TransferUnits("Stellung1_Neutral", 0, "Uebergabe_Spieler", 0)
		TransferUnits("Stellung2_Friend", 0, "Uebergabe_Spieler", 0)
		TransferUnits("Stellung2_Neutral", 0, "Uebergabe_Spieler", 0)
		TransferUnits("Stellung3_Friend", 0, "Uebergabe_Spieler", 0)
		TransferUnits("Stellung3_Neutral", 0, "Uebergabe_Spieler", 0)
		TransferUnits("Schuetzen", 0, "Uebergabe_Spieler", 0)
		TransferUnits("Schuetzen1", 0, "Uebergabe_Spieler", 0)
		TransferUnits("Verlierer", 0, "Uebergabe_Spieler", 0)
		TransferUnits("Verlierer1", 0, "Uebergabe_Spieler", 0)
		TransferUnits("Lager_Nord1", 0, "Lager_Nord2", 0)
		mission.CameraLock(true)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 8*10, function()  MoveGroupTo("Sani1", {}, {"Befehlshaber", }, {}, true, true, "", false, 1) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  TransferUnits("Sani1", 0, "Uebergabe_Spieler", 0) end)
		AIparts:RemovePeriodic("Befehlshaber erreicht")
	end
end

function func_Konvoi_Stellung_1()
	if NumGroupUnitsInZone("Konvoi", "Stellung1") > 0 then
		TransferUnits("Stellung1_Neutral", 0, "Stellung1_Friend", 0)
		AIparts:RemovePeriodic("Konvoi Stellung 1")
	end
end

function func_Konvoi_Stellung_2()
	if NumGroupUnitsInZone("Konvoi", "Stellung2") > 0 then
		TransferUnits("Stellung2_Neutral", 0, "Stellung2_Friend", 0)
		AIparts:RemovePeriodic("Konvoi Stellung 2")
	end
end

function func_Konvoi_Stellung_3()
	if NumGroupUnitsInZone("Konvoi", "Stellung3") > 0 then
		TransferUnits("Stellung3_Neutral", 0, "Stellung3_Friend", 0)
		AIparts:RemovePeriodic("Konvoi Stellung 3")
	end
end

function func_Spieler_vor_Schmitt()
	if NumPlayerUnitsInZone("Player", "Vor_Schmidt") > 0 and IsObjectiveCompleted("Kreuzung", "Player") then
		TransferUnits("Neutral_Start", 0, "Friend_Start", 0)
		TransferUnits("Stellung1_Neutral", 0, "Stellung1_Friend", 0)
		TransferUnits("Stellung2_Neutral", 0, "Stellung2_Friend", 0)
		TransferUnits("Stellung3_Neutral", 0, "Stellung3_Friend", 0)
		TransferUnits("Befehlshaber_Neutral", 0, "Befehlshaber_Friend", 0)
		TransferUnits("Sani", 0, "Sani1", 0)
		AIparts:RemovePeriodic("Spieler vor Schmitt")
	end
end

function func_Aufgabe_Verteidigung()
	if IsObjectiveCompleted("Befehlshaber", "Player") then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 35*10, function()  mission.CameraAt({263.497864, 29.040123, -134.962341}, 53.006287, -174.662003, 130.717789, 5.00) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 40*10, function()  mission.OutScreenMessage(100013, 10, "0xFFE0E0E0") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 50*10, function()  mission.CameraAt({134.962341, 15.782298, 422.025116}, 53.006287, -174.662003, 130.697601, 5.00) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 55*10, function()  mission.OutScreenMessage(100014, 10, "0xFFE0E0E0") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 65*10, function()  mission.CameraAt({-117.824295, 23.563293, 143.531403}, 59.999992, 117.162323, 101.012444, 5.00) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 70*10, function()  mission.OutScreenMessage(100015, 10, "0xFFE0E0E0") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 80*10, function()  mission.CameraAt({-86.585258, 20.732883, -28.596008}, 59.999996, -145.766586, 70.848007, 10.00) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 85*10, function()  mission.OutScreenMessage(100016, 10, "0xFFE0E0E0") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 95*10, function()  mission.CameraAt({-53.556488, 20.755533, -14.995659}, 30.000000, 90.000000, 272.141815, 10.00) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 100*10, function()  mission.CameraLock(false) end)
		msd_vars.Verteidigung = 1
		AIparts:RemovePeriodic("Aufgabe Verteidigung")
	end
end

function func_Spieler_verloren()
	if msd_vars.Spieler_verliert == 1 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 40*10, function()  PlayerDefeat("Player") end)
	end
end

function func_Verteidigung_aufstellen()
	if msd_vars.Verteidigung == 1 then
		AcivateObjective("Vossenack")
		AcivateObjective("Schmidt")
		AIparts:RemovePeriodic("Verteidigung aufstellen")
	end
end

function func_Ausloeser_Sturm_Wald_1_2_3()
	if msd_vars.Verteidigung == 1 then
		AIparts:AddOneTime("TIMER_VAR_SturmWald1", 600*10, function() msd_vars.SturmWald1 = 1 end)
		AIparts:AddOneTime("TIMER_VAR_SturmWald2", 700*10, function() msd_vars.SturmWald2 = 1 end)
		AIparts:AddOneTime("TIMER_VAR_SturmWald3", 800*10, function() msd_vars.SturmWald3 = 1 end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 660*10, function()  SendPlane("Enemy", "Wald1", "strike_fighter", "W", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 760*10, function()  SendPlane("Enemy", "Wald2", "strike_fighter", "W", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 860*10, function()  SendPlane("Enemy", "Wald3", "strike_fighter", "W", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 300*10, function()  SendPlane("Player", "FliegerAttack5", "scout", "E", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 300*10, function()  SendPlane("Player", "FliegerAttack7", "scout", "E", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 300*10, function()  SendPlane("Player", "FliegerAttack9", "scout", "E", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 360*10, function()  mission.OutScreenMessage(100051, 20, "0xFFE0E0E0") end)
		AIparts:RemovePeriodic("Ausloeser Sturm Wald 1,2,3")
	end
end

function func_Sturm_auf_Wald_1()
	if NumGroupUnitsInZone("Wald1", "Wald1") > 20 then
		msd_vars.Wald1Enemy = 1
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "Wald1"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		AIparts:RemovePeriodic("Sturm auf Wald 1")
	end
	if msd_vars.SturmWald1 == 1 and msd_vars.Wald1Timer == 1 and msd_vars.Wald1Enemy == 0 then
		RunSpawn("Enemy", {"Wald1_Feind", }, "Spawn_03", "Wald1", "", true, true, {}, false, 50)
		MoveGroupToZone("Wald1", "Wald1", false, false)
		msd_vars.Wald1Timer = 0
		AIparts:AddOneTime("TIMER_VAR_Wald1Timer", 400*10, function() msd_vars.Wald1Timer = 1 end)
		msd_vars.Wald1_Counter = msd_vars.Wald1_Counter + 1
	end
end

function func_Sturm_auf_Wald_2()
	if NumGroupUnitsInZone("Wald2", "Wald2") > 20 then
		msd_vars.Wald2Enemy = 1
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "Wald2"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		AIparts:RemovePeriodic("Sturm auf Wald 2")
	end
	if msd_vars.SturmWald2 == 1 and msd_vars.Wald2Timer == 1 and msd_vars.Wald2Enemy == 0 then
		RunSpawn("Enemy", {"Wald2_Feind", }, "Spawn_04", "Wald2", "", true, true, {}, false, 50)
		MoveGroupToZone("Wald2", "Wald2", false, false)
		msd_vars.Wald2Timer = 0
		AIparts:AddOneTime("TIMER_VAR_Wald2Timer", 400*10, function() msd_vars.Wald2Timer = 1 end)
		msd_vars.Wald1_Counter = msd_vars.Wald1_Counter + 1
	end
end

function func_Sturm_auf_Wald_3()
	if NumGroupUnitsInZone("Wald3", "Wald3") > 20 then
		msd_vars.Wald3Enemy = 1
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "Wald3"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		AIparts:RemovePeriodic("Sturm auf Wald 3")
	end
	if msd_vars.SturmWald3 == 1 and msd_vars.Wald3Timer == 1 and msd_vars.Wald3Enemy == 0 then
		RunSpawn("Enemy", {"Wald3_Feind", }, "Spawn_05", "Wald3", "", true, true, {}, false, 50)
		MoveGroupToZone("Wald3", "Wald3", false, false)
		msd_vars.Wald3Timer = 0
		AIparts:AddOneTime("TIMER_VAR_Wald3Timer", 400*10, function() msd_vars.Wald3Timer = 1 end)
		msd_vars.Wald1_Counter = msd_vars.Wald1_Counter + 1
	end
end

function func_Sturm_Wald_Welle1_beendet()
	if msd_vars.Wald1Enemy == 1 and msd_vars.Wald2Enemy == 1 and msd_vars.Wald3Enemy == 1 then
		msd_vars.SturmWaldWelle1 = 1
		AIparts:RemovePeriodic("Sturm Wald Welle1 beendet")
	end
	if msd_vars.SturmHuegelWelle1 == 1 then
		msd_vars.SturmWaldWelle1 = 1
		AIparts:RemovePeriodic("Sturm Wald Welle1 beendet")
	end
end

function func_Ausloeser_Sturm_Huegel_1_2()
	if msd_vars.Wald1Enemy == 1 or msd_vars.Wald2Enemy == 1 or msd_vars.Wald3Enemy == 1 or msd_vars.Wald1_Counter > 10 then
		AIparts:AddOneTime("TIMER_VAR_SturmHuegel1", 10*10, function() msd_vars.SturmHuegel1 = 1 end)
		AIparts:AddOneTime("TIMER_VAR_SturmHuegel2", 100*10, function() msd_vars.SturmHuegel2 = 1 end)
		SendPlane("Enemy", "Huegel2", "strike_fighter", "W", 15, -1, "")
		SendPlane("Enemy", "Huegel1", "strike_fighter", "W", 15, -1, "")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 1*10, function()  RunSpawn("Player", {"Verteidigung_Player_1", }, "Spawn_02", "", "", true, true, {}, false, 40) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 2*10, function()  RunSpawn("Player", {"Verteidigung_Player_1", }, "Spawn_03", "", "", true, true, {}, false, 40) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 3*10, function()  RunSpawn("Player", {"Verteidigung_Player_1", }, "Spawn_04", "", "", true, true, {}, false, 40) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 4*10, function()  RunSpawn("Player", {"Verteidigung_Player_1", }, "Spawn_05", "", "", true, true, {}, false, 40) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  RunSpawn("Player", {"Verteidigung_Player_1", }, "Spawn_07", "", "", true, true, {}, false, 40) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 6*10, function()  RunSpawn("Player", {"Verteidigung_Player_1", }, "Spawn_06", "", "", true, true, {}, false, 40) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  Bombardment("Bunker_Kreuzung", 10, 8, 6, 30) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  mission.OutScreenMessage(100024, 20, "0xFFE0E0E0") end)
		AIparts:RemovePeriodic("Ausloeser Sturm Huegel 1,2")
	end
end

function func_Sturm_auf_Huegel_1()
	if NumGroupUnitsInZone("Huegel1", "Huegel1") > 25 then
		msd_vars.Huegel1Enemy = 1
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "Huegel1"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		AIparts:RemovePeriodic("Sturm auf Huegel 1")
		FlushSpawn(2)
	end
	if msd_vars.SturmHuegel1 == 1 and msd_vars.Huegel1Timer == 1 and msd_vars.Huegel1Enemy == 0 then
		RunSpawn("Enemy", {"Huegel1_Feind", }, "Spawn_06", "Huegel1", "", true, true, {}, false, 50)
		MoveGroupToZone("Huegel1", "Huegel1", false, false)
		msd_vars.Huegel1Timer = 0
		AIparts:AddOneTime("TIMER_VAR_Huegel1Timer", 150*10, function() msd_vars.Huegel1Timer = 1 end)
		msd_vars.Huegel_Counter = msd_vars.Huegel_Counter + 1
	end
end

function func_Sturm_auf_Huegel_2()
	if NumGroupUnitsInZone("Huegel2", "Huegel2") > 25 then
		msd_vars.Huegel2Enemy = 1
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "Huegel2"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		AIparts:RemovePeriodic("Sturm auf Huegel 2")
		FlushSpawn(2)
	end
	if msd_vars.SturmHuegel2 == 1 and msd_vars.Huegel2Timer == 1 and msd_vars.Huegel2Enemy == 0 then
		RunSpawn("Enemy", {"Huegel2_Feind1", }, "Spawn_06", "Huegel2", "", true, true, {}, false, 50)
		MoveGroupToZone("Huegel2", "Huegel2", false, false)
		msd_vars.Huegel2Timer = 0
		AIparts:AddOneTime("TIMER_VAR_Huegel2Timer", 300*10, function() msd_vars.Huegel2Timer = 1 end)
		msd_vars.Huegel_Counter = msd_vars.Huegel_Counter + 1
	end
end

function func_Ausl_ser_Sturm_Huegel2_2()
	if msd_vars.Huegel_Counter >= 6 then
		msd_vars.StrumHuegel2_2 = 1
		mission.OutScreenMessage(100052, 20, "0xFFE0E0E0")
		AIparts:RemovePeriodic("Auslöser Sturm Huegel2_2")
	end
end

function func_Sturm_auf_Huegel_2_2()
	if NumGroupUnitsInZone("Huegel2", "Huegel2") > 25 then
		msd_vars.Huegel2Enemy = 1
		AIparts:RemovePeriodic("Sturm auf Huegel 2_2")
		FlushSpawn(2)
	end
	if msd_vars.StrumHuegel2_2 == 1 and msd_vars.Huegel2Timer2 == 1 and msd_vars.Huegel2Enemy == 0 and msd_vars.SturmHuegelWelle1 == 0 then
		RunSpawn("Enemy", {"Huegel2_Feind2", }, "Spawn_07", "Huegel2", "", true, true, {}, false, 50)
		MoveGroupToZone("Huegel2", "Huegel2", false, false)
		msd_vars.Huegel2Timer2 = 0
		AIparts:AddOneTime("TIMER_VAR_Huegel2Timer2", 300*10, function() msd_vars.Huegel2Timer2 = 1 end)
	end
end

function func_Air_Strike_Bunker_SSW()
	if NumGroupUnitsInZone("Huegel2", "BunkerSSW") > 3 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  SendPlane("Enemy", "Bunker SSW", "fighter", "NW", 1, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 70*10, function()  SendPlane("Enemy", "Bunker SSW", "strike_fighter", "NW", 1, -1, "") end)
		AIparts:RemovePeriodic("Air Strike Bunker SSW")
	end
end

function func_Sturm_Huegel_Welle1_beendet()
	if msd_vars.Huegel1Enemy == 1 and msd_vars.Huegel2Enemy == 1 then
		msd_vars.SturmHuegelWelle1 = 1
		MoveGroupToZone("Huegel1", "Huegel1", true, false)
		MoveGroupToZone("Huegel2", "Huegel2", true, false)
		AIparts:RemovePeriodic("Sturm Huegel Welle1 beendet")
	end
end

function func_Ausloeser_Sturm_Wald_4_5_6()
	if msd_vars.SturmHuegelWelle1 == 1 then
		msd_vars.Wald1Enemy = 1
		msd_vars.Wald2Enemy = 1
		msd_vars.Wald3Enemy = 1
		AIparts:AddOneTime("TIMER_VAR_SturmWald4", 50*10, function() msd_vars.SturmWald4 = 1 end)
		AIparts:AddOneTime("TIMER_VAR_SturmWald5", 100*10, function() msd_vars.SturmWald5 = 1 end)
		AIparts:AddOneTime("TIMER_VAR_SturmWald6", 150*10, function() msd_vars.SturmWald6 = 1 end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  TransferUnits("Huegel1", 13, "Exit", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  TransferUnits("Huegel2", 13, "Exit", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  TransferUnits("Wald1", 13, "Exit", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  TransferUnits("Wald2", 13, "Exit", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  TransferUnits("Wald3", 13, "Exit", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 120*10, function()  MoveGroupToZone("Exit", "Exit", true, false) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 300*10, function()  DisappearUnitsInGroup("Exit") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 320*10, function()  RunSpawn("Player", {"Verteidigung_Player_2", }, "Spawn_09", "", "", true, true, {}, false, 200) end)
		AIparts:RemovePeriodic("Ausloeser Sturm Wald 4,5,6")
	end
end

function func_Ausloeser_Sturm_Wald_7()
	if msd_vars.Huegel1Enemy == 1 then
		msd_vars.SturmWald7 = 1
		AIparts:RemovePeriodic("Ausloeser Sturm Wald 7")
	end
end

function func_Sturm_auf_Wald_4()
	if NumGroupUnitsInZone("Wald4", "Wald4") > 20 then
		msd_vars.Wald4Enemy = 1
		MoveGroupToZone("Wald4", "Wald4", true, false)
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "Wald4"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		AIparts:RemovePeriodic("Sturm auf Wald 4")
	end
	if msd_vars.SturmWald4 == 1 and msd_vars.Wald4Timer == 1 and msd_vars.Wald4Enemy == 0 then
		RunSpawn("Enemy", {"Wald4_Feind", }, "Spawn_03", "Wald4", "Wald4", true, true, {}, false, 50)
		MoveGroupToZone("Wald4", "Wald4", false, false)
		msd_vars.Wald4Timer = 0
		AIparts:AddOneTime("TIMER_VAR_Wald4Timer", 500*10, function() msd_vars.Wald4Timer = 1 end)
	end
end

function func_Sturm_auf_Wald_5()
	if NumGroupUnitsInZone("Wald5", "Wald5") > 20 then
		msd_vars.Wald5Enemy = 1
		MoveGroupToZone("Wald5", "Wald5", true, false)
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "Wald5"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		AIparts:RemovePeriodic("Sturm auf Wald 5")
	end
	if msd_vars.SturmWald5 == 1 and msd_vars.Wald5Timer == 1 and msd_vars.Wald5Enemy == 0 then
		RunSpawn("Enemy", {"Wald5_Feind", }, "Spawn_04", "Wald5", "Wald5", true, true, {}, false, 50)
		MoveGroupToZone("Wald5", "Wald5", false, false)
		msd_vars.Wald5Timer = 0
		AIparts:AddOneTime("TIMER_VAR_Wald5Timer", 400*10, function() msd_vars.Wald5Timer = 1 end)
	end
end

function func_Sturm_auf_Wald_6()
	if NumGroupUnitsInZone("Wald6", "Wald6") > 20 then
		msd_vars.Wald6Enemy = 1
		MoveGroupToZone("Wald6", "Wald6", true, false)
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "Wald6"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		AIparts:RemovePeriodic("Sturm auf Wald 6")
	end
	if msd_vars.SturmWald6 == 1 and msd_vars.Wald6Timer == 1 and msd_vars.Wald6Enemy == 0 then
		RunSpawn("Enemy", {"Wald6_Feind", }, "Spawn_05", "Wald6", "Wald6", true, true, {}, false, 50)
		MoveGroupToZone("Wald6", "Wald6", false, false)
		msd_vars.Wald6Timer = 0
		AIparts:AddOneTime("TIMER_VAR_Wald6Timer", 450*10, function() msd_vars.Wald6Timer = 1 end)
	end
end

function func_Sturm_auf_Wald_7()
	if NumGroupUnitsInZone("Wald7", "Wald7") > 20 then
		msd_vars.Wald7Enemy = 1
		MoveGroupToZone("Wald7", "Wald7", true, false)
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "Wald7"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		AIparts:RemovePeriodic("Sturm auf Wald 7")
	end
	if msd_vars.SturmWald7 == 1 and msd_vars.Wald7Timer == 1 and msd_vars.Wald7Enemy == 0 then
		RunSpawn("Enemy", {"Wald7_Feind", }, "Spawn_01", "Wald7", "Wald7", true, true, {}, false, 50)
		MoveGroupToZone("Wald7", "Wald7", false, false)
		msd_vars.Wald7Timer = 0
		AIparts:AddOneTime("TIMER_VAR_Wald7Timer", 300*10, function() msd_vars.Wald7Timer = 1 end)
	end
end

function func_Sturm_auf_Wald_8()
	if msd_vars.SturmWaldWelle2 == 1 then
		RunSpawn("Enemy", {"Wald8_Feind", }, "Spawn_01", "Wald8", "Wald8", true, true, {}, false, 30)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 100*10, function()  MoveGroupToZone("Wald8", "Wald8", false, false) end)
		AIparts:RemovePeriodic("Sturm auf Wald 8")
	end
end

function func_Air_Strike_Bunker_Mitte()
	if NumPlayerUnitsInZone("Enemy", "Stellung2") > 1 then
		SendPlane("Enemy", "Bunker Mitte", "fighter", "SW", 1, -1, "")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  SendPlane("Enemy", "Bunker Mitte", "strike_fighter", "SW", 1, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 20*10, function()  SendPlane("Enemy", "FliegerAttack1", "fighter", "NW", 1, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  SendPlane("Enemy", "FliegerAttack1", "strike_fighter", "NW", 1, -1, "") end)
		AIparts:RemovePeriodic("Air Strike Bunker Mitte")
	end
end

function func_Sturm_Wald_Welle_2_beendet()
	if msd_vars.Wald4Enemy == 1 and msd_vars.Wald5Enemy == 1 and msd_vars.Wald6Enemy == 1 and msd_vars.Wald7Enemy == 1 then
		msd_vars.SturmWaldWelle2 = 1
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  UnloadTransports("Wald4") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  UnloadTransports("Wald5") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  UnloadTransports("Wald6") end)
		AIparts:RemovePeriodic("Sturm Wald Welle 2 beendet")
	end
end

function func_WaldWelle2Exit()
	if msd_vars.SturmWaldWelle2 == 1 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  TransferUnits("Wald4", 6, "Exit", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  TransferUnits("Wald5", 6, "Exit", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  TransferUnits("Wald6", 6, "Exit", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  TransferUnits("Wald7", 6, "Exit", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  TransferUnits("Wald4", 16, "Exit", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  TransferUnits("Wald5", 16, "Exit", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  TransferUnits("Wald6", 16, "Exit", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  TransferUnits("Wald7", 16, "Exit", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  MoveGroupToZone("Exit", "Exit", false, false) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 200*10, function()  DisappearUnitsInGroup("Exit") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  TransferUnits("Wald4", 14, "Exit", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  TransferUnits("Wald5", 14, "Exit", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  TransferUnits("Wald6", 14, "Exit", 0) end)
		AIparts:RemovePeriodic("WaldWelle2Exit")
	end
end

function func_Ausloeser_Sturm_Vossenack()
	if msd_vars.SturmWaldWelle2 == 1 then
		AIparts:AddOneTime("TIMER_VAR_Sturm_Vossenack", 100*10, function() msd_vars.Sturm_Vossenack = 1 end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  SendPlane("Enemy", "Vossenack", "scout", "SW", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 200*10, function()  CreateFXObject("smoke/chimney.dsc", "Wald4", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 200*10, function()  CreateFXObject("smoke/chimney.dsc", "Wald5", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 200*10, function()  CreateFXObject("smoke/chimney.dsc", "Wald6", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 200*10, function()  CreateFXObject("smoke/chimney.dsc", "Wald7", 0) end)
		AIparts:RemovePeriodic("Ausloeser Sturm Vossenack")
	end
end

function func_Sturm_auf_Vossenack()
	if NumGroupUnitsInZone("Sturm_Vossenack", "Vossenack") > 20 or NumGroupUnitsInZone("Sturm_Vossenack", "Vossenack") > 10 and NumPlayerUnitsInZone("Player", "Vossenack") <= 5 then
		msd_vars.VossenackEnemy = 1
		MoveGroupToZone("Sturm_Vossenack", "Vossenack", true, false)
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "Vossenack"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		TransferUnits("Sturm_Vossenack", 16, "Sturm_Schmidt", 8)
		AIparts:RemovePeriodic("Sturm auf Vossenack")
	end
	if msd_vars.Sturm_Vossenack == 1 and msd_vars.TimerVossenack == 1 and msd_vars.VossenackEnemy == 0 and msd_vars.VossenackTimeout == 0 then
		RunSpawn("Enemy", {"Strum_Vossenack_Enemy", }, "Spawn_02", "Sturm_Vossenack", "", true, true, {}, false, 200)
		msd_vars.TimerVossenack = 0
		AIparts:AddOneTime("TIMER_VAR_TimerVossenack", 300*10, function() msd_vars.TimerVossenack = 1 end)
		MoveGroupToZone("Sturm_Vossenack", "Vossenack", true, false)
		msd_vars.VossenackCounter = msd_vars.VossenackCounter + 1
	end
	if msd_vars.VossenackTimeout == "1" then
		AIparts:RemovePeriodic("Sturm auf Vossenack")
	end
end

function func_Sturm_Vossenack_beendet()
	if msd_vars.VossenackEnemy == 1 then
		FailObjective("Vossenack")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  UnloadTransports("Sturm_Vossenack") end)
		MoveGroupToZone("Sturm_Vossenack", "Vossenack", true, false)
		mission.OutScreenMessage(100022, 20, "0xFFE0E0E0")
		AIparts:RemovePeriodic("Sturm Vossenack beendet")
	end
end

function func_Sturm_Vossenack_Abbruch()
	if msd_vars.VossenackCounter > 7 then
		msd_vars.VossenackTimeout = 1
		AIparts:RemovePeriodic("Sturm Vossenack Abbruch")
	end
end

function func_Ausloeser_Sturm_Schmidt()
	if msd_vars.SturmWaldWelle2 == 1 then
		AIparts:AddOneTime("TIMER_VAR_Sturm_Schmidt", 200*10, function() msd_vars.Sturm_Schmidt = 1 end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 180*10, function()  SendPlane("Enemy", "Befehlshaber", "scout", "W", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 200*10, function()  TransferUnits("Wald7", 16, "Sturm_Schmidt", 0) end)
		AIparts:RemovePeriodic("Ausloeser Sturm Schmidt")
	end
end

function func_Sturm_auf_Schmidt()
	if NumGroupUnitsInZone("Sturm_Schmidt", "Schmidt") > 45 or NumGroupUnitsInZone("Sturm_Schmidt", "Schmidt") > 25 and NumPlayerUnitsInZone("Player", "Schmidt") <= 5 then
		msd_vars.SchmidtEnemy = 1
		MoveGroupToZone("Sturm_Schmidt", "Schmidt", true, false)
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "Befehlshaber"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		TransferUnits("Sturm_Schmidt", 16, "Sturm_Vossenack", 8)
		AIparts:RemovePeriodic("Sturm auf Schmidt")
	end
	if msd_vars.Sturm_Schmidt == 1 and msd_vars.TimerSchmidt == 1 and msd_vars.SchmidtEnemy == 0 and msd_vars.SchmidtTimeout == 0 then
		RunSpawn("Enemy", {"Strum_Schmidt_Enemy", }, "Spawn_08", "Sturm_Schmidt", "", true, true, {}, false, 200)
		msd_vars.TimerSchmidt = 0
		AIparts:AddOneTime("TIMER_VAR_TimerSchmidt", 300*10, function() msd_vars.TimerSchmidt = 1 end)
		MoveGroupToZone("Sturm_Schmidt", "Schmidt", true, false)
		msd_vars.SchmidtCounter = msd_vars.SchmidtCounter + 1
	end
	if msd_vars.SchmidtTimeout == 1 then
		AIparts:RemovePeriodic("Sturm auf Schmidt")
	end
end

function func_BomberAttackSchmidt()
	if NumGroupUnitsInZone("Sturm_Schmidt", "Schmidt") > 1 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  SendPlane("Enemy", "BunkerWestSchmidt", "bomber", "W", 5, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 100*10, function()  SendPlane("Enemy", "BunkerWestSchmidt", "strike_fighter", "W", 5, -1, "") end)
		AIparts:RemovePeriodic("BomberAttackSchmidt")
	end
end

function func_Sturm_Schmidt_beendet()
	if msd_vars.SchmidtEnemy == 1 then
		FailObjective("Schmidt")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  UnloadTransports("Sturm_Schmidt") end)
		MoveGroupToZone("Sturm_Schmidt", "Schmidt", true, false)
		mission.OutScreenMessage(100023, 20, "0xFFE0E0E0")
		AIparts:RemovePeriodic("Sturm Schmidt beendet")
	end
end

function func_Sturm_Schmidt_Abbruch()
	if msd_vars.SchmidtCounter > 8 then
		msd_vars.SchmidtTimeout = 1
		AIparts:RemovePeriodic("Sturm Schmidt Abbruch")
	end
end

function func_Abfrage_Verteidigung()
	if msd_vars.SchmidtTimeout == 1 and msd_vars.VossenackTimeout == 1 then
		ProceedObjective("Schmidt", "Player")
		ProceedObjective("Vossenack", "Player")
		AIparts:RemovePeriodic("Abfrage Verteidigung")
	end
	if msd_vars.SchmidtTimeout == 1 and IsObjectiveFailed("Vossenack", "Player") then
		ProceedObjective("Schmidt", "Player")
		AIparts:RemovePeriodic("Abfrage Verteidigung")
	end
	if msd_vars.VossenackTimeout == 1 and IsObjectiveFailed("Schmidt", "Player") then
		ProceedObjective("Vossenack", "Player")
		AIparts:RemovePeriodic("Abfrage Verteidigung")
	end
	if IsObjectiveFailed("Vossenack", "Player") and IsObjectiveFailed("Schmidt", "Player") then
		AIparts:RemovePeriodic("Abfrage Verteidigung")
	end
end

function func_Countdown_Panzerverstaerkung()
	if msd_vars.SturmWaldWelle2 == 1 then
		msd_vars.CountdownPanzer = 1
		AIparts:RemovePeriodic("Countdown Panzerverstaerkung")
	end
end

function func_Start_Countdown()
	if msd_vars.CountdownPanzer == 1 and msd_vars.TimerCountdown == 1 then
		msd_vars.CounterPanzer = msd_vars.CounterPanzer + 1
		msd_vars.TimerCountdown = 0
		AIparts:AddOneTime("TIMER_VAR_TimerCountdown", 300*10, function() msd_vars.TimerCountdown = 1 end)
	end
	if msd_vars.CounterPanzer > 9 then
		AIparts:RemovePeriodic("Start Countdown")
	end
end

function func_Verstaerkung_Gegenschlag1()
	if msd_vars.VerstaerkungGegenschlag == 1 then
		RunSpawn("Player", {"Gegenschlag1", }, "Spawn_11", "Gegenschlag1", "", true, true, {}, false, 30)
		RunSpawn("Player", {"Gegenschlag1", }, "Spawn_10", "Gegenschlag1", "", true, true, {}, false, 30)
		AIparts:AddOneTime("TIMER_VAR_Gegenschlag2", 300*10, function() msd_vars.Gegenschlag2 = 1 end)
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "FliegerAttack1"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "FliegerAttack2"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "FliegerAttack4"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "FliegerAttack5"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "FliegerAttack6"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "FliegerAttack7"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "FliegerAttack8"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		Spawn({desc = "Units/Aircrafts/american/c_47.dsc", position = {-800, 50, 800}, player = "Enemy", commands = {{unload_to = "FliegerAttack9"}, {dislocation = {-800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Vehicles/Transports/American/willys_supply.dsc", num = 1},{desc = "Units/Artillery/Antitank/American/37mm_m3a1.dsc", num = 1},{desc = "Units/Artillery/Mg/american/30_cal_hmg.dsc", num = 1},{desc = "Units/Artillery/Mortars/american/81mm_m1.dsc", num = 1},{desc = "Units/Artillery/Field/american/75mm_m1a1.dsc", num = 1},{desc = "Units/Vehicles/Transports/American/willys.dsc", num = 1},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2}}})
		RunSpawn("Enemy", {"Soldiers_Feind", }, "Spawn_09", "Inf_Attack", "", true, true, {{dislocation="Konvoi Ende", }, {disappear=true, }, }, false, 500)
		AIparts:RemovePeriodic("Verstaerkung Gegenschlag1")
	end
end

function func_Verstaerkung_Gegenschlag2()
	if msd_vars.Gegenschlag2 == 1 then
		RunSpawn("Player", {"Gegenschlag2", }, "Spawn_10", "Gegenschlag2", "", true, true, {}, false, 30)
		RunSpawn("Player", {"Gegenschlag2", }, "Spawn_11", "Gegenschlag2", "", true, true, {}, false, 30)
		AIparts:AddOneTime("TIMER_VAR_Gegenschlag3", 400*10, function() msd_vars.Gegenschlag3 = 1 end)
		RunSpawn("Enemy", {"Soldiers_Feind", }, "Spawn_09", "Inf_Attack", "", true, true, {{dislocation="Konvoi Ende", }, {disappear=true, }, }, false, 500)
		AIparts:RemovePeriodic("Verstaerkung Gegenschlag2")
	end
end

function func_Verstaerkung_Gegenschlag3()
	if msd_vars.Gegenschlag3 == 1 then
		RunSpawn("Player", {"Gegenschlag3", }, "Spawn_10", "Gegenschlag3", "", true, true, {}, false, 30)
		RunSpawn("Player", {"Gegenschlag3", }, "Spawn_11", "Gegenschlag3", "", true, true, {}, false, 30)
		AIparts:AddOneTime("TIMER_VAR_Gegenschlag4", 500*10, function() msd_vars.Gegenschlag4 = 1 end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 440*10, function()  mission.OutScreenMessage(100039, 20, "0xFFE0E0E0") end)
		RunSpawn("Enemy", {"Soldiers_Feind", }, "Spawn_09", "Inf_Attack", "", true, true, {{dislocation="Konvoi Ende", }, {disappear=true, }, }, false, 500)
		AIparts:RemovePeriodic("Verstaerkung Gegenschlag3")
	end
end

function func_Verstaerkung_Gegenschlag4()
	if msd_vars.Gegenschlag4 == 1 then
		RunSpawn("Player", {"Gegenschlag4", }, "Spawn_10", "Gegenschlag4", "", true, true, {}, false, 30)
		RunSpawn("Player", {"Gegenschlag4", }, "Spawn_11", "Gegenschlag4", "", true, true, {}, false, 30)
		RunSpawn("Enemy", {"Soldiers_Feind", }, "Spawn_09", "Inf_Attack", "", true, true, {{dislocation="Konvoi Ende", }, {disappear=true, }, }, false, 500)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  AddBonus(1, 3, 1, -1, -1) end)
		AIparts:RemovePeriodic("Verstaerkung Gegenschlag4")
	end
end

function func_Auftrag_Gegenschlag1()
	if msd_vars.SchmidtEnemy == 1 and msd_vars.VossenackEnemy == 1 and msd_vars.VerstaerkungGegenschlag == 1 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  mission.OutScreenMessage(100029, 20, "0xFFE0E0E0") end)
		AcivateObjective("Gegenschlag_Schmidt")
		AcivateObjective("Gegenschlag_Vossenack")
		AIparts:RemovePeriodic("Auftrag_Gegenschlag1")
	end
end

function func_Auftrag_Gegenschlag2()
	if IsObjectiveCompleted("Gegenschlag_Schmidt", "Player") and IsObjectiveCompleted("Gegenschlag_Vossenack", "Player") and msd_vars.VerstaerkungGegenschlag == 1 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  mission.OutScreenMessage(100030, 20, "0xFFE0E0E0") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  AcivateObjective("Gegenschlag_Sieg") end)
		AIparts:RemovePeriodic("Auftrag_Gegenschlag2")
	end
	if IsObjectiveCompleted("Gegenschlag_Schmidt", "Player") and IsObjectiveCompleted("Vossenack", "Player") and msd_vars.VerstaerkungGegenschlag == 1 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  mission.OutScreenMessage(100030, 20, "0xFFE0E0E0") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  AcivateObjective("Gegenschlag_Sieg") end)
		AIparts:RemovePeriodic("Auftrag_Gegenschlag2")
	end
	if IsObjectiveCompleted("Schmidt", "Player") and IsObjectiveCompleted("Gegenschlag_Vossenack", "Player") and msd_vars.VerstaerkungGegenschlag == 1 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  mission.OutScreenMessage(100030, 20, "0xFFE0E0E0") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  AcivateObjective("Gegenschlag_Sieg") end)
		AIparts:RemovePeriodic("Auftrag_Gegenschlag2")
	end
end

function func_Auftrag_Gegenschlag3()
	if msd_vars.SchmidtEnemy == 1 and msd_vars.VossenackEnemy == 0 and msd_vars.VerstaerkungGegenschlag == 1 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  mission.OutScreenMessage(100028, 20, "0xFFE0E0E0") end)
		AcivateObjective("Gegenschlag_Schmidt")
		AIparts:RemovePeriodic("Auftrag_Gegenschlag3")
	end
end

function func_Auftrag_Gegenschlag4()
	if msd_vars.SchmidtEnemy == 0 and msd_vars.VossenackEnemy == 1 and msd_vars.VerstaerkungGegenschlag == 1 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  mission.OutScreenMessage(100027, 20, "0xFFE0E0E0") end)
		AcivateObjective("Gegenschlag_Vossenack")
		AIparts:RemovePeriodic("Auftrag_Gegenschlag4")
	end
end

function func_Auftrag_Gegenschlag5()
	if msd_vars.SchmidtEnemy == 0 and msd_vars.VossenackEnemy == 0 and msd_vars.VerstaerkungGegenschlag == 1 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  mission.OutScreenMessage(100030, 20, "0xFFE0E0E0") end)
		AcivateObjective("Gegenschlag_Sieg")
		AIparts:RemovePeriodic("Auftrag_Gegenschlag5")
	end
end

function func_Player_erobert_Vossenack()
	if msd_vars.VossenackEnemy == 1 and NumPlayerUnitsInZone("Enemy", "Vossenack") <= 4 then
		ProceedObjective("Gegenschlag_Vossenack", "Player")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  mission.OutScreenMessage(100055, 20, "0xFFE0E0E0") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 100*10, function()  RunSpawn("Player", {"50_Soldaten", }, "Spawn_14", "", "", true, true, {}, false, 30) end)
		AIparts:RemovePeriodic("Player erobert Vossenack")
	end
end

function func_Player_erobert_Schmidt__()
	if msd_vars.SchmidtEnemy == 1 and NumPlayerUnitsInZone("Enemy", "Schmidt") <= 4 then
		ProceedObjective("Gegenschlag_Schmidt", "Player")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  mission.OutScreenMessage(100056, 20, "0xFFE0E0E0") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 100*10, function()  RunSpawn("Player", {"50_Soldaten", }, "Spawn_12", "", "", true, true, {}, false, 30) end)
		AIparts:RemovePeriodic("Player erobert Schmidt  ")
	end
end

function func_Ausloeser_Sieg()
	if NumPlayerUnitsInZone("Enemy", "Wald_west") < 8 and IsObjectiveActive("Gegenschlag_Sieg") then
		ProceedObjective("Gegenschlag_Sieg", "Player")
		mission.OutScreenMessage(100040, 20, "0xFFE0E0E0")
		AIparts:RemovePeriodic("Ausloeser Sieg")
	end
end

function func_Sieg()
	if IsObjectiveCompleted("Gegenschlag_Sieg", "Player") then
		PlayerWin("Player")
		AIparts:RemovePeriodic("Sieg")
	end
end

function func_FliegerAttack1()
	if msd_vars.VerstaerkungGegenschlag == 1 and NumPlayerUnitsInZone("Player", "FliegerAttack1") > 1 then
		SendPlane("Enemy", "FliegerAttack1", "fighter", "W", 15, -1, "")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  SendPlane("Enemy", "FliegerAttack1", "strike_fighter", "W", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 20*10, function()  SendPlane("Enemy", "FliegerAttack1.1", "fighter", "W", 25, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 25*10, function()  SendPlane("Enemy", "FliegerAttack1.1", "strike_fighter", "W", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 40*10, function()  SendPlane("Enemy", "FliegerAttack1", "strike_fighter", "NW", 15, -1, "") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 45*10, function()  SendPlane("Enemy", "FliegerAttack1", "fighter", "SW", 15, -1, "") end)
		AIparts:RemovePeriodic("FliegerAttack1")
	end
end

function func_FliegerAttack2()
	if msd_vars.VerstaerkungGegenschlag == 1 and NumPlayerUnitsInZone("Player", "FliegerAttack2") > 2 then
		SendPlane("Enemy", "FliegerAttack2", "strike_fighter", "W", 15, -1, "")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  SendPlane("Enemy", "FliegerAttack2", "fighter", "W", 15, -1, "") end)
		AIparts:RemovePeriodic("FliegerAttack2")
	end
end

function func_FliegerAttack3()
	if msd_vars.VerstaerkungGegenschlag == 1 and NumPlayerUnitsInZone("Player", "FliegerAttack3") > 2 then
		SendPlane("Enemy", "FliegerAttack3", "fighter", "W", 15, -1, "")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  SendPlane("Enemy", "FliegerAttack3", "strike_fighter", "W", 15, -1, "") end)
		AIparts:RemovePeriodic("FliegerAttack3")
	end
end

function func_FliegerAttack4()
	if msd_vars.VerstaerkungGegenschlag == 1 and NumPlayerUnitsInZone("Player", "FliegerAttack4") > 2 then
		SendPlane("Enemy", "FliegerAttack4", "strike_fighter", "W", 15, -1, "")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  SendPlane("Enemy", "FliegerAttack4", "fighter", "NW", 15, -1, "") end)
		AIparts:RemovePeriodic("FliegerAttack4")
	end
end

function func_FliegerAttack5()
	if msd_vars.VerstaerkungGegenschlag == 1 and NumPlayerUnitsInZone("Player", "FliegerAttack5") > 2 then
		SendPlane("Enemy", "FliegerAttack5", "fighter", "W", 15, -1, "")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  SendPlane("Enemy", "FliegerAttack5", "strike_fighter", "W", 15, -1, "") end)
		AIparts:RemovePeriodic("FliegerAttack5")
	end
end

function func_FliegerAttack6()
	if msd_vars.VerstaerkungGegenschlag == 1 and NumPlayerUnitsInZone("Player", "FliegerAttack6") > 2 then
		SendPlane("Enemy", "FliegerAttack6", "strike_fighter", "W", 15, -1, "")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  SendPlane("Enemy", "FliegerAttack6", "fighter", "W", 15, -1, "") end)
		AIparts:RemovePeriodic("FliegerAttack6")
	end
end

function func_FliegerAttack7()
	if msd_vars.VerstaerkungGegenschlag == 1 and NumPlayerUnitsInZone("Player", "FliegerAttack7") > 2 then
		SendPlane("Enemy", "FliegerAttack7", "strike_fighter", "NW", 15, -1, "")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  SendPlane("Enemy", "FliegerAttack7", "fighter", "W", 15, -1, "") end)
		AIparts:RemovePeriodic("FliegerAttack7")
	end
end

function func_FliegerAttack8()
	if msd_vars.VerstaerkungGegenschlag == 1 and NumPlayerUnitsInZone("Player", "FliegerAttack8") > 2 then
		SendPlane("Enemy", "FliegerAttack8", "strike_fighter", "NW", 15, -1, "")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  SendPlane("Enemy", "FliegerAttack8", "fighter", "W", 15, -1, "") end)
		AIparts:RemovePeriodic("FliegerAttack8")
	end
end

function func_FliegerAttack9()
	if msd_vars.VerstaerkungGegenschlag == 1 and NumPlayerUnitsInZone("Player", "FliegerAttack9") > 2 then
		SendPlane("Enemy", "FliegerAttack9", "strike_fighter", "NW", 15, -1, "")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 5*10, function()  SendPlane("Enemy", "FliegerAttack9", "fighter", "W", 15, -1, "") end)
		AIparts:RemovePeriodic("FliegerAttack9")
	end
end

function func_AriAttack1()
	if msd_vars.VerstaerkungGegenschlag == 1 and NumPlayerUnitsInZone("Player", "AriAttack1") > 2 then
		Bombardment("AriAttack1", 30, 14, 6, 30)
		AIparts:RemovePeriodic("AriAttack1")
	end
end

function func_Ende()
	if IsObjectiveCompleted("Befehlshaber", "Player") and NumPlayerUnits("Player") < 2 then
		mission.OutScreenMessage(100005, 20, "0xFFE0E0E0")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  PlayerDefeat("Player") end)
	end
end

function func_Countdown1()
	if msd_vars.CounterPanzer == 1 then
		mission.OutScreenMessage(100043, 20, "0xFFE0E0E0")
		AIparts:RemovePeriodic("Countdown1")
	end
end

function func_Countdown2()
	if msd_vars.CounterPanzer == 2 then
		mission.OutScreenMessage(100044, 10, "0xFFE0E0E0")
		AIparts:RemovePeriodic("Countdown2")
	end
end

function func_Countdown3()
	if msd_vars.CounterPanzer == 3 then
		mission.OutScreenMessage(100045, 10, "0xFFE0E0E0")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  AddBonus(1, 3, 1, -1, -1) end)
		AIparts:RemovePeriodic("Countdown3")
	end
end

function func_Countdown4()
	if msd_vars.CounterPanzer == 4 then
		mission.OutScreenMessage(100046, 10, "0xFFE0E0E0")
		AIparts:RemovePeriodic("Countdown4")
	end
end

function func_Countdown5()
	if msd_vars.CounterPanzer == 5 then
		mission.OutScreenMessage(100041, 20, "0xFFE0E0E0")
		AIparts:RemovePeriodic("Countdown5")
	end
end

function func_Countdown6()
	if msd_vars.CounterPanzer == 6 then
		mission.OutScreenMessage(100042, 10, "0xFFE0E0E0")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  AddBonus(1, 3, 1, -1, -1) end)
		AIparts:RemovePeriodic("Countdown6")
	end
end

function func_Countdown7()
	if msd_vars.CounterPanzer == 7 then
		mission.OutScreenMessage(100047, 10, "0xFFE0E0E0")
		AIparts:RemovePeriodic("Countdown7")
	end
end

function func_Countdown8()
	if msd_vars.CounterPanzer == 8 then
		mission.OutScreenMessage(100048, 10, "0xFFE0E0E0")
		AIparts:RemovePeriodic("Countdown8")
	end
end

function func_Countdown9()
	if msd_vars.CounterPanzer == 9 then
		mission.OutScreenMessage(100049, 20, "0xFFE0E0E0")
		msd_vars.VerstaerkungGegenschlag = 1
		AIparts:RemovePeriodic("Countdown9")
	end
end

function func_Gegenschlag_Wald_West()
	if msd_vars.Gegenschlag4 == 1 and NumPlayerUnitsInZone("Player", "Wald_west") > 2 then
		RunSpawn("Enemy", {"Soldiers_Feind", }, "Spawn_09", "Inf_Attack", "", true, true, {{dislocation="Konvoi Ende", }, {disappear=true, }, }, false, 500)
		mission.OutScreenMessage(100050, 20, "0xFFE0E0E0")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  RunSpawn("Player", {"Gegenschlag_Wald_West", }, "Spawn_10", "Gegenschlag5", "", true, true, {}, false, 30) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  RunSpawn("Player", {"Gegenschlag_Wald_West", }, "Spawn_11", "Gegenschlag5", "", true, true, {}, false, 30) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  RunSpawn("Enemy", {"Strum_Schmidt_Enemy", }, "Spawn_11", "Sturm_Vossenack", "Sturm_Vossenack", true, true, {}, false, 30) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 15*10, function()  RunSpawn("Enemy", {"Strum_Schmidt_Enemy", }, "Spawn_12", "Sturm_Schmidt", "Sturm_Schmidt", true, true, {}, false, 30) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 300*10, function()  MoveGroupToZone("Sturm_Schmidt", "Schmidt", false, false) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 300*10, function()  MoveGroupToZone("Sturm_Vossenack", "Vossenack", false, false) end)
		AIparts:RemovePeriodic("Gegenschlag_Wald_West")
	end
end

function func_Spieler_Wald_West_vor_Auftrag()
	if msd_vars.VerstaerkungGegenschlag == 0 and NumPlayerUnitsInZone("Player", "Wald_west") > 2 then
		RunSpawn("Enemy", {"Wald7_Feind", }, "Spawn_09", "Inf_Attack", "", true, true, {{dislocation="Konvoi Ende", }, {disappear=true, }, }, false, 500)
		AIparts:RemovePeriodic("Spieler Wald West vor Auftrag")
	end
end

function func_Uebergabe_Artillerie()
	if NumPlayerUnitsInZone("Player", "Ari") > 0 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  AddBonus(1, 3, 3, -1, -1) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  TransferUnits("Ari_Neutral", 0, "Uebergabe_Spieler", 0) end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 10*10, function()  mission.OutScreenMessage(100053, 10, "0xFFE0E0E0") end)
		AIparts:RemovePeriodic("Uebergabe Artillerie")
	end
end

function func_Hinweis_Artillerie()
	if NumPlayerUnitsInZone("Enemy", "Wald1") > 3 and NumPlayerUnitsInZone("Player", "Ari") == 0 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  mission.OutScreenMessage(100012, 10, "0xFFE0E0E0") end)
		AIparts:RemovePeriodic("Hinweis Artillerie")
	end
end

function func_Feind_in_Vossenack()
	if NumPlayerUnitsInZone("Enemy", "Vossenack") > 0 then
		mission.OutScreenMessage(100054, 1, "0xFFE0E0E0")
		MoveGroupToZone("Wald7", "Wald7", false, false)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  Spawn({desc = "Units/Aircrafts/German/ju_52.dsc", position = {800, 50,0}, player = "Player", commands = {{unload_to = "Abwurf1"}, {dislocation = {800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Artillery/Mg/german/mg42_schweres.dsc", num = 1},{desc = "Units/Artillery/Mortars/german/8cm_grwr34.dsc", num = 1},{desc = "Objects/ammo_boxes/fuel_800.dsc", num = 2},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2},{desc = "Units/Soldiers/german/german_mech.dsc", num = 2},{desc = "Units/Soldiers/german/german_medic.dsc", num = 2}}}) end)
		AIparts:RemovePeriodic("Feind in Vossenack")
	end
end

function func_Feind_in_Schmidt()
	if NumPlayerUnitsInZone("Enemy", "Schmidt") > 0 then
		mission.OutScreenMessage(100054, 1, "0xFFE0E0E0")
		MoveGroupToZone("Wald7", "Wald7", false, false)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 60*10, function()  Spawn({desc = "Units/Aircrafts/German/ju_52.dsc", position = {800, 50,0}, player = "Player", commands = {{unload_to = "Abwurf2"}, {dislocation = {800, 50, 0}}, {disappear = true}}, cargo = {{desc = "Units/Artillery/Mg/german/mg42_schweres.dsc", num = 1},{desc = "Units/Artillery/Mortars/german/8cm_grwr34.dsc", num = 1},{desc = "Objects/ammo_boxes/fuel_800.dsc", num = 2},{desc = "Objects/ammo_boxes/ammo_4000.dsc", num = 2},{desc = "Units/Soldiers/german/german_mech.dsc", num = 2},{desc = "Units/Soldiers/german/german_medic.dsc", num = 2}}}) end)
		AIparts:RemovePeriodic("Feind in Schmidt")
	end
end

function func_Infanterie_Verstaerkung_Gegenschlag()
	if IsObjectiveActive("Gegenschlag_Sieg") and msd_vars.Gegenschlag4 == 1 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 100*10, function()  RunSpawn("Player", {"50_Soldaten", }, "Spawn_13", "", "", true, true, {}, false, 50) end)
		AIparts:RemovePeriodic("Infanterie Verstaerkung Gegenschlag")
	end
end

function func_Feind_in_Wald1()
	if NumPlayerUnitsInZone("Enemy", "Wald1") > 0 then
		mission.OutScreenMessage(100054, 1, "0xFFE0E0E0")
		AIparts:RemovePeriodic("Feind in Wald1")
	end
end

function func_Feind_in_Wald2()
	if NumPlayerUnitsInZone("Enemy", "Wald2") > 0 then
		mission.OutScreenMessage(100054, 1, "0xFFE0E0E0")
		AIparts:RemovePeriodic("Feind in Wald2")
	end
end

function func_Feind_in_Wald_3()
	if NumPlayerUnitsInZone("Enemy", "Wald3") > 0 then
		mission.OutScreenMessage(100054, 1, "0xFFE0E0E0")
		AIparts:RemovePeriodic("Feind in Wald 3")
	end
end

function func_Feind_in_Huegel1()
	if NumPlayerUnitsInZone("Enemy", "Huegel1") > 0 then
		mission.OutScreenMessage(100054, 1, "0xFFE0E0E0")
		AIparts:RemovePeriodic("Feind in Huegel1")
	end
end

function func_Feind_in_Huegel2()
	if NumPlayerUnitsInZone("Enemy", "Huegel2") > 0 then
		mission.OutScreenMessage(100054, 1, "0xFFE0E0E0")
		AIparts:RemovePeriodic("Feind in Huegel2")
	end
end

function func_Feind_in_Wald()
	if NumPlayerUnitsInZone("Enemy", "Wald1") > 0 or NumPlayerUnitsInZone("Enemy", "Wald2") > 0 or NumPlayerUnitsInZone("Enemy", "Wald3") > 0 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  RunSpawn("Player", {"Verteidigung_Player_2", }, "Spawn_08", "", "", true, true, {}, false, 200) end)
		AIparts:RemovePeriodic("Feind in Wald")
	end
end

function func_Spawn_Final_Attack1()
	if msd_vars.Gegenschlag4 == 1 and NumGroupUnitsInZone("Gegenschlag5", "Wald_west") > 1 then
		RunSpawn("Enemy", {"Final_Attack", }, "Spawn_10", "Final_Attack", "Final_Attack", true, true, {}, false, 20)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 100*10, function()  MoveGroupToZone("Final_Attack", "Huegel1", false, false) end)
		AIparts:RemovePeriodic("Spawn Final Attack1")
	end
end

function func_Final_Attack2()
	if NumGroupUnitsInZone("Final_Attack", "Huegel1") > 1 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 100*10, function()  MoveGroupToZone("Final_Attack", "FliegerAttack1", false, false) end)
		AIparts:RemovePeriodic("Final Attack2")
	end
end

function func_Final_Attack3()
	if NumGroupUnitsInZone("Final_Attack", "FliegerAttack1") > 0 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 100*10, function()  MoveGroupToZone("Final_Attack", "Wald4", false, false) end)
		AIparts:RemovePeriodic("Final Attack3")
	end
end

function func_Final_Attack4()
	if NumGroupUnitsInZone("Final_Attack", "Wald4") > 0 then
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  MoveGroupToZone("Final_Attack", "Wald_west", false, false) end)
		AIparts:RemovePeriodic("Final Attack4")
	end
end

function func_cheat()
	if msd_vars.cheat and NumPlayerUnitsInZone("Player", "Ari") > 0 and NumPlayerUnitsInZone("Player", "Camp") > 0 then
		PlayerWin("Player")
		AIparts:RemovePeriodic("cheat")
	end
end

function func_Fallis()
	if NumPlayerUnitsInZone("Enemy", "Wald_west") < 30 and IsObjectiveActive("Gegenschlag_Sieg") then
		SendPlane("Enemy", "Wald4", "bomber", "NW", 15, -1, "")
		SendPlane("Enemy", "Wald5", "bomber", "W", 15, -1, "")
		SendPlane("Enemy", "Wald7", "bomber", "NW", 15, -1, "")
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 20*10, function()  SendPlane("Enemy", "Wald4", "transport", "NW", 15, 4, "Falli") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 30*10, function()  SendPlane("Enemy", "Wald5", "transport", "W", 15, 4, "Falli") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 40*10, function()  SendPlane("Enemy", "Wald7", "transport", "NW", 15, 4, "Falli") end)
		AIparts:AddOneTime(AIparts:GetUniqueId("TIMER_DO_"), 180*10, function()  MoveGroupToZone("Falli", "Wald_west", true, false) end)
		AIparts:RemovePeriodic("Fallis")
	end
end

function func_Sound()
	do
		mission.OutScreenMessage(100059, 5, "0xFF000000")
	end
end

