Mission event file for Space Marine Stronghold mission
Guide
/
Mission event file for Space Marine Stronghold mission
Aggiornato 4 years ago di Merric

--[[ IMPORTS ]]

import("ScarUtil.scar") import("WXPScarUtil.scar")


--[[ GAME SETUP ]]

-- Orbital Relay Fire control [[the random firing of the orbital relay while under AI control]]. -- Orbital Relay Scar feature [[setting up the button and what happens when the player clicks on it]]. -- Keeping the AI moral up [[makes units invulnerable to moral loss for the AI]] -- Moral Loss [[Rule concerning the capture of the relic/temple area and the subsequent loss of moral for the SM]]. -- AI Definition [[what the AI can and can't do]] -- Spawning and Upgrading Things on the map -- upgrading SM held strat points and relic -- Spawning Armies [[should be all of the AI's armies here]] -- Initial Attack -- Whirlwind Attack -- Patrols -- Space Marine Infantry Reinforcement -- Checking where to send reinforcements -- Sending a raid on the enemy player -- Scouts raiding the player -- Assault Squads raids -- Probing [[creates and sends on patrols an array of skull probes to pester the player's stealth units]] -- Chatty AI --Orbital relay contact -- Relic contact --Reinforcement contact -- Static Movement [[makes units move around in certain areas to appear more dynamic]] -- Breach right event -- Breach left event -- Breach main bastion event -- Primary Objective - destroy the space marine HQ -- Secondary Objective - stop infantry reinforcements -- Secondary Objective - capture orbital relay -- Secondary Objective -use orbital relay -- Secondary Objective - capture relic/break moral

--[[ the OnGameSetup() function is mandatory! ]] function OnGameSetup()

--[[defining the name of the player's faction]]
if MetaMap_GetPlayerRaceName() == "chaos_marine_race" then
	
	factionname = "$690014"
	colorscheme = "default_1"
	
	g_Player1 = Setup_Player(0, factionname, MetaMap_GetPlayerRaceName(), 1)
	Misc_PlayerTeamColor(g_Player1, colorscheme)
	
	g_Player4 = Setup_Player(3, factionname, MetaMap_GetPlayerRaceName(), 1)
	Misc_PlayerTeamColor(g_Player4,colorscheme)

	g_Player5 = Setup_Player(4, factionname, MetaMap_GetPlayerRaceName(), 1)
	Misc_PlayerTeamColor(g_Player5,colorscheme)

	g_Player6 = Setup_Player(5, factionname, MetaMap_GetPlayerRaceName(), TEAM_NEUTRAL)
	Misc_PlayerTeamColor(g_Player6,colorscheme)
	
elseif MetaMap_GetPlayerRaceName() == "eldar_race" then

	factionname = "$690012"
	colorscheme = "default_5"
	
	g_Player1 = Setup_Player(0, factionname, MetaMap_GetPlayerRaceName(), 1)
	Misc_PlayerTeamColor(g_Player1, colorscheme)
	
	g_Player4 = Setup_Player(3, factionname, MetaMap_GetPlayerRaceName(), 1)
	Misc_PlayerTeamColor(g_Player4,colorscheme)

	g_Player5 = Setup_Player(4, factionname, MetaMap_GetPlayerRaceName(), 1)
	Misc_PlayerTeamColor(g_Player5,colorscheme)

	g_Player6 = Setup_Player(5, factionname, MetaMap_GetPlayerRaceName(), TEAM_NEUTRAL)
	Misc_PlayerTeamColor(g_Player6,colorscheme)
	
elseif MetaMap_GetPlayerRaceName() == "guard_race" then

	factionname = "$690011"
	colorscheme = "default_8"
	
	g_Player1 = Setup_Player(0, factionname, MetaMap_GetPlayerRaceName(), 1)
	g_Player4 = Setup_Player(3, factionname, MetaMap_GetPlayerRaceName(), 1)
	g_Player5 = Setup_Player(4, factionname, MetaMap_GetPlayerRaceName(), 1)
	g_Player6 = Setup_Player(5, factionname, MetaMap_GetPlayerRaceName(), TEAM_NEUTRAL)



elseif MetaMap_GetPlayerRaceName() == "ork_race" then

	factionname = "$690013"
	colorscheme = "default_4"
	
	g_Player1 = Setup_Player(0, factionname, MetaMap_GetPlayerRaceName(), 1)
	Misc_PlayerTeamColor(g_Player1, colorscheme)
	
	g_Player4 = Setup_Player(3, factionname, MetaMap_GetPlayerRaceName(), 1)
	Misc_PlayerTeamColor(g_Player4,colorscheme)

	g_Player5 = Setup_Player(4, factionname, MetaMap_GetPlayerRaceName(), 1)
	Misc_PlayerTeamColor(g_Player5,colorscheme)

	g_Player6 = Setup_Player(5, factionname, MetaMap_GetPlayerRaceName(), TEAM_NEUTRAL)
	Misc_PlayerTeamColor(g_Player6,colorscheme)
	
elseif MetaMap_GetPlayerRaceName() == "space_marine_race" then

	factionname = "$690010"
	colorscheme = "default_0"
	
	g_Player1 = Setup_Player(0, factionname, MetaMap_GetPlayerRaceName(), 1)
	g_Player4 = Setup_Player(3, factionname, MetaMap_GetPlayerRaceName(), 1)
	g_Player5 = Setup_Player(4, factionname, MetaMap_GetPlayerRaceName(), 1)
	g_Player6 = Setup_Player(5, factionname, MetaMap_GetPlayerRaceName(), TEAM_NEUTRAL)

	
elseif MetaMap_GetPlayerRaceName() == "tau_race" then
	
	factionname = "$690015"
	colorscheme = "default_0"
	
	g_Player1 = Setup_Player(0, factionname, MetaMap_GetPlayerRaceName(), 1)
	g_Player4 = Setup_Player(3, factionname, MetaMap_GetPlayerRaceName(), 1)
	g_Player5 = Setup_Player(4, factionname, MetaMap_GetPlayerRaceName(), 1)
	g_Player6 = Setup_Player(5, factionname, MetaMap_GetPlayerRaceName(), TEAM_NEUTRAL)

	
elseif MetaMap_GetPlayerRaceName() == "necron_race" then

	factionname = "$690016"
	colorscheme = "default_0"
	
	g_Player1 = Setup_Player(0, factionname, MetaMap_GetPlayerRaceName(), 1)
	g_Player4 = Setup_Player(3, factionname, MetaMap_GetPlayerRaceName(), 1)
	g_Player5 = Setup_Player(4, factionname, MetaMap_GetPlayerRaceName(), 1)
	g_Player6 = Setup_Player(5, factionname, MetaMap_GetPlayerRaceName(), TEAM_NEUTRAL)


end




g_Player2 = Setup_Player(1, "$690010", "space_marine_race", 2)
Misc_PlayerTeamColor(g_Player2,"default_0")

g_Player3 = Setup_Player(2, "$690010", "space_marine_race", 2)
Misc_PlayerTeamColor(g_Player3,"default_0")


--[[ DEFINE VARIABLES AND TABLES - define any preset values here for later use]] g_firstrun = true g_Jump = false g_Moral = true g_Vehicle = 1 g_Win = false g_Relic = false g_Target = 1 g_Timer = 0 g_Raids = 0 g_HQ_Type = nil g_add_button = false g_Orbital = false g_assault = 0 g_insert1 = true g_insert2 = true g_insert3 = true g_insert4 = true g_insert5 = true g_insert6 = true g_insert7 = true g_insert8 = true g_insert9 = true g_insert10 = true g_Relay_Fired = false g_Strength = 0

--difficulty variable
g_Difficulty = 0

--army iterations
g_Whirlwind_Army_iter = 1
g_Gap_Army_iter = 1
g_CP_Army_iter = 1
g_Mine_Army_iter = 1
g_LP_Army_iter = 1
g_RP_Army_iter = 1
g_Slag_Army_iter = 1
g_Bastion_Army_iter = 1
g_Patrol_Army_A_iter = 1
g_SM_Reinforcement_Army_1_iter = 1
g_SM_Reinforcement_Army_2_iter = 1
g_SM_Reinforcement_Army_3_iter = 1
g_SM_Reinforcement_Army_4_iter = 1
g_FLP_Army_iter = 1
g_FRP_Army_iter = 1
g_Scout_Army_iter = 1
g_Snow_Army_iter = 1
g_Assault_Army_iter = 1
g_Initial_Raid_iter = 1

--Army size variables
g_Gap = 0
g_CP = 0
g_Mine = 0
g_LP = 0
g_RP = 0
g_Slag = 0
g_Bastion = 0
g_Patrol_A = 0

--patrol iteration
g_Patrol_Move = 0

--space marine reinforcement
g_SM_Reinforcement = 0
g_One = false
g_Two = false
g_Three = false

--whether a spot has been abandonned
g_RP_Abandon = false
g_Bastion_Abandon = false
g_LP_Abandon = false
g_CP_Abandon = false


-- generator markers start at 0
g_bonus_gen_counter = 0

-- turrer markers start at 6
g_bonus_turret_counter = 6

--[[ define the "enemy" who will win if the player 'loses' ]] g_enemy = g_Player2

--[[Win condition Objective]]

end


--[[ the OnGameRestore() function is mandatory!, this will only get called after loading a game ]]

function OnGameRestore()

end


--[[ ON INITIALIZATION ]]

function OnInit()

--[[ RESEARCH LEVEL - sets the research level of the mission, locks researches, squads, and buildings for the appropriate mission number DOW specific!
 sets the research level of the mission, locks researches, squads, and buildings]]
Rule_SetResearchLevel( 4 )
	
	
--[[ NIS PRESETS - turn off event cues, set the viewable space to black (faded out) and preset letterboxing 
turn off event cues, set the viewable space to black (faded out) and preset letterboxing ]]
WXP_OpeningNISPreset()	
	
--[[ START THE MUSIC ]]
-- call the function to load the jukebox with tunes]]
Rule_SetupMusicPlaylist()	

--[[ SET AI - call the function to set the pregame state of the AI 
call the function to set the pregame state of the AI ]]
Rule_PresetAI()		
	
--[[ START NIS - calls the NIS function located in the MissionName.nis file 
calls the NIS function located in the MissionName.nis file ]]	
Util_StartNIS( EVENTS.NIS_Opening )


	
--[[ GET THE START PLAY MISSION READY TO ROLL ]]
Rule_Add( Rule_GameStart )	


end

--[[ the Scar_AddInit(OnInit) function is mandatory! This registers your init function with scar. ]] Scar_AddInit(OnInit)


--[[ GAME RESTRICTIONS ]]

--[[ Disables, enables, and grants research items ]]

function Rule_SetResearchLevel( resLevel )

--[[ WXP Specific ]]
WXP_Restrict( resLevel )

end


--[[ MUSIC ]]

function Rule_SetupMusicPlaylist()

--music
t_music = {"MU_IG_STR_SpaceMarine", "MU_IG_STR_SpaceMarine_perc", "MU_IG_STR_SpaceMarine_perc_brass", "MU_IG_STR_SpaceMarine_perc_str"}

Playlist_Manager( PC_Music, t_music, true, true , {20, 40})


--ambient sound
t_ambient_sound = {"Snowy_wind_2"}


Playlist_Manager( PC_Ambient, t_ambient_sound, true, true , {2, 4})

end


--[[ PRESET AI ]]

function Rule_PresetAI()

--Cpu_EnableAll(false)
Cpu_Enable(g_Player3, true)
Cpu_Enable(g_Player2, false)	

end


--[[ START PLAY ]]

--[[ NOW TO KICK OFF THE ACTUAL MISSION ONCE THE OPENING NIS IS DONE ]]

function Rule_GameStart()

if g_firstrun then
	
	g_Strength = MetaMap_GetTerritoryMilitaryStrength(MetaMap_GetDefendingTerritoryIndex())
		
	--[[ PREACTION ]]
	
	--[[ DIFFICULTY LEVEL - gets the difficulty level from the UI and passes it into the function]]
	Rule_SetDifficultyLevel( Difficulty_Get() )
	
	
	--[[ Get the AI doing whatever after the NIS is over ]]
	Rule_StartAI()
	Rule_AddOneShot(Rule_Setup_AI, 200)
					 
	--[[Despawning Nis objects]]
	Rule_AddOneShot(Rule_Despawn, 1)
	
	
	--[[Upgrade towers and points]]
	Rule_AddOneShot(Rule_Upgrade_SM_Points, 0)
--	Rule_AddOneShot(Rule_Create_SM_Turrets, 0)
	Rule_AddOneShot(Rule_Create_SM_Mines, 0)
	Rule_AddOneShot(Rule_Create_SM_Buildings, 0)
	Rule_AddOneShot(Rule_Create_Player_Buildings, 0)
	


	--[[ Set up a Win Check ]]
	Rule_AddInterval(Rule_EndGame_Win, 10)
	
	--[[ Set up a Lose Check ]]
	Rule_AddInterval(Rule_EndGameLose, 10)		

		
--	Rule_AddOneShot(test, 30)
	
	
	--[[ Clean up ]]
	Rule_Remove(Rule_GameStart)
	

end

end


--[[ DIFFICULTY ]]

function Rule_SetDifficultyLevel( difficultyLevel )

--[[ STATIC MODIFIERS ]]
-- Use this space to set any Static Modifiers. ifiers that will not change with the difficulty setting.

-- easy
if difficultyLevel == DIFFICULTY_EASY then

	g_Difficulty = 1
	

	
	--[[force commander]]
	
	--health and armor
	local ModID7 = Modifier_Create(MAT_EntityType , "health_maximum_modifier", MUT_Multiplication, false, 10 , "force_commander")
	Modifier_ApplyToPlayer( ModID7, g_Player2  )
	
	local ModID8 = Modifier_Create(MAT_EntityType, "armour_modifier", MUT_Multiplication, false, 1.2, "force_commander")
	Modifier_ApplyToPlayer( ModID8, g_Player2)
	
	--ranged weapon
	local ModID9 = Modifier_Create(MAT_WeaponType, "max_damage_weapon_modifier", MUT_Multiplication, false, 1.5, "space_marine_bolt_pistol_forcecommander")
	Modifier_ApplyToPlayer( ModID9, g_Player2)
	
	local ModID10 = Modifier_Create(MAT_WeaponType, "min_damage_weapon_modifier", MUT_Multiplication, false, 1.5, "space_marine_bolt_pistol_forcecommander")
	Modifier_ApplyToPlayer( ModID10, g_Player2)
	
	--melee weapon
	local ModID11 = Modifier_Create(MAT_WeaponType, "min_damage_weapon_modifier", MUT_Multiplication, false, 1.5, "space_marine_power_sword_force_commander")
	Modifier_ApplyToPlayer( ModID11, g_Player2)
	
	local ModID12 = Modifier_Create(MAT_WeaponType, "min_damage_weapon_modifier", MUT_Multiplication, false, 1.5, "space_marine_power_sword_force_commander")
	Modifier_ApplyToPlayer( ModID12, g_Player2)
	

	
-- medium
elseif difficultyLevel == DIFFICULTY_NORMAL then

	g_Difficulty = 2
	
	--[[force commander]]
	
	--health and armor
	local ModID7 = Modifier_Create(MAT_EntityType , "health_maximum_modifier", MUT_Multiplication, false, 10 , "force_commander")
	Modifier_ApplyToPlayer( ModID7, g_Player2  )
	
	local ModID8 = Modifier_Create(MAT_EntityType, "armour_modifier", MUT_Multiplication, false, 1.2, "force_commander")
	Modifier_ApplyToPlayer( ModID8, g_Player2)
	
	--ranged weapon
	local ModID9 = Modifier_Create(MAT_WeaponType, "max_damage_weapon_modifier", MUT_Multiplication, false, 1.5, "space_marine_bolt_pistol_forcecommander")
	Modifier_ApplyToPlayer( ModID9, g_Player2)
	
	local ModID10 = Modifier_Create(MAT_WeaponType, "min_damage_weapon_modifier", MUT_Multiplication, false, 1.5, "space_marine_bolt_pistol_forcecommander")
	Modifier_ApplyToPlayer( ModID10, g_Player2)
	
	--melee weapon
	local ModID11 = Modifier_Create(MAT_WeaponType, "min_damage_weapon_modifier", MUT_Multiplication, false, 1.5, "space_marine_power_sword_force_commander")
	Modifier_ApplyToPlayer( ModID11, g_Player2)
	
	local ModID12 = Modifier_Create(MAT_WeaponType, "min_damage_weapon_modifier", MUT_Multiplication, false, 1.5, "space_marine_power_sword_force_commander")
	Modifier_ApplyToPlayer( ModID12, g_Player2)
	
	
	print("g_Difficulty" ..g_Difficulty)
	
-- hard
elseif difficultyLevel == DIFFICULTY_HARD then
	
	g_Difficulty = 3
	
			--[[force commander]]
	
	--health and armor
	local ModID7 = Modifier_Create(MAT_EntityType , "health_maximum_modifier", MUT_Multiplication, false, 10 , "force_commander")
	Modifier_ApplyToPlayer( ModID7, g_Player2  )
	
	local ModID8 = Modifier_Create(MAT_EntityType, "armour_modifier", MUT_Multiplication, false, 1.2, "force_commander")
	Modifier_ApplyToPlayer( ModID8, g_Player2)
	
	--ranged weapon
	local ModID9 = Modifier_Create(MAT_WeaponType, "max_damage_weapon_modifier", MUT_Multiplication, false, 1.5, "space_marine_bolt_pistol_forcecommander")
	Modifier_ApplyToPlayer( ModID9, g_Player2)
	
	local ModID10 = Modifier_Create(MAT_WeaponType, "min_damage_weapon_modifier", MUT_Multiplication, false, 1.5, "space_marine_bolt_pistol_forcecommander")
	Modifier_ApplyToPlayer( ModID10, g_Player2)
	
	--melee weapon
	local ModID11 = Modifier_Create(MAT_WeaponType, "min_damage_weapon_modifier", MUT_Multiplication, false, 1.5, "space_marine_power_sword_force_commander")
	Modifier_ApplyToPlayer( ModID11, g_Player2)
	
	local ModID12 = Modifier_Create(MAT_WeaponType, "min_damage_weapon_modifier", MUT_Multiplication, false, 1.5, "space_marine_power_sword_force_commander")
	Modifier_ApplyToPlayer( ModID12, g_Player2)
	
	print("g_Difficulty" ..g_Difficulty)
	
end

end


--[[AI Definition]]

function Rule_Setup_AI()

Cpu_Enable(g_Player3, true)	
Cpu_Enable(g_Player2, false)	

Cpu_EnableComponent(g_Player3, true, CT_Resourcing)
Cpu_EnableComponent(g_Player3, false, CT_BuildBuildings)
Cpu_EnableComponent(g_Player3, true, CT_BuildUnits)
Cpu_EnableComponent(g_Player3, true, CT_BuildResearch)
Cpu_EnableComponent(g_Player3, false, CT_BuildAddOns)
Cpu_EnableComponent(g_Player3, true, CT_Tactics)


Cpu_SetDifficulty(g_Player3,   AD_Standard)


Player_RestrictSquad(g_Player3, "space_marine_squad_servitor")
Player_RestrictSquad(g_Player3, "space_marine_squad_apothecary")
Player_RestrictSquad(g_Player3, "space_marine_squad_assault")
Player_RestrictSquad(g_Player3, "space_marine_squad_chaplain")
Player_RestrictSquad(g_Player3, "space_marine_squad_dreadnought")
Player_RestrictSquad(g_Player3, "space_marine_squad_dreadnought_hellfire")
Player_RestrictSquad(g_Player3, "space_marine_squad_force_commander")
Player_RestrictSquad(g_Player3, "space_marine_squad_land_raider")
Player_RestrictSquad(g_Player3, "space_marine_squad_land_speeder")
Player_RestrictSquad(g_Player3, "space_marine_squad_librarian")
Player_RestrictSquad(g_Player3, "space_marine_squad_predator")
Player_RestrictSquad(g_Player3, "space_marine_squad_rhino")

Player_RestrictSquad(g_Player3, "space_marine_squad_tactical")

Player_RestrictSquad(g_Player3, "space_marine_squad_terminator")
Player_RestrictSquad(g_Player3, "space_marine_squad_terminator_assault")
Player_RestrictSquad(g_Player3, "space_marine_squad_whirlwind")
	

Cpu_SetMaxPercentage(g_Player3, .15)

Rule_AddInterval(Rule_AI_Moral, 5)
Rule_AddOneShot(Rule_Increase_AI, 1000)

end

function Rule_Increase_AI()

-- Cpu_SetDifficulty(g_Player3, AD_Standard) Cpu_SetMaxPercentage(g_Player3, .25)

Player_SetSquadCap(g_Player3, 7)

Rule_AddOneShot(Rule_Increase_AI2, 1000)

end

function Rule_Increase_AI2()

Player_UnRestrictSquad(g_Player3, "space_marine_squad_land_speeder")

Rule_AddOneShot(Rule_Increase_AI3,1000)

end

function Rule_Increase_AI3()

Player_UnRestrictSquad(g_Player3, "space_marine_squad_dreadnought")
Player_UnRestrictSquad(g_Player3, "space_marine_squad_dreadnought_hellfire")
Rule_AddOneShot(Rule_Increase_AI4, 1000)

end

function Rule_Increase_AI4()

Cpu_SetDifficulty(g_Player3,   AD_Hard)

end

function Rule_Despawn()

EGroup_DeSpawn("eg_Smokes")
EGroup_DeSpawn("eg_Pod_Flare")
EGroup_DeSpawn("eg_Pod_Flare2")
EGroup_DeSpawn("eg_EndFire")

--fires
EGroup_DeSpawn("eg_SM_C_Outro1")

--guardsman, ork, space marine bodies
EGroup_DeSpawn("eg_SM_C_Outro2")

--fire and debris
EGroup_DeSpawn("eg_SM_C_Outro3")

end

--[[Precaching]]


--[[ AI ]]

function Rule_StartAI()

Cpu_EnableAll(false)	

end


--[[ TRACK PERSISTENT CHARACTERS ]]

-- this section keeps track of the characters, and controls losing when they die. function Rule_TrackCharacters()

end


--[[ CORE GAME ]]


--[[Spawning and Upgrading Things on the map]]

--[[create the player buildings]]

function Rule_Create_Player_Buildings()

t_Player_Buildings ={

chaos_name = {"eg_Player_HQ"},
chaos_building_blueprint = {"chaos_hq"},
chaos_marker_spawn = {"mkr_Player_HQ"},

eldar_name = {"eg_Player_HQ"},
eldar_building_blueprint = {"eldar_hq"},
eldar_marker_spawn ={"mkr_Player_HQ"}, 

guard_name = {"eg_Player_HQ"},
guard_building_blueprint = {"guard_hq"}, 
guard_marker_spawn ={"mkr_Player_HQ"},

ork_name = {"eg_Player_HQ"},
ork_building_blueprint = {"ork_hq"},
ork_marker_spawn ={"mkr_Player_HQ"},

marines_name = {"eg_Player_HQ"},
marines_building_blueprint = {"space_marine_hq"},
marines_marker_spawn ={"mkr_Player_HQ"},

tau_name = {"eg_Player_HQ"},
tau_building_blueprint = {"tau_hq"},
tau_marker_spawn= {"mkr_Player_HQ"},

necron_name ={"eg_Player_HQ"},
necron_building_blueprint = {"monolith"},
necron_marker_spawn = {"mkr_Player_HQ"},

}

t_Player_Builder_Units = {

chaos_buildername = {"sg_Player_Builder"},
chaos_builder_blueprint = {"chaos_squad_slave"},
chaos_buildermarker_spawn = {"mkr_Player_Builder"},

eldar_buildername = {"sg_Player_Builder"},
eldar_builder_blueprint = {"eldar_squad_bonesinger"},
eldar_buildermarker_spawn ={"mkr_Player_Builder"}, 

guard_buildername = {"sg_Player_Builder"},
guard_builder_blueprint = {"guard_squad_enginseer"}, 
guard_buildermarker_spawn ={"mkr_Player_Builder"},

ork_buildername = {"sg_Player_Builder"},
ork_builder_blueprint = {"ork_squad_grot"},
ork_buildermarker_spawn ={"mkr_Player_Builder"},

marines_buildername = {"sg_Player_Builder"},
marines_builder_blueprint = {"space_marine_squad_servitor"},
marines_buildermarker_spawn ={"mkr_Player_Builder"},

tau_buildername = {"sg_Player_Builder"},
tau_builder_blueprint = {"tau_builder_squad"},
tau_buildermarker_spawn= {"mkr_Player_Builder"},

necron_buildername ={"sg_Player_Builder"},
necron_builder_blueprint = {"necron_builder_scarab_squad"},
necron_buildermarker_spawn = {"mkr_Player_Builder"},
}

if MetaMap_GetPlayerRaceName() == "chaos_marine_race" then

	for i = 1, table.getn(t_Player_Buildings.chaos_name) do
		
		Entity_CreateBuildingMarker(g_Player1, t_Player_Buildings.chaos_name[i], t_Player_Buildings.chaos_building_blueprint[i], t_Player_Buildings.chaos_marker_spawn[i], 1)
		Util_CreateSquadsAtMarkerEx(g_Player1, t_Player_Builder_Units.chaos_buildername[i], t_Player_Builder_Units.chaos_builder_blueprint[i], t_Player_Builder_Units.chaos_buildermarker_spawn[i], 1, 1)
		
		--i'm saving the hq blueprint in order to use it later
		g_HQ_Type = "chaos_hq"
		g_Leader_Type = "chaos_squad_lord_advance_sp"
						
		--To spawn the appropriate bodies during the Nis
		g_Player_Bodies1 = "carnage_chaos_cultist_01"
		g_Player_Bodies2 = "carnage_chaos_cultist_02"
		
		--win/loss
		t_building_exceptions = {
		"chaos_thermo_plasma_generator",
		"chaos_plasma_generator",
		"chaos_turret_bolter",
		"chaos_mine_field"}
		
		t_unit_exceptions = {}
		
	end

elseif MetaMap_GetPlayerRaceName() == "eldar_race" then

	for i = 1, table.getn(t_Player_Buildings.eldar_name) do
	
		Entity_CreateBuildingMarker(g_Player1, t_Player_Buildings.eldar_name[i], t_Player_Buildings.eldar_building_blueprint[i], t_Player_Buildings.eldar_marker_spawn[i], 1)
		Util_CreateSquadsAtMarkerEx(g_Player1, t_Player_Builder_Units.eldar_buildername[i], t_Player_Builder_Units.eldar_builder_blueprint[i], t_Player_Builder_Units.eldar_buildermarker_spawn[i], 1, 1)
	
		--i'm saving the hq blueprint in order to use it later
		g_HQ_Type = "eldar_hq"
		g_Leader_Type = "eldar_squad_farseer_advance_sp"
		
		--To spawn the appropriate bodies during the Nis
		g_Player_Bodies1 = "carnage_eldar_guardians_01"
		g_Player_Bodies2 = "carnage_eldar_guardians_02"
		
		
		--win/loss
		t_building_exceptions = {
		"eldar_advanced_warp_generator",
		"eldar_warp_generator",
		"eldar_support_platform_scatterlaser",
		"eldar_mine_field"}
		
		t_unit_exceptions = {}
	
	end

elseif MetaMap_GetPlayerRaceName() == "guard_race" then

	for i = 1, table.getn(t_Player_Buildings.guard_name) do
	
		Entity_CreateBuildingMarker(g_Player1, t_Player_Buildings.guard_name[i], t_Player_Buildings.guard_building_blueprint[i], t_Player_Buildings.guard_marker_spawn[i], 1)
		Util_CreateSquadsAtMarkerEx(g_Player1, t_Player_Builder_Units.guard_buildername[i], t_Player_Builder_Units.guard_builder_blueprint[i], t_Player_Builder_Units.guard_buildermarker_spawn[i], 1, 1)
		
		--i'm saving the hq blueprint in order to use it later
		g_HQ_Type = "guard_hq"
		g_Leader_Type = "guard_squad_command_squad_advance_sp"
		
		--To spawn the appropriate bodies during the Nis
		g_Player_Bodies1 = "carnage_guard_men_01"
		g_Player_Bodies2 = "carnage_guard_men_02"
		
		--win/loss
		t_building_exceptions = {
		"guard_thermo_plasma",
		"guard_plasma_generator",
		"guard_turret_heavy_bolter",
		"guard_mines"}
		
		t_unit_exceptions = {}
	
	end

elseif MetaMap_GetPlayerRaceName() == "ork_race" then

	for i = 1, table.getn(t_Player_Buildings.ork_name) do
		
		Entity_CreateBuildingMarker(g_Player1, t_Player_Buildings.ork_name[i], t_Player_Buildings.ork_building_blueprint[i], t_Player_Buildings.ork_marker_spawn[i], 1)
		Util_CreateSquadsAtMarkerEx(g_Player1, t_Player_Builder_Units.ork_buildername[i], t_Player_Builder_Units.ork_builder_blueprint[i], t_Player_Builder_Units.ork_buildermarker_spawn[i], 1, 1)
		
		--i'm saving the hq blueprint in order to use it later
		g_HQ_Type = "ork_hq"
		g_Leader_Type = "ork_squad_warboss_advance_sp"
		
		--To spawn the appropriate bodies during the Nis
		g_Player_Bodies1 = "carnage_ork_boyz_01"
		g_Player_Bodies2 = "carnage_ork_boyz_02"
		
		
		--win/loss
		t_building_exceptions = {
		"ork_bigger_generator",
		"ork_generator",
		"ork_waagh_banner",
		"ork_mine_field"}
		
		t_unit_exceptions = {}
		
	end

elseif MetaMap_GetPlayerRaceName() == "space_marine_race" then

	for i = 1, table.getn(t_Player_Buildings.marines_name) do
		
		Entity_CreateBuildingMarker(g_Player1, t_Player_Buildings.marines_name[i], t_Player_Buildings.marines_building_blueprint[i], t_Player_Buildings.marines_marker_spawn[i], 1)
		Util_CreateSquadsAtMarkerEx(g_Player1, t_Player_Builder_Units.marines_buildername[i], t_Player_Builder_Units.marines_builder_blueprint[i], t_Player_Builder_Units.marines_buildermarker_spawn[i], 1, 1)
		
		--i'm saving the hq blueprint in order to use it later
		g_HQ_Type = "space_marine_hq"
		g_Leader_Type = "space_marine_squad_force_commander_advance_sp"
		
		
		--To spawn the appropriate bodies during the Nis
		g_Player_Bodies1 = "carnage_space_marines_01"
		g_Player_Bodies2 = "carnage_space_marines_02"
		
		--win/loss
		t_building_exceptions = {
		"space_marine_thermo_generator",
		"space_marine_generator",
		"space_marine_turret_bolter",
		"space_marine_mine_field"}
		
		t_unit_exceptions = {}
		
		
	end
	
elseif MetaMap_GetPlayerRaceName() == "tau_race" then
	
	for i = 1, table.getn(t_Player_Buildings.tau_name) do
		
		Entity_CreateBuildingMarker(g_Player1, t_Player_Buildings.tau_name[i], t_Player_Buildings.tau_building_blueprint[i], t_Player_Buildings.tau_marker_spawn[i], 1)
		Util_CreateSquadsAtMarkerEx(g_Player1, t_Player_Builder_Units.tau_buildername[i], t_Player_Builder_Units.tau_builder_blueprint[i], t_Player_Builder_Units.tau_buildermarker_spawn[i], 1, 1)
		
		--i'm saving the hq blueprint in order to use it later
		g_HQ_Type = "tau_hq"
		g_Leader_Type = "tau_commander_squad_advance_sp"
		
		
		--To spawn the appropriate bodies during the Nis
		g_Player_Bodies1 = "carnage_tau_02"
		g_Player_Bodies2 = "carnage_tau_04"
		
		--win/loss
		t_building_exceptions = {
		"tau_thermoplasma_generator",
		"tau_plasma_generator",}

		
		t_unit_exceptions = {}
		
	end
	
elseif MetaMap_GetPlayerRaceName() == "necron_race" then
	
	for i = 1, table.getn(t_Player_Buildings.necron_name) do
		
		Entity_CreateBuildingMarker(g_Player1, t_Player_Buildings.tau_name[i], t_Player_Buildings.necron_building_blueprint[i], t_Player_Buildings.necron_marker_spawn[i], 1)
		Util_CreateSquadsAtMarkerEx(g_Player1, t_Player_Builder_Units.necron_buildername[i], t_Player_Builder_Units.necron_builder_blueprint[i], t_Player_Builder_Units.necron_buildermarker_spawn[i], 1, 1)
		
		--i'm saving the hq blueprint in order to use it later
		g_HQ_Type = "monolith"
		g_Leader_Type = "necron_lord_squad_advance_sp"
		
		--To spawn the appropriate bodies during the Nis
		g_Player_Bodies1 = "carnage_necron_02"
		g_Player_Bodies2 = "carnage_necron_03"
		
		--win/loss
		t_building_exceptions = {
		"necron_thermoplasma_generator",
		"necron_plasma_generator",
		"necron_turret",}
		
		t_unit_exceptions = {}
		
	end
	
end

--blueprint table with the relevant hq
t_blueprinthq = Util_MakeBlueprintTable(g_HQ_Type)
t_blueprintleader = Util_MakeBlueprintTable(g_Leader_Type)
	
	
--determine race specific blueprints to be looked for when creating forward base
if MetaMap_GetPlayerRaceName() == "chaos_marine_race" then
	
	g_bonus_generator = "chaos_plasma_generator"
	g_bonus_turret = "chaos_turret_bolter"
	g_bonus_barracks = "chaos_temple"
	g_bonus_barracks2 = 0 --value on used for tau kroot nest, dummy value for all other races, like the Tau turret.
	g_bonus_research = "chaos_armoury"
	
elseif MetaMap_GetPlayerRaceName() == "eldar_race" then
	
	g_bonus_generator = "eldar_warp_generator"
	g_bonus_turret = "eldar_support_platform_scatterlaser"
	g_bonus_barracks = "eldar_aspect_portal"
	g_bonus_barracks2 = 0 --value on used for tau kroot nest, dummy value for all other races, like the Tau turret.
	g_bonus_research = "eldar_soul_shrine"
			
elseif MetaMap_GetPlayerRaceName() == "guard_race" then

	g_bonus_generator = "guard_plasma_generator"
	g_bonus_turret = "guard_turret_heavy_bolter"
	g_bonus_barracks = "guard_infantry"
	g_bonus_barracks2 = 0 --value on used for tau kroot nest, dummy value for all other races, like the Tau turret.
	g_bonus_research = "guard_tactica"
	
elseif MetaMap_GetPlayerRaceName() == "ork_race" then

	g_bonus_generator = "ork_generator"
	g_bonus_turret = "ork_waagh_banner"
	g_bonus_barracks = "ork_boy_hut"
	g_bonus_barracks2 = 0 --value on used for tau kroot nest, dummy value for all other races, like the Tau turret.
	g_bonus_research = "ork_pile_o_guns"
	
elseif MetaMap_GetPlayerRaceName() == "space_marine_race" then
	
	g_bonus_generator = "space_marine_generator"
	g_bonus_turret = "space_marine_turret_bolter"
	g_bonus_barracks = "space_marine_barracks"
	g_bonus_barracks2 = 0 --value on used for tau kroot nest, dummy value for all other races, like the Tau turret.
	g_bonus_research = "space_marine_armoury"
	
elseif MetaMap_GetPlayerRaceName() == "tau_race" then
	
	g_bonus_generator = "tau_plasma_generator"
	g_bonus_turret = 0  --tau have no turrets, so zero is simply a filler value to establish the variable instead of writting cutom checks for tau later.  0 will never be a value fed in by code, so it simply allows the algorithym to function in a standadrd manner for all races.
	g_bonus_barracks = "tau_barracks"
	g_bonus_barracks2 = "tau_kroot_nest"
	g_bonus_research = "tau_research_building"
	
elseif MetaMap_GetPlayerRaceName() == "necron_race" then
	
	g_bonus_generator = "necron_plasma_generator"
	g_bonus_turret = "necron_turret"
	g_bonus_barracks = "necron_summoning_core"
	g_bonus_barracks2 = 0 --value on used for tau kroot nest, dummy value for all other races, like the Tau turret.
	g_bonus_research = "necron_forbidden_archive"
	
end

--Add in any bonus buildings made availible if the player has purchased them via owning Hyperion peaks province
t_blueprintEntitybonus = {}

MetaMap_GetAttackingRaceStartingEntitiesList(t_blueprintEntitybonus)

for j = 1,table.getn(t_blueprintEntitybonus) do

	if t_blueprintEntitybonus[j] == g_bonus_generator then
		
		Entity_CreateBuildingMarker(g_Player1, "eg_Bonus"..j, t_blueprintEntitybonus[j], "MM_Reinforcement"..g_bonus_gen_counter, 1)
		
		--increase by one, the next generator will then spawn at the correct marker after this one
		g_bonus_gen_counter = g_bonus_gen_counter + 1
		
	elseif t_blueprintEntitybonus[j] == g_bonus_turret then

		Entity_CreateBuildingMarker(g_Player1, "eg_Bonus"..j, t_blueprintEntitybonus[j], "MM_Reinforcement"..g_bonus_turret_counter, 1)

		--increase by one, the next turret will then spawn at the correct marker after this one
		g_bonus_turret_counter = g_bonus_turret_counter + 1
	

	elseif t_blueprintEntitybonus[j] == g_bonus_barracks then

		--fixed marker spawn based on Phil's table.  Only one barracks is spawned, always at marker 10

		--Necron intentionally spawn a summoning core in place of a barracks due to the monolith doubling as their barracks.
		Entity_CreateBuildingMarker(g_Player1, "eg_Bonus"..j, t_blueprintEntitybonus[j], "MM_Reinforcement10", 1)

	elseif t_blueprintEntitybonus[j] == g_bonus_research then

		--fixed marker spawn based on Phil's table.  Only one research building is spawned, always at marker 11
		Entity_CreateBuildingMarker(g_Player1, "eg_Bonus"..j, t_blueprintEntitybonus[j], "MM_Reinforcement11", 1)
			

	elseif t_blueprintEntitybonus[j] == g_bonus_barracks2 then

		--This will only be used to spawn the kroot nest when the player is Tau, otherwise it will be passed over due to g_bonus_barracks2 being a dummy value.
		--fixed marker spawn based on Phil's table.  Only one kroot nest is spawned, always at marker 13
		Entity_CreateBuildingMarker(g_Player1, "eg_Bonus"..j, t_blueprintEntitybonus[j], "MM_Reinforcement13", 1)

	end

			

end	



--setting up the upgrades for the commander
MetaMap_UpdatePlayerWargear(g_Player1)

--setting up the bonus units for the player
t_blueprintbonus = {}
MetaMap_GetRaceStartingSquadsList(MetaMap_GetPlayerRaceName(), t_blueprintbonus)


for j = 1,  table.getn(t_blueprintbonus) do

	if j <= 7 then
	
			k = j
	else
			k = j - 7
	
	end
	

	Util_CreateSquadsAtMarker(g_Player1, "sg_Bonus"..j, t_blueprintbonus[j], "mkr_Bonus"..k, 1)
	
	
end
		

Rule_Remove(Rule_Create_Player_Buildings)

end

--[[upgrading SM held strat points and relic]]

function Rule_Upgrade_SM_Points()

for i = 1, 9 do

	EGroup_ForceAddOn("eg_SM_List_Post"..i, "space_marine_list_post_addon_2" )


end

end

--turrets

function Rule_Create_SM_Turrets()

for i = 1, 28 do

	Entity_CreateBuildingMarker(g_Player3,"sg_SM_Turret"..i, "space_marine_turret_bolter","mkr_SM_Defence"..i, 1)


end

end

--mine fields

function Rule_Create_SM_Mines()

for i = 1, 10 do

	Entity_CreateBuildingMarker(g_Player2,"sg_SM_Mine"..i, "space_marine_mine_field","mkr_Mine"..i, 1)


end

end

--creating the Barracks, vehicle and chapel

function Rule_Create_SM_Buildings()

	--i am creating the buildings for one player then sending them to the other in order to keep them with the same color
	Entity_CreateBuildingMarker(g_Player2,"eg_SM_Baracks", "space_marine_barracks","mkr_SM_Infantry_HQ", 1)
	Entity_CreateBuildingMarker(g_Player2,"eg_SM_Vehicle", "space_marine_vehicle_building","mkr_SM_Vehicle_HQ", 1)
	Entity_CreateBuildingMarker(g_Player2,"eg_SM_Chapel", "space_marine_ability_building","mkr_SM_Chapel", 1)
	Entity_CreateBuildingMarker(g_Player2,"eg_SM_HQ", "space_marine_hq","mkr_SM_HQ", 1)
	Entity_CreateBuildingMarker(g_Player2,"eg_SM_Armoury", "space_marine_armoury","mkr_SM_Armoury", 1)
	Entity_CreateBuildingMarker(g_Player2,"eg_SM_Assault_Barracks", "space_marine_barracks","mkr_Assault_Barracks", 1)
	
	
	
	EGroup_ForceAddOn("eg_SM_HQ", "space_marine_hq_addon_2")
	
	--do not transfer the orbital relay
	Entity_CreateBuildingMarker(g_Player6,"eg_SM_Orbital", "space_marine_orbital_relay_stronghold_sp","mkr_Orbital_Relay", 1)
	EGroup_SetHealthInvulnerable("eg_SM_Orbital", true)

	for i = 1, 9 do
	
		Entity_CreateBuildingMarker(g_Player2,"eg_SM_Generator"..i, "space_marine_generator","mkr_SMPower"..i, 1)
	
	end

	
	EGroup_SetPlayerOwner("eg_SM_Baracks", g_Player3)
	EGroup_SetPlayerOwner("eg_SM_Vehicle", g_Player3)
	EGroup_SetPlayerOwner("eg_SM_Chapel", g_Player3)
	EGroup_SetPlayerOwner("eg_SM_HQ", g_Player3)
	EGroup_SetPlayerOwner("eg_SM_Armoury", g_Player3)
	
	for j = 1, 6 do
	
		EGroup_SetPlayerOwner("eg_SM_Generator"..j, g_Player3)
	
	end
	

end

--[[Spawning Armies]]

function Rule_SM_Whirlwind_Creation()

if g_Strength >= 13 then

	t_Whirlwind_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_Whirlwind1", --[[2]]"sg_SM_Whirlwind2", --[[3]]"sg_SM_Whirlwind3"},  
		
		blueprint = {--[[1]]"space_marine_squad_whirlwind", --[[2]]"space_marine_squad_whirlwind", --[[3]]"space_marine_squad_whirlwind"},
		
		marker_spawn = {--[[1]]"mkr_Whirlwind1", --[[2]]"mkr_Whirlwind2", --[[3]]"mkr_Whirlwind3"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 1, --[[3]] 1}, 
		
	}

else


	t_Whirlwind_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_Whirlwind1", --[[2]]"sg_SM_Whirlwind3"},  
		
		blueprint = {--[[1]]"space_marine_squad_whirlwind", --[[2]]"space_marine_squad_whirlwind"},
		
		marker_spawn = {--[[1]]"mkr_Whirlwind1", --[[2]]"mkr_Whirlwind3"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 1}, 
		
	}





end


local i = g_Whirlwind_Army_iter 
if g_Whirlwind_Army_iter <= table.getn(t_Whirlwind_Army.sgroup_name) and (SGroup_Exists(t_Whirlwind_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Whirlwind_Army.sgroup_name[i])) then
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_Whirlwind_Army.sgroup_name[i], t_Whirlwind_Army.blueprint[i], t_Whirlwind_Army.marker_spawn[i], t_Whirlwind_Army.squad_num[i], t_Whirlwind_Army.squad_size[i])
	
	--these space marines don't break
	if Squad_HasMorale(SGroup_GetSpawnedSquadAt(SGroup_FromName(t_Whirlwind_Army.sgroup_name[i]), 1)) then
		SGroup_SetMoraleInvulnerable(t_Whirlwind_Army.sgroup_name[i], true)
	end
	
	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_Whirlwind_Army"),  SGroup_FromName(t_Whirlwind_Army.sgroup_name[i]))
	Cmd_SetStance(t_Whirlwind_Army.sgroup_name[i], STANCE_Hold)

	--prevent AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_Whirlwind_Army.sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_SM_Whirlwind_Army")
	
elseif g_Whirlwind_Army_iter > table.getn(t_Whirlwind_Army.sgroup_name) then
		g_Whirlwind_Army_iter = 0
		
		Rule_AddInterval(Rule_Whirlwind_Attack, 15)
		Rule_Remove(Rule_SM_Whirlwind_Creation)

	
end
g_Whirlwind_Army_iter = g_Whirlwind_Army_iter+1

end

--units closest to the player at start blocking off the ramps

function Rule_SM_Gap_Creation()

if 	g_Strength == 15 then

	t_Gap_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_Gap1", --[[2]]"sg_SM_Gap2", --[[3]]"sg_SM_Gap3", --[[4]]"sg_SM_Gap4"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_veteran_stronghold_sp", 
		--[[4]]"space_marine_squad_veteran_stronghold_sp"},
		
		marker_spawn = {--[[1]]"mkr_SM_Ramp1", --[[2]]"mkr_SM_Ramp2", --[[3]]"mkr_SM_Ramp3", --[[4]]"mkr_SM_Ramp4"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 3, --[[2]] 2, --[[3]] 3, --[[4]] 2}, 
		
	}
elseif g_Strength == 14 then
	
	
	t_Gap_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_Gap1", --[[2]]"sg_SM_Gap2", --[[3]]"sg_SM_Gap3", --[[4]]"sg_SM_Gap4"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_tactical", 
		--[[4]]"space_marine_squad_veteran_stronghold_sp"},
		
		marker_spawn = {--[[1]]"mkr_SM_Ramp1", --[[2]]"mkr_SM_Ramp2", --[[3]]"mkr_SM_Ramp3", --[[4]]"mkr_SM_Ramp4"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 3, --[[2]] 2, --[[3]] 3, --[[4]] 2}, 
		
	}
	
elseif g_Strength < 14 then	
	
	t_Gap_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_Gap1", --[[2]]"sg_SM_Gap2", --[[3]]"sg_SM_Gap3", --[[4]]"sg_SM_Gap4"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", 
		--[[4]]"space_marine_squad_tactical"},
		
		marker_spawn = {--[[1]]"mkr_SM_Ramp1", --[[2]]"mkr_SM_Ramp2", --[[3]]"mkr_SM_Ramp3", --[[4]]"mkr_SM_Ramp4"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 3, --[[2]] 2, --[[3]] 3, --[[4]] 2}, 
		
	}
	
end	

local i = g_Gap_Army_iter 
if g_Gap_Army_iter <= table.getn(t_Gap_Army.sgroup_name) and (SGroup_Exists(t_Gap_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Gap_Army.sgroup_name[i])) then
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_Gap_Army.sgroup_name[i], t_Gap_Army.blueprint[i], t_Gap_Army.marker_spawn[i], t_Gap_Army.squad_num[i], t_Gap_Army.squad_size[i])
	
	
	--these space marines don't break
	if Squad_HasMorale(SGroup_GetSpawnedSquadAt(SGroup_FromName(t_Gap_Army.sgroup_name[i]), 1)) then
		SGroup_SetMoraleInvulnerable(t_Gap_Army.sgroup_name[i], true)
	end
		
	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_Gap_Army"),  SGroup_FromName(t_Gap_Army.sgroup_name[i]))
	
	--prevent AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_Gap_Army.sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_SM_Gap_Army")
	
elseif g_Gap_Army_iter > table.getn(t_Gap_Army.sgroup_name) then
		g_Gap_Army_iter = 0
		
		if g_Strength == 15 then
			--upgrading the tac marines to chain guns
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap1"), 1), "space_marine_flamer_veteran", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap2"), 1), "space_marine_heavy_bolter_veteran", 2)
			
			--upgrading the tac marines to flamers
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap3"), 1), "space_marine_flamer_veteran", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap4"), 1), "space_marine_heavy_bolter_veteran", 2)
		
		elseif g_Strength == 14 then
		
			--upgrading the tac marines to chain guns
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap1"), 1), "space_marine_flamer_tactical", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap2"), 1), "space_marine_heavy_bolter_veteran", 1)
			
			--upgrading the tac marines to flamers
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap3"), 1), "space_marine_flamer_tactical", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap4"), 1), "space_marine_heavy_bolter_veteran", 1)
			
			
		elseif g_Strength == 13 then
		
			--upgrading the tac marines to chain guns
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap1"), 1), "space_marine_flamer_tactical", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap2"), 1), "space_marine_heavy_bolter_tactical", 2)
			
			--upgrading the tac marines to flamers
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap3"), 1), "space_marine_flamer_tactical", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap4"), 1), "space_marine_heavy_bolter_tactical", 2)
			
		elseif g_Strength == 12 then
		
			--upgrading the tac marines to chain guns
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap1"), 1), "space_marine_flamer_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap2"), 1), "space_marine_heavy_bolter_tactical", 2)
			
			--upgrading the tac marines to flamers
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap3"), 1), "space_marine_flamer_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap4"), 1), "space_marine_heavy_bolter_tactical", 2)
			
		elseif g_Strength == 11 then
		
			--upgrading the tac marines to chain guns
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap1"), 1), "space_marine_flamer_tactical", 1)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap2"), 1), "space_marine_heavy_bolter_tactical", 1)
			
			--upgrading the tac marines to flamers
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap3"), 1), "space_marine_flamer_tactical", 1)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap4"), 1), "space_marine_heavy_bolter_tactical", 1)
			
		else
		
			--upgrading the tac marines to chain guns
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap1"), 1), "space_marine_flamer_tactical", 1)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap2"), 1), "space_marine_flamer_tactical", 1)
			
			--upgrading the tac marines to flamers
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap3"), 1), "space_marine_flamer_tactical", 1)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Gap4"), 1), "space_marine_flamer_tactical", 1)
		
		end
		
		--flamers will follow the player a bit
		Cmd_SetStance("sg_SM_Gap1", STANCE_Hold)
		Cmd_SetStance("sg_SM_Gap3", STANCE_Hold)
		
		--Heavy Bolters do not follow
		Cmd_SetStance("sg_SM_Gap2", STANCE_StandGround)
		Cmd_SetStance("sg_SM_Gap4", STANCE_StandGround)
		
		Rule_AddOneShot(Rule_Count_Gap, 5)
		
		--adding a little static movement to make things look more lively
		Rule_AddIntervalDelay(Rule_Static_Movement27, 60, 60)
		Rule_AddIntervalDelay(Rule_Static_Movement28, 60, 65)
		Rule_AddIntervalDelay(Rule_Static_Movement29, 60, 70)
		Rule_AddIntervalDelay(Rule_Static_Movement30, 60, 63)

		
		Rule_Remove(Rule_SM_Gap_Creation)

	
end
g_Gap_Army_iter = g_Gap_Army_iter+1

end

function Rule_Count_Gap()

--counting is done seperatly from the spawning to avoid issues with units attaching themselves
g_Gap = SGroup_Count(SGroup_FromName("sg_SM_Gap_Army"))

end

--Central plateau army

function Rule_SM_CP_Creation()

if g_Strength == 15 then

	t_CP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_CP1", --[[2]]"sg_SM_CP2", --[[3]]"sg_SM_CP3", --[[4]]"sg_SM_CP4", --[[5]]"sg_SM_CP5", --[[6]]"sg_SM_CP6"},  
		
		blueprint = {--[[1]]"space_marine_squad_librarian_stronghold_sp", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_veteran_stronghold_sp", 
		--[[4]]"space_marine_squad_terminator_assault_veteran_stronghold_sp", --[[5]]"space_marine_squad_veteran_stronghold_sp", 	--[[6]]"space_marine_squad_veteran_stronghold_sp"},
		
		marker_spawn = {--[[1]]"mkr_SM_CP1", --[[2]]"mkr_SM_CP2", --[[3]]"mkr_SM_CP3", --[[4]]"mkr_SM_CP4", --[[5]]"mkr_SM_CP5", --[[6]]"mkr_SM_CP6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 4, --[[3]] 4, --[[4]] 4, --[[5]] 6, --[[6]] 6}, 
		
	}
	
elseif g_Strength ==14 then	
	
	t_CP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_CP1", --[[2]]"sg_SM_CP2", --[[3]]"sg_SM_CP3", --[[4]]"sg_SM_CP4", --[[5]]"sg_SM_CP5", --[[6]]"sg_SM_CP6"},  
		
		blueprint = {--[[1]]"space_marine_squad_librarian_stronghold_sp", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_veteran_stronghold_sp", 
		--[[4]]"space_marine_squad_terminator_assault_veteran_stronghold_sp", --[[5]]"space_marine_squad_tactical", 	--[[6]]"space_marine_squad_tactical"},
		
		marker_spawn = {--[[1]]"mkr_SM_CP1", --[[2]]"mkr_SM_CP2", --[[3]]"mkr_SM_CP3", --[[4]]"mkr_SM_CP4", --[[5]]"mkr_SM_CP5", --[[6]]"mkr_SM_CP6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 4, --[[3]] 4, --[[4]] 4, --[[5]] 6, --[[6]] 6}, 
		
	}
	
elseif g_Strength ==13 then


	t_CP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_CP1", --[[2]]"sg_SM_CP2", --[[3]]"sg_SM_CP3", --[[4]]"sg_SM_CP4", --[[5]]"sg_SM_CP5", --[[6]]"sg_SM_CP6"},  
		
		blueprint = {--[[1]]"space_marine_squad_librarian", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", 
		--[[4]]"space_marine_squad_terminator_assault", --[[5]]"space_marine_squad_veteran_stronghold_sp", 	--[[6]]"space_marine_squad_veteran_stronghold_sp"},
		
		marker_spawn = {--[[1]]"mkr_SM_CP1", --[[2]]"mkr_SM_CP2", --[[3]]"mkr_SM_CP3", --[[4]]"mkr_SM_CP4", --[[5]]"mkr_SM_CP5", --[[6]]"mkr_SM_CP6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 4, --[[3]] 4, --[[4]] 4, --[[5]] 3, --[[6]] 3}, 
		
	}

elseif g_Strength ==12 then


	t_CP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_CP1", --[[2]]"sg_SM_CP2", --[[3]]"sg_SM_CP3", --[[4]]"sg_SM_CP4", --[[5]]"sg_SM_CP5", --[[6]]"sg_SM_CP6"},  
		
		blueprint = {--[[1]]"space_marine_squad_librarian", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", 
		--[[4]]"space_marine_squad_terminator_assault", --[[5]]"space_marine_squad_tactical", 	--[[6]]"space_marine_squad_tactical"},
		
		marker_spawn = {--[[1]]"mkr_SM_CP1", --[[2]]"mkr_SM_CP2", --[[3]]"mkr_SM_CP3", --[[4]]"mkr_SM_CP4", --[[5]]"mkr_SM_CP5", --[[6]]"mkr_SM_CP6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 4, --[[3]] 4, --[[4]] 4, --[[5]] 6, --[[6]] 6}, 
		
	}	
	
elseif g_Strength ==11 then


	t_CP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_CP1", --[[2]]"sg_SM_CP2", --[[3]]"sg_SM_CP3", --[[4]]"sg_SM_CP4", --[[5]]"sg_SM_CP5", --[[6]]"sg_SM_CP6"},  
		
		blueprint = {--[[1]]"space_marine_squad_librarian", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", 
		--[[4]]"space_marine_squad_terminator_assault", --[[5]]"space_marine_squad_tactical", 	--[[6]]"space_marine_squad_tactical"},
		
		marker_spawn = {--[[1]]"mkr_SM_CP1", --[[2]]"mkr_SM_CP2", --[[3]]"mkr_SM_CP3", --[[4]]"mkr_SM_CP4", --[[5]]"mkr_SM_CP5", --[[6]]"mkr_SM_CP6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 4, --[[3]] 4, --[[4]] 4, --[[5]] 6, --[[6]] 6}, 
		
	}	
	
	
else


	t_CP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_CP1", --[[2]]"sg_SM_CP2", --[[3]]"sg_SM_CP3", --[[4]]"sg_SM_CP4", --[[5]]"sg_SM_CP5", --[[6]]"sg_SM_CP6"},  
		
		blueprint = {--[[1]]"space_marine_squad_librarian", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", 
		--[[4]]"space_marine_squad_terminator_assault", --[[5]]"space_marine_squad_tactical", 	--[[6]]"space_marine_squad_tactical"},
		
		marker_spawn = {--[[1]]"mkr_SM_CP1", --[[2]]"mkr_SM_CP2", --[[3]]"mkr_SM_CP3", --[[4]]"mkr_SM_CP4", --[[5]]"mkr_SM_CP5", --[[6]]"mkr_SM_CP6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 4, --[[3]] 4, --[[4]] 4, --[[5]] 6, --[[6]] 6}, 
		
	}

end

local i = g_CP_Army_iter 
if g_CP_Army_iter <= table.getn(t_CP_Army.sgroup_name) and (SGroup_Exists(t_CP_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_CP_Army.sgroup_name[i])) then
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_CP_Army.sgroup_name[i], t_CP_Army.blueprint[i], t_CP_Army.marker_spawn[i], t_CP_Army.squad_num[i], t_CP_Army.squad_size[i])
	
	--these space marines don't break
	if Squad_HasMorale(SGroup_GetSpawnedSquadAt(SGroup_FromName(t_CP_Army.sgroup_name[i]), 1)) then
		SGroup_SetMoraleInvulnerable(t_CP_Army.sgroup_name[i], true)
	end
	
	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_CP_Army"),  SGroup_FromName(t_CP_Army.sgroup_name[i]))
	
	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_CP_Army.sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_SM_CP_Army")
	
elseif g_CP_Army_iter > table.getn(t_CP_Army.sgroup_name) then
		g_CP_Army_iter = 0
		
	if g_Strength == 15 then
		--upgrading the tac marines to chain guns and flamers
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP2"), 1), "space_marine_flamer_veteran", 4)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP2"), 1), "space_marine_heavy_bolter_veteran", 2)
		
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP3"), 1), "space_marine_flamer_veteran", 4)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP3"), 1), "space_marine_heavy_bolter_veteran", 2)
		
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP5"), 1), "space_marine_heavy_bolter_veteran", 6)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP6"), 1), "space_marine_heavy_bolter_veteran", 6)

	elseif g_Strength == 14 then
	
		--upgrading the tac marines to chain guns and flamers
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP2"), 1), "space_marine_flamer_veteran", 2)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP2"), 1), "space_marine_heavy_bolter_veteran", 2)
		
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP3"), 1), "space_marine_flamer_veteran", 2)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP3"), 1), "space_marine_heavy_bolter_veteran", 2)
		
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP5"), 1), "space_marine_heavy_bolter_tactical", 6)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP6"), 1), "space_marine_heavy_bolter_tactical", 4)
	
	
	elseif g_Strength == 13 then
	
		--upgrading the tac marines to chain guns and flamers
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP2"), 1), "space_marine_flamer_tactical", 4)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP2"), 1), "space_marine_heavy_bolter_tactical", 2)
		
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP3"), 1), "space_marine_flamer_tactical", 4)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP3"), 1), "space_marine_heavy_bolter_tactical", 2)
		
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP5"), 1), "space_marine_heavy_bolter_veteran", 3)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP6"), 1), "space_marine_heavy_bolter_veteran", 3)
	
	elseif g_Strength == 12 then
	
		--upgrading the tac marines to chain guns and flamers
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP2"), 1), "space_marine_flamer_tactical", 4)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP2"), 1), "space_marine_heavy_bolter_tactical", 2)
		
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP3"), 1), "space_marine_flamer_tactical", 4)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP3"), 1), "space_marine_heavy_bolter_tactical", 2)
		
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP5"), 1), "space_marine_heavy_bolter_tactical", 6)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP6"), 1), "space_marine_heavy_bolter_tactical", 6)
	
	elseif g_Strength == 11 then
	
		--upgrading the tac marines to chain guns and flamers
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP2"), 1), "space_marine_flamer_tactical", 3)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP2"), 1), "space_marine_heavy_bolter_tactical", 2)
		
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP3"), 1), "space_marine_flamer_tactical", 3)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP3"), 1), "space_marine_heavy_bolter_tactical", 2)
		
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP5"), 1), "space_marine_heavy_bolter_tactical", 6)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP6"), 1), "space_marine_heavy_bolter_tactical", 6)
	
	else
	
		--upgrading the tac marines to chain guns and flamers
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP2"), 1), "space_marine_flamer_tactical", 3)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP2"), 1), "space_marine_heavy_bolter_tactical", 1)
		
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP3"), 1), "space_marine_flamer_tactical", 3)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP3"), 1), "space_marine_heavy_bolter_tactical", 1)
		
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP5"), 1), "space_marine_heavy_bolter_tactical", 4)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_CP6"), 1), "space_marine_heavy_bolter_tactical", 4)
	
	end
		
		--tac marines will follow the player a bit
		Cmd_SetStance("sg_SM_CP2", STANCE_Hold)
		Cmd_SetStance("sg_SM_CP3", STANCE_Hold)
		Cmd_SetStance("sg_SM_CP5", STANCE_Hold)
		Cmd_SetStance("sg_SM_CP6", STANCE_Hold)
		Cmd_SetStance("sg_SM_CP4", STANCE_Hold)
		
		Rule_AddOneShot(Rule_CP_Count, 5)

		
		--get the units moving around a bit
		Rule_AddIntervalDelay(Rule_Static_Movement1, 60, 60)
		Rule_AddIntervalDelay(Rule_Static_Movement2, 60, 65)
		Rule_AddIntervalDelay(Rule_Static_Movement3, 60, 70)
		Rule_AddIntervalDelay(Rule_Static_Movement4, 60, 63)
		Rule_AddIntervalDelay(Rule_Static_Movement5, 60, 74)
		Rule_AddIntervalDelay(Rule_Static_Movement6, 60, 77)
		
		Rule_Remove(Rule_SM_CP_Creation)

	
end
g_CP_Army_iter = g_CP_Army_iter+1

end

function Rule_CP_Count()

--count added seperatly to avoid issues with units being attached
g_CP = SGroup_Count(SGroup_FromName("sg_SM_CP_Army"))

end

--Two minefield army

function Rule_SM_Mine_Army_Creation()

if g_Strength == 15 then

	t_Mine_Army = {
		
		sgroup_name = { --[[1]]"sg_Field_SM1", --[[2]]"sg_Field_SM2", --[[3]]"sg_Field_SM3", --[[4]]"sg_Field_SM4", --[[5]]"sg_Field_SM5", --[[6]]"sg_Field_SM6"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_dreadnought_hellfire", --[[3]]"space_marine_squad_veteran_stronghold_sp", --[[4]]"space_marine_squad_veteran_stronghold_sp", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_veteran_stronghold_sp"},
		
		marker_spawn = { --[[1]]"mkr_Field_SM1", --[[2]]"mkr_Field_SM2", --[[3]]"mkr_Field_SM3", --[[4]]"mkr_Field_SM4", --[[5]]"mkr_Field_SM5", --[[6]]"mkr_Field_SM6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 3, --[[6]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 1, --[[3]] 4, --[[4]] 4, --[[5]] 1, --[[6]] 4}, 
		
	}

elseif g_Strength ==14 then


	t_Mine_Army = {
		
		sgroup_name = { --[[1]]"sg_Field_SM1", --[[2]]"sg_Field_SM2", --[[3]]"sg_Field_SM3", --[[4]]"sg_Field_SM4", --[[5]]"sg_Field_SM5", --[[6]]"sg_Field_SM6"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_dreadnought_hellfire", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_tactical"},
		
		marker_spawn = { --[[1]]"mkr_Field_SM1", --[[2]]"mkr_Field_SM2", --[[3]]"mkr_Field_SM3", --[[4]]"mkr_Field_SM4", --[[5]]"mkr_Field_SM5", --[[6]]"mkr_Field_SM6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 3, --[[6]] 1}, 
		
		squad_size = {--[[1]] 2, --[[2]] 1, --[[3]] 4, --[[4]] 4, --[[5]] 1, --[[6]] 4}, 
		
	}
elseif g_Strength ==13 then


	t_Mine_Army = {
		
		sgroup_name = { --[[1]]"sg_Field_SM1", --[[2]]"sg_Field_SM2", --[[3]]"sg_Field_SM3", --[[4]]"sg_Field_SM4", --[[5]]"sg_Field_SM5", --[[6]]"sg_Field_SM6"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_dreadnought_hellfire", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_tactical"},
		
		marker_spawn = { --[[1]]"mkr_Field_SM1", --[[2]]"mkr_Field_SM2", --[[3]]"mkr_Field_SM3", --[[4]]"mkr_Field_SM4", --[[5]]"mkr_Field_SM5", --[[6]]"mkr_Field_SM6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 3, --[[6]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 2, --[[3]] 4, --[[4]] 4, --[[5]] 1, --[[6]] 4}, 
		
		}
		
elseif g_Strength == 12 then


	t_Mine_Army = {
		
		sgroup_name = { --[[1]]"sg_Field_SM1", --[[2]]"sg_Field_SM2", --[[3]]"sg_Field_SM3", --[[4]]"sg_Field_SM4", --[[5]]"sg_Field_SM5", --[[6]]"sg_Field_SM6"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_dreadnought_hellfire", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_tactical"},
		
		marker_spawn = { --[[1]]"mkr_Field_SM1", --[[2]]"mkr_Field_SM2", --[[3]]"mkr_Field_SM3", --[[4]]"mkr_Field_SM4", --[[5]]"mkr_Field_SM5", --[[6]]"mkr_Field_SM6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 3, --[[6]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 1, --[[3]] 4, --[[4]] 4, --[[5]] 1, --[[6]] 4}, 
		
		}
		
elseif g_Strength ==11 then


	t_Mine_Army = {
		
		sgroup_name = { --[[1]]"sg_Field_SM1", --[[2]]"sg_Field_SM2", --[[3]]"sg_Field_SM3", --[[4]]"sg_Field_SM4", --[[5]]"sg_Field_SM5", --[[6]]"sg_Field_SM6"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_dreadnought_hellfire", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_tactical"},
		
		marker_spawn = { --[[1]]"mkr_Field_SM1", --[[2]]"mkr_Field_SM2", --[[3]]"mkr_Field_SM3", --[[4]]"mkr_Field_SM4", --[[5]]"mkr_Field_SM5", --[[6]]"mkr_Field_SM6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 3, --[[6]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 1, --[[3]] 4, --[[4]] 4, --[[5]] 1, --[[6]] 4}, 
		
		}

else


	t_Mine_Army = {
		
		sgroup_name = { --[[1]]"sg_Field_SM1", --[[2]]"sg_Field_SM2", --[[3]]"sg_Field_SM3", --[[4]]"sg_Field_SM4", --[[5]]"sg_Field_SM5", --[[6]]"sg_Field_SM6"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_dreadnought_hellfire", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_tactical"},
		
		marker_spawn = { --[[1]]"mkr_Field_SM1", --[[2]]"mkr_Field_SM2", --[[3]]"mkr_Field_SM3", --[[4]]"mkr_Field_SM4", --[[5]]"mkr_Field_SM5", --[[6]]"mkr_Field_SM6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 3, --[[6]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 1, --[[3]] 4, --[[4]] 4, --[[5]] 1, --[[6]] 4}, 
		
	}

end


local i = g_Mine_Army_iter 
if g_Mine_Army_iter <= table.getn(t_Mine_Army.sgroup_name) and (SGroup_Exists(t_Mine_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Mine_Army.sgroup_name[i])) then
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_Mine_Army.sgroup_name[i], t_Mine_Army.blueprint[i], t_Mine_Army.marker_spawn[i], t_Mine_Army.squad_num[i], t_Mine_Army.squad_size[i])
	
	--these space marines don't break
	if Squad_HasMorale(SGroup_GetSpawnedSquadAt(SGroup_FromName(t_Mine_Army.sgroup_name[i]), 1)) then
		SGroup_SetMoraleInvulnerable(t_Mine_Army.sgroup_name[i], true)
	end
	
	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_Mine_Army"),  SGroup_FromName(t_Mine_Army.sgroup_name[i]))
	
	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_Mine_Army.sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_SM_Mine_Army")
	
elseif g_Mine_Army_iter > table.getn(t_Mine_Army.sgroup_name) then
		g_Mine_Army_iter = 0
		
		
		if g_Strength == 15 then
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM1"), 1), "space_marine_flamer_veteran", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM3"), 1), "space_marine_flamer_veteran", 2)
			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM1"), 1), "space_marine_missile_launcher_veteran", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM3"), 1), "space_marine_missile_launcher_veteran", 2)
			
		elseif g_Strength == 14 then
		
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM1"), 1), "space_marine_flamer_veteran", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM3"), 1), "space_marine_flamer_veteran", 2)
			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM3"), 1), "space_marine_missile_launcher_veteran", 2)
			
		elseif g_Strength == 13 then
		
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM1"), 1), "space_marine_flamer_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM3"), 1), "space_marine_flamer_tactical", 2)
			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM1"), 1), " space_marine_missile_launcher_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM3"), 1), " space_marine_missile_launcher_tactical", 2)
			
		elseif g_Strength == 12 then
		
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM1"), 1), "space_marine_flamer_tactical", 1)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM3"), 1), "space_marine_flamer_tactical", 1)
			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM1"), 1), " space_marine_missile_launcher_tactical", 1)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM3"), 1), " space_marine_missile_launcher_tactical", 1)
			
		elseif g_Strength == 12 then
		
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM1"), 1), "space_marine_flamer_tactical", 1)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM3"), 1), "space_marine_flamer_tactical", 1)
			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM1"), 1), " space_marine_missile_launcher_tactical", 1)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM3"), 1), " space_marine_missile_launcher_tactical", 1)
			
		elseif g_Strength == 11 then
		
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM1"), 1), "space_marine_flamer_tactical", 1)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM3"), 1), "space_marine_flamer_tactical", 1)
			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM1"), 1), " space_marine_missile_launcher_tactical", 1)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM3"), 1), " space_marine_missile_launcher_tactical", 1)
			
		else
		
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM1"), 1), "space_marine_flamer_tactical", 1)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM3"), 1), "space_marine_flamer_tactical", 1)
			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM1"), 1), " space_marine_missile_launcher_tactical", 1)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Field_SM3"), 1), " space_marine_missile_launcher_tactical", 1)
		
		end
		
		
		--these marines will follow the player a bit
		Cmd_SetStance("sg_Field_SM1", STANCE_Hold)
		Cmd_SetStance("sg_Field_SM3", STANCE_Hold)
		Cmd_SetStance("sg_Field_SM5", STANCE_Hold)
		Cmd_SetStance("sg_Field_SM2", STANCE_Hold)
		Cmd_SetStance("sg_Field_SM4", STANCE_Hold)
		Cmd_SetStance("sg_Field_SM6", STANCE_Hold)
		
		Rule_AddOneShot(Rule_Count_Field, 5)
			
		Rule_Remove(Rule_SM_Mine_Army_Creation)

	
end
g_Mine_Army_iter = g_Mine_Army_iter+1

end

function Rule_Count_Field()

--count added seperatly to avoid units attaching
g_Mine = SGroup_Count(SGroup_FromName("sg_SM_Mine_Army"))

end

--Left plateau army

function Rule_SM_LP_Creation()

if g_Strength == 15 then
	
	t_LP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_LP1", --[[2]]"sg_SM_LP2", --[[3]]"sg_SM_LP3", --[[4]]"sg_SM_LP4", --[[5]]"sg_SM_LP5", --[[6]]"sg_SM_LP6"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_terminator_veteran_stronghold_sp", --[[4]]"space_marine_squad_terminator_veteran_stronghold_sp", 
		--[[5]]"space_marine_squad_terminator_assault_veteran_stronghold_sp", --[[6]]"space_marine_squad_chaplain_stronghold_sp"},
		
		marker_spawn = { --[[1]]"mkr_SM_LP1", --[[2]]"mkr_SM_LP2", --[[3]]"mkr_SM_LP3", --[[4]]"mkr_SM_LP4", --[[5]]"mkr_SM_LP5", --[[6]]"mkr_SM_LP6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1}, 
		
		squad_size = {--[[1]] 6, --[[2]] 5, --[[3]] 4, --[[4]] 4, --[[5]] 4, --[[6]] 1}, 
		
	}

elseif g_Strength == 14 then

	t_LP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_LP1", --[[2]]"sg_SM_LP2", --[[3]]"sg_SM_LP3", --[[4]]"sg_SM_LP4", --[[5]]"sg_SM_LP5", --[[6]]"sg_SM_LP6"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_terminator", --[[4]]"space_marine_squad_terminator", 
		--[[5]]"space_marine_squad_terminator_assault_veteran_stronghold_sp", --[[6]]"space_marine_squad_chaplain_stronghold_sp"},
		
		marker_spawn = { --[[1]]"mkr_SM_LP1", --[[2]]"mkr_SM_LP2", --[[3]]"mkr_SM_LP3", --[[4]]"mkr_SM_LP4", --[[5]]"mkr_SM_LP5", --[[6]]"mkr_SM_LP6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1}, 
		
		squad_size = {--[[1]] 6, --[[2]] 5, --[[3]] 4, --[[4]] 4, --[[5]] 4, --[[6]] 1}, 
		
	}

elseif g_Strength == 13 then
	
	t_LP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_LP1", --[[2]]"sg_SM_LP2", --[[3]]"sg_SM_LP3", --[[4]]"sg_SM_LP4", --[[5]]"sg_SM_LP5", --[[6]]"sg_SM_LP6"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_terminator", --[[4]]"space_marine_squad_terminator", 
		--[[5]]"space_marine_squad_terminator_assault", --[[6]]"space_marine_squad_chaplain_stronghold_sp"},
		
		marker_spawn = { --[[1]]"mkr_SM_LP1", --[[2]]"mkr_SM_LP2", --[[3]]"mkr_SM_LP3", --[[4]]"mkr_SM_LP4", --[[5]]"mkr_SM_LP5", --[[6]]"mkr_SM_LP6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1}, 
		
		squad_size = {--[[1]] 6, --[[2]] 5, --[[3]] 4, --[[4]] 4, --[[5]] 4, --[[6]] 1}, 
		
	}

elseif g_Strength == 12 then

	t_LP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_LP1", --[[2]]"sg_SM_LP2", --[[3]]"sg_SM_LP3", --[[4]]"sg_SM_LP4", --[[5]]"sg_SM_LP5", --[[6]]"sg_SM_LP6"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_terminator", --[[4]]"space_marine_squad_terminator", 
		--[[5]]"space_marine_squad_terminator_assault", --[[6]]"space_marine_squad_chaplain"},
		
		marker_spawn = { --[[1]]"mkr_SM_LP1", --[[2]]"mkr_SM_LP2", --[[3]]"mkr_SM_LP3", --[[4]]"mkr_SM_LP4", --[[5]]"mkr_SM_LP5", --[[6]]"mkr_SM_LP6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1}, 
		
		squad_size = {--[[1]] 6, --[[2]] 5, --[[3]] 4, --[[4]] 4, --[[5]] 4, --[[6]] 1}, 
		
	}

elseif g_Strength == 11 then

	t_LP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_LP1", --[[2]]"sg_SM_LP2", --[[3]]"sg_SM_LP3", --[[4]]"sg_SM_LP4", --[[5]]"sg_SM_LP5", --[[6]]"sg_SM_LP6"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_terminator", --[[4]]"space_marine_squad_terminator", 
		--[[5]]"space_marine_squad_terminator_assault", --[[6]]"space_marine_squad_chaplain"},
		
		marker_spawn = { --[[1]]"mkr_SM_LP1", --[[2]]"mkr_SM_LP2", --[[3]]"mkr_SM_LP3", --[[4]]"mkr_SM_LP4", --[[5]]"mkr_SM_LP5", --[[6]]"mkr_SM_LP6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1}, 
		
		squad_size = {--[[1]] 5, --[[2]] 5, --[[3]] 4, --[[4]] 3, --[[5]] 4, --[[6]] 1}, 
		
	}		
			
else

	t_LP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_LP1", --[[2]]"sg_SM_LP2", --[[3]]"sg_SM_LP3", --[[4]]"sg_SM_LP4", --[[5]]"sg_SM_LP5", --[[6]]"sg_SM_LP6"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_terminator", --[[4]]"space_marine_squad_terminator", 
		--[[5]]"space_marine_squad_terminator_assault", --[[6]]"space_marine_squad_chaplain"},
		
		marker_spawn = { --[[1]]"mkr_SM_LP1", --[[2]]"mkr_SM_LP2", --[[3]]"mkr_SM_LP3", --[[4]]"mkr_SM_LP4", --[[5]]"mkr_SM_LP5", --[[6]]"mkr_SM_LP6"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 5, --[[3]] 4, --[[4]] 3, --[[5]] 2, --[[6]] 1}, 
		
	}



end	
	


local i = g_LP_Army_iter 
if g_LP_Army_iter <= table.getn(t_LP_Army.sgroup_name) and (SGroup_Exists(t_LP_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_LP_Army.sgroup_name[i])) then
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_LP_Army.sgroup_name[i], t_LP_Army.blueprint[i], t_LP_Army.marker_spawn[i], t_LP_Army.squad_num[i], t_LP_Army.squad_size[i])
	
	--these space marines don't break
	if Squad_HasMorale(SGroup_GetSpawnedSquadAt(SGroup_FromName(t_LP_Army.sgroup_name[i]), 1)) then
		SGroup_SetMoraleInvulnerable(t_LP_Army.sgroup_name[i], true)
	end
	
	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_LP_Army"),  SGroup_FromName(t_LP_Army.sgroup_name[i]))
	
	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_LP_Army.sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_SM_LP_Army")
	
	
elseif g_LP_Army_iter > table.getn(t_LP_Army.sgroup_name) then
		g_LP_Army_iter = 0
		
		if g_Strength == 15 then
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP1"), 1), "space_marine_flamer_veteran", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP1"), 1), "space_marine_missile_launcher_veteran", 2)
			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP2"), 1), "space_marine_flamer_veteran", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP2"), 1), "space_marine_missile_launcher_veteran", 2)
		
		elseif g_Strength ==14 then
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP1"), 1), "space_marine_flamer_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP1"), 1), " space_marine_missile_launcher_tactical", 4)
			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP2"), 1), "space_marine_flamer_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP2"), 1), " space_marine_missile_launcher_tactical", 4)
		
		elseif g_Strength ==13 then
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP1"), 1), "space_marine_flamer_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP1"), 1), " space_marine_missile_launcher_tactical", 3)
			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP2"), 1), "space_marine_flamer_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP2"), 1), " space_marine_missile_launcher_tactical", 3)
		
		
		elseif g_Strength ==12 then
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP1"), 1), "space_marine_flamer_tactical", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP1"), 1), " space_marine_missile_launcher_tactical", 3)
			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP2"), 1), "space_marine_flamer_tactical", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP2"), 1), " space_marine_missile_launcher_tactical", 3)
		
		
		elseif g_Strength ==11 then
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP1"), 1), "space_marine_flamer_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP1"), 1), " space_marine_missile_launcher_tactical", 2)
			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP2"), 1), "space_marine_flamer_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP2"), 1), " space_marine_missile_launcher_tactical", 2)
		
		
		
		else
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP1"), 1), "space_marine_flamer_tactical", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP1"), 1), " space_marine_missile_launcher_tactical", 2)
			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP2"), 1), "space_marine_flamer_tactical", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_LP2"), 1), " space_marine_missile_launcher_tactical", 2)
		
		
		end
		
		
		
		
		--these marines will follow the player a bit
		Cmd_SetStance("sg_SM_LP1", STANCE_Hold)
		Cmd_SetStance("sg_SM_LP2", STANCE_Hold)
		Cmd_SetStance("sg_SM_LP3", STANCE_Hold)
		Cmd_SetStance("sg_SM_LP4", STANCE_Hold)
		Cmd_SetStance("sg_SM_LP5", STANCE_Hold)
		Cmd_SetStance("sg_SM_LP6", STANCE_Hold)
		
		Rule_AddOneShot(Rule_Count_LP, 5)
		
		
		Rule_AddIntervalDelay(Rule_Static_Movement12, 60, 60)
		Rule_AddIntervalDelay(Rule_Static_Movement13, 60, 65)
		Rule_AddIntervalDelay(Rule_Static_Movement14, 60, 70)
		Rule_AddIntervalDelay(Rule_Static_Movement15, 60, 63)
		Rule_AddIntervalDelay(Rule_Static_Movement16, 60, 67)
		Rule_AddIntervalDelay(Rule_Static_Movement17, 60, 74)
		
		Rule_Remove(Rule_SM_LP_Creation)

	
end
g_LP_Army_iter = g_LP_Army_iter+1

end

function Rule_Count_LP()

--count added seperatly to avoid issues with units being attached
g_LP = SGroup_Count(SGroup_FromName("sg_SM_LP_Army"))

end

--Right plateau army

function Rule_SM_RP_Creation()

if g_Strength == 15 then

	t_RP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_RP1", --[[2]]"sg_SM_RP2", --[[3]]"sg_SM_RP3", --[[4]]"sg_SM_RP4", --[[5]]"sg_SM_RP5", --[[6]]"sg_SM_RP6", --[[7]]"sg_SM_RP7", --[[8]]"sg_SM_RP8", --[[9]]"sg_SM_RP9", 
		--[[10]]"sg_SM_RP10", --[[11]]"sg_SM_RP11", --[[12]]"sg_SM_RP12", --[[13]]"sg_SM_RP13"},  
		
		blueprint = {--[[1]]"space_marine_squad_terminator_assault_veteran_stronghold_sp", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_terminator_veteran_stronghold_sp", --[[4]]"space_marine_squad_veteran_stronghold_sp", 
		--[[5]]"space_marine_squad_veteran_stronghold_sp", --[[6]]"space_marine_squad_terminator_veteran_stronghold_sp", --[[7]]"space_marine_squad_dreadnought", --[[8]]"space_marine_squad_dreadnought_hellfire", --[[9]]"space_marine_squad_apothecary_veteran_stronghold_sp",
		--[[10]]"space_marine_squad_apothecary_veteran_stronghold_sp", --[[11]]"space_marine_squad_apothecary_veteran_stronghold_sp", --[[12]]"space_marine_squad_apothecary_veteran_stronghold_sp", --[[13]]"space_marine_squad_apothecary_veteran_stronghold_sp"},
		
		marker_spawn = { --[[1]]"mkr_SM_RP1", --[[2]]"mkr_SM_RP2", --[[3]]"mkr_SM_RP3", --[[4]]"mkr_SM_RP4", --[[5]]"mkr_SM_RP5", --[[6]]"mkr_SM_RP6", --[[7]]"mkr_SM_RP7", --[[8]]"mkr_SM_RP8",
		 --[[9]]"mkr_SM_RP9", --[[10]]"mkr_SM_RP10", --[[11]]"mkr_SM_RP11", --[[12]]"mkr_SM_RP12", --[[13]]"mkr_SM_RP13"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 1}, 
		
		squad_size = {--[[1]] 5, --[[2]] 6, --[[3]] 4, --[[4]] 6, --[[5]] 6, --[[6]] 4, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 1}, 
		
	}
	
elseif g_Strength == 14 then

	
	t_RP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_RP1", --[[2]]"sg_SM_RP2", --[[3]]"sg_SM_RP3", --[[4]]"sg_SM_RP4", --[[5]]"sg_SM_RP5", --[[6]]"sg_SM_RP6", --[[7]]"sg_SM_RP7", --[[8]]"sg_SM_RP8", --[[9]]"sg_SM_RP9", 
		--[[10]]"sg_SM_RP10", --[[11]]"sg_SM_RP11", --[[12]]"sg_SM_RP12", --[[13]]"sg_SM_RP13"},  
		
		blueprint = {--[[1]]"space_marine_squad_terminator_assault", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_terminator", --[[4]]"space_marine_squad_terminator", 
		--[[5]]"space_marine_squad_tactical", --[[6]]"space_marine_squad_terminator", --[[7]]"space_marine_squad_dreadnought", --[[8]]"space_marine_squad_dreadnought_hellfire", --[[9]]"space_marine_squad_apothecary",
		--[[10]]"space_marine_squad_apothecary_veteran_stronghold_sp", --[[11]]"space_marine_squad_apothecary", --[[12]]"space_marine_squad_apothecary_veteran_stronghold_sp", --[[13]]"space_marine_squad_apothecary"},
		
		marker_spawn = { --[[1]]"mkr_SM_RP1", --[[2]]"mkr_SM_RP2", --[[3]]"mkr_SM_RP3", --[[4]]"mkr_SM_RP4", --[[5]]"mkr_SM_RP5", --[[6]]"mkr_SM_RP6", --[[7]]"mkr_SM_RP7", --[[8]]"mkr_SM_RP8",
		 --[[9]]"mkr_SM_RP9", --[[10]]"mkr_SM_RP10", --[[11]]"mkr_SM_RP11", --[[12]]"mkr_SM_RP12", --[[13]]"mkr_SM_RP13"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 1}, 
		
		squad_size = {--[[1]] 5, --[[2]] 6, --[[3]] 4, --[[4]] 6, --[[5]] 6, --[[6]] 4, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 1}, 
		
	}

elseif g_Strength == 13 then

	
	t_RP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_RP1", --[[2]]"sg_SM_RP2", --[[3]]"sg_SM_RP3", --[[4]]"sg_SM_RP4", --[[5]]"sg_SM_RP5", --[[6]]"sg_SM_RP6", --[[7]]"sg_SM_RP7", --[[8]]"sg_SM_RP8", --[[9]]"sg_SM_RP9", 
		--[[10]]"sg_SM_RP10", --[[11]]"sg_SM_RP11", --[[12]]"sg_SM_RP12", --[[13]]"sg_SM_RP13"},  
		
		blueprint = {--[[1]]"space_marine_squad_terminator_assault", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_terminator", --[[4]]"space_marine_squad_terminator", 
		--[[5]]"space_marine_squad_tactical", --[[6]]"space_marine_squad_terminator", --[[7]]"space_marine_squad_dreadnought", --[[8]]"space_marine_squad_dreadnought_hellfire", --[[9]]"space_marine_squad_apothecary",
		--[[10]]"space_marine_squad_apothecary", --[[11]]"space_marine_squad_apothecary_veteran_stronghold_sp", --[[12]]"space_marine_squad_apothecary", --[[13]]"space_marine_squad_apothecary"},
		
		marker_spawn = { --[[1]]"mkr_SM_RP1", --[[2]]"mkr_SM_RP2", --[[3]]"mkr_SM_RP3", --[[4]]"mkr_SM_RP4", --[[5]]"mkr_SM_RP5", --[[6]]"mkr_SM_RP6", --[[7]]"mkr_SM_RP7", --[[8]]"mkr_SM_RP8",
		 --[[9]]"mkr_SM_RP9", --[[10]]"mkr_SM_RP10", --[[11]]"mkr_SM_RP11", --[[12]]"mkr_SM_RP12", --[[13]]"mkr_SM_RP13"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 1}, 
		
		squad_size = {--[[1]] 5, --[[2]] 6, --[[3]] 4, --[[4]] 6, --[[5]] 6, --[[6]] 4, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 1}, 
		
	}

elseif g_Strength == 12 then

	
	t_RP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_RP1", --[[2]]"sg_SM_RP2", --[[3]]"sg_SM_RP3", --[[4]]"sg_SM_RP4", --[[5]]"sg_SM_RP5", --[[6]]"sg_SM_RP6", --[[7]]"sg_SM_RP7", --[[8]]"sg_SM_RP8", --[[9]]"sg_SM_RP9", 
		--[[10]]"sg_SM_RP10", --[[11]]"sg_SM_RP11", --[[12]]"sg_SM_RP12", --[[13]]"sg_SM_RP13"},  
		
		blueprint = {--[[1]]"space_marine_squad_terminator_assault", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_terminator", --[[4]]"space_marine_squad_terminator", 
		--[[5]]"space_marine_squad_tactical", --[[6]]"space_marine_squad_terminator", --[[7]]"space_marine_squad_dreadnought", --[[8]]"space_marine_squad_dreadnought_hellfire", --[[9]]"space_marine_squad_apothecary",
		--[[10]]"space_marine_squad_apothecary", --[[11]]"space_marine_squad_apothecary", --[[12]]"space_marine_squad_apothecary", --[[13]]"space_marine_squad_apothecary"},
		
		marker_spawn = { --[[1]]"mkr_SM_RP1", --[[2]]"mkr_SM_RP2", --[[3]]"mkr_SM_RP3", --[[4]]"mkr_SM_RP4", --[[5]]"mkr_SM_RP5", --[[6]]"mkr_SM_RP6", --[[7]]"mkr_SM_RP7", --[[8]]"mkr_SM_RP8",
		 --[[9]]"mkr_SM_RP9", --[[10]]"mkr_SM_RP10", --[[11]]"mkr_SM_RP11", --[[12]]"mkr_SM_RP12", --[[13]]"mkr_SM_RP13"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 1}, 
		
		squad_size = {--[[1]] 5, --[[2]] 6, --[[3]] 4, --[[4]] 6, --[[5]] 6, --[[6]] 4, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 1}, 
		
	}

elseif g_Strength == 11 then

	
	t_RP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_RP1", --[[2]]"sg_SM_RP2", --[[3]]"sg_SM_RP3", --[[4]]"sg_SM_RP4", --[[5]]"sg_SM_RP5", --[[6]]"sg_SM_RP6", --[[7]]"sg_SM_RP7", --[[8]]"sg_SM_RP8", --[[9]]"sg_SM_RP9", 
		--[[10]]"sg_SM_RP10", --[[11]]"sg_SM_RP11", --[[12]]"sg_SM_RP12", --[[13]]"sg_SM_RP13"},  
		
		blueprint = {--[[1]]"space_marine_squad_terminator_assault", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_terminator", --[[4]]"space_marine_squad_terminator", 
		--[[5]]"space_marine_squad_tactical", --[[6]]"space_marine_squad_terminator", --[[7]]"space_marine_squad_dreadnought", --[[8]]"space_marine_squad_dreadnought_hellfire", --[[9]]"space_marine_squad_apothecary",
		--[[10]]"space_marine_squad_apothecary", --[[11]]"space_marine_squad_apothecary", --[[12]]"space_marine_squad_apothecary", --[[13]]"space_marine_squad_apothecary"},
		
		marker_spawn = { --[[1]]"mkr_SM_RP1", --[[2]]"mkr_SM_RP2", --[[3]]"mkr_SM_RP3", --[[4]]"mkr_SM_RP4", --[[5]]"mkr_SM_RP5", --[[6]]"mkr_SM_RP6", --[[7]]"mkr_SM_RP7", --[[8]]"mkr_SM_RP8",
		 --[[9]]"mkr_SM_RP9", --[[10]]"mkr_SM_RP10", --[[11]]"mkr_SM_RP11", --[[12]]"mkr_SM_RP12", --[[13]]"mkr_SM_RP13"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 1}, 
		
		squad_size = {--[[1]] 5, --[[2]] 6, --[[3]] 4, --[[4]] 6, --[[5]] 6, --[[6]] 4, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 1}, 
		
	}		

else

	
	t_RP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_RP1", --[[2]]"sg_SM_RP2", --[[3]]"sg_SM_RP3", --[[4]]"sg_SM_RP4", --[[5]]"sg_SM_RP5", --[[6]]"sg_SM_RP6", --[[7]]"sg_SM_RP7", --[[8]]"sg_SM_RP8", --[[9]]"sg_SM_RP9", 
		--[[10]]"sg_SM_RP10", --[[11]]"sg_SM_RP11", --[[12]]"sg_SM_RP12", --[[13]]"sg_SM_RP13"},  
		
		blueprint = {--[[1]]"space_marine_squad_terminator_assault", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_terminator", --[[4]]"space_marine_squad_terminator", 
		--[[5]]"space_marine_squad_tactical", --[[6]]"space_marine_squad_terminator", --[[7]]"space_marine_squad_dreadnought", --[[8]]"space_marine_squad_dreadnought_hellfire", --[[9]]"space_marine_squad_apothecary",
		--[[10]]"space_marine_squad_apothecary", --[[11]]"space_marine_squad_apothecary", --[[12]]"space_marine_squad_apothecary", --[[13]]"space_marine_squad_apothecary"},
		
		marker_spawn = { --[[1]]"mkr_SM_RP1", --[[2]]"mkr_SM_RP2", --[[3]]"mkr_SM_RP3", --[[4]]"mkr_SM_RP4", --[[5]]"mkr_SM_RP5", --[[6]]"mkr_SM_RP6", --[[7]]"mkr_SM_RP7", --[[8]]"mkr_SM_RP8",
		 --[[9]]"mkr_SM_RP9", --[[10]]"mkr_SM_RP10", --[[11]]"mkr_SM_RP11", --[[12]]"mkr_SM_RP12", --[[13]]"mkr_SM_RP13"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 1}, 
		
		squad_size = {--[[1]] 5, --[[2]] 6, --[[3]] 4, --[[4]] 6, --[[5]] 6, --[[6]] 4, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 1}, 
		
	}

end


local i = g_RP_Army_iter 
if g_RP_Army_iter <= table.getn(t_RP_Army.sgroup_name) and (SGroup_Exists(t_RP_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_RP_Army.sgroup_name[i])) then
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_RP_Army.sgroup_name[i], t_RP_Army.blueprint[i], t_RP_Army.marker_spawn[i], t_RP_Army.squad_num[i], t_RP_Army.squad_size[i])
	
	--these space marines don't break
	if Squad_HasMorale(SGroup_GetSpawnedSquadAt(SGroup_FromName(t_RP_Army.sgroup_name[i]), 1)) then
		SGroup_SetMoraleInvulnerable(t_RP_Army.sgroup_name[i], true)
	end
	
	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_RP_Army"),  SGroup_FromName(t_RP_Army.sgroup_name[i]))
	
	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_RP_Army.sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_SM_RP_Army")

	
elseif g_RP_Army_iter > table.getn(t_RP_Army.sgroup_name) then
		g_RP_Army_iter = 0
		
		if g_Strength == 15 then
		--upgrading the tac marines 
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP2"), 1), "space_marine_flamer_veteran", 4)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP4"), 1), "space_marine_plasma_gun_veteran", 3)
		
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP5"), 1), "space_marine_flamer_veteran", 4)

		elseif g_Strength == 14 then
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP2"), 1), "space_marine_flamer_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP4"), 1), "space_marine_plasma_gun", 3)
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP5"), 1), "space_marine_flamer_tactical", 4)
		
		
		elseif g_Strength == 13 then
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP2"), 1), "space_marine_flamer_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP4"), 1), "space_marine_plasma_gun", 3)
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP5"), 1), "space_marine_flamer_tactical", 4)
		
		elseif g_Strength ==12 then
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP2"), 1), "space_marine_flamer_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP4"), 1), "space_marine_plasma_gun", 3)
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP5"), 1), "space_marine_flamer_tactical", 4)
		
		elseif g_Strength == 11 then
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP2"), 1), "space_marine_flamer_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP4"), 1), "space_marine_plasma_gun", 3)
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP5"), 1), "space_marine_flamer_tactical", 4)
		
		else
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP2"), 1), "space_marine_flamer_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP4"), 1), "space_marine_plasma_gun", 3)
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_RP5"), 1), "space_marine_flamer_tactical", 4)
		
		
		end

		
		--these marines will follow the player a bit
		Cmd_SetStance("sg_SM_RP1", STANCE_Hold)
		Cmd_SetStance("sg_SM_RP3", STANCE_Hold)
		Cmd_SetStance("sg_SM_RP4", STANCE_Hold)
		Cmd_SetStance("sg_SM_RP6", STANCE_Hold)
		Cmd_SetStance("sg_SM_RP7", STANCE_Hold)
		Cmd_SetStance("sg_SM_RP8", STANCE_Hold)
		Cmd_SetStance("sg_SM_RP2", STANCE_Hold)
		Cmd_SetStance("sg_SM_RP5", STANCE_Hold)
		
		
		if g_Strength == 15 then
		
			Cmd_AttachSquads("sg_SM_RP5", "sg_SM_RP11")
			Cmd_AttachSquads("sg_SM_RP4", "sg_SM_RP12")
			Cmd_AttachSquads("sg_SM_RP6", "sg_SM_RP9")
			Cmd_AttachSquads("sg_SM_RP3", "sg_SM_RP10")
			Cmd_AttachSquads("sg_SM_RP1", "sg_SM_RP13")
			
		elseif g_Strength == 14 then
			
			Cmd_AttachSquads("sg_SM_RP5", "sg_SM_RP11")
			Cmd_AttachSquads("sg_SM_RP4", "sg_SM_RP12")
			Cmd_AttachSquads("sg_SM_RP6", "sg_SM_RP9")
			Cmd_AttachSquads("sg_SM_RP3", "sg_SM_RP10")
			Cmd_AttachSquads("sg_SM_RP1", "sg_SM_RP13")
			
		elseif g_Strength == 13 then	
			
			Cmd_AttachSquads("sg_SM_RP5", "sg_SM_RP11")
			Cmd_AttachSquads("sg_SM_RP4", "sg_SM_RP12")
			Cmd_AttachSquads("sg_SM_RP6", "sg_SM_RP9")
			Cmd_AttachSquads("sg_SM_RP3", "sg_SM_RP10")
			Cmd_AttachSquads("sg_SM_RP1", "sg_SM_RP13")
			
		elseif g_Strength == 12 then

			Cmd_AttachSquads("sg_SM_RP5", "sg_SM_RP11")
			Cmd_AttachSquads("sg_SM_RP4", "sg_SM_RP12")
			Cmd_AttachSquads("sg_SM_RP6", "sg_SM_RP9")
			Cmd_AttachSquads("sg_SM_RP3", "sg_SM_RP10")
			Cmd_AttachSquads("sg_SM_RP1", "sg_SM_RP13")
		
		elseif g_Strength == 11 then
		
			Cmd_AttachSquads("sg_SM_RP5", "sg_SM_RP11")
			Cmd_AttachSquads("sg_SM_RP4", "sg_SM_RP12")
			Cmd_AttachSquads("sg_SM_RP6", "sg_SM_RP9")
		
		else


		end
		
		Rule_AddOneShot(Rule_Count_RP, 5)
		
		Rule_Remove(Rule_SM_RP_Creation)

	
end
g_RP_Army_iter = g_RP_Army_iter+1

end

function Rule_Count_RP()

--count added seperatly to avoid issues with units attaching
g_RP = SGroup_Count(SGroup_FromName("sg_SM_RP_Army"))

end

--army defending slag

function Rule_SM_Slag_Creation()

if g_Strength == 15 then	

t_Slag_Army = {
		
		sgroup_name = { --[[1]]"sg_Slag1", --[[2]]"sg_Slag2"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_dreadnought"},
		
		marker_spawn = { --[[1]]"mkr_Slag1", --[[2]]"mkr_Slag2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 1}, 
		
	}
	
elseif g_Strength == 14 then



	t_Slag_Army = {
		
		sgroup_name = { --[[1]]"sg_Slag1", --[[2]]"sg_Slag2"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_dreadnought"},
		
		marker_spawn = { --[[1]]"mkr_Slag1", --[[2]]"mkr_Slag2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 1}, 
		
	}

elseif g_Strength == 13 then


	t_Slag_Army = {
		
		sgroup_name = { --[[1]]"sg_Slag1", --[[2]]"sg_Slag2"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_dreadnought"},
		
		marker_spawn = { --[[1]]"mkr_Slag1", --[[2]]"mkr_Slag2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 1}, 
		
	}
	
elseif g_Strength == 12 then


	t_Slag_Army = {
		
		sgroup_name = { --[[1]]"sg_Slag1", --[[2]]"sg_Slag2"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_dreadnought"},
		
		marker_spawn = { --[[1]]"mkr_Slag1", --[[2]]"mkr_Slag2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 1}, 
		
	}
	
elseif g_Strength == 11 then


	t_Slag_Army = {
		
		sgroup_name = { --[[1]]"sg_Slag1", --[[2]]"sg_Slag2"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_dreadnought"},
		
		marker_spawn = { --[[1]]"mkr_Slag1", --[[2]]"mkr_Slag2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 1}, 
		
	}
	
else


	t_Slag_Army = {
		
		sgroup_name = { --[[1]]"sg_Slag1", --[[2]]"sg_Slag2"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_dreadnought"},
		
		marker_spawn = { --[[1]]"mkr_Slag1", --[[2]]"mkr_Slag2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 1}, 
		
	}

end

local i = g_Slag_Army_iter 
if g_Slag_Army_iter <= table.getn(t_Slag_Army.sgroup_name) and (SGroup_Exists(t_Slag_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Slag_Army.sgroup_name[i])) then
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_Slag_Army.sgroup_name[i], t_Slag_Army.blueprint[i], t_Slag_Army.marker_spawn[i], t_Slag_Army.squad_num[i], t_Slag_Army.squad_size[i])
	
	--these space marines don't break
	if Squad_HasMorale(SGroup_GetSpawnedSquadAt(SGroup_FromName(t_Slag_Army.sgroup_name[i]), 1)) then
		SGroup_SetMoraleInvulnerable(t_Slag_Army.sgroup_name[i], true)
	end
	
	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_Slag_Army"),  SGroup_FromName(t_Slag_Army.sgroup_name[i]))
	

	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_Slag_Army.sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_SM_Slag_Army")
	
elseif g_Slag_Army_iter > table.getn(t_Slag_Army.sgroup_name) then
		g_Slag_Army_iter = 0
		
		
		if g_Strength == 15 then
			
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Slag1"), 1), "space_marine_missile_launcher_veteran", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Slag1"), 1), "space_marine_flamer_veteran", 2)
		
		elseif g_Strength == 14 then
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Slag1"), 1), "space_marine_missile_launcher_veteran", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Slag1"), 1), "space_marine_flamer_veteran", 2)
		
		elseif g_Strength == 13 then
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Slag1"), 1), "space_marine_missile_launcher_veteran", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Slag1"), 1), "space_marine_missile_launcher_tactical", 2)
			
		elseif g_Strength == 12 then
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Slag1"), 1), "space_marine_missile_launcher_veteran", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Slag1"), 1), "space_marine_missile_launcher_tactical", 2)
			
		elseif g_Strength == 11 then
	
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Slag1"), 1), "space_marine_missile_launcher_veteran", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Slag1"), 1), "space_marine_missile_launcher_tactical", 2)
			
		else
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Slag1"), 1), "space_marine_missile_launcher_veteran", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Slag1"), 1), "space_marine_missile_launcher_tactical", 2)
		
		
		end
	
		--these marines will follow the player a bit
		Cmd_SetStance("sg_Slag1", STANCE_Hold)
		Cmd_SetStance("sg_Slag2", STANCE_Hold)
			
		Rule_AddOneShot(Rule_Count_Slag, 5)

		--setting up a little movement to stop everything from looking so static
		Rule_AddIntervalDelay(Rule_Static_Movement25, 60, 60)
		Rule_AddIntervalDelay(Rule_Static_Movement26, 60, 70)
		
		
		Rule_Remove(Rule_SM_Slag_Creation)

	
end
g_Slag_Army_iter = g_Slag_Army_iter+1

end

function Rule_Count_Slag()

--count added seperatly to avoid problems with units attaching
g_Slag = SGroup_Count(SGroup_FromName("sg_SM_Slag_Army"))

end

--Bastion army

function Rule_SM_Bastion_Creation()

if g_Strength == 15 then

	t_Bastion_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_Bastion1", --[[2]]"sg_SM_Bastion2", --[[3]]"sg_SM_Bastion3", --[[4]]"sg_SM_Bastion4", --[[5]]"sg_SM_Bastion5", --[[6]]"sg_SM_Bastion6", --[[7]]"sg_SM_Bastion7", 
		--[[8]]"sg_SM_Bastion8", --[[9]]"sg_SM_Bastion9", --[[10]]"sg_SM_Bastion10", --[[11]]"sg_SM_Bastion11", --[[12]]"sg_SM_Bastion12", --[[13]]"sg_SM_Bastion13", --[[14]]"sg_SM_Bastion14", 
		--[[15]]"sg_SM_Bastion15", --[[16]]"sg_SM_Bastion16", --[[17]]"sg_SM_Bastion17", --[[18]]"sg_SM_Bastion18", --[[19]]"sg_SM_Bastion19", --[[20]]"sg_SM_Bastion20", --[[21]]"sg_SM_Bastion21", --[[22]]"sg_SM_Bastion22",
		--[[23]]"sg_SM_Bastion23", --[[24]]"sg_SM_Bastion24", --[[25]]"sg_SM_Bastion25"},  
		
		blueprint = {--[[1]]"space_marine_squad_land_speeder", --[[2]]"space_marine_squad_land_speeder", --[[3]]"space_marine_squad_terminator_assault_veteran_stronghold_sp", 
		--[[4]]"space_marine_squad_terminator_assault_veteran_stronghold_sp", 	--[[5]]"space_marine_squad_apothecary_veteran_stronghold_sp", --[[6]]"space_marine_squad_apothecary_veteran_stronghold_sp", 
		--[[7]]"space_marine_squad_veteran_stronghold_sp", --[[8]]"space_marine_squad_apothecary_veteran_stronghold_sp", --[[9]]"space_marine_squad_veteran_stronghold_sp", 
		--[[10]]"space_marine_squad_apothecary_veteran_stronghold_sp", --[[11]]"space_marine_squad_predator", --[[12]]"space_marine_squad_predator", --[[13]]"space_marine_squad_terminator_veteran_stronghold_sp", 
		--[[14]]"space_marine_squad_apothecary_veteran_stronghold_sp",--[[15]]"space_marine_squad_veteran_stronghold_sp", --[[16]]"space_marine_squad_apothecary_veteran_stronghold_sp", 
		--[[17]]"space_marine_squad_veteran_stronghold_sp", --[[18]]"space_marine_squad_apothecary_veteran_stronghold_sp", --[[19]]"space_marine_squad_force_commander_advance_sp",
		--[[20]]"space_marine_squad_veteran_stronghold_sp", --[[21]]"space_marine_squad_veteran_stronghold_sp", --[[22]]"space_marine_squad_librarian_stronghold_sp", --[[23]]"space_marine_squad_librarian_stronghold_sp",
		--[[24]]"space_marine_squad_librarian_stronghold_sp", --[[25]]"space_marine_squad_librarian_stronghold_sp"},
		
		marker_spawn = { --[[1]]"mkr_SM_Bastion1", --[[2]]"mkr_SM_Bastion2", --[[3]]"mkr_SM_Bastion3", --[[4]]"mkr_SM_Bastion4", --[[5]]"mkr_SM_Bastion5", --[[6]]"mkr_SM_Bastion6", --[[7]]"mkr_SM_Bastion7", 
		--[[8]]"mkr_SM_Bastion8", --[[9]]"mkr_SM_Bastion9", --[[10]]"mkr_SM_Bastion10", --[[11]]"mkr_SM_Bastion11", --[[12]]"mkr_SM_Bastion12", --[[13]]"mkr_SM_Bastion13", --[[14]]"mkr_SM_Bastion14", 
		--[[15]]"mkr_SM_Bastion15", --[[16]]"mkr_SM_Bastion16", --[[17]]"mkr_SM_Bastion17", --[[18]]"mkr_SM_Bastion18", --[[19]]"mkr_SM_Bastion19", --[[20]]"mkr_SM_Bastion20", --[[21]]"mkr_SM_Bastion21", 
		--[[22]]"mkr_SM_Bastion22", --[[23]]"mkr_SM_Bastion23", --[[24]]"mkr_SM_Bastion24", --[[25]]"mkr_SM_Bastion25"}, 
		
		squad_num = {--[[1]] 2, --[[2]] 2, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 2, --[[13]] 1, --[[14]] 1, --[[15]] 1, --[[16]] 1, --[[17]] 1, --[[18]] 1, --[[19]] 1, 
		--[[20]] 1, --[[21]] 1, --[[22]] 1, --[[23]] 1, --[[24]] 1, --[[25]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 1, --[[3]] 8, --[[4]] 8, --[[5]] 1, --[[6]] 1, --[[7]] 8, --[[8]] 1, --[[9]] 8, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 4, --[[14]] 1, --[[15]] 8, --[[16]] 1, --[[17]] 8, --[[18]] 1, --[[19]] 1, 
		--[[20]] 8, --[[21]] 8, --[[22]] 1, --[[23]] 1, --[[24]] 1, --[[25]] 1}, 
		
	}

elseif g_Strength == 14 then

	t_Bastion_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_Bastion1", --[[2]]"sg_SM_Bastion2", --[[3]]"sg_SM_Bastion3", --[[4]]"sg_SM_Bastion4", --[[5]]"sg_SM_Bastion5", --[[6]]"sg_SM_Bastion6", --[[7]]"sg_SM_Bastion7", 
		--[[8]]"sg_SM_Bastion8", --[[9]]"sg_SM_Bastion9", --[[10]]"sg_SM_Bastion10", --[[11]]"sg_SM_Bastion11", --[[12]]"sg_SM_Bastion12", --[[13]]"sg_SM_Bastion13", --[[14]]"sg_SM_Bastion14", 
		--[[15]]"sg_SM_Bastion15", --[[16]]"sg_SM_Bastion16", --[[17]]"sg_SM_Bastion17", --[[18]]"sg_SM_Bastion18", --[[19]]"sg_SM_Bastion19", --[[20]]"sg_SM_Bastion20", --[[21]]"sg_SM_Bastion21", --[[22]]"sg_SM_Bastion22",
		--[[23]]"sg_SM_Bastion23", --[[24]]"sg_SM_Bastion24", --[[25]]"sg_SM_Bastion25"},  
		
		blueprint = {--[[1]]"space_marine_squad_land_speeder", --[[2]]"space_marine_squad_land_speeder", --[[3]]"space_marine_squad_terminator_assault", 
		--[[4]]"space_marine_squad_terminator_assault", 	--[[5]]"space_marine_squad_apothecary_veteran_stronghold_sp", --[[6]]"space_marine_squad_apothecary_veteran_stronghold_sp", 
		--[[7]]"space_marine_squad_tactical", --[[8]]"space_marine_squad_apothecary", --[[9]]"space_marine_squad_tactical", 
		--[[10]]"space_marine_squad_apothecary_veteran_stronghold_sp", --[[11]]"space_marine_squad_predator", --[[12]]"space_marine_squad_predator", --[[13]]"space_marine_squad_terminator", 
		--[[14]]"space_marine_squad_apothecary_veteran_stronghold_sp",--[[15]]"space_marine_squad_tactical", --[[16]]"space_marine_squad_apothecary_veteran_stronghold_sp", 
		--[[17]]"space_marine_squad_apothecary_veteran_stronghold_sp", --[[18]]"space_marine_squad_apothecary_veteran_stronghold_sp", --[[19]]"space_marine_squad_force_commander_advance_sp",
		--[[20]]"space_marine_squad_tactical", --[[21]]"space_marine_squad_tactical", --[[22]]"space_marine_squad_librarian_stronghold_sp", --[[23]]"space_marine_squad_librarian_stronghold_sp",
		--[[24]]"space_marine_squad_librarian_stronghold_sp", --[[25]]"space_marine_squad_librarian_stronghold_sp"},
		
		marker_spawn = { --[[1]]"mkr_SM_Bastion1", --[[2]]"mkr_SM_Bastion2", --[[3]]"mkr_SM_Bastion3", --[[4]]"mkr_SM_Bastion4", --[[5]]"mkr_SM_Bastion5", --[[6]]"mkr_SM_Bastion6", --[[7]]"mkr_SM_Bastion7", 
		--[[8]]"mkr_SM_Bastion8", --[[9]]"mkr_SM_Bastion9", --[[10]]"mkr_SM_Bastion10", --[[11]]"mkr_SM_Bastion11", --[[12]]"mkr_SM_Bastion12", --[[13]]"mkr_SM_Bastion13", --[[14]]"mkr_SM_Bastion14", 
		--[[15]]"mkr_SM_Bastion15", --[[16]]"mkr_SM_Bastion16", --[[17]]"mkr_SM_Bastion17", --[[18]]"mkr_SM_Bastion18", --[[19]]"mkr_SM_Bastion19", --[[20]]"mkr_SM_Bastion20", --[[21]]"mkr_SM_Bastion21", 
		--[[22]]"mkr_SM_Bastion22", --[[23]]"mkr_SM_Bastion23", --[[24]]"mkr_SM_Bastion24", --[[25]]"mkr_SM_Bastion25"}, 
		
		squad_num = {--[[1]] 2, --[[2]] 2, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 2, --[[13]] 1, --[[14]] 1, --[[15]] 1, --[[16]] 1, --[[17]] 1, --[[18]] 1, --[[19]] 1, 
		--[[20]] 1, --[[21]] 1, --[[22]] 1, --[[23]] 1, --[[24]] 1, --[[25]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 1, --[[3]] 8, --[[4]] 8, --[[5]] 1, --[[6]] 1, --[[7]] 8, --[[8]] 1, --[[9]] 8, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 4, --[[14]] 1, --[[15]] 8, --[[16]] 1, --[[17]] 8, --[[18]] 1, --[[19]] 1, 
		--[[20]] 8, --[[21]] 8, --[[22]] 1, --[[23]] 1, --[[24]] 1, --[[25]] 1}, 
		
	}
	
	
elseif g_Strength == 13 then

	t_Bastion_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_Bastion1", --[[2]]"sg_SM_Bastion2", --[[3]]"sg_SM_Bastion3", --[[4]]"sg_SM_Bastion4", --[[5]]"sg_SM_Bastion5", --[[6]]"sg_SM_Bastion6", --[[7]]"sg_SM_Bastion7", 
		--[[8]]"sg_SM_Bastion8", --[[9]]"sg_SM_Bastion9", --[[10]]"sg_SM_Bastion10", --[[11]]"sg_SM_Bastion11", --[[12]]"sg_SM_Bastion12", --[[13]]"sg_SM_Bastion13", --[[14]]"sg_SM_Bastion14", 
		--[[15]]"sg_SM_Bastion15", --[[16]]"sg_SM_Bastion16", --[[17]]"sg_SM_Bastion17", --[[18]]"sg_SM_Bastion18", --[[19]]"sg_SM_Bastion19", --[[20]]"sg_SM_Bastion20", --[[21]]"sg_SM_Bastion21", --[[22]]"sg_SM_Bastion22",
		--[[23]]"sg_SM_Bastion23", --[[24]]"sg_SM_Bastion24", --[[25]]"sg_SM_Bastion25"},  
		
		blueprint = {--[[1]]"space_marine_squad_land_speeder", --[[2]]"space_marine_squad_land_speeder", --[[3]]"space_marine_squad_terminator_assault", 
		--[[4]]"space_marine_squad_terminator_assault", 	--[[5]]"space_marine_squad_apothecary", --[[6]]"space_marine_squad_apothecary", 
		--[[7]]"space_marine_squad_tactical", --[[8]]"space_marine_squad_apothecary", --[[9]]"space_marine_squad_tactical", 
		--[[10]]"space_marine_squad_apothecary", --[[11]]"space_marine_squad_predator", --[[12]]"space_marine_squad_predator", --[[13]]"space_marine_squad_terminator", 
		--[[14]]"space_marine_squad_apothecary",--[[15]]"space_marine_squad_tactical", --[[16]]"space_marine_squad_apothecary", 
		--[[17]]"space_marine_squad_apothecary", --[[18]]"space_marine_squad_apothecary_veteran_stronghold_sp", --[[19]]"space_marine_squad_force_commander_advance_sp",
		--[[20]]"space_marine_squad_tactical", --[[21]]"space_marine_squad_tactical", --[[22]]"space_marine_squad_librarian_stronghold_sp", --[[23]]"space_marine_squad_librarian_stronghold_sp",
		--[[24]]"space_marine_squad_librarian_stronghold_sp", --[[25]]"space_marine_squad_librarian_stronghold_sp"},
		
		marker_spawn = { --[[1]]"mkr_SM_Bastion1", --[[2]]"mkr_SM_Bastion2", --[[3]]"mkr_SM_Bastion3", --[[4]]"mkr_SM_Bastion4", --[[5]]"mkr_SM_Bastion5", --[[6]]"mkr_SM_Bastion6", --[[7]]"mkr_SM_Bastion7", 
		--[[8]]"mkr_SM_Bastion8", --[[9]]"mkr_SM_Bastion9", --[[10]]"mkr_SM_Bastion10", --[[11]]"mkr_SM_Bastion11", --[[12]]"mkr_SM_Bastion12", --[[13]]"mkr_SM_Bastion13", --[[14]]"mkr_SM_Bastion14", 
		--[[15]]"mkr_SM_Bastion15", --[[16]]"mkr_SM_Bastion16", --[[17]]"mkr_SM_Bastion17", --[[18]]"mkr_SM_Bastion18", --[[19]]"mkr_SM_Bastion19", --[[20]]"mkr_SM_Bastion20", --[[21]]"mkr_SM_Bastion21", 
		--[[22]]"mkr_SM_Bastion22", --[[23]]"mkr_SM_Bastion23", --[[24]]"mkr_SM_Bastion24", --[[25]]"mkr_SM_Bastion25"}, 
		
		squad_num = {--[[1]] 2, --[[2]] 2, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 2, --[[13]] 1, --[[14]] 1, --[[15]] 1, --[[16]] 1, --[[17]] 1, --[[18]] 1, --[[19]] 1, 
		--[[20]] 1, --[[21]] 1, --[[22]] 1, --[[23]] 1, --[[24]] 1, --[[25]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 1, --[[3]] 8, --[[4]] 8, --[[5]] 1, --[[6]] 1, --[[7]] 8, --[[8]] 1, --[[9]] 8, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 4, --[[14]] 1, --[[15]] 8, --[[16]] 1, --[[17]] 8, --[[18]] 1, --[[19]] 1, 
		--[[20]] 8, --[[21]] 8, --[[22]] 1, --[[23]] 1, --[[24]] 1, --[[25]] 1}, 
		
	}
	
	
elseif g_Strength == 12 then

	t_Bastion_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_Bastion1", --[[2]]"sg_SM_Bastion2", --[[3]]"sg_SM_Bastion3", --[[4]]"sg_SM_Bastion4", --[[5]]"sg_SM_Bastion5", --[[6]]"sg_SM_Bastion6", --[[7]]"sg_SM_Bastion7", 
		--[[8]]"sg_SM_Bastion8", --[[9]]"sg_SM_Bastion9", --[[10]]"sg_SM_Bastion10", --[[11]]"sg_SM_Bastion11", --[[12]]"sg_SM_Bastion12", --[[13]]"sg_SM_Bastion13", --[[14]]"sg_SM_Bastion14", 
		--[[15]]"sg_SM_Bastion15", --[[16]]"sg_SM_Bastion16", --[[17]]"sg_SM_Bastion17", --[[18]]"sg_SM_Bastion18", --[[19]]"sg_SM_Bastion19", --[[20]]"sg_SM_Bastion20", --[[21]]"sg_SM_Bastion21", --[[22]]"sg_SM_Bastion22",
		--[[23]]"sg_SM_Bastion23", --[[24]]"sg_SM_Bastion24", --[[25]]"sg_SM_Bastion25"},  
		
		blueprint = {--[[1]]"space_marine_squad_land_speeder", --[[2]]"space_marine_squad_land_speeder", --[[3]]"space_marine_squad_terminator_assault", 
		--[[4]]"space_marine_squad_terminator_assault", 	--[[5]]"space_marine_squad_apothecary", --[[6]]"space_marine_squad_apothecary", 
		--[[7]]"space_marine_squad_tactical", --[[8]]"space_marine_squad_apothecary", --[[9]]"space_marine_squad_tactical", 
		--[[10]]"space_marine_squad_apothecary", --[[11]]"space_marine_squad_predator", --[[12]]"space_marine_squad_predator", --[[13]]"space_marine_squad_terminator", 
		--[[14]]"space_marine_squad_apothecary_veteran_stronghold_sp",--[[15]]"space_marine_squad_tactical", --[[16]]"space_marine_squad_apothecary", 
		--[[17]]"space_marine_squad_apothecary", --[[18]]"space_marine_squad_apothecary_veteran_stronghold_sp", --[[19]]"space_marine_squad_force_commander_advance_sp",
		--[[20]]"space_marine_squad_tactical", --[[21]]"space_marine_squad_tactical", --[[22]]"space_marine_squad_librarian", --[[23]]"space_marine_squad_librarian",
		--[[24]]"space_marine_squad_librarian", --[[25]]"space_marine_squad_librarian"},
		
		marker_spawn = { --[[1]]"mkr_SM_Bastion1", --[[2]]"mkr_SM_Bastion2", --[[3]]"mkr_SM_Bastion3", --[[4]]"mkr_SM_Bastion4", --[[5]]"mkr_SM_Bastion5", --[[6]]"mkr_SM_Bastion6", --[[7]]"mkr_SM_Bastion7", 
		--[[8]]"mkr_SM_Bastion8", --[[9]]"mkr_SM_Bastion9", --[[10]]"mkr_SM_Bastion10", --[[11]]"mkr_SM_Bastion11", --[[12]]"mkr_SM_Bastion12", --[[13]]"mkr_SM_Bastion13", --[[14]]"mkr_SM_Bastion14", 
		--[[15]]"mkr_SM_Bastion15", --[[16]]"mkr_SM_Bastion16", --[[17]]"mkr_SM_Bastion17", --[[18]]"mkr_SM_Bastion18", --[[19]]"mkr_SM_Bastion19", --[[20]]"mkr_SM_Bastion20", --[[21]]"mkr_SM_Bastion21", 
		--[[22]]"mkr_SM_Bastion22", --[[23]]"mkr_SM_Bastion23", --[[24]]"mkr_SM_Bastion24", --[[25]]"mkr_SM_Bastion25"}, 
		
		squad_num = {--[[1]] 2, --[[2]] 2, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 2, --[[13]] 1, --[[14]] 1, --[[15]] 1, --[[16]] 1, --[[17]] 1, --[[18]] 1, --[[19]] 1, 
		--[[20]] 1, --[[21]] 1, --[[22]] 1, --[[23]] 1, --[[24]] 1, --[[25]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 1, --[[3]] 8, --[[4]] 8, --[[5]] 1, --[[6]] 1, --[[7]] 8, --[[8]] 1, --[[9]] 8, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 4, --[[14]] 1, --[[15]] 8, --[[16]] 1, --[[17]] 8, --[[18]] 1, --[[19]] 1, 
		--[[20]] 8, --[[21]] 8, --[[22]] 1, --[[23]] 1, --[[24]] 1, --[[25]] 1}, 
		
	}
	
elseif g_Strength == 11 then

	t_Bastion_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_Bastion1", --[[2]]"sg_SM_Bastion2", --[[3]]"sg_SM_Bastion3", --[[4]]"sg_SM_Bastion4", --[[5]]"sg_SM_Bastion5", --[[6]]"sg_SM_Bastion6", --[[7]]"sg_SM_Bastion7", 
		--[[8]]"sg_SM_Bastion8", --[[9]]"sg_SM_Bastion9", --[[10]]"sg_SM_Bastion10", --[[11]]"sg_SM_Bastion11", --[[12]]"sg_SM_Bastion12", --[[13]]"sg_SM_Bastion13", --[[14]]"sg_SM_Bastion14", 
		--[[15]]"sg_SM_Bastion15", --[[16]]"sg_SM_Bastion16", --[[17]]"sg_SM_Bastion17", --[[18]]"sg_SM_Bastion18", --[[19]]"sg_SM_Bastion19", --[[20]]"sg_SM_Bastion20", --[[21]]"sg_SM_Bastion21", --[[22]]"sg_SM_Bastion22",
		--[[23]]"sg_SM_Bastion23", --[[24]]"sg_SM_Bastion24", --[[25]]"sg_SM_Bastion25"},  
		
		blueprint = {--[[1]]"space_marine_squad_land_speeder", --[[2]]"space_marine_squad_land_speeder", --[[3]]"space_marine_squad_terminator_assault", 
		--[[4]]"space_marine_squad_terminator_assault", 	--[[5]]"space_marine_squad_apothecary", --[[6]]"space_marine_squad_apothecary", 
		--[[7]]"space_marine_squad_tactical", --[[8]]"space_marine_squad_apothecary", --[[9]]"space_marine_squad_tactical", 
		--[[10]]"space_marine_squad_apothecary", --[[11]]"space_marine_squad_predator", --[[12]]"space_marine_squad_predator", --[[13]]"space_marine_squad_terminator", 
		--[[14]]"space_marine_squad_apothecary",--[[15]]"space_marine_squad_tactical", --[[16]]"space_marine_squad_apothecary", 
		--[[17]]"space_marine_squad_apothecary", --[[18]]"space_marine_squad_apothecary", --[[19]]"space_marine_squad_force_commander_advance_sp",
		--[[20]]"space_marine_squad_tactical", --[[21]]"space_marine_squad_tactical", --[[22]]"space_marine_squad_librarian", --[[23]]"space_marine_squad_librarian",
		--[[24]]"space_marine_squad_librarian", --[[25]]"space_marine_squad_librarian"},
		
		marker_spawn = { --[[1]]"mkr_SM_Bastion1", --[[2]]"mkr_SM_Bastion2", --[[3]]"mkr_SM_Bastion3", --[[4]]"mkr_SM_Bastion4", --[[5]]"mkr_SM_Bastion5", --[[6]]"mkr_SM_Bastion6", --[[7]]"mkr_SM_Bastion7", 
		--[[8]]"mkr_SM_Bastion8", --[[9]]"mkr_SM_Bastion9", --[[10]]"mkr_SM_Bastion10", --[[11]]"mkr_SM_Bastion11", --[[12]]"mkr_SM_Bastion12", --[[13]]"mkr_SM_Bastion13", --[[14]]"mkr_SM_Bastion14", 
		--[[15]]"mkr_SM_Bastion15", --[[16]]"mkr_SM_Bastion16", --[[17]]"mkr_SM_Bastion17", --[[18]]"mkr_SM_Bastion18", --[[19]]"mkr_SM_Bastion19", --[[20]]"mkr_SM_Bastion20", --[[21]]"mkr_SM_Bastion21", 
		--[[22]]"mkr_SM_Bastion22", --[[23]]"mkr_SM_Bastion23", --[[24]]"mkr_SM_Bastion24", --[[25]]"mkr_SM_Bastion25"}, 
		
		squad_num = {--[[1]] 2, --[[2]] 2, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 2, --[[13]] 1, --[[14]] 1, --[[15]] 1, --[[16]] 1, --[[17]] 1, --[[18]] 1, --[[19]] 1, 
		--[[20]] 1, --[[21]] 1, --[[22]] 1, --[[23]] 1, --[[24]] 1, --[[25]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 1, --[[3]] 8, --[[4]] 8, --[[5]] 1, --[[6]] 1, --[[7]] 8, --[[8]] 1, --[[9]] 8, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 4, --[[14]] 1, --[[15]] 8, --[[16]] 1, --[[17]] 8, --[[18]] 1, --[[19]] 1, 
		--[[20]] 8, --[[21]] 8, --[[22]] 1, --[[23]] 1, --[[24]] 1, --[[25]] 1}, 
		
	}
	
else

	t_Bastion_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_Bastion1", --[[2]]"sg_SM_Bastion2", --[[3]]"sg_SM_Bastion3", --[[4]]"sg_SM_Bastion4", --[[5]]"sg_SM_Bastion5", --[[6]]"sg_SM_Bastion6", --[[7]]"sg_SM_Bastion7", 
		--[[8]]"sg_SM_Bastion8", --[[9]]"sg_SM_Bastion9", --[[10]]"sg_SM_Bastion10", --[[11]]"sg_SM_Bastion11", --[[12]]"sg_SM_Bastion12", --[[13]]"sg_SM_Bastion13", --[[14]]"sg_SM_Bastion14", 
		--[[15]]"sg_SM_Bastion15", --[[16]]"sg_SM_Bastion16", --[[17]]"sg_SM_Bastion17", --[[18]]"sg_SM_Bastion18", --[[19]]"sg_SM_Bastion19", --[[20]]"sg_SM_Bastion20", --[[21]]"sg_SM_Bastion21", --[[22]]"sg_SM_Bastion22",
		--[[23]]"sg_SM_Bastion23", --[[24]]"sg_SM_Bastion24", --[[25]]"sg_SM_Bastion25"},  
		
		blueprint = {--[[1]]"space_marine_squad_land_speeder", --[[2]]"space_marine_squad_land_speeder", --[[3]]"space_marine_squad_terminator_assault", 
		--[[4]]"space_marine_squad_terminator_assault", 	--[[5]]"space_marine_squad_apothecary", --[[6]]"space_marine_squad_apothecary", 
		--[[7]]"space_marine_squad_tactical", --[[8]]"space_marine_squad_apothecary", --[[9]]"space_marine_squad_tactical", 
		--[[10]]"space_marine_squad_apothecary", --[[11]]"space_marine_squad_predator", --[[12]]"space_marine_squad_predator", --[[13]]"space_marine_squad_terminator", 
		--[[14]]"space_marine_squad_apothecary",--[[15]]"space_marine_squad_tactical", --[[16]]"space_marine_squad_apothecary", 
		--[[17]]"space_marine_squad_apothecary", --[[18]]"space_marine_squad_apothecary", --[[19]]"space_marine_squad_force_commander_advance_sp",
		--[[20]]"space_marine_squad_tactical", --[[21]]"space_marine_squad_tactical", --[[22]]"space_marine_squad_librarian", --[[23]]"space_marine_squad_librarian",
		--[[24]]"space_marine_squad_librarian", --[[25]]"space_marine_squad_librarian"},
		
		marker_spawn = { --[[1]]"mkr_SM_Bastion1", --[[2]]"mkr_SM_Bastion2", --[[3]]"mkr_SM_Bastion3", --[[4]]"mkr_SM_Bastion4", --[[5]]"mkr_SM_Bastion5", --[[6]]"mkr_SM_Bastion6", --[[7]]"mkr_SM_Bastion7", 
		--[[8]]"mkr_SM_Bastion8", --[[9]]"mkr_SM_Bastion9", --[[10]]"mkr_SM_Bastion10", --[[11]]"mkr_SM_Bastion11", --[[12]]"mkr_SM_Bastion12", --[[13]]"mkr_SM_Bastion13", --[[14]]"mkr_SM_Bastion14", 
		--[[15]]"mkr_SM_Bastion15", --[[16]]"mkr_SM_Bastion16", --[[17]]"mkr_SM_Bastion17", --[[18]]"mkr_SM_Bastion18", --[[19]]"mkr_SM_Bastion19", --[[20]]"mkr_SM_Bastion20", --[[21]]"mkr_SM_Bastion21", 
		--[[22]]"mkr_SM_Bastion22", --[[23]]"mkr_SM_Bastion23", --[[24]]"mkr_SM_Bastion24", --[[25]]"mkr_SM_Bastion25"}, 
		
		squad_num = {--[[1]] 2, --[[2]] 2, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 2, --[[13]] 1, --[[14]] 1, --[[15]] 1, --[[16]] 1, --[[17]] 1, --[[18]] 1, --[[19]] 1, 
		--[[20]] 1, --[[21]] 1, --[[22]] 1, --[[23]] 1, --[[24]] 1, --[[25]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 1, --[[3]] 8, --[[4]] 8, --[[5]] 1, --[[6]] 1, --[[7]] 8, --[[8]] 1, --[[9]] 8, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 4, --[[14]] 1, --[[15]] 8, --[[16]] 1, --[[17]] 8, --[[18]] 1, --[[19]] 1, 
		--[[20]] 8, --[[21]] 8, --[[22]] 1, --[[23]] 1, --[[24]] 1, --[[25]] 1}, 
		
	}
	


end
	

local i = g_Bastion_Army_iter 
if g_Bastion_Army_iter <= table.getn(t_Bastion_Army.sgroup_name) and (SGroup_Exists(t_Bastion_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Bastion_Army.sgroup_name[i])) then
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_Bastion_Army.sgroup_name[i], t_Bastion_Army.blueprint[i], t_Bastion_Army.marker_spawn[i], t_Bastion_Army.squad_num[i], t_Bastion_Army.squad_size[i])
	
	--these space marines don't break
	if Squad_HasMorale(SGroup_GetSpawnedSquadAt(SGroup_FromName(t_Bastion_Army.sgroup_name[i]), 1)) then
		SGroup_SetMoraleInvulnerable(t_Bastion_Army.sgroup_name[i], true)
	end
	
	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_Bastion_Army"),  SGroup_FromName(t_Bastion_Army.sgroup_name[i]))
	
	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_Bastion_Army.sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_SM_Bastion_Army")

	
elseif g_Bastion_Army_iter > table.getn(t_Bastion_Army.sgroup_name) then
		g_Bastion_Army_iter = 0
		
		--upgrading the tac marines
		
		if g_Strength == 15 then
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion7"), 1), "space_marine_heavy_bolter_veteran", 5)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion9"), 1), "space_marine_heavy_bolter_veteran", 5)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion15"), 1), "space_marine_missile_launcher_veteran", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion17"), 1), "space_marine_flamer_veteran", 8)			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion17"), 1), "space_marine_missile_launcher_veteran", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion20"), 1), "space_marine_heavy_bolter_veteran", 9)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion21"), 1), "space_marine_heavy_bolter_veteran", 8)

		elseif g_Strength == 14 then
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion7"), 1), "space_marine_heavy_bolter_tactical", 5)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion9"), 1), "space_marine_heavy_bolter_tactical", 5)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion15"), 1), "space_marine_missile_launcher_tactical", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion17"), 1), "space_marine_flamer_tactical", 8)			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion17"), 1), "space_marine_missile_launcher_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion20"), 1), "space_marine_heavy_bolter_tactical", 9)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion21"), 1), "space_marine_heavy_bolter_tactical", 8)	


		elseif g_Strength == 13 then
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion7"), 1), "space_marine_heavy_bolter_tactical", 5)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion9"), 1), "space_marine_heavy_bolter_tactical", 5)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion15"), 1), "space_marine_missile_launcher_tactical", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion17"), 1), "space_marine_flamer_tactical", 8)			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion17"), 1), "space_marine_missile_launcher_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion20"), 1), "space_marine_heavy_bolter_tactical", 9)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion21"), 1), "space_marine_heavy_bolter_tactical", 8)
		
		
		elseif g_Strength == 12 then
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion7"), 1), "space_marine_heavy_bolter_tactical", 5)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion9"), 1), "space_marine_heavy_bolter_tactical", 5)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion15"), 1), "space_marine_missile_launcher_tactical", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion17"), 1), "space_marine_flamer_tactical", 8)			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion17"), 1), "space_marine_missile_launcher_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion20"), 1), "space_marine_heavy_bolter_tactical", 9)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion21"), 1), "space_marine_heavy_bolter_tactical", 8)
		
		
		elseif g_Strength == 11 then
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion7"), 1), "space_marine_heavy_bolter_tactical", 5)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion9"), 1), "space_marine_heavy_bolter_tactical", 5)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion15"), 1), "space_marine_missile_launcher_tactical", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion17"), 1), "space_marine_flamer_tactical", 8)			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion17"), 1), "space_marine_missile_launcher_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion20"), 1), "space_marine_heavy_bolter_tactical", 9)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion21"), 1), "space_marine_heavy_bolter_tactical", 8)
		
		
		else
		
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion7"), 1), "space_marine_heavy_bolter_tactical", 5)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion9"), 1), "space_marine_heavy_bolter_tactical", 5)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion15"), 1), "space_marine_missile_launcher_tactical", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion17"), 1), "space_marine_flamer_tactical", 8)			
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion17"), 1), "space_marine_missile_launcher_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion20"), 1), "space_marine_heavy_bolter_tactical", 9)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion21"), 1), "space_marine_heavy_bolter_tactical", 8)
		

		end
		
		
		if g_Strength == 15 then
		
			--attaching leaders
			Cmd_AttachSquads("sg_SM_Bastion4", "sg_SM_Bastion5")
			Cmd_AttachSquads("sg_SM_Bastion3", "sg_SM_Bastion6")
			Cmd_AttachSquads("sg_SM_Bastion7", "sg_SM_Bastion8")
			Cmd_AttachSquads("sg_SM_Bastion9", "sg_SM_Bastion10")
			Cmd_AttachSquads("sg_SM_Bastion13", "sg_SM_Bastion14")
			Cmd_AttachSquads("sg_SM_Bastion15", "sg_SM_Bastion16")
			Cmd_AttachSquads("sg_SM_Bastion17", "sg_SM_Bastion18")
		
		elseif g_Strength == 14 then
		
						--attaching leaders
			Cmd_AttachSquads("sg_SM_Bastion4", "sg_SM_Bastion5")
			Cmd_AttachSquads("sg_SM_Bastion3", "sg_SM_Bastion6")
			Cmd_AttachSquads("sg_SM_Bastion7", "sg_SM_Bastion8")
			Cmd_AttachSquads("sg_SM_Bastion9", "sg_SM_Bastion10")
			Cmd_AttachSquads("sg_SM_Bastion13", "sg_SM_Bastion14")
			Cmd_AttachSquads("sg_SM_Bastion15", "sg_SM_Bastion16")
			Cmd_AttachSquads("sg_SM_Bastion17", "sg_SM_Bastion18")
		
		elseif g_Strength == 13 then
		
						--attaching leaders
			Cmd_AttachSquads("sg_SM_Bastion4", "sg_SM_Bastion5")
			Cmd_AttachSquads("sg_SM_Bastion3", "sg_SM_Bastion6")
			Cmd_AttachSquads("sg_SM_Bastion7", "sg_SM_Bastion8")
			Cmd_AttachSquads("sg_SM_Bastion9", "sg_SM_Bastion10")
			Cmd_AttachSquads("sg_SM_Bastion13", "sg_SM_Bastion14")
			Cmd_AttachSquads("sg_SM_Bastion15", "sg_SM_Bastion16")
			Cmd_AttachSquads("sg_SM_Bastion17", "sg_SM_Bastion18")
		
		elseif g_Strength == 12 then
		
		
			--attaching leaders
			Cmd_AttachSquads("sg_SM_Bastion4", "sg_SM_Bastion5")
			Cmd_AttachSquads("sg_SM_Bastion3", "sg_SM_Bastion6")
			Cmd_AttachSquads("sg_SM_Bastion7", "sg_SM_Bastion8")
			Cmd_AttachSquads("sg_SM_Bastion9", "sg_SM_Bastion10")
			Cmd_AttachSquads("sg_SM_Bastion13", "sg_SM_Bastion14")
			Cmd_AttachSquads("sg_SM_Bastion15", "sg_SM_Bastion16")
			Cmd_AttachSquads("sg_SM_Bastion17", "sg_SM_Bastion18")
			
		elseif g_Strength == 11 then
		
			--attaching leaders
			Cmd_AttachSquads("sg_SM_Bastion4", "sg_SM_Bastion5")
			Cmd_AttachSquads("sg_SM_Bastion3", "sg_SM_Bastion6")
			Cmd_AttachSquads("sg_SM_Bastion7", "sg_SM_Bastion8")
			Cmd_AttachSquads("sg_SM_Bastion9", "sg_SM_Bastion10")
			Cmd_AttachSquads("sg_SM_Bastion13", "sg_SM_Bastion14")
			Cmd_AttachSquads("sg_SM_Bastion15", "sg_SM_Bastion16")
			Cmd_AttachSquads("sg_SM_Bastion17", "sg_SM_Bastion18")
		
		
		else
		
			--attaching leaders
			Cmd_AttachSquads("sg_SM_Bastion4", "sg_SM_Bastion5")
			Cmd_AttachSquads("sg_SM_Bastion3", "sg_SM_Bastion6")
			Cmd_AttachSquads("sg_SM_Bastion7", "sg_SM_Bastion8")
			Cmd_AttachSquads("sg_SM_Bastion9", "sg_SM_Bastion10")
			Cmd_AttachSquads("sg_SM_Bastion13", "sg_SM_Bastion14")
			Cmd_AttachSquads("sg_SM_Bastion15", "sg_SM_Bastion16")
			Cmd_AttachSquads("sg_SM_Bastion17", "sg_SM_Bastion18")
		
		end
		
		--these marines will follow the player a bit
		Cmd_SetStance("sg_SM_Bastion1", STANCE_Hold)
		Cmd_SetStance("sg_SM_Bastion2", STANCE_Hold)			
		Cmd_SetStance("sg_SM_Bastion11", STANCE_Hold)
		Cmd_SetStance("sg_SM_Bastion12", STANCE_Hold)
		Cmd_SetStance("sg_SM_Bastion15", STANCE_Hold)
		Cmd_SetStance("sg_SM_Bastion3", STANCE_Hold)
		
		Cmd_SetStance("sg_SM_Bastion13", STANCE_Hold)
		Cmd_SetStance("sg_SM_Bastion17", STANCE_Hold)
		
		Cmd_SetStance("sg_SM_Bastion4", STANCE_Attack)
		Cmd_SetStance("sg_SM_Bastion7", STANCE_Attack)
		Cmd_SetStance("sg_SM_Bastion9", STANCE_Attack)
		
		--SM commander
		Cmd_SetStance("sg_SM_Bastion19", STANCE_Attack)
		
		
		Cmd_SetStance("sg_SM_Bastion20", STANCE_StandGround)
		Cmd_SetStance("sg_SM_Bastion21", STANCE_StandGround)
		
		Cmd_SetStance("sg_SM_Bastion22", STANCE_StandGround)
		Cmd_SetStance("sg_SM_Bastion23", STANCE_StandGround)
		Cmd_SetStance("sg_SM_Bastion24", STANCE_StandGround)
		Cmd_SetStance("sg_SM_Bastion25", STANCE_StandGround)
		
	
		
		--giving the force commander his wargear research
		Player_GrantResearch(g_Player2, "marine_wargear_upgrade_09_greaves_research")
		Player_GrantResearch(g_Player2, "marine_wargear_upgrade_05_halo_research")
		Player_GrantResearch(g_Player2, "marine_wargear_upgrade_06_shoulders_research")
		Player_GrantResearch(g_Player2, "marine_wargear_upgrade_10_teleporter_research")
		Player_GrantResearch(g_Player2, "marine_wargear_upgrade_07_girdle_research")
		Player_GrantResearch(g_Player2, "marine_wargear_upgrade_08_gauntlets_research")
		Player_GrantResearch(g_Player2, "marine_wargear_upgrade_01_power_sword_research")
		Player_GrantResearch(g_Player2, "marine_wargear_upgrade_04_multi_melta_research")
		
		--infiltrate skull probes
		Player_GrantResearch(g_Player2, "marine_skull_probe_infiltrate_research")

		
		
		--giving the force commander his wargear
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion19"), 1),"space_marine_force_commander_greaves", 1)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion19"), 1),"space_marine_force_commander_halo", 1)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion19"), 1),"space_marine_force_commander_shoulders", 1)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion19"), 1),"space_marine_force_commander_teleporter", 1)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion19"), 1),"space_marine_force_commander_girdle", 1)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion19"), 1),"space_marine_force_commander_gauntlets", 1)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion19"), 1),"space_marine_power_sword_force_commander", 1)
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_Bastion19"), 1),"space_marine_bolt_pistol_combi_chaingun_forcecommander", 1)
		
			
		
		--makes the units move around so they look less static
		Rule_AddIntervalDelay(Rule_Static_Movement18, 60, 60)
		Rule_AddIntervalDelay(Rule_Static_Movement19, 60, 65)
		Rule_AddIntervalDelay(Rule_Static_Movement20, 60, 70)
		Rule_AddIntervalDelay(Rule_Static_Movement21, 60, 60)
		Rule_AddIntervalDelay(Rule_Static_Movement22, 60, 64)
		Rule_AddIntervalDelay(Rule_Static_Movement23, 60, 72)
		Rule_AddIntervalDelay(Rule_Static_Movement24, 60, 73)			
		Rule_AddIntervalDelay(Rule_Static_Movement31, 60, 60)
		Rule_AddIntervalDelay(Rule_Static_Movement32, 60, 63)
		Rule_AddIntervalDelay(Rule_Static_Movement33, 60, 65)
		Rule_AddIntervalDelay(Rule_Static_Movement34, 60, 67)
		
		Rule_AddOneShot(Rule_Count_Bastion, 5)
		
		Rule_Remove(Rule_SM_Bastion_Creation)

	
end
g_Bastion_Army_iter = g_Bastion_Army_iter+1

end

function Rule_Count_Bastion()

--count added seperatly to avoid problems with units attaching
g_Bastion = SGroup_Count(SGroup_FromName("sg_SM_Bastion_Army"))

end

--patrol army moving around left plateau

function Rule_Patrol_Army_A_Creation()

t_Patrol_Army_A = {
		
		sgroup_name = { --[[1]]"sg_SM_Patrol1"},  
		
		blueprint = {--[[1]]"space_marine_squad_land_speeder"},
		
		marker_spawn = {--[[1]]"mkr_PatrolA1"}, 
		
		squad_num = {--[[1]] 3}, 
		
		squad_size = {--[[1]] 1}, 
		
	}


local i = g_Patrol_Army_A_iter 
if g_Patrol_Army_A_iter <= table.getn(t_Patrol_Army_A.sgroup_name) and (SGroup_Exists(t_Patrol_Army_A.sgroup_name[i]) == false or SGroup_IsEmpty(t_Patrol_Army_A.sgroup_name[i])) then
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_Patrol_Army_A.sgroup_name[i], t_Patrol_Army_A.blueprint[i], t_Patrol_Army_A.marker_spawn[i], t_Patrol_Army_A.squad_num[i], t_Patrol_Army_A.squad_size[i])
	
	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_Patrol_Army_A.sgroup_name[i])

	
elseif g_Patrol_Army_A_iter > table.getn(t_Patrol_Army_A.sgroup_name) then
	g_Patrol_Army_A_iter = 0
	
	--count and save in a variable the number of units in the sg_SM_Bastion group
	g_Patrol_A = SGroup_Count(SGroup_FromName("sg_SM_Patrol1"))
	
	Rule_AddInterval(Rule_Patrol_A, 5)
	Rule_Remove(Rule_Patrol_Army_A_Creation)

	
end
g_Patrol_Army_A_iter = g_Patrol_Army_A_iter+1

end

--[[Reinforcements army 1]]

function Rule_SM_Reinforcements_1()

if g_Strength == 15 then

	t_SM_Reinforcements_1 = {
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_veteran_stronghold_sp", --[[4]]"space_marine_squad_veteran_stronghold_sp"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_3", --[[3]]"mkr_SM_Infantry_Drop_4", --[[4]]"mkr_SM_Infantry_Drop_2", }, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 2, --[[2]] 2,--[[3]] 1, --[[4]] 2}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true},
		
	}
	
elseif g_Strength == 14 then
	
	t_SM_Reinforcements_1 = {
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_3", --[[3]]"mkr_SM_Infantry_Drop_4", --[[4]]"mkr_SM_Infantry_Drop_2", }, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 2, --[[2]] 2,--[[3]] 1, --[[4]] 2}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true},
		
	}
	
elseif g_Strength == 13 then
	
	t_SM_Reinforcements_1 = {
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_3", --[[3]]"mkr_SM_Infantry_Drop_4", --[[4]]"mkr_SM_Infantry_Drop_2", }, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 2, --[[2]] 2,--[[3]] 1, --[[4]] 2}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true},
		
	}
	
elseif g_Strength == 12 then
	
	t_SM_Reinforcements_1 = {
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_3", --[[3]]"mkr_SM_Infantry_Drop_4", --[[4]]"mkr_SM_Infantry_Drop_2", }, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 4,--[[3]] 4, --[[4]] 4}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true},
		
	}
	
elseif g_Strength == 11 then
	
	t_SM_Reinforcements_1 = {
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_3", --[[3]]"mkr_SM_Infantry_Drop_4", --[[4]]"mkr_SM_Infantry_Drop_2", }, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 4,--[[3]] 4, --[[4]] 4}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true},
		
	}

else
	
	t_SM_Reinforcements_1 = {
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_3", --[[3]]"mkr_SM_Infantry_Drop_4", --[[4]]"mkr_SM_Infantry_Drop_2", }, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 4,--[[3]] 2, --[[4]] 4}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true},
		
	}

	
end

local i = g_SM_Reinforcement_Army_1_iter 
if g_SM_Reinforcement_Army_1_iter <= table.getn(t_SM_Reinforcements_1.sgroup_name) and (SGroup_Exists(t_SM_Reinforcements_1.sgroup_name[i]) == false or SGroup_IsEmpty(t_SM_Reinforcements_1.sgroup_name[i])) then
	
	if t_SM_Reinforcements_1.deepstrike[i] == true then
		
		local sgroupID = Util_CreateSquadsAndDropPodIn(g_Player2, t_SM_Reinforcements_1.sgroup_name[i], t_SM_Reinforcements_1.blueprint[i], Marker_GetPosition(Marker_FromName(t_SM_Reinforcements_1.marker_spawn[i], "basic_marker")), t_SM_Reinforcements_1.squad_num[i], t_SM_Reinforcements_1.squad_size[i])

	elseif t_SM_Reinforcements_1.deepstrike[i] == false then
		
		local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_SM_Reinforcements_1.sgroup_name[i], t_SM_Reinforcements_1.blueprint[i], t_SM_Reinforcements_1.marker_spawn[i], t_SM_Reinforcements_1.squad_num[i], t_SM_Reinforcements_1.squad_size[i])
	
	end

	--these space marines don't break
	if g_Moral == true then
		SGroup_SetMoraleInvulnerable(t_SM_Reinforcements_1.sgroup_name[i], true)
	end

	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_Reinforcement"),  SGroup_FromName(t_SM_Reinforcements_1.sgroup_name[i]))
	
	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_SM_Reinforcements_1.sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_SM_Reinforcement")
	
	
elseif g_SM_Reinforcement_Army_1_iter > table.getn(t_SM_Reinforcements_1.sgroup_name) then
		g_SM_Reinforcement_Army_1_iter = 0
					
		
		Rule_Remove(Rule_SM_Reinforcements_1)

		Cmd_MoveToMarker("sg_SM_Reinforcement", "mkr_SM_Gate1")
		
		--where do the reinforcements go?
		if Rule_Exists(Rule_Meeting_Point) == false then
			Rule_AddInterval(Rule_Meeting_Point, 1)
		end
	
end
g_SM_Reinforcement_Army_1_iter = g_SM_Reinforcement_Army_1_iter+1

end

--[[Reinforcements army 2]]

function Rule_SM_Reinforcements_2()

if g_Strength == 15 then

	t_SM_Reinforcements_2 = {
		
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_veteran_stronghold_sp", --[[4]]"space_marine_squad_veteran_stronghold_sp", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_land_speeder", --[[7]]"space_marine_squad_land_speeder", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_Drop_Reinforcement1", --[[2]]"mkr_SM_Infantry_Drop_3", --[[3]]"mkr_SM_Infantry_Drop_4", --[[4]]"mkr_SM_Infantry_Drop_2", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 2, --[[2]] 4,--[[3]] 3, --[[4]] 4, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
	}

elseif g_Strength == 14 then

	t_SM_Reinforcements_2 = {
		
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_land_speeder", --[[7]]"space_marine_squad_land_speeder", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_Drop_Reinforcement1", --[[2]]"mkr_SM_Infantry_Drop_3", --[[3]]"mkr_SM_Infantry_Drop_4", --[[4]]"mkr_SM_Infantry_Drop_2", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 2, --[[2]] 2,--[[3]] 3, --[[4]] 4, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
		}


elseif g_Strength == 13 then

	t_SM_Reinforcements_2 = {
		
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_land_speeder", --[[7]]"space_marine_squad_land_speeder", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_Drop_Reinforcement1", --[[2]]"mkr_SM_Infantry_Drop_3", --[[3]]"mkr_SM_Infantry_Drop_4", --[[4]]"mkr_SM_Infantry_Drop_2", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 2, --[[2]] 4,--[[3]] 3, --[[4]] 4, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
		}

elseif g_Strength == 12 then

	t_SM_Reinforcements_2 = {
	
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_land_speeder", --[[7]]"space_marine_squad_land_speeder", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_Drop_Reinforcement1", --[[2]]"mkr_SM_Infantry_Drop_3", --[[3]]"mkr_SM_Infantry_Drop_4", --[[4]]"mkr_SM_Infantry_Drop_2", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 4,--[[3]] 4, --[[4]] 4, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
		}

elseif g_Strength == 11 then

	t_SM_Reinforcements_2 = {
		
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_land_speeder", --[[7]]"space_marine_squad_land_speeder", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_Drop_Reinforcement1", --[[2]]"mkr_SM_Infantry_Drop_3", --[[3]]"mkr_SM_Infantry_Drop_4", --[[4]]"mkr_SM_Infantry_Drop_2", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 3, --[[2]] 4,--[[3]] 3, --[[4]] 4, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
		}

else
	
	
	t_SM_Reinforcements_2 = {
		
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_land_speeder", --[[7]]"space_marine_squad_land_speeder", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_Drop_Reinforcement1", --[[2]]"mkr_SM_Infantry_Drop_3", --[[3]]"mkr_SM_Infantry_Drop_4", --[[4]]"mkr_SM_Infantry_Drop_2", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 2, --[[2]] 4,--[[3]] 3, --[[4]] 4, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
	}
	
end


local i = g_SM_Reinforcement_Army_2_iter 
if g_SM_Reinforcement_Army_2_iter <= table.getn(t_SM_Reinforcements_2.sgroup_name) and (SGroup_Exists(t_SM_Reinforcements_2.sgroup_name[i]) == false or SGroup_IsEmpty(t_SM_Reinforcements_2.sgroup_name[i])) then
			
	if t_SM_Reinforcements_2.deepstrike[i] == true then
		
		local sgroupID = Util_CreateSquadsAndDropPodIn(g_Player2, t_SM_Reinforcements_2.sgroup_name[i], t_SM_Reinforcements_2.blueprint[i], Marker_GetPosition(Marker_FromName(t_SM_Reinforcements_2.marker_spawn[i], "basic_marker")), t_SM_Reinforcements_2.squad_num[i], 
		t_SM_Reinforcements_2.squad_size[i])

	elseif t_SM_Reinforcements_2.deepstrike[i] == false then
		
		local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_SM_Reinforcements_2.sgroup_name[i], t_SM_Reinforcements_2.blueprint[i], t_SM_Reinforcements_2.marker_spawn[i], t_SM_Reinforcements_2.squad_num[i], t_SM_Reinforcements_2.squad_size[i])
	
	end
	
	--if the relic is not captured then their moral doesn't break
	if g_Moral == true then
		SGroup_SetMoraleInvulnerable(t_SM_Reinforcements_2.sgroup_name[i], true)
	end
	
	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_Reinforcement"),  SGroup_FromName(t_SM_Reinforcements_2.sgroup_name[i]))	
	
	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_SM_Reinforcements_2.sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_SM_Reinforcement")
	
elseif g_SM_Reinforcement_Army_2_iter > table.getn(t_SM_Reinforcements_2.sgroup_name) then
		g_SM_Reinforcement_Army_2_iter = 0
		
		
		
		Rule_Remove(Rule_SM_Reinforcements_2)
		Cmd_MoveToMarker("sg_SM_Reinforcement", "mkr_SM_Gate1")
		
		--where do the reinforcements go?
		if Rule_Exists(Rule_Meeting_Point) == false then
			Rule_AddInterval(Rule_Meeting_Point, 1)
		end
	
end
g_SM_Reinforcement_Army_2_iter = g_SM_Reinforcement_Army_2_iter+1

end

--[[Reinforcements army 3]]

function Rule_SM_Reinforcements_3()

if g_Strength == 15 then

	t_SM_Reinforcements_3 = {
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_veteran_stronghold_sp", --[[4]]"space_marine_squad_veteran_stronghold_sp", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_land_speeder", --[[7]]"space_marine_squad_dreadnought_hellfire", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_2", --[[3]]"mkr_SM_Infantry_Drop_1", --[[4]]"mkr_SM_Infantry_Drop_2", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 5,--[[3]] 5, --[[4]] 5, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
	}

elseif g_Strength == 14 then

	t_SM_Reinforcements_3 = {
	
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_land_speeder", --[[7]]"space_marine_squad_dreadnought_hellfire", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_2", --[[3]]"mkr_SM_Infantry_Drop_1", --[[4]]"mkr_SM_Infantry_Drop_2", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 3, --[[2]] 3,--[[3]] 5, --[[4]] 5, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
	}

elseif g_Strength == 13 then

	t_SM_Reinforcements_3 = {
	
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_land_speeder", --[[7]]"space_marine_squad_dreadnought_hellfire", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_2", --[[3]]"mkr_SM_Infantry_Drop_1", --[[4]]"mkr_SM_Infantry_Drop_2", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 5,--[[3]] 5, --[[4]] 5, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
	}

elseif g_Strength == 12 then

	t_SM_Reinforcements_3 = {
	
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_land_speeder", --[[7]]"space_marine_squad_dreadnought_hellfire", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_2", --[[3]]"mkr_SM_Infantry_Drop_1", --[[4]]"mkr_SM_Infantry_Drop_2", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 6, --[[2]] 6,--[[3]] 5, --[[4]] 5, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
	}

elseif g_Strength == 11 then


	t_SM_Reinforcements_3 = {
	
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_land_speeder", --[[7]]"space_marine_squad_dreadnought_hellfire", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_2", --[[3]]"mkr_SM_Infantry_Drop_1", --[[4]]"mkr_SM_Infantry_Drop_2", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 5, --[[2]] 5,--[[3]] 5, --[[4]] 5, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
	}

else


	t_SM_Reinforcements_3 = {
	
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_land_speeder", --[[7]]"space_marine_squad_dreadnought_hellfire", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_2", --[[3]]"mkr_SM_Infantry_Drop_1", --[[4]]"mkr_SM_Infantry_Drop_2", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 5,--[[3]] 5, --[[4]] 5, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
	}

end

local i = g_SM_Reinforcement_Army_3_iter 
if g_SM_Reinforcement_Army_3_iter <= table.getn(t_SM_Reinforcements_3.sgroup_name) and (SGroup_Exists(t_SM_Reinforcements_3.sgroup_name[i]) == false or SGroup_IsEmpty(t_SM_Reinforcements_3.sgroup_name[i])) then
	
	if t_SM_Reinforcements_3.deepstrike[i] == true then
		
		local sgroupID = Util_CreateSquadsAndDropPodIn(g_Player2, t_SM_Reinforcements_3.sgroup_name[i], t_SM_Reinforcements_3.blueprint[i], Marker_GetPosition(Marker_FromName(t_SM_Reinforcements_3.marker_spawn[i], "basic_marker")), t_SM_Reinforcements_3.squad_num[i], 
		t_SM_Reinforcements_3.squad_size[i])

	elseif t_SM_Reinforcements_3.deepstrike[i] == false then
		
		local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_SM_Reinforcements_3.sgroup_name[i], t_SM_Reinforcements_3.blueprint[i], t_SM_Reinforcements_3.marker_spawn[i], t_SM_Reinforcements_3.squad_num[i], t_SM_Reinforcements_3.squad_size[i])
	
	end
	
	
	--if the relic is not captured then their moral doesn't break
	if g_Moral == true then
		SGroup_SetMoraleInvulnerable(t_SM_Reinforcements_3.sgroup_name[i], true)
	end
	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_Reinforcement"),  SGroup_FromName(t_SM_Reinforcements_3.sgroup_name[i]))	
	
	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_SM_Reinforcements_3.sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_SM_Reinforcement")
	
elseif g_SM_Reinforcement_Army_3_iter > table.getn(t_SM_Reinforcements_3.sgroup_name) then
		g_SM_Reinforcement_Army_3_iter = 0
		
		
		
		Rule_Remove(Rule_SM_Reinforcements_3)
		Cmd_MoveToMarker("sg_SM_Reinforcement", "mkr_SM_Gate1")
		
		--where do the reinforcements go?
		if Rule_Exists(Rule_Meeting_Point) == false then
			Rule_AddInterval(Rule_Meeting_Point, 1)
		end
	
end
g_SM_Reinforcement_Army_3_iter = g_SM_Reinforcement_Army_3_iter+1

end

--[[Reinforcements army 4]]

function Rule_SM_Reinforcements_4()

if g_Strength == 15 then
	
	t_SM_Reinforcements_4 = {
		
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_veteran_stronghold_sp", --[[4]]"space_marine_squad_land_speeder", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_predator", --[[7]]"space_marine_squad_dreadnought_hellfire", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_2", --[[3]]"mkr_SM_Infantry_Drop_1", --[[4]]"mkr_SM_Vehicle_Drop1", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 5, --[[2]] 4,--[[3]] 5, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
	}

elseif g_Strength == 14 then

	t_SM_Reinforcements_4 = {
	
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_land_speeder", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_predator", --[[7]]"space_marine_squad_dreadnought_hellfire", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_2", --[[3]]"mkr_SM_Infantry_Drop_1", --[[4]]"mkr_SM_Vehicle_Drop1", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 3, --[[2]] 3,--[[3]] 5, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
	}

elseif g_Strength == 13 then
	
	t_SM_Reinforcements_4 = {
	
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_land_speeder", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_predator", --[[7]]"space_marine_squad_dreadnought_hellfire", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_2", --[[3]]"mkr_SM_Infantry_Drop_1", --[[4]]"mkr_SM_Vehicle_Drop1", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 3, --[[2]] 4,--[[3]] 5, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
	}

elseif g_Strength == 12 then

	t_SM_Reinforcements_4 = {
	
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_land_speeder", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_predator", --[[7]]"space_marine_squad_dreadnought_hellfire", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_2", --[[3]]"mkr_SM_Infantry_Drop_1", --[[4]]"mkr_SM_Vehicle_Drop1", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 6, --[[2]] 6,--[[3]] 5, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
	}

elseif g_Strength == 11 then

	t_SM_Reinforcements_4 = {
	
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_land_speeder", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_predator", --[[7]]"space_marine_squad_dreadnought_hellfire", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_2", --[[3]]"mkr_SM_Infantry_Drop_1", --[[4]]"mkr_SM_Vehicle_Drop1", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 6, --[[2]] 5,--[[3]] 5, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
	}

else


	t_SM_Reinforcements_4 = {
	
		sgroup_name = { --[[1]]"sg_SM_Reinforcement1", --[[2]]"sg_SM_Reinforcement2", --[[3]]"sg_SM_Reinforcement3", --[[4]]"sg_SM_Reinforcement4", --[[5]]"sg_SM_Reinforcement5", --[[6]]"sg_SM_Reinforcement6",
		--[[7]]"sg_SM_Reinforcement7", --[[8]]"sg_SM_Reinforcement8"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_land_speeder", --[[5]]"space_marine_squad_land_speeder", 
		--[[6]]"space_marine_squad_predator", --[[7]]"space_marine_squad_dreadnought_hellfire", --[[8]]"space_marine_squad_dreadnought"},
		
		marker_spawn = {--[[1]]"mkr_SM_Infantry_Drop_1", --[[2]]"mkr_SM_Infantry_Drop_2", --[[3]]"mkr_SM_Infantry_Drop_1", --[[4]]"mkr_SM_Vehicle_Drop1", --[[5]]"mkr_SM_Vehicle_Drop1", --[[6]]"mkr_SM_Vehicle_Drop2",
		--[[7]]"mkr_SM_Vehicle_Drop1", --[[8]]"mkr_SM_Vehicle_Drop2"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		squad_size = {--[[1]] 5, --[[2]] 4,--[[3]] 5, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
		
		deepstrike = {--[[1]] true, --[[2]] true,--[[3]] true, --[[4]] true, --[[5]] false, --[[6]] false, --[[7]] false, --[[8]] false},
		
	}
	
end

local i = g_SM_Reinforcement_Army_4_iter 
if g_SM_Reinforcement_Army_4_iter <= table.getn(t_SM_Reinforcements_4.sgroup_name) and (SGroup_Exists(t_SM_Reinforcements_4.sgroup_name[i]) == false or SGroup_IsEmpty(t_SM_Reinforcements_4.sgroup_name[i])) then
		
	if t_SM_Reinforcements_4.deepstrike[i] == true then
		
		local sgroupID = Util_CreateSquadsAndDropPodIn(g_Player2, t_SM_Reinforcements_4.sgroup_name[i], t_SM_Reinforcements_4.blueprint[i], Marker_GetPosition(Marker_FromName(t_SM_Reinforcements_4.marker_spawn[i], "basic_marker")), t_SM_Reinforcements_4.squad_num[i], 
		t_SM_Reinforcements_4.squad_size[i])

	elseif t_SM_Reinforcements_4.deepstrike[i] == false then
		
		local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_SM_Reinforcements_4.sgroup_name[i], t_SM_Reinforcements_4.blueprint[i], t_SM_Reinforcements_4.marker_spawn[i], t_SM_Reinforcements_4.squad_num[i], t_SM_Reinforcements_4.squad_size[i])
	
	end
	
	--these space marines don't break unless the relic is captured
	if g_Moral == true then
		SGroup_SetMoraleInvulnerable(t_SM_Reinforcements_4.sgroup_name[i], true)
	end
	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_Reinforcement"),  SGroup_FromName(t_SM_Reinforcements_4.sgroup_name[i]))	
	
	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_SM_Reinforcements_4.sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_SM_Reinforcement")
	
elseif g_SM_Reinforcement_Army_4_iter > table.getn(t_SM_Reinforcements_4.sgroup_name) then
		g_SM_Reinforcement_Army_4_iter = 0
		

			
		Rule_Remove(Rule_SM_Reinforcements_4)
		Cmd_MoveToMarker("sg_SM_Reinforcement", "mkr_SM_Gate1")
		
		--where do the reinforcements go?
		if Rule_Exists(Rule_Meeting_Point) == false then
			Rule_AddInterval(Rule_Meeting_Point, 1)
		end
	
end
g_SM_Reinforcement_Army_4_iter = g_SM_Reinforcement_Army_4_iter+1

end

--[[Assault marine raid forward left plateau]]

function Rule_FLP_Army()

if g_Strength == 15 then
	
	t_FLP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_FLP1", --[[2]]"sg_SM_FLP2", --[[3]]"sg_SM_FLP3", --[[4]]"sg_SM_FLP4", --[[5]]"sg_SM_FLPE1", --[[6]]"sg_SM_FLPE2", },  
		
		blueprint = {--[[1]]"space_marine_squad_dreadnought_hellfire", --[[2]]"space_marine_squad_assault_veteran_stronghold_sp", --[[3]]"space_marine_squad_dreadnought_hellfire", --[[4]]"space_marine_squad_assault_veteran_stronghold_sp", --[[5]]"space_marine_squad_assault_veteran_stronghold_sp",
		--[[6]]"space_marine_squad_veteran_stronghold_sp", },
		
		marker_spawn = {--[[1]]"mkr_FLP_Raid1", --[[2]]"mkr_FLP_Raid2", --[[3]]"mkr_FLP_Raid3", --[[4]]"mkr_FLP_Escort1", --[[5]]"mkr_FLP_Escort2", --[[6]]"mkr_FLP_Escort3", 
		}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1,}, 
		
		squad_size = {--[[1]] 4, --[[2]] 4,--[[3]] 3, --[[4]] 4, --[[5]] 4, --[[6]] 4,}, 
		
	}

elseif g_Strength == 14 then

		t_FLP_Army = {
			
			sgroup_name = { --[[1]]"sg_SM_FLP1", --[[2]]"sg_SM_FLP2", --[[3]]"sg_SM_FLP3", --[[4]]"sg_SM_FLP4", --[[5]]"sg_SM_FLPE1", --[[6]]"sg_SM_FLPE2", },  
			
			blueprint = {--[[1]]"space_marine_squad_dreadnought_hellfire", --[[2]]"space_marine_squad_assault", --[[3]]"space_marine_squad_dreadnought_hellfire", --[[4]]"space_marine_squad_assault", --[[5]]"space_marine_squad_assault",
			--[[6]]"space_marine_squad_tactical", },
			
			marker_spawn = {--[[1]]"mkr_FLP_Raid1", --[[2]]"mkr_FLP_Raid2", --[[3]]"mkr_FLP_Raid3", --[[4]]"mkr_FLP_Escort1", --[[5]]"mkr_FLP_Escort2", --[[6]]"mkr_FLP_Escort3", 
			}, 
			
			squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1,}, 
			
			squad_size = {--[[1]] 4, --[[2]] 4,--[[3]] 3, --[[4]] 4, --[[5]] 4, --[[6]] 4,}, 
			
		}


elseif g_Strength == 13 then

		t_FLP_Army = {
			
			sgroup_name = { --[[1]]"sg_SM_FLP1", --[[2]]"sg_SM_FLP2", --[[3]]"sg_SM_FLP3", --[[4]]"sg_SM_FLP4", --[[5]]"sg_SM_FLPE1", --[[6]]"sg_SM_FLPE2", },  
			
			blueprint = {--[[1]]"space_marine_squad_dreadnought_hellfire", --[[2]]"space_marine_squad_assault_veteran_stronghold_sp", --[[3]]"space_marine_squad_dreadnought_hellfire", --[[4]]"space_marine_squad_assault", --[[5]]"space_marine_squad_assault",
			--[[6]]"space_marine_squad_veteran_stronghold_sp", },
			
			marker_spawn = {--[[1]]"mkr_FLP_Raid1", --[[2]]"mkr_FLP_Raid2", --[[3]]"mkr_FLP_Raid3", --[[4]]"mkr_FLP_Escort1", --[[5]]"mkr_FLP_Escort2", --[[6]]"mkr_FLP_Escort3", 
			}, 
			
			squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1,}, 
			
			squad_size = {--[[1]] 4, --[[2]] 2,--[[3]] 3, --[[4]] 4, --[[5]] 4, --[[6]] 4,}, 
			
		}

elseif g_Strength == 12 then

		t_FLP_Army = {
			
			sgroup_name = { --[[1]]"sg_SM_FLP1", --[[2]]"sg_SM_FLP2", --[[3]]"sg_SM_FLP3", --[[4]]"sg_SM_FLP4", --[[5]]"sg_SM_FLPE1", --[[6]]"sg_SM_FLPE2", },  
			
			blueprint = {--[[1]]"space_marine_squad_dreadnought_hellfire", --[[2]]"space_marine_squad_assault", --[[3]]"space_marine_squad_dreadnought_hellfire", --[[4]]"space_marine_squad_assault", --[[5]]"space_marine_squad_assault",
			--[[6]]"space_marine_squad_veteran_stronghold_sp", },
			
			marker_spawn = {--[[1]]"mkr_FLP_Raid1", --[[2]]"mkr_FLP_Raid2", --[[3]]"mkr_FLP_Raid3", --[[4]]"mkr_FLP_Escort1", --[[5]]"mkr_FLP_Escort2", --[[6]]"mkr_FLP_Escort3", 
			}, 
			
			squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1,}, 
			
			squad_size = {--[[1]] 4, --[[2]] 4,--[[3]] 3, --[[4]] 4, --[[5]] 4, --[[6]] 4,}, 
			
		}

elseif g_Strength == 11 then


		t_FLP_Army = {
			
			sgroup_name = { --[[1]]"sg_SM_FLP1", --[[2]]"sg_SM_FLP2", --[[3]]"sg_SM_FLP3", --[[4]]"sg_SM_FLP4", --[[5]]"sg_SM_FLPE1", --[[6]]"sg_SM_FLPE2", },  
			
			blueprint = {--[[1]]"space_marine_squad_dreadnought_hellfire", --[[2]]"space_marine_squad_assault", --[[3]]"space_marine_squad_dreadnought_hellfire", --[[4]]"space_marine_squad_assault", --[[5]]"space_marine_squad_assault",
			--[[6]]"space_marine_squad_tactical", },
			
			marker_spawn = {--[[1]]"mkr_FLP_Raid1", --[[2]]"mkr_FLP_Raid2", --[[3]]"mkr_FLP_Raid3", --[[4]]"mkr_FLP_Escort1", --[[5]]"mkr_FLP_Escort2", --[[6]]"mkr_FLP_Escort3", 
			}, 
			
			squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1,}, 
			
			squad_size = {--[[1]] 4, --[[2]] 4,--[[3]] 3, --[[4]] 4, --[[5]] 4, --[[6]] 6,}, 
			
		}

else

		t_FLP_Army = {
			
			sgroup_name = { --[[1]]"sg_SM_FLP1", --[[2]]"sg_SM_FLP2", --[[3]]"sg_SM_FLP3", --[[4]]"sg_SM_FLP4", --[[5]]"sg_SM_FLPE1", --[[6]]"sg_SM_FLPE2", },  
			
			blueprint = {--[[1]]"space_marine_squad_dreadnought_hellfire", --[[2]]"space_marine_squad_assault", --[[3]]"space_marine_squad_dreadnought_hellfire", --[[4]]"space_marine_squad_assault", --[[5]]"space_marine_squad_assault",
			--[[6]]"space_marine_squad_tactical", },
			
			marker_spawn = {--[[1]]"mkr_FLP_Raid1", --[[2]]"mkr_FLP_Raid2", --[[3]]"mkr_FLP_Raid3", --[[4]]"mkr_FLP_Escort1", --[[5]]"mkr_FLP_Escort2", --[[6]]"mkr_FLP_Escort3", 
			}, 
			
			squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1,}, 
			
			squad_size = {--[[1]] 4, --[[2]] 4,--[[3]] 3, --[[4]] 4, --[[5]] 4, --[[6]] 4,}, 
			
		}

end


local i = g_FLP_Army_iter 
if g_FLP_Army_iter <= table.getn(t_FLP_Army.sgroup_name) and (SGroup_Exists(t_FLP_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_FLP_Army.sgroup_name[i])) then
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_FLP_Army.sgroup_name[i], t_FLP_Army.blueprint[i], t_FLP_Army.marker_spawn[i], t_FLP_Army.squad_num[i], t_FLP_Army.squad_size[i])
	
	--these space marines don't break
	if Squad_HasMorale(SGroup_GetSpawnedSquadAt(SGroup_FromName(t_FLP_Army.sgroup_name[i]), 1)) then
		SGroup_SetMoraleInvulnerable(t_FLP_Army.sgroup_name[i], true)
	end
	
	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_FLP"),  SGroup_FromName(t_FLP_Army.sgroup_name[i]))
	
	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_FLP_Army.sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_SM_FLP")
	
elseif g_FLP_Army_iter > table.getn(t_FLP_Army.sgroup_name) then
		g_FLP_Army_iter = 0
		
		Cmd_SetStance("sg_SM_FLP", STANCE_Hold)
		
		Rule_Remove(Rule_FLP_Army)


end
g_FLP_Army_iter = g_FLP_Army_iter+1

end

--[[Defenders of the forward right plateau and the vehicle HQ]]

function Rule_FRP_Army()

if g_Strength == 15 then
	
	t_FRP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_FRP1", --[[2]]"sg_SM_FRP2", --[[3]]"sg_SM_FRP3", --[[4]]"sg_SM_FRP4", --[[5]]"sg_SM_FRP5", --[[6]]"sg_SM_FRP6", --[[7]]"sg_SM_FRP7", --[[8]]"sg_SM_FRP8", --[[9]]"sg_SM_FRP9",
		--[[10]]"sg_SM_FRP10", --[[11]]"sg_SM_FRP11"},  
		
		blueprint = {--[[1]]"space_marine_squad_dreadnought", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_veteran_stronghold_sp", --[[4]]"space_marine_squad_land_speeder", --[[5]]"space_marine_squad_land_speeder",
		--[[6]]"space_marine_squad_assault_veteran_stronghold_sp", --[[7]]"space_marine_squad_land_speeder", --[[8]]"space_marine_squad_land_speeder", --[[9]]"space_marine_squad_land_speeder", --[[10]]"space_marine_squad_veteran_stronghold_sp", 
		--[[11]]"space_marine_squad_veteran_stronghold_sp"},
		
		marker_spawn = {--[[1]]"mkr_FRP1", --[[2]]"mkr_FRP2", --[[3]]"mkr_FRP3", --[[4]]"mkr_FRP4", --[[5]]"mkr_FRP5", --[[6]]"mkr_FRP6", --[[7]]"mkr_FRP7", --[[8]]"mkr_FRP8", --[[9]]"mkr_FRP9", --[[10]]"mkr_FRP10", 
		--[[11]]"mkr_FRP11"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 7, --[[3]] 8, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 8, --[[11]] 7}, 
		
	}

elseif g_Strength == 14 then

	t_FRP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_FRP1", --[[2]]"sg_SM_FRP2", --[[3]]"sg_SM_FRP3", --[[4]]"sg_SM_FRP4", --[[5]]"sg_SM_FRP5", --[[6]]"sg_SM_FRP6", --[[7]]"sg_SM_FRP7", --[[8]]"sg_SM_FRP8", --[[9]]"sg_SM_FRP9",
		--[[10]]"sg_SM_FRP10", --[[11]]"sg_SM_FRP11"},  
		
		blueprint = {--[[1]]"space_marine_squad_dreadnought", --[[2]]"space_marine_squad_veteran_stronghold_sp", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_land_speeder", --[[5]]"space_marine_squad_land_speeder",
		--[[6]]"space_marine_squad_assault", --[[7]]"space_marine_squad_land_speeder", --[[8]]"space_marine_squad_land_speeder", --[[9]]"space_marine_squad_land_speeder", --[[10]]"space_marine_squad_tactical", 
		--[[11]]"space_marine_squad_veteran_stronghold_sp"},
		
		marker_spawn = {--[[1]]"mkr_FRP1", --[[2]]"mkr_FRP2", --[[3]]"mkr_FRP3", --[[4]]"mkr_FRP4", --[[5]]"mkr_FRP5", --[[6]]"mkr_FRP6", --[[7]]"mkr_FRP7", --[[8]]"mkr_FRP8", --[[9]]"mkr_FRP9", --[[10]]"mkr_FRP10", 
		--[[11]]"mkr_FRP11"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 4, --[[3]] 8, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 8, --[[11]] 4}, 
		
	}


elseif g_Strength == 13 then

	t_FRP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_FRP1", --[[2]]"sg_SM_FRP2", --[[3]]"sg_SM_FRP3", --[[4]]"sg_SM_FRP4", --[[5]]"sg_SM_FRP5", --[[6]]"sg_SM_FRP6", --[[7]]"sg_SM_FRP7", --[[8]]"sg_SM_FRP8", --[[9]]"sg_SM_FRP9",
		--[[10]]"sg_SM_FRP10", --[[11]]"sg_SM_FRP11"},  
		
		blueprint = {--[[1]]"space_marine_squad_dreadnought", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_land_speeder", --[[5]]"space_marine_squad_land_speeder",
		--[[6]]"space_marine_squad_assault", --[[7]]"space_marine_squad_land_speeder", --[[8]]"space_marine_squad_land_speeder", --[[9]]"space_marine_squad_land_speeder", --[[10]]"space_marine_squad_tactical", 
		--[[11]]"space_marine_squad_veteran_stronghold_sp"},
		
		marker_spawn = {--[[1]]"mkr_FRP1", --[[2]]"mkr_FRP2", --[[3]]"mkr_FRP3", --[[4]]"mkr_FRP4", --[[5]]"mkr_FRP5", --[[6]]"mkr_FRP6", --[[7]]"mkr_FRP7", --[[8]]"mkr_FRP8", --[[9]]"mkr_FRP9", --[[10]]"mkr_FRP10", 
		--[[11]]"mkr_FRP11"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 7, --[[3]] 8, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 8, --[[11]] 5}, 
		
	}

elseif g_Strength == 12 then

	t_FRP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_FRP1", --[[2]]"sg_SM_FRP2", --[[3]]"sg_SM_FRP3", --[[4]]"sg_SM_FRP4", --[[5]]"sg_SM_FRP5", --[[6]]"sg_SM_FRP6", --[[7]]"sg_SM_FRP7", --[[8]]"sg_SM_FRP8", --[[9]]"sg_SM_FRP9",
		--[[10]]"sg_SM_FRP10", --[[11]]"sg_SM_FRP11"},  
		
		blueprint = {--[[1]]"space_marine_squad_dreadnought", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_land_speeder", --[[5]]"space_marine_squad_land_speeder",
		--[[6]]"space_marine_squad_assault", --[[7]]"space_marine_squad_land_speeder", --[[8]]"space_marine_squad_land_speeder", --[[9]]"space_marine_squad_land_speeder", --[[10]]"space_marine_squad_tactical", 
		--[[11]]"space_marine_squad_tactical"},
		
		marker_spawn = {--[[1]]"mkr_FRP1", --[[2]]"mkr_FRP2", --[[3]]"mkr_FRP3", --[[4]]"mkr_FRP4", --[[5]]"mkr_FRP5", --[[6]]"mkr_FRP6", --[[7]]"mkr_FRP7", --[[8]]"mkr_FRP8", --[[9]]"mkr_FRP9", --[[10]]"mkr_FRP10", 
		--[[11]]"mkr_FRP11"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 8, --[[3]] 8, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 8, --[[11]] 8}, 
		
	}


elseif g_Strength == 11 then

	t_FRP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_FRP1", --[[2]]"sg_SM_FRP2", --[[3]]"sg_SM_FRP3", --[[4]]"sg_SM_FRP4", --[[5]]"sg_SM_FRP5", --[[6]]"sg_SM_FRP6", --[[7]]"sg_SM_FRP7", --[[8]]"sg_SM_FRP8", --[[9]]"sg_SM_FRP9",
		--[[10]]"sg_SM_FRP10", --[[11]]"sg_SM_FRP11"},  
		
		blueprint = {--[[1]]"space_marine_squad_dreadnought", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_land_speeder", --[[5]]"space_marine_squad_land_speeder",
		--[[6]]"space_marine_squad_assault", --[[7]]"space_marine_squad_land_speeder", --[[8]]"space_marine_squad_land_speeder", --[[9]]"space_marine_squad_land_speeder", --[[10]]"space_marine_squad_tactical", 
		--[[11]]"space_marine_squad_tactical"},
		
		marker_spawn = {--[[1]]"mkr_FRP1", --[[2]]"mkr_FRP2", --[[3]]"mkr_FRP3", --[[4]]"mkr_FRP4", --[[5]]"mkr_FRP5", --[[6]]"mkr_FRP6", --[[7]]"mkr_FRP7", --[[8]]"mkr_FRP8", --[[9]]"mkr_FRP9", --[[10]]"mkr_FRP10", 
		--[[11]]"mkr_FRP11"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 7, --[[3]] 8, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 8, --[[11]] 8}, 
		
	}


else
	
	t_FRP_Army = {
		
		sgroup_name = { --[[1]]"sg_SM_FRP1", --[[2]]"sg_SM_FRP2", --[[3]]"sg_SM_FRP3", --[[4]]"sg_SM_FRP4", --[[5]]"sg_SM_FRP5", --[[6]]"sg_SM_FRP6", --[[7]]"sg_SM_FRP7", --[[8]]"sg_SM_FRP8", --[[9]]"sg_SM_FRP9",
		--[[10]]"sg_SM_FRP10", --[[11]]"sg_SM_FRP11"},  
		
		blueprint = {--[[1]]"space_marine_squad_dreadnought", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_land_speeder", --[[5]]"space_marine_squad_land_speeder",
		--[[6]]"space_marine_squad_assault", --[[7]]"space_marine_squad_land_speeder", --[[8]]"space_marine_squad_land_speeder", --[[9]]"space_marine_squad_land_speeder", --[[10]]"space_marine_squad_tactical", 
		--[[11]]"space_marine_squad_tactical"},
		
		marker_spawn = {--[[1]]"mkr_FRP1", --[[2]]"mkr_FRP2", --[[3]]"mkr_FRP3", --[[4]]"mkr_FRP4", --[[5]]"mkr_FRP5", --[[6]]"mkr_FRP6", --[[7]]"mkr_FRP7", --[[8]]"mkr_FRP8", --[[9]]"mkr_FRP9", --[[10]]"mkr_FRP10", 
		--[[11]]"mkr_FRP11"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1}, 
		
		squad_size = {--[[1]] 1, --[[2]] 7, --[[3]] 8, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 8, --[[11]] 7}, 
		
	}
	
end



local i = g_FRP_Army_iter 
if g_FRP_Army_iter <= table.getn(t_FRP_Army.sgroup_name) and (SGroup_Exists(t_FRP_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_FRP_Army.sgroup_name[i])) then
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_FRP_Army.sgroup_name[i], t_FRP_Army.blueprint[i], t_FRP_Army.marker_spawn[i], t_FRP_Army.squad_num[i], t_FRP_Army.squad_size[i])
	
	--these space marines don't break
	if Squad_HasMorale(SGroup_GetSpawnedSquadAt(SGroup_FromName(t_FRP_Army.sgroup_name[i]), 1)) then
		SGroup_SetMoraleInvulnerable(t_FRP_Army.sgroup_name[i], true)
	end
	
	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_FRP"),  SGroup_FromName(t_FRP_Army.sgroup_name[i]))
	
	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_FRP_Army.sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_SM_FRP")
	
elseif g_FRP_Army_iter > table.getn(t_FRP_Army.sgroup_name) then
		g_FRP_Army_iter = 0
		
		
		if g_Strength == 15 then
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP2"), 1), "space_marine_heavy_bolter_veteran", 7)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP3"), 1), "space_marine_heavy_bolter_veteran", 8)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP10"), 1), "space_marine_flamer_veteran", 7)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP11"), 1), "space_marine_missile_launcher_veteran", 7)
			
			
		elseif g_Strength == 14 then
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP2"), 1), "space_marine_heavy_bolter_veteran", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP3"), 1), "space_marine_heavy_bolter_tactical", 8)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP10"), 1), "space_marine_flamer_tactical", 7)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP11"), 1), "space_marine_missile_launcher_veteran", 4)
		
		elseif g_Strength == 13 then
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP2"), 1), "space_marine_heavy_bolter_tactical", 7)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP3"), 1), "space_marine_heavy_bolter_tactical", 8)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP10"), 1), "space_marine_flamer_tactical", 7)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP11"), 1), "space_marine_missile_launcher_veteran", 3)
		
		elseif g_Strength == 12 then
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP2"), 1), "space_marine_heavy_bolter_tactical", 7)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP3"), 1), "space_marine_heavy_bolter_tactical", 5)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP10"), 1), "space_marine_flamer_tactical", 5)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP11"), 1), "space_marine_missile_launcher_tactical", 7)
		
		elseif g_Strength == 11 then
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP2"), 1), "space_marine_heavy_bolter_tactical", 5)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP3"), 1), "space_marine_heavy_bolter_tactical", 5)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP10"), 1), "space_marine_flamer_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP11"), 1), "space_marine_missile_launcher_tactical", 5)
		
		else
		
		
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP2"), 1), "space_marine_heavy_bolter_tactical", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP3"), 1), "space_marine_heavy_bolter_tactical", 4)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP10"), 1), "space_marine_flamer_tactical", 3)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SM_FRP11"), 1), "space_marine_missile_launcher_tactical", 4)
		
		
		end
		
		--prevent the landspeeders from moving
		Cmd_SetStance("sg_SM_FRP4", STANCE_StandGround)
		Cmd_SetStance("sg_SM_FRP5", STANCE_StandGround)
		Cmd_SetStance("sg_SM_FRP7", STANCE_StandGround)
		Cmd_SetStance("sg_SM_FRP8", STANCE_StandGround)
		Cmd_SetStance("sg_SM_FRP9", STANCE_StandGround)
		
		Cmd_SetStance("sg_SM_FRP1", STANCE_Hold)
		Cmd_SetStance("sg_SM_FRP2", STANCE_Hold)
		Cmd_SetStance("sg_SM_FRP3", STANCE_Hold)
		Cmd_SetStance("sg_SM_FRP6", STANCE_Hold)
		Cmd_SetStance("sg_SM_FRP10", STANCE_Hold)
		Cmd_SetStance("sg_SM_FRP11", STANCE_Hold)
		
		
		--get the units moving around a bit
		Rule_AddIntervalDelay(Rule_Static_Movement7, 60, 60)
		Rule_AddIntervalDelay(Rule_Static_Movement8, 60, 65)
		Rule_AddIntervalDelay(Rule_Static_Movement9, 60, 70)
		Rule_AddIntervalDelay(Rule_Static_Movement10, 60, 60)
		Rule_AddIntervalDelay(Rule_Static_Movement11, 60, 65)
		
		
		Rule_Remove(Rule_FRP_Army)


end
g_FRP_Army_iter = g_FRP_Army_iter+1

end

--scouts attacking the player's HQ

function Rule_Scout_Raiders_Creation()

if g_Strength == 15 then
	t_Scout_Raiders_Army1 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army2 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 3, --[[2]] 3, --[[3]] 3, --[[4]] 3}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army3 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 3, --[[3]] 4, --[[4]] 4}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army4 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 5, --[[2]] 5, --[[3]] 4, --[[4]] 4}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army5 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 5, --[[3]] 6, --[[4]] 6}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army6 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 2, --[[2]] 1, --[[3]] 2, --[[4]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 7, --[[3]] 7, --[[4]] 7}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}

elseif g_Strength == 14 then

t_Scout_Raiders_Army1 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army2 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 3, --[[2]] 3, --[[3]] 3, --[[4]] 3}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army3 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 3, --[[3]] 4, --[[4]] 4}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army4 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 5, --[[2]] 5, --[[3]] 4, --[[4]] 4}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army5 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 5, --[[3]] 6, --[[4]] 6}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army6 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 2, --[[2]] 1, --[[3]] 2, --[[4]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 7, --[[3]] 7, --[[4]] 7}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}

elseif g_Strength == 13 then

t_Scout_Raiders_Army1 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army2 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 3, --[[2]] 3, --[[3]] 3, --[[4]] 3}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army3 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 3, --[[3]] 4, --[[4]] 4}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army4 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 5, --[[2]] 5, --[[3]] 4, --[[4]] 4}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army5 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 5, --[[3]] 6, --[[4]] 6}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army6 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 2, --[[2]] 1, --[[3]] 2, --[[4]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 7, --[[3]] 7, --[[4]] 7}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
elseif g_Strength == 12 then

t_Scout_Raiders_Army1 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army2 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 3, --[[2]] 3, --[[3]] 3, --[[4]] 3}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army3 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 3, --[[3]] 4, --[[4]] 4}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army4 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 5, --[[2]] 5, --[[3]] 4, --[[4]] 4}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army5 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 5, --[[3]] 6, --[[4]] 6}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army6 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 2, --[[2]] 1, --[[3]] 2, --[[4]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 7, --[[3]] 7, --[[4]] 7}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
elseif g_Strength == 11 then

t_Scout_Raiders_Army1 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army2 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 3, --[[2]] 3, --[[3]] 3, --[[4]] 3}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army3 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 3, --[[3]] 4, --[[4]] 4}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army4 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 5, --[[2]] 5, --[[3]] 4, --[[4]] 4}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army5 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 5, --[[3]] 6, --[[4]] 6}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army6 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 2, --[[2]] 1, --[[3]] 2, --[[4]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 7, --[[3]] 7, --[[4]] 7}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
else

t_Scout_Raiders_Army1 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army2 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 3, --[[2]] 3, --[[3]] 3, --[[4]] 3}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army3 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 3, --[[3]] 4, --[[4]] 4}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army4 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 5, --[[2]] 5, --[[3]] 4, --[[4]] 4}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army5 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 5, --[[3]] 6, --[[4]] 6}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}
	
	t_Scout_Raiders_Army6 = {
		
		sgroup_name = { --[[1]]"sg_SM_Scout1", --[[2]]"sg_SM_Scout2", --[[3]]"sg_SM_Scout3", --[[4]]"sg_SM_Scout4"},  
		
		blueprint = {--[[1]]"space_marine_squad_scout", --[[2]]"space_marine_squad_scout", --[[3]]"space_marine_squad_scout", --[[4]]"space_marine_squad_scout"},
		
		marker_spawn = {--[[1]]"mkr_Scout_Raiders", --[[2]]"mkr_Scout_Raiders", --[[3]]"mkr_Scout_Raiders", --[[4]]"mkr_Scout_Raiders"}, 
		
		squad_num = {--[[1]] 2, --[[2]] 1, --[[3]] 2, --[[4]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 7, --[[3]] 7, --[[4]] 7}, 
		
		weapon = {--[[1]]"space_marine_flamer_scout", --[[2]]"space_marine_sniper_rifle", --[[3]]"space_marine_flamer_scout", --[[4]]"space_marine_plasma_gun_scout"}, 
		
		weapon_num ={--[[1]] 2, --[[2]] 2, --[[3]] 2, --[[4]] 2},
		
		stance = {--[[1]] STANCE_Hold, --[[2]] STANCE_Hold, --[[3]] STANCE_Hold, --[[4]] STANCE_Hold}, 
		
	}

end

t_Scout_Raiding_Tables ={--[[1]]t_Scout_Raiders_Army1, --[[2]] t_Scout_Raiders_Army2, --[[3]] t_Scout_Raiders_Army3, --[[4]] t_Scout_Raiders_Army4, --[[5]] t_Scout_Raiders_Army5, --[[6]] t_Scout_Raiders_Army6}


local i = g_Scout_Army_iter 
if g_Scout_Army_iter <= table.getn(t_Scout_Raiding_Tables[g_tablearmy].sgroup_name) and (SGroup_Exists(t_Scout_Raiding_Tables[g_tablearmy].sgroup_name[i]) == false or SGroup_IsEmpty(t_Scout_Raiding_Tables[g_tablearmy].sgroup_name[i])) then
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_Scout_Raiding_Tables[g_tablearmy].sgroup_name[i], t_Scout_Raiding_Tables[g_tablearmy].blueprint[i], t_Scout_Raiding_Tables[g_tablearmy].marker_spawn[i], 
	t_Scout_Raiding_Tables[g_tablearmy].squad_num[i], t_Scout_Raiding_Tables[g_tablearmy].squad_size[i])
	
	local j = World_GetRand(1, 2) 
	--these space marines don't break
	if Squad_HasMorale(SGroup_GetSpawnedSquadAt(SGroup_FromName(t_Scout_Raiding_Tables[g_tablearmy].sgroup_name[i]), 1)) then
		SGroup_SetMoraleInvulnerable(t_Scout_Raiding_Tables[g_tablearmy].sgroup_name[i], true)
	end
	
	--upgrade weapon
	Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName(t_Scout_Raiding_Tables[g_tablearmy].sgroup_name[i]), 1), t_Scout_Raiding_Tables[g_tablearmy].weapon[i], 
	t_Scout_Raiding_Tables[g_tablearmy].weapon_num[i])
	
	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_Scout_Army"),  SGroup_FromName(t_Scout_Raiding_Tables[g_tablearmy].sgroup_name[i]))
	
	--set stance
	Cmd_SetStance(t_Scout_Raiding_Tables[g_tablearmy].sgroup_name[i], t_Scout_Raiding_Tables[g_tablearmy].stance[i])
	
	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_Scout_Raiding_Tables[g_tablearmy].sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_SM_Scout_Army")
	
	Cmd_AttackMoveMarker(t_Scout_Raiding_Tables[g_tablearmy].sgroup_name[i], "mkr_Scout_Raider_Dest"..j)
elseif g_Scout_Army_iter > table.getn(t_Scout_Raiding_Tables[g_tablearmy].sgroup_name) then
		g_Scout_Army_iter = 0
		
	
		Rule_Remove(Rule_Scout_Raiders_Creation)
		Rule_AddInterval(Rule_Scout_Raids, 30)

	
end
g_Scout_Army_iter = g_Scout_Army_iter+1

end

--snow patrol army

function Rule_SM_SnowArmy()

if 	g_Strength == 15 then
	
	t_Snow_Army = {
		
		sgroup_name = { --[[1]]"sg_SnowPatrol1", --[[2]]"sg_SnowPatrol2", --[[3]]"sg_SnowPatrol3"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_veteran_stronghold_sp",  --[[3]]"space_marine_squad_veteran_stronghold_sp"},
		
		marker_spawn = { --[[1]]"mkr_SnowPatrol1_1", --[[2]]"mkr_SnowPatrol2_1", --[[3]]"mkr_SnowPatrol3_1"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 4, --[[3]] 4}, 
		
	}

elseif g_Strength == 14 then
	
	t_Snow_Army = {
		
		sgroup_name = { --[[1]]"sg_SnowPatrol1", --[[2]]"sg_SnowPatrol2", --[[3]]"sg_SnowPatrol3"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical",  --[[3]]"space_marine_squad_tactical"},
		
		marker_spawn = { --[[1]]"mkr_SnowPatrol1_1", --[[2]]"mkr_SnowPatrol2_1", --[[3]]"mkr_SnowPatrol3_1"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 4, --[[3]] 4}, 
		
	}

elseif g_Strength == 13 then

	t_Snow_Army = {
		
		sgroup_name = { --[[1]]"sg_SnowPatrol1", --[[2]]"sg_SnowPatrol2", --[[3]]"sg_SnowPatrol3"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical",  --[[3]]"space_marine_squad_tactical"},
		
		marker_spawn = { --[[1]]"mkr_SnowPatrol1_1", --[[2]]"mkr_SnowPatrol2_1", --[[3]]"mkr_SnowPatrol3_1"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 4, --[[3]] 4}, 
		
	}

elseif g_Strength == 12 then
	
	t_Snow_Army = {
		
		sgroup_name = { --[[1]]"sg_SnowPatrol1", --[[2]]"sg_SnowPatrol2", --[[3]]"sg_SnowPatrol3"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical",  --[[3]]"space_marine_squad_tactical"},
		
		marker_spawn = { --[[1]]"mkr_SnowPatrol1_1", --[[2]]"mkr_SnowPatrol2_1", --[[3]]"mkr_SnowPatrol3_1"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 4, --[[3]] 4}, 
		
	}

elseif g_Strength == 11 then
	
	t_Snow_Army = {
		
		sgroup_name = { --[[1]]"sg_SnowPatrol1", --[[2]]"sg_SnowPatrol2", --[[3]]"sg_SnowPatrol3"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical",  --[[3]]"space_marine_squad_tactical"},
		
		marker_spawn = { --[[1]]"mkr_SnowPatrol1_1", --[[2]]"mkr_SnowPatrol2_1", --[[3]]"mkr_SnowPatrol3_1"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 4, --[[3]] 4}, 
		
	}

else

	t_Snow_Army = {
		
		sgroup_name = { --[[1]]"sg_SnowPatrol1", --[[2]]"sg_SnowPatrol2", --[[3]]"sg_SnowPatrol3"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical",  --[[3]]"space_marine_squad_tactical"},
		
		marker_spawn = { --[[1]]"mkr_SnowPatrol1_1", --[[2]]"mkr_SnowPatrol2_1", --[[3]]"mkr_SnowPatrol3_1"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 4, --[[3]] 4}, 
		
	}


end



local i = g_Snow_Army_iter 
if g_Snow_Army_iter <= table.getn(t_Snow_Army.sgroup_name) and (SGroup_Exists(t_Snow_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Snow_Army.sgroup_name[i])) then
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_Snow_Army.sgroup_name[i], t_Snow_Army.blueprint[i], t_Snow_Army.marker_spawn[i], t_Snow_Army.squad_num[i], t_Snow_Army.squad_size[i])
	
	--these space marines don't break
	if Squad_HasMorale(SGroup_GetSpawnedSquadAt(SGroup_FromName(t_Snow_Army.sgroup_name[i]), 1)) then
		SGroup_SetMoraleInvulnerable(t_Snow_Army.sgroup_name[i], true)
	end
	
	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SnowArmy"),  SGroup_FromName(t_Snow_Army.sgroup_name[i]))
	

	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_Snow_Army.sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_SnowArmy")
	
elseif g_Snow_Army_iter > table.getn(t_Snow_Army.sgroup_name) then
		g_Snow_Army_iter = 0
		
		
		if g_Strength == 15 then
			
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol1"), 1), "space_marine_missile_launcher_veteran", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol2"), 1), "space_marine_flamer_veteran", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol3"), 1), "space_marine_plasma_gun", 2)
		
		elseif g_Strength == 14 then
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol1"), 1), "space_marine_missile_launcher_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol2"), 1), "space_marine_flamer_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol3"), 1), "space_marine_plasma_gun", 2)
		
		
		elseif g_Strength == 13 then
					
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol1"), 1), "space_marine_missile_launcher_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol2"), 1), "space_marine_flamer_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol3"), 1), "space_marine_plasma_gun", 2)
		
		elseif g_Strength == 12 then
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol1"), 1), "space_marine_missile_launcher_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol2"), 1), "space_marine_flamer_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol3"), 1), "space_marine_plasma_gun", 2)
		
		elseif g_Strength == 11 then
			
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol1"), 1), "space_marine_missile_launcher_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol2"), 1), "space_marine_flamer_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol3"), 1), "space_marine_plasma_gun", 2)
		
		else
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol1"), 1), "space_marine_missile_launcher_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol2"), 1), "space_marine_flamer_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_SnowPatrol3"), 1), "space_marine_plasma_gun", 2)
		
		end
		
		
		Rule_AddInterval(Rule_SP_Patrol,5)
		Rule_Remove(Rule_SM_SnowArmy)

	
end
g_Snow_Army_iter = g_Snow_Army_iter+1

end

--[[Initial Attack]]

--this is just to show the player how tough the SM are on this map.

function Rule_Initial_Raid()

if 	g_Strength == 15 then
	
	t_Initial_Raid_Army = {
		
		sgroup_name = { --[[1]]"sg_InitialRaid1", --[[2]]"sg_InitialRaid2", --[[3]]"sg_InitialRaid3", --[[4]]"sg_InitialRaid4", --[[5]]"sg_InitialRaid4"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_veteran_stronghold_sp",  --[[3]]"space_marine_squad_veteran_stronghold_sp", --[[4]]"space_marine_squad_dreadnought_hellfire", --[[5]]"space_marine_squad_assault"},
		
		marker_spawn = { --[[1]]"mkr_Exemplar_Marine", --[[2]]"mkr_Exemplar_Marine", --[[3]]"mkr_Exemplar_Marine", --[[4]]"mkr_Exemplar_Marine", --[[5]]"mkr_Exemplar_Marine"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 2, --[[5]] 1}, 
		
		squad_size = {--[[1]] 8, --[[2]] 8, --[[3]] 8, --[[4]] 1, --[[5]] 8}, 
		
	}

elseif g_Strength == 14 then
	
	t_Initial_Raid_Army = {
		
		sgroup_name = { --[[1]]"sg_InitialRaid1", --[[2]]"sg_InitialRaid2", --[[3]]"sg_InitialRaid3", --[[4]]"sg_InitialRaid4"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_veteran_stronghold_sp",  --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_dreadnought_hellfire"},
		
		marker_spawn = { --[[1]]"mkr_Exemplar_Marine", --[[2]]"mkr_Exemplar_Marine", --[[3]]"mkr_Exemplar_Marine", --[[4]]"mkr_Exemplar_Marine"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 6, --[[2]] 7, --[[3]] 7, --[[4]] 1}, 
		
	}

elseif g_Strength == 13 then

	t_Initial_Raid_Army = {
		
		sgroup_name = { --[[1]]"sg_InitialRaid1", --[[2]]"sg_InitialRaid2", --[[3]]"sg_InitialRaid3", --[[4]]"sg_InitialRaid4"},  
		
		blueprint = {--[[1]]"space_marine_squad_veteran_stronghold_sp", --[[2]]"space_marine_squad_tactical",  --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_dreadnought_hellfire"},
		
		marker_spawn = { --[[1]]"mkr_Exemplar_Marine", --[[2]]"mkr_Exemplar_Marine", --[[3]]"mkr_Exemplar_Marine", --[[4]]"mkr_Exemplar_Marine"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 8, --[[2]] 8, --[[3]] 8, --[[4]] 1}, 
		
	}

elseif g_Strength == 12 then
	
	t_Initial_Raid_Army = {
		
		sgroup_name = { --[[1]]"sg_InitialRaid1", --[[2]]"sg_InitialRaid2", --[[3]]"sg_InitialRaid3", --[[4]]"sg_InitialRaid4"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical",  --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_land_speeder"},
		
		marker_spawn = { --[[1]]"mkr_Exemplar_Marine", --[[2]]"mkr_Exemplar_Marine", --[[3]]"mkr_Exemplar_Marine", --[[4]]"mkr_Exemplar_Marine"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 7, --[[2]] 7, --[[3]] 5, --[[4]] 1}, 
		
	}

elseif g_Strength == 11 then
	
	t_Initial_Raid_Army = {
		
		sgroup_name = { --[[1]]"sg_InitialRaid1", --[[2]]"sg_InitialRaid2", --[[3]]"sg_InitialRaid3", --[[4]]"sg_InitialRaid4"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical",  --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_land_speeder"},
		
		marker_spawn = { --[[1]]"mkr_Exemplar_Marine", --[[2]]"mkr_Exemplar_Marine", --[[3]]"mkr_Exemplar_Marine", --[[4]]"mkr_Exemplar_Marine"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 4, --[[3]] 4, --[[4]] 1}, 
		
	}

else

	t_Initial_Raid_Army = {
		
		sgroup_name = { --[[1]]"sg_InitialRaid1", --[[2]]"sg_InitialRaid2", --[[3]]"sg_InitialRaid3"},  
		
		blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical",  --[[3]]"space_marine_squad_tactical"},
		
		marker_spawn = { --[[1]]"mkr_Exemplar_Marine", --[[2]]"mkr_Exemplar_Marine", --[[3]]"mkr_Exemplar_Marine"}, 
		
		squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1}, 
		
		squad_size = {--[[1]] 4, --[[2]] 4, --[[3]] 4}, 
		
	}


end



local i = g_Initial_Raid_iter 
if g_Initial_Raid_iter <= table.getn(t_Initial_Raid_Army.sgroup_name) and (SGroup_Exists(t_Initial_Raid_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Initial_Raid_Army.sgroup_name[i])) then
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_Initial_Raid_Army.sgroup_name[i], t_Initial_Raid_Army.blueprint[i], t_Initial_Raid_Army.marker_spawn[i], t_Initial_Raid_Army.squad_num[i], t_Initial_Raid_Army.squad_size[i])
	Cmd_AttackMoveMarker(t_Initial_Raid_Army.sgroup_name[i], "mkr_Player_HQ")
	--these space marines don't break
	if Squad_HasMorale(SGroup_GetSpawnedSquadAt(SGroup_FromName(t_Initial_Raid_Army.sgroup_name[i]), 1)) then
		SGroup_SetMoraleInvulnerable(t_Initial_Raid_Army.sgroup_name[i], true)
	end
	
	--add them all into one meta group
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_InitialRaid"),  SGroup_FromName(t_Initial_Raid_Army.sgroup_name[i]))
	

	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers(t_Initial_Raid_Army.sgroup_name[i])
	Cpu_LockSGroupAcrossPlayers("sg_InitialRaid")
	
elseif g_Initial_Raid_iter > table.getn(t_Initial_Raid_Army.sgroup_name) then
		g_Initial_Raid_iter = 0
		
		
		if g_Strength == 15 then
			
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid1"), 1), "space_marine_missile_launcher_veteran", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid2"), 1), "space_marine_flamer_veteran", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid3"), 1), "space_marine_plasma_gun_veteran", 2)
		
		elseif g_Strength == 14 then
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid1"), 1), "space_marine_missile_launcher_veteran", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid2"), 1), "space_marine_flamer_veteran", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid3"), 1), "space_marine_plasma_gun_veteran", 2)
		
		
		elseif g_Strength == 13 then
					
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid1"), 1), "space_marine_missile_launcher_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid2"), 1), "space_marine_flamer_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid3"), 1), "space_marine_plasma_gun", 2)
		
		elseif g_Strength == 12 then
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid1"), 1), "space_marine_missile_launcher_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid2"), 1), "space_marine_flamer_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid3"), 1), "space_marine_plasma_gun", 2)
		
		elseif g_Strength == 11 then
			
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid1"), 1), "space_marine_missile_launcher_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid2"), 1), "space_marine_flamer_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid3"), 1), "space_marine_plasma_gun", 2)
		
		else
		
			--upgrading the tac marines 
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid1"), 1), "space_marine_missile_launcher_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid2"), 1), "space_marine_flamer_tactical", 2)
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_InitialRaid3"), 1), "space_marine_plasma_gun", 2)
		
		end
		
		Rule_Remove(Rule_Initial_Raid)

	Rule_AddOneShot(Rule_SM_Information, 45)
end

g_Initial_Raid_iter = g_Initial_Raid_iter+1

end

function Rule_SM_Information()

Util_StartIntel(EVENTS.IE_Marines_Contact)	
Rule_Remove(Rule_SM_Information)

end

function Rule_Reset_Exemplar()

Cmd_SetStance("sg_Exemplar_Marine", STANCE_Hold)
Cmd_SetStance("sg_Exemplar_Scouts", STANCE_Hold)

end

--[[Whirlwind Attack]]

function Rule_Whirlwind_Attack()

if SGroup_Exists("sg_SM_Whirlwind_Army") and SGroup_IsEmpty("sg_SM_Whirlwind_Army") == false then
	
	for i = 1, 3 do

		if SGroup_Exists("sg_SM_Whirlwind"..i) and SGroup_IsEmpty("sg_SM_Whirlwind"..i) == false then
			local rand = World_GetRand(1, 3)
			local mkr = "mkr_WW_Target"..i
		--	Cmd_AttackGroundMarker("sg_SM_Whirlwind"..i, mkr..rand)
			Util_AttackGroundMarkerRandomRadius("sg_SM_Whirlwind"..i, mkr..rand, nil)
		
		
		else
		
		end

	end
	
else
	
	Rule_Remove(Rule_Whirlwind_Attack)
	
end

end


--[[Patrols]]

function Rule_Patrol_A()

if SGroup_Exists("sg_SM_Patrol1") and SGroup_IsEmpty("sg_SM_Patrol1") == false then
	
	if g_Patrol_Move == 0 and Prox_AllSquadsNearMarker("sg_SM_Patrol1", "mkr_PatrolA1")  then
	
		Cmd_AttackMoveMarker("sg_SM_Patrol1", "mkr_PatrolA2")
		g_Patrol_Move = g_Patrol_Move +1
	
	elseif g_Patrol_Move == 1 and  Prox_AllSquadsNearMarker("sg_SM_Patrol1", "mkr_PatrolA2")  then
	
		Cmd_AttackMoveMarker("sg_SM_Patrol1", "mkr_PatrolA3")
		g_Patrol_Move = g_Patrol_Move +1
		
	elseif g_Patrol_Move == 2 and  Prox_AllSquadsNearMarker("sg_SM_Patrol1", "mkr_PatrolA3")  then
	
		Cmd_AttackMoveMarker("sg_SM_Patrol1", "mkr_PatrolA4")
		g_Patrol_Move = g_Patrol_Move +1
		
	elseif g_Patrol_Move == 3 and  Prox_AllSquadsNearMarker("sg_SM_Patrol1", "mkr_PatrolA4")  then
	
		Cmd_AttackMoveMarker("sg_SM_Patrol1", "mkr_PatrolA5")
		g_Patrol_Move = g_Patrol_Move +1
		
	elseif g_Patrol_Move == 4 and  Prox_AllSquadsNearMarker("sg_SM_Patrol1", "mkr_PatrolA5")  then
	
		Cmd_AttackMoveMarker("sg_SM_Patrol1", "mkr_PatrolA6")
		g_Patrol_Move = g_Patrol_Move +1
		
	elseif g_Patrol_Move == 5 and  Prox_AllSquadsNearMarker("sg_SM_Patrol1", "mkr_PatrolA6")  then
	
		Cmd_AttackMoveMarker("sg_SM_Patrol1", "mkr_PatrolA7")
		g_Patrol_Move = g_Patrol_Move +1
		
	elseif g_Patrol_Move == 6 and  Prox_AllSquadsNearMarker("sg_SM_Patrol1", "mkr_PatrolA7")  then
	
		Cmd_AttackMoveMarker("sg_SM_Patrol1", "mkr_PatrolA1")
		g_Patrol_Move = 0

	end

else
	
	Rule_Remove(Rule_Patrol_A)

end

end

t_reverse_table = {--[[1]]false, --[[2]]false, --[[3]]false}

function Rule_SP_Patrol()

t_SP1_patrol ={--[[1]]"mkr_SnowPatrol1_1", --[[2]]"mkr_SnowPatrol1_2", --[[3]]"mkr_SnowPatrol1_3", --[[4]]"mkr_SnowPatrol1_4", --[[5]]"mkr_SnowPatrol1_5"} t_SP2_patrol ={--[[1]]"mkr_SnowPatrol2_1", --[[2]]"mkr_SnowPatrol2_2", --[[3]]"mkr_SnowPatrol2_3", --[[4]]"mkr_SnowPatrol2_4"} t_SP3_patrol ={--[[1]]"mkr_SnowPatrol3_1", --[[2]]"mkr_SnowPatrol3_2", --[[3]]"mkr_SnowPatrol3_3", --[[4]]"mkr_SnowPatrol3_4"} t_SP_patroltables = {--[[1]]t_SP1_patrol, --[[2]]t_SP2_patrol, --[[3]]t_SP3_patrol}

for i = 1, 3 do

	if SGroup_Exists("sg_SnowArmy") and SGroup_IsEmpty("sg_SnowArmy") == false then
	
		if SGroup_Exists("sg_SnowPatrol"..i) and SGroup_IsEmpty("sg_SnowPatrol"..i) == false then
			
			if t_reverse_table[i] == false then
				
				local maxsize = table.getn(t_SP_patroltables[i])
				for k = 1, maxsize do
				
					if Prox_AnySquadNearMarker("sg_SnowPatrol"..i, t_SP_patroltables[i][k]) then
		
						if k == maxsize then
					
							t_reverse_table[i] = true
							
							j = k - 1
							Cmd_AttackMoveMarker("sg_SnowPatrol"..i, t_SP_patroltables[i][j])
					
						else
					
							j = k + 1
							Cmd_AttackMoveMarker("sg_SnowPatrol"..i, t_SP_patroltables[i][j])
						
						end
						break
					end
				end
		
			elseif t_reverse_table[i] == true then
			
				local maxsize = table.getn(t_SP_patroltables[i])
				for k = 1, maxsize do
				
					if Prox_AnySquadNearMarker("sg_SnowPatrol"..i, t_SP_patroltables[i][k]) then
		
						if k == 1 then
					
							t_reverse_table[i] = false
							
							j = k + 1
							Cmd_AttackMoveMarker("sg_SnowPatrol"..i, t_SP_patroltables[i][j])
					
						else
					
							j = k - 1
							Cmd_AttackMoveMarker("sg_SnowPatrol"..i, t_SP_patroltables[i][j])
						
						end
						break
					end
				end
			end
		end
	else

		Rule_Remove(Rule_SP_Patrol)	
			
	end
end

end

--[[Space Marine Infantry Reinforcement]]

--small cutscene to show the player that the SM are reinforcing. function Rule_Reinforcement_Nis()

Util_StartNIS( EVENTS.NIS_Reinforce )

end

function Rule_Space_Marine_Reinforcement() --checks if the landing area buildings are destroyed before spawning things there. If they are destroyed then the rule is removed if not thing units are created if EGroup_IsEmpty("eg_SM_Baracks") == false then

	if g_SM_Reinforcement <= 5 and g_One == false   then
		
			Rule_AddInterval(Rule_SM_Reinforcements_1, 5)
			g_SM_Reinforcement = g_SM_Reinforcement +1
	
	elseif g_SM_Reinforcement >= 6 and g_SM_Reinforcement < 30 and g_Two == false then
		
		g_One = true
		Rule_AddInterval(Rule_SM_Reinforcements_2, 5)
		g_SM_Reinforcement = g_SM_Reinforcement +1

	elseif g_SM_Reinforcement >= 10 and g_SM_Reinforcement  < 45 and g_Three == false  then
		
		g_Two = true
		Rule_AddInterval(Rule_SM_Reinforcements_3, 5)
		g_SM_Reinforcement = g_SM_Reinforcement +1
	
	elseif g_SM_Reinforcement <= 15 then
		
		g_Three = true
		Rule_AddInterval(Rule_SM_Reinforcements_4, 5)
		g_SM_Reinforcement = g_SM_Reinforcement +1
	
	end
else
	g_RP_Abandon = true
	Rule_Remove(Rule_Space_Marine_Reinforcement)

end

end


--[[Orbital Relay Fire control]]

--this is the function that controls the firing of the orbital bombardment

function Rule_Change_Target()

if g_Orbital == false  and EGroup_Exists("eg_SM_Orbital") and EGroup_IsEmpty("eg_SM_Orbital") == false  then

	if g_Target == 1 then
		Rule_AddOneShot(Rule_Check_Target_Marker, 1)
		g_Target = 2

	elseif g_Target ==2 then
	
		Rule_AddOneShot(Rule_Check_Target_Point, 1)
		g_Target = 1
	end

elseif g_Orbital == true or EGroup_Exists("eg_SM_Orbital") == false or EGroup_Exists("eg_SM_Orbital") and EGroup_IsEmpty("eg_SM_Orbital") then

	Rule_Remove(Rule_Change_Target)

end

end

function Rule_Check_Target_Marker()

local rand = World_GetRand(1, 20)
for i = 1, 43 do
	
	--is the orbital relay still there
	if EGroup_Exists("eg_SM_Orbital") and EGroup_IsEmpty("eg_SM_Orbital") == false then
		
		--check to see if the player is near one of the target markers
		if Player_AreSquadsNearMarker(g_Player1, "mkr_OR_Target"..i) then
			
			--if he is cast orbital bombardment on him
			World_FXEvent("data:Art/Events/Markers/Orbital_Bombardment_Marker", Marker_GetPosition(Marker_FromName("mkr_OR_Target"..i, "basic_marker")))
			Command_EntityAbilityPos(g_Player2,EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_SM_Orbital"), 1), "marines_orbital_bombardment_stronghold_sp", 
			Marker_GetPosition(Marker_FromName("mkr_OR_Target"..i, "basic_marker")))
			
			if rand >= 15 then
			--play an IE event but not everytime
				Util_StartIntel(EVENTS.IE_Relay_Firing)
			end
			--and stop the function to prevent multiple bombardments at once
			break
	
		end
	else

		Rule_Remove(Rule_Check_Target_Marker)
	end
end

end

function Rule_Check_Target_Point()

local rand = World_GetRand(1, 20)
for i = 1, 7 do
	
	--is the orbital relay still there
	if EGroup_Exists("eg_SM_Orbital") and EGroup_IsEmpty("eg_SM_Orbital") == false then
		
		--check to see if the player is near one of the target markers
		if EGroup_HasStrategicPointWithStructure("eg_SM_List_Post"..i) then
			
			--if he is cast orbital bombardment on him
			World_FXEvent("data:Art/Events/Markers/Orbital_Bombardment_Marker", Marker_GetPosition(Marker_FromName("mkr_OR_Target"..i, "basic_marker")))
			Command_EntityAbilityPos(g_Player2,EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_SM_Orbital"), 1), "marines_orbital_bombardment_stronghold_sp", 
			Marker_GetPosition(Marker_FromName("mkr_OR_Target"..i, "basic_marker")))
			
			if rand >= 15 then
			--play an IE event but not everytime
				Util_StartIntel(EVENTS.IE_Relay_Firing)
			end
			--and stop the function to prevent multiple bombardments at once
			break
	
		end
	else

		Rule_Remove(Rule_Check_Target_Point)
	end
end

end


--[[ Checking where to send reinforcements ]]

function Rule_Meeting_Point()

if Prox_AnySquadNearMarker("sg_SM_Reinforcement", "mkr_SM_Gate1") then
		
	--checks to see if the player has an HQ and if yes to go attack it
	EGroup_Clear(EGroup_CreateIfNotFound("eg_Player1_Buildings"))
	EGroup_AddGroup(EGroup_FromName("eg_Player1_Buildings"), Player_GetEntities(g_Player1))
	
	local countbuilding = EGroup_CountSpawned(EGroup_FromName("eg_Player1_Buildings"))
	
	for i = 1, countbuilding do
	
		EGroup_Clear(EGroup_CreateIfNotFound("eg_Potential_HQ"))
		EGroup_Add(EGroup_FromName("eg_Potential_HQ"), EGroup_GetSpawnedEntityAt("eg_Player1_Buildings", i))

		if EGroup_ContainsBlueprints(EGroup_FromName("eg_Potential_HQ"), t_blueprinthq, true) then
		
			pos_HQ = Entity_GetPosition( EGroup_GetSpawnedEntityAt("eg_Potential_HQ", 1))
			Cmd_AttackMovePos("sg_SM_Reinforcement", pos_HQ)
	
		else

			
			Cmd_AttackMoveMarker("sg_SM_Reinforcement", "mkr_Raid_Destination_Final")

		end
	end
	
	
	Rule_Remove(Rule_Meeting_Point)

end

end


--[[Sending a raid on the enemy player ]]

function Rule_Space_Marine_Attack_Final()

if SGroup_Exists("sg_SM_Raiders") and Prox_AnySquadNearMarker("sg_SM_Raiders", "mkr_Raid_Destination1") then

	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_Raid_1"), SGroup_FromName("sg_SM_Raiders"))
	SGroup_Clear(SGroup_FromName("sg_SM_Raiders"))
	
	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers("sg_SM_Raid_1")
		
	--check where to attack
	EGroup_AddGroup(EGroup_CreateIfNotFound("eg_Player1_Buildings"), Player_GetEntities(g_Player1))

	local countbuilding = EGroup_CountSpawned(EGroup_FromName("eg_Player1_Buildings"))
	
	for i = 1, countbuilding do
	
		EGroup_Clear(EGroup_CreateIfNotFound("eg_Potential_HQ"))
		EGroup_Add(EGroup_FromName("eg_Potential_HQ"), EGroup_GetSpawnedEntityAt("eg_Player1_Buildings", i))

		if EGroup_ContainsBlueprints(EGroup_FromName("eg_Potential_HQ"), t_blueprinthq, true) then
		
			pos_HQ = Entity_GetPosition( EGroup_GetSpawnedEntityAt("eg_Potential_HQ", 1))
			Cmd_AttackMovePos("sg_SM_Raid_1", pos_HQ)


		end
	
	end
	
	
	
	Cmd_AttackMoveMarker("sg_SM_Raid_1", "mkr_Raid_Destination_Final")

elseif SGroup_Exists("sg_SM_Raiders") and Prox_AnySquadNearMarker("sg_SM_Raiders", "mkr_Raid_Destination2") then
	
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_SM_Raid_2"), SGroup_FromName("sg_SM_Raiders"))
	SGroup_Clear(SGroup_FromName("sg_SM_Raiders"))

	--preventing the AI from using these units
	Cpu_LockSGroupAcrossPlayers("sg_SM_Raid_2")
	
	--check where to attack
	EGroup_AddGroup(EGroup_CreateIfNotFound("eg_Player1_Buildings"), Player_GetEntities(g_Player1))

	local countbuilding = EGroup_CountSpawned(EGroup_FromName("eg_Player1_Buildings"))
	
	for i = 1, countbuilding do
	
		EGroup_Clear(EGroup_CreateIfNotFound("eg_Potential_HQ"))
		EGroup_Add(EGroup_FromName("eg_Potential_HQ"), EGroup_GetSpawnedEntityAt("eg_Player1_Buildings", i))

		if EGroup_ContainsBlueprints(EGroup_FromName("eg_Potential_HQ"), t_blueprinthq, true) then
		
			pos_HQ = Entity_GetPosition( EGroup_GetSpawnedEntityAt("eg_Potential_HQ", 1))
			Cmd_AttackMovePos("sg_SM_Raid_2", pos_HQ)


		end
	end
	
end	
	

end


--[[Raid retreat procedure ]]

function Rule_Check_For_Retreat()

for i = 1, 2 do

	if SGroup_Exists("sg_SM_Raid_"..i) and SGroup_Count(SGroup_FromName("sg_SM_Raid_"..i)) <= 2 then
	
		Cmd_MoveToMarker("sg_SM_Raid_"..i, "mkr_Raid_Destination"..i)

	end
end

end


--[[Check to see if an area is overrun ]]

function Rule_Abandon_Ship()

--checks to see if the relic and/or strat point on the plateau are captured and if yes sets thos areas as not to be reinforced

if g_CP_Abandon == false and EGroup_IsCapturedByPlayer("eg_SM_List_Post6", g_Player1, false) then
	
	g_CP_Abandon = true

end
	
if g_LP_Abandon == false and  EGroup_IsCapturedByPlayer("eg_SM_List_Post1", g_Player1, false) and EGroup_IsCapturedByPlayer("eg_SM_List_Post5", g_Player1, false) then

	g_LP_Abandon = true

end

if g_RP_Abandon == false and EGroup_IsCapturedByPlayer("eg_SM_List_Post8", g_Player1, false) then

	g_RP_Abandon = true
	
end

if g_CP_Abandon and g_LP_Abandon and g_RP_Abandon then
	Rule_Remove(Rule_Abandon_Ship)

end

end


--[[Scouts raiding the player]]

function Rule_Scout_Raids()

if EGroup_Exists("eg_SM_HQ") and EGroup_IsEmpty("eg_SM_HQ") == false then

	if g_Raids <= 50 then
	
		g_tablearmy = 1
		
	elseif g_Raids <= 100 then
	
		g_tablearmy = 2
	
	elseif g_Raids <= 150 then
	
		g_tablearmy = 3
		
		if Player_GetResearchState(g_Player2, "marine_scout_infiltrate_research") ~=  RS_Complete then

			Player_GrantResearch(g_Player2, "marine_scout_infiltrate_research")
		
		end
	
	elseif g_Raids <= 200 then
	
		g_tablearmy = 4
	
	elseif g_Raids <= 250 then
	
		g_tablearmy = 5
		
	else 
	
		g_tablearmy = 6
	
	end

	Rule_AddInterval(Rule_Scout_Raiders_Creation, 20)
	Rule_Remove(Rule_Scout_Raids)
	g_Raids = g_Raids +1

else
	
	

end

end


--[[Assault Squads raids]]

t_assault1 = { sgroup_name = {}, blueprint = {}, marker_spawn = {}, squad_num = {}, squad_size = {}, }

function Rule_Create_Assault_Base_Raid()

if g_assault <= 2 then

	if g_insert1 == true then
		
		--i am inserting the values into a table instead of having a premade table to be able to use just one table for the whole raiding army instead of having to use a different table for each new change in the raid.
		table.insert(t_assault1.sgroup_name, "sg_Assault1")
		table.insert(t_assault1.blueprint, "space_marine_squad_assault_veteran_stronghold_sp")
		table.insert(t_assault1.marker_spawn, "mkr_Assault_Barracks_Spawn")
		table.insert(t_assault1.squad_num, 1)
		table.insert(t_assault1.squad_size, 1)
	
		g_insert1 = false
	
	end
	

elseif g_assault <= 4 then

	if g_insert2 == true then
		
		--changing the size of the first squad
		t_assault1.squad_size[1] = 4
	
		g_insert2 = false
	
	end
	
elseif g_assault <= 6 then

	if g_insert3 == true then
		
		--changing the size of the first squad
		t_assault1.squad_size[1] = 6
	
		g_insert3 = false
	
	end

elseif g_assault <= 8 then

	if g_insert4 == true then
		
		--i am inserting the values into a table instead of having a premade table to be able to use just one table for the whole raiding army instead of having to use a different table for each new change in the raid.
		table.insert(t_assault1.sgroup_name, "sg_Assault2")
		table.insert(t_assault1.blueprint, "space_marine_squad_assault_veteran_stronghold_sp")
		table.insert(t_assault1.marker_spawn, "mkr_Assault_Barracks_Spawn")
		table.insert(t_assault1.squad_num, 1)
		table.insert(t_assault1.squad_size, 3)
	
		--changing the size of the first squad
		t_assault1.squad_size[1] = 3
	
		g_insert4 = false
	
	end

elseif g_assault <= 10 then

	if g_insert5 == true then
		
		--changing the size of the second squad
		t_assault1.squad_size[2] = 5
	
		g_insert5 = false
	
	end
	
elseif g_assault <= 12 then

	if g_insert6 == true then
		
		--changing the size of the first squad
		t_assault1.squad_size[1] = 5
	
		g_insert6 = false
	
	end

elseif g_assault <= 14 then

	if g_insert7 == true then
		
		--i am inserting the values into a table instead of having a premade table to be able to use just one table for the whole raiding army instead of having to use a different table for each new change in the raid.
		table.insert(t_assault1.sgroup_name, "sg_Assault3")
		table.insert(t_assault1.blueprint, "space_marine_squad_assault_veteran_stronghold_sp")
		table.insert(t_assault1.marker_spawn, "mkr_Assault_Barracks_Spawn")
		table.insert(t_assault1.squad_num, 1)
		table.insert(t_assault1.squad_size, 2)
	
		--changing the size of the first squad
		t_assault1.squad_size[1] = 3
		
		--changing the size of the second squad
		t_assault1.squad_size[2] = 3
	
		g_insert7 = false
	
	end

elseif g_assault <= 16 then

	if g_insert8 == true then
		
		--changing the size of the first squad
		t_assault1.squad_size[1] = 4
		
		--changing the size of the second squad
		t_assault1.squad_size[2] = 4
		
		--changing the size of the third squad
		t_assault1.squad_size[3] = 3
	
		g_insert8 = false
	
	end

elseif g_assault <= 18 then

	if g_insert9 == true then
		
		--changing the size of the first squad
		t_assault1.squad_size[1] = 5
		
		--changing the size of the second squad
		t_assault1.squad_size[2] = 5
		
		--changing the size of the third squad
		t_assault1.squad_size[3] = 4
	
		g_insert9 = false
	
	end

elseif g_assault > 18 then


	if g_insert10 == true then
		
		
		--i am inserting the values into a table instead of having a premade table to be able to use just one table for the whole raiding army instead of having to use a different table for each new change in the raid.
		table.insert(t_assault1.sgroup_name, "sg_Assault4")
		table.insert(t_assault1.blueprint, "space_marine_squad_assault_veteran_stronghold_sp")
		table.insert(t_assault1.marker_spawn, "mkr_Assault_Barracks_Spawn")
		table.insert(t_assault1.squad_num, 1)
		table.insert(t_assault1.squad_size, 4)
		
		--changing the size of the first squad
		t_assault1.squad_size[1] = 4
		
		--changing the size of the second squad
		t_assault1.squad_size[2] = 4
		
		--changing the size of the third squad
		t_assault1.squad_size[3] = 4
	
		g_insert10 = false
	
	end
end



if EGroup_Exists("eg_SM_Assault_Barracks") and EGroup_IsEmpty("eg_SM_Assault_Barracks") == false then

	local i = g_Assault_Army_iter 
	if g_Assault_Army_iter <= table.getn(t_assault1.sgroup_name) and (SGroup_Exists(t_assault1.sgroup_name[i]) == false or SGroup_IsEmpty(t_assault1.sgroup_name[i])) then
		local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_assault1.sgroup_name[i], t_assault1.blueprint[i], t_assault1.marker_spawn[i], t_assault1.squad_num[i], t_assault1.squad_size[i])
		SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Assault_Army"), SGroup_FromName(t_assault1.sgroup_name[i]))
		
	elseif g_Assault_Army_iter > table.getn(t_assault1.sgroup_name) then
			g_Assault_Army_iter = 0
			
						
			g_assault = g_assault +1
					
	end

	g_Assault_Army_iter = g_Assault_Army_iter+1			

else

	Rule_Remove(Rule_Create_Assault_Base_Raid)

end
	

end

function Rule_Assault_Marines_Assault()

--checks to see if the player has an HQ and if yes to go attack it
	EGroup_Clear(EGroup_CreateIfNotFound("eg_Player1_Buildings"))
	EGroup_AddGroup(EGroup_FromName("eg_Player1_Buildings"), Player_GetEntities(g_Player1))
	
	local countbuilding = EGroup_CountSpawned(EGroup_FromName("eg_Player1_Buildings"))
	
	for i = 1, countbuilding do
	
		EGroup_Clear(EGroup_CreateIfNotFound("eg_Potential_HQ"))
		EGroup_Add(EGroup_FromName("eg_Potential_HQ"), EGroup_GetSpawnedEntityAt("eg_Player1_Buildings", i))

		if EGroup_ContainsBlueprints(EGroup_FromName("eg_Potential_HQ"), t_blueprinthq, true) then
		
			pos_HQ = Entity_GetPosition( EGroup_GetSpawnedEntityAt("eg_Potential_HQ", 1))
			
			if SGroup_Exists("sg_Assault_Army") and SGroup_IsEmpty("sg_Assault_Army") == false then
				Cmd_AttackMovePos("sg_Assault_Army", pos_HQ)
			end
			--at this point we want to stop the for loop
			break

		end
	end

end


--[[Moral Loss]]

function Rule_Moral_Loss()

--if the relic is captured by the player then the space marine no longer are invulnerable to moral

if EGroup_IsCapturedByPlayer("eg_Relic", g_Player1, false) then

	--[[set the moral for the space marines as vulnerable again]]
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Player2Squads"), Player_GetSquads(g_Player2))
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Player3Squads"), Player_GetSquads(g_Player3))
	
	
	SGroup_SetMoraleInvulnerable("sg_Player2Squads", false)
	SGroup_SetMoraleInvulnerable("sg_Player3Squads", false)
	
	--[[break moral just to show the player that taking the relic actually did something]]
	SGroup_SetAvgMorale("sg_Player2Squads", 0)
	SGroup_SetAvgMorale("sg_Player3Squads", 0)
		
	
		
	g_Moral = false
	g_Relic = true
	
--	Util_StartIntel(EVENTS.IE_Relic_Captured)
	
	Rule_Remove(Rule_AI_Moral)
	Rule_AddOneShot(Rule_AI_Moral_Reset, 5)
	
	--breaks moral for all the SM every x seconds
	Rule_AddInterval(Rule_Moral_Affected, 380)
	
	Rule_Remove(Rule_Moral_Loss)
	
end

end


--[[ Keeping the AI moral up ]]

function Rule_AI_Moral()

SGroup_AddGroup(SGroup_CreateIfNotFound("sg_AI_Player3"), Player_GetSquads(g_Player3))
g_CountAI = SGroup_Count(SGroup_FromName("sg_AI_Player3"))


for i = 1, g_CountAI do

	if Squad_HasMorale(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_AI_Player3"), i)) then
	
		Squad_SetMoraleInvulnerable(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_AI_Player3"), i), true)
		
	end


end

end

function Rule_AI_Moral_Reset()

SGroup_AddGroup(SGroup_CreateIfNotFound("sg_AI_Player3"), Player_GetSquads(g_Player3))
g_CountAI = SGroup_Count(SGroup_FromName("sg_AI_Player3"))


for i = 1, g_CountAI do

	if Squad_HasMorale(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_AI_Player3"), i)) then
	
		Squad_SetMoraleInvulnerable(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_AI_Player3"), i), false)
		
	end


end

end

function Rule_Moral_Affected()

SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Player2Squads"), Player_GetSquads(g_Player2))
SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Player3Squads"), Player_GetSquads(g_Player3))

SGroup_SetAvgMorale("sg_Player2Squads", 0)
SGroup_SetAvgMorale("sg_Player3Squads", 0)

end

--[[Probing]]

function Rule_Patrolling_Probe()

t_probe1 = {--[[1]]"mkr_Skull_Target11", --[[2]]"mkr_Skull_Target12", --[[3]]"mkr_Skull_Target13", --[[4]]"mkr_Skull_Target14", --[[5]]"mkr_Skull_Target15", --[[6]]"mkr_Skull_Target16", --[[7]]"mkr_Skull_Target17", --[[8]]"mkr_Skull_Target18"}

t_probe2 = {--[[1]]"mkr_Skull_Target21", --[[2]]"mkr_Skull_Target22", --[[3]]"mkr_Skull_Target23", --[[4]]"mkr_Skull_Target24"}

t_probe3 = {--[[1]]"mkr_Skull_Target31", --[[2]]"mkr_Skull_Target32", --[[3]]"mkr_Skull_Target33", --[[4]]"mkr_Skull_Target34", --[[5]]"mkr_Skull_Target35", --[[6]]"mkr_Skull_Target36", --[[7]]"mkr_Skull_Target37", --[[8]]"mkr_Skull_Target38"}

t_probe4 = {--[[1]]"mkr_Skull_Target41", --[[2]]"mkr_Skull_Target42", --[[3]]"mkr_Skull_Target43", --[[4]]"mkr_Skull_Target44", --[[5]]"mkr_Skull_Target45",--[[6]]"mkr_Skull_Target46", --[[7]]"mkr_Skull_Target47"}

t_probe5 = {--[[1]]"mkr_Skull_Target51", --[[2]]"mkr_Skull_Target52", --[[3]]"mkr_Skull_Target53", --[[4]]"mkr_Skull_Target54", --[[5]]"mkr_Skull_Target55", --[[6]]"mkr_Skull_Target56"}

t_probe6 = {--[[1]]"mkr_Skull_Target61", --[[2]]"mkr_Skull_Target62", --[[3]]"mkr_Skull_Target63", --[[4]]"mkr_Skull_Target64", --[[5]]"mkr_Skull_Target65", --[[6]]"mkr_Skull_Target66"}

t_probe7 = {--[[1]]"mkr_Skull_Target71", --[[2]]"mkr_Skull_Target72", --[[3]]"mkr_Skull_Target73", --[[4]]"mkr_Skull_Target74", --[[5]]"mkr_Skull_Target75", --[[6]]"mkr_Skull_Target76", --[[7]]"mkr_Skull_Target77", --[[8]]"mkr_Skull_Target78", --[[9]]"mkr_Skull_Target79"} t_probe8 = {--[[1]]"mkr_Skull_Target47", --[[2]]"mkr_Skull_Target54", --[[3]]"mkr_Skull_Target53", --[[4]]"mkr_Skull_Target52", --[[5]]"mkr_Skull_Target45"}

t_probe9 = {--[[1]]"mkr_Skull_Target80", --[[2]]"mkr_Skull_Target85", --[[3]]"mkr_Skull_Target81", --[[4]]"mkr_Skull_Target87", --[[5]]"mkr_Skull_Target82", --[[6]]"mkr_Skull_Target86", --[[7]]"mkr_Skull_Target83", --[[8]]"mkr_Skull_Target88"}

t_probetables ={t_probe1, t_probe2, t_probe3, t_probe4, t_probe5, t_probe6, t_probe7, t_probe8, t_probe9}

for i = 1, 9 do
local maxsize =  table.getn(t_probetables[i])

	if EGroup_Exists("eg_SM_List_Post"..i) and EGroup_IsEmpty("eg_SM_List_Post"..i) == false then

		if SGroup_Exists("sg_Probe"..i) == false or SGroup_Exists("sg_Probe"..i) and  SGroup_IsEmpty("sg_Probe"..i) then
			
			Util_CreateSquadsAtMarkerEx(g_Player2, "sg_Probe"..i, "space_marine_squad_skull_probe", "mkr_Skull"..i, 1, 1)
			 Cmd_MoveToMarker("sg_Probe"..i, t_probetables[i][1])
			break
		elseif SGroup_Exists("sg_Probe"..i) and SGroup_IsEmpty("sg_Probe"..i) == false then 

			for k = 1,  table.getn(t_probetables[i]) do

				if Prox_AllSquadsNearMarker("sg_Probe"..i, t_probetables[i][k]) then
					if k < maxsize then
						local j = k +1
						 Cmd_MoveToMarker("sg_Probe"..i, t_probetables[i][j])
						 break
					elseif k == maxsize then
						local h = 1
						 Cmd_MoveToMarker("sg_Probe"..i, t_probetables[i][h])
						 break
					end
				end
			end
		end
	end
end

end


--[[Orbital Relay Scar feature]]

function Rule_Button_Setup()

t_orbital_firing = {
	button_icon = {--[[1]]"Scar_buttons/fire_orbital", --[[2]]"Scar_buttons/fire_orbital", --[[3]]"Scar_buttons/fire_orbital"},
	button_description = {--[[1]]"$2774602", --[[2]]"$2774603"}, 
}


g_button_spawn = Util_AbilityButton_CreateModal(t_orbital_firing.button_icon, t_orbital_firing.button_description, true)

end

function Rule_Leader_Check()

--it is no longer checking to see whether you have your leader selected but now whether it's the orbital relay.


if EGroup_IsCapturedByPlayer("eg_Orbital_Point", g_Player1, true) and EGroup_IsSelected("eg_SM_Orbital") then 	

	
	if g_add_button == true then
		Util_ButtonManagerUpdateAll()
	else
		Util_EGroupAbilityButton_Add2Manager(g_button_spawn, "eg_SM_Orbital")

		g_add_button = true
	end

	
end	
	
	

end

function Rule_Button_Click()

if Button_GetPressed(g_button_spawn) == true then


	local pos  = Button_GetPressedPosition(g_button_spawn)

	if Player_CanSeePosition(g_Player1, pos) then
	
		World_FXEvent("data:Art/Events/Markers/Orbital_Bombardment_Marker", pos)
		Command_EntityAbilityPos(g_Player1, EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_SM_Orbital"), 1), "marines_orbital_bombardment_stronghold_sp", 
		pos)
	
		Button_SetEnabled(g_button_spawn, false)
		Rule_AddOneShot(Rule_Reset_Button, 90)
		
		g_Relay_Fired = true
	
	else
		UIWarning_Show("$2774604")
	
	end

end

end

function Rule_Reset_Button()

Button_SetEnabled(g_button_spawn, true)
Rule_Remove(Rule_Reset_Button)

end

--[[ Static Movement ]]

--getting the entrenched squads to move around a bit to appear less scripted --these are for the central plateau with the whirlwinds function Rule_Static_Movement1()

if SGroup_Exists("sg_SM_CP1") and SGroup_IsEmpty("sg_SM_CP1") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_CP2", "mkr_SM_CP1")

else

	Rule_Remove(Rule_Static_Movement1)

end

end


function Rule_Static_Movement2()

if SGroup_Exists("sg_SM_CP2") and SGroup_IsEmpty("sg_SM_CP2") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_CP2", "mkr_SM_CP2")

else

	Rule_Remove(Rule_Static_Movement2)

end

end


function Rule_Static_Movement3()

if SGroup_Exists("sg_SM_CP3") and SGroup_IsEmpty("sg_SM_CP3") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_CP3", "mkr_SM_CP3")

else

	Rule_Remove(Rule_Static_Movement3)

end

end


function Rule_Static_Movement4()

if SGroup_Exists("sg_SM_CP4") and SGroup_IsEmpty("sg_SM_CP4") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_CP4", "mkr_SM_CP4")

else

	Rule_Remove(Rule_Static_Movement4)

end

end


function Rule_Static_Movement5()

if SGroup_Exists("sg_SM_CP5") and SGroup_IsEmpty("sg_SM_CP5") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_CP5", "mkr_SM_CP5")

else

	Rule_Remove(Rule_Static_Movement5)

end

end


function Rule_Static_Movement6()

if SGroup_Exists("sg_SM_CP6") and SGroup_IsEmpty("sg_SM_CP6") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_CP6", "mkr_SM_CP6")

else

	Rule_Remove(Rule_Static_Movement6)

end

end

--these are for the right plateau with the orbital relay

function Rule_Static_Movement7()

if SGroup_Exists("sg_SM_FRP1") and SGroup_IsEmpty("sg_SM_FRP1") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_FRP1", "mkr_FRP1")

else

	Rule_Remove(Rule_Static_Movement7)

end

end

--

function Rule_Static_Movement8()

if SGroup_Exists("sg_SM_FRP2") and SGroup_IsEmpty("sg_SM_FRP2") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_FRP2", "mkr_FRP2")

else

	Rule_Remove(Rule_Static_Movement8)

end

end

--

function Rule_Static_Movement9()

if SGroup_Exists("sg_SM_FRP3") and SGroup_IsEmpty("sg_SM_FRP3") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_FRP3", "mkr_FRP3")

else

	Rule_Remove(Rule_Static_Movement9)

end

end

--

function Rule_Static_Movement10()

if SGroup_Exists("sg_SM_FRP10") and SGroup_IsEmpty("sg_SM_FRP10") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_FRP10", "mkr_FRP10")

else

	Rule_Remove(Rule_Static_Movement10)

end

end

--

function Rule_Static_Movement11()

if SGroup_Exists("sg_SM_FRP11") and SGroup_IsEmpty("sg_SM_FRP11") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_FRP11", "mkr_FRP11")

else

	Rule_Remove(Rule_Static_Movement11)

end

end

--these are for the back plateau with the relic

function Rule_Static_Movement12()

if SGroup_Exists("sg_SM_LP2") and SGroup_IsEmpty("sg_SM_LP2") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_LP2", "mkr_SM_LP2")

else

	Rule_Remove(Rule_Static_Movement12)

end

end


function Rule_Static_Movement13()

if SGroup_Exists("sg_SM_LP3") and SGroup_IsEmpty("sg_SM_LP3") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_LP3", "mkr_SM_LP3")

else

	Rule_Remove(Rule_Static_Movement13)

end

end


function Rule_Static_Movement14()

if SGroup_Exists("sg_SM_LP4") and SGroup_IsEmpty("sg_SM_LP4") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_LP4", "mkr_SM_LP4")

else

	Rule_Remove(Rule_Static_Movement14)

end

end


function Rule_Static_Movement15()

if SGroup_Exists("sg_SM_LP5") and SGroup_IsEmpty("sg_SM_LP5") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_LP5", "mkr_SM_LP5")

else

	Rule_Remove(Rule_Static_Movement15)

end

end


function Rule_Static_Movement16()

if SGroup_Exists("sg_SM_LP6") and SGroup_IsEmpty("sg_SM_LP6") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_LP6", "mkr_SM_LP6")

else

	Rule_Remove(Rule_Static_Movement16)

end

end


function Rule_Static_Movement17()

if SGroup_Exists("sg_SM_LP1") and SGroup_IsEmpty("sg_SM_LP1") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_LP1", "mkr_SM_LP1")

else

	Rule_Remove(Rule_Static_Movement17)

end

end

--these are for the bastion itself

function Rule_Static_Movement18()

if SGroup_Exists("sg_SM_Bastion17") and SGroup_IsEmpty("sg_SM_Bastion17") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_Bastion17", "mkr_SM_Bastion17")

else

	Rule_Remove(Rule_Static_Movement18)

end

end


function Rule_Static_Movement19()

if SGroup_Exists("sg_SM_Bastion15") and SGroup_IsEmpty("sg_SM_Bastion15") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_Bastion15", "mkr_SM_Bastion15")

else

	Rule_Remove(Rule_Static_Movement19)

end

end


function Rule_Static_Movement20()

if SGroup_Exists("sg_SM_Bastion12") and SGroup_IsEmpty("sg_SM_Bastion12") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_Bastion12", "mkr_SM_Bastion12")

else

	Rule_Remove(Rule_Static_Movement20)

end

end


function Rule_Static_Movement21()

if SGroup_Exists("sg_SM_Bastion13") and SGroup_IsEmpty("sg_SM_Bastion13") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_Bastion13", "mkr_SM_Bastion13")

else

	Rule_Remove(Rule_Static_Movement21)

end

end


function Rule_Static_Movement22()

if SGroup_Exists("sg_SM_Bastion7") and SGroup_IsEmpty("sg_SM_Bastion7") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_Bastion7", "mkr_SM_Bastion7")

else

	Rule_Remove(Rule_Static_Movement22)

end

end


function Rule_Static_Movement23()

if SGroup_Exists("sg_SM_Bastion9") and SGroup_IsEmpty("sg_SM_Bastion9") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_Bastion9", "mkr_SM_Bastion9")

else

	Rule_Remove(Rule_Static_Movement23)

end

end


function Rule_Static_Movement24()

if SGroup_Exists("sg_SM_Bastion4") and SGroup_IsEmpty("sg_SM_Bastion4") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_Bastion4", "mkr_SM_Bastion4")

else

	Rule_Remove(Rule_Static_Movement24)

end

end

---units near the slag deposit

function Rule_Static_Movement25()

if SGroup_Exists("sg_Slag1") and SGroup_IsEmpty("sg_Slag1") == false then

	Util_AttackMoveMarkerRandomRadius("sg_Slag1", "mkr_Slag1")

else

	Rule_Remove(Rule_Static_Movement25)

end

end

--

function Rule_Static_Movement26()

if SGroup_Exists("sg_Slag2") and SGroup_IsEmpty("sg_Slag2") == false then

	Util_AttackMoveMarkerRandomRadius("sg_Slag2", "mkr_Slag2")

else

	Rule_Remove(Rule_Static_Movement26)

end

end

--the four squads on the ramps nearest the player

function Rule_Static_Movement27()

if SGroup_Exists("sg_SM_Gap1") and SGroup_IsEmpty("sg_SM_Gap1") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_Gap1", "mkr_SM_Ramp1")

else

	Rule_Remove(Rule_Static_Movement27)

end

end

--

function Rule_Static_Movement28()

if SGroup_Exists("sg_SM_Gap2") and SGroup_IsEmpty("sg_SM_Gap2") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_Gap2", "mkr_SM_Ramp2")

else

	Rule_Remove(Rule_Static_Movement28)

end

end

--

function Rule_Static_Movement29()

if SGroup_Exists("sg_SM_Gap3") and SGroup_IsEmpty("sg_SM_Gap3") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_Gap3", "mkr_SM_Ramp3")

else

	Rule_Remove(Rule_Static_Movement29)

end

end

--

function Rule_Static_Movement30()

if SGroup_Exists("sg_SM_Gap4") and SGroup_IsEmpty("sg_SM_Gap4") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_Gap4", "mkr_SM_Ramp4")

else

	Rule_Remove(Rule_Static_Movement30)

end

end

--bastion detector librarians

function Rule_Static_Movement31()

if SGroup_Exists("sg_SM_Bastion22") and SGroup_IsEmpty("sg_SM_Bastion22") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_Bastion22", "mkr_SM_Bastion22")

else

	Rule_Remove(Rule_Static_Movement31)

end

end

--

function Rule_Static_Movement32()

if SGroup_Exists("sg_SM_Bastion23") and SGroup_IsEmpty("sg_SM_Bastion23") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_Bastion23", "mkr_SM_Bastion23")

else

	Rule_Remove(Rule_Static_Movement32)

end

end

--

function Rule_Static_Movement33()

if SGroup_Exists("sg_SM_Bastion24") and SGroup_IsEmpty("sg_SM_Bastion24") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_Bastion24", "mkr_SM_Bastion24")

else

	Rule_Remove(Rule_Static_Movement33)

end

end

--

function Rule_Static_Movement34()

if SGroup_Exists("sg_SM_Bastion25") and SGroup_IsEmpty("sg_SM_Bastion25") == false then

	Util_AttackMoveMarkerRandomRadius("sg_SM_Bastion25", "mkr_SM_Bastion25")

else

	Rule_Remove(Rule_Static_Movement34)

end

end

--[[ Chatty AI ]]

--this is to have the AI send generic messages to the player every x seconds. So far they're not supposed to repeat but are supposed to be random

t_Talk = { false, false, false, false, false, false, false, false, false}

function Rule_Trash_Talk()

t_Event ={EVENTS.IE_Generic1, EVENTS.IE_Generic2, EVENTS.IE_Generic3, EVENTS.IE_Generic4, EVENTS.IE_Generic5, EVENTS.IE_Generic6, EVENTS.IE_Generic7, EVENTS.IE_Generic8, EVENTS.IE_Generic9} local i = World_GetRand(1, 9)

if Event_IsAnyRunning() == false and t_Talk[i] == false then

	Util_StartIntel(t_Event[i])
	t_Talk[i] = true

end

end

---[[opening taunts]]

function Rule_Opening_Discussion()

local humanplayer = MetaMap_GetPlayerRaceName()

if humanplayer == "chaos_marine_race" then

	Util_StartIntel(EVENTS.IE_Chaos_Start)
	
elseif humanplayer == "eldar_race" then

	Util_StartIntel(EVENTS.IE_Eldar_Start)

elseif humanplayer == "guard_race" then

	Util_StartIntel(EVENTS.IE_IG_Start)

elseif humanplayer == "ork_race" then

	Util_StartIntel(EVENTS.IE_Ork_Start)	

elseif humanplayer =="space_marine_race" then

	--[[no text since this is the SM stronghold]]

elseif humanplayer == "tau_race" then

	Util_StartIntel(EVENTS.IE_Tau_Start)

elseif humanplayer == "necron_race" then

	Util_StartIntel(EVENTS.IE_Necron_Start)
	
end

end

--[[relic captured taunt]]

function Rule_Relic_Discussion()

local humanplayer = MetaMap_GetPlayerRaceName()

if humanplayer == "chaos_marine_race" then

	Util_StartIntel(EVENTS.IE_Chaos_Relic)
	
elseif humanplayer == "eldar_race" then

	Util_StartIntel(EVENTS.IE_Eldar_Relic)

elseif humanplayer == "guard_race" then

	Util_StartIntel(EVENTS.IE_IG_Relic)

elseif humanplayer == "ork_race" then

	Util_StartIntel(EVENTS.IE_Ork_Relic)	

elseif humanplayer =="space_marine_race" then

	--[[no text since this is the SM stronghold]]

elseif humanplayer == "tau_race" then

	Util_StartIntel(EVENTS.IE_Tau_Relic)

elseif humanplayer == "necron_race" then

	Util_StartIntel(EVENTS.IE_Necron_Relic)
	
end

end

--[[Bastion breach taunt]]

function Rule_Bastion_Discussion()

local humanplayer = MetaMap_GetPlayerRaceName()

if humanplayer == "chaos_marine_race" then

	Util_StartIntel(EVENTS.IE_Chaos_Bastion)
	
elseif humanplayer == "eldar_race" then

	Util_StartIntel(EVENTS.IE_Eldar_Bastion)

elseif humanplayer == "guard_race" then

	Util_StartIntel(EVENTS.IE_IG_Bastion)

elseif humanplayer == "ork_race" then

	Util_StartIntel(EVENTS.IE_Ork_Bastion)	

elseif humanplayer =="space_marine_race" then

	--[[no text since this is the SM stronghold]]

elseif humanplayer == "tau_race" then

	Util_StartIntel(EVENTS.IE_Tau_Bastion)

elseif humanplayer == "necron_race" then

	Util_StartIntel(EVENTS.IE_Necron_Bastion)
	
end

end

--[[ Orbital relay contact ]]

function Rule_Player_Near_Relay()

if Player_AreSquadsNearMarker(g_Player1, "mkr_OR_Target9") and Event_IsAnyRunning() == false then

	Util_StartIntel(EVENTS.IE_Relay_Contact)	
	Rule_Remove(Rule_Player_Near_Relay)
end

end


--[[ Relic contact ]]

function Rule_Player_Near_Relic()

if Player_AreSquadsNearMarker(g_Player1, "mkr_OR_Target1") and Event_IsAnyRunning() == false or Player_AreSquadsNearMarker(g_Player1, "mkr_OR_Target3") and Event_IsAnyRunning() == false then

	Util_StartIntel(EVENTS.IE_Relic_Contact)	
	Rule_Remove(Rule_Player_Near_Relic)
end

end


--[[ Reinforcement contact ]]

function Rule_Player_Near_Reinforcement()

if Player_AreSquadsNearMarker(g_Player1, "mkr_OR_Target10") and Event_IsAnyRunning() == false or Player_AreSquadsNearMarker(g_Player1, "mkr_OR_Target12") and Event_IsAnyRunning() == false then

	Util_StartIntel(EVENTS.IE_Reinforcements_Contact)	
	Rule_Remove(Rule_Player_Near_Reinforcement)
end

end


--[[ Breach right event ]]

function Rule_Player_Near_Right_Entry()

if Player_AreSquadsNearMarker(g_Player1, "mkr_OR_Target14") and Event_IsAnyRunning() == false then

	Util_StartIntel(EVENTS.IE_Breach_Right)	
	Rule_Remove(Rule_Player_Near_Right_Entry)
end

end


--[[ Breach left event ]]

function Rule_Player_Near_Left_Entry()

if Player_AreSquadsNearMarker(g_Player1, "mkr_OR_Target15") and Event_IsAnyRunning() == false then

	Util_StartIntel(EVENTS.IE_Breach_Left)	
	Rule_Remove(Rule_Player_Near_Left_Entry)
end

end


--[[ Breach main bastion event ]]

function Rule_Player_Near_Main_Bastion()

if Player_AreSquadsNearMarker(g_Player1, "mkr_OR_Target16") and Event_IsAnyRunning() == false then

	Rule_AddOneShot(Rule_Bastion_Discussion, 5)	
	Rule_Remove(Rule_Player_Near_Main_Bastion)
end

end


--[[ OBJECTIVES ]]

--[[Primary Objective - destroy the space marine HQ]] function Rule_Objective_Destroy_HQ()

Objective_Destroy_HQ = {title_id = 2750000, short_desc_id = 2750001, help_tip_id = 2750000}

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Destroy_HQ.title_id) == false then
	
	Util_WXP_ObjectiveCreate(Objective_Destroy_HQ, true, g_Player1)
	
	Objective_ShowScreen()
	Flash_OtherButton("dlg_objectives", 0, false, true)
	
	--[[adding map and mini-map pings]]
	g_ping_hq = Objective_PingMarker(Objective_Destroy_HQ.title_id, "mkr_SM_HQ", true, "default")
	g_ping_hq_mini = Ping_Marker("mkr_SM_HQ", true, "default")
	
	Rule_AddOneShot(Rule_Stop_HQ_Ping, 5)
	
	Rule_AddInterval(Rule_Player_Near_Right_Entry, 1)
	Rule_AddInterval(Rule_Player_Near_Left_Entry, 1)
	Rule_AddInterval(Rule_Player_Near_Main_Bastion, 1)
	
elseif Event_IsAnyRunning() == false and g_Win == true then 

	--[[removing map and mini-map pings]]
	Objective_PingRemove(Objective_Destroy_HQ.title_id, g_ping_hq)
	
	Util_ObjectiveComplete(Objective_Destroy_HQ.title_id)
	Rule_Remove(Rule_Objective_Destroy_HQ)
	
	--[[game is won]]
	Util_StartNIS( EVENTS.NIS_Closing )
		
	
end

end

function Rule_Stop_HQ_Ping()

Ping_Stop(g_ping_hq_mini)

end

--[[Secondary Objective - stop infantry reinforcements]] function Rule_Objective_Destroy_Barracks()

Objective_Destroy_Barracks = {title_id = 2750100, short_desc_id = 2750101, help_tip_id = 2750100}

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Destroy_Barracks.title_id) == false then
	
	Util_WXP_ObjectiveCreate(Objective_Destroy_Barracks, false, g_Player1)
	
	Objective_ShowScreen()
	Flash_OtherButton("dlg_objectives", 0, false, true)
	
	--[[adding map and mini-map pings]]
	g_ping_Barracks = Objective_PingMarker(Objective_Destroy_Barracks.title_id, "mkr_SM_Infantry_HQ", true, "default")
	g_ping_Barracks_mini = Ping_Marker("mkr_SM_Infantry_HQ", true, "default")
	
	Rule_AddOneShot(Rule_Stop_Barracks_Ping, 5)
	Rule_AddInterval(Rule_Player_Near_Reinforcement, 1)
	
elseif Event_IsAnyRunning() == false and EGroup_IsEmpty("eg_SM_Baracks") == true then 

	--[[removing map and mini-map pings]]
	Objective_PingRemove(Objective_Destroy_Barracks.title_id, g_ping_Barracks)
	
	
	
	Util_ObjectiveComplete(Objective_Destroy_Barracks.title_id)
	Rule_Remove(Rule_Objective_Destroy_Barracks)
	
	
end

end

function Rule_Stop_Barracks_Ping()

Ping_Stop(g_ping_Barracks_mini)

end

--[[Secondary Objective - capture orbital relay]] function Rule_Objective_Destroy_Orbital()

Objective_Destroy_Orbital = {title_id = 2750200, short_desc_id = 2750201, help_tip_id = 2750200}

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Destroy_Orbital.title_id) == false then
	
	Util_WXP_ObjectiveCreate(Objective_Destroy_Orbital, false, g_Player1)
	
	Objective_ShowScreen()
	Flash_OtherButton("dlg_objectives", 0, false, true)
	
	--[[adding map and mini-map pings]]
	g_ping_Cult = Objective_PingMarker(Objective_Destroy_Orbital.title_id, "mkr_Orbital_Relay", true, "default")
	g_ping_Cult_mini = Ping_Marker("mkr_Orbital_Relay", true, "default")
	
	Rule_AddOneShot(Rule_Stop_Cult_Ping, 5)
	Rule_AddInterval(Rule_Player_Near_Relay, 1)
	
elseif Event_IsAnyRunning() == false and EGroup_IsCapturedByPlayer("eg_Orbital_Point", g_Player1, true) then 

	--turning off the orbital bombardments for the SM player
	g_Orbital = true

	--[[removing map and mini-map pings]]
	Objective_PingRemove(Objective_Destroy_Orbital.title_id, g_ping_Cult)
	

	--create the scar orbital bombardment button
	Rule_AddOneShot(Rule_Button_Setup, 1)
	Rule_AddIntervalDelay(Rule_Leader_Check, 1, 2)
	Rule_AddDelay(Rule_Button_Click,10)
	
	
	Util_ObjectiveComplete(Objective_Destroy_Orbital.title_id)
	
	Util_StartIntel(EVENTS.IE_Relay_Destroyed)
	
	Rule_AddIntervalDelay(Rule_Objective_Use_Relay, 1, 10)
	
	Rule_Remove(Rule_Objective_Destroy_Orbital)
	
end

end

function Rule_Stop_Cult_Ping()

Ping_Stop(g_ping_Cult_mini)

end

--[[Secondary Objective -use orbital relay]] function Rule_Objective_Use_Relay()

Objective_Use_Relay = {title_id = 2750400, short_desc_id = 2750401, help_tip_id = 2750400}

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Use_Relay.title_id) == false then
	
	Util_WXP_ObjectiveCreate(Objective_Use_Relay, false, g_Player1)
	
	Objective_ShowScreen()
	Flash_OtherButton("dlg_objectives", 0, false, true)
	
	--[[adding map and mini-map pings]]
	g_ping_Relay2 = Objective_PingMarker(Objective_Use_Relay.title_id, "mkr_Orbital_Relay", true, "default")
	g_ping_Relay2_mini = Ping_Marker("mkr_Orbital_Relay", true, "default")
	
	Rule_AddOneShot(Rule_Stop_Relay2_Ping, 5)
	
elseif Event_IsAnyRunning() == false and g_Relay_Fired == true then 

	--[[removing map and mini-map pings]]
	Objective_PingRemove(Objective_Use_Relay.title_id, g_ping_Relay2)
	
	Util_ObjectiveComplete(Objective_Use_Relay.title_id)
	

	Rule_Remove(Rule_Objective_Use_Relay)
	
	
end

end

function Rule_Stop_Relay2_Ping()

Ping_Stop(g_ping_Relay2_mini)

end

--[[Secondary Objective - capture relic/break moral]] function Rule_Objective_Capture_Relic()

Objective_Capture_Relic = {title_id = 2750300, short_desc_id = 2750301, help_tip_id = 2750300}

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Capture_Relic.title_id) == false then
	
	Util_WXP_ObjectiveCreate(Objective_Capture_Relic, false, g_Player1)
	
	--[[adding map and mini-map pings]]
	g_ping_Relic = Objective_PingMarker(Objective_Capture_Relic.title_id, "mkr_Ping_Relic", true, "default")
	g_ping_Relic_mini = Ping_Marker("mkr_Ping_Relic", true, "default")
	
	Rule_AddInterval(Rule_Player_Near_Relic, 1)
	
	Rule_AddOneShot(Rule_Stop_Relic_Ping, 5)
	
elseif Event_IsAnyRunning() == false and g_Relic == true then 

	--[[removing map and mini-map pings]]
	Objective_PingRemove(Objective_Capture_Relic.title_id, g_ping_Relic)
	
	Util_ObjectiveComplete(Objective_Capture_Relic.title_id)
	
	Rule_AddOneShot(Rule_Relic_Discussion, 5)
	Rule_Remove(Rule_Objective_Capture_Relic)
	
	
end

end

function Rule_Stop_Relic_Ping()

Ping_Stop(g_ping_Relic_mini)

end


--[[ win loss ]]

function Rule_EndGame_Win()

if EGroup_Exists("eg_SM_HQ") == false or (EGroup_Exists("eg_SM_HQ") and EGroup_IsEmpty("eg_SM_HQ")) then

	g_Win = true
	Rule_Remove( Rule_EndGame_Win )
	Rule_Remove(Rule_EndGameLose)

end

end

function Rule_EndGameLose()

--[[ Lose because of Annihilation ]]	
if( Player_HasBuildingsExcept(g_Player1, t_building_exceptions) == false ) then
	if( Player_HasSquadsExcept(g_Player1, t_unit_exceptions ) == false ) then
		Rule_RemoveAll()
		Fade_Start(4, false)
		World_SetTeamWin( g_enemy, "" )
		Rule_AddIntervalEx( Rule_GameOver,5,1 )
		Rule_Remove( Rule_EndGameLose )
		Rule_Remove( Rule_EndGame_Win )
	end
end

end

--[[ call this with an interval to ensure the mission ends ]] function Rule_GameOver() World_SetGameOver() end


--[[Timer ]]

function Rule_Add_Timer()

	Rule_AddInterval(Rule_Increment_Timer, 60)

end

function Rule_Increment_Timer()

g_Timer = g_Timer +1

end


--[[Nis function ]]

function Rule_Closing_Spawn()

for i = 70, 74 do

	if SGroup_Exists("sg_Actortac"..i) and SGroup_IsEmpty("sg_Actortac"..i) then
	
		Util_CreateSquadsAtMarkerEx(g_Player1, "sg_Actortac"..i, g_Nis_Blueprint, "mkr_actorM"..i, 1, 4)
		SGroup_AddGroup(SGroup_CreateIfNotFound("sg_All_Closing_Actors"), SGroup_FromName("sg_Actortac"..i))
		Cmd_SetStance("sg_Actortac"..i, STANCE_StandGround)
		Cmd_SetMeleeStance("sg_Actortac"..i, MSTANCE_Ranged)
		Cmd_MoveToMarker("sg_Actortac"..i, "mkr_actorS"..i)


	elseif SGroup_Exists("sg_Actortac"..i) == false then
	
		Util_CreateSquadsAtMarkerEx(g_Player1, "sg_Actortac"..i, g_Nis_Blueprint, "mkr_actorM"..i, 1, 4)
		SGroup_AddGroup(SGroup_CreateIfNotFound("sg_All_Closing_Actors"), SGroup_FromName("sg_Actortac"..i))
		Cmd_SetStance("sg_Actortac"..i, STANCE_StandGround)
		Cmd_SetMeleeStance("sg_Actortac"..i, MSTANCE_Ranged)
		Cmd_MoveToMarker("sg_Actortac"..i, "mkr_actorS"..i)
	
	
	
	end


end

end


--[[test ]]

--[[creates an entity that's not a building; spawns it and adds it to a group.]] function Util_SpawnEntity(egroupname, entityname, markername)

	local entity = Entity_Create(entityname, g_Player2, Marker_GetPosition(Marker_FromName(markername, "basic_marker")))
	Entity_Spawn(entity)
	EGroup_Add(EGroup_CreateIfNotFound(egroupname), entity)
	
	

end

function test()

SGroup_AddGroup(SGroup_CreateIfNotFound("sg_test"), Player_GetSquads(g_Player1))
print(SGroup_CountDeSpawned(SGroup_FromName("sg_test")))	

SGroup_ReSpawn("sg_test")

end

function Rule_Cheat1()

Util_StartNIS(EVENTS.NIS_Reinforce)
Rule_Remove(Rule_Cheat1)

end

function Rule_Cheat2()

Util_StartNIS( EVENTS.NIS_Closing )
Rule_Remove(Rule_Cheat2)

end

function Rule_Cheat3()

Util_StartNIS( EVENTS.NIS_SM_Campaign_Intro )
Rule_Remove(Rule_Cheat3)

end

Statistiche del gioco
Follower
52
Runs
159
Giocatori
16
Discussioni recenti
Pubblicato 6 years ago
3 risposte
Pubblicato 6 years ago
35 risposte
Pubblicato 6 years ago
6 risposte
Pubblicato 6 years ago
10 risposte
Pubblicato 6 years ago
4 risposte