Mission event file for Disorder mission 3
Руководства
/
Mission event file for Disorder mission 3
Обновлено 4 years ago от Merric

--[[ IMPORTS ]]

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


--[[ GAME SETUP ]]

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

g_Player1 = Setup_Player(0, "$690087", "ork_race", 1)
Misc_PlayerTeamColor(g_Player1,"default_4")
Player_DoNotPrecache(g_Player1, _t_MSD3_Player1)

g_Player2 = Setup_Player(1, "$690088", "chaos_marine_race", 2)
Misc_PlayerTeamColor(g_Player2,"default_6")
Player_DoNotPrecache(g_Player2, _t_MSD3_Player2)

g_Player3 = Setup_Player(2, "$690080", "guard_race", 3)
Player_DoNotPrecache(g_Player3, _t_MSD3_Player3)

g_Player4 = Setup_Player(3, "$690084", "eldar_race", 4)
Misc_PlayerTeamColor(g_Player4,"default_5")
Player_DoNotPrecache(g_Player4, _t_MSD3_Player4)

g_Player5 = Setup_Player(4, "$000000", "npc_race", TEAM_NEUTRAL)
Player_DoNotPrecache(g_Player5, _t_MSD3_Player5)

g_Player6 = Setup_Player(5, "$000000", "npc_race", 2)
Player_DoNotPrecache(g_Player6, _t_MSD3_Player6)
--[[ DEFINE VARIABLES AND TABLES - define any preset values here for later use]]

g_firstrun = true
g_Player_Ork_Army_iter = 1
g_Sturnn_Army_iter = 1
g_Player_Chaos_Army_iter = 1
g_Mechanize_Guard_Army_iter = 1
g_Psyker_Guard_Army_iter = 1
g_Fire_Support_Guard_Army_iter = 1
g_Lawlessness_Guard_Army_iter = 1
g_Drama_Imperial_Army_iter=1
g_Enemy_Ork_Army_iter = 1
g_Eldar_Base_Raid_Army_iter= 1
g_Player_Ork_Army_Reinforcements_iter = 1
g_Eldar_Avatar_Army_iter = 1
g_Closing_Nis_Army_iter = 1
g_build = 0
g_building = 1
g_P1_iter = 1
g_P2_iter = 1
g_P3_iter = 1
g_add_button = false
g_captured = false
g_Secure_Blood = 0
g_First_Blood = false
g_Avatar = 0
g_Avatar_Kaput = nil
g_Transform = false
g_Explore = 0
g_Eldar_Avatar_Stop1_Army_iter = 1
g_Eldar_Avatar_Stop2_Army_iter = 1
g_Eldar_Avatar_Stop3_Army_iter = 1
g_Eldar_Avatar_Stop4_Army_iter = 1
g_onitsway = false
g_Audio_Warning_One = false
g_Audio_Warning_Far = false
g_Audio_Warning_Wrong = false
g_Blood_Flag = false

g_Counter = 5

g_Blood_Pit = 0
g_Blood_Tab = 0
--[[ define the "enemy" who will win if the player 'loses' ]]
g_enemy = g_Player4

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
Rule_SetResearchLevel( 4 )

--[[ NIS PRESETS ]]
-- 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 ]]
Rule_PresetAI()		

--[[ START NIS ]]
-- 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 )
Player_GrantResearch(g_Player2, "chaos_infiltration_research")
Player_RestrictBuilding(g_Player2, "chaos_greater_sacrificial_circle")
Player_RestrictBuilding(g_Player2, "chaos_thermo_plasma_generator")
Player_RestrictBuilding(g_Player2, "chaos_hq")

Player_RestrictResearch(g_Player2, "chaos_bloodthirster_research")
Player_RestrictResearch(g_Player2, "chaos_sorcerer_research_1")
Player_RestrictResearch(g_Player2, "chaos_sorcerer_research_2")
Player_RestrictAbility(g_Player2, "chaos_chains_of_torment")
Player_RestrictResearch(g_Player2, "chaos_smoke_launcher_research")

Player_RestrictAbility(g_Player2, "chaos_corruption")
Player_RestrictSquad(g_Player2, "chaos_squad_rhino")

Player_RestrictSquad(g_Player2, "chaos_squad_lord")
Player_RestrictSquad(g_Player1, "ork_squad_warboss")

Player_GrantResearch(g_Player6, "chaos_bloodthirster_research")
EGroup_ForceAddOn("eg_Chaos_HQ", "chaos_hq_addon_1")

local ModID = Modifier_Create(MAT_EntityType, "health_maximum_modifier", MUT_Multiplication, false, 50 , "eldar_avatar")
Modifier_ApplyToPlayer( ModID, g_Player4 )

local ModID2 = Modifier_Create(MAT_EntityType , "health_maximum_modifier", MUT_Multiplication, false, 4 , "guard_leaders_captain")
Modifier_ApplyToPlayer( ModID2, g_Player3 )

end


--[[ MUSIC ]]

function Rule_SetupMusicPlaylist()

t_music = {"music_msd3", "music_theme_chaos_01", "music_ork_theme", "music_coming_of_chaos" }
t_music_sturnn_assault ={"music_msd4", "music_msd4_perc"}
t_music_chaos = {"music_msd3"}
t_music_post_mid_nis = {"music_msd3_perc", "music_msd3_perc", "music_msd3_perc_choir"}
t_music_summoning = {"music_msd3", "music_msd3_perc"}
t_music_post_synckill2 = {"music_msd5c"}
t_music_end_nis = {"playerswitch_chaos"}

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

t_ambient = {"Snowy_wind_1", "Warhammer_XP_battle_BG" }
Playlist_Manager( PC_Ambient, t_ambient, true, true , {5, 10})

end

function Rule_Sturnn_Ambiance()

if Player_AreSquadsNearMarker(g_Player1, "mkr_Sturnn_Fight_Center") then

Playlist_Manager( PC_Music, t_music_sturnn_assault, true, false , {20, 40})

Rule_Remove(Rule_Sturnn_Ambiance)

end

end


--[[ PRESET AI ]]

function Rule_PresetAI()

Cpu_EnableAll(false)	

end


--[[ START PLAY ]]

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

function Rule_GameStart()

if g_firstrun then
	
	--[[ SET RESOURCES ]]
	Player_SetAllResources(g_Player1, 1000, 1000)
	Player_SetAllResources(g_Player2, 4000, 4000)
		
	--[[ PREACTION ]]
	-- Use this space to add core mission functions that should be in place during the opening NIS
	
	--[[ DIFFICULTY LEVEL ]]
	-- gets the difficulty level from the UI and passes it into the function
	Rule_SetDifficultyLevel( Difficulty_Get() )
	
	
	g_firstrun = false
	
elseif Event_IsAnyRunning() == false then		
		
	--[[ Get the AI doing whatever after the NIS is over ]]
	Rule_StartAI()
		
	--[[ FOW ]]
	World_EnablePlayerToPlayerFOW(g_Player2, g_Player1, true)
	
	--[[ WIN CHECK ]]
--	Rule_AddInterval(Rule_EndGameWin, 1)
	
	--[[ LOSE CHECK ]]
	Rule_AddInterval(Rule_EndGameLose, 1)
	
	--[[ ASSIGN OBJECTIVES ]]
--	Rule_AddInterval(Rule_Objective_Name, 1)
		
	--[[ AUTOSAVE AFTER NIS ]]
	Rule_Add(Rule_Autosave_MissionStart)
		
	--[[ GENERATE ACTION ]]
	-- Use this space to add all core mission functions
	
	Rule_Add(Rule_Sturnn_Army_Creation)



	Rule_Add(Rule_Psyker_Guard_Army_Creation)
	Rule_Add(Rule_Mechanize_Guard_Army_Creation)
	Rule_Add(Rule_Fire_Support_Guard_Army_Creation)
	Rule_Add(Rule_Lawlessness_Guard_Army_Creation)
	

	
	Rule_AddInterval(Rule_Blood_Sacrifice, 5)
	Rule_AddInterval(Rule_Blood_Tab, 3)
	
	
	
	--[[ Clean up ]]
	Rule_Remove(Rule_GameStart)
	
end

end


--[[ DIFFICULTY ]]

function Rule_SetDifficultyLevel( difficultyLevel )

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

-- Difficulty_SetForAll( difficultyLevel ) Difficulty_SetForPlayer(g_Player3, difficultyLevel) Difficulty_SetForPlayer(g_Player4, difficultyLevel)

--[[ DIFFICULTY GENERAL RULES ]]
--[[ Types of things that can me done	include: 
a) adding resource values
b) changing variables for the number of starting units a player recieves 
b) or even activating new objectives (although we refrained from this in DoW as the increased testing requirements it dictates)
]]	
-- easy
if difficultyLevel == DIFFICULTY_EASY then
	
	--Cpu_SetDifficulty( g_Player2, AD_Standard )
	
-- medium
elseif difficultyLevel == DIFFICULTY_NORMAL then
	
-- hard
elseif difficultyLevel == DIFFICULTY_HARD then
	
end

end


--[[ 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() --[[ if SGroup_Exists("sg_leader") then Util_TrackCharacterAndDropPodIn( g_Player1, "sg_leader", "chaos_squad_sorcerer", "mkr_summon" ) end ]] end


--[[ CORE GAME ]]

function Rule_Timer() g_time = g_time+1 end


--[[ Player Ork Army Creation ]]

function Rule_Player_Ork_Army_Creation()

local i = g_Player_Ork_Army_iter 

t_Player_Ork_Army = {
	
	sgroup_name = { --[[1]]"sg_Player_Ork1", --[[2]]"sg_Player_Ork2", --[[3]]"sg_Player_Ork3", --[[4]]"sg_Actor_Ork1", --[[5]]"sg_Actor_Ork2", --[[6]]"sg_Actor_Ork3", --[[7]]"sg_Actor_Ork4",
	--[[8]]"sg_Actor_Ork5", --[[9]]"sg_Actor_Ork6", --[[10]]"sg_Actor_Ork7", --[[11]]"sg_Actor_Boss", --[[12]]"sg_Actor_Ork8", --[[13]]"sg_Actor_Ork9"},  
	
	blueprint = {--[[1]]"ork_squad_slugga", --[[2]]"ork_squad_shoota_boy",  --[[3]]"ork_squad_nob", --[[4]]"ork_squad_shoota_boy", --[[5]]"ork_squad_killa_kan", --[[6]]"ork_squad_slugga", --[[7]]"ork_squad_killa_kan",
	--[[8]]"ork_squad_nob", --[[9]]"ork_squad_killa_kan", --[[10]]"ork_squad_wartrak", --[[11]]"ork_squad_warboss", --[[12]]"ork_squad_wartrak", --[[13]]"ork_squad_wartrak"},
	
	marker_spawn = {--[[1]]"mkr_Player_Ork1", --[[2]]"mkr_Player_Ork2",  --[[3]]"mkr_Player_Ork4", --[[4]]"mkr_Ork_Arrival1", --[[5]]"mkr_Ork_Arrival2", --[[6]]"mkr_Ork_Arrival4", --[[7]]"mkr_Ork_Arrival5", --[[8]]"mkr_Ork_Arrival6", --[[9]]"mkr_Ork_Arrival7",
	--[[10]]"mkr_Ork_Arrival8",--[[11]]"mkr_Ork_Arrival3", --[[12]]"mkr_Ork_Arrival9", --[[13]]"mkr_Ork_Arrival10"}, 
	
	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]] 5, --[[3]] 5, --[[4]] 9, --[[5]] 9, --[[6]] 3, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 9, --[[11]] 1, --[[12]] 1, --[[13]] 1}, 
}

if g_Player_Ork_Army_iter <= table.getn(t_Player_Ork_Army.sgroup_name) and (SGroup_Exists(t_Player_Ork_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Player_Ork_Army.sgroup_name[i])) then

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player1, t_Player_Ork_Army.sgroup_name[i], t_Player_Ork_Army.blueprint[i], t_Player_Ork_Army.marker_spawn[i], t_Player_Ork_Army.squad_num[i], t_Player_Ork_Army.squad_size[i])
		SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Orks"), SGroup_FromName(t_Player_Ork_Army.sgroup_name[i]))
		
	elseif g_Player_Ork_Army_iter > table.getn(t_Player_Ork_Army.sgroup_name) then
		g_Player_Ork_Army_iter = 0
			
				
		Rule_AddInterval(Rule_Player_Ork_Army_Creation_Reinforcements, 15)		
		Rule_Remove(Rule_Player_Ork_Army_Creation)
		
	end
g_Player_Ork_Army_iter = g_Player_Ork_Army_iter+1

end


--[[ Player Ork Army Reinforcements ]]

--[[ - this uses the same table as the Rule_Player_Ork_Army_Creation however it randomizes what gets spawned. The boss and the armored nob are not included in this table.]]

function Rule_Player_Ork_Army_Creation_Reinforcements()

local i = g_Player_Ork_Army_Reinforcements_iter 


t_Player_Ork_Army_Reinforcement = {
	
	sgroup_name = { --[[1]]"sg_Player_Ork1", --[[2]]"sg_Player_Ork2", --[[3]]"sg_Player_Ork3", --[[4]]"sg_Actor_Ork1", --[[5]]"sg_Actor_Ork2", --[[6]]"sg_Actor_Ork3", --[[7]]"sg_Actor_Ork4",
	--[[8]] --[[9]]"sg_Actor_Ork6", --[[10]]"sg_Actor_Ork7",  --[[11]]"sg_Actor_Ork8", --[[12]]"sg_Actor_Ork9"},  
	
	blueprint = {--[[1]]"ork_squad_slugga", --[[2]]"ork_squad_shoota_boy",  --[[3]]"ork_squad_nob", --[[4]]"ork_squad_nob", --[[5]]"ork_squad_killa_kan", --[[6]]"ork_squad_shoota_boy", --[[7]]"ork_squad_killa_kan",
	--[[8]] --[[9]]"ork_squad_killa_kan", --[[10]]"ork_squad_wartrak", --[[11]]"ork_squad_wartrak", --[[12]]"ork_squad_wartrak"},
	
	marker_spawn = {--[[1]]"mkr_Player_Ork1", --[[2]]"mkr_Player_Ork2",  --[[3]]"mkr_Player_Ork4", --[[4]]"mkr_Ork_Arrival1", --[[5]]"mkr_Ork_Arrival2", --[[6]]"mkr_Ork_Arrival4", --[[7]]"mkr_Ork_Arrival5", --[[8]]--[[9]]"mkr_Ork_Arrival7",
	--[[10]]"mkr_Ork_Arrival8", --[[11]]"mkr_Ork_Arrival9", --[[12]]"mkr_Ork_Arrival10"}, 
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] --[[9]] 1, --[[10]] 1,  --[[11]] 1, --[[12]] 1}, 

	squad_size = {--[[1]] 5, --[[2]] 5, --[[3]] 5, --[[4]] 9, --[[5]] 9, --[[6]] 9, --[[7]] 9, --[[8]]  --[[9]] 1, --[[10]] 9,  --[[11]] 1, --[[12]] 1}, 
}

local j = World_GetRand(1, table.getn(t_Player_Ork_Army_Reinforcement.sgroup_name))
if g_Player_Ork_Army_Reinforcements_iter <= table.getn(t_Player_Ork_Army_Reinforcement.sgroup_name) and (SGroup_Exists(t_Player_Ork_Army_Reinforcement.sgroup_name[i]) == false or SGroup_IsEmpty(t_Player_Ork_Army_Reinforcement.sgroup_name[i])) then

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player1, t_Player_Ork_Army_Reinforcement.sgroup_name[i], t_Player_Ork_Army_Reinforcement.blueprint[j], t_Player_Ork_Army_Reinforcement.marker_spawn[i], t_Player_Ork_Army_Reinforcement.squad_num[i], t_Player_Ork_Army_Reinforcement.squad_size[i])
		SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Orks"), SGroup_FromName(t_Player_Ork_Army_Reinforcement.sgroup_name[i]))
		
	elseif g_Player_Ork_Army_Reinforcements_iter > table.getn(t_Player_Ork_Army_Reinforcement.sgroup_name) then
		g_Player_Ork_Army_Reinforcements_iter = 0
					
	end
g_Player_Ork_Army_Reinforcements_iter = g_Player_Ork_Army_Reinforcements_iter+1

end

function Rule_Gorgutz_Track() local blueprinttable = Util_MakeBlueprintTable("ork_squad_warboss")

--[[ check to see if the group is empty AND if the boolean has been returned to false - this prevents duplicate rule adds ]]
if g_gorgutzreturn ~= true and SGroup_Exists("sg_Actor_Boss") and ( SGroup_IsEmpty("sg_Actor_Boss") or SGroup_ContainsBlueprints( "sg_Actor_Boss", blueprinttable, false) == false) then
	
	--[[ prevents duplicate rule adds ]]
	g_gorgutzreturn = true
	
	--[[ 6 second delay, keeps it from being instantaneous ]]
	Rule_AddOneShot(Rule_Gorgutz_Return, 6)
	

end

end

function Rule_Gorgutz_Return()

--[[ recreate the unit ]]
Util_CreateSquadsAtMarker(g_Player1, "sg_Actor_Boss", "ork_squad_warboss", "mkr_Ork_Arrival3", 1)

--[[ play the fx ]]
World_FXEventSquad("data:Art/Events/Unit_Upgrade_Morale_FX/Reinforce_Trooper", SGroup_FromName("sg_Actor_Boss"))

--[[ reset the flag ]]
g_gorgutzreturn = false

--[[ if no messages have played recently, play the Intel Event - this keeps messages from flooding the player ]]

if Event_TimeSinceLast() > 15 then
	Util_StartIntel(EVENTS.IE_Ork_ImBack)
end
EventCue_DoEvent( "recruit_commander", "/Races/Shared/Upgrade_weapon", "$42890", "$42892" )

end


--[[ Enemy Ork Army Creation ]]

function Rule_Enemy_Ork_Army_Creation()

local i = g_Enemy_Ork_Army_iter 

t_Enemy_Ork_Army = {
	sgroup_name = { --[[1]]"sg_Enemy_Ork1", --[[2]]"sg_Enemy_Ork2", --[[3]]"sg_Enemy_Ork3", --[[4]]"sg_Ork_Builder", --[[5]]"sg_Enemy_Ork4", --[[6]] --[[7]]"sg_Enemy_Ork7", --[[8]]"sg_Enemy_Ork8", --[[9]] --[[10]]"sg_Enemy_Ork10",
	--[[11]]"sg_Enemy_Ork11", --[[12]]"sg_Enemy_Ork12", --[[13]] --[[14]]"sg_Enemy_Ork14", --[[15]]"sg_Enemy_Ork_Patrol1", --[[16]]"sg_Enemy_Ork16", --[[17]]"sg_Enemy_Ork17", --[[18]]"sg_Enemy_Ork18", --[[19]]"sg_Enemy_Ork19", --[[20]]
	--[[21]]"sg_Enemy_Ork21", --[[22]]"sg_Enemy_Ork_Patrol2", --[[23]]"sg_Enemy_Ork_Patrol3"},  
	
	blueprint = {--[[1]]"ork_squad_shoota_boy", --[[2]]"ork_squad_shoota_boy", --[[3]]"ork_squad_killa_kan", --[[4]]"ork_squad_grot", --[[5]]"ork_squad_shoota_boy", --[[6]] --[[7]]"ork_squad_slugga", --[[8]]"ork_squad_shoota_boy",
	--[[9]] --[[10]]"ork_squad_slugga", --[[11]]"ork_squad_shoota_boy", --[[12]]"ork_squad_killa_kan", --[[13]] --[[14]]"ork_squad_shoota_boy", --[[15]]"ork_squad_armored_nob", --[[16]]"ork_squad_looted_tank", --[[17]]"ork_squad_wartrak",
	--[[18]]"ork_squad_shoota_boy", --[[19]]"ork_squad_shoota_boy", --[[20]] --[[21]]"ork_squad_shoota_boy", --[[22]]"ork_squad_slugga", --[[23]]"ork_squad_killa_kan"},
	
	marker_spawn = {--[[1]]"mkr_Ork_Base1", --[[2]]"mkr_Ork_Base2", --[[3]]"mkr_Ork_Base3", --[[4]]"mkr_Ork_Base4", --[[5]]"mkr_Ork_Base5", --[[6]] --[[7]]"mkr_Ork_Base7", --[[8]]"mkr_Ork_Base8", --[[9]] 
	--[[10]]"mkr_Ork_Base10", --[[11]]"mkr_Ork_Base11", --[[12]]"mkr_Ork_Base12", --[[13]]--[[14]]"mkr_Ork_Base14", --[[15]]"mkr_Ork_Base15", --[[16]]"mkr_Ork_Base16", --[[17]]"mkr_Ork_Base17", --[[18]]"mkr_Ork_Base18", --[[19]]"mkr_Ork_Base19",
	--[[20]] --[[21]]"mkr_Ork_Base21", --[[22]]"mkr_Ork_Base22", --[[23]]"mkr_Ork_Base23"}, 
	
	stance = {--[[1]]STANCE_Hold, --[[2]]STANCE_Hold, --[[3]]STANCE_Hold, --[[4]]STANCE_Hold, --[[5]]STANCE_Attack, --[[6]] --[[7]]STANCE_Hold, --[[8]]STANCE_Hold, --[[9]]
	--[[10]]STANCE_Hold, --[[11]]STANCE_Hold, --[[12]]STANCE_Hold, --[[13]] --[[14]]STANCE_StandGround, --[[15]]STANCE_Hold, --[[16]]STANCE_Hold, --[[17]]STANCE_StandGround, --[[18]]STANCE_StandGround,
	--[[19]]STANCE_Attack, --[[20]] --[[21]]STANCE_Attack, --[[22]]STANCE_Attack, --[[23]]STANCE_Attack},
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 2, --[[5]] 1, --[[6]]  --[[7]] 1, --[[8]] 1, --[[9]]  --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]]  --[[14]] 1, --[[15]] 1, --[[16]] 1, --[[17]] 1, --[[18]] 1, --[[19]] 1, --[[20]]  --[[21]] 1, --[[22]] 1, --[[23]] 1}, 
	
	squad_size = {--[[1]] 6, --[[2]] 7, --[[3]] 1, --[[4]] 6, --[[5]] 8, --[[6]]  --[[7]] 7, --[[8]] 10, --[[9]]  --[[10]] 10, --[[11]] 10, --[[12]] 1, --[[13]]  --[[14]] 6, --[[15]] 2, --[[16]] 1, --[[17]] 1, --[[18]] 6, --[[19]] 5, --[[20]]  --[[21]] 10, --[[22]] 7, --[[23]] 1}, 
}

if g_Enemy_Ork_Army_iter <= table.getn(t_Enemy_Ork_Army.sgroup_name) and (SGroup_Exists(t_Enemy_Ork_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Enemy_Ork_Army.sgroup_name[i])) then

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player1, t_Enemy_Ork_Army.sgroup_name[i], t_Enemy_Ork_Army.blueprint[i], t_Enemy_Ork_Army.marker_spawn[i], t_Enemy_Ork_Army.squad_num[i], t_Enemy_Ork_Army.squad_size[i])
	Cmd_SetStance(t_Enemy_Ork_Army.sgroup_name[i], t_Enemy_Ork_Army.stance[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Ork_AI_Army"), SGroup_FromName(t_Enemy_Ork_Army.sgroup_name[i]))
	
	elseif g_Enemy_Ork_Army_iter > table.getn(t_Enemy_Ork_Army.sgroup_name) then

			g_Enemy_Ork_Army_iter = 0
			
			Rule_AddInterval(Rule_Set_Up_Ork_Buildings, 2)
			Rule_AddInterval(Rule_Ork_Patrol_P1, 5)
			Rule_AddInterval(Rule_Ork_Patrol_P2, 5)
			Rule_AddInterval(Rule_Ork_Patrol_P3, 5)
			
						
			Rule_Remove(Rule_Enemy_Ork_Army_Creation)
		
	end
g_Enemy_Ork_Army_iter = g_Enemy_Ork_Army_iter+1

end


--[[ Sturnn Army Creation ]]

function Rule_Sturnn_Army_Creation()

local i = g_Sturnn_Army_iter 

t_Sturnn_Army = {
	
	sgroup_name = { --[[1]]"sg_Guard_Command1", --[[2]]"sg_Guard_Command2", --[[3]]"sg_Guard_Command3", --[[4]]"sg_Guard_Command4", --[[5]]"sg_Guard_Command5", --[[6]] "sg_Captain_Sturnn", --[[7]]"sg_Guard_Command6", --[[8]]"sg_Guard_Command7", --[[9]]"sg_Guard_Command8", 
	--[[10]]"sg_Guard_Command9", --[[11]]"sg_Guard_Command10", --[[12]]"sg_Guard_Command11", --[[13]]"sg_Guard_Command12", --[[14]]"sg_Guard_Command13", --[[15]]"sg_Guard_Command14", --[[16]]"sg_Guard_Command15", --[[17]]"sg_Guard_Command16", --[[18]]"sg_Guard_Command17", 
	--[[19]]"sg_Guard_Command18"},  
	
	blueprint = {--[[1]]"guard_squad_guardsmen",--[[2]]"guard_squad_ogryns", --[[3]]"guard_squad_guardsmen", --[[4]]"guard_squad_sentinel", --[[5]]"guard_squad_sentinel", --[[6]] "guard_squad_command_squad", --[[7]]"guard_squad_guardsmen", --[[8]]"guard_squad_lemanruss", --[[9]]"guard_squad_priest", 
	--[[10]]"guard_squad_guardsmen", --[[11]]"guard_squad_hellhound", --[[12]]"guard_squad_guardsmen", --[[13]]"guard_squad_sentinel", --[[14]]"guard_squad_guardsmen", --[[15]]"guard_squad_hellhound", --[[16]]"guard_squad_hellhound", --[[17]]"guard_squad_guardsmen", --[[18]]"guard_squad_guardsmen",
	--[[19]]"guard_squad_guardsmen"	},
	
	marker_spawn = {--[[1]]"mkr_Imp_Army1", --[[2]]"mkr_Imp_Army2", --[[3]]"mkr_Imp_Army3", --[[4]]"mkr_Imp_Army4", --[[5]]"mkr_Imp_Army5", --[[6]]"mkr_Sturnn_Combat", --[[7]]"mkr_Imp_Army6", --[[8]]"mkr_Imp_Army7", --[[9]]"mkr_Imp_Army8", --[[10]]"mkr_Imp_Army9",
	--[[11]]"mkr_Imp_Army10", --[[12]]"mkr_Imp_Army11", --[[13]]"mkr_Imp_Army12", --[[14]]"mkr_Imp_Army13", --[[15]]"mkr_Imp_Army14", --[[16]]"mkr_Imp_Army15", --[[17]]"mkr_Imp_Army16", --[[18]]"mkr_Imp_Army17", --[[19]]"mkr_Imp_Army18"}, 
	
	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, --[[14]] 1, --[[15]] 1, --[[16]] 1, --[[17]] 1, --[[18]] 1, --[[19]] 1}, 
	
	squad_size = {--[[1]] 9, --[[2]] 6, --[[3]] 9, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 6, --[[8]] 1, --[[9]] 1, --[[10]] 7, --[[11]] 2, --[[12]] 7, --[[13]] 1, --[[14]] 4, --[[15]] 1, --[[16]] 1, --[[17]] 9, --[[18]] 8, --[[19]] 7},
}
		
if g_Sturnn_Army_iter <= table.getn(t_Sturnn_Army.sgroup_name) and (SGroup_Exists(t_Sturnn_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Sturnn_Army.sgroup_name[i])) then

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_Sturnn_Army.sgroup_name[i], t_Sturnn_Army.blueprint[i], t_Sturnn_Army.marker_spawn[i], t_Sturnn_Army.squad_num[i], t_Sturnn_Army.squad_size[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Sturnn_Command"), SGroup_CreateIfNotFound(t_Sturnn_Army.sgroup_name[i]))
		
	elseif g_Sturnn_Army_iter > table.getn(t_Sturnn_Army.sgroup_name) then
			g_Sturnn_Army_iter = 0
			Rule_Add(Rule_Sturnn_Monitor)
			Rule_Add(Rule_Objective_Kill_Sturnn)

			Cmd_SetStance("sg_Guard_Command4",STANCE_StandGround)
			Cmd_SetStance("sg_Guard_Command6",STANCE_StandGround)
			Cmd_SetStance("sg_Guard_Command9",STANCE_StandGround)
			Cmd_SetStance("sg_Guard_Command10",STANCE_StandGround)
			Cmd_SetStance("sg_Guard_Command11",STANCE_StandGround)
			Cmd_SetStance("sg_Guard_Command12",STANCE_StandGround)
			Cmd_SetStance("sg_Guard_Command13",STANCE_StandGround)
			Cmd_SetStance("sg_Guard_Command14",STANCE_StandGround)
		
			
			Rule_Add(Rule_Mine_Movement)
			Rule_Remove(Rule_Sturnn_Army_Creation)
			
	end
g_Sturnn_Army_iter = g_Sturnn_Army_iter+1

end


--[[ Mechanize Guard Army Creation ]]

function Rule_Mechanize_Guard_Army_Creation()

local i = g_Mechanize_Guard_Army_iter 

t_Mechanize_Guard_Army = {
	
	sgroup_name = { --[[1]]"sg_Mechanize1", --[[2]]"sg_Mechanize2", --[[3]]"sg_Mechanize3", --[[4]] --[[5]]"sg_Mechanize5", --[[6]]"sg_Mechanize6", --[[7]]"sg_Sentinel1", --[[8]]"sg_Sentinel2", --[[9]]"sg_Mechanize7", --[[10]]"sg_Mechanize8", --[[11]]"sg_Mechanize9", --[[12]]"sg_Mechanize10",
	--[[13]]"sg_Mechanize11"},  
	
	blueprint = {--[[1]]"guard_squad_lemanruss", --[[2]]"guard_squad_hellhound", --[[3]]"guard_squad_hellhound", --[[4]] --[[5]]"guard_squad_lemanruss", --[[6]]"guard_squad_lemanruss", --[[7]]"guard_squad_sentinel", --[[8]]"guard_squad_sentinel", --[[9]]"guard_squad_guardsmen", --[[10]]"guard_squad_guardsmen",
	--[[11]]"guard_squad_guardsmen", --[[12]]"guard_squad_guardsmen", --[[13]]"guard_squad_guardsmen"},
	
	marker_spawn = {--[[1]]"mkr_Mechanize1", --[[2]]"mkr_Mechanize2", --[[3]]"mkr_Mechanize3", --[[4]] --[[5]]"mkr_Mechanize5", --[[6]]"mkr_Mechanize6", --[[7]]"mkr_Mechanize7", --[[8]]"mkr_Mechanize8", --[[9]]"mkr_Capture_Flag1", --[[10]]"mkr_Capture_Flag2", --[[11]]"mkr_Mechanize9",
	--[[12]]"mkr_Mechanize10", --[[13]]"mkr_Mechanize11",}, 
	
	stance = {--[[1]]STANCE_StandGround, --[[2]]STANCE_StandGround, --[[3]]STANCE_StandGround, --[[4]] --[[5]]STANCE_StandGround, --[[6]]STANCE_StandGround, --[[7]]STANCE_Attack, --[[8]]STANCE_Hold, --[[9]]STANCE_StandGround, --[[10]]STANCE_StandGround, --[[11]]STANCE_StandGround, --[[12]]STANCE_StandGround,
	--[[13]]STANCE_StandGround},
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]]  --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 1}, 
	
	squad_size = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]]  --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 9, --[[10]] 9, --[[11]] 9, --[[12]] 9, --[[13]] 9}, 
}
		
if g_Mechanize_Guard_Army_iter <= table.getn(t_Mechanize_Guard_Army.sgroup_name) and (SGroup_Exists(t_Mechanize_Guard_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Mechanize_Guard_Army.sgroup_name[i])) then

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_Mechanize_Guard_Army.sgroup_name[i], t_Mechanize_Guard_Army.blueprint[i], t_Mechanize_Guard_Army.marker_spawn[i], t_Mechanize_Guard_Army.squad_num[i], t_Mechanize_Guard_Army.squad_size[i])
	Cmd_SetStance(t_Mechanize_Guard_Army.sgroup_name[i], t_Mechanize_Guard_Army.stance[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guards_Second_Half"), SGroup_FromName(t_Mechanize_Guard_Army.sgroup_name[i]))
		
	elseif g_Mechanize_Guard_Army_iter > table.getn(t_Mechanize_Guard_Army.sgroup_name) then
			g_Mechanize_Guard_Army_iter = 0
			
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Mechanize7")
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Mechanize8")
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Mechanize9")
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Mechanize10")
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Mechanize11")
			Rule_AddInterval(Rule_Imperial_Guard_EmergencyTrack, 15)
			Rule_Remove(Rule_Mechanize_Guard_Army_Creation)
		
	end
g_Mechanize_Guard_Army_iter = g_Mechanize_Guard_Army_iter+1

end


--[[ Psyker Guard Army Creation ]]

function Rule_Psyker_Guard_Army_Creation()

local i = g_Psyker_Guard_Army_iter 

t_Psyker_Guard_Army = {
	
	sgroup_name = { --[[1]]"sg_Psyker1", --[[2]]"sg_Psyker2", --[[3]]"sg_Psyker3", --[[4]]"sg_Psyker4", --[[5]]"sg_Psyker5", --[[6]]"sg_Psyker6", --[[7]]"sg_Psyker7", --[[8]]"sg_Psyker8", --[[9]]"sg_Psyker9", --[[10]]"sg_Psyker10", --[[11]]"sg_Psyker11", --[[12]]"sg_Psyker12"},  
	
	blueprint = {--[[1]]"guard_squad_psyker", --[[2]]"guard_squad_psyker", --[[3]]"guard_squad_psyker", --[[4]]"guard_squad_psyker", --[[5]]"guard_squad_guardsmen", --[[6]]"guard_squad_guardsmen", --[[7]]"guard_squad_hellhound", --[[8]]"guard_squad_psyker", --[[9]]"guard_squad_sentinel", 
	--[[10]]"guard_squad_sentinel", --[[11]]"guard_squad_guardsmen", --[[12]]"guard_squad_guardsmen"},
	
	marker_spawn = {--[[1]]"mkr_Psyker1", --[[2]]"mkr_Psyker2", --[[3]]"mkr_Psyker3", --[[4]]"mkr_Psyker4", --[[5]]"mkr_Psyker5", --[[6]]"mkr_Psyker6", --[[7]]"mkr_Psyker7", --[[8]]"mkr_Psyker8", --[[9]]"mkr_Psyker9", --[[10]]"mkr_Psyker10", --[[11]]"mkr_Capture_Flag5",
	--[[12]]"mkr_Capture_Flag6"}, 
	
	squad_num = {--[[1]] 3, --[[2]] 3, --[[3]] 3, --[[4]] 3, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 1}, 
	
	squad_size = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 7, --[[6]] 8, --[[7]] 2, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 9, --[[12]] 9}, 
}
		
if g_Psyker_Guard_Army_iter <= table.getn(t_Psyker_Guard_Army.sgroup_name) and (SGroup_Exists(t_Psyker_Guard_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Psyker_Guard_Army.sgroup_name[i])) then

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_Psyker_Guard_Army.sgroup_name[i], t_Psyker_Guard_Army.blueprint[i], t_Psyker_Guard_Army.marker_spawn[i], t_Psyker_Guard_Army.squad_num[i], t_Psyker_Guard_Army.squad_size[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guards_Second_Half"), SGroup_FromName(t_Psyker_Guard_Army.sgroup_name[i]))
		
	elseif g_Psyker_Guard_Army_iter > table.getn(t_Psyker_Guard_Army.sgroup_name) then
			g_Psyker_Guard_Army_iter = 0
			
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Psyker5")
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Psyker6")
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Psyker11")
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Psyker12")
			
			Rule_Remove(Rule_Psyker_Guard_Army_Creation)
		
	end
g_Psyker_Guard_Army_iter = g_Psyker_Guard_Army_iter+1

end


--[[ Fire Support Guard Army Creation ]]

function Rule_Fire_Support_Guard_Army_Creation()

local i = g_Fire_Support_Guard_Army_iter 

t_Fire_Support_Guard_Army = {
	
	sgroup_name = { --[[1]]"sg_Support1", --[[2]]"sg_Support2", --[[3]]"sg_Support3", --[[4]]"sg_Support4", --[[5]]"sg_Support5", --[[6]]"sg_Support6", --[[7]]"sg_Support7", --[[8]]"sg_Support8", --[[9]] --[[10]]--[[11]]"sg_Support11", --[[12]]"sg_Support12", --[[13]]"sg_Support13",
	--[[14]]"sg_Support14", --[[15]]"sg_Support15"},  
	
	blueprint = {--[[1]]"guard_squad_basilisk", --[[2]]"guard_squad_lemanruss", --[[3]]"guard_squad_basilisk", --[[4]]"guard_squad_lemanruss", --[[5]]"guard_squad_basilisk", --[[6]]"guard_squad_basilisk", --[[7]]"guard_squad_basilisk", --[[8]]"guard_squad_hellhound",
	--[[9]] --[[10]] --[[11]]"guard_squad_guardsmen", --[[12]]"guard_squad_guardsmen", --[[13]]"guard_squad_guardsmen", --[[14]]"guard_squad_guardsmen", --[[15]]"guard_squad_guardsmen"},
	
	marker_spawn = {--[[1]]"mkr_Fire_Support1", --[[2]]"mkr_Fire_Support2", --[[3]]"mkr_Fire_Support3", --[[4]]"mkr_Fire_Support4", --[[5]]"mkr_Fire_Support5", --[[6]]"mkr_Fire_Support6", --[[7]]"mkr_Fire_Support7", --[[8]]"mkr_Fire_Support8", --[[9]] --[[10]]
	--[[11]]"mkr_Capture_Flag7", --[[12]]"mkr_Capture_Flag8", --[[13]]"mkr_Fire_Support11", --[[14]]"mkr_Fire_Support12", --[[15]]"mkr_Fire_Support13"}, 
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]]  --[[10]] --[[11]] 1, --[[12]] 1, --[[13]] 1, --[[14]] 1, --[[15]] 1}, 
	
	squad_size = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]]  --[[10]]  --[[11]] 9, --[[12]] 9, --[[13]] 9, --[[14]] 9, --[[15]] 9}, 

}
		
if g_Fire_Support_Guard_Army_iter <= table.getn(t_Fire_Support_Guard_Army.sgroup_name) and (SGroup_Exists(t_Fire_Support_Guard_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Fire_Support_Guard_Army.sgroup_name[i])) then

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_Fire_Support_Guard_Army.sgroup_name[i], t_Fire_Support_Guard_Army.blueprint[i], t_Fire_Support_Guard_Army.marker_spawn[i], t_Fire_Support_Guard_Army.squad_num[i], t_Fire_Support_Guard_Army.squad_size[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guards_Second_Half"), SGroup_FromName(t_Fire_Support_Guard_Army.sgroup_name[i]))
		
	elseif g_Fire_Support_Guard_Army_iter > table.getn(t_Fire_Support_Guard_Army.sgroup_name) then
			g_Fire_Support_Guard_Army_iter = 0
			
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Support11")
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Support12")
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Support13")
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Support14")
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Support15")
			
			Cmd_SetStance("sg_Support1", STANCE_StandGround)
			Cmd_SetStance("sg_Support3", STANCE_StandGround)
			Cmd_SetStance("sg_Support5", STANCE_StandGround)
			Cmd_SetStance("sg_Support6", STANCE_StandGround)
			Cmd_SetStance("sg_Support7", STANCE_StandGround)
			Cmd_SetStance("sg_Support8", STANCE_StandGround)
			Cmd_SetStance("sg_Support11", STANCE_StandGround)
			Cmd_SetStance("sg_Support12", STANCE_StandGround)
			
			Rule_Remove(Rule_Fire_Support_Guard_Army_Creation)
		
	end
g_Fire_Support_Guard_Army_iter = g_Fire_Support_Guard_Army_iter+1

end


--[[ Lawlessness Guard Army Creation ]]

function Rule_Lawlessness_Guard_Army_Creation()

local i = g_Lawlessness_Guard_Army_iter 

t_Lawlessness_Guard_Army = {
	sgroup_name = { --[[1]]"sg_Law1", --[[2]] --[[3]]"sg_Law3", --[[4]]"sg_Law4", --[[5]]"sg_Law5", --[[6]]"sg_Law6", --[[7]]"sg_Law7", --[[8]]"sg_Law8", --[[9]]"sg_Law9", --[[10]]"sg_Law10", --[[11]]"sg_Law11"},  
	
	blueprint = {--[[1]]"guard_squad_ogryns", --[[2]] --[[3]]"guard_squad_ogryns", --[[4]]"guard_squad_ogryns", --[[5]]"guard_squad_guardsmen", --[[6]]"guard_squad_guardsmen", --[[7]]"guard_squad_guardsmen",
	--[[8]]"guard_squad_priest", --[[9]]"guard_squad_priest", --[[10]]"guard_squad_guardsmen", --[[11]]"guard_squad_guardsmen"},
	
	marker_spawn = {--[[1]]"mkr_Law1", --[[2]] --[[3]]"mkr_Law3", --[[4]]"mkr_Law4", --[[5]]"mkr_Law5", --[[6]]"mkr_Law6", --[[7]]"mkr_Law7", --[[8]]"mkr_Law8", --[[9]]"mkr_Law9", --[[10]]"mkr_Law10", --[[11]]"mkr_Law11"}, 
	
	stance	=	{--[[1]] STANCE_Attack, --[[2]]  --[[3]] STANCE_Attack, --[[4]] STANCE_Attack, --[[5]] STANCE_Hold, --[[6]] STANCE_Hold, --[[7]] STANCE_Hold, --[[8]] STANCE_Attack, --[[9]] STANCE_Attack, --[[10]] STANCE_Hold,
	--[[11]] STANCE_Hold},
	
	squad_num = {--[[1]] 1, --[[2]] --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1}, 
	
	squad_size = {--[[1]] 9, --[[2]]  --[[3]] 6, --[[4]] 6, --[[5]] 7, --[[6]] 8, --[[7]] 8, --[[8]] 1, --[[9]] 1, --[[10]] 9, --[[11]] 9}, 

}
		
if g_Lawlessness_Guard_Army_iter <= table.getn(t_Lawlessness_Guard_Army.sgroup_name) and (SGroup_Exists(t_Lawlessness_Guard_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Lawlessness_Guard_Army.sgroup_name[i])) then

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_Lawlessness_Guard_Army.sgroup_name[i], t_Lawlessness_Guard_Army.blueprint[i], t_Lawlessness_Guard_Army.marker_spawn[i], t_Lawlessness_Guard_Army.squad_num[i], t_Lawlessness_Guard_Army.squad_size[i])
	Cmd_SetStance(t_Lawlessness_Guard_Army.sgroup_name[i], t_Lawlessness_Guard_Army.stance[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guards_Second_Half"), SGroup_FromName(t_Lawlessness_Guard_Army.sgroup_name[i]))
	
	elseif g_Lawlessness_Guard_Army_iter > table.getn(t_Lawlessness_Guard_Army.sgroup_name) then
			g_Lawlessness_Guard_Army_iter = 0
			
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Law5")
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Law6")
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Law7")
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Law10")
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen_Total"), "sg_Law11")
			
			Rule_AddDelay(Rule_Hide_Guard_Armies, 15)
			Rule_Remove(Rule_Lawlessness_Guard_Army_Creation)
		
	end
g_Lawlessness_Guard_Army_iter = g_Lawlessness_Guard_Army_iter+1

end

function Rule_Hide_Guard_Armies()

--[[despawning troops in second half of map]]
SGroup_DeSpawn("sg_Guards_Second_Half")
Rule_Remove(Rule_Hide_Guard_Armies)

end


--[[ Player Chaos Army Creation ]]

function Rule_Player_Chaos_Army_Creation()

local i = g_Player_Chaos_Army_iter 

t_Player_Chaos_Army = {
	
	sgroup_name = { --[[1]]"sg_Chaos_Army1", --[[2]]"sg_Crull", --[[3]]"sg_Chaos_Army2", --[[4]]"sg_Chaos_Sorcerer", --[[5]]"sg_Chaos_Armor", --[[6]]"sg_Chaos_Army3", --[[7]]"sg_Chaos_Army4"},  
	
	blueprint = {--[[1]]"chaos_marine_squad", --[[2]]"chaos_squad_lord", --[[3]]"chaos_marine_squad", --[[4]]"chaos_squad_sorcerer",--[[5]]"chaos_squad_predator", --[[6]]"chaos_squad_cultist", --[[7]]"chaos_squad_slave"},
	
	marker_spawn = {--[[1]]"mkr_Chaos_Army1", --[[2]]"mkr_Crull", --[[3]]"mkr_Chaos_Army2", --[[4]]"mkr_Chaos_Sorcerer", --[[5]]"mkr_Chaos_Armor", --[[6]]"mkr_Chaos_Army3", --[[7]]"mkr_Chaos_Army4"}, 
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 3, --[[6]] 1, --[[7]] 2}, 
	
	squad_size = {--[[1]] 9, --[[2]] 1, --[[3]] 9, --[[4]] 1, --[[5]] 1, --[[6]] 5, --[[7]] 1}, 
}
		
if g_Player_Chaos_Army_iter <= table.getn(t_Player_Chaos_Army.sgroup_name) and (SGroup_Exists(t_Player_Chaos_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Player_Chaos_Army.sgroup_name[i])) then

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_Player_Chaos_Army.sgroup_name[i], t_Player_Chaos_Army.blueprint[i], t_Player_Chaos_Army.marker_spawn[i], t_Player_Chaos_Army.squad_num[i], t_Player_Chaos_Army.squad_size[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Chaos_Group"), SGroup_FromName(t_Player_Chaos_Army.sgroup_name[i]))
		
	elseif g_Player_Chaos_Army_iter > table.getn(t_Player_Chaos_Army.sgroup_name) then
			g_Player_Chaos_Army_iter = 0
			
			FOW_RevealMarker("mkr_Blood_Pit", -1)
			Rule_Add(Rule_Crull_Track)
			Rule_AddIntervalDelay(Rule_Trigger_Eldar_Raid, 240, 10)
			Rule_AddInterval(Rule_Ogryn_Advice, 3)
			Rule_Remove(Rule_Player_Chaos_Army_Creation)
			
	end
g_Player_Chaos_Army_iter = g_Player_Chaos_Army_iter+1

end

function Rule_Crull_Track()

local blueprinttable = Util_MakeBlueprintTable("chaos_squad_lord")

--[[ check to see if the group is empty AND if the boolean has been returned to false - this prevents duplicate rule adds ]]
if g_crullreturn ~= true and SGroup_Exists("sg_Crull") and ( SGroup_IsEmpty("sg_Crull") or SGroup_ContainsBlueprints( "sg_Crull", blueprinttable, false) == false)then
	
	--[[ prevents duplicate rule adds ]]
	g_crullreturn = true
	
	--[[ 6 second delay, keeps it from being instantaneous ]]
	Rule_AddOneShot(Rule_Crull_Return, 6)
	

end

end

function Rule_Crull_Return()

--[[ recreate the unit ]]
Util_CreateSquadsAtMarker(g_Player2, "sg_Crull", "chaos_squad_lord","mkr_Crull", 1)

--[[ play the fx ]]
World_FXEventSquad("data:Art/Events/Unit_Upgrade_Morale_FX/Reinforce_Trooper", SGroup_FromName("sg_Crull"))

--[[ reset the flag ]]
g_crullreturn = false

--[[ if no messages have played recently, play the Intel Event - this keeps messages from flooding the player ]]

if Event_TimeSinceLast() > 15 then
	Util_StartIntel(EVENTS.IE_Chaos_ImBack)
end
EventCue_DoEvent( "recruit_commander", "/Races/Shared/Upgrade_weapon", "$42890", "$42892" )

end


--[[ Switch ]]

--[[ - the death of Sturnn will trigger the switch to the chaos side]]

function Rule_Sturnn_Monitor()

if SGroup_GetAvgHealth("sg_Captain_Sturnn") == 0 then
	
	g_kill_Sturnn = true

	Rule_Remove(Rule_Mine_Movement)
	Rule_Remove(Rule_Sturnn_Monitor)
			
	
end

end


--[[ Ogryn advice ]]

function Rule_Ogryn_Advice()

if Player_AreSquadsNearMarker(g_Player2, "mkr_Ogryn_Advice") then
	
	Util_StartIntel(EVENTS.IE_Ogryn_Advice)
	Rule_Remove(Rule_Ogryn_Advice)
end

end


--[[ Mine movement ]]

--[[ - this makes the two squads waiting on the wings of the imp base move towards it when either of the mines have been destroyed]]

function Rule_Mine_Movement()

if EGroup_Count(EGroup_CreateIfNotFound("eg_Imperial_Mines")) <= 1 then
	Cmd_AttackMoveMarker("sg_Guard_Command1", "mkr_Imp_Army8")
	Cmd_AttackMoveMarker("sg_Guard_Command3", "mkr_Imp_Army8")
	
	Rule_Remove(Rule_Mine_Movement)

end

end


--[[ Ork Base creation ]]

--[[ create ork buildings ]]

function Rule_Set_Up_Ork_Buildings()

local blue = {--[[1]]"ork_waagh_banner", --[[2]]"ork_waagh_banner", --[[3]]"ork_boy_hut", --[[4]]"ork_generator", --[[5]]"ork_generator", --[[6]]"ork_pile_o_guns",
--[[7]]"ork_generator", --[[8]]"ork_waagh_banner", --[[9]]"ork_mine_field", --[[10]]"ork_mine_field", --[[11]]"ork_mine_field"}

	
for i = 1, table.getn(blue) do
	Entity_CreateBuildingMarker(g_Player1, "eg_ork_build"..i, blue[i], "mkr_Ork_Building"..i, 0.1)
	EGroup_AddGroup(EGroup_CreateIfNotFound("eg_ork_buildings"), EGroup_FromName("eg_ork_build"..i))

end
	
	Rule_AddOneShot(Rule_temp, 1)
	Rule_Remove(Rule_Set_Up_Ork_Buildings)

end

function Rule_temp()

Command_SquadEntity(g_Player1, SGroup_FromName("sg_Ork_Builder"), SCMD_BuildStructure, EGroup_FromName("eg_ork_build1"))
Rule_AddIntervalDelay(Rule_Begin_Construction, 6, 10)

end

--[[ start the construction ]]

function Rule_Begin_Construction()

local i = g_building

if SGroup_Exists("sg_Ork_Builder") == false or SGroup_IsEmpty("sg_Ork_Builder") then
	
	Rule_Remove(Rule_Begin_Construction)



elseif SGroup_Exists("Rule_Begin_Construction") and i <= 11 
and  Squad_GetActiveCommand(SGroup_GetSpawnedSquadAt(SGroup_CreateIfNotFound("sg_Ork_Builder"), 1)) == SQUADSTATEID_Idle then
	
	Command_SquadEntity(g_Player1, SGroup_FromName("sg_Ork_Builder"), SCMD_BuildStructure, EGroup_FromName("eg_ork_build"..i))
	g_building = g_building+1
	
elseif  i >= 11  then

	Rule_Remove(Rule_Begin_Construction)
	
elseif EGroup_Exists("eg_ork_build"..i) == false then

	Rule_Remove(Rule_Begin_Construction)
	
end

end


--[[ Ork Patrols ]]

function Rule_Ork_Patrol_P1()

local i = g_P1_iter

t_patrol_P1 = {
	sgroup_name = {--[[1]]"sg_Enemy_Ork_Patrol1", "sg_Enemy_Ork_Patrol1", "sg_Enemy_Ork_Patrol1", "sg_Enemy_Ork_Patrol1", "sg_Enemy_Ork_Patrol1", "sg_Enemy_Ork_Patrol1"},
	marker_target = {--[[1]]"mkr_P1P1", --[[2]]"mkr_P1P2", --[[3]]"mkr_P1P3", --[[4]]"mkr_P1P4", --[[5]]"mkr_P1P5", --[[6]]"mkr_P1P6"}, 
}

if  g_P1_iter <= table.getn(t_patrol_P1.sgroup_name) and (SGroup_Exists(t_patrol_P1.sgroup_name[i]) == true and SGroup_IsEmpty(t_patrol_P1.sgroup_name[i])) == false and Squad_GetActiveCommand(SGroup_GetSpawnedSquadAt(SGroup_CreateIfNotFound(t_patrol_P1.sgroup_name[i]), 1)) == SQUADSTATEID_Idle then

	Cmd_AttackMoveMarker(t_patrol_P1.sgroup_name[i], t_patrol_P1.marker_target[i])
	
elseif SGroup_IsEmpty("sg_Enemy_Ork_Patrol1") == true then

	Rule_Remove(Rule_Ork_Patrol_P1)

elseif g_P1_iter > table.getn(t_patrol_P1.sgroup_name) then
		g_P1_iter = 0
	
end
g_P1_iter = g_P1_iter+1

end

function Rule_Ork_Patrol_P2()

local i = g_P2_iter

t_patrol_P2 = {
	sgroup_name = {--[[1]]"sg_Enemy_Ork_Patrol2", "sg_Enemy_Ork_Patrol2", "sg_Enemy_Ork_Patrol2", "sg_Enemy_Ork_Patrol2", "sg_Enemy_Ork_Patrol2", "sg_Enemy_Ork_Patrol2"},
	marker_target = {--[[1]]"mkr_P2P1", --[[2]]"mkr_P2P2", --[[3]]"mkr_P2P3", --[[4]]"mkr_P2P4", --[[5]]"mkr_P2P5", --[[6]]"mkr_P2P6"}, 
}

if  g_P2_iter <= table.getn(t_patrol_P2.sgroup_name) and (SGroup_Exists(t_patrol_P2.sgroup_name[i]) == true and SGroup_IsEmpty(t_patrol_P2.sgroup_name[i])) == false and Squad_GetActiveCommand(SGroup_GetSpawnedSquadAt(SGroup_CreateIfNotFound(t_patrol_P2.sgroup_name[i]), 1)) == SQUADSTATEID_Idle then

	Cmd_AttackMoveMarker(t_patrol_P2.sgroup_name[i], t_patrol_P2.marker_target[i])
	
elseif SGroup_IsEmpty("sg_Enemy_Ork_Patrol2") == true then

	Rule_Remove(Rule_Ork_Patrol_P2)

elseif g_P2_iter > table.getn(t_patrol_P2.sgroup_name) then
		g_P2_iter = 0
				
	
end
g_P2_iter = g_P2_iter+1

end

function Rule_Ork_Patrol_P3()

local i = g_P3_iter

t_patrol_P3 = {
	sgroup_name = {--[[1]]"sg_Enemy_Ork_Patrol3", "sg_Enemy_Ork_Patrol3", "sg_Enemy_Ork_Patrol3", "sg_Enemy_Ork_Patrol3", "sg_Enemy_Ork_Patrol3", "sg_Enemy_Ork_Patrol3"},
	marker_target = {--[[1]]"mkr_P2P6", --[[2]]"mkr_P2P5", --[[3]]"mkr_P2P4", --[[4]]"mkr_P2P3", --[[5]]"mkr_P2P2", --[[6]]"mkr_P2P1"}, 
}

if  g_P3_iter <= table.getn(t_patrol_P3.sgroup_name) and (SGroup_Exists(t_patrol_P3.sgroup_name[i]) == true and SGroup_IsEmpty(t_patrol_P3.sgroup_name[i])) == false and Squad_GetActiveCommand(SGroup_GetSpawnedSquadAt(SGroup_CreateIfNotFound(t_patrol_P3.sgroup_name[i]), 1)) == SQUADSTATEID_Idle then

	Cmd_AttackMoveMarker(t_patrol_P3.sgroup_name[i], t_patrol_P3.marker_target[i])

elseif SGroup_IsEmpty("sg_Enemy_Ork_Patrol3") == true then

	Rule_Remove(Rule_Ork_Patrol_P3)

elseif g_P3_iter > table.getn(t_patrol_P3.sgroup_name) then
		g_P3_iter = 0
				
	
end
g_P3_iter = g_P3_iter+1

end


--[[ Guardsmen Capture button]]

function Rule_Capture_Button()

t_capture_button = {
	button_icon = {--[[1]]"Scar_buttons/capture_guards", --[[2]]"Scar_buttons/capture_guards", --[[3]]"Scar_buttons/capture_guards"},
	button_description = {--[[1]]"$880400", --[[2]]"$880401"}, 
}

g_button_capture_guardsmen = Util_AbilityButton_CreateModal(t_capture_button.button_icon, t_capture_button.button_description, true)
Rule_AddInterval(Rule_Capture_Button_Click, 1)
Rule_AddInterval(Rule_Captured_Guardsman_Control, 1)

end

function Rule_Pre_Button_Group()

SGroup_Clear(SGroup_CreateIfNotFound("sg_Potential_Sorcerer"))
Misc_GetSelectedSquads(SGroup_CreateIfNotFound("sg_Potential_Sorcerer"))
Util_FilterBlueprint("chaos_squad_sorcerer", "sg_Potential_Sorcerer", "sg_Potential_Sorcerer2")

end

function Rule_Sorcerer_Button()

-- SGroup_Clear(SGroup_CreateIfNotFound("sg_Potential_Sorcerer")) -- Misc_GetSelectedSquads(SGroup_CreateIfNotFound("sg_Potential_Sorcerer")) -- Util_FilterBlueprint("chaos_squad_sorcerer", "sg_Potential_Sorcerer", "sg_Potential_Sorcerer2")

if SGroup_Exists("sg_Potential_Sorcerer2") 
and SGroup_Count(SGroup_FromName("sg_Potential_Sorcerer2")) > 0  then

-- and (Squad_GetBlueprintName(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Potential_Sorcerer2"), 1)) == "chaos_squad_sorcerer") then SGroup_Clear(SGroup_CreateIfNotFound("sg_Sorcerer")) SGroup_AddGroup(SGroup_FromName("sg_Sorcerer"), SGroup_FromName("sg_Potential_Sorcerer2"))

	if g_add_button == false then
	
		Util_SGroupAbilityButton_Add2Manager(g_button_capture_guardsmen, "sg_Sorcerer")
		Util_ButtonManagerUpdateAll()
		
		g_add_button = true
	
	end
	
	Util_ButtonManagerUpdateAll()
	
end

end

function Rule_Capture_Button_Click()

if Button_GetPressed(g_button_capture_guardsmen) == true then  
	SGroup_Clear(SGroup_CreateIfNotFound("sg_Guardsmen_Potentials")) 
	Button_GetPressedSquad(g_button_capture_guardsmen, SGroup_FromName("sg_Guardsmen_Potentials"))
	
	--[[ - this is the position of where the button is pressed in the game world]]
	local pos1 = SGroup_GetPosition(SGroup_FromName("sg_Guardsmen_Potentials"))
	local pos2 = SGroup_GetPosition(SGroup_FromName("sg_Sorcerer"))
	
	--[[ - this makes sure that the sorcerer squad hasn't gotten destroyed or been despawned before capturing the guards]]
	if SGroup_IsEmpty("sg_Guardsmen_Potentials") == false and SGroup_Exists("sg_Sorcerer") and SGroup_CountDeSpawned(SGroup_FromName("sg_Sorcerer")) == 0 and SGroup_IsEmpty("sg_Sorcerer") == false then
		
		if g_captured == false and Squad_GetBlueprintName(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Guardsmen_Potentials"), 1)) == "guard_squad_guardsmen" and World_DistancePointToPoint(pos1, pos2) < 25 then
			
			Anim_PlaySGroupAnim(SGroup_FromName("sg_Sorcerer"), "special_attack_3_sp" )
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Guardsmen"), SGroup_FromName("sg_Guardsmen_Potentials"))
			SGroup_SetPlayerOwner("sg_Guardsmen", g_Player6)
			Cmd_SetStance("sg_Guardsmen", STANCE_CeaseFire)
			World_FXEventSquad("data:Art/Events/Unit_Upgrade_Morale_FX/Reinforce_Trooper", SGroup_FromName("sg_Guardsmen"))
			Util_StartIntel(EVENTS.IE_Guardsmen_Captured)
			g_captured = true
		
		elseif g_captured == true then
			
			if g_Audio_Warning_One == false then
				
				Util_StartIntel(EVENTS.IE_Can_Control_Only_One_Squad)
				g_Audio_Warning_One = true
			
			else
			
				UIWarning_Show("$880406")
			
			end
	
		elseif Squad_GetBlueprintName(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Guardsmen_Potentials"), 1)) == "guard_squad_guardsmen" and World_DistancePointToPoint(pos1, pos2) > 25 then
	
			
			if g_Audio_Warning_Far == false then
							
				Util_StartIntel(EVENTS.IE_Squad_Too_Far)
				g_Audio_Warning_Far = true
			
			else
				
				UIWarning_Show("$880405")
			
			end
		
		elseif Squad_GetBlueprintName(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Guardsmen_Potentials"), 1)) == "guard_squad_guardsmen" == false then
		
			if g_Audio_Warning_Wrong == false then
			
				Util_StartIntel(EVENTS.IE_Wrong_Squad_Targeted)
				g_Audio_Warning_Wrong = true
			
			else
			
				UIWarning_Show("$880404")
			
			end
		
		end
	end
end

end

--[[ - this rule dictates what the guardsmen squads do once they've been converted]]

function Rule_Captured_Guardsman_Control()

if 	SGroup_Exists("sg_Guardsmen") and SGroup_IsEmpty("sg_Guardsmen") == false then
	
	if SGroup_Exists("sg_Sorcerer") and SGroup_CountDeSpawned(SGroup_FromName("sg_Sorcerer")) == 0 and SGroup_IsEmpty("sg_Sorcerer") == false then
		
		local sorcerpos = SGroup_GetPosition("sg_Sorcerer")
		
		if World_DistanceSGroupToPoint(SGroup_FromName("sg_Guardsmen"), sorcerpos, true) <= 38 then
			
			Cmd_MoveToPosOffset("sg_Guardsmen", sorcerpos, 4, 5)
			
		end
		
		if World_DistanceSGroupToPoint(SGroup_FromName("sg_Guardsmen"), sorcerpos, true) > 40 then
			
			Cmd_StopSquads("sg_Guardsmen")
			SGroup_SetPlayerOwner("sg_Guardsmen", g_Player3)
			Cmd_SetStance("sg_Guardsmen", STANCE_Hold)
			g_captured = false
			
		end
			
	elseif SGroup_Exists("sg_Sorcerer") and SGroup_CountDeSpawned(SGroup_FromName("sg_Sorcerer")) == 1 then
		
		Cmd_StopSquads("sg_Guardsmen")
		SGroup_SetPlayerOwner("sg_Guardsmen", g_Player3)
		g_captured = false
		
	end
elseif SGroup_Exists("sg_Guardsmen") == false or SGroup_IsEmpty("sg_Guardsmen") then
	
	g_captured = false

end

end


--[[ sync kill button]]

function Rule_SyncKill_Button()

t_synckill_button = {
	button_icon = {--[[1]]"Scar_buttons/synchkill_icon", --[[2]]"Scar_buttons/synchkill_icon", --[[3]]"Scar_buttons/synchkill_icon"},
	button_description = {--[[1]]"$880402", --[[2]]"$880403"}, 
}

g_button_bloodthirster_sync_kill = Util_AbilityButton_CreateModal(t_synckill_button.button_icon, t_synckill_button.button_description, true)
Rule_AddInterval(Rule_Synckill_Button_Click, 1)

end

function Rule_Synckill_Button_Click()

if Button_GetPressed(g_button_bloodthirster_sync_kill) == true then  
	SGroup_Clear(SGroup_CreateIfNotFound("sg_Avatar_Potential")) 
	Button_GetPressedSquad(g_button_bloodthirster_sync_kill, SGroup_FromName("sg_Avatar_Potential"))
	
	--[[ - this is the position of where the button is pressed in the game world]]
	local pos1 = SGroup_GetPosition(SGroup_FromName("sg_Avatar_Potential"))
	local pos2 = SGroup_GetPosition(SGroup_FromName("sg_Offering"))
	
		
	if SGroup_IsEmpty("sg_Avatar_Potential") == false 
	and Squad_GetBlueprintName(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Avatar_Potential"), 1)) == "eldar_squad_avatar" 
	and World_DistancePointToPoint(pos1, pos2) < 10 then
			
			Util_StartIntel(EVENTS.NIS_Avatar_Bloodthirster_Synchkill)
					
		elseif SGroup_IsEmpty("sg_Avatar_Potential") == false 
		and Squad_GetBlueprintName(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Avatar_Potential"), 1)) == "eldar_squad_avatar" 
		and World_DistancePointToPoint(pos1, pos2) > 10 then
	
			Util_StartIntel(EVENTS.IE_Avatar_Too_Far)
		
		elseif SGroup_IsEmpty("sg_Avatar_Potential") == false 
		and Squad_GetBlueprintName(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Avatar_Potential"), 1)) == "eldar_squad_avatar" == false then
		
			Util_StartIntel(EVENTS.IE_Wrong_Squad_Targeted_Avatar)
		
		else
		
			Util_StartIntel(EVENTS.IE_Wrong_Squad_Targeted_Avatar)
		
	end
end

end


--[[ Check for sorcerer's death ]]

function Rule_Check_Sorcerer_Death()

local blueprint_table = Util_MakeBlueprintTable("chaos_squad_sorcerer")

Player_AddSquadsToSGroup(g_Player2, "sg_Chaos_Total_Group")

if SGroup_ContainsBlueprints(SGroup_FromName("sg_Chaos_Total_Group"), blueprint_table, true) == false then
	
	Util_StartIntel(EVENTS.IE_Deceased_Sorcerer)
	
end

end


--[[ Blood Pit Sacrifice ]]

function Rule_Blood_Sacrifice()

local i = 1
if Player_AreSquadsNearMarker(g_Player6, "mkr_Blood_Pit") == true and g_Blood_Flag == false then
	local sgroupID = SGroup_CreateIfNotFound("sg_Prospect")
		SGroup_Clear(sgroupID)
		SGroup_Clear("sg_Guardsmen")
		Player_GetAllSquadsNearMarker(g_Player6, "sg_Prospect", "mkr_Blood_Pit")
		for y = 1, SGroup_Count(sgroupID) do
			local squadID = SGroup_GetSpawnedSquadAt(sgroupID, y)
			local blueprint = Squad_GetBlueprintName(squadID)
				if blueprint == "guard_squad_guardsmen" then
					local sgroupID2 = SGroup_CreateIfNotFound("sg_Sacrifice")
					
					SGroup_Add(sgroupID2, squadID)
					--[[ - the index is 1 because there should only be one squad at a time. Comment back in the squad_count line if you want the sacrifices to be based
					on the number of individuals sacrificed and not the number of squads]]
				--	local sacrifice = Squad_Count(SGroup_GetSpawnedSquadAt(sgroupID2, 1))
					local sacrifice = 1
					
					g_Blood_Tab = g_Blood_Tab + sacrifice
					
					g_Counter = g_Counter- sacrifice
					
					
					if g_Counter > 0 then
						UI_ShowCountUpdate("BloodTab", g_Counter)
						
					elseif g_Counter <= 0 then	
						UI_ShowCountUpdate("BloodTab", 0)
					end
					g_captured = 0
					Sound_PlayStinger("stinger_msd3_sacrificeofblood")
					
					--[[stops the squads from moving to prevent any sliding]]
					Cmd_StopSquads("sg_Sacrifice")
					
					Anim_PlaySGroupAnim(SGroup_FromName("sg_Sacrifice"), "sp_sacrifice")
					g_Blood_Flag = true
					
					--[[this is done to let the animation play itself out and thus prevent bodies hanging in the air after the squad is killed]]
					SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Delayed_Death"), SGroup_FromName("sg_Sacrifice"))
					SGroup_Clear(SGroup_FromName("sg_Sacrifice"))
					Rule_Check_AddOneShot(Rule_Delayed_Removal,9)		
					g_First_Blood = true
					
		
				end
			
		end
end

end

function Rule_Delayed_Removal()

SGroup_SelfDestroy("sg_Delayed_Death", true)
g_Blood_Flag = false
Rule_Remove(Rule_Delayed_Removal)

end

function Rule_Blood_Tab()

local i = g_Blood_Tab/5

if g_Blood_Tab >= 5  then

	Util_SetBloodPitLevel("eg_Blood_Pit", 1)
	g_Blood_Sacrifices = true
	g_Blood_Pit = g_Blood_Pit + 1
	UI_HideCount("BloodTab")
	
	Util_SGroupAbilityButton_Remove(g_button_capture_guardsmen)
	
	Rule_Remove(Rule_Sorcerer_Button)
	Rule_Remove(Rule_Capture_Button_Click)
	Rule_Remove(Rule_Captured_Guardsman_Control)
	
	Rule_AddDelay(Rule_Remove_Button_Delayed, 2)
	

	Rule_Remove(Rule_Blood_Tab)		
else 
	
	Util_SetBloodPitLevel("eg_Blood_Pit", i)
	
end

end

function Rule_Remove_Button_Delayed()

Button_Remove(g_button_capture_guardsmen)
Rule_Remove(Rule_Remove_Button_Delayed)

end

function Rule_Set_The_Tab()

UI_ShowCount("BloodTab", g_Player2, 880300, g_Counter )

end

function Rule_Avatar_Warning()

if	Player_AreSquadsNearMarker(g_Player4, "mkr_Eldar_Range") then
local pos = Marker_GetPosition(Marker_FromName("mkr_Vessel", "basic_marker"))

Util_StartNIS(EVENTS.NIS_Avatar)
Util_Summon("sg_Chaos_Sorcerer", pos)


Rule_Add(Rule_Sorcerer_Transformation)
Rule_Remove(Rule_Avatar_Warning)

end

end


--[[ Sorcerer Transformation ]]

function Rule_Sorcerer_Transformation()

local i = 1

if Player_AreSquadsNearMarker(g_Player2, "mkr_Blood_Pit") == true  then
	local sgroupID = SGroup_CreateIfNotFound("sg_Potentials")
		SGroup_Clear(sgroupID)
		Player_GetAllSquadsNearMarker(g_Player2, "sg_Potentials", "mkr_Blood_Pit")
		for y = 1, SGroup_Count(sgroupID) do
			local squadID = SGroup_GetSpawnedSquadAt(sgroupID, y)
			local blueprint = Squad_GetBlueprintName(squadID)
				if blueprint == "chaos_squad_sorcerer" then
					local sgroupID2 = SGroup_CreateIfNotFound("sg_Offering")
					
					SGroup_Add(sgroupID2, squadID)
					local chosen = Squad_Count(SGroup_GetSpawnedSquadAt(sgroupID2, 1))
					
					g_Transform = true

					Rule_AddOneShot(Rule_Begin_Possession, 0)
					Rule_AddInterval(Rule_Sorcerer_Health_Check, 3)
					Player_RestrictSquad(g_Player2, "chaos_squad_sorcerer")
					Rule_Remove(Rule_Sorcerer_Transformation)
				end
	end
end

end

function Rule_Sorcerer_Health_Check()

if SGroup_IsEmpty("sg_Offering") then

	g_Avatar_Kaput = false
	Rule_Remove(Rule_Sorcerer_Health_Check)
end

end

function Rule_Begin_Possession()

Playlist_Manager( PC_Music, t_music_summoning, true, false , {20, 40})

SGroup_SetPlayerOwner("sg_Offering", g_Player6)
Cmd_MoveToMarker("sg_Offering", "mkr_Blood_Pit")
Rule_AddOneShot(Rule_Possess_Sorcerer, 6)

end

function Rule_Possess_Sorcerer()

Cmd_StopSquads("sg_Offering")
UI_ShowCountdown(880301, 150)
Rule_AddOneShot(Rule_Possession_End, 150)
Rule_AddOneShot(Rule_SyncKill_Button, 0)

end

function Rule_Possession_End()

Cmd_Possesion("sg_Offering")
Rule_AddOneShot(Rule_Possession_Transfer, 4)

end

function Rule_Possession_Transfer()

SGroup_SetPlayerOwner("sg_Offering", g_Player2)
Rule_Remove(Rule_Possession_Transfer)
Rule_Add(Rule_Possession_Exit)

end

function Rule_Possession_Exit()

t_Bloodthirster = {chaos_squad_bloodthirster}

if SGroup_Exists("sg_Offering") and SGroup_IsEmpty("sg_Offering") == false and SGroup_ContainsBlueprints(SGroup_FromName("sg_Offering"), t_Bloodthirster, true) then

	SGroup_SetPlayerOwner("sg_Offering", g_Player2)
	Util_SGroupAbilityButton_Add2Manager(g_button_bloodthirster_sync_kill, "sg_Offering")
	Cmd_MoveToMarker("sg_Offering", "mkr_Vessel")
	Rule_Remove(Rule_Possession_Exit)
end

end

function Rule_Eldar_Avatar_Army()

local i = g_Eldar_Avatar_Army_iter 

t_Eldar_Avatar_Army = {
	
	sgroup_name = { --[[1]]"sg_Eldar_Avatar", --[[2]]"sg_Eldar_Avatar_Army1", --[[3]]"sg_Eldar_Avatar_Army2", --[[4]]"sg_Eldar_Avatar_Army3", --[[5]]"sg_Eldar_Avatar_Army4"},  
	
	blueprint = {--[[1]]"eldar_squad_avatar", --[[2]]"eldar_guardian_squad", --[[3]]"eldar_squad_banshees", --[[4]]"eldar_guardian_squad", --[[5]]"eldar_guardian_squad"},
	
	marker_spawn = {--[[1]]"mkr_Avatar_Attack", --[[2]]"mkr_Avatar_Escort1", --[[3]]"mkr_Avatar_Escort2", --[[4]]"mkr_Avatar_Escort3", --[[5]]"mkr_Avatar_Escort4"}, 
	
	attack_target={--[[1]]"mkr_Eldar_Base_Raid_Target1", --[[2]]"mkr_Eldar_Base_Raid_Target1", --[[3]]"mkr_Eldar_Base_Raid_Target1", --[[4]]"mkr_Eldar_Base_Raid_Target1", --[[5]]"mkr_Eldar_Base_Raid_Target1"},
	
	stance = {--[[1]]STANCE_Hold, --[[2]]STANCE_Hold, --[[3]]STANCE_Hold, --[[4]]STANCE_Hold, --[[5]]STANCE_Hold},
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1}, 
	
	squad_size = {--[[1]] 1, --[[2]] 9, --[[3]] 5, --[[4]] 9, --[[5]] 9}, 
}
		
if g_Eldar_Avatar_Army_iter <= table.getn(t_Eldar_Avatar_Army.sgroup_name) and (SGroup_Exists(t_Eldar_Avatar_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Eldar_Avatar_Army.sgroup_name[i])) then

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Eldar_Avatar_Army.sgroup_name[i], t_Eldar_Avatar_Army.blueprint[i], t_Eldar_Avatar_Army.marker_spawn[i], t_Eldar_Avatar_Army.squad_num[i], t_Eldar_Avatar_Army.squad_size[i])
		Cmd_SetStance(t_Eldar_Avatar_Army.sgroup_name[i], t_Eldar_Avatar_Army.stance[i])
		
	elseif g_Eldar_Avatar_Army_iter > table.getn(t_Eldar_Avatar_Army.sgroup_name) then
			g_Eldar_Avatar_Army_iter = 0
		
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army"), SGroup_FromName("sg_Eldar_Avatar_Army1"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army"), SGroup_FromName("sg_Eldar_Avatar_Army2"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army"), SGroup_FromName("sg_Eldar_Avatar_Army3"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army"), SGroup_FromName("sg_Eldar_Avatar_Army4"))
			
			SGroup_SetHealthInvulnerable("sg_Eldar_Avatar", true)
			
			FOW_TagSGroup(g_Player2, SGroup_FromName("sg_Eldar_Avatar"))
			Cmd_AttackMoveMarker("sg_Eldar_Avatar_Army", "mkr_Eldar_Base_Raid_Target1")
			Cmd_AttackMoveMarker("sg_Eldar_Avatar", "mkr_Avatar_Stop1")
			Rule_AddInterval(Rule_Check_Avatar_Presence_Stop1, 1)
			Rule_Remove(Rule_Eldar_Avatar_Army)
		
	end
g_Eldar_Avatar_Army_iter = g_Eldar_Avatar_Army_iter+1

end

function Rule_Check_Avatar_Presence_Stop1() Cmd_MoveToMarker("sg_Eldar_Avatar_Army", "mkr_Eldar_Base_Raid_Target1")

if Prox_AllSquadsNearMarker("sg_Eldar_Avatar", "mkr_Avatar_Stop1") then

	Cmd_StopSquads("sg_Eldar_Avatar")
	Cmd_SetStance("sg_Eldar_Avatar", STANCE_StandGround)
	SGroup_FaceMarker("sg_Eldar_Avatar", "mkr_Avatar_Stop2")
	Rule_AddDelay(Rule_Avatar_Stop1_Army, 40)
	Rule_AddIntervalDelay(Rule_Avatar_Move1,10, 50)
	Rule_AddIntervalDelay(Rule_Check_Avatar_Presence_Stop2, 1, 50)
	Rule_Remove(Rule_Check_Avatar_Presence_Stop1)

end

end

function Rule_Avatar_Stop1_Army()

local i = g_Eldar_Avatar_Stop1_Army_iter 

t_Eldar_Avatar_Stop1_Army = {
	
	sgroup_name = { --[[1]]"sg_Eldar_Avatar_Stop_Army1", --[[2]]"sg_Eldar_Avatar_Stop_Army2", --[[3]]"sg_Eldar_Avatar_Stop_Army3", --[[4]]"sg_Eldar_Avatar_Stop_Army4", --[[5]]"sg_Eldar_Avatar_Stop_Army5"},  
	
	blueprint = {--[[1]]"eldar_guardian_squad", --[[2]]"eldar_guardian_squad", --[[3]]"eldar_squad_banshees", --[[4]]"eldar_squad_dark_reapers", --[[5]]"eldar_guardian_squad"},
	
	marker_spawn = {--[[1]]"mkr_Avatar_Escort1B", --[[2]]"mkr_Avatar_Escort2B", --[[3]]"mkr_Avatar_Escort3B", --[[4]]"mkr_Avatar_Escort4B", --[[5]]"mkr_Avatar_Escort5B"}, 
	
	attack_target={--[[1]]"mkr_Eldar_Base_Raid_Target1", --[[2]]"mkr_Eldar_Base_Raid_Target1", --[[3]]"mkr_Eldar_Base_Raid_Target1", --[[4]]"mkr_Eldar_Base_Raid_Target1", --[[5]]"mkr_Eldar_Base_Raid_Target1"},
	
	stance = {--[[1]]STANCE_Hold, --[[2]]STANCE_Hold, --[[3]]STANCE_Hold, --[[4]]STANCE_Hold, --[[5]]STANCE_Hold},
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1}, 
	
	squad_size = {--[[1]] 9, --[[2]] 9, --[[3]] 4, --[[4]] 5, --[[5]] 9}, 
}
		
if g_Eldar_Avatar_Stop1_Army_iter <= table.getn(t_Eldar_Avatar_Stop1_Army.sgroup_name) and (SGroup_Exists(t_Eldar_Avatar_Stop1_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Eldar_Avatar_Stop1_Army.sgroup_name[i])) then

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Eldar_Avatar_Stop1_Army.sgroup_name[i], t_Eldar_Avatar_Stop1_Army.blueprint[i], t_Eldar_Avatar_Stop1_Army.marker_spawn[i], t_Eldar_Avatar_Stop1_Army.squad_num[i], t_Eldar_Avatar_Stop1_Army.squad_size[i])
		Cmd_SetStance(t_Eldar_Avatar_Stop1_Army.sgroup_name[i], t_Eldar_Avatar_Stop1_Army.stance[i])
		World_FXEventSquad("data:Art/Events/Unit_Upgrade_Morale_FX/Reinforce_Trooper", SGroup_FromName(t_Eldar_Avatar_Stop1_Army.sgroup_name[i]))
	elseif g_Eldar_Avatar_Stop1_Army_iter > table.getn(t_Eldar_Avatar_Stop1_Army.sgroup_name) then
			g_Eldar_Avatar_Stop1_Army_iter = 0
		
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army2"), SGroup_FromName("sg_Eldar_Avatar_Stop_Army1"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army2"), SGroup_FromName("sg_Eldar_Avatar_Stop_Army2"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army2"), SGroup_FromName("sg_Eldar_Avatar_Stop_Army3"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army2"), SGroup_FromName("sg_Eldar_Avatar_Stop_Army4"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army2"), SGroup_FromName("sg_Eldar_Avatar_Stop_Army5"))
			Cmd_AttackMoveMarker("sg_Eldar_Avatar_Army2", "mkr_Eldar_Base_Raid_Target1")
			Rule_Remove(Rule_Avatar_Stop1_Army)
	end
g_Eldar_Avatar_Stop1_Army_iter = g_Eldar_Avatar_Stop1_Army_iter+1

end

function Rule_Avatar_Move1()

Cmd_MoveToMarker("sg_Eldar_Avatar", "mkr_Avatar_Stop2")

end

function Rule_Check_Avatar_Presence_Stop2()

Cmd_MoveToMarker("sg_Eldar_Avatar_Army2", "mkr_Eldar_Base_Raid_Target1")

if Prox_AllSquadsNearMarker("sg_Eldar_Avatar", "mkr_Avatar_Stop2") then

	Rule_Remove(Rule_Avatar_Move1)
	Cmd_StopSquads("sg_Eldar_Avatar")
	Cmd_SetStance("sg_Eldar_Avatar", STANCE_StandGround)
	SGroup_FaceMarker("sg_Eldar_Avatar", "mkr_Fake_Avatar")
	Rule_AddDelay(Rule_Avatar_Stop2_Army, 40)
	Rule_AddIntervalDelay(Rule_Avatar_Move2, 10, 50)
	Rule_AddIntervalDelay(Rule_Check_Avatar_Presence_Stop3, 1, 50)
	Rule_Remove(Rule_Check_Avatar_Presence_Stop2)

end

end

function Rule_Avatar_Stop2_Army()

local i = g_Eldar_Avatar_Stop2_Army_iter 

t_Eldar_Avatar_Stop2_Army = {
	
	sgroup_name = { --[[1]]"sg_Eldar_Avatar_Stop2_Army1", --[[2]]"sg_Eldar_Avatar_Stop2_Army2", --[[3]]"sg_Eldar_Avatar_Stop2_Army3", --[[4]]"sg_Eldar_Avatar_Stop2_Army4", --[[5]]"sg_Eldar_Avatar_Stop2_Army5"},  
	
	blueprint = {--[[1]]"eldar_guardian_squad", --[[2]]"eldar_guardian_squad", --[[3]]"eldar_squad_banshees", --[[4]]"eldar_squad_dark_reapers", --[[5]]"eldar_guardian_squad"},
	
	marker_spawn = {--[[1]]"mkr_Avatar_Escort1C", --[[2]]"mkr_Avatar_Escort2C", --[[3]]"mkr_Avatar_Escort3C", --[[4]]"mkr_Avatar_Escort4C", --[[5]]"mkr_Avatar_Escort5C"}, 
	
	attack_target={--[[1]]"mkr_Eldar_Base_Raid_Target1", --[[2]]"mkr_Eldar_Base_Raid_Target1", --[[3]]"mkr_Eldar_Base_Raid_Target1", --[[4]]"mkr_Eldar_Base_Raid_Target1", --[[5]]"mkr_Eldar_Base_Raid_Target1"},
	
	stance = {--[[1]]STANCE_Attack, --[[2]]STANCE_Attack, --[[3]]STANCE_Attack, --[[4]]STANCE_Attack, --[[5]]STANCE_Attack},
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 2}, 
	
	squad_size = {--[[1]] 9, --[[2]] 9, --[[3]] 9, --[[4]] 5, --[[5]] 9}, 
}
		
if g_Eldar_Avatar_Stop2_Army_iter <= table.getn(t_Eldar_Avatar_Stop2_Army.sgroup_name) and (SGroup_Exists(t_Eldar_Avatar_Stop2_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Eldar_Avatar_Stop2_Army.sgroup_name[i])) then

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Eldar_Avatar_Stop2_Army.sgroup_name[i], t_Eldar_Avatar_Stop2_Army.blueprint[i], t_Eldar_Avatar_Stop2_Army.marker_spawn[i], t_Eldar_Avatar_Stop2_Army.squad_num[i], t_Eldar_Avatar_Stop2_Army.squad_size[i])
		Cmd_SetStance(t_Eldar_Avatar_Stop2_Army.sgroup_name[i], t_Eldar_Avatar_Stop2_Army.stance[i])
		World_FXEventSquad("data:Art/Events/Unit_Upgrade_Morale_FX/Reinforce_Trooper", SGroup_FromName(t_Eldar_Avatar_Stop2_Army.sgroup_name[i]))
	elseif g_Eldar_Avatar_Stop2_Army_iter > table.getn(t_Eldar_Avatar_Stop2_Army.sgroup_name) then
			g_Eldar_Avatar_Stop2_Army_iter = 0
		
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army3"), SGroup_FromName("sg_Eldar_Avatar_Stop2_Army1"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army3"), SGroup_FromName("sg_Eldar_Avatar_Stop2_Army2"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army3"), SGroup_FromName("sg_Eldar_Avatar_Stop2_Army3"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army3"), SGroup_FromName("sg_Eldar_Avatar_Stop2_Army4"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army3"), SGroup_FromName("sg_Eldar_Avatar_Stop2_Army5"))
			Cmd_AttackMoveMarker("sg_Eldar_Avatar_Army3", "mkr_Eldar_Base_Raid_Target1")
			
			Rule_Remove(Rule_Avatar_Stop2_Army)
	end
g_Eldar_Avatar_Stop2_Army_iter = g_Eldar_Avatar_Stop2_Army_iter+1

end

function Rule_Avatar_Move2()

Cmd_MoveToMarker("sg_Eldar_Avatar", "mkr_Avatar_Stop3")

end

function Rule_Check_Avatar_Presence_Stop3() Cmd_MoveToMarker("sg_Eldar_Avatar_Army3", "mkr_Eldar_Base_Raid_Target1")

if Prox_AllSquadsNearMarker("sg_Eldar_Avatar", "mkr_Avatar_Stop3") then

	Rule_Remove(Rule_Avatar_Move2)
	Cmd_StopSquads("sg_Eldar_Avatar")
	Cmd_SetStance("sg_Eldar_Avatar", STANCE_StandGround)
	SGroup_FaceMarker("sg_Eldar_Avatar", "mkr_Avatar_Escort2D")
	Rule_AddDelay(Rule_Avatar_Stop3_Army, 40)
	Rule_AddIntervalDelay(Rule_Avatar_Move3, 10, 50)
	Rule_AddIntervalDelay(Rule_Check_Avatar_Presence_Stop4, 1, 50)
	Rule_Remove(Rule_Check_Avatar_Presence_Stop3)

end

end

function Rule_Avatar_Stop3_Army()

local i = g_Eldar_Avatar_Stop3_Army_iter 

t_Eldar_Avatar_Stop3_Army = {
	
	sgroup_name = { --[[1]]"sg_Eldar_Avatar_Stop3_Army1", --[[2]]"sg_Eldar_Avatar_Stop3_Army2", --[[3]]"sg_Eldar_Avatar_Stop3_Army3", --[[4]]"sg_Eldar_Avatar_Stop3_Army4", --[[5]]"sg_Eldar_Avatar_Stop3_Army5"},  
	
	blueprint = {--[[1]]"eldar_guardian_squad", --[[2]]"eldar_guardian_squad", --[[3]]"eldar_squad_banshees", --[[4]]"eldar_squad_dark_reapers", --[[5]]"eldar_squad_fire_dragon"},
	
	marker_spawn = {--[[1]]"mkr_Avatar_Escort1D", --[[2]]"mkr_Avatar_Escort2D", --[[3]]"mkr_Avatar_Escort3D", --[[4]]"mkr_Avatar_Escort4D", --[[5]]"mkr_Avatar_Escort5D"}, 
	
	attack_target={--[[1]]"mkr_Eldar_Base_Raid_Target1", --[[2]]"mkr_Eldar_Base_Raid_Target1", --[[3]]"mkr_Eldar_Base_Raid_Target1", --[[4]]"mkr_Eldar_Base_Raid_Target1", --[[5]]"mkr_Eldar_Base_Raid_Target1"},
	
	stance = {--[[1]]STANCE_Attack, --[[2]]STANCE_Attack, --[[3]]STANCE_Attack, --[[4]]STANCE_Attack, --[[5]]STANCE_Attack},
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 2}, 
	
	squad_size = {--[[1]] 9, --[[2]] 9, --[[3]] 9, --[[4]] 5, --[[5]] 5}, 
}
		
if g_Eldar_Avatar_Stop3_Army_iter <= table.getn(t_Eldar_Avatar_Stop3_Army.sgroup_name) and (SGroup_Exists(t_Eldar_Avatar_Stop3_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Eldar_Avatar_Stop3_Army.sgroup_name[i])) then

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Eldar_Avatar_Stop3_Army.sgroup_name[i], t_Eldar_Avatar_Stop3_Army.blueprint[i], t_Eldar_Avatar_Stop3_Army.marker_spawn[i], t_Eldar_Avatar_Stop3_Army.squad_num[i], t_Eldar_Avatar_Stop3_Army.squad_size[i])
		Cmd_SetStance(t_Eldar_Avatar_Stop3_Army.sgroup_name[i], t_Eldar_Avatar_Stop3_Army.stance[i])
		World_FXEventSquad("data:Art/Events/Unit_Upgrade_Morale_FX/Reinforce_Trooper", SGroup_FromName(t_Eldar_Avatar_Stop3_Army.sgroup_name[i]))
	elseif g_Eldar_Avatar_Stop3_Army_iter > table.getn(t_Eldar_Avatar_Stop3_Army.sgroup_name) then
			g_Eldar_Avatar_Stop3_Army_iter = 0
		
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army4"), SGroup_FromName("sg_Eldar_Avatar_Stop3_Army1"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army4"), SGroup_FromName("sg_Eldar_Avatar_Stop3_Army2"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army4"), SGroup_FromName("sg_Eldar_Avatar_Stop3_Army3"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army4"), SGroup_FromName("sg_Eldar_Avatar_Stop3_Army4"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army4"), SGroup_FromName("sg_Eldar_Avatar_Stop3_Army5"))
			
			Cmd_AttackMoveMarker("sg_Eldar_Avatar_Army4", "mkr_Eldar_Base_Raid_Target1")
			
			Rule_Remove(Rule_Avatar_Stop3_Army)
	end
g_Eldar_Avatar_Stop3_Army_iter = g_Eldar_Avatar_Stop3_Army_iter+1

end

function Rule_Avatar_Move3()

Cmd_MoveToMarker("sg_Eldar_Avatar", "mkr_Avatar_Stop4")

end

function Rule_Check_Avatar_Presence_Stop4()

Cmd_MoveToMarker("sg_Eldar_Avatar_Army4", "mkr_Eldar_Base_Raid_Target1")

if Prox_AllSquadsNearMarker("sg_Eldar_Avatar", "mkr_Avatar_Stop4") then

	Rule_Remove(Rule_Avatar_Move3)
	Cmd_StopSquads("sg_Eldar_Avatar")
	Cmd_SetStance("sg_Eldar_Avatar", STANCE_StandGround)
	SGroup_FaceMarker("sg_Eldar_Avatar", "mkr_Eldar_Base_Raid_Target1")
	Rule_AddDelay(Rule_Avatar_Stop4_Army, 5)
	Rule_AddOneShot(Rule_Army_Stop4_Buffer, 15)
	Rule_AddIntervalDelay(Rule_Avatar_Move4, 10,  5)
	Rule_Remove(Rule_Check_Avatar_Presence_Stop4)
	
end

end

function Rule_Army_Stop4_Buffer()

Rule_Add(Rule_Avatar_Stop4_Army)

end

function Rule_Avatar_Stop4_Army()

local i = g_Eldar_Avatar_Stop4_Army_iter 

t_Eldar_Avatar_Stop4_Army = {
	
	sgroup_name = { --[[1]]"sg_Eldar_Avatar_Stop4_Army1", --[[2]]"sg_Eldar_Avatar_Stop4_Army2", --[[3]]"sg_Eldar_Avatar_Stop4_Army3", --[[4]]"sg_Eldar_Avatar_Stop4_Army4", --[[5]]"sg_Eldar_Avatar_Stop4_Army5"},  
	
	blueprint = {--[[1]]"eldar_squad_seer_council", --[[2]]"eldar_squad_fire_dragon", --[[3]]"eldar_squad_banshees", --[[4]]"eldar_squad_dark_reapers", --[[5]]"eldar_squad_fire_dragon"},
	
	marker_spawn = {--[[1]]"mkr_Avatar_Escort1E", --[[2]]"mkr_Avatar_Escort2E", --[[3]]"mkr_Avatar_Escort3E", --[[4]]"mkr_Avatar_Escort4E", --[[5]]"mkr_Avatar_Escort5E"}, 
	
	attack_target={--[[1]]"mkr_Eldar_Base_Raid_Target1", --[[2]]"mkr_Eldar_Base_Raid_Target1", --[[3]]"mkr_Eldar_Base_Raid_Target1", --[[4]]"mkr_Eldar_Base_Raid_Target1", --[[5]]"mkr_Eldar_Base_Raid_Target1"},
	
	stance = {--[[1]]STANCE_Attack, --[[2]]STANCE_Attack, --[[3]]STANCE_Attack, --[[4]]STANCE_Attack, --[[5]]STANCE_Attack},
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 2}, 
	
	squad_size = {--[[1]] 7, --[[2]] 5, --[[3]] 7, --[[4]] 5, --[[5]] 5}, 
}
		
if g_Eldar_Avatar_Stop4_Army_iter <= table.getn(t_Eldar_Avatar_Stop4_Army.sgroup_name) and (SGroup_Exists(t_Eldar_Avatar_Stop4_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Eldar_Avatar_Stop4_Army.sgroup_name[i])) then

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Eldar_Avatar_Stop4_Army.sgroup_name[i], t_Eldar_Avatar_Stop4_Army.blueprint[i], t_Eldar_Avatar_Stop4_Army.marker_spawn[i], t_Eldar_Avatar_Stop4_Army.squad_num[i], t_Eldar_Avatar_Stop4_Army.squad_size[i])
		Cmd_SetStance(t_Eldar_Avatar_Stop4_Army.sgroup_name[i], t_Eldar_Avatar_Stop4_Army.stance[i])
		World_FXEventSquad("data:Art/Events/Unit_Upgrade_Morale_FX/Reinforce_Trooper", SGroup_FromName(t_Eldar_Avatar_Stop4_Army.sgroup_name[i]))
	elseif g_Eldar_Avatar_Stop4_Army_iter > table.getn(t_Eldar_Avatar_Stop4_Army.sgroup_name) then
			g_Eldar_Avatar_Stop4_Army_iter = 0
			
			
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army5"), SGroup_FromName("sg_Eldar_Avatar_Stop4_Army1"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army5"), SGroup_FromName("sg_Eldar_Avatar_Stop4_Army2"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army5"), SGroup_FromName("sg_Eldar_Avatar_Stop4_Army3"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army5"), SGroup_FromName("sg_Eldar_Avatar_Stop4_Army4"))
			SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Avatar_Army5"), SGroup_FromName("sg_Eldar_Avatar_Stop4_Army5"))
		
		Cmd_MoveToMarker("sg_Eldar_Avatar_Army5", "mkr_Eldar_Base_Raid_Target1")
		Rule_Remove(Rule_Avatar_Stop4_Army)
	end
g_Eldar_Avatar_Stop4_Army_iter = g_Eldar_Avatar_Stop4_Army_iter+1

end

function Rule_Avatar_Move4()

Cmd_SetStance("sg_Eldar_Avatar", STANCE_StandGround)
Cmd_MoveToMarker("sg_Eldar_Avatar", "mkr_Eldar_Base_Raid_Target1")

end

function Rule_Temp_Moment()

Util_StartNIS(EVENTS.NIS_Moment)

end


--[[ Eldar Base Raids ]]

--[[ - the timer for this trigger is added at the end of the player chaos creation.]]

function Rule_Trigger_Eldar_Raid()

t_HQ_Table = {
{name = "chaos_hq", count = 1}
}
Rule_Add(Rule_Eldar_Base_Raid_Army_Creation)
local EgroupID = Player_GetEntities(g_Player2)
local Count = EGroup_Count(EgroupID)
for i = 1, Count do
	local Indexed= EGroup_GetSpawnedEntityAt(EgroupID, i)
	EGroup_Add(EGroup_CreateIfNotFound("eg_Chaos_Temp"..i), Indexed)
	if EGroup_ContainsBlueprints(EGroup_FromName("eg_Chaos_Temp"..i), t_HQ_Table, true) then
		HQposition = EGroup_GetPosition(EGroup_FromName("eg_Chaos_Temp"..i))
	end
	EGroup_Clear(EGroup_FromName("eg_Chaos_Temp"..i))
end	

end

function Rule_Eldar_Base_Raid_Army_Creation()

local i = g_Eldar_Base_Raid_Army_iter 

t_Eldar_Base_Raid_Army = {
	
	sgroup_name = { --[[1]]"sg_Eldar_Base_Raid1", --[[2]]"sg_Eldar_Base_Raid2", --[[3]]"sg_Eldar_Base_Raid3"},  
	
	blueprint = {--[[1]]"eldar_squad_fire_dragon", --[[2]]"eldar_guardian_squad", --[[3]]"eldar_squad_banshees"},
	
	marker_spawn = {--[[1]]"mkr_Eldar_Base_Raid1", --[[2]]"mkr_Eldar_Base_Raid2", --[[3]]"mkr_Eldar_Base_Raid3", --[[4]]"mkr_Eldar_Base_Raid4", --[[5]]"mkr_Eldar_Base_Raid5", --[[6]]"mkr_Eldar_Base_Raid6"}, 
	
	raid_target={--[[1]]"mkr_Eldar_Base_Raid_Target1"},
	
	stance = {--[[1]]STANCE_Burn, --[[2]]STANCE_Burn, --[[3]]STANCE_Burn},
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1}, 
	
	squad_size = {--[[1]] 7, --[[2]] 7, --[[3]] 7}, 
}
		
if g_Eldar_Base_Raid_Army_iter <= table.getn(t_Eldar_Base_Raid_Army.sgroup_name) and (SGroup_Exists(t_Eldar_Base_Raid_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Eldar_Base_Raid_Army.sgroup_name[i])) then

	local j = World_GetRand(1, table.getn(t_Eldar_Base_Raid_Army.marker_spawn))
	local randomsize = World_GetRand(3, 10)
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Eldar_Base_Raid_Army.sgroup_name[i], t_Eldar_Base_Raid_Army.blueprint[i], t_Eldar_Base_Raid_Army.marker_spawn[j], t_Eldar_Base_Raid_Army.squad_num[i], randomsize)
		World_FXEventSquad("data:Art/Events/Unit_Upgrade_Morale_FX/Reinforce_Trooper", SGroup_FromName(t_Eldar_Base_Raid_Army.sgroup_name[i]))
		Cmd_SetStance(t_Eldar_Base_Raid_Army.sgroup_name[i], t_Eldar_Base_Raid_Army.stance[i])
		
	elseif g_Eldar_Base_Raid_Army_iter > table.getn(t_Eldar_Base_Raid_Army.sgroup_name) then
			g_Eldar_Base_Raid_Army_iter = 0
			

			Cmd_AttackMovePos(t_Eldar_Base_Raid_Army.sgroup_name[1], HQposition)
			Cmd_AttackMovePos(t_Eldar_Base_Raid_Army.sgroup_name[2], HQposition)
			Cmd_AttackMovePos(t_Eldar_Base_Raid_Army.sgroup_name[3], HQposition)
			
			Util_StartIntel(EVENTS.IE_Incoming_Eldar_Raid)
			Rule_Remove(Rule_Eldar_Base_Raid_Army_Creation)
		
	end
g_Eldar_Base_Raid_Army_iter = g_Eldar_Base_Raid_Army_iter+1

end


--[[ Emergency Guard creator ]]

function Rule_Imperial_Guard_EmergencyTrack()

--[[ table of markers to be used as the seed locations for the random drop sites ]]
local table1 = {"mkr_ig_rally1", "mkr_ig_rally2", "mkr_ig_rally3", "mkr_ig_rally4"}

--[[ list of criteria before a drop is called ]]
if SGroup_IsEmpty("sg_Guardsmen_Total") and g_onitsway ~= true 
and ( SGroup_Exists("sg_ig_dropship") == false or SGroup_IsEmpty("sg_ig_dropship") ) 
and ( SGroup_Exists("sg_emergency_defender") == false or SGroup_IsEmpty("sg_emergency_defender") ) then
	
	--[[ grab a random marker, translate into a pos and get a random pos based on that ]]
	local rand1 = World_GetRand(1, table.getn(table1))
	local randx = World_GetRand(-30, 30)
	local randz = World_GetRand(-30, 30)
	local pos = Marker_GetPosition(Marker_FromName(table1[rand1], "basic_marker"))
	pos.x = pos.x+randx
	pos.z = pos.z+randz
	g_droppos = pos
	
	g_onitsway = true
	--[[ call the drop a variable number of seconds from now ]]
	local rand2 = World_GetRand(10, 35)
	Rule_AddOneShot(Rule_IG_EmergencyDrop_Land, rand2)
	
end

end

--[[ the drop ship comes in ]] function Rule_IG_EmergencyDrop_Land()

--[[ create the drop ship ]]
local sgroupID  = Util_CreateSquadsAtPosition(g_Player3, "sg_ig_dropship", "npc_valkyrie", g_droppos, 1)
Anim_PlaySGroupAnim(sgroupID, "sp_land")
SGroup_SetHealthInvulnerable("sg_ig_dropship", true)

--[[ reveal and ping the location ]]
FOW_RevealArea(g_droppos.x, g_droppos.z, 20, 45)
Util_Ping_LoopingPos("png_emergency", g_droppos)

g_onitsway = false
Rule_AddOneShot(Rule_IG_EmergencyDrop_Deploy, 10)

end

--[[ generate some guardsmen ]] function Rule_IG_EmergencyDrop_Deploy()

for i = 1, 3 do
	local rand = World_GetRand(4, 8)
	local sgroupID = Util_CreateSquadsAtPositionEx(g_Player3, "sg_emergency_defender", "guard_squad_guardsmen", g_droppos, 1, rand)
	
end

Rule_AddOneShot(Rule_IG_EmergencyDrop_TakeOff, 15)

end

--[[ drop ship takes off ]] function Rule_IG_EmergencyDrop_TakeOff()

Anim_PlaySGroupAnim(SGroup_FromName("sg_ig_dropship"), "sp_take_off")

Rule_AddOneShot(Rule_IG_EmergencyDrop_Remove, 10)

end

--[[ clean up ]] function Rule_IG_EmergencyDrop_Remove()

Util_Ping_Stop("png_emergency")
SGroup_DeSpawn("sg_ig_dropship")
SGroup_DestroyAllSquads("sg_ig_dropship")

end


--[[ Closing Nis Eldar Warriors ]]

function Rule_Closing_Nis_Army()

local i = g_Closing_Nis_Army_iter 

t_Closing_Nis_Army = {
	
	sgroup_name = { --[[1]]"sg_Actor_Victims2", --[[2]]"sg_Actor_Victims"},  
	
	blueprint = {--[[1]]"eldar_squad_banshees", --[[2]]"eldar_guardian_squad"},
	
	marker_spawn = {--[[1]]"mkr_Blood_Victim2", --[[2]]"mkr_Blood_Victim1"}, 
				
	stance = {--[[1]]STANCE_Attack, --[[2]]STANCE_Attack},
	
	mstance = {--[[1]] MSTANCE_Assault, --[[2]] MSTANCE_Assault},
	
	squad_num = {--[[1]] 1, --[[2]] 1}, 
	
	squad_size = {--[[1]] 9, --[[2]] 9}, 
}
		
if g_Closing_Nis_Army_iter <= table.getn(t_Closing_Nis_Army.sgroup_name) and (SGroup_Exists(t_Closing_Nis_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Closing_Nis_Army.sgroup_name[i])) then

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Closing_Nis_Army.sgroup_name[i], t_Closing_Nis_Army.blueprint[i], t_Closing_Nis_Army.marker_spawn[i], t_Closing_Nis_Army.squad_num[i], t_Closing_Nis_Army.squad_size[i])
		World_FXEventSquad("data:Art/Events/Unit_Upgrade_Morale_FX/Reinforce_Trooper", SGroup_FromName(t_Closing_Nis_Army.sgroup_name[i]))
		Cmd_SetStance(t_Closing_Nis_Army.sgroup_name[i], t_Closing_Nis_Army.stance[i])
		Cmd_SetMeleeStance(t_Closing_Nis_Army.sgroup_name[i], t_Closing_Nis_Army.mstance[i])
		Cmd_AttackSGroup(t_Closing_Nis_Army.sgroup_name[i], "sg_Actor_Blood")
		
	elseif g_Closing_Nis_Army_iter > table.getn(t_Closing_Nis_Army.sgroup_name) then
			g_Closing_Nis_Army_iter = 0
						
	end
g_Closing_Nis_Army_iter = g_Closing_Nis_Army_iter+1

end


--[[ Sorcerer Mind Control ]]

--[[ - this is the mechanic that will force the player to have a sorcerer within a certain distance of the captured guardsmen. If the sorcerer dies or he gets too far from the guardsmen the player will lose his control over them. ]]

function Rule_Sorcerer_Mind_Control()

for n = 1,8 do
	if SGroup_Exists("sg_Captured"..n ) == true and  SGroup_IsEmpty("sg_Captured"..n ) == false then
		local pos = SGroup_GetPosition("sg_Chaos_Sorcerer")
		if World_DistanceSGroupToPoint(SGroup_FromName("sg_Captured" ..n ), pos, true) >= 30  then
			SGroup_SetPlayerOwner("sg_Captured" ..n, g_Player3)
			
		end
	end

end

end


--[[ GAME OVER - Player Wins ]]

function Rule_EndGameWin()

if Objective_Exists(Objective_Name.title_id) and Objective_GetState(Objective_Name.title_id) == OS_Complete then
	Rule_RemoveAll()
	Util_Start(EVENTS.NIS_Closing)
end

end

function Rule_Closing()

Rule_RemoveAll()
Util_StartNIS(EVENTS.NIS_Closing)

end

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


--[[ OBJECTIVES ]]


--[[ Kill Sturnn ]]

function Rule_Objective_Kill_Sturnn()

Objective_Kill_Sturnn = { title_id = 881000, short_desc_id = 881001, help_tip_id = 881002 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Kill_Sturnn.title_id) == false then
	
	Util_WXP_ObjectiveCreate(Objective_Kill_Sturnn, true, g_Player1)
	Rule_AddOneShot(Rule_Objective_Kill_Sturnn_Ping, 0)
	g_kill_Sturnn = nil
	
	g_objpng_killsturnnID = Objective_PingMarker(Objective_Kill_Sturnn.title_id, "mkr_Sturnn_Combat", true, "attack")
	
elseif Event_IsAnyRunning() == false and g_kill_Sturnn == true  then
	
	Util_ObjectiveComplete(Objective_Kill_Sturnn.title_id)
	Rule_AddOneShot(Rule_Objective_Kill_Sturnn_Complete, 0)
	
	Objective_PingRemove(Objective_Kill_Sturnn.title_id, g_objpng_killsturnnID)
	
	Rule_Remove(Rule_Objective_Kill_Sturnn)
	
elseif Event_IsAnyRunning() == false and g_kill_Sturnn == false then
	
	Util_ObjectiveFail(Objective_Kill_Sturnn.title_id)
	Rule_AddOneShot(Rule_Objective_Kill_Sturnn_Failed, 0)
	Rule_Remove(Rule_Objective_Kill_Sturnn)
	
	Objective_PingRemove(Objective_Kill_Sturnn.title_id, g_objpng_killsturnnID)
	
end

end

function Rule_Objective_Kill_Sturnn_Ping()

Util_Ping_LoopingMkr("pg_Captain_Sturnn", "mkr_Sturnn_Combat")
Rule_AddInterval(Rule_Gorgutz_Track, 4)

end

function Rule_Objective_Kill_Sturnn_Complete()

Util_Ping_Stop("pg_Captain_Sturnn")
Util_StartNIS(EVENTS.NIS_Twist)
			
SGroup_DeSpawn("sg_Orks")
SGroup_DeSpawn("sg_Sturnn_Command")
SGroup_DestroyAllSquads("sg_Sturnn_Command")
SGroup_DestroyAllSquads("sg_Orks")

end

function Rule_Objective_Kill_Sturnn_Failed()

Util_Ping_Stop("pg_Captain_Sturnn")
Rule_RemoveAll()
Fade_Start(4, false)
World_SetTeamWin( g_enemy, "" )
Rule_AddIntervalEx( Rule_GameOver,5,1 )

end


--[[ Fortify position ]]

--[[ - this is the objective for the chaos player to capture four strategic points]] function Rule_Fortify_Position()

Objective_Fortify_Position = { title_id = 881006, short_desc_id = 881007, help_tip_id = 881008 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Fortify_Position.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate( Objective_Fortify_Position, 881009 )
	Rule_AddOneShot(Rule_Ping_Fortify_Strat_Points, 0)
	
	t_fortifypings = {}
	for i = 1, 4 do
		t_fortifypings[i] = Objective_PingMarker(Objective_Fortify_Position.title_id, "mkr_Fortify_Strat_Point"..i, true, "default")
	end
	
	g_Fortify_Position = 0
	
elseif Event_IsAnyRunning() == false and g_Fortify_Position == 4  then
	
	Util_ObjectiveComplete(Objective_Fortify_Position.title_id)
	Rule_AddInterval(Rule_Objective_Build_Turret, 1)
	Rule_AddInterval(Rule_Objective_Build_Machine_Pit, 1)
	g_Secure_Blood = g_Secure_Blood + 1
	Rule_Remove(Rule_Fortify_Position)
	
	for i = 1, 4 do
		Objective_PingRemove(Objective_Fortify_Position.title_id, t_fortifypings[i])
	end
	
end

end

function Rule_Ping_Fortify_Strat_Points()

Util_Ping_LoopingMkr("Fortify Point1", "mkr_Fortify_Strat_Point1")
Util_Ping_LoopingMkr("Fortify Point2", "mkr_Fortify_Strat_Point2")
Util_Ping_LoopingMkr("Fortify Point3", "mkr_Fortify_Strat_Point3")
Util_Ping_LoopingMkr("Fortify Point4", "mkr_Fortify_Strat_Point4")
Rule_AddInterval(Rule_Check_Ownership_Fortify_Point1, 2)
Rule_AddInterval(Rule_Check_Ownership_Fortify_Point2, 2)
Rule_AddInterval(Rule_Check_Ownership_Fortify_Point3, 2)
Rule_AddInterval(Rule_Check_Ownership_Fortify_Point4, 2)

Rule_Remove(Rule_Ping_Fortify_Strat_Points)

end

function Rule_Check_Ownership_Fortify_Point1()

Player_GetAllEntitiesNearMarker(g_Player2, "eg_Strat_Listening1", "mkr_Fortify_Strat_Point1")
local j = EGroup_Count(EGroup_FromName("eg_Strat_Listening1"))

for i = 1, j do

	if Player_OwnsEGroup(g_Player2, EGroup_FromName("eg_Strat_Fortify1")) and Entity_IsBuilding(EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_Strat_Listening1"), i)) ==  true and
	Entity_GetBuildingProgress(EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_Strat_Listening1"), i)) == 1 then
		
		Util_Ping_Stop("Fortify Point1")
		g_Fortify_Position =g_Fortify_Position +1
		Rule_Remove(Rule_Check_Ownership_Fortify_Point1)
	
	end
end

end

function Rule_Check_Ownership_Fortify_Point2()

Player_GetAllEntitiesNearMarker(g_Player2, "eg_Strat_Listening2", "mkr_Fortify_Strat_Point2")
local j = EGroup_Count(EGroup_FromName("eg_Strat_Listening2"))

for i = 1, j do

	if Player_OwnsEGroup(g_Player2, EGroup_FromName("eg_Strat_Fortify2")) and Entity_IsBuilding(EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_Strat_Listening2"), i)) ==  true and
	Entity_GetBuildingProgress(EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_Strat_Listening2"), i)) == 1 then
		
		Util_Ping_Stop("Fortify Point2")
		g_Fortify_Position =g_Fortify_Position +1
		Rule_Remove(Rule_Check_Ownership_Fortify_Point2)
	
	end
end

end

function Rule_Check_Ownership_Fortify_Point3()

Player_GetAllEntitiesNearMarker(g_Player2, "eg_Strat_Listening3", "mkr_Fortify_Strat_Point3")
local j = EGroup_Count(EGroup_FromName("eg_Strat_Listening3"))

for i = 1, j do

	if Player_OwnsEGroup(g_Player2, EGroup_FromName("eg_Strat_Fortify3")) and Entity_IsBuilding(EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_Strat_Listening3"), i)) ==  true and
	Entity_GetBuildingProgress(EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_Strat_Listening3"), i)) == 1 then
		
		Util_Ping_Stop("Fortify Point3")
		g_Fortify_Position =g_Fortify_Position +1
		Rule_Remove(Rule_Check_Ownership_Fortify_Point3)
	
	end
end

end

function Rule_Check_Ownership_Fortify_Point4()

Player_GetAllEntitiesNearMarker(g_Player2, "eg_Strat_Listening4", "mkr_Fortify_Strat_Point4")
local j = EGroup_Count(EGroup_FromName("eg_Strat_Listening4"))

for i = 1, j do

	if Player_OwnsEGroup(g_Player2, EGroup_FromName("eg_Strat_Fortify4")) and Entity_IsBuilding(EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_Strat_Listening4"), i)) ==  true and
	Entity_GetBuildingProgress(EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_Strat_Listening4"), i)) == 1 then
		
		Util_Ping_Stop("Fortify Point4")
		g_Fortify_Position =g_Fortify_Position +1
		Rule_Remove(Rule_Check_Ownership_Fortify_Point4)
	
	end
end

end


--[[ Blood Sacrifices ]]

function Rule_Objective_Blood_Sacrifices()

Objective_Blood_Sacrifices = { title_id = 881003, short_desc_id = 881004, help_tip_id = 881005 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Blood_Sacrifices.title_id) == false then
	
	Util_ObjectiveCreate(Objective_Blood_Sacrifices, true)
	Rule_AddOneShot(Rule_Objective_Blood_Sacrifices_Ping, 0)
	g_Blood_Sacrifices = nil
	
	t_sacrificepings = {}
	for i = 1, 8 do
		t_sacrificepings[i] = Objective_PingMarker(Objective_Blood_Sacrifices.title_id, "mkr_Capture_Flag"..i, true, "default")
	end
	
elseif Event_IsAnyRunning() == false and g_Blood_Sacrifices == true  then
	
	Util_ObjectiveComplete(Objective_Blood_Sacrifices.title_id)
	Rule_AddOneShot(Rule_Objective_Blood_Sacrifices_Complete, 0)
	
	for i = 1, 8 do
		Objective_PingRemove(Objective_Blood_Sacrifices.title_id, t_sacrificepings[i])
	end
	
	Rule_Remove(Rule_Objective_Blood_Sacrifices)
	
elseif Event_IsAnyRunning() == false and g_Blood_Sacrifices == false then
	
	Util_ObjectiveFail(Objective_Blood_Sacrifices.title_id)
	Rule_AddOneShot(Rule_Objective_Blood_Sacrifices_Failed, 0)
	Rule_Remove(Rule_Objective_Blood_Sacrifices)
	
	for i = 1, 8 do
		Objective_PingRemove(Objective_Blood_Sacrifices.title_id, t_sacrificepings[i])
	end
	
end

end

--[[ - the pings will be stopped individually as each source of captured guardsmen taries]]

function Rule_Objective_Blood_Sacrifices_Ping()

Util_Ping_LoopingMkr("pg_Sacrifice_Mechanize1", "mkr_Capture_Flag1")
Util_Ping_LoopingMkr("pg_Sacrifice_Mechanize2", "mkr_Capture_Flag2")
Util_Ping_LoopingMkr("pg_Sacrifice_Lawlessness1", "mkr_Capture_Flag3")
Util_Ping_LoopingMkr("pg_Sacrifice_Lawlessness2", "mkr_Capture_Flag4")
Util_Ping_LoopingMkr("pg_Sacrifice_Psyker1", "mkr_Capture_Flag5")
Util_Ping_LoopingMkr("pg_Sacrifice_Psyker2", "mkr_Capture_Flag6")
Util_Ping_LoopingMkr("pg_Sacrifice_Support1", "mkr_Capture_Flag7")
Util_Ping_LoopingMkr("pg_Sacrifice_Support2", "mkr_Capture_Flag8")

end

function Rule_Objective_Blood_Sacrifices_Complete()

Rule_Remove(Rule_Set_Up_Ork_Buildings)
Rule_Remove(Rule_Ork_Patrol_P1)
Rule_Remove(Rule_Ork_Patrol_P2)
Rule_Remove(Rule_Ork_Patrol_P3)
Rule_Remove(Rule_Begin_Construction)
Rule_Remove(Rule_Check_Sorcerer_Death)
SGroup_DeSpawn("sg_Ork_AI_Army")
EGroup_DeSpawn("eg_ork_build1")
EGroup_DeSpawn("eg_ork_build2")	
EGroup_DeSpawn("eg_ork_build7")		
	

Rule_Add(Rule_Eldar_Avatar_Army)			
	

Rule_Remove(Rule_Sorcerer_Mind_Control)
	

--[[ creates a chaos scouting unit to have a tidy way of warning the player to the upcoming danger]]
Util_CreateSquadsAtMarkerEx(g_Player2, "sg_Chaos_Scout", "chaos_marine_squad", "mkr_Chaos_Scout", 1, 5)
Cmd_SetStance("sg_Chaos_Scout", STANCE_Attack)
SGroup_SetAvgHealth("sg_Chaos_Scout", 0.2)
	
Rule_Add(Rule_Avatar_Warning)			

end

function Rule_Objective_Blood_Sacrifices_Failed()

Util_Ping_Stop("pg_Sacrifice_Mechanize1")
Util_Ping_Stop("pg_Sacrifice_Mechanize2")
Util_Ping_Stop("pg_Sacrifice_Lawlessness1")
Util_Ping_Stop("pg_Sacrifice_Lawlessness2")
Util_Ping_Stop("pg_Sacrifice_Psyker1")
Util_Ping_Stop("pg_Sacrifice_Psyker2")
Util_Ping_Stop("pg_Sacrifice_Support1")
Util_Ping_Stop("pg_Sacrifice_Support2")

Rule_RemoveAll()
Fade_Start(4, false)
World_SetTeamWin( g_enemy, "" )
Rule_AddIntervalEx( Rule_GameOver,5,1 )

end


--[[ Objective secure the blood pit ]]

function Rule_Objective_Secure_Blood_Pit()

Objective_Secure_Blood_Pit = { title_id = 881009, short_desc_id = 881010, help_tip_id = 881011 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Secure_Blood_Pit.title_id) == false then
	
	Util_WXP_ObjectiveCreate(Objective_Secure_Blood_Pit, true, g_Player2)
	Rule_AddIntervalDelay(Rule_Objective_Explore_Imperial_Base, 1, 120)
		
	Rule_AddInterval(Rule_Fortify_Position, 1)
elseif Event_IsAnyRunning() == false and g_Secure_Blood == 3  then
	
	Util_ObjectiveComplete(Objective_Secure_Blood_Pit.title_id)
	Rule_Add(Rule_Autosave_Blood_Pit_Secured)
	Rule_Remove(Rule_Objective_Secure_Blood_Pit)
		
end

end


--[[ Objective Build a turret ]]

function Rule_Objective_Build_Turret()

Objective_Build_Turret = { title_id = 881012, short_desc_id = 881013, help_tip_id = 881014 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Build_Turret.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate( Objective_Build_Turret, 881009 )
	
elseif Event_IsAnyRunning() == false and Player_HasBuildingType(g_Player2, "chaos_turret_bolter")  then
	
	Util_ObjectiveComplete(Objective_Build_Turret.title_id)
	g_Secure_Blood = g_Secure_Blood + 1
	Rule_Remove(Rule_Objective_Build_Turret)
		
end

end


--[[ Objective Build a machine pit ]]

function Rule_Objective_Build_Machine_Pit()

Objective_Build_Machine_Pit = { title_id = 881015, short_desc_id = 881016, help_tip_id = 881017 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Build_Machine_Pit.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate( Objective_Build_Machine_Pit, 881009 )
	
elseif Event_IsAnyRunning() == false and Player_HasBuildingType(g_Player2, "chaos_machine_pit")  then
	
	Util_ObjectiveComplete(Objective_Build_Machine_Pit.title_id)
	g_Secure_Blood = g_Secure_Blood + 1
	Rule_Remove(Rule_Objective_Build_Machine_Pit)
		
end

end


--[[ Objective Fill Blood pit ]]

function Rule_Objective_Fill_Blood_Pit()

Objective_Fill_Blood_Pit = { title_id = 881018, short_desc_id = 881019, help_tip_id = 881020 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Fill_Blood_Pit.title_id) == false then
	
	Util_WXP_ObjectiveCreate(Objective_Fill_Blood_Pit, true, g_Player2)
	Rule_AddInterval(Rule_Objective_Capture_Guardsmen, 1)
	
elseif Event_IsAnyRunning() == false and g_Blood_Pit >= 3  then
	
	Util_ObjectiveComplete(Objective_Fill_Blood_Pit.title_id)
	Rule_Add(Rule_Autosave_Blood_Pit_Filled)
	Rule_AddOneShot(Rule_Objective_Blood_Sacrifices_Complete, 0)
	Rule_Remove(Rule_Objective_Fill_Blood_Pit)
		
end

end


--[[ Objective Explore Imperial base ]]

function Rule_Objective_Explore_Imperial_Base()

Objective_Explore_Imperial_Base = { title_id = 881024, short_desc_id = 881025, help_tip_id = 881026 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Explore_Imperial_Base.title_id) == false then
	
	Util_WXP_ObjectiveCreate(Objective_Explore_Imperial_Base, true, g_Player2)
	Util_Ping_LoopingMkr("pg_Psyker_Ping", "mkr_Psyker_Ping")	
	Util_StartIntel(EVENTS.IE_Explore_Base)
	Rule_AddOneShot(Rule_Infiltration_Advice, 120)
	
	g_objpng_exploreID = Objective_PingMarker(Objective_Explore_Imperial_Base.title_id, "mkr_Psyker_Ping", true, "default")
	
elseif Event_IsAnyRunning() == false and Player_AreSquadsNearMarker(g_Player2, "mkr_Explore3") then
	
	Rule_AddOneShot(Rule_Psyker_Ping_Remove, 1)
	
	Util_ObjectiveComplete(Objective_Explore_Imperial_Base.title_id)
	Rule_AddInterval(Rule_Objective_Fill_Blood_Pit, 1)
	
	Objective_PingRemove(Objective_Explore_Imperial_Base.title_id, g_objpng_exploreID)
	
	Rule_Remove(Rule_Objective_Explore_Imperial_Base)
	
end

end

function Rule_Psyker_Ping_Remove()

Util_Ping_Stop("pg_Psyker_Ping")

end

--[[ Objective Capture Guardsmen ]]

function Rule_Objective_Capture_Guardsmen()

Objective_Capture_Guardsmen = { title_id = 881027, short_desc_id = 881028, help_tip_id = 881029 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Capture_Guardsmen.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate( Objective_Capture_Guardsmen, 881018 )
	Rule_AddOneShot(Rule_Ping_Support, 1)
	Rule_AddOneShot(Rule_Capture_Button, 0)
	Rule_AddDelay(Rule_Sorcerer_Button, 5)

-- Rule_Remove(Rule_Pre_Button_Group)

	g_objpng_capture1ID = Objective_PingMarker(Objective_Capture_Guardsmen.title_id, "mkr_Support_Ping", true, "default")
	g_objpng_capture2ID = Objective_PingMarker(Objective_Capture_Guardsmen.title_id, "mkr_Lawlessness_Ping", true, "default")
	g_objpng_capture3ID = Objective_PingMarker(Objective_Capture_Guardsmen.title_id, "mkr_Vehicle_Ping", true, "default")
	
elseif Event_IsAnyRunning() == false and g_captured == true  then
	
	Util_ObjectiveComplete(Objective_Capture_Guardsmen.title_id)
	Rule_AddInterval(Rule_Objective_Sacrifice_Guardsmen, 1)
	Rule_AddOneShot(Rule_Set_The_Tab, 0)
	g_Blood_Pit =g_Blood_Pit +1
	Rule_Remove(Rule_Objective_Capture_Guardsmen)
	
	Objective_PingRemove(Objective_Capture_Guardsmen.title_id, g_objpng_capture1ID)
	Objective_PingRemove(Objective_Capture_Guardsmen.title_id, g_objpng_capture2ID)
	Objective_PingRemove(Objective_Capture_Guardsmen.title_id, g_objpng_capture3ID)
	
end

end

function Rule_Ping_Support()

Util_Ping_LoopingMkr("pg_Support", "mkr_Support_Ping")
Rule_AddOneShot(Rule_Ping_Support_End, 8)

end

function Rule_Ping_Support_End()

Util_Ping_Stop("pg_Support")
Rule_AddOneShot(Rule_Ping_Lawlessness, 1)

end

function Rule_Ping_Lawlessness()

Util_Ping_LoopingMkr("pg_Lawlessness", "mkr_Lawlessness_Ping")
Rule_AddOneShot(Rule_Ping_Lawlessness_End, 8)

end

function Rule_Ping_Lawlessness_End()

Util_Ping_Stop("pg_Lawlessness")
Rule_AddOneShot(Rule_Ping_Vehicle, 1)

end

function Rule_Ping_Vehicle()

Util_Ping_LoopingMkr("pg_Vehicle", "mkr_Vehicle_Ping")
Rule_AddOneShot(Rule_Ping_Vehicle_End, 8)

end

function Rule_Ping_Vehicle_End()

Util_Ping_Stop("pg_Vehicle")

end


--[[ Objective Sacrifice Guardsmen ]]

function Rule_Objective_Sacrifice_Guardsmen()

Objective_Sacrifice_Guardsmen = { title_id = 881030, short_desc_id = 881031, help_tip_id = 881032 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Sacrifice_Guardsmen.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate( Objective_Sacrifice_Guardsmen, 881018 )
	
elseif Event_IsAnyRunning() == false and g_First_Blood == true  then
	
	Util_ObjectiveComplete(Objective_Sacrifice_Guardsmen.title_id)
	g_Blood_Pit = g_Blood_Pit +1
	Rule_Remove(Rule_Objective_Sacrifice_Guardsmen)
		
end

end


--[[ Objective Destroy Avatar ]]

function Rule_Objective_Destroy_Avatar()

Objective_Destroy_Avatar = { title_id = 881033, short_desc_id = 881034, help_tip_id = 881035 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Destroy_Avatar.title_id) == false then
	
	Util_WXP_ObjectiveCreate(Objective_Destroy_Avatar, true, g_Player2)
	Rule_AddInterval(Rule_Objective_Possess_Sorcerer, 1)
elseif Event_IsAnyRunning() == false and g_Avatar == 2  then
	
	Util_ObjectiveComplete(Objective_Destroy_Avatar.title_id)

	Rule_Remove(Rule_Objective_Destroy_Avatar)
		
end

end


--[[ Objective Possess your sorcerer ]]

function Rule_Objective_Possess_Sorcerer()

Objective_Possess_Sorcerer = { title_id = 881036, short_desc_id = 881037, help_tip_id = 881038 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Possess_Sorcerer.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate( Objective_Possess_Sorcerer, 881033 )
	
elseif Event_IsAnyRunning() == false and g_Transform == true  then
	
	Util_ObjectiveComplete(Objective_Possess_Sorcerer.title_id)
	g_Avatar = g_Avatar +1
	Rule_AddInterval(Rule_Objective_Kill_Avatar, 1)
	Rule_Add(Rule_Autosave_Kill_Avatar)
	Rule_Remove(Rule_Objective_Possess_Sorcerer)
		
end

end


--[[ Objective Kill Avatar ]]

function Rule_Objective_Kill_Avatar()

Objective_Kill_Avatar = { title_id = 881039, short_desc_id = 881040, help_tip_id = 881041 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Kill_Avatar.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate( Objective_Kill_Avatar, 881033 )
	
elseif Event_IsAnyRunning() == false and g_Avatar_Kaput == true  then

	Util_ObjectiveComplete(Objective_Kill_Avatar.title_id)
	g_Avatar = g_Avatar +1
	Rule_Remove(Rule_Objective_Kill_Avatar)
		
	elseif Event_IsAnyRunning() == false and g_Avatar_Kaput == false then

	Util_ObjectiveFail(Objective_Kill_Avatar.title_id)
	Rule_RemoveAll()
	Fade_Start(4, false)
	World_SetTeamWin( g_enemy, "" )
	Rule_AddIntervalEx( Rule_GameOver,5,1 )
		
end

end

--[[ Player Loss Conditions ]]

function Rule_EndGameLose()

t_building_exceptions = 
{
	--[[1]]"chaos_listening_post", --[[2]]"chaos_plasma_generator", --[[3]]"chaos_turret_bolter", --[[4]]"chaos_armoury", --[[5]]"chaos_greater_sacrificial_circle", --[[6]]"chaos_machine_pit",
	--[[7]]"chaos_mine_field", --[[8]] "chaos_sacrificial_circle", --[[9]] "chaos_thermo_plasma_generator"	}

t_unit_exceptions = 
{--[[1]]"chaos_marine_squad", --[[2]]"chaos_squad_cultist", --[[3]]"chaos_squad_defiler", --[[4]]"chaos_squad_horror", --[[5]]"chaos_squad_khorne_berserker", --[[6]]"chaos_squad_lord", --[[7]]"chaos_squad_obliterator",
--[[8]]"chaos_squad_possessed_marine", --[[9]]"chaos_squad_predator", --[[10]]"chaos_squad_raptor", --[[11]]"chaos_squad_rhino"}

--[[ Lose because of Annihilation ]]	


if( Player_HasBuildingsExcept(g_Player2, t_building_exceptions) == false ) then
		
	if( Player_HasSquadsExcept(g_Player2, t_unit_exceptions ) == false ) then
		
		Util_StartNIS(EVENTS.NIS_Loss)
		
		Rule_Remove( Rule_EndGameLose )
	end
end

--[[ Lose because of the Objectives Failed ]]

--[[ if Objective_Exists(Objective_Name.title_id) == true and Objective_GetState(Objective_Name.title_id) == OS_Failed then Rule_RemoveAll() Fade_Start(4, false) World_SetTeamWin( g_enemy, "" ) Rule_AddIntervalEx( Rule_GameOver,5,1 ) Rule_Remove( Rule_EndGameLose ) end]]

end

function Rule_Bloodthirster_End_Game_Lose()

if SGroup_Exists("sg_Offering") and SGroup_IsEmpty("sg_Offering") then

	Util_StartNIS(EVENTS.NIS_Loss)
	Rule_Remove(Rule_Bloodthirster_End_Game_Lose)
elseif EGroup_Exists("eg_Chaos_HQ") and EGroup_IsEmpty("eg_Chaos_HQ") then

	Util_StartNIS(EVENTS.NIS_Loss)
	Rule_Remove(Rule_Bloodthirster_End_Game_Lose)
	
end

end

--[[ AUTOSAVES ]]

function Rule_Autosave_MissionStart()

if not Event_IsAnyRunning() then
	Util_Autosave( "$880200" )
	Rule_Remove(Rule_Autosave_MissionStart)
end

end

function Rule_Autosave_Switch_Chaos()

if not Event_IsAnyRunning() then
	Util_Autosave( "$880201" )
	Rule_Remove(Rule_Autosave_Switch_Chaos)
end

end

function Rule_Autosave_Blood_Pit_Secured()

if not Event_IsAnyRunning() then
	Util_Autosave( "$880202" )
	Rule_Remove(Rule_Autosave_Blood_Pit_Secured)
end

end

function Rule_Autosave_Blood_Pit_Filled()

if not Event_IsAnyRunning() then
	Util_Autosave( "$880203" )
	Rule_Remove(Rule_Autosave_Blood_Pit_Filled)
end

end

function Rule_Autosave_Kill_Avatar()

if not Event_IsAnyRunning() then
	Util_Autosave( "$880204" )
	Rule_Remove(Rule_Autosave_Kill_Avatar)
end

end

--[[ INTEL EVENTS ]]

--[[ Intel Event 1 ]] function Rule_IE_OpeningSpeech()

Util_StartIntel(EVENTS.IE_OpeningSpeech)

end

--[[ New Objective Created ]] function Rule_IE_Objective_NameCreate()

Util_StartIntel(EVENTS.IE_Objective_NameCreate)

end

--[[ Objective Failed ]] function Rule_IE_Objective_NameComplete()

Util_StartIntel(EVENTS.IE_Objective_NameComplete)

end

--[[ Intel Event 1 ]] function Rule_IE_Objective_NameFailed()

Util_StartIntel(EVENTS.IE_Objective_NameFailed)

end

--[[ Infiltration ]]

function Rule_Infiltration_Advice()

Util_StartIntel(EVENTS.IE_Use_Infiltration)

end


function Util_FilterBlueprint(blueprint, sgroupold, sgroupnew)

local sgroupID = SGroup_CreateIfNotFound(sgroupold)
	SGroup_AddGroup(sgroupID, SGroup_FromName("sg_Potential_Sorcerer"))

for y = 1, SGroup_Count(sgroupID) do
	
	local squadID = SGroup_GetSpawnedSquadAt(sgroupID, y)
	local blueprintcheck = Squad_GetBlueprintName(squadID)
		
		if blueprintcheck == blueprint then
		
			local sgroupID2 = SGroup_CreateIfNotFound(sgroupnew)
			SGroup_Clear(sgroupID2)
			SGroup_Add(sgroupID2, squadID)
		end

end

end


--[[ CHEATS ]]

--[[ function CheatClosing()

Rule_RemoveAll()
Util_StartNIS(EVENTS.NIS_Closing)

end

function CheatMissionMoment()

Util_CreateSquadsAtMarkerEx(g_Player2, "sg_Offering", "chaos_squad_bloodthirster", "mkr_Blood_Pit", 1, 1)
Util_CreateSquadsAtMarkerEx(g_Player4, "sg_Eldar_Avatar", "eldar_squad_avatar", "mkr_Fake_Avatar", 1, 1)
Cmd_MoveToMarker("sg_Eldar_Avatar", "mkr_Blood_Pit")

end

function CheatMissionTwist()

Rule_RemoveAll()
Util_StartNIS(EVENTS.NIS_Twist)

end

function CheatMidMissionName()

Rule_RemoveAll()
Util_StartNIS(EVENTS.NIS_MidName)

end

function Rule_Blood_Cheat()

g_Blood_Tab = 4

end

function Rule_Kill_Sturnn()

SGroup_DeSpawn("sg_Captain_Sturnn")

end

function Rule_Avatar_Cheat()

g_Blood_Pit = 4

end

function Rule_Secure_Pit()

g_Secure_Blood = 3

end

function Rule_Ping_Check()

Rule_AddOneShot(Rule_Ping_Support, 1)

end

function Rule_Nis_check()

Util_StartIntel(EVENTS.IE_Incoming_Eldar_Raid)

end

function blood()

g_Blood_Tab = g_Blood_Tab +1
local i = g_Blood_Tab/4
Util_SetBloodPitLevel("eg_Blood_Pit", i)

end]]



Статистика игры
Подписчики
12
Времена
62
Игроки
7
Последние запуски
Уровень: Trophies (Disorder 5 / Orks)
Уровень: Blood for the Blood God! (Disorder 3)
Уровень: Titan of the Emperor (Order 5 / Imperial guard)
Модераторы