import("ScarUtil.scar")

function OnGameSetup()

player1 = World_GetPlayerAt(1)
player2 = World_GetPlayerAt(2)
player3 = World_GetPlayerAt(3)
player4 = World_GetPlayerAt(4)

end

function OnInit()

LOCSTRINGS = 
	{	
		TITLE = "Desert Tactics",
		OBJECTIVE = "all command abilities are provided, one every few minutes",
		OBJECTIVE2 = "you will receive 11 command abilities",
		OBJECTIVE3 = "Capture this point for Armor reinforcements",
		OBJECTIVE4 = "Capture this point for support units",
		OBJECTIVE5 = "secure all four points, to receive Air raids every 5 min",
		OBJECTIVE6 = "secure all four points, to receive Elite Tiger Ace every 8 min",
		COMMAND1 = "command abilities received",
		COMMAND2 = "final command ability received",
		REINFORCEMENTS = "Reinforcements have arrived",	
		REINFORCEMENTS2 = "King Tigers have arrived",
		AIRRAID = "Fighter squad on attack run",
		AXCOUNTER = "Axis counter attack has started",
		ALCOUNTER = "Allies counter attack has started",
	}
	for key, value in pairs(LOCSTRINGS) do LOCSTRINGS[key] = Util_CreateLocString(value) end
SOUNDS =
{
BACKGROUND = "ambiences/amightywind1",
}
for key, value in pairs(SOUNDS) do Sound_PreCacheSound(value) end
Sound_PlayStreamed(SOUNDS.BACKGROUND)

Util_PlayMusic("SOUND/Music/sp/m14/m04_ob4_shermansarrive", 0, 0)
status_intro = 1
timer = 1
timer2 = 1
timer3 = 280
plyerTEAMONE = 1
plyerTEAMTWO = 1
plyerTEAMThr = 1
plyerTEAMFor = 1
counter = 1
Alcounter = 1
Axcounter = 1

ArmyID()
Construct()
reinf_Tank = {SBP.ALLIES.PERSHING, SBP.ALLIES.M10, SBP.ALLIES.SHERMAN, SBP.ALLIES.SHERMAN, SBP.ALLIES.SHERMAN, SBP.ALLIES.CROCODILE, SBP.ALLIES.CROCODILE, SBP.ALLIES.CALLIOPE}
reinf_Tank2 = {SBP.AXIS.TIGER, SBP.AXIS.PANTHER, SBP.AXIS.PANZER, SBP.AXIS.PANZER, SBP.AXIS.PANZER, SBP.AXIS.OSTWIND, SBP.AXIS.OSTWIND, SBP.AXIS.STUG}
reinf_Support = {SBP.ALLIES.HALFTRACK, SBP.ALLIES.GREYHOUND, SBP.ALLIES.AT_57MM, SBP.ALLIES.SNIPER, SBP.ALLIES.HEAVYMG, SBP.ALLIES.RANGER}
reinf_Support2 = {SBP.AXIS.HALFTRACK, SBP.AXIS.PUMA, SBP.AXIS.PAK_38, SBP.AXIS.SNIPER, SBP.AXIS.HEAVYMG, SBP.AXIS.KNIGHTSCROSS}

reinf_TankCW = {SBP.CW.CHURCHILL_CROC, SBP.CW.CHURCHILL, SBP.CW.COMMAND_CROMWELL, SBP.CW.CROMWELL, SBP.CW.CROMWELL, SBP.CW.STUART, SBP.CW.STUART, SBP.CW.FIREFLY}
reinf_TankPE = {SBP.ELITE.JAGDPANTHER, SBP.ELITE.PANTHER, SBP.ELITE.PANZER_SUPPORT, SBP.ELITE.PANZER_SUPPORT, SBP.ELITE.PANZER_SUPPORT, SBP.ELITE.MARDER, SBP.ELITE.MARDER, SBP.ELITE.HETZER}
reinf_SupportCW = {SBP.CW.COMMANDOS_JEEP, SBP.CW.TETRARCH, SBP.CW.BREN_CARRIER, SBP.CW.COMMANDOS_SNIPER, SBP.CW.COMMANDOS_MG, SBP.CW.COMMANDOS}
reinf_SupportPE = {SBP.ELITE.HALFTRACK_251, SBP.ELITE.ARMOURCAR_223, SBP.ELITE.HALFTRACK_SNIPER, SBP.ELITE.HALFTRACK_MORTAR, SBP.ELITE.HALFTRACK_250, SBP.ELITE.PANZERGRENADIER}



Rule_AddInterval(Tankreinf, 900)
Rule_AddInterval(Supportinf, 360)
Rule_AddInterval(Construct2, 150)

Rule_AddInterval(BIGALLIED, 1)
Rule_AddInterval(BIGAXIS, 480)
Rule_AddInterval(BIGcounter, 180)


Rule_AddInterval(CounterAttacks, 1)


Rule_AddInterval(timer1, 1)
end

Scar_AddInit(OnInit)

function timer1()
if timer == 5 then
Util_GlobalMessage(LOCSTRINGS.TITLE, 3)
elseif timer == 10 then
Util_GlobalMessage(LOCSTRINGS.OBJECTIVE, 5)
elseif timer == 17 then
Util_GlobalMessage(LOCSTRINGS.OBJECTIVE2, 5)
elseif timer == 24 then
Util_GlobalMessage(LOCSTRINGS.OBJECTIVE3, 5)
UI_CreateMinimapBlip(eg_TWENTYFOUR, 30, BT_ObjectivePrimary)
elseif timer == 31 then
Util_GlobalMessage(LOCSTRINGS.OBJECTIVE4, 5)
UI_CreateMinimapBlip(eg_TWENTYFIVE, 30, BT_ObjectivePrimary)
elseif timer == 38 then
if Player_GetID(Game_GetLocalPlayer()) == Player_GetID(player3) or Player_GetID(Game_GetLocalPlayer()) == Player_GetID(player4) then 
	Util_GlobalMessage(LOCSTRINGS.OBJECTIVE6, 5)
	UI_CreateMinimapBlip(eg_TWENTYTHREE, 30, BT_ObjectiveSecondary)
	UI_CreateMinimapBlip(eg_TWENTYFOUR, 30, BT_ObjectiveSecondary)
	UI_CreateMinimapBlip(eg_TWENTYFIVE, 30, BT_ObjectiveSecondary)
	UI_CreateMinimapBlip(eg_TWENTYSIX, 30, BT_ObjectiveSecondary)
end	
elseif timer == 39 then
if Player_GetID(Game_GetLocalPlayer()) == Player_GetID(player1) or Player_GetID(Game_GetLocalPlayer()) == Player_GetID(player2) then 
	Util_GlobalMessage(LOCSTRINGS.OBJECTIVE5, 5)
	UI_CreateMinimapBlip(eg_TWENTYTHREE, 30, BT_ObjectiveSecondary)
	UI_CreateMinimapBlip(eg_TWENTYFOUR, 30, BT_ObjectiveSecondary)
	UI_CreateMinimapBlip(eg_TWENTYFIVE, 30, BT_ObjectiveSecondary)
	UI_CreateMinimapBlip(eg_TWENTYSIX, 30, BT_ObjectiveSecondary)
end
elseif timer == 600 then
counter = counter + 1



Rule_RemoveMe()
end

timer = timer + 1

end

--identifies what army the player is using (and AI) 2=Americans, 3=British, 4=classic german, 5=PanzerElite
function ArmyID()

	if Player_HasBuilding(player1, EBP.ALLIES.HQ3) then
	plyerTEAMONE = 2
	else
	plyerTEAMONE = 3
	end

	if Player_HasBuilding(player3, EBP.AXIS.HQ3) then
	plyerTEAMThr = 4
	elseif Player_HasBuilding(player3, EBP.ELITE.HQ3) then
	plyerTEAMThr = 5
	end

	if Player_HasBuilding(player2, EBP.ALLIES.HQ3) then
	plyerTEAMTWO = 2
	else
	plyerTEAMTWO = 3
	end

	if Player_HasBuilding(player4, EBP.AXIS.HQ3) then
	plyerTEAMFor = 4
	elseif Player_HasBuilding(player4, EBP.ELITE.HQ3) then
	plyerTEAMFor = 5
	end
end

--locks down the ability to select commander upgrades
function Construct()
if plyerTEAMONE == 2 then
	UI_ForceCommanderTreeChoice(player1, UPG.COMMANDER_TREE.ALLIES.INFANTRY)
	Player_SetUpgradeAvailability(player1, UPG.COMMANDER_TREE.ALLIES.INFANTRY_00, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player1, UPG.COMMANDER_TREE.ALLIES.INFANTRY_01, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player1, UPG.COMMANDER_TREE.ALLIES.INFANTRY_02, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player1, UPG.COMMANDER_TREE.ALLIES.INFANTRY_10, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player1, UPG.COMMANDER_TREE.ALLIES.INFANTRY_11, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player1, UPG.COMMANDER_TREE.ALLIES.INFANTRY_12, ITEM_LOCKED)
else
	UI_ForceCommanderTreeChoice(player1, UPG.COMMANDER_TREE.CW.COMMANDOS)
	Player_SetUpgradeAvailability(player1, UPG.COMMANDER_TREE.CW.COMMANDOS_00, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player1, UPG.COMMANDER_TREE.CW.COMMANDOS_01, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player1, UPG.COMMANDER_TREE.CW.COMMANDOS_02, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player1, UPG.COMMANDER_TREE.CW.COMMANDOS_10, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player1, UPG.COMMANDER_TREE.CW.COMMANDOS_11, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player1, UPG.COMMANDER_TREE.CW.COMMANDOS_12, ITEM_LOCKED)
end

if plyerTEAMTWO == 2 then
	UI_ForceCommanderTreeChoice(player2, UPG.COMMANDER_TREE.ALLIES.INFANTRY)
	Player_SetUpgradeAvailability(player2, UPG.COMMANDER_TREE.ALLIES.INFANTRY_00, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player2, UPG.COMMANDER_TREE.ALLIES.INFANTRY_01, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player2, UPG.COMMANDER_TREE.ALLIES.INFANTRY_02, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player2, UPG.COMMANDER_TREE.ALLIES.INFANTRY_10, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player2, UPG.COMMANDER_TREE.ALLIES.INFANTRY_11, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player2, UPG.COMMANDER_TREE.ALLIES.INFANTRY_12, ITEM_LOCKED)
else
	UI_ForceCommanderTreeChoice(player2, UPG.COMMANDER_TREE.CW.COMMANDOS)
	Player_SetUpgradeAvailability(player2, UPG.COMMANDER_TREE.CW.COMMANDOS_00, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player2, UPG.COMMANDER_TREE.CW.COMMANDOS_01, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player2, UPG.COMMANDER_TREE.CW.COMMANDOS_02, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player2, UPG.COMMANDER_TREE.CW.COMMANDOS_10, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player2, UPG.COMMANDER_TREE.CW.COMMANDOS_11, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player2, UPG.COMMANDER_TREE.CW.COMMANDOS_12, ITEM_LOCKED)
end

if plyerTEAMThr == 4 then
	UI_ForceCommanderTreeChoice(player3, UPG.COMMANDER_TREE.AXIS.DEFENSE)
	Player_SetUpgradeAvailability(player3, UPG.COMMANDER_TREE.AXIS.DEFENSE_00, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player3, UPG.COMMANDER_TREE.AXIS.DEFENSE_01, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player3, UPG.COMMANDER_TREE.AXIS.DEFENSE_02, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player3, UPG.COMMANDER_TREE.AXIS.DEFENSE_10, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player3, UPG.COMMANDER_TREE.AXIS.DEFENSE_11, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player3, UPG.COMMANDER_TREE.AXIS.DEFENSE_12, ITEM_LOCKED)
else
	UI_ForceCommanderTreeChoice(player3, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE)
	Player_SetUpgradeAvailability(player3, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_00, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player3, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_01, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player3, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_02, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player3, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_10, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player3, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_11, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player3, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_12, ITEM_LOCKED)
end

if plyerTEAMFor == 4 then
	UI_ForceCommanderTreeChoice(player4, UPG.COMMANDER_TREE.AXIS.DEFENSE)
	Player_SetUpgradeAvailability(player4, UPG.COMMANDER_TREE.AXIS.DEFENSE_00, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player4, UPG.COMMANDER_TREE.AXIS.DEFENSE_01, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player4, UPG.COMMANDER_TREE.AXIS.DEFENSE_02, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player4, UPG.COMMANDER_TREE.AXIS.DEFENSE_10, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player4, UPG.COMMANDER_TREE.AXIS.DEFENSE_11, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player4, UPG.COMMANDER_TREE.AXIS.DEFENSE_12, ITEM_LOCKED)
else
	UI_ForceCommanderTreeChoice(player4, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE)
	Player_SetUpgradeAvailability(player4, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_00, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player4, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_01, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player4, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_02, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player4, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_10, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player4, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_11, ITEM_LOCKED)
	Player_SetUpgradeAvailability(player4, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_12, ITEM_LOCKED)
end
	

end

--provides comander upgrades each player every few minutes
function Construct2()
	if plyerTEAMONE == 2 then
	Construct2AM(player1)
	else
	Construct2CW(player1)
	end

	if plyerTEAMTWO == 2 then
	Construct2AM(player2)
	else
	Construct2CW(player2)
	end

	if plyerTEAMThr == 4 then
	Construct2AX(player3)
	else
	Construct2PE(player3)
	end

	if plyerTEAMFor == 4 then
	Construct2AX(player4)
	else
	Construct2PE(player4)
	end

	if timer2 == 11 then
	EventCue_Create(CUE.NORMAL, LOCSTRINGS.COMMAND2, LOCSTRINGS.COMMAND2)
	elseif timer2 < 11 then
	EventCue_Create(CUE.NORMAL, LOCSTRINGS.COMMAND1, LOCSTRINGS.COMMAND1)
	end

	timer2 = timer2 + 1
end

function Construct2AM(playerid)
	
if timer2 == 1 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ALLIES.ARMOR_00)
elseif timer2 == 2 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ALLIES.INFANTRY_10)
elseif timer2 == 3 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ALLIES.INFANTRY_12)
elseif timer2 == 4 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ALLIES.INFANTRY_01)
elseif timer2 == 5 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ALLIES.AIRBORNE_00)
elseif timer2 == 6 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ALLIES.ARMOR_11)
elseif timer2 == 7 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ALLIES.AIRBORNE_11)
elseif timer2 == 8 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ALLIES.AIRBORNE_02)
elseif timer2 == 9 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ALLIES.INFANTRY_11)
elseif timer2 == 10 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ALLIES.ARMOR_01)
elseif timer2 == 11 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ALLIES.ARMOR_02)
Rule_RemoveMe()
end

end

function Construct2AX(playerid)
	
if timer2 == 1 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.AXIS.DEFENSE_10)
elseif timer2 == 2 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.AXIS.DEFENSE_01)
elseif timer2 == 3 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.AXIS.DEFENSE_02)
elseif timer2 == 4 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.AXIS.BLITZKRIEG_00)
elseif timer2 == 5 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.AXIS.PROPAGANDA_11)
elseif timer2 == 6 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.AXIS.BLITZKRIEG_12)
elseif timer2 == 7 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.AXIS.PROPAGANDA_01)
elseif timer2 == 8 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.AXIS.BLITZKRIEG_11)
elseif timer2 == 9 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.AXIS.PROPAGANDA_12)
elseif timer2 == 10 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.AXIS.BLITZKRIEG_01)
elseif timer2 == 11 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.AXIS.BLITZKRIEG_02)
Rule_RemoveMe()
end

end

function Construct2CW(playerid)
	
if timer2 == 1 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.CW.CANADIAN_ARTILLERY_10)
elseif timer2 == 2 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.CW.ENGINEERS_00)
elseif timer2 == 3 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.CW.CANADIAN_ARTILLERY_01)
elseif timer2 == 4 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.CW.ENGINEERS_01)
elseif timer2 == 5 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.CW.COMMANDOS_00)
elseif timer2 == 6 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.CW.COMMANDOS_01)
elseif timer2 == 7 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.CW.ENGINEERS_11)
elseif timer2 == 8 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.CW.COMMANDOS_02)
elseif timer2 == 9 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.CW.COMMANDOS_12)
elseif timer2 == 10 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.CW.CANADIAN_ARTILLERY_02)
elseif timer2 == 11 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.CW.ENGINEERS_12)
Rule_RemoveMe()
end

end

function Construct2PE(playerid)
	
if timer2 == 1 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ELITE.TANK_DESTROYER_11)
elseif timer2 == 2 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ELITE.SCORCHED_EARTH_10)
elseif timer2 == 3 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_10)
elseif timer2 == 4 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_12)
elseif timer2 == 5 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_00)
elseif timer2 == 6 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_11)
elseif timer2 == 7 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ELITE.TANK_DESTROYER_01)
elseif timer2 == 8 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_01)
elseif timer2 == 9 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ELITE.LUFTWAFFE_02)
elseif timer2 == 10 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ELITE.SCORCHED_EARTH_12)
elseif timer2 == 11 then
	Cmd_InstantUpgrade(playerid, UPG.COMMANDER_TREE.ELITE.TANK_DESTROYER_12)
Rule_RemoveMe()
end

end




--gives tanks for holding point 24
function Tankreinf()
	if EGroup_IsCapturedByPlayer(eg_TWENTYFOUR, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYFOUR, player4, ANY) then
	
		if plyerTEAMThr == 4 then		
		Span_Tank_Ax(player3)
		else
		Span_Tank_PE(player3)
		end	

		if plyerTEAMFor == 4 then
		Span_Tank_Ax(player4)
		else
		Span_Tank_PE(player4)
		end

	end


	if EGroup_IsCapturedByPlayer(eg_TWENTYFOUR, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYFOUR, player2, ANY) then
		
		if plyerTEAMONE == 2 then
		Span_Tank_Al(player1)
		else		
		Span_Tank_CW(player1)
		end

		if plyerTEAMTWO == 2 then
		Span_Tank_Al(player2)
		else
		Span_Tank_CW(player2)
		end

	end
end

--give support units for holding point 25
function Supportinf()
	if EGroup_IsCapturedByPlayer(eg_TWENTYFIVE, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYFIVE, player4, ANY) then
		
		if plyerTEAMThr == 4 then
		Span_Support_Ax(player3)
		else
		Span_Support_PE(player3)
		end

		if plyerTEAMFor == 4 then
		Span_Support_Ax(player4)
		else
		Span_Support_PE(player4)
		end

	end

	if EGroup_IsCapturedByPlayer(eg_TWENTYFIVE, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYFIVE, player2, ANY) then
		
		if plyerTEAMONE == 2 then
		Span_Support_Al(player1)
		else
		Span_Support_CW(player1)
		end

		if plyerTEAMTWO == 2 then
		Span_Support_Al(player2)
		else
		Span_Support_CW(player2)
		end
		
	end
end

function Span_Tank_Al(playerid)
	local spawnpos = marker1
	local targetpos = marker3

	if playerid == player2 then
		spawnpos = marker1
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(3,4), "blue_marker"))
	elseif playerid == player1 then
		spawnpos = marker2
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(3,4), "blue_marker"))
	end

	local sg_reinf = SGroup_CreateIfNotFound("sg_reinf")
	SGroup_Clear(sg_reinf)
		
	local NumTanks = World_GetRand(0, 1)
	if NumTanks == 0 then
	Util_CreateSquads(playerid, sg_reinf, reinf_Tank[World_GetRand(1, table.getn(reinf_Tank))], spawnpos, nil, 1) 
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
	elseif NumTanks == 1 then
	Util_CreateSquads(playerid, sg_reinf, reinf_Tank[World_GetRand(1, table.getn(reinf_Tank))], spawnpos, nil, 1)
	Util_CreateSquads(playerid, sg_reinf, reinf_Tank[World_GetRand(1, table.getn(reinf_Tank))], spawnpos, nil, 1) 
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
	end	
	 
	if Player_GetID(Game_GetLocalPlayer()) == Player_GetID(playerid) then		
		EventCue_Create(CUE.NORMAL, LOCSTRINGS.REINFORCEMENTS, LOCSTRINGS.REINFORCEMENTS)
		UI_CreateMinimapBlip(spawnpos, 20, BT_GeneralPing)
	end	
end
function Span_Tank_Ax(playerid)
	local spawnpos = marker5
	local targetpos = marker8
	
	if playerid == player3 then
		spawnpos = marker5
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(7,8), "blue_marker"))
	elseif playerid == player4 then
		spawnpos = marker6
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(7,8), "blue_marker"))
	end

	local sg_reinf = SGroup_CreateIfNotFound("sg_reinf")
	SGroup_Clear(sg_reinf)
		
	local NumTanks = World_GetRand(0, 1)
	if NumTanks == 0 then
	Util_CreateSquads(playerid, sg_reinf, reinf_Tank2[World_GetRand(1, table.getn(reinf_Tank2))], spawnpos, nil, 1) 
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
	elseif NumTanks == 1 then
	Util_CreateSquads(playerid, sg_reinf, reinf_Tank2[World_GetRand(1, table.getn(reinf_Tank2))], spawnpos, nil, 1)
	Util_CreateSquads(playerid, sg_reinf, reinf_Tank2[World_GetRand(1, table.getn(reinf_Tank2))], spawnpos, nil, 1) 
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
	end
		 
	if Player_GetID(Game_GetLocalPlayer()) == Player_GetID(playerid) then		
		EventCue_Create(CUE.NORMAL, LOCSTRINGS.REINFORCEMENTS, LOCSTRINGS.REINFORCEMENTS)
		UI_CreateMinimapBlip(spawnpos, 20, BT_GeneralPing)
	end	
end

function Span_Support_Al(playerid)
	local spawnpos = marker1
	local targetpos = marker2
	
	if playerid == player2 then
		spawnpos = marker1
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(3,4), "blue_marker"))
	elseif playerid == player1 then
		spawnpos = marker2
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(3,4), "blue_marker"))
	end

	local sg_reinf = SGroup_CreateIfNotFound("sg_reinf")
	SGroup_Clear(sg_reinf)
		
	NumTanks = World_GetRand(0, 1)
	if NumTanks == 0 then
	Util_CreateSquads(playerid, sg_reinf, reinf_Support[World_GetRand(1, table.getn(reinf_Support))], spawnpos, nil, 1)
	Util_CreateSquads(playerid, sg_reinf, reinf_Support[World_GetRand(1, table.getn(reinf_Support))], spawnpos, nil, 1)
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
	elseif NumTanks == 1 then
	Util_CreateSquads(playerid, sg_reinf, reinf_Support[World_GetRand(1, table.getn(reinf_Support))], spawnpos, nil, 1) 
	Util_CreateSquads(playerid, sg_reinf, reinf_Support[World_GetRand(1, table.getn(reinf_Support))], spawnpos, nil, 1) 
	Util_CreateSquads(playerid, sg_reinf, reinf_Support[World_GetRand(1, table.getn(reinf_Support))], spawnpos, nil, 1) 
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
	end
		 
	if Player_GetID(Game_GetLocalPlayer()) == Player_GetID(playerid) then		
		EventCue_Create(CUE.NORMAL, LOCSTRINGS.REINFORCEMENTS, LOCSTRINGS.REINFORCEMENTS)
		UI_CreateMinimapBlip(spawnpos, 20, BT_GeneralPing)
	end	
end
function Span_Support_Ax(playerid)
	local spawnpos = marker6
	local targetpos = marker1
	
	if playerid == player3 then
		spawnpos = marker5
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(7,8), "blue_marker"))
	elseif playerid == player4 then
		spawnpos = marker6
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(7,8), "blue_marker"))
	end

	local sg_reinf = SGroup_CreateIfNotFound("sg_reinf")
	SGroup_Clear(sg_reinf)
		
	local NumTanks = World_GetRand(0, 1)
	if NumTanks == 0 then
	Util_CreateSquads(playerid, sg_reinf, reinf_Support2[World_GetRand(1, table.getn(reinf_Support2))], spawnpos, nil, 1)
	Util_CreateSquads(playerid, sg_reinf, reinf_Support2[World_GetRand(1, table.getn(reinf_Support2))], spawnpos, nil, 1)
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
	elseif NumTanks == 1 then
	Util_CreateSquads(playerid, sg_reinf, reinf_Support2[World_GetRand(1, table.getn(reinf_Support2))], spawnpos, nil, 1) 
	Util_CreateSquads(playerid, sg_reinf, reinf_Support2[World_GetRand(1, table.getn(reinf_Support2))], spawnpos, nil, 1) 
	Util_CreateSquads(playerid, sg_reinf, reinf_Support2[World_GetRand(1, table.getn(reinf_Support2))], spawnpos, nil, 1) 
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
	end
		 
	if Player_GetID(Game_GetLocalPlayer()) == Player_GetID(playerid) then		
		EventCue_Create(CUE.NORMAL, LOCSTRINGS.REINFORCEMENTS, LOCSTRINGS.REINFORCEMENTS)
		UI_CreateMinimapBlip(spawnpos, 20, BT_GeneralPing)
	end	
end


function Span_Tank_CW(playerid)
	local spawnpos = marker1
	local targetpos = marker3

	if playerid == player2 then
		spawnpos = marker1
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(3,4), "blue_marker"))
	elseif playerid == player1 then
		spawnpos = marker2
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(3,4), "blue_marker"))
	end

	local sg_reinf = SGroup_CreateIfNotFound("sg_reinf")
	SGroup_Clear(sg_reinf)
		
	local NumTanks = World_GetRand(0, 1)
	if NumTanks == 0 then
	Util_CreateSquads(playerid, sg_reinf, reinf_TankCW[World_GetRand(1, table.getn(reinf_TankCW))], spawnpos, nil, 1) 
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
	elseif NumTanks == 1 then
	Util_CreateSquads(playerid, sg_reinf, reinf_TankCW[World_GetRand(1, table.getn(reinf_TankCW))], spawnpos, nil, 1)
	Util_CreateSquads(playerid, sg_reinf, reinf_TankCW[World_GetRand(1, table.getn(reinf_TankCW))], spawnpos, nil, 1) 
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
	end	
	 
	if Player_GetID(Game_GetLocalPlayer()) == Player_GetID(playerid) then		
		EventCue_Create(CUE.NORMAL, LOCSTRINGS.REINFORCEMENTS, LOCSTRINGS.REINFORCEMENTS)
		UI_CreateMinimapBlip(spawnpos, 20, BT_GeneralPing)
	end	
end
function Span_Tank_PE(playerid)
	local spawnpos = marker5
	local targetpos = marker8
	
	if playerid == player3 then
		spawnpos = marker5
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(7,8), "blue_marker"))
	elseif playerid == player4 then
		spawnpos = marker6
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(7,8), "blue_marker"))
	end

	local sg_reinf = SGroup_CreateIfNotFound("sg_reinf")
	SGroup_Clear(sg_reinf)
		
	local NumTanks = World_GetRand(0, 1)
	if NumTanks == 0 then
	Util_CreateSquads(playerid, sg_reinf, reinf_TankPE[World_GetRand(1, table.getn(reinf_TankPE))], spawnpos, nil, 1) 
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
	elseif NumTanks == 1 then
	Util_CreateSquads(playerid, sg_reinf, reinf_TankPE[World_GetRand(1, table.getn(reinf_TankPE))], spawnpos, nil, 1)
	Util_CreateSquads(playerid, sg_reinf, reinf_TankPE[World_GetRand(1, table.getn(reinf_TankPE))], spawnpos, nil, 1) 
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
	end
		 
	if Player_GetID(Game_GetLocalPlayer()) == Player_GetID(playerid) then		
		EventCue_Create(CUE.NORMAL, LOCSTRINGS.REINFORCEMENTS, LOCSTRINGS.REINFORCEMENTS)
		UI_CreateMinimapBlip(spawnpos, 20, BT_GeneralPing)
	end	
end

function Span_Support_CW(playerid)
	local spawnpos = marker1
	local targetpos = marker2
	
	if playerid == player2 then
		spawnpos = marker1
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(3,4), "blue_marker"))
	elseif playerid == player1 then
		spawnpos = marker2
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(3,4), "blue_marker"))
	end

	local sg_reinf = SGroup_CreateIfNotFound("sg_reinf")
	SGroup_Clear(sg_reinf)
		
	NumTanks = World_GetRand(0, 1)
	if NumTanks == 0 then
	Util_CreateSquads(playerid, sg_reinf, reinf_SupportCW[World_GetRand(1, table.getn(reinf_SupportCW))], spawnpos, nil, 1)
	Util_CreateSquads(playerid, sg_reinf, reinf_SupportCW[World_GetRand(1, table.getn(reinf_SupportCW))], spawnpos, nil, 1)
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
	elseif NumTanks == 1 then
	Util_CreateSquads(playerid, sg_reinf, reinf_SupportCW[World_GetRand(1, table.getn(reinf_SupportCW))], spawnpos, nil, 1) 
	Util_CreateSquads(playerid, sg_reinf, reinf_SupportCW[World_GetRand(1, table.getn(reinf_SupportCW))], spawnpos, nil, 1) 
	Util_CreateSquads(playerid, sg_reinf, reinf_SupportCW[World_GetRand(1, table.getn(reinf_SupportCW))], spawnpos, nil, 1) 
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
	end
		 
	if Player_GetID(Game_GetLocalPlayer()) == Player_GetID(playerid) then		
		EventCue_Create(CUE.NORMAL, LOCSTRINGS.REINFORCEMENTS, LOCSTRINGS.REINFORCEMENTS)
		UI_CreateMinimapBlip(spawnpos, 20, BT_GeneralPing)
	end	
end
function Span_Support_PE(playerid)
	local spawnpos = marker6
	local targetpos = marker1
	
	if playerid == player3 then
		spawnpos = marker5
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(7,8), "blue_marker"))
	elseif playerid == player4 then
		spawnpos = marker6
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(7,8), "blue_marker"))
	end

	local sg_reinf = SGroup_CreateIfNotFound("sg_reinf")
	SGroup_Clear(sg_reinf)
		
	local NumTanks = World_GetRand(0, 1)
	if NumTanks == 0 then
	Util_CreateSquads(playerid, sg_reinf, reinf_SupportPE[World_GetRand(1, table.getn(reinf_SupportPE))], spawnpos, nil, 1)
	Util_CreateSquads(playerid, sg_reinf, reinf_SupportPE[World_GetRand(1, table.getn(reinf_SupportPE))], spawnpos, nil, 1)
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
	elseif NumTanks == 1 then
	Util_CreateSquads(playerid, sg_reinf, reinf_SupportPE[World_GetRand(1, table.getn(reinf_SupportPE))], spawnpos, nil, 1) 
	Util_CreateSquads(playerid, sg_reinf, reinf_SupportPE[World_GetRand(1, table.getn(reinf_SupportPE))], spawnpos, nil, 1) 
	Util_CreateSquads(playerid, sg_reinf, reinf_SupportPE[World_GetRand(1, table.getn(reinf_SupportPE))], spawnpos, nil, 1) 
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
	end
		 
	if Player_GetID(Game_GetLocalPlayer()) == Player_GetID(playerid) then		
		EventCue_Create(CUE.NORMAL, LOCSTRINGS.REINFORCEMENTS, LOCSTRINGS.REINFORCEMENTS)
		UI_CreateMinimapBlip(spawnpos, 20, BT_GeneralPing)
	end	
end




--calls allies 4 point reward
function BIGALLIED()
	local comboteam = 1

	comboteam = plyerTEAMONE + plyerTEAMTWO

	if EGroup_IsCapturedByPlayer(eg_TWENTYTHREE, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYTHREE, player2, ANY) then
	if EGroup_IsCapturedByPlayer(eg_TWENTYFOUR, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYFOUR, player2, ANY) then
	if EGroup_IsCapturedByPlayer(eg_TWENTYFIVE, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYFIVE, player2, ANY) then
	if EGroup_IsCapturedByPlayer(eg_TWENTYSIX, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYSIX, player2, ANY) then
		
	if comboteam == 4 then
	Air_Raid()
	elseif comboteam == 5 then
	Air_RaidCombo()
	elseif comboteam == 6 then
	Air_RaidCW()
	end

	end
	end
	end
	end

	timer3 = timer3 + 1

	if timer3 == 320 then
	timer3 = timer3 - 300
	end

end

--call Axis 4 point reward
function BIGAXIS()
	if EGroup_IsCapturedByPlayer(eg_TWENTYTHREE, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYTHREE, player4, ANY) then
	if EGroup_IsCapturedByPlayer(eg_TWENTYFOUR, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYFOUR, player4, ANY) then
	if EGroup_IsCapturedByPlayer(eg_TWENTYFIVE, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYFIVE, player4, ANY) then
	if EGroup_IsCapturedByPlayer(eg_TWENTYSIX, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYSIX, player4, ANY) then
		TigerACE(player3)
		TigerACE(player4)
	end
	end
	end
	end
end

function BIGcounter()
	if EGroup_IsCapturedByPlayer(eg_TWENTYTHREE, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYTHREE, player4, ANY) then
	if EGroup_IsCapturedByPlayer(eg_TWENTYFOUR, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYFOUR, player4, ANY) then
	if EGroup_IsCapturedByPlayer(eg_TWENTYFIVE, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYFIVE, player4, ANY) then
	if EGroup_IsCapturedByPlayer(eg_TWENTYSIX, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYSIX, player4, ANY) then

		if plyerTEAMONE == 2 then
		AirDrop2(player1)
		else
		AirDrop2CW(player1)
		end

		if plyerTEAMTWO == 2 then
		AirDrop2(player2)
		else
		AirDrop2CW(player2)
		end

	end
	end
	end
	end
	if EGroup_IsCapturedByPlayer(eg_TWENTYTHREE, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYTHREE, player2, ANY) then
	if EGroup_IsCapturedByPlayer(eg_TWENTYFOUR, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYFOUR, player2, ANY) then
	if EGroup_IsCapturedByPlayer(eg_TWENTYFIVE, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYFIVE, player2, ANY) then
	if EGroup_IsCapturedByPlayer(eg_TWENTYSIX, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYSIX, player2, ANY) then

		if plyerTEAMThr == 4 then
		DesertKorps(player3)
		else
		DesertKorpsPE(player3)
		end

		if plyerTEAMFor == 4 then
		DesertKorps(player4)
		else
		DesertKorpsPE(player4)
		end

	end
	end
	end
	end
end

function AirDrop2(playerid)
	local spawnpos = marker105
	local spawnposTWO = marker111
	local targetpos = marker107

	if playerid == player1 then
		spawnpos = marker105
		targetpos = marker108
	elseif playerid == player2 then
		spawnpos = marker106
		targetpos = marker109
	end

	local sg_reinf = SGroup_CreateIfNotFound("sg_reinf")
	SGroup_Clear(sg_reinf)
	local sg_reinfPARA = SGroup_CreateIfNotFound("sg_reinfPARA")
	SGroup_Clear(sg_reinfPARA)

	spawnposTWO = Util_GetPosition(Marker_FromName("marker"..World_GetRand(111,114), "magenta_marker"))
	Util_Paradrop(playerid, sg_reinfPARA, SBP.ALLIES.PARATROOPER, spawnposTWO, 1)
	Util_CreateSquadsAtMarker(playerid, sg_reinf, SBP.ALLIES.SNIPER, spawnpos, 1)
	Util_CreateSquadsAtMarker(playerid, sg_reinf, SBP.ALLIES.RANGER, spawnpos, 1) 
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
end

function AirDrop2CW(playerid)
	local spawnpos = marker105
	local spawnposTWO = marker111
	local targetpos = marker107

	if playerid == player1 then
		spawnpos = marker105
		targetpos = marker108
	elseif playerid == player2 then
		spawnpos = marker106
		targetpos = marker109
	end

	local sg_reinf = SGroup_CreateIfNotFound("sg_reinf")
	SGroup_Clear(sg_reinf)
	local sg_reinfPARA = SGroup_CreateIfNotFound("sg_reinfPARA")
	SGroup_Clear(sg_reinfPARA)

	spawnposTWO = Util_GetPosition(Marker_FromName("marker"..World_GetRand(111,114), "magenta_marker"))
	Util_Paradrop(playerid, sg_reinfPARA, SBP.CW.COMMANDOS_PARATROOPER_SP, spawnposTWO, 1)
	Util_CreateSquadsAtMarker(playerid, sg_reinf, SBP.CW.COMMANDOS_SNIPER, spawnpos, 1)
	Util_CreateSquadsAtMarker(playerid, sg_reinf, SBP.CW.COMMANDOS, spawnpos, 1) 
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
end

--gives axis an infusion of troops to counter the allis controling the 4 center points
function DesertKorps(playerid)
	local spawnpos = marker105
	local targetpos = marker107
	
	if playerid == player3 then
		spawnpos = marker105
		targetpos = marker108
	elseif playerid == player4 then
		spawnpos = marker106
		targetpos = marker109
	end

	local sg_reinf = SGroup_CreateIfNotFound("sg_reinf")
	SGroup_Clear(sg_reinf)
	local sg_reinfTWO = SGroup_CreateIfNotFound("sg_reinfTWO")
	SGroup_Clear(sg_reinfTWO)
	local sg_reinfTHREE = SGroup_CreateIfNotFound("sg_reinfTHREE")
	SGroup_Clear(sg_reinfTHREE)
	
	Util_CreateSquads(playerid, sg_reinf, SBP.AXIS.KNIGHTSCROSS, spawnpos, nil, 1)  
	Util_CreateSquads(playerid, sg_reinfTWO, SBP.AXIS.SNIPER, spawnpos, nil, 1) 
	Util_CreateSquads(playerid, sg_reinfTHREE, SBP.AXIS.VOLKS_2PANZERF, spawnpos, nil, 1) 
	Cmd_Move(sg_reinfTWO, Util_GetPosition(targetpos), 15)

	if playerid == player3 then
		Cmd_MoveToThenCapture( sg_reinf, eg_TWENTYFOUR)
		Cmd_MoveToThenCapture( sg_reinfTHREE, eg_TWENTYTHREE)
	elseif playerid == player4 then
		Cmd_MoveToThenCapture( sg_reinf, eg_TWENTYFIVE)
		Cmd_MoveToThenCapture( sg_reinfTHREE, eg_TWENTYSIX)
	end	 	
end

function DesertKorpsPE(playerid)
	local spawnpos = marker105
	local targetpos = marker107
	
	if playerid == player3 then
		spawnpos = marker105
		targetpos = marker108
	elseif playerid == player4 then
		spawnpos = marker106
		targetpos = marker109
	end

	local sg_reinf = SGroup_CreateIfNotFound("sg_reinf")
	SGroup_Clear(sg_reinf)
	local sg_reinfTWO = SGroup_CreateIfNotFound("sg_reinfTWO")
	SGroup_Clear(sg_reinfTWO)
	local sg_reinfTHREE = SGroup_CreateIfNotFound("sg_reinfTHREE")
	SGroup_Clear(sg_reinfTHREE)
	
	Util_CreateSquads(playerid, sg_reinf, SBP.ELITE.FALLSCHIRMJAGER, spawnpos, nil, 1)  
	Util_CreateSquads(playerid, sg_reinfTWO, SBP.ELITE.HALFTRACK_250, spawnpos, nil, 1) 
	Util_CreateSquads(playerid, sg_reinfTHREE, SBP.ELITE.PANZERGRENADIER, spawnpos, nil, 1) 
	Cmd_Move(sg_reinfTWO, Util_GetPosition(targetpos), 15)

	if playerid == player3 then
		Cmd_MoveToThenCapture( sg_reinf, eg_TWENTYFOUR)
		Cmd_MoveToThenCapture( sg_reinfTHREE, eg_TWENTYTHREE)
	elseif playerid == player4 then
		Cmd_MoveToThenCapture( sg_reinf, eg_TWENTYFIVE)
		Cmd_MoveToThenCapture( sg_reinfTHREE, eg_TWENTYSIX)
	end	 	
end

--calls in an air raid of 10 planes through out the battle field
function Air_Raid()
if timer3 == 300 then
bomber2()
EventCue_Create(CUE.NORMAL, LOCSTRINGS.AIRRAID, LOCSTRINGS.AIRRAID)
elseif timer3 == 302 then
bomber2()
elseif timer3 == 304 then
bomber2()
elseif timer3 == 306 then
bomber2()
elseif timer3 == 308 then
bomber2()
elseif timer3 == 310 then
bomber2()
elseif timer3 == 312 then
bomber2()
elseif timer3 == 314 then
bomber2()
elseif timer3 == 316 then
bomber2()
elseif timer3 == 318 then
bomber2()
end
end
function bomber2()	
	pilot = World_GetPlayerAt(World_GetRand(1, 2))	 	
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(49,68), "green_marker"))
	targets = Util_GetPosition(Marker_FromName("marker"..World_GetRand(49,68), "green_marker"))
	Cmd_Ability(pilot, ABILITY.COMMANDER_TREE.ALLIES.STRAFE_ROCKET, target, targets, true)
end

function Air_RaidCW()
if timer3 == 300 then
bomber3()
EventCue_Create(CUE.NORMAL, LOCSTRINGS.AIRRAID, LOCSTRINGS.AIRRAID)
elseif timer3 == 302 then
bomber3()
elseif timer3 == 304 then
bomber3()
elseif timer3 == 306 then
bomber3()
elseif timer3 == 308 then
bomber3()
elseif timer3 == 310 then
bomber3()
elseif timer3 == 312 then
bomber3()
elseif timer3 == 314 then
bomber3()
elseif timer3 == 316 then
bomber3()
elseif timer3 == 318 then
bomber3()
end
end
function bomber3()	
	pilot = World_GetPlayerAt(World_GetRand(1, 2))	 	
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(49,68), "green_marker"))
	targets = Util_GetPosition(Marker_FromName("marker"..World_GetRand(49,68), "green_marker"))
	Cmd_Ability(pilot, ABILITY.CW.TYPHOON_ROCKET, target, targets, true)
end

function Air_RaidCombo()
if timer3 == 300 then
bomber2()
EventCue_Create(CUE.NORMAL, LOCSTRINGS.AIRRAID, LOCSTRINGS.AIRRAID)
elseif timer3 == 302 then
bomber3()
elseif timer3 == 304 then
bomber2()
elseif timer3 == 306 then
bomber3()
elseif timer3 == 308 then
bomber2()
elseif timer3 == 310 then
bomber3()
elseif timer3 == 312 then
bomber2()
elseif timer3 == 314 then
bomber3()
elseif timer3 == 316 then
bomber2()
elseif timer3 == 318 then
bomber3()
end
end

--gives axis players King Tigers
function TigerACE(playerid)
	local spawnpos = marker9
	local targetpos = marker10
	
	if playerid == player3 then
		spawnpos = marker9
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(10,11), "yellow_marker"))
	elseif playerid == player4 then
		spawnpos = marker9
		targetpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(10,11), "yellow_marker"))
	end

	local sg_reinf = SGroup_CreateIfNotFound("sg_reinf")
	SGroup_Clear(sg_reinf)
		
	Util_CreateSquads(playerid, sg_reinf, SBP.AXIS.KING_TIGER, spawnpos, nil, 1) 
	Cmd_Move(sg_reinf, Util_GetPosition(targetpos), 15)
		 
	if Player_GetID(Game_GetLocalPlayer()) == Player_GetID(playerid) then		
		EventCue_Create(CUE.NORMAL, LOCSTRINGS.REINFORCEMENTS2, LOCSTRINGS.REINFORCEMENTS2)
		UI_CreateMinimapBlip(spawnpos, 20, BT_GeneralPing)
	end
end

--checks conditons for counter attacks and calls them
function CounterAttacks()

	if counter == 2 then
	if Axcounter == 1 then
	AxisCounterAttack()
	end
	end
	if counter == 2 then
	if Alcounter == 1 then
	AlliesCounterAttack()
	end
	end

end

function AxisCounterAttack()
	local pointnum = 0


	if EGroup_IsCapturedByPlayer(eg_ONE, player3, ANY) or EGroup_IsCapturedByPlayer(eg_ONE, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWO, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWO, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_THREE, player3, ANY) or EGroup_IsCapturedByPlayer(eg_THREE, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_FOUR, player3, ANY) or EGroup_IsCapturedByPlayer(eg_FOUR, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_FIVE, player3, ANY) or EGroup_IsCapturedByPlayer(eg_FIVE, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_SIX, player3, ANY) or EGroup_IsCapturedByPlayer(eg_SIX, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_SEVEN, player3, ANY) or EGroup_IsCapturedByPlayer(eg_SEVEN, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_EIGHT, player3, ANY) or EGroup_IsCapturedByPlayer(eg_EIGHT, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_NINE, player3, ANY) or EGroup_IsCapturedByPlayer(eg_NINE, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TEN, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TEN, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_ELEVEN, player3, ANY) or EGroup_IsCapturedByPlayer(eg_ELEVEN, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWELVE, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWELVE, player4, ANY) then
	pointnum = pointnum + 1	
	end
	if EGroup_IsCapturedByPlayer(eg_THIRTEEN, player3, ANY) or EGroup_IsCapturedByPlayer(eg_THIRTEEN, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_FOURTEEN, player3, ANY) or EGroup_IsCapturedByPlayer(eg_FOURTEEN, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_FIFTEEN, player3, ANY) or EGroup_IsCapturedByPlayer(eg_FIFTEEN, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_SIXTEEN, player3, ANY) or EGroup_IsCapturedByPlayer(eg_SIXTEEN, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_SEVENTEEN, player3, ANY) or EGroup_IsCapturedByPlayer(eg_SEVENTEEN, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_EIGHTEEN, player3, ANY) or EGroup_IsCapturedByPlayer(eg_EIGHTEEN, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_NINETEEN, player3, ANY) or EGroup_IsCapturedByPlayer(eg_NINETEEN, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWENTY, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTY, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWENTYONE, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYONE, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWENTYTWO, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYTWO, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWENTYTHREE, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYTHREE, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWENTYFOUR, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYFOUR, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWENTYFIVE, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYFIVE, player4, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWENTYSIX, player3, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYSIX, player4, ANY) then
	pointnum = pointnum + 1
	end


	if pointnum == 7 then
	Ax_Counter()
	end
	if pointnum == 6 then
	Ax_Counter()
	end
	if pointnum == 5 then
	Ax_Counter()
	end
	if pointnum == 4 then
	Ax_Counter()
	end
	if pointnum == 3 then
	Ax_Counter()
	end
	if pointnum == 2 then
	Ax_Counter()
	end
	if pointnum == 1 then
	Ax_Counter()
	end
	if pointnum == 0 then
	Ax_Counter()
	end

end

--activates axis counter attack
function Ax_Counter()
	Axcounter = Axcounter + 1
	
	local spawnpos = marker12
	
	spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	

	local sg_reinf = SGroup_CreateIfNotFound("sg_reinf")
	SGroup_Clear(sg_reinf)
	local sg_reinfTWO = SGroup_CreateIfNotFound("sg_reinfTWO")
	SGroup_Clear(sg_reinfTWO)
	
	if plyerTEAMThr == 4 then	
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.OFFICER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.KNIGHTSCROSS, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.STORMTROOPER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.SNIPER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.NEBELWERFER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.PUMA, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.PAK_38, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.HALFTRACK_FLAME, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.STUG, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.PANZER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.TIGER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))	
	else
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.KETTENRAD, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.FALLSCHIRMJAGER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.PANZERGRENADIER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.ASSAULTGRENADIER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.ARMOURCAR_222, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.ARMOURCAR_223, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.HALFTRACK_SNIPER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.HALFTRACK_251, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.MARDER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.PANZER_SUPPORT, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.JAGDPANTHER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	end

	if plyerTEAMFor == 4 then
	Util_CreateSquads(player4, sg_reinfTWO, SBP.AXIS.HEAVYMG, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player4, sg_reinfTWO, SBP.AXIS.KNIGHTSCROSS, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player4, sg_reinfTWO, SBP.AXIS.STORMTROOPER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player4, sg_reinfTWO, SBP.AXIS.SNIPER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player4, sg_reinfTWO, SBP.AXIS.MOTORCYCLE, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player4, sg_reinfTWO, SBP.AXIS.PUMA, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player4, sg_reinfTWO, SBP.AXIS.PAK_38, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player4, sg_reinfTWO, SBP.AXIS.HALFTRACK_STUKA, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player4, sg_reinfTWO, SBP.AXIS.OSTWIND, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player4, sg_reinfTWO, SBP.AXIS.PANZER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player4, sg_reinfTWO, SBP.AXIS.PANTHER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))	
	else
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.PANZERGRENADIER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.TANKBUSTERS, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.HEAVYMG, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.MORTAR, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.LUFTWAFFE, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.ARMOURCAR_221, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.WIRBLEWIND, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.HETZER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.HUMMEL, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.BERGETIGER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	Util_CreateSquads(player3, sg_reinf, SBP.ELITE.PANTHER, spawnpos, nil, 1)
		spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(12,21), "orange_marker"))
	end	

	Cmd_Move(sg_reinf, Util_GetPosition(marker8), 15)
	Cmd_Move(sg_reinfTWO, Util_GetPosition(marker7), 15)

		
		Util_GlobalMessage(LOCSTRINGS.AXCOUNTER, 5)

	PlayerTHREESpecial()
	PlayerFOURSpecial()

	
end

--checks for allied counter attack
function AlliesCounterAttack()
	local pointnum = 0


	if EGroup_IsCapturedByPlayer(eg_ONE, player1, ANY) or EGroup_IsCapturedByPlayer(eg_ONE, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWO, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWO, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_THREE, player1, ANY) or EGroup_IsCapturedByPlayer(eg_THREE, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_FOUR, player1, ANY) or EGroup_IsCapturedByPlayer(eg_FOUR, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_FIVE, player1, ANY) or EGroup_IsCapturedByPlayer(eg_FIVE, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_SIX, player1, ANY) or EGroup_IsCapturedByPlayer(eg_SIX, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_SEVEN, player1, ANY) or EGroup_IsCapturedByPlayer(eg_SEVEN, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_EIGHT, player1, ANY) or EGroup_IsCapturedByPlayer(eg_EIGHT, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_NINE, player1, ANY) or EGroup_IsCapturedByPlayer(eg_NINE, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TEN, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TEN, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_ELEVEN, player1, ANY) or EGroup_IsCapturedByPlayer(eg_ELEVEN, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWELVE, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWELVE, player2, ANY) then
	pointnum = pointnum + 1
	end	
	if EGroup_IsCapturedByPlayer(eg_THIRTEEN, player1, ANY) or EGroup_IsCapturedByPlayer(eg_THIRTEEN, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_FOURTEEN, player1, ANY) or EGroup_IsCapturedByPlayer(eg_FOURTEEN, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_FIFTEEN, player1, ANY) or EGroup_IsCapturedByPlayer(eg_FIFTEEN, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_SIXTEEN, player1, ANY) or EGroup_IsCapturedByPlayer(eg_SIXTEEN, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_SEVENTEEN, player1, ANY) or EGroup_IsCapturedByPlayer(eg_SEVENTEEN, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_EIGHTEEN, player1, ANY) or EGroup_IsCapturedByPlayer(eg_EIGHTEEN, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_NINETEEN, player1, ANY) or EGroup_IsCapturedByPlayer(eg_NINETEEN, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWENTY, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTY, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWENTYONE, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYONE, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWENTYTWO, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYTWO, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWENTYTHREE, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYTHREE, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWENTYFOUR, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYFOUR, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWENTYFIVE, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYFIVE, player2, ANY) then
	pointnum = pointnum + 1
	end
	if EGroup_IsCapturedByPlayer(eg_TWENTYSIX, player1, ANY) or EGroup_IsCapturedByPlayer(eg_TWENTYSIX, player2, ANY) then
	pointnum = pointnum + 1
	end
	

	if pointnum == 7 then
	AL_Counter()
	end
	if pointnum == 6 then
	AL_Counter()
	end
	if pointnum == 5 then
	AL_Counter()
	end
	if pointnum == 4 then
	AL_Counter()
	end
	if pointnum == 3 then
	AL_Counter()
	end
	if pointnum == 2 then
	AL_Counter()
	end
	if pointnum == 1 then
	AL_Counter()
	end
	if pointnum == 0 then
	AL_Counter()
	end

end

function AL_Counter()
	Alcounter = Alcounter + 1

	local spawnpos = marker69
	
	spawnpos = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposOne = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposTwo = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposThree = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposFour = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposFive = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposSix = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposSeven = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposEight = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposNine = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposTen = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))

	spawnposB = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposBOne = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposBTwo = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposBThree = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposBFour = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposBFive = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposBSix = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposBSeven = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposBEight = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposBNine = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))
	spawnposBTen = Util_GetPosition(Marker_FromName("marker"..World_GetRand(69,78), "cyan_marker"))	


	local sg_reinf = SGroup_CreateIfNotFound("sg_reinf")
	SGroup_Clear(sg_reinf)
	local sg_reinfTWO = SGroup_CreateIfNotFound("sg_reinfTWO")
	SGroup_Clear(sg_reinfTWO)
	
	if plyerTEAMONE == 2 then	
	Util_CreateSquads(player1, sg_reinf, SBP.ALLIES.OFFICER, spawnpos, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.ALLIES.RIFLEMEN, spawnposOne, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.ALLIES.RANGER, spawnposTwo, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.ALLIES.SNIPER, spawnposThree, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.ALLIES.AT_57MM, spawnposFour, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.ALLIES.GREYHOUND, spawnposFive, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.ALLIES.GREYHOUND, spawnposSix, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.ALLIES.HALFTRACK, spawnposSeven, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.ALLIES.CROCODILE, spawnposEight, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.ALLIES.SHERMAN, spawnposNine, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.ALLIES.PERSHING, spawnposTen, nil, 1)
	else
	Util_CreateSquads(player1, sg_reinf, SBP.CW.CAPTAIN, spawnpos, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.TOMMIES, spawnposOne, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.COMMANDOS, spawnposTwo, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.COMMANDOS_SNIPER, spawnposThree, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.BREN_CARRIER, spawnposFour, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.TETRARCH, spawnposFive, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.STUART, spawnposSix, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.CROMWELL, spawnposSeven, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.COMMANDOS_JEEP, spawnposEight, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.FIREFLY, spawnposNine, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.CHURCHILL_CROC, spawnposTen, nil, 1)
	end	


	if plyerTEAMTWO == 2 then
	Util_CreateSquads(player2, sg_reinfTWO, SBP.ALLIES.JEEP, spawnposB, nil, 1)
	Util_CreateSquads(player2, sg_reinfTWO, SBP.ALLIES.RANGER, spawnposBOne, nil, 1)
	Util_CreateSquads(player2, sg_reinfTWO, SBP.ALLIES.HEAVYMG, spawnposBTwo, nil, 1)
	Util_CreateSquads(player2, sg_reinfTWO, SBP.ALLIES.SNIPER, spawnposBThree, nil, 1)
	Util_CreateSquads(player2, sg_reinfTWO, SBP.ALLIES.AT_57MM, spawnposBFour, nil, 1)
	Util_CreateSquads(player2, sg_reinfTWO, SBP.ALLIES.AT_57MM, spawnposBFive, nil, 1)
	Util_CreateSquads(player2, sg_reinfTWO, SBP.ALLIES.GREYHOUND, spawnposBSix, nil, 1)
	Util_CreateSquads(player2, sg_reinfTWO, SBP.ALLIES.HALFTRACK, spawnposBSeven, nil, 1)
	Util_CreateSquads(player2, sg_reinfTWO, SBP.ALLIES.CALLIOPE, spawnposBEight, nil, 1)
	Util_CreateSquads(player2, sg_reinfTWO, SBP.ALLIES.SHERMAN, spawnposBNine, nil, 1)
	Util_CreateSquads(player2, sg_reinfTWO, SBP.ALLIES.M10, spawnposBTen, nil, 1)
	else
	Util_CreateSquads(player1, sg_reinf, SBP.CW.LIEUTENANT, spawnpos, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.SAPPER, spawnposOne, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.COMMANDOS_MG, spawnposTwo, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.VICKERSMG, spawnposThree, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.BREN_CARRIER, spawnposFour, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.TETRARCH, spawnposFive, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.COMMANDOS_JEEP, spawnposSix, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.COMMAND_CROMWELL, spawnposSeven, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.CHURCHILL_AVRE, spawnposEight, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.FIREFLY, spawnposNine, nil, 1)
	Util_CreateSquads(player1, sg_reinf, SBP.CW.CHURCHILL, spawnposTen, nil, 1)
	end

	Cmd_Move(sg_reinf, Util_GetPosition(marker4), 15)	
	Cmd_Move(sg_reinfTWO, Util_GetPosition(marker3), 15)

		
		Util_GlobalMessage(LOCSTRINGS.ALCOUNTER, 5)
	
	PlayerONESpecial()
	PlayerTWOSpecial()
	
end

--allows player one acces to the four unuseable tanks next to there base
function PlayerONESpecial()

	SGroup_SetPlayerOwner( sg_Croc, player1 )
	SGroup_SetPlayerOwner( sg_Pershing, player1 )
	SGroup_SetPlayerOwner( sg_ShermanONE, player1 )
	SGroup_SetPlayerOwner( sg_ShermanTWO, player1 )	
	Cmd_Move(sg_Croc, Util_GetPosition(marker4), 15)	
	Cmd_Move(sg_Pershing, Util_GetPosition(marker3), 15)
	Cmd_Move(sg_ShermanONE, Util_GetPosition(marker4), 15)	
	Cmd_Move(sg_ShermanTWO, Util_GetPosition(marker3), 15)
end

--gives player two a large supply drop
function PlayerTWOSpecial()

	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(92,104), "blue_marker"))
	Cmd_Ability(player2, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(92,104), "blue_marker"))
	Cmd_Ability(player2, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(92,104), "blue_marker"))
	Cmd_Ability(player2, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(92,104), "blue_marker"))
	Cmd_Ability(player2, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(92,104), "blue_marker"))
	Cmd_Ability(player2, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(92,104), "blue_marker"))
	Cmd_Ability(player2, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(92,104), "blue_marker"))
	Cmd_Ability(player2, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(92,104), "blue_marker"))
	Cmd_Ability(player2, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(92,104), "blue_marker"))
	Cmd_Ability(player2, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(92,104), "blue_marker"))
	Cmd_Ability(player2, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(92,104), "blue_marker"))
	Cmd_Ability(player2, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(92,104), "blue_marker"))
	Cmd_Ability(player2, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(92,104), "blue_marker"))
	Cmd_Ability(player2, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)

end

--gives player three a huge infusion of basic infantry grenadiers
function PlayerTHREESpecial()

	local sg_reinf = SGroup_CreateIfNotFound("sg_reinf")
	SGroup_Clear(sg_reinf)
	local sg_reinfTWO = SGroup_CreateIfNotFound("sg_reinfTWO")
	SGroup_Clear(sg_reinfTWO)
	
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.GRENADIER, marker22, nil, 1)
	Util_CreateSquads(player3, sg_reinfTWO, SBP.AXIS.GRENADIER, marker23, nil, 1)
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.GRENADIER, marker24, nil, 1)
	Util_CreateSquads(player3, sg_reinfTWO, SBP.AXIS.GRENADIER, marker25, nil, 1)
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.GRENADIER, marker26, nil, 1)
	Util_CreateSquads(player3, sg_reinfTWO, SBP.AXIS.GRENADIER, marker27, nil, 1)
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.GRENADIER, marker28, nil, 1)
	Util_CreateSquads(player3, sg_reinfTWO, SBP.AXIS.GRENADIER, marker29, nil, 1)
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.GRENADIER, marker30, nil, 1)	
	Util_CreateSquads(player3, sg_reinfTWO, SBP.AXIS.GRENADIER, marker31, nil, 1)
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.GRENADIER, marker32, nil, 1)
	Util_CreateSquads(player3, sg_reinfTWO, SBP.AXIS.GRENADIER, marker33, nil, 1)
	Util_CreateSquads(player3, sg_reinf, SBP.AXIS.GRENADIER, marker34, nil, 1)	
	Util_CreateSquads(player3, sg_reinfTWO, SBP.AXIS.GRENADIER, marker35, nil, 1)

	Cmd_Move(sg_reinf, Util_GetPosition(marker7), 15)
	Cmd_Move(sg_reinfTWO, Util_GetPosition(marker8), 15)
end

--gives player four a large supply drop at the air field behind there base
function PlayerFOURSpecial()

	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(36,48), "yellow_marker"))
	Cmd_Ability(player4, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(36,48), "yellow_marker"))
	Cmd_Ability(player4, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(36,48), "yellow_marker"))
	Cmd_Ability(player4, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(36,48), "yellow_marker"))
	Cmd_Ability(player4, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(36,48), "yellow_marker"))
	Cmd_Ability(player4, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(36,48), "yellow_marker"))
	Cmd_Ability(player4, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(36,48), "yellow_marker"))
	Cmd_Ability(player4, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(36,48), "yellow_marker"))
	Cmd_Ability(player4, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(36,48), "yellow_marker"))
	Cmd_Ability(player4, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(36,48), "yellow_marker"))
	Cmd_Ability(player4, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(36,48), "yellow_marker"))
	Cmd_Ability(player4, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(36,48), "yellow_marker"))
	Cmd_Ability(player4, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)
	target = Util_GetPosition(Marker_FromName("marker"..World_GetRand(36,48), "yellow_marker"))
	Cmd_Ability(player4, ABILITY.COMMANDER_TREE.ALLIES.SUPPLY_DROP, target, target, true)

end

function Util_CreateLocString(text)
	local tmpstr = LOC(text)
	tmpstr[1] = text
	return tmpstr
end

function Util_GlobalMessage(title, displaytime)
	local _ShowMsg = function()
		CTRL.Game_TextTitleFade(title, 0, displaytime, 2, "")
		CTRL.WAIT()
	end

	Util_StartIntel(_ShowMsg)
end
