Mission event file for Disorder mission 4
ガイド
/
Mission event file for Disorder mission 4
更新済み 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, "$690088", "chaos_marine_race", 1)
Misc_PlayerTeamColor(g_Player1,"default_6")
Player_DoNotPrecache(g_Player1, _t_MSD4_Player1)


g_Player2 = Setup_Player(1, "$690087", "ork_race", 2)
Misc_PlayerTeamColor(g_Player2,"default_4")
Player_DoNotPrecache(g_Player2, _t_MSD4_Player2)


g_Player3 = Setup_Player(2, "$690085", "space_marine_race", 3)
Misc_PlayerTeamColor(g_Player3,"default_1")
Player_DoNotPrecache(g_Player3, _t_MSD4_Player3)


g_Player4 = Setup_Player(3, "$690082", "guard_race", 3)
Player_DoNotPrecache(g_Player4, _t_MSD4_Player4)


g_Player5 = Setup_Player(4, "$690083", "eldar_race", 5)
Misc_PlayerTeamColor(g_Player5,"default_5")
Player_DoNotPrecache(g_Player5, _t_MSD4_Player5)


g_Player6 = Setup_Player(5, "$000000", "npc_race", 3) --[[this is the team in which guards and eldar and spacemarines are allied]]
Player_DoNotPrecache(g_Player6, _t_MSD4_Player6)


g_Player7 = Setup_Player(6, "$000000", "npc_race", TEAM_NEUTRAL)
Player_DoNotPrecache(g_Player7, _t_MSD4_Player7)




--[[ DEFINE VARIABLES AND TABLES - define any preset values here for later use]]
g_firstrun = true
--[[bases]]
g_Create_Eldar_Base	= 1
g_Create_Eldar_Static_Base = 1
g_Create_Guard_Static_Base = 1
--[[armies]]
g_Player_Ork_Army_iter = 1
g_Player_Chaos_Army_iter = 1
g_Chaos_Imperial_Army_iter = 1
g_Eldar_Army_iter = 1
g_Control_Building_Army_iter = 1
g_Eldar_Defence_Army_iter = 1
g_Chaos_Imperial_Army_iter = 1
g_Guard_Defence_Army1_iter = 1
g_Guard_Defence_Army2_iter = 1
g_Guard_Defence_Army3_iter = 1
g_Guard_Defence_Army4_iter = 1
g_Guard_Defence_Army5_iter = 1
g_Guard_Defence_Army6_iter = 1
g_Guard_Defence_Army7_iter = 1
g_Guard_Defence_Army8_iter = 1
g_Guard_Defence_Army9_iter = 1
g_Guard_Defence_Army10_iter = 1
g_Guard_Defence_Army11_iter = 1
g_Player_Chaos_Hero_iter	= 1
g_Player_Ork_Hero_iter = 1
g_Escort = 1
g_Npc_Reinforcement_Army_iter = 1
g_Prism = 0
g_Farseer = false
g_Chaos_HQ = false
g_Ork_HQ = false
g_Ork = nil
g_Nis = false


--[[value for the countdown to the capture of the control building on the chaos side]]
g_Control_Countdown = 300

--[[value for the countdown before the final eldar relocation]]
g_Control_Countdown_Eldar = 300

g_Imperial_Control = false
g_Move_iter = 1
g_Convoy_Maker = 1
g_Wait = 0
g_Stage = 1
g_Jump = 0
g_time = 0
g_Ability_Timer = 0
g_Chaos_Objectives = 0
g_Ork_Objectives = 0

g_Ork_Switch = 1
g_Chaos_Switch = 1
g_Human_Player = 1
g_Control_Total = 0
g_Control_Health = 0
g_On = false
g_Ability = true
g_gatesopen = false

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

end

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

end

--[[ the OnLoad() function acts like the OnInit() but for saved games only ]] function OnLoad()

if g_gatesopen then
	Anim_PlayEGroupAnim(EGroup_FromName("eg_Gate_Final"), "die")
end

end

Scar_AddLoad(OnLoad)

--[[ 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 )

end

function Rule_Research_Grant()

Player_GrantResearch(g_Player5, "eldar_ranger_infiltration_research")
Player_GrantResearch(g_Player5, "eldar_shroud_ability_research")
Player_GrantResearch(g_Player5, "eldar_webway_gate_relocation_research")
Player_GrantResearch(g_Player1, "eldar_farseer_ability_research_3")

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

local ModID = Modifier_Create(MAT_EntityType, "ability_recharge_modifier", MUT_Multiplication, false, 50 , "eldar_eldritchstorm")
Modifier_ApplyToPlayer( ModID, g_Player6 )

local ModID2 = Modifier_Create(MAT_EntityType, "health_maximum_modifier", MUT_Multiplication, false, 4 , "eldar_farseer")
Modifier_ApplyToPlayer( ModID2, g_Player6)

end

--[[ MUSIC ]]

function Rule_SetupMusicPlaylist()

t_music = {"music_theme_chaos_01", "music_ork_theme", "music_coming_of_chaos" }
t_music_stage1 = {"music_msd4_perc"}
t_music_stage2 = {"music_msd4_perc_choir"}
t_music_stage3 = {"music_msd4", "music_msd4_perc", "music_msd4_perc_choir"}
t_music_nis_ulthwe = {"music_EldarThemeV2"}
t_music_nis_marine = {"stinger_mso2_theultramarines"}
t_music_nis_ork = {"playerswitch_ork"}
t_music_nis_chaos = {"playerswitch_chaos"}

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

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

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, 4000, 2500)
	Player_SetAllResources(g_Player2, 4000, 2500)
	
	--[[ 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, false)
	
	--[[ WIN CHECK ]]
--	Rule_AddInterval(Rule_EndGameWin, 1)
	
	--[[ LOSE CHECK ]]

-- Rule_AddInterval(Rule_EndGameLose, 1)

	--[[ ASSIGN OBJECTIVES ]]

	Rule_AddInterval(Rule_Objective_Breach_Psychic_Shield, 1)
	Rule_AddInterval(Rule_Objective_Reach_The_Titan, 1)
	Rule_AddInterval(Rule_Objective_Control_Chaos, 5)
	Rule_AddInterval(Rule_Objective_Control_Ork, 2)
	Rule_AddInterval(Rule_Objective_Switch_Side, 2)
	Rule_AddInterval(Rule_Objective_Destroy_Eldar_Base, 5)
	Rule_AddInterval(Rule_Objective_Convoy, 5)
	Rule_AddInterval(Rule_Objective_Kill_The_Farseer, 5)
	Rule_AddInterval(Rule_Check_HQ_End, 1)
	Rule_Add(Rule_Check_HQ_Chaos)
	Rule_Add(Rule_Check_HQ_Ork)
	Rule_AddInterval(Rule_Mid_Nis_Trigger, 3)
	
	--[[ AUTOSAVE AFTER NIS ]]
	Rule_Add(Rule_Autosave_MissionStart)
	
	--[[ GENERATE ACTION ]]
	-- Use this space to add all core mission functions
	Rule_AddOneShot(Rule_Research_Grant, 0)
	Rule_AddOneShot(Rule_Begin, 1)
	
	
	--[[ 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_SetForPlayer(g_Player5, difficultyLevel) Difficulty_SetForPlayer(g_Player6, 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


--[[ The starter ]]

function Rule_Begin()

Rule_Add(Rule_Chaos_Imperial_Army_Creation)
Rule_Add(Rule_Eldar_Army_Creation)

Rule_Add(Rule_Control_Building_Army_Creation)
Rule_AddOneShot(Rule_Switch_Player_Button, 1)

Rule_Add(Rule_Convoy_Maker)
Rule_Add(Rule_TitanCrew_Create)
Rule_AddOneShot(Rule_Proactive_Defence_Army_Table, 1)

end


--[[ Player switch button ]]

function Rule_Switch_Player_Button()

t_switch_player_button = {
	button_icon = {--[[1]]"Scar_buttons/switchto_Ork", --[[2]]"Scar_buttons/switchto_Ork", --[[3]]"Scar_buttons/switchto_Ork"},
	button_description = {--[[1]]"$890400", --[[2]]"$890401"}, 
}

g_buttonID1 = Util_ScarButton_Create("btn_ScarUI", t_switch_player_button.button_icon, t_switch_player_button.button_description, true, true)

Rule_AddInterval(Rule_Button_Click, 1)

end

function Rule_Button_Click()

if g_Human_Player == 1 and Button_GetPressed(g_buttonID1) == true and g_Nis == false and Event_IsAnyRunning() == false then


	Util_StartNIS(EVENTS.NIS_Switch_Ork)

elseif g_Human_Player == 2 and Button_GetPressed(g_buttonID1) == true and g_Nis == false and Event_IsAnyRunning() == false then


	Util_StartNIS(EVENTS.NIS_Switch_Chaos)

end

end


--[[ Player Ork Army ]]

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_Player_Ork4", --[[5]]"sg_Player_Ork_Boss", --[[6]]"sg_Player_Ork5", --[[7]]"sg_Player_Ork6"},  
	
	blueprint = {--[[1]]"ork_squad_shoota_boy", --[[2]]"ork_squad_shoota_boy",  --[[3]]"ork_squad_nob", --[[4]]"ork_squad_nob", --[[5]]"ork_squad_warboss", --[[6]]"ork_squad_wartrak", --[[7]]"ork_squad_wartrak"},
	
	marker_spawn = {--[[1]]"mkr_Ork1", --[[2]]"mkr_Ork2",  --[[3]]"mkr_Ork3", --[[4]]"mkr_Ork4", --[[5]]"mkr_Ork_Boss", --[[6]]"mkr_Ork5", --[[7]]"mkr_Ork6"}, 
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1}, 
	
	squad_size = {--[[1]] 6, --[[2]] 6, --[[3]] 6, --[[4]] 6, --[[5]] 1, --[[6]] 1, --[[7]] 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_Player2, 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])

		
	elseif g_Player_Ork_Army_iter > table.getn(t_Player_Ork_Army.sgroup_name) then
			g_Player_Ork_Army_iter = 0
			Rule_AddInterval(Rule_Gorgutz_Track, 1)
			Rule_Remove(Rule_Player_Ork_Army_Creation)				
	end
g_Player_Ork_Army_iter = g_Player_Ork_Army_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_Player_Ork_Boss") and ( SGroup_IsEmpty("sg_Player_Ork_Boss") or SGroup_ContainsBlueprints( "sg_Player_Ork_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_Player2, "sg_Player_Ork_Boss", "ork_squad_warboss", "mkr_Ork_Boss", 1)

--[[ play the fx ]]
World_FXEventSquad("data:Art/Events/Unit_Upgrade_Morale_FX/Reinforce_Trooper", SGroup_FromName("sg_Player_Ork_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

--[[ Player Chaos Army ]]

function Rule_Player_Chaos_Army_Creation()

local i = g_Player_Chaos_Army_iter 

t_Player_Chaos_Army = {
	
	sgroup_name = {--[[1]]"sg_Player_Chaos1", --[[2]]"sg_Player_Chaos2", --[[3]]"sg_Player_Chaos3",  --[[4]]"sg_Player_Chaos_Boss"},  

	blueprint = {--[[1]]"chaos_squad_possessed_marine", --[[2]]"chaos_marine_squad",  --[[3]]"chaos_squad_horror", --[[4]]"chaos_squad_lord"},
	
	marker_spawn = {--[[1]]"mkr_Chaos1", --[[2]]"mkr_Chaos2",  --[[3]]"mkr_Chaos3", --[[5]]"mkr_Chaos_Boss"}, 
	
	squad_num = {--[[1]] 1, --[[2]] 1,  --[[3]] 2, --[[4]] 1}, 
	
	squad_size = {--[[1]] 6, --[[2]] 6,  --[[3]] 6, --[[4]] 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_Player1, 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])

		
	elseif g_Player_Chaos_Army_iter > table.getn(t_Player_Chaos_Army.sgroup_name) then
			g_Player_Chaos_Army_iter = 0
			Cmd_ReinforceLeader("sg_Player_Chaos2", 1)
			Rule_AddInterval(Rule_Crull_Track, 4)
			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_Player_Chaos_Boss") and ( SGroup_IsEmpty("sg_Player_Chaos_Boss") or SGroup_ContainsBlueprints( "sg_Player_Chaos_Boss", 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_Player1, "sg_Player_Chaos_Boss", "chaos_squad_lord", "mkr_Chaos_Boss", 1)

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

--[[ 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


--[[ Static Imperial Army ]]

function Rule_Chaos_Imperial_Army_Creation()

local i = g_Chaos_Imperial_Army_iter 

t_Chaos_Imperial_Army = {
	
	sgroup_name = {--[[1]]"sg_Chaos_Imperial1", --[[2]]"sg_Chaos_Imperial1B", --[[3]]"sg_Chaos_Imperial2", --[[4]]"sg_Chaos_Imperial2B", --[[5]]"sg_Chaos_Imperial3B", --[[6]] --[[7]]"sg_Chaos_Imperial4", --[[8]]"sg_Chaos_Imperial5", --[[9]]"sg_Chaos_Imperial6", --[[10]]"sg_Chaos_Imperial7", 
	--[[11]]"sg_Chaos_Imperial8", --[[12]]"sg_Chaos_Imperial9", --[[13]]"sg_Chaos_Imperial10", --[[14]]"sg_Chaos_Imperial11", --[[15]]"sg_Chaos_Imperial12", --[[16]] --[[17]]"sg_Chaos_Imperial14", --[[18]]"sg_Chaos_Imperial15", --[[19]]"sg_Chaos_Imperial16", --[[20]]"sg_Imperial_Artillery1",
	--[[21]]"sg_Imperial_Artillery2"},  
	
	blueprint = {--[[1]]"guard_squad_guardsmen", --[[2]]"guard_squad_hellhound", --[[3]]"guard_squad_kasrkin", --[[4]]"guard_squad_lemanruss", --[[5]]"guard_squad_hellhound", --[[6]] --[[7]]"guard_squad_guardsmen", --[[8]]"guard_squad_ogryns", --[[9]]"guard_squad_kasrkin", 
	--[[10]]"guard_squad_kasrkin", --[[11]]"guard_squad_ogryns", --[[12]]"guard_squad_guardsmen", --[[13]]"guard_squad_kasrkin", --[[14]]"guard_squad_guardsmen", --[[15]]"guard_squad_kasrkin", --[[16]]--[[17]]"guard_squad_guardsmen", --[[18]]"guard_squad_sentinel", 
	--[[19]]"guard_squad_sentinel", --[[20]]"guard_squad_basilisk", --[[21]]"guard_squad_basilisk"},
	
	marker_spawn = {--[[1]]"mkr_Chaos_Imperial1", --[[2]]"mkr_Chaos_Imperial1B", --[[3]]"mkr_Chaos_Imperial2", --[[4]]"mkr_Chaos_Imperial2B", --[[5]]"mkr_Chaos_Imperial3B", --[[6]] --[[7]]"mkr_Chaos_Imperial4", --[[8]]"mkr_Chaos_Imperial5", --[[9]]"mkr_Chaos_Imperial6",
	--[[10]]"mkr_Chaos_Imperial7", --[[11]]"mkr_Chaos_Imperial8", --[[12]]"mkr_Chaos_Imperial9", --[[13]]"mkr_Chaos_Imperial10", --[[14]]"mkr_Chaos_Imperial11", --[[15]]"mkr_Chaos_Imperial12", --[[16]] --[[17]]"mkr_Chaos_Imperial14", --[[18]]"mkr_Chaos_Imperial15", --[[19]]"mkr_Chaos_Imperial16",
	--[[20]]"mkr_Chaos_Imperial17", --[[21]]"mkr_Chaos_Imperial18"}, 
	
	stance = {--[[1]]STANCE_Hold, --[[2]]STANCE_Hold, --[[3]]STANCE_Hold, --[[4]]STANCE_Hold, --[[5]]STANCE_Hold, --[[6]] --[[7]]STANCE_Hold, --[[8]]STANCE_Hold, --[[9]]STANCE_Hold, --[[10]]STANCE_Hold, --[[11]]STANCE_Hold, --[[12]]STANCE_Hold, --[[13]]STANCE_Hold, --[[14]]STANCE_Hold, --[[15]]STANCE_Hold, --[[16]]
	--[[17]]STANCE_Hold, --[[18]]STANCE_Hold, --[[19]]STANCE_Hold, --[[20]]STANCE_StandGround, --[[21]]STANCE_StandGround},
	
	melee_stance = {--[[1]]MSTANCE_Ranged, --[[2]]MSTANCE_Ranged, --[[3]]MSTANCE_Ranged, --[[4]]MSTANCE_Ranged, --[[5]]MSTANCE_Ranged, --[[6]] --[[7]]MSTANCE_Ranged, --[[8]]MSTANCE_Ranged, --[[9]]MSTANCE_Ranged, --[[10]]MSTANCE_Ranged, --[[11]]MSTANCE_Ranged, --[[12]]MSTANCE_Ranged, --[[13]]MSTANCE_Ranged, --[[14]]MSTANCE_Ranged,
	--[[15]]MSTANCE_Ranged, --[[16]]--[[17]]MSTANCE_Ranged, --[[18]]MSTANCE_Ranged, --[[19]]MSTANCE_Ranged, --[[20]]MSTANCE_Ranged, --[[21]]MSTANCE_Ranged},
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]]  --[[7]] 1, --[[8]] 1, --[[9]] 1, --[[10]] 1, --[[11]] 1, --[[12]] 1, --[[13]] 1, --[[14]] 2, --[[15]] 1, --[[16]] --[[17]] 1, --[[18]] 1, --[[19]] 1, --[[20]] 1, --[[21]] 1}, 
	
	squad_size = {--[[1]] 6, --[[2]] 1, --[[3]] 6, --[[4]] 1, --[[5]] 1, --[[6]]  --[[7]] 9, --[[8]] 5, --[[9]] 6, --[[10]] 8, --[[11]] 5, --[[12]] 9, --[[13]] 9, --[[14]] 6, --[[15]] 7, --[[16]] --[[17]] 9, --[[18]] 1, --[[19]] 1, --[[20]] 1, --[[21]] 1}, 
}

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Chaos_Imperial_Army.sgroup_name[i], t_Chaos_Imperial_Army.blueprint[i], t_Chaos_Imperial_Army.marker_spawn[i], t_Chaos_Imperial_Army.squad_num[i], t_Chaos_Imperial_Army.squad_size[i])
	Cmd_SetStance(t_Chaos_Imperial_Army.sgroup_name[i], t_Chaos_Imperial_Army.stance[i])
	Cmd_SetMeleeStance(t_Chaos_Imperial_Army.sgroup_name[i], t_Chaos_Imperial_Army.melee_stance[i])
		
	elseif g_Chaos_Imperial_Army_iter > table.getn(t_Chaos_Imperial_Army.sgroup_name) then
			g_Chaos_Imperial_Army_iter = 0
			Rule_Remove(Rule_Chaos_Imperial_Army_Creation)
							
	end
g_Chaos_Imperial_Army_iter = g_Chaos_Imperial_Army_iter+1

end


--[[ Guard Proactive Army 1]]

function Rule_Guard_Proactive_Army1()

t_Guard_Defence_Army1 = {

	sgroup_name = { --[[1]]"sg_Guard_Counter1_1", --[[2]]"sg_Guard_Counter2_2"},  
	
	blueprint = {--[[1]]"guard_squad_guardsmen", --[[2]]"guard_squad_guardsmen"},
	
	marker_spawn = {--[[1]]"mkr_Guard_Generator1", --[[2]]"mkr_Guard_Generator1"}, 
	
	stance = {--[[1]]STANCE_Attack, --[[2]]STANCE_Attack},
	
	melee_stance = {--[[1]]MSTANCE_Ranged, --[[2]]MSTANCE_Ranged},
	
	squad_num = {--[[1]] 1, --[[2]] 1}, 
	
	squad_size = {--[[1]] 6, --[[2]] 6}, 
}

local i = g_Guard_Defence_Army1_iter 

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Guard_Defence_Army1.sgroup_name[i], t_Guard_Defence_Army1.blueprint[i], t_Guard_Defence_Army1.marker_spawn[i], t_Guard_Defence_Army1.squad_num[i], t_Guard_Defence_Army1.squad_size[i])
	Cmd_SetStance(t_Guard_Defence_Army1.sgroup_name[i], t_Guard_Defence_Army1.stance[i])
	Cmd_SetMeleeStance(t_Guard_Defence_Army1.sgroup_name[i], t_Guard_Defence_Army1.melee_stance[i])
	Cmd_AttackMoveMarker(t_Guard_Defence_Army1.sgroup_name[i], "mkr_Guard_Target")
	
	
	elseif g_Guard_Defence_Army1_iter > table.getn(t_Guard_Defence_Army1.sgroup_name) then
			g_Guard_Defence_Army1_iter = 0
			Rule_AddOneShot(Rule_Buffer_Guard_Proactive_Army1, 1)
			Rule_Remove(Rule_Guard_Proactive_Army1)
	end
	g_Guard_Defence_Army1_iter = g_Guard_Defence_Army1_iter+1
			

end

function Rule_Buffer_Guard_Proactive_Army1()

Rule_AddIntervalDelay(Rule_Guard_Proactive_Army1, 7, 60)

end

function Rule_Guard_Proactive_Army1_Check()

if EGroup_GetAvgHealth("eg_Guard_Generator1") <= 0 then

	Rule_Remove(Rule_Buffer_Guard_Proactive_Army1)
	Rule_Remove(Rule_Guard_Proactive_Army1)
	Rule_Remove(Rule_Guard_Proactive_Army1_Check)

end

end

--[[ - this proximity check triggers both Guard Proactive Army 1 and 2]] function Rule_Prox_Guard_Check1() if g_Current_Player == g_Player2 then if Player_AreSquadsNearMarker(g_Player1, "mkr_Prox_Guard_Check1") == true then

		Rule_Add(Rule_Guard_Proactive_Army1)
		Rule_Add(Rule_Guard_Proactive_Army1_Check)
		Rule_Add(Rule_Guard_Proactive_Army2)
		Rule_Add(Rule_Guard_Proactive_Army2_Check)
		Rule_Remove(Rule_Prox_Guard_Check1)
	
	elseif Player_AreSquadsNearMarker(g_Player1, "mkr_Prox_Guard_Check1B") == true then
	
		Rule_Add(Rule_Guard_Proactive_Army1)
		Rule_Add(Rule_Guard_Proactive_Army1_Check)
		Rule_Add(Rule_Guard_Proactive_Army2)
		Rule_Add(Rule_Guard_Proactive_Army2_Check)
		Rule_Remove(Rule_Prox_Guard_Check1)
		
	end
else

end

end

--[[ Guard Proactive Army 2]]

function Rule_Guard_Proactive_Army2()

t_Guard_Defence_Army2 = {

	sgroup_name = { --[[1]]"sg_Guard_Counter2_1", --[[2]]"sg_Guard_Counter2_2"},  
	
	blueprint = {--[[1]]"guard_squad_guardsmen", --[[2]]"guard_squad_kasrkin"},
	
	marker_spawn = {--[[1]]"mkr_Guard_Generator2", --[[2]]"mkr_Guard_Generator2"}, 
	
	stance = {--[[1]]STANCE_Attack, --[[2]]STANCE_Attack},
	
	melee_stance = {--[[1]]MSTANCE_Ranged, --[[2]]MSTANCE_Ranged},
	
	squad_num = {--[[1]] 1, --[[2]] 1}, 
	
	squad_size = {--[[1]] 6, --[[2]] 4}, 
}

local i = g_Guard_Defence_Army2_iter 

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Guard_Defence_Army2.sgroup_name[i], t_Guard_Defence_Army2.blueprint[i], t_Guard_Defence_Army2.marker_spawn[i], t_Guard_Defence_Army2.squad_num[i], t_Guard_Defence_Army2.squad_size[i])
	Cmd_SetStance(t_Guard_Defence_Army2.sgroup_name[i], t_Guard_Defence_Army2.stance[i])
	Cmd_SetMeleeStance(t_Guard_Defence_Army2.sgroup_name[i], t_Guard_Defence_Army2.melee_stance[i])
	Cmd_AttackMoveMarker(t_Guard_Defence_Army2.sgroup_name[i], "mkr_Guard_Target")
			
	elseif g_Guard_Defence_Army2_iter > table.getn(t_Guard_Defence_Army2.sgroup_name) then
			g_Guard_Defence_Army2_iter = 0
			Rule_AddOneShot(Rule_Buffer_Guard_Proactive_Army2, 1)
			Rule_Remove(Rule_Guard_Proactive_Army2)
	end
	g_Guard_Defence_Army2_iter = g_Guard_Defence_Army2_iter+1
			

end

function Rule_Buffer_Guard_Proactive_Army2()

Rule_AddIntervalDelay(Rule_Guard_Proactive_Army2, 7, 80)

end

function Rule_Guard_Proactive_Army2_Check()

if EGroup_GetAvgHealth("eg_Guard_Generator2") <= 0 then

	Rule_Remove(Rule_Buffer_Guard_Proactive_Army2)
	Rule_Remove(Rule_Guard_Proactive_Army2)
	Rule_Remove(Rule_Guard_Proactive_Army2_Check)

end

end


--[[ Guard Proactive Army 3]]

function Rule_Guard_Proactive_Army3()

t_Guard_Defence_Army3 = {

	sgroup_name = { --[[1]]"sg_Guard_Counter3_1", --[[2]]"sg_Guard_Counter3_2"},  
	
	blueprint = {--[[1]]"guard_squad_guardsmen", --[[2]]"guard_squad_guardsmen"},
	
	marker_spawn = {--[[1]]"mkr_Guard_Generator3", --[[2]]"mkr_Guard_Generator3"}, 
	
	stance = {--[[1]]STANCE_Attack, --[[2]]STANCE_Attack},
	
	melee_stance = {--[[1]]MSTANCE_Ranged, --[[2]]MSTANCE_Ranged},
	
	squad_num = {--[[1]] 1, --[[2]] 1}, 
	
	squad_size = {--[[1]] 6, --[[2]] 6}, 
}

local i = g_Guard_Defence_Army3_iter 

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Guard_Defence_Army3.sgroup_name[i], t_Guard_Defence_Army3.blueprint[i], t_Guard_Defence_Army3.marker_spawn[i], t_Guard_Defence_Army3.squad_num[i], t_Guard_Defence_Army3.squad_size[i])
	Cmd_SetStance(t_Guard_Defence_Army3.sgroup_name[i], t_Guard_Defence_Army3.stance[i])
	Cmd_SetMeleeStance(t_Guard_Defence_Army3.sgroup_name[i], t_Guard_Defence_Army3.melee_stance[i])
	Cmd_AttackMoveMarker(t_Guard_Defence_Army3.sgroup_name[i], "mkr_Guard_Target")
			
	elseif g_Guard_Defence_Army3_iter > table.getn(t_Guard_Defence_Army3.sgroup_name) then
			g_Guard_Defence_Army3_iter = 0
			Rule_AddOneShot(Rule_Buffer_Guard_Proactive_Army3, 1)
			Rule_Remove(Rule_Guard_Proactive_Army3)
	end
	g_Guard_Defence_Army3_iter = g_Guard_Defence_Army3_iter+1
			

end

function Rule_Buffer_Guard_Proactive_Army3()

Rule_AddIntervalDelay(Rule_Guard_Proactive_Army3, 7, 70)

end

function Rule_Guard_Proactive_Army3_Check()

if EGroup_GetAvgHealth("eg_Guard_Generator3") <= 0 then

	Rule_Remove(Rule_Buffer_Guard_Proactive_Army3)
	Rule_Remove(Rule_Guard_Proactive_Army3)
	Rule_Remove(Rule_Guard_Proactive_Army3_Check)

end

end

function Rule_Prox_Guard_Check2() if g_Current_Player == g_Player2 then if Player_AreSquadsNearMarker(g_Player1, "mkr_Prox_Guard_Check2") == true then

		Rule_Add(Rule_Guard_Proactive_Army3)
		Rule_Add(Rule_Guard_Proactive_Army3_Check)
		Rule_Remove(Rule_Prox_Guard_Check2)
		
	elseif Player_AreSquadsNearMarker(g_Player1, "mkr_Prox_Guard_Check2B") == true then
	
		Rule_Add(Rule_Guard_Proactive_Army3)
		Rule_Add(Rule_Guard_Proactive_Army3_Check)
		Rule_Remove(Rule_Prox_Guard_Check2)
		
	
	end
else

end

end


--[[ Guard Proactive Army 4]]

function Rule_Guard_Proactive_Army4()

t_Guard_Defence_Army4 = {

	sgroup_name = { --[[1]]"sg_Guard_Counter4_1", --[[2]]"sg_Guard_Counter4_2", --[[3]]"sg_Guard_Counter4_3"},  
	
	blueprint = {--[[1]]"guard_squad_guardsmen", --[[2]]"guard_squad_guardsmen", --[[3]]"guard_squad_guardsmen"},
	
	marker_spawn = {--[[1]]"mkr_Guard_Generator4", --[[2]]"mkr_Guard_Generator4", --[[3]]"mkr_Guard_Generator4"}, 
	
	stance = {--[[1]]STANCE_Attack, --[[2]]STANCE_Attack, --[[3]]STANCE_Attack},
	
	melee_stance = {--[[1]]MSTANCE_Ranged, --[[2]]MSTANCE_Ranged, --[[3]]MSTANCE_Ranged},
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1}, 
	
	squad_size = {--[[1]] 6, --[[2]] 6, --[[3]] 7}, 
}

local i = g_Guard_Defence_Army4_iter 

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Guard_Defence_Army4.sgroup_name[i], t_Guard_Defence_Army4.blueprint[i], t_Guard_Defence_Army4.marker_spawn[i], t_Guard_Defence_Army4.squad_num[i], t_Guard_Defence_Army4.squad_size[i])
	Cmd_SetStance(t_Guard_Defence_Army4.sgroup_name[i], t_Guard_Defence_Army4.stance[i])
	Cmd_SetMeleeStance(t_Guard_Defence_Army4.sgroup_name[i], t_Guard_Defence_Army4.melee_stance[i])
	Cmd_AttackMoveMarker(t_Guard_Defence_Army4.sgroup_name[i], "mkr_Guard_Target")
			
	elseif g_Guard_Defence_Army4_iter > table.getn(t_Guard_Defence_Army4.sgroup_name) then
			g_Guard_Defence_Army4_iter = 0
			Rule_AddOneShot(Rule_Buffer_Guard_Proactive_Army4, 1)
			Rule_Remove(Rule_Guard_Proactive_Army4)
	end
	g_Guard_Defence_Army4_iter = g_Guard_Defence_Army4_iter+1
			

end

function Rule_Buffer_Guard_Proactive_Army4()

Rule_AddIntervalDelay(Rule_Guard_Proactive_Army4, 7, 70)

end

function Rule_Guard_Proactive_Army4_Check()

if EGroup_GetAvgHealth("eg_Guard_Generator4") <= 0 then

	Rule_Remove(Rule_Buffer_Guard_Proactive_Army4)
	Rule_Remove(Rule_Guard_Proactive_Army4)
	Rule_Remove(Rule_Guard_Proactive_Army4_Check)

end

end

--[[ - this check triggers both proactive army 4 and 5]] function Rule_Prox_Guard_Check3()

if Player_AreSquadsNearMarker(g_Player1, "mkr_Prox_Guard_Check3")  then
		
	Rule_Add(Rule_Guard_Proactive_Army4)
	Rule_Add(Rule_Guard_Proactive_Army4_Check)
	Rule_Add(Rule_Guard_Proactive_Army5)
	Rule_Add(Rule_Guard_Proactive_Army5_Check)
Rule_Remove(Rule_Prox_Guard_Check3)
	
end

end


--[[ Guard Proactive Army 5]]

function Rule_Guard_Proactive_Army5()

t_Guard_Defence_Army5 = {

	sgroup_name = { --[[1]]"sg_Guard_Counter5_1", --[[2]]"sg_Guard_Counter5_2", --[[3]]"sg_Guard_Counter5_3"},  
	
	blueprint = {--[[1]]"guard_squad_guardsmen", --[[2]]"guard_squad_guardsmen", --[[3]]"guard_squad_guardsmen"},
	
	marker_spawn = {--[[1]]"mkr_Guard_Generator5", --[[2]]"mkr_Guard_Generator5", --[[3]]"mkr_Guard_Generator5"}, 
	
	stance = {--[[1]]STANCE_Attack, --[[2]]STANCE_Attack, --[[3]]STANCE_Attack},
	
	melee_stance = {--[[1]]MSTANCE_Ranged, --[[2]]MSTANCE_Ranged, --[[3]]MSTANCE_Ranged},
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1}, 
	
	squad_size = {--[[1]] 7, --[[2]] 8, --[[3]] 7}, 
}

local i = g_Guard_Defence_Army5_iter 

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Guard_Defence_Army5.sgroup_name[i], t_Guard_Defence_Army5.blueprint[i], t_Guard_Defence_Army5.marker_spawn[i], t_Guard_Defence_Army5.squad_num[i], t_Guard_Defence_Army5.squad_size[i])
	Cmd_SetStance(t_Guard_Defence_Army5.sgroup_name[i], t_Guard_Defence_Army5.stance[i])
	Cmd_SetMeleeStance(t_Guard_Defence_Army5.sgroup_name[i], t_Guard_Defence_Army5.melee_stance[i])
	Cmd_AttackMoveMarker(t_Guard_Defence_Army5.sgroup_name[i], "mkr_Guard_Target")
			
	elseif g_Guard_Defence_Army5_iter > table.getn(t_Guard_Defence_Army5.sgroup_name) then
			g_Guard_Defence_Army5_iter = 0
			Rule_AddOneShot(Rule_Buffer_Guard_Proactive_Army5, 1)
			Rule_Remove(Rule_Guard_Proactive_Army5)
	end
	g_Guard_Defence_Army5_iter = g_Guard_Defence_Army5_iter+1
			

end

function Rule_Buffer_Guard_Proactive_Army5()

Rule_AddIntervalDelay(Rule_Guard_Proactive_Army5, 7, 70)

end

function Rule_Guard_Proactive_Army5_Check()

if EGroup_GetAvgHealth("eg_Guard_Generator5") <= 0 then

	Rule_Remove(Rule_Buffer_Guard_Proactive_Army5)
	Rule_Remove(Rule_Guard_Proactive_Army5)
	Rule_Remove(Rule_Guard_Proactive_Army5_Check)

end

end


--[[ Guard Proactive Army 6]]

function Rule_Guard_Proactive_Army6()

t_Guard_Defence_Army6 = {

	sgroup_name = { --[[1]]"sg_Guard_Counter6_1", --[[2]]"sg_Guard_Counter6_2"},  
	
	blueprint = {--[[1]]"guard_squad_sentinel", --[[2]]"guard_squad_sentinel",},
	
	marker_spawn = {--[[1]]"mkr_Guard_Generator6", --[[2]]"mkr_Guard_Generator6"}, 
	
	stance = {--[[1]]STANCE_Attack, --[[2]]STANCE_Attack},
	
	melee_stance = {--[[1]]MSTANCE_Ranged, --[[2]]MSTANCE_Ranged},
	
	squad_num = {--[[1]] 1, --[[2]] 1}, 
	
	squad_size = {--[[1]] 7, --[[2]] 7}, 
}

local i = g_Guard_Defence_Army6_iter 

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Guard_Defence_Army6.sgroup_name[i], t_Guard_Defence_Army6.blueprint[i], t_Guard_Defence_Army6.marker_spawn[i], t_Guard_Defence_Army6.squad_num[i], t_Guard_Defence_Army6.squad_size[i])
	Cmd_SetStance(t_Guard_Defence_Army6.sgroup_name[i], t_Guard_Defence_Army6.stance[i])
	Cmd_SetMeleeStance(t_Guard_Defence_Army6.sgroup_name[i], t_Guard_Defence_Army6.melee_stance[i])
	Cmd_AttackMoveMarker(t_Guard_Defence_Army6.sgroup_name[i], "mkr_Guard_Target")
			
	elseif g_Guard_Defence_Army6_iter > table.getn(t_Guard_Defence_Army6.sgroup_name) then
			g_Guard_Defence_Army6_iter = 0
			Rule_AddOneShot(Rule_Buffer_Guard_Proactive_Army6, 1)
			Rule_Remove(Rule_Guard_Proactive_Army6)
	end
	g_Guard_Defence_Army6_iter = g_Guard_Defence_Army6_iter+1
			

end

function Rule_Buffer_Guard_Proactive_Army6()

Rule_AddIntervalDelay(Rule_Guard_Proactive_Army6, 20, 60)

end

function Rule_Guard_Proactive_Army6_Check()

if EGroup_GetAvgHealth("eg_Guard_Generator6") <= 0 then

	Rule_Remove(Rule_Buffer_Guard_Proactive_Army6)
	Rule_Remove(Rule_Guard_Proactive_Army6)
	Rule_Remove(Rule_Guard_Proactive_Army6_Check)

end

end

--[[ - this check triggers both proactive army 6 and 7]] function Rule_Prox_Guard_Check4()

if Player_AreSquadsNearMarker(g_Player1, "mkr_Prox_Guard_Check4")  then
		
	Rule_Add(Rule_Guard_Proactive_Army6)
	Rule_Add(Rule_Guard_Proactive_Army6_Check)
	Rule_Add(Rule_Guard_Proactive_Army7)
	Rule_Add(Rule_Guard_Proactive_Army7_Check)
	Rule_Remove(Rule_Prox_Guard_Check4)
	
end

end


--[[ Guard Proactive Army 7]]

function Rule_Guard_Proactive_Army7()

t_Guard_Defence_Army7 = {

	sgroup_name = { --[[1]]"sg_Guard_Counter7_1", --[[2]]"sg_Guard_Counter7_2", --[[3]]"sg_Guard_Counter7_3"},  
	
	blueprint = {--[[1]]"guard_squad_guardsmen", --[[2]]"guard_squad_guardsmen", --[[3]]"guard_squad_guardsmen"},
	
	marker_spawn = {--[[1]]"mkr_Guard_Generator7", --[[2]]"mkr_Guard_Generator7", --[[3]]"mkr_Guard_Generator7"}, 
	
	stance = {--[[1]]STANCE_Attack, --[[2]]STANCE_Attack, --[[3]]STANCE_Attack},
	
	melee_stance = {--[[1]]MSTANCE_Ranged, --[[2]]MSTANCE_Ranged, --[[3]]MSTANCE_Assault},
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1}, 
	
	squad_size = {--[[1]] 6, --[[2]] 6, --[[3]] 3}, 


}

local i = g_Guard_Defence_Army7_iter 

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Guard_Defence_Army7.sgroup_name[i], t_Guard_Defence_Army7.blueprint[i], t_Guard_Defence_Army7.marker_spawn[i], t_Guard_Defence_Army7.squad_num[i], t_Guard_Defence_Army7.squad_size[i])
	Cmd_SetStance(t_Guard_Defence_Army7.sgroup_name[i], t_Guard_Defence_Army7.stance[i])
	Cmd_SetMeleeStance(t_Guard_Defence_Army7.sgroup_name[i], t_Guard_Defence_Army7.melee_stance[i])
	Cmd_AttackMoveMarker(t_Guard_Defence_Army7.sgroup_name[i], "mkr_Guard_Target")
			
	elseif g_Guard_Defence_Army7_iter > table.getn(t_Guard_Defence_Army7.sgroup_name) then
			g_Guard_Defence_Army7_iter = 0
			Rule_AddOneShot(Rule_Buffer_Guard_Proactive_Army7, 1)
			Rule_Remove(Rule_Guard_Proactive_Army7)
	end
	g_Guard_Defence_Army7_iter = g_Guard_Defence_Army7_iter+1
			

end

function Rule_Buffer_Guard_Proactive_Army7()

Rule_AddIntervalDelay(Rule_Guard_Proactive_Army7, 7,  70)

end

function Rule_Guard_Proactive_Army7_Check()

if EGroup_GetAvgHealth("eg_Guard_Generator7") <= 0 then

	Rule_Remove(Rule_Buffer_Guard_Proactive_Army7)
	Rule_Remove(Rule_Guard_Proactive_Army7)
	Rule_Remove(Rule_Guard_Proactive_Army7_Check)

end

end


--[[ Guard Proactive Army 8]]

function Rule_Guard_Proactive_Army8()

t_Guard_Defence_Army8 = {

	sgroup_name = { --[[1]]"sg_Guard_Counter8_1"},  
	
	blueprint = {--[[1]]"guard_squad_hellhound"},
	
	marker_spawn = {--[[1]]"mkr_Guard_Generator8"}, 
	
	stance = {--[[1]]STANCE_Attack},
	
	melee_stance = {--[[1]]MSTANCE_Ranged},
	
	squad_num = {--[[1]] 1}, 
	
	squad_size = {--[[1]] 1}, 
}

local i = g_Guard_Defence_Army8_iter 

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Guard_Defence_Army8.sgroup_name[i], t_Guard_Defence_Army8.blueprint[i], t_Guard_Defence_Army8.marker_spawn[i], t_Guard_Defence_Army8.squad_num[i], t_Guard_Defence_Army8.squad_size[i])
	Cmd_SetStance(t_Guard_Defence_Army8.sgroup_name[i], t_Guard_Defence_Army8.stance[i])
	Cmd_SetMeleeStance(t_Guard_Defence_Army8.sgroup_name[i], t_Guard_Defence_Army8.melee_stance[i])
	Cmd_AttackMoveMarker(t_Guard_Defence_Army8.sgroup_name[i], "mkr_Guard_Target")
			
	elseif g_Guard_Defence_Army8_iter > table.getn(t_Guard_Defence_Army8.sgroup_name) then
			g_Guard_Defence_Army8_iter = 0
			Rule_AddOneShot(Rule_Buffer_Guard_Proactive_Army8, 1)
			Rule_Remove(Rule_Guard_Proactive_Army8)
	end
	g_Guard_Defence_Army8_iter = g_Guard_Defence_Army8_iter+1
			

end

function Rule_Buffer_Guard_Proactive_Army8()

Rule_AddDelay(Rule_Guard_Proactive_Army8, 140)

end

function Rule_Guard_Proactive_Army8_Check()

if EGroup_GetAvgHealth("eg_Guard_Generator8") <= 0 then

	Rule_Remove(Rule_Buffer_Guard_Proactive_Army8)
	Rule_Remove(Rule_Guard_Proactive_Army8)
	Rule_Remove(Rule_Guard_Proactive_Army8_Check)


end

end

function Rule_Prox_Guard_Check5()

if Player_AreSquadsNearMarker(g_Player1, "mkr_Prox_Guard_Check5")  then
		
	Rule_Add(Rule_Guard_Proactive_Army8)
	Rule_Add(Rule_Guard_Proactive_Army8_Check)
	Rule_Remove(Rule_Prox_Guard_Check5)
	
end

end


--[[ Guard Proactive Army 9]]

function Rule_Guard_Proactive_Army9()

t_Guard_Defence_Army9 = {

	sgroup_name = { --[[1]]"sg_Guard_Counter9_1", --[[2]]"sg_Guard_Counter9_2", --[[3]]"sg_Guard_Counter9_3"},  
	
	blueprint = {--[[1]]"guard_squad_guardsmen", --[[2]]"guard_squad_psyker", --[[3]]"guard_squad_guardsmen"},
	
	marker_spawn = {--[[1]]"mkr_Guard_Generator9", --[[2]]"mkr_Guard_Generator9", --[[3]]"mkr_Guard_Generator9"}, 
	
	stance = {--[[1]]STANCE_Attack, --[[2]]STANCE_Attack, --[[3]]STANCE_Attack},
	
	melee_stance = {--[[1]]MSTANCE_Ranged, --[[2]]MSTANCE_Ranged, --[[3]]MSTANCE_Ranged},
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1}, 
	
	squad_size = {--[[1]] 8, --[[2]] 1, --[[3]] 9}, 
}

local i = g_Guard_Defence_Army9_iter 

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Guard_Defence_Army9.sgroup_name[i], t_Guard_Defence_Army9.blueprint[i], t_Guard_Defence_Army9.marker_spawn[i], t_Guard_Defence_Army9.squad_num[i], t_Guard_Defence_Army9.squad_size[i])
	Cmd_SetStance(t_Guard_Defence_Army9.sgroup_name[i], t_Guard_Defence_Army9.stance[i])
	Cmd_SetMeleeStance(t_Guard_Defence_Army9.sgroup_name[i], t_Guard_Defence_Army9.melee_stance[i])
	Cmd_AttackMoveMarker(t_Guard_Defence_Army9.sgroup_name[i], "mkr_Guard_Target")
			
	elseif g_Guard_Defence_Army9_iter > table.getn(t_Guard_Defence_Army9.sgroup_name) then
			g_Guard_Defence_Army9_iter = 0
			Rule_AddOneShot(Rule_Buffer_Guard_Proactive_Army9, 1)
			Rule_Remove(Rule_Guard_Proactive_Army9)
	end
	g_Guard_Defence_Army9_iter = g_Guard_Defence_Army9_iter+1
			

end

function Rule_Buffer_Guard_Proactive_Army9()

Rule_AddIntervalDelay(Rule_Guard_Proactive_Army9, 7, 100)

end

function Rule_Guard_Proactive_Army9_Check()

if EGroup_GetAvgHealth("eg_Guard_Generator9") <= 0 then

	Rule_Remove(Rule_Buffer_Guard_Proactive_Army9)
	Rule_Remove(Rule_Guard_Proactive_Army9)
	Rule_Remove(Rule_Guard_Proactive_Army9_Check)

end

end

--[[ - this proximity check triggers Guard Proactive Army 9, 10 and 11]] function Rule_Prox_Guard_Check6()

if Player_AreSquadsNearMarker(g_Player1, "mkr_Prox_Guard_Check6")  then
		
	Rule_Add(Rule_Guard_Proactive_Army9)
	Rule_Add(Rule_Guard_Proactive_Army9_Check)
	Rule_Add(Rule_Guard_Proactive_Army10)
	Rule_Add(Rule_Guard_Proactive_Army10_Check)
	Rule_Add(Rule_Guard_Proactive_Army11)
	Rule_Add(Rule_Guard_Proactive_Army11_Check)
	Rule_Remove(Rule_Prox_Guard_Check6)
	
elseif Player_AreSquadsNearMarker(g_Player1, "mkr_Prox_Guard_Check6B")  then
	
	Rule_Add(Rule_Guard_Proactive_Army9)
	Rule_Add(Rule_Guard_Proactive_Army9_Check)
	Rule_Add(Rule_Guard_Proactive_Army10)
	Rule_Add(Rule_Guard_Proactive_Army10_Check)
	Rule_Add(Rule_Guard_Proactive_Army11)
	Rule_Add(Rule_Guard_Proactive_Army11_Check)
	Rule_Remove(Rule_Prox_Guard_Check6)
			
end

end


--[[ Guard Proactive Army 10]]

function Rule_Guard_Proactive_Army10()

t_Guard_Defence_Army10 = {

	sgroup_name = { --[[1]]"sg_Guard_Counter10_1", --[[2]]"sg_Guard_Counter10_2"},  
	
	blueprint = {--[[1]]"guard_squad_guardsmen", --[[2]]"guard_squad_guardsmen"},
	
	marker_spawn = {--[[1]]"mkr_Guard_Generator10", --[[2]]"mkr_Guard_Generator10"}, 
	
	stance = {--[[1]]STANCE_Attack, --[[2]]STANCE_Attack},
	
	melee_stance = {--[[1]]MSTANCE_Ranged, --[[2]]MSTANCE_Ranged},
	
	squad_num = {--[[1]] 1, --[[2]] 1}, 
	
	squad_size = {--[[1]] 9, --[[2]] 9}, 
}

local i = g_Guard_Defence_Army10_iter 

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Guard_Defence_Army10.sgroup_name[i], t_Guard_Defence_Army10.blueprint[i], t_Guard_Defence_Army10.marker_spawn[i], t_Guard_Defence_Army10.squad_num[i], t_Guard_Defence_Army10.squad_size[i])
	Cmd_SetStance(t_Guard_Defence_Army10.sgroup_name[i], t_Guard_Defence_Army10.stance[i])
	Cmd_SetMeleeStance(t_Guard_Defence_Army10.sgroup_name[i], t_Guard_Defence_Army10.melee_stance[i])
	Cmd_AttackMoveMarker(t_Guard_Defence_Army10.sgroup_name[i], "mkr_Guard_Target")
			
	elseif g_Guard_Defence_Army10_iter > table.getn(t_Guard_Defence_Army10.sgroup_name) then
			g_Guard_Defence_Army10_iter = 0
			Rule_AddOneShot(Rule_Buffer_Guard_Proactive_Army10, 1)
			Rule_Remove(Rule_Guard_Proactive_Army10)
	end
	g_Guard_Defence_Army10_iter = g_Guard_Defence_Army10_iter+1
			

end

function Rule_Buffer_Guard_Proactive_Army10()

Rule_AddDelay(Rule_Guard_Proactive_Army10, 100)

end

function Rule_Guard_Proactive_Army10_Check()

if EGroup_GetAvgHealth("eg_Guard_Generator10") <= 0 then

	Rule_Remove(Rule_Buffer_Guard_Proactive_Army10)
	Rule_Remove(Rule_Guard_Proactive_Army10)
	Rule_Remove(Rule_Guard_Proactive_Army10_Check)

end

end


--[[ Guard Proactive Army 11]]

function Rule_Guard_Proactive_Army11()

t_Guard_Defence_Army11 = {

	sgroup_name = { --[[1]]"sg_Guard_Counter11_1", --[[2]]"sg_Guard_Counter11_2"},  
	
	blueprint = {--[[1]]"guard_squad_guardsmen", --[[2]]"guard_squad_guardsmen"},
	
	marker_spawn = {--[[1]]"mkr_Guard_Generator11", --[[2]]"mkr_Guard_Generator11"}, 
	
	stance = {--[[1]]STANCE_Attack, --[[2]]STANCE_Attack},
	
	melee_stance = {--[[1]]MSTANCE_Ranged, --[[2]]MSTANCE_Assault},
	
	squad_num = {--[[1]] 1, --[[2]] 1}, 
	
	squad_size = {--[[1]] 10, --[[2]] 6}, 
}

local i = g_Guard_Defence_Army11_iter 

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player4, t_Guard_Defence_Army11.sgroup_name[i], t_Guard_Defence_Army11.blueprint[i], t_Guard_Defence_Army11.marker_spawn[i], t_Guard_Defence_Army11.squad_num[i], t_Guard_Defence_Army11.squad_size[i])
	Cmd_SetStance(t_Guard_Defence_Army11.sgroup_name[i], t_Guard_Defence_Army11.stance[i])

	Cmd_AttackMoveMarker(t_Guard_Defence_Army11.sgroup_name[i], "mkr_Guard_Target")
			
	elseif g_Guard_Defence_Army11_iter > table.getn(t_Guard_Defence_Army11.sgroup_name) then
			g_Guard_Defence_Army11_iter = 0
			Rule_AddOneShot(Rule_Buffer_Guard_Proactive_Army11, 1)
			Rule_Remove(Rule_Guard_Proactive_Army11)
	end
	g_Guard_Defence_Army11_iter = g_Guard_Defence_Army11_iter+1
			

end

function Rule_Buffer_Guard_Proactive_Army11()

Rule_AddIntervalDelay(Rule_Guard_Proactive_Army11, 7,  120)

end

function Rule_Guard_Proactive_Army11_Check()

if EGroup_GetAvgHealth("eg_Guard_Generator11") <= 0 then

	Rule_Remove(Rule_Buffer_Guard_Proactive_Army11)
	Rule_Remove(Rule_Guard_Proactive_Army11)
	Rule_Remove(Rule_Guard_Proactive_Army11_Check)

end

end

--[[ Eldar Army ]]

function Rule_Eldar_Army_Creation()

local i = g_Eldar_Army_iter 

t_Eldar_Army = {

	sgroup_name = { --[[1]]"sg_Eldar_Ranger1", --[[2]]"sg_Eldar1",  --[[4]]"sg_Eldar3", --[[5]]"sg_Eldar5", --[[6]]"sg_Eldar_Ranger2", --[[7]]"sg_Eldar_Ranger3", --[[8]]"sg_Eldar_Ranger4", --[[9]]"sg_Eldar6", --[[10]]"sg_Wraithlord1", --[[11]]"sg_Eldar_Warp_Spiders1", --[[12]]"sg_Eldar_Warp_Spiders2",
	--[[13]]"sg_Eldar_Vyper1", --[[14]]"sg_Eldar_Vyper2", --[[15]]"sg_Eldar_Fire_Prism1", --[[16]]"sg_Eldar8", --[[17]]"sg_Wraithlord2", --[[18]]"sg_Wraithlord3", --[[19]]"sg_Eldar_Warp_Spiders3", --[[20]]"sg_Eldar_Warp_Spiders4", --[[21]]"sg_Eldar9", --[[22]]"sg_Eldar10", --[[23]]"sg_Eldar11"},  
	
	blueprint = {--[[1]]"eldar_squad_rangers", --[[2]]"eldar_squad_dark_reapers",  --[[4]]"eldar_squad_warp_spider", --[[5]]"eldar_squad_dark_reapers", --[[6]]"eldar_squad_rangers", --[[7]]"eldar_squad_rangers", --[[8]]"eldar_squad_rangers", --[[9]]"eldar_squad_banshees", 
	--[[10]]"eldar_squad_wraithlord", --[[11]]"eldar_squad_warp_spider", --[[12]]"eldar_squad_warp_spider", --[[13]]"eldar_squad_vypers", --[[14]]"eldar_squad_vypers", --[[15]]"eldar_squad_fire_prism", --[[16]]"eldar_squad_wraithlord", --[[17]]"eldar_squad_wraithlord", --[[18]]"eldar_squad_wraithlord", 
	--[[19]]"eldar_squad_warp_spider", --[[20]]"eldar_squad_warp_spider", --[[21]]"eldar_squad_banshees", --[[22]]"eldar_squad_banshees", --[[23]]"eldar_squad_falcon_grav_tank"},
	
	marker_spawn = {--[[1]]"mkr_Ork_Eldar1", --[[2]]"mkr_Ork_Eldar2",  --[[4]]"mkr_Ork_Eldar4", --[[5]]"mkr_Ork_Eldar5", --[[6]]"mkr_Ork_Eldar6", --[[7]]"mkr_Ork_Eldar7", --[[8]]"mkr_Ork_Eldar8", --[[9]]"mkr_Ork_Eldar9", --[[10]]"mkr_Ork_Eldar10", --[[11]]"mkr_Ork_Eldar11", 
	--[[12]]"mkr_Ork_Eldar12", --[[13]]"mkr_Ork_Eldar13", --[[14]]"mkr_Ork_Eldar14", --[[15]]"mkr_Ork_Eldar15", --[[16]]"mkr_Ork_Eldar16", --[[17]]"mkr_Ork_Eldar17", --[[18]]"mkr_Ork_Eldar18", --[[19]]"mkr_Ork_Eldar19", --[[20]]"mkr_Ork_Eldar20", --[[21]]"mkr_Ork_Eldar21", --[[22]]"mkr_Ork_Eldar22", 
	--[[23]]"mkr_Ork_Eldar23"}, 
	
	stance = {--[[1]]STANCE_Hold, --[[2]]STANCE_Attack, --[[4]]STANCE_Attack, --[[5]]STANCE_StandGround, --[[6]]STANCE_Hold, --[[7]]STANCE_Hold, --[[8]]STANCE_Hold, --[[9]]STANCE_Attack, --[[10]]STANCE_Attack, --[[11]]STANCE_Hold, 
	--[[12]]STANCE_StandGround, --[[13]]STANCE_StandGround, --[[14]]STANCE_StandGround, --[[15]]STANCE_StandGround, --[[16]]STANCE_StandGround, --[[17]]STANCE_Hold, --[[18]]STANCE_Attack, --[[19]]STANCE_Hold, --[[20]]STANCE_Hold, --[[21]]STANCE_Hold, --[[22]]STANCE_Attack, --[[23]]STANCE_Hold},
	
	melee_stance = {--[[1]]MSTANCE_Ranged, --[[2]]MSTANCE_Ranged,  --[[4]]MSTANCE_Ranged, --[[5]]MSTANCE_Ranged, --[[6]]MSTANCE_Ranged, --[[7]]MSTANCE_Ranged, --[[8]]MSTANCE_Ranged, --[[9]]MSTANCE_Assault, --[[10]]MSTANCE_Assault, --[[11]]MSTANCE_Ranged, 
	--[[12]]MSTANCE_Ranged, --[[13]]MSTANCE_Ranged, --[[14]]MSTANCE_Ranged, --[[15]]MSTANCE_Ranged, --[[16]]MSTANCE_Assault, --[[17]]MSTANCE_Ranged, --[[18]]MSTANCE_Assault, --[[19]]MSTANCE_Ranged, --[[20]]MSTANCE_Ranged, --[[21]]MSTANCE_Assault, --[[22]]MSTANCE_Assault, 
	--[[23]]MSTANCE_Ranged},
	
	squad_num = {--[[1]] 1, --[[2]] 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, --[[20]] 1, --[[21]] 1, --[[22]] 1, --[[23]] 1}, 
	
	squad_size = {--[[1]] 1, --[[2]] 4, --[[4]] 9, --[[5]] 6, --[[6]] 1, --[[7]] 1, --[[8]] 2, --[[9]] 6, --[[10]] 1, --[[11]] 10, --[[12]] 10, --[[13]] 1, --[[14]] 1, --[[15]] 1, --[[16]] 7, --[[17]] 1, --[[18]] 1, --[[19]] 10, --[[20]] 10, --[[21]] 10, --[[22]] 10, --[[23]] 1}, 
}

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player5, t_Eldar_Army.sgroup_name[i], t_Eldar_Army.blueprint[i], t_Eldar_Army.marker_spawn[i], t_Eldar_Army.squad_num[i], t_Eldar_Army.squad_size[i])
	Cmd_SetStance(t_Eldar_Army.sgroup_name[i], t_Eldar_Army.stance[i])
	Cmd_SetMeleeStance(t_Eldar_Army.sgroup_name[i], t_Eldar_Army.melee_stance[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Eldar_Static_Troops"), SGroup_FromName(t_Eldar_Army.sgroup_name[i]))
	Cpu_LockSGroupAcrossPlayers(t_Eldar_Army.sgroup_name[i])
	
	elseif g_Eldar_Army_iter > table.getn(t_Eldar_Army.sgroup_name) then
			g_Eldar_Army_iter = 0

			for i = 1, 4 do
				Cmd_Infiltrate("sg_Eldar_Ranger"..i, true)
				SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Rangers"), SGroup_CreateIfNotFound("sg_Eldar_Ranger"..i))
			end
			
							
			--[[giving the control building on the ork side to the player that is hostile to the orks. Building created under different player for color purposes]]
			EGroup_SetPlayerOwner("eg_Control_Building_Ork", g_Player6)
			Rule_Add(Rule_Infiltration_Reveal)				
			Rule_AddDelay(Rule_Eldar_Proactive_Defence_Army, 6)
			Rule_AddInterval(Rule_Warp_Spider_Jump1, 5)
			Rule_AddInterval(Rule_Warp_Spider_Jump2, 5)
			Rule_AddInterval(Rule_Vyper_Jump1, 5)
			Rule_Remove(Rule_Eldar_Army_Creation)
							
	end
g_Eldar_Army_iter = g_Eldar_Army_iter+1

end

function Rule_Infiltration_Reveal() if g_Current_Player == g_Player1 then if Player_AreSquadsNearMarker(g_Player2, "mkr_Infiltrate_Checker") then

		Cmd_Infiltrate("sg_Rangers", false)
		Cmd_SetStance("sg_Rangers", STANCE_Attack)

		
		Rule_Remove(Rule_Infiltration_Reveal)
	
	end
else

end

end


--[[ Eldar Proactive Army ]]

function Rule_Proactive_Defence_Army_Table()

t_Eldar_Defence_Army = {

	sgroup_name = { --[[1]]"sg_Eldar_Counter1", --[[2]]"sg_Eldar_Counter2", --[[3]]"sg_Eldar_Counter3", --[[4]]"sg_Eldar_Counter4"},  
	
	blueprint = {--[[1]]"eldar_guardian_squad", --[[2]]"eldar_guardian_squad",  --[[3]]"eldar_guardian_squad", --[[4]]"eldar_squad_banshees"},
	
	marker_spawn = {--[[1]]"mkr_Eldar_Counter_BaseA", --[[2]]"mkr_Eldar_Counter_BaseA",  --[[3]]"mkr_Eldar_Counter_BaseA", --[[4]]"mkr_Eldar_Counter_BaseA"}, 
	
	stance = {--[[1]]STANCE_Attack, --[[2]]STANCE_Attack, --[[3]]STANCE_Attack, --[[4]]STANCE_Attack},
	
	melee_stance = {--[[1]]MSTANCE_Assault, --[[2]]MSTANCE_Ranged, --[[3]]MSTANCE_Assault, --[[4]]MSTANCE_Ranged},
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1}, 
	
	squad_size = {--[[1]] 4, --[[2]] 4, --[[3]] 5, --[[4]] 5}, 
}

end

function Rule_Eldar_Proactive_Defence_Army()

local i = g_Eldar_Defence_Army_iter 

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player5, t_Eldar_Defence_Army.sgroup_name[i], t_Eldar_Defence_Army.blueprint[i], t_Eldar_Defence_Army.marker_spawn[i], t_Eldar_Defence_Army.squad_num[i], t_Eldar_Defence_Army.squad_size[i])
	Cmd_SetStance(t_Eldar_Defence_Army.sgroup_name[i], t_Eldar_Defence_Army.stance[i])
	Cmd_SetMeleeStance(t_Eldar_Defence_Army.sgroup_name[i], t_Eldar_Defence_Army.melee_stance[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Proactive_Defenders"), SGroup_CreateIfNotFound(t_Eldar_Defence_Army.sgroup_name[i]))
	
	elseif g_Eldar_Defence_Army_iter > table.getn(t_Eldar_Defence_Army.sgroup_name) then
			g_Eldar_Defence_Army_iter = 0

			Cmd_AttackMoveMarker("sg_Proactive_Defenders", "mkr_Eldar_Target")				
			Rule_AddOneShot(Rule_Buffer_Rule, 1)
			Rule_Remove(Rule_Eldar_Proactive_Defence_Army)
							
	end
	g_Eldar_Defence_Army_iter = g_Eldar_Defence_Army_iter+1
	
		

end

function Rule_Buffer_Rule()

Rule_AddDelay(Rule_Eldar_Proactive_Defence_Army, 120)

end


--[[ Control Building Army ]]

function Rule_Control_Building_Army_Creation()

local i = g_Control_Building_Army_iter 

t_Control_Building_Army = {

	sgroup_name = {--[[1]]"sg_Control_Imp1", --[[2]]"sg_Control_Imp2", --[[3]]"sg_Control_Imp3", --[[4]]"sg_Control_Imp4", --[[5]]"sg_Control_Imp5", 
	--[[6]]"sg_Control_Imp6", --[[7]]"sg_Control_Imp7",	--[[8]]"sg_Control_Eldar1", --[[9]]"sg_Control_Eldar2", --[[10]]"sg_Control_Eldar3", --[[11]]"sg_Control_Eldar4", 
	--[[12]]"sg_Control_Eldar5", --[[13]]"sg_Control_Eldar6", --[[14]]"sg_Control_Eldar7", --[[15]]"sg_Control_Eldar8", --[[16]]"sg_Control_Eldar9", --[[17]]"sg_Farseer"},  
	
	blueprint = {--[[1]]"guard_squad_guardsmen", --[[2]]"guard_squad_kasrkin", --[[3]]"guard_squad_commissar", --[[4]]"guard_squad_guardsmen", 
	--[[5]]"guard_squad_kasrkin", --[[6]]"guard_squad_guardsmen", --[[7]]"guard_squad_guardsmen",--[[8]]"eldar_squad_banshees", 
	--[[9]]"eldar_squad_fire_dragon", --[[10]]"eldar_squad_banshees", --[[11]]"eldar_squad_banshees", --[[12]]"eldar_squad_dark_reapers", 
	--[[13]]"eldar_squad_banshees", --[[14]]"eldar_squad_banshees", --[[15]]"eldar_squad_banshees", --[[16]]"eldar_squad_fire_dragon", 
	--[[17]]"eldar_squad_farseer"},
	
	marker_spawn = {--[[1]]"mkr_Control_Imp1", --[[2]]"mkr_Control_Imp2", --[[3]]"mkr_Control_Imp3", --[[4]]"mkr_Control_Imp4", --[[5]]"mkr_Control_Imp5", 
	--[[6]]"mkr_Control_Imp6", --[[7]]"mkr_Control_Imp7",	--[[8]]"mkr_Control_Eldar1", --[[9]]"mkr_Control_Eldar2", --[[10]]"mkr_Control_Eldar3", 
	--[[11]]"mkr_Control_Eldar4", --[[12]]"mkr_Control_Eldar5", --[[13]]"mkr_Control_Eldar6", --[[14]]"mkr_Control_Eldar7", --[[15]]"mkr_Control_Eldar8", 
	--[[16]]"mkr_Control_Eldar9", --[[17]]"mkr_Eldar_FarseerF"}, 
	
	stance = {--[[1]]STANCE_StandGround, --[[2]]STANCE_Hold, --[[3]]STANCE_StandGround, --[[4]]STANCE_Hold, --[[5]]STANCE_StandGround, --[[6]]STANCE_StandGround, 
	--[[7]]STANCE_StandGround, --[[8]]STANCE_Hold, --[[9]]STANCE_StandGround, --[[10]]STANCE_Hold, --[[11]]STANCE_Hold, --[[12]]STANCE_StandGround, 
	--[[13]]STANCE_Hold, --[[14]]STANCE_Hold, --[[15]]STANCE_Hold, --[[16]]STANCE_StandGround, --[[17]]STANCE_Hold},
	
	melee_stance = {--[[1]]MSTANCE_Ranged, --[[2]]MSTANCE_Assault, --[[3]]MSTANCE_Ranged, --[[4]]MSTANCE_Assault, --[[5]]MSTANCE_Ranged, --[[6]]MSTANCE_Ranged, 
	--[[7]]MSTANCE_Ranged, --[[8]]MSTANCE_Assault, --[[9]]MSTANCE_Ranged, --[[10]]MSTANCE_Assault, --[[11]]MSTANCE_Assault, --[[12]]MSTANCE_Ranged, 
	--[[13]]MSTANCE_Assault, --[[14]]MSTANCE_Assault, --[[15]]MSTANCE_Assault, --[[16]]MSTANCE_Ranged, --[[17]]MSTANCE_Assault}, 
	
	marker_face = {--[[1]]"mkr_Face3", --[[2]]"mkr_Face2", --[[3]]"mkr_Face4", --[[4]]"mkr_Face2", --[[5]]"mkr_Face3", --[[6]]"mkr_Face2", --[[7]]"mkr_Face8", --[[8]]"mkr_Face7", --[[9]]"mkr_Face8", --[[10]]"mkr_Face6", --[[11]]"mkr_Face8", --[[12]]"mkr_Face6", --[[13]]"mkr_Face7",
	--[[14]]"mkr_Face6", --[[15]]"mkr_Face7", --[[16]]"mkr_Face8", --[[17]]"mkr_Face5"},
	
	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}, 
	
	squad_size = {--[[1]] 7, --[[2]] 8, --[[3]] 1, --[[4]] 7, --[[5]] 8, --[[6]] 4, --[[7]] 4, --[[8]] 4, --[[9]] 5, --[[10]] 4, --[[11]] 4, --[[12]] 5, --[[13]] 4, --[[14]] 4, --[[15]] 4, --[[16]] 5, --[[17]] 1}, 
}

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player6, t_Control_Building_Army.sgroup_name[i], t_Control_Building_Army.blueprint[i], t_Control_Building_Army.marker_spawn[i], t_Control_Building_Army.squad_num[i], t_Control_Building_Army.squad_size[i])
		SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Control"), SGroup_CreateIfNotFound(t_Control_Building_Army.sgroup_name[i]))
		Cmd_SetMeleeStance(t_Control_Building_Army.sgroup_name[i], t_Control_Building_Army.melee_stance[i])
		Cmd_SetStance(t_Control_Building_Army.sgroup_name[i], t_Control_Building_Army.stance[i])
		
	
	elseif g_Control_Building_Army_iter > table.getn(t_Control_Building_Army.sgroup_name) then
			
			g_Control_Building_Army_iter = 0
			g_Control_Total = SGroup_GetTotalHealthMax("sg_Control")
			SGroup_DeSpawn("sg_Control")
			Rule_Remove(Rule_Control_Building_Army_Creation)

				
	end
g_Control_Building_Army_iter = g_Control_Building_Army_iter+1

end

function Rule_Control_Health_Check()

if  SGroup_GetTotalHealthCurrent("sg_Control") <= (g_Control_Total * 75)/100 then

	Rule_AddOneShot(Rule_The_Moment, 2)
	Rule_Remove(Rule_Control_Health_Check)

else
		g_Control_Health = 0
end

end

function Rule_The_Moment()

if g_Human_Player == 1 then

	local pos = Marker_GetPosition(Marker_FromName("mkr_Chaos_Drop_Pod1", "basic_marker"))
	local pos2 = Marker_GetPosition(Marker_FromName("mkr_Chaos_Drop_Pod2", "basic_marker"))
	local pos3 = Marker_GetPosition(Marker_FromName("mkr_Chaos_Drop_Pod3", "basic_marker"))
	
	Playlist_Manager( PC_Music, t_music_nis_marine, true, false , {20, 40})
	
	
	Util_CreateSquadsAtMarker(g_Player6, "sg_Control_Avatar", "eldar_squad_avatar", "mkr_Chaos_Avatar", 1)
	Cmd_SetStance("sg_Control_Avatar", STANCE_Attack)
	Cmd_AttackMoveMarker("sg_Control_Avatar","mkr_Guard_Target")

	Util_CreateSquadsAndDropPodIn(g_Player3, "sg_Control_Drop1", "space_marine_squad_tactical", pos, 1, 9)
	Util_CreateSquadsAndDropPodIn(g_Player3, "sg_Control_Drop2", "space_marine_squad_tactical", pos2, 1, 9)
	Util_CreateSquadsAndDropPodIn(g_Player3, "sg_Control_Drop3", "space_marine_squad_tactical", pos3, 1, 9)
	
	SGroup_SetPlayerOwner("sg_Control_Drop1", g_Player6)
	SGroup_SetPlayerOwner("sg_Control_Drop2", g_Player6)
	SGroup_SetPlayerOwner("sg_Control_Drop3", g_Player6)

elseif g_Human_Player == 2 then
	
	local pos = Marker_GetPosition(Marker_FromName("mkr_Ork_Drop_Pod1", "basic_marker"))
	local pos2 = Marker_GetPosition(Marker_FromName("mkr_Ork_Drop_Pod2", "basic_marker"))
	local pos3 = Marker_GetPosition(Marker_FromName("mkr_Ork_Drop_Pod3", "basic_marker"))
	
	Playlist_Manager( PC_Music, t_music_nis_ulthwe, true, false , {20, 40})
	
	Util_CreateSquadsAtMarker(g_Player6, "sg_Control_Avatar", "eldar_squad_avatar", "mkr_Ork_Avatar", 1)
	Cmd_SetStance("sg_Control_Avatar", STANCE_Attack)
	Cmd_AttackMoveMarker("sg_Control_Avatar","mkr_Eldar_Target")

	Util_CreateSquadsAndDropPodIn(g_Player3, "sg_Control_Drop1", "space_marine_squad_tactical", pos, 1, 9)
	Util_CreateSquadsAndDropPodIn(g_Player3, "sg_Control_Drop2", "space_marine_squad_tactical", pos2, 1, 9)
	Util_CreateSquadsAndDropPodIn(g_Player3, "sg_Control_Drop3", "space_marine_squad_tactical", pos3, 1, 9)
	
	SGroup_SetPlayerOwner("sg_Control_Drop1", g_Player6)
	SGroup_SetPlayerOwner("sg_Control_Drop2", g_Player6)
	SGroup_SetPlayerOwner("sg_Control_Drop3", g_Player6)
	
end

end

function Rule_Test()

	t_Player_Ork_Army.marker_spawn ={"mkr_OrkD1", "mkr_OrkD2",  "mkr_OrkD3", "mkr_OrkD4", "mkr_Ork_BossD"}
	t_Player_Ork_Army.squad_num ={2, 2, 2, 2, 1}
	t_Player_Ork_Army.squad_size ={9, 9, 9, 1, 1}

end



--[[ Bases ]]



--[[ Eldar Moving Base ]]

function Rule_Create_Eldar_Base()

local i = g_Create_Eldar_Base 

t_base = {
	egroup_name = {--[[1]]"eg_Base1", --[[2]]"eg_Base2", --[[3]]"eg_Base3", --[[4]]"eg_Base4", --[[5]]"eg_Base5", --[[6]]"eg_Base6", --[[7]]"eg_Base7", --[[8]]"eg_Base8", --[[9]]"eg_Base9"}, 
	
	blueprint = {--[[1]]"eldar_hq", --[[2]]"eldar_webway_gate",  --[[3]]"eldar_warp_generator", --[[4]] "eldar_aspect_portal", --[[5]]"eldar_soul_shrine", --[[6]]"eldar_warp_generator", --[[7]]"eldar_support_portal", --[[8]]"eldar_webway_gate", --[[9]]"eldar_aspect_portal"},
	
	marker_spawn = {--[[1]]"mkr_Eldar_BaseA1", --[[2]]"mkr_Eldar_BaseA2",  --[[3]]"mkr_Eldar_BaseA3", --[[4]]"mkr_Eldar_BaseA4", --[[5]]"mkr_Eldar_BaseA5", --[[6]]"mkr_Eldar_Base_Static4", --[[7]]"mkr_Eldar_Base_Static5", --[[8]]"mkr_Eldar_Base_Static6", --[[9]]"mkr_Eldar_BaseA6"}, 
	
	health = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1, --[[9]] 1}, 
	
}

if g_Create_Eldar_Base <= table.getn(t_base.egroup_name) and (EGroup_Exists(t_base.egroup_name[i]) == false or EGroup_IsEmpty(t_base.egroup_name[i])) then
	
	local sgroupID = Entity_CreateBuildingMarker(g_Player5, t_base.egroup_name[i], t_base.blueprint[i], t_base.marker_spawn[i], t_base.health[i])
	EGroup_AddGroup(EGroup_CreateIfNotFound("eg_Eldar_Base"), EGroup_CreateIfNotFound(t_base.egroup_name[i]))

	
	elseif g_Create_Eldar_Base > table.getn(t_base.egroup_name) then
			g_Create_Eldar_Base = 0
			
			FOW_TagEGroup(g_Player1, "eg_Eldar_Base")
			FOW_TagEGroup(g_Player2, "eg_Eldar_Base")
			Rule_AddOneShot(Rule_Base_Healths, 15)
			Rule_AddInterval(Rule_Eldar_Relocation_Check, 3)
			Rule_AddInterval(Rule_Eldar_Base_Checker, 2)
			Rule_Remove(Rule_Create_Eldar_Base)
		
	end
g_Create_Eldar_Base = g_Create_Eldar_Base+1

end

function Rule_Eldar_Base_Checker()

if EGroup_Exists("eg_Base1") == false then
	
	g_Eldar_Base_Destroy = true
	Rule_Remove(Rule_Eldar_Relocation_Check)
	Util_Ping_Stop("pg_Eldar1")
	Util_Ping_Stop("pg_Eldar2")
	Util_Ping_Stop("pg_Eldar3")
	Util_Ping_Stop("pg_Eldar4")
	
	Rule_Remove(Rule_Buffer_Rule)
	Rule_Remove(Rule_Proactive_Defence_Army_Table)		
	Rule_Remove(Rule_Eldar_Base_Checker)
	
elseif EGroup_Exists("eg_Base1") and EGroup_IsEmpty("eg_Base1") then

	g_Eldar_Base_Destroy = true
	Rule_Remove(Rule_Eldar_Relocation_Check)
	Util_Ping_Stop("pg_Eldar1")
	Util_Ping_Stop("pg_Eldar2")
	Util_Ping_Stop("pg_Eldar3")
	Util_Ping_Stop("pg_Eldar4")
	
	
	Rule_Remove(Rule_Buffer_Rule)
	Rule_Remove(Rule_Proactive_Defence_Army_Table)		
	Rule_Remove(Rule_Eldar_Base_Checker)
	
end

end


--[[ Eldar Static Base ]]

function Rule_Create_Eldar_Static_Base()

local i = g_Create_Eldar_Static_Base

t_base = {
	egroup_name = {--[[1]]"eg_Eldar_Base_Static1", --[[2]]"eg_Eldar_Base_Static2", --[[3]]"eg_Eldar_Base_Static3", --[[7]]"eg_Eldar_Base_Static7", --[[8]]"eg_Eldar_Base_Static8", --[[9]]"eg_Eldar_Base_Static9", --[[10]]"eg_Eldar_Base_Static10",
	--[[11]]"eg_Eldar_Base_Static11", --[[12]]"eg_Eldar_Base_Static12", --[[13]]"eg_Eldar_Base_Static13", --[[14]]"eg_Eldar_Base_Static14", --[[15]]"eg_Eldar_Base_Static15", --[[16]]"eg_Eldar_Base_Static16", --[[17]]"eg_Eldar_Base_Static17", --[[18]]"eg_Eldar_Base_Static18", --[[19]]"eg_Eldar_Base_Static19", --[[20]]"eg_Eldar_Base_Static20",
	--[[21]]"eg_Eldar_Base_Static22", --[[22]]"eg_Eldar_Base_Static22", --[[23]]"eg_Eldar_Base_Static23", --[[24]]"eg_Eldar_Base_Static24", --[[25]]"eg_Eldar_Base_Static25", --[[26]]"eg_Eldar_Base_Static26", --[[27]]"eg_Eldar_Base_Static27", --[[30]]"eg_Eldar_Base_Static30", --[[31]]"eg_Webway_Gate1", 
	--[[32]]"eg_Eldar_Base_Static32", --[[33]]"eg_Webway_Gate2", --[[34]]"eg_Eldar_Base_Static33",   --[[39]]"eg_Eldar_Base_Static38"}, 
	
	blueprint = {--[[1]]"eldar_support_platform_scatterlaser", --[[2]]"eldar_support_platform_scatterlaser", --[[3]]"eldar_support_platform_scatterlaser", --[[7]]"eldar_support_platform_scatterlaser", --[[8]]"eldar_support_platform_scatterlaser", --[[9]]"eldar_support_platform_scatterlaser", --[[10]]"eldar_warp_generator",
	--[[11]]"eldar_warp_generator", --[[12]]"eldar_support_platform_scatterlaser", --[[13]]"eldar_support_platform_scatterlaser", --[[14]]"eldar_support_platform_scatterlaser", --[[15]]"eldar_warp_generator", --[[16]]"eldar_support_platform_scatterlaser", --[[17]]"eldar_aspect_portal", --[[18]]"eldar_support_portal", --[[19]]"eldar_support_platform_scatterlaser", --[[20]]"eldar_support_platform_scatterlaser",
	--[[21]]"eldar_support_platform_scatterlaser", --[[22]]"eldar_support_platform_scatterlaser", --[[23]]"eldar_support_platform_scatterlaser", --[[24]]"eldar_support_platform_scatterlaser", --[[25]]"eldar_warp_generator", --[[26]]"eldar_aspect_portal", --[[27]]"eldar_warp_generator", 
	--[[30]]"eldar_support_platform_scatterlaser", --[[31]]"eldar_webway_gate", --[[32]]"eldar_support_platform_scatterlaser", --[[33]]"eldar_webway_gate", --[[34]]"eldar_support_platform_scatterlaser",  --[[39]]"eldar_support_platform_scatterlaser"},
	
	marker_spawn = {--[[1]]"mkr_Eldar_Base_Static1", --[[2]]"mkr_Eldar_Base_Static2", --[[3]]"mkr_Eldar_Base_Static3", --[[7]]"mkr_Eldar_Base_Static7", --[[8]]"mkr_Eldar_Base_Static8", --[[9]]"mkr_Eldar_Base_Static9", --[[10]]"mkr_Eldar_Base_Static10", 
	--[[11]]"mkr_Eldar_Base_Static11", --[[12]]"mkr_Eldar_Base_Static12", --[[13]]"mkr_Eldar_Base_Static13", --[[14]]"mkr_Eldar_Base_Static14", --[[15]]"mkr_Eldar_Base_Static15", --[[16]]"mkr_Eldar_Base_Static16", --[[17]]"mkr_Eldar_Base_Static17", --[[18]]"mkr_Eldar_Base_Static18", --[[19]]"mkr_Eldar_Base_Static19",
	--[[20]]"mkr_Eldar_Base_Static20", --[[21]]"mkr_Eldar_Base_Static21", --[[22]]"mkr_Eldar_Base_Static22", --[[23]]"mkr_Eldar_Base_Static23", --[[24]]"mkr_Eldar_Base_Static24", --[[25]]"mkr_Eldar_Base_Static25", --[[26]]"mkr_Eldar_Base_Static26", --[[27]]"mkr_Eldar_Base_Static27", 
	--[[30]]"mkr_Eldar_Base_Static30", --[[31]]"mkr_Eldar_Base_Static31", --[[32]]"mkr_Eldar_Base_Static32", --[[33]]"mkr_Eldar_Base_Static33", --[[34]]"mkr_Eldar_Base_Static34",  --[[39]]"mkr_Eldar_Base_Static39"}, 
	
	health = {--[[1]] 1, --[[2]] 1, --[[3]] 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, --[[20]] 1, --[[21]] 1, --[[22]] 1, --[[23]] 1, --[[24]] 1, --[[25]] 1, --[[26]] 1, --[[27]] 1, --[[30]] 1,
	--[[31]] 1, --[[32]] 1, --[[33]] 1, --[[34]] 1,  --[[39]] 1}, 
	
}

if g_Create_Eldar_Static_Base <= table.getn(t_base.egroup_name) and (EGroup_Exists(t_base.egroup_name[i]) == false or EGroup_IsEmpty(t_base.egroup_name[i])) then
	
	local sgroupID = Entity_CreateBuildingMarker(g_Player5, t_base.egroup_name[i], t_base.blueprint[i], t_base.marker_spawn[i], t_base.health[i])
	
	
	elseif g_Create_Eldar_Static_Base > table.getn(t_base.egroup_name) then
			g_Create_Eldar_Static_Base = 0
			
			for i = 1, 4 do
			
				EGroup_ForceAddOn("eg_Strat_Point"..i,"eldar_list_post_addon_1")
			end
			
			for i = 5, 10 do
			
				EGroup_ForceAddOn("eg_Strat_Point"..i,"eldar_list_post_addon_2")
			
			end
			
			for i = 1, 2 do
			
				EGroup_Shroud("eg_Webway_Gate"..i, true)
			
			end

			EGroup_ForceAddOn("eg_Eldar_Base_Static3","eldar_support_platform_addon")
			EGroup_ForceAddOn("eg_Eldar_Base_Static7","eldar_support_platform_addon")
			EGroup_ForceAddOn("eg_Eldar_Base_Static18","eldar_support_platform_addon")
			EGroup_ForceAddOn("eg_Strat_Point11", "eldar_list_post_addon_2")
			Rule_Remove(Rule_Create_Eldar_Static_Base)
		
	end
g_Create_Eldar_Static_Base = g_Create_Eldar_Static_Base+1

end


--[[ Guard Static Base ]]

function Rule_Create_Guard_Static_Base()

local i = g_Create_Guard_Static_Base

t_Guard_base = {
	egroup_name = {--[[1]]"eg_Guard_Base_Static1", --[[2]]"eg_Guard_Base_Static2", --[[3]]"eg_Guard_Base_Static3", --[[4]]"eg_Guard_Base_Static4", --[[5]]"eg_Guard_Base_Static5", --[[6]]"eg_Guard_Generator1", --[[7]]"eg_Guard_Generator2", --[[8]]"eg_Guard_Generator3", --[[9]]"eg_Guard_Generator4",
	--[[10]]"eg_Guard_Generator5", --[[11]]"eg_Guard_Base_Static6", --[[12]]"eg_Guard_Base_Static7", --[[13]]"eg_Guard_Base_Static8", --[[14]]"eg_Guard_Generator6", --[[15]]"eg_Guard_Generator7", --[[16]]"eg_Guard_Generator8", --[[17]]"eg_Guard_Base_Static9", --[[18]]"eg_Guard_Base_Static10", --[[19]]"eg_Guard_Base_Static11",
	--[[20]]"eg_Guard_Base_Static12", --[[21]]"eg_Guard_Base_Static13", --[[22]]"eg_Guard_Generator9", --[[23]]"eg_Guard_Generator10", --[[23]]"eg_Guard_Generator11"}, 
	
	blueprint = {--[[1]]"guard_turret_heavy_bolter", --[[2]]"guard_turret_heavy_bolter", --[[3]]"guard_turret_heavy_bolter", --[[4]]"guard_turret_heavy_bolter", --[[5]]"guard_turret_heavy_bolter", --[[6]]"guard_infantry", --[[7]]"guard_infantry", --[[8]]"guard_infantry", --[[9]]"guard_infantry",
	--[[10]]"guard_infantry", --[[11]]"guard_turret_heavy_bolter", --[[12]]"guard_turret_heavy_bolter", --[[13]]"guard_turret_heavy_bolter", --[[14]]"guard_mechanized", --[[15]]"guard_infantry", --[[16]]"guard_mechanized", --[[17]]"guard_turret_heavy_bolter", --[[18]]"guard_turret_heavy_bolter",
	--[[19]]"guard_turret_heavy_bolter", --[[20]]"guard_turret_heavy_bolter", --[[21]]"guard_turret_heavy_bolter", --[[22]]"guard_infantry", --[[23]]"guard_infantry", --[[24]]"guard_infantry"},
	
	marker_spawn = {--[[1]]"mkr_Guard_Base_Static1", --[[2]]"mkr_Guard_Base_Static2", --[[3]]"mkr_Guard_Base_Static3", --[[4]]"mkr_Guard_Base_Static4", --[[5]]"mkr_Guard_Base_Static5", --[[6]]"mkr_Guard_Base_Static6", --[[7]]"mkr_Guard_Base_Static7", --[[8]]"mkr_Guard_Base_Static8", 
	--[[9]]"mkr_Guard_Base_Static9", --[[10]]"mkr_Guard_Base_Static10", --[[11]]"mkr_Guard_Base_Static11",--[[12]]"mkr_Guard_Base_Static12", --[[13]]"mkr_Guard_Base_Static13", --[[14]]"mkr_Guard_Base_Static14", --[[15]]"mkr_Guard_Base_Static15", --[[16]]"mkr_Guard_Base_Static16",
	--[[17]]"mkr_Guard_Base_Static17", --[[18]]"mkr_Guard_Base_Static18", --[[19]]"mkr_Guard_Base_Static19", --[[20]]"mkr_Guard_Base_Static20", --[[21]]"mkr_Guard_Base_Static21", --[[22]]"mkr_Guard_Base_Static22", --[[23]]"mkr_Guard_Base_Static23", --[[24]]"mkr_Guard_Base_Static24"}, 
	
	health = {--[[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, --[[20]] 1, --[[21]] 1, --[[22]] 1, --[[23]] 1, --[[24]] 1}, 
	
}

if g_Create_Guard_Static_Base <= table.getn(t_Guard_base.egroup_name) and (EGroup_Exists(t_Guard_base.egroup_name[i]) == false or EGroup_IsEmpty(t_Guard_base.egroup_name[i])) then
	
	local sgroupID = Entity_CreateBuildingMarker(g_Player4, t_Guard_base.egroup_name[i], t_Guard_base.blueprint[i], t_Guard_base.marker_spawn[i], t_Guard_base.health[i])
	
	
	elseif g_Create_Guard_Static_Base > table.getn(t_Guard_base.egroup_name) then
			g_Create_Guard_Static_Base = 0
			
			EGroup_ForceAddOn("eg_Chaos_Strat_Point1", "addon_guard_list_post_1")
			EGroup_ForceAddOn("eg_Chaos_Strat_Point3", "addon_guard_list_post_1")
			EGroup_ForceAddOn("eg_Chaos_Strat_Point4", "addon_guard_list_post_1")
			EGroup_ForceAddOn("eg_Chaos_Strat_Point5", "addon_guard_list_post_1")
			
			EGroup_ForceAddOn("eg_Chaos_Strat_Point6", "addon_guard_list_post_2")
			EGroup_ForceAddOn("eg_Chaos_Strat_Point11", "addon_guard_list_post_2")
			EGroup_ForceAddOn("eg_Chaos_Strat_Point12", "addon_guard_list_post_2")
			
			Rule_AddInterval(Rule_Prox_Guard_Check1, 5)
			Rule_AddInterval(Rule_Prox_Guard_Check2, 5)
			Rule_AddIntervalDelay(Rule_Prox_Guard_Check3, 5, 60)
			Rule_AddIntervalDelay(Rule_Prox_Guard_Check4, 5, 160)
			Rule_AddIntervalDelay(Rule_Prox_Guard_Check5, 5, 120)
			Rule_AddIntervalDelay(Rule_Prox_Guard_Check6, 5, 320)
			Rule_Remove(Rule_Create_Guard_Static_Base)
		
	end
g_Create_Guard_Static_Base = g_Create_Guard_Static_Base+1

end


--[[ Semi AI Eldar Army]]

function Rule_Eldar_AI_Kickoff()

Player_SetAllResources(g_Player5, 1000, 1000)
	
Cpu_Enable(g_Player5, true)
Cpu_SetDifficulty(g_Player5,  AD_Advanced)
Player_SetMaxSquadCap( g_Player5, 100 )
Player_SetSquadCap( g_Player5, 100 )
	

end


--[[ Relocation ]]

function Rule_Eldar_Relocation_Check()

if EGroup_Exists("eg_Eldar_Base") and EGroup_IsEmpty("eg_Eldar_Base") == false and  g_Stage == 2 and g_On == true then
	
	
	Cmd_EGroupRelocateMarker("eg_Eldar_Base", "mkr_Relocate1", 50)

	
	Util_Ping_LoopingMkr("pg_Eldar1", "mkr_Eldar_BaseB2")		

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

	FOW_TagEGroup(g_Player1, "eg_Eldar_Base")
	FOW_TagEGroup(g_Player2, "eg_Eldar_Base")
	g_Jump = 1
	g_On = false
	
	table.remove(t_Eldar_Defence_Army.marker_spawn, 1)
	table.remove(t_Eldar_Defence_Army.marker_spawn, 1)
	table.remove(t_Eldar_Defence_Army.marker_spawn, 1)
	table.remove(t_Eldar_Defence_Army.marker_spawn, 1)
	table.insert(t_Eldar_Defence_Army.marker_spawn, "mkr_Eldar_Counter_BaseB")
	table.insert(t_Eldar_Defence_Army.marker_spawn, "mkr_Eldar_Counter_BaseB")
	table.insert(t_Eldar_Defence_Army.marker_spawn, "mkr_Eldar_Counter_BaseB")
	table.insert(t_Eldar_Defence_Army.marker_spawn, "mkr_Eldar_Counter_BaseB")
	table.remove(t_Eldar_Defence_Army.blueprint, 1)
	table.insert(t_Eldar_Defence_Army.blueprint, 1, "eldar_squad_banshees")

elseif EGroup_Exists("eg_Eldar_Base") and EGroup_IsEmpty("eg_Eldar_Base") == false and g_Stage == 3 and g_On == true then
	
	Cmd_EGroupRelocateMarker("eg_Eldar_Base", "mkr_Relocate2", 50)
	
	Util_Ping_Stop("pg_Eldar1")
	Util_Ping_LoopingMkr("pg_Eldar2", "mkr_Eldar_BaseC2")
	FOW_TagEGroup(g_Player1, "eg_Eldar_Base")
	FOW_TagEGroup(g_Player2, "eg_Eldar_Base")
	g_Jump = 2
	g_On = false
	
	table.remove(t_Eldar_Defence_Army.marker_spawn, 1)
	table.remove(t_Eldar_Defence_Army.marker_spawn, 1)
	table.remove(t_Eldar_Defence_Army.marker_spawn, 1)
	table.remove(t_Eldar_Defence_Army.marker_spawn, 1)
	table.insert(t_Eldar_Defence_Army.marker_spawn, "mkr_Eldar_Counter_BaseC")
	table.insert(t_Eldar_Defence_Army.marker_spawn, "mkr_Eldar_Counter_BaseC")
	table.insert(t_Eldar_Defence_Army.marker_spawn, "mkr_Eldar_Counter_BaseC")
	table.insert(t_Eldar_Defence_Army.marker_spawn, "mkr_Eldar_Counter_BaseC")
	table.remove(t_Eldar_Defence_Army.blueprint, 2)
	table.insert(t_Eldar_Defence_Army.blueprint, 2, "eldar_squad_dark_reapers")

elseif EGroup_Exists("eg_Eldar_Base") and EGroup_IsEmpty("eg_Eldar_Base") == false and g_Stage == 4 and g_On == true then

	
	Cmd_EGroupRelocateMarker("eg_Eldar_Base", "mkr_Relocate3", 50)
	
	
	Playlist_Manager( PC_Music, t_music_stage2, true, true , {20, 40})
	
			
--	Util_Ping_Stop("pg_Eldar2")
--	Util_Ping_LoopingMkr("pg_Eldar3", "mkr_Eldar_BaseD2")
	FOW_TagEGroup(g_Player1, "eg_Eldar_Base")
	FOW_TagEGroup(g_Player2, "eg_Eldar_Base")
	g_Jump = 3
	g_On = false
	
		table.remove(t_Eldar_Defence_Army.marker_spawn, 1)
		table.remove(t_Eldar_Defence_Army.marker_spawn, 1)
		table.remove(t_Eldar_Defence_Army.marker_spawn, 1)
		table.remove(t_Eldar_Defence_Army.marker_spawn, 1)
		table.insert(t_Eldar_Defence_Army.marker_spawn, "mkr_Eldar_Counter_BaseD")
		table.insert(t_Eldar_Defence_Army.marker_spawn, "mkr_Eldar_Counter_BaseD")
		table.insert(t_Eldar_Defence_Army.marker_spawn, "mkr_Eldar_Counter_BaseD")
		table.insert(t_Eldar_Defence_Army.marker_spawn, "mkr_Eldar_Counter_BaseD")
		table.remove(t_Eldar_Defence_Army.blueprint, 3)
		table.insert(t_Eldar_Defence_Army.blueprint, 3, "eldar_squad_banshees")
	
elseif EGroup_Exists("eg_Eldar_Base") and EGroup_IsEmpty("eg_Eldar_Base") == false and g_Stage == 5 and g_On == true then

	
	Cmd_EGroupRelocateMarker("eg_Eldar_Base", "mkr_Relocate4", 50)
	
	Playlist_Manager( PC_Music, t_music_stage3, true, false , {20, 40})
	
	Util_Ping_Stop("pg_Eldar2")
--	Util_Ping_Stop("pg_Eldar3")
	Util_Ping_LoopingMkr("pg_Eldar4", "mkr_Eldar_BaseE2")
	FOW_TagEGroup(g_Player1, "eg_Eldar_Base")
	FOW_TagEGroup(g_Player2, "eg_Eldar_Base")
	g_Jump = 4
	g_On = false
	
	table.remove(t_Eldar_Defence_Army.marker_spawn, 1)
	table.remove(t_Eldar_Defence_Army.marker_spawn, 1)
	table.remove(t_Eldar_Defence_Army.marker_spawn, 1)
	table.remove(t_Eldar_Defence_Army.marker_spawn, 1)
	table.insert(t_Eldar_Defence_Army.marker_spawn, "mkr_Eldar_Counter_BaseE")
	table.insert(t_Eldar_Defence_Army.marker_spawn, "mkr_Eldar_Counter_BaseE")
	table.insert(t_Eldar_Defence_Army.marker_spawn, "mkr_Eldar_Counter_BaseE")
	table.insert(t_Eldar_Defence_Army.marker_spawn, "mkr_Eldar_Counter_BaseE")
	table.remove(t_Eldar_Defence_Army.blueprint, 3)
	table.insert(t_Eldar_Defence_Army.blueprint, 3, "eldar_squad_banshees")
	

	Rule_AddIntervalDelay(Rule_Create_Prism, 35, 10)
	
elseif EGroup_Exists("eg_Eldar_Base") and EGroup_IsEmpty("eg_Eldar_Base") == false and g_Stage == 6 and g_On == true then

	g_On = false
	Entity_CreateBuildingMarker(g_Player5, "eg_Final_Webway_Gate", "eldar_webway_gate", "mkr_Relocate5", 1)
	Rule_AddDelay(Rule_Relocation_Victory, 310)
	
	Rule_Remove(Rule_Proactive_Defence_Army_Table)
	
	Rule_Remove(Rule_Eldar_Relocation_Check)
end

end

function Rule_Relocation_Victory()

if EGroup_Exists("eg_Base1") and EGroup_IsEmpty("eg_Base1") == false then
	Cmd_EGroupRelocateMarker("eg_Base1", "mkr_Relocate5", 50)
	Rule_Remove(Rule_Relocation_Victory)
else
	Rule_Remove(Rule_Relocation_Victory)
end

end

function Rule_Create_Prism()

if g_Prism <= 1 then

	Util_CreateSquadsAtMarker(g_Player5, "sg_Fire_Prism", "eldar_squad_fire_prism", "mkr_Fire_Prism", 1)

	g_Prism = g_Prism +1

elseif g_Prism >= 2 then

	Cmd_AttackEGroup("sg_Fire_Prism", "eg_Control_Building_Ork")
	
	Rule_Add(Rule_Eldar_Victory_Check)
	Rule_Remove(Rule_Create_Prism)
	
end

end

function Rule_Eldar_Victory_Check()

local pos = EGroup_GetPosition(EGroup_FromName("eg_Base1"))

if Marker_InProximity(Marker_FromName("mkr_Relocate5", "basic_marker"), pos) then

	g_Chaos_Objectives = 100
	Rule_Remove(Rule_Eldar_Victory_Check)

end

end


--[[ Eldar Farseer Eldrictch Storm use ]]

--[[check to see if the farseer has arrived at her final stand]] function Rule_Farseer_Last_Stand_Point()

if Prox_AllSquadsNearMarker("sg_Farseer", "mkr_Eldar_FarseerF") then

	--[[once there it triggers the check for her to use eldritch storm]]
	Rule_AddInterval(Rule_Eldrictch_Storm_Use, 1)
	Rule_Remove(Rule_Farseer_Last_Stand_Point)

end

end

function Rule_Eldrictch_Storm_Use()

for i = 1, 6 do
	
	SGroup_Clear(SGroup_CreateIfNotFound("sg_Eldritch_Target"..i))
	Player_GetAllSquadsNearMarker(g_Current_Player, "sg_Eldritch_Target"..i, "mkr_Farseer_Target"..i)
	
	if SGroup_CountSpawned(SGroup_FromName("sg_Eldritch_Target"..i)) >= 3 and g_Ability == true then
		local pos= Marker_GetPosition(Marker_FromName("mkr_Farseer_Target"..i, "basic_marker"))
		Cmd_CastAbilityMarker("sg_Farseer","eldar_eldritchstorm",pos)
		g_Ability = false
		Rule_AddInterval(Rule_Ability_Timer)

	end
end

end

--[[this needs to be tied in to the recharge rate; if the recharge rate of eldritch storm is sped up this needs to be modified accordingly]] function Rule_Ability_Timer()

if g_Ability_Timer >= 180 then

	g_Ability = true
	Rule_Remove(Rule_Ability_Timer)
	
else

	g_Ability_Timer = g_Ability_Timer +1
end

end

function Rule_Farseer_Checker()

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

	g_Farseer = true
	
	Sound_PlayStinger("stinger_msd4_deathofthefarseer")
	Rule_Remove(Rule_Farseer_Checker)
	
elseif SGroup_Exists("sg_Farseer") == false then
	Sound_PlayStinger("stinger_msd4_deathofthefarseer")
	g_Farseer = true
	Rule_Remove(Rule_Farseer_Checker)
end

end


--[[ Eldar Base Health Check ]]

function Rule_Game_Timer()

g_time = g_time+1

end

function Rule_Base_Healths()

Rule_Add(Rule_Eldar_Health1)
g_Base_Health = EGroup_GetTotalHealthMax("eg_Eldar_Base")

end

function Rule_Eldar_Health1()

if g_time == 60 then

	g_Stage = 2
	g_On = true
	g_Jump = 1
	Rule_Remove(Rule_Eldar_Health1)
	Rule_AddDelay(Rule_Eldar_Health2, 25)
end

end

function Rule_Eldar_Health2()

if g_time == 400 then


	g_Stage = 3
	g_On = true
	g_Jump = 2
	Rule_Remove(Rule_Eldar_Health2)
	Rule_AddDelay(Rule_Eldar_Health3, 25)
end

end

function Rule_Eldar_Health3()

if g_time == 640 then


	g_Stage = 4
	g_On = true
	g_Jump = 3
	Rule_Remove(Rule_Eldar_Health3)
	Rule_AddDelay(Rule_Eldar_Health4, 25)
end

end

function Rule_Eldar_Health4()

if g_time == 1250 then

	g_Stage = 5
	g_On = true
	g_Jump = 4
	Rule_Remove(Rule_Eldar_Health4)
end

end


--[[ Reinforcement of non controlled human player ]]

--[[ - this is to keep as best possible the squads exisiting and reinforced for the side that the player is not currently controlling.]]

--[[g_Current_Player must be set in the switch NiS g_Player_Squads = Player_GetSquadCount(g_Current_Player) must be set in the switch NiS g_Spawn_Marker must be set in the switch NiS

]]

function Rule_Player_Squad_Reinforcement_Army()

t_Npc_Reinforcement_Army = {

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

t_Trooper_Number = {}

Rule_Add(Rule_Setting_Npc_Table)

end

function Rule_Setting_Npc_Table()

SGroup_CreateIfNotFound("sg_Npc_Army")
SGroup_Clear("sg_Npc_Army")
SGroup_AddGroup(SGroup_FromName("sg_Npc_Army"), Player_GetSquads(g_Current_Player))

g_Player_Squads = SGroup_CountSpawned(SGroup_FromName("sg_Temporary_Group"))


for i = 1, g_Player_Squads do
		
	local SquadID = SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Npc_Army"), i)
	table.insert(t_Trooper_Number, Squad_Count(SquadID))
	
	SGroup_CreateIfNotFound("sg_Npc_Squad"..i)
	SGroup_Clear(SGroup_FromName("sg_Npc_Squad" ..i))
	SGroup_Add(SGroup_FromName("sg_Npc_Squad" ..i), SquadID)
	local Blueprint = Squad_GetBlueprintName(SquadID)
	
	if  Blueprint ~= "chaos_squad_lord" and  Blueprint ~= "ork_squad_warboss" then
	
		table.insert(t_Npc_Reinforcement_Army.sgroup_name, "sg_Npc_Squad" ..i)
		table.insert(t_Npc_Reinforcement_Army.blueprint, Blueprint)
		table.insert(t_Npc_Reinforcement_Army.marker_spawn, g_Spawn_Marker)
		table.insert(t_Npc_Reinforcement_Army.stance, STANCE_StandGround)
		table.insert(t_Npc_Reinforcement_Army.squad_num, 1)
		table.insert(t_Npc_Reinforcement_Army.squad_size, 9)
				
	end
end

Rule_Add(Rule_Npc_Reinforcement_Army)
Rule_Add(Rule_Npc_Squad_Reinforcement)
Rule_Remove(Rule_Setting_Npc_Table)

end

function Rule_Npc_Reinforcement_Army()

local i = g_Npc_Reinforcement_Army_iter 

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Current_Player, t_Npc_Reinforcement_Army.sgroup_name[i], t_Npc_Reinforcement_Army.blueprint[i], t_Npc_Reinforcement_Army.marker_spawn[i], t_Npc_Reinforcement_Army.squad_num[i], t_Npc_Reinforcement_Army.squad_size[i])
	Cmd_SetStance(t_Npc_Reinforcement_Army.sgroup_name[i], t_Npc_Reinforcement_Army.stance[i])

			
	elseif g_Npc_Reinforcement_Army_iter > table.getn(t_Npc_Reinforcement_Army.sgroup_name) then
			g_Npc_Reinforcement_Army_iter = 0

							
	end
	g_Npc_Reinforcement_Army_iter = g_Npc_Reinforcement_Army_iter+1
	
		

end

function Rule_Npc_Squad_Reinforcement()

for i = 1, g_Player_Squads do

	if SGroup_Exists("sg_Npc_Squad"..i) and SGroup_IsEmpty("sg_Npc_Squad"..i) == false
	and	Squad_Count(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Npc_Squad" ..i), 1)) < t_Trooper_Number[i] then
	local Troopers_Needed = t_Trooper_Number[i] - Squad_Count(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_Npc_Squad" ..i), 1)) 
		Cmd_ReinforceTrooper("sg_Npc_Squad" ..i, Troopers_Needed)

	end
end

end



--[[ Enemy Tricks ]]


function Rule_Warp_Spider_Jump1()

if g_Current_Player == g_Player1 then

	if Player_AreSquadsNearMarker(g_Player2, "mkr_Ork_Eldar11") then
	
		Cmd_JumpToMarker("sg_Eldar_Warp_Spiders1", "mkr_Ork_Eldar11_Target")
		Cmd_JumpToMarker("sg_Eldar_Warp_Spiders2", "mkr_Ork_Eldar12_Target")
		Cmd_SetStance("sg_Eldar_Warp_Spiders1", STANCE_Attack)
		Cmd_SetStance("sg_Eldar_Warp_Spiders2", STANCE_Attack)
		Cmd_SetStance("sg_Eldar8", STANCE_Attack)
		

		Rule_Remove(Rule_Warp_Spider_Jump1)
		
	end
else
	
	
end	
	

end

function Rule_Warp_Spider_Jump2()

if g_Current_Player == g_Player1 then 
	if Player_AreSquadsNearMarker(g_Player2, "mkr_Warp_Check1") then
	
		Cmd_JumpToMarker("sg_Eldar_Warp_Spiders3", "mkr_Ork_Eldar19_Target")
		Cmd_JumpToMarker("sg_Eldar_Warp_Spiders4", "mkr_Ork_Eldar20_Target")
		Cmd_SetStance("sg_Eldar_Warp_Spiders3", STANCE_Attack)
		Cmd_SetStance("sg_Eldar_Warp_Spiders4", STANCE_Attack)
		Cmd_SetStance("sg_Eldar9", STANCE_Attack)
		Rule_Remove(Rule_Warp_Spider_Jump2)
	
	elseif Player_AreSquadsNearMarker(g_Player2, "mkr_Warp_Check2") then
	
		Cmd_JumpToMarker("sg_Eldar_Warp_Spiders3", "mkr_Ork_Eldar19B_Target")
		Cmd_JumpToMarker("sg_Eldar_Warp_Spiders4", "mkr_Ork_Eldar20B_Target")
		Cmd_SetStance("sg_Eldar_Warp_Spiders3", STANCE_Attack)
		Cmd_SetStance("sg_Eldar_Warp_Spiders4", STANCE_Attack)
		Cmd_SetStance("sg_Eldar9", STANCE_Attack)
		Cmd_AttackMoveMarker("sg_Eldar9", "mkr_Warp_Check2")
		Rule_Remove(Rule_Warp_Spider_Jump2)
		
	end
else

end

end

function Rule_Vyper_Jump1() if g_Current_Player == g_Player1 then

	if Player_AreSquadsNearMarker(g_Player2, "mkr_Vyper_Jump_Check") then
	
		Cmd_JumpToMarker("sg_Eldar_Vyper1", "mkr_Ork_Eldar13_Target")
		
		Rule_AddOneShot(Rule_Vyper1_Command, 5)
		Rule_Remove(Rule_Vyper_Jump1)
		
	end

else

end

end

function Rule_Vyper1_Command()

	Cmd_SetStance("sg_Eldar_Vyper1", STANCE_Attack)
	Cmd_SetStance("sg_Eldar_Vyper2", STANCE_Attack)
	Cmd_AttackMoveMarker("sg_Eldar_Vyper1", "mkr_Eldar_Target")
	Rule_Remove(Rule_Vyper1_Command)

end


--[[ Convoy ]]

function Rule_TitanCrew_Create()

local i = g_Escort 

t_convoy_escort = {
	
	sgroup_name = {--[[1]] "sg_Escort1", --[[2]] "sg_Escort2", --[[3]] "sg_Escort3", --[[4]] "sg_Escort4", --[[5]] "sg_Escort5", --[[6]] "sg_Escort6", --[[7]] "sg_Escort7", --[[8]] "sg_Escort8"},  
	
	blueprint = {--[[1]]"space_marine_squad_tactical", --[[2]]"space_marine_squad_tactical", --[[3]]"space_marine_squad_tactical", --[[4]]"space_marine_squad_tactical", --[[5]]"space_marine_squad_tactical", --[[6]]"space_marine_squad_tactical",
	--[[7]]"space_marine_squad_tactical", --[[8]]"space_marine_squad_tactical"},
	
	marker_spawn = {--[[1]]"mkr_Convoy1", --[[2]]"mkr_Convoy1", --[[3]]"mkr_Convoy1", --[[4]]"mkr_Convoy1", --[[5]]"mkr_Convoy1", --[[6]]"mkr_Convoy1", --[[7]]"mkr_Convoy1", --[[8]]"mkr_Convoy1"}, 
	
	weapon = {--[[1]]"space_marine_plasma_gun", --[[2]]"space_marine_flamer_tactical", --[[3]]"space_marine_plasma_gun", --[[4]]"space_marine_plasma_gun", --[[5]]"space_marine_flamer_tactical", --[[6]]"space_marine_bolter_tactical", --[[7]]"space_marine_bolter_tactical",
	--[[8]]"space_marine_bolter_tactical"},
	
	stance ={--[[1]]STANCE_StandGround, --[[2]]STANCE_StandGround, --[[3]]STANCE_StandGround, --[[4]]STANCE_StandGround, --[[5]]STANCE_StandGround, --[[6]]STANCE_StandGround, --[[7]]STANCE_StandGround, --[[8]]STANCE_StandGround},
	
	squad_num = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 
	
	squad_size = {--[[1]] 1, --[[2]] 1, --[[3]] 1, --[[4]] 1, --[[5]] 1, --[[6]] 1, --[[7]] 1, --[[8]] 1}, 

}

if g_Escort <= table.getn(t_convoy_escort.sgroup_name) and (SGroup_Exists(t_convoy_escort.sgroup_name[i]) == false or SGroup_IsEmpty(t_convoy_escort.sgroup_name[i])) then
	
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_convoy_escort.sgroup_name[i], t_convoy_escort.blueprint[i], t_convoy_escort.marker_spawn[i], t_convoy_escort.squad_num[i], t_convoy_escort.squad_size[i])
	Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName(t_convoy_escort.sgroup_name[i]), 1), t_convoy_escort.weapon[i], 1)
	Cmd_SetStance(t_convoy_escort.sgroup_name[i], t_convoy_escort.stance[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_convoyescort"), SGroup_FromName(t_convoy_escort.sgroup_name[i]))
	
	elseif g_Escort > table.getn(t_convoy.sgroup_name) then
			g_Escort = 0
			
	local sgroupID2 = Util_CreateSquadsAtMarkerEx(g_Player3, "sg_convoyleader", "space_marine_squad_chaplain", "mkr_Convoy1", 1, 1)
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_convoyescort"), sgroupID2)
	
	Rule_Remove(Rule_TitanCrew_Create)
	end
g_Escort = g_Escort+1

end

function Rule_TitanCrew_EscortMove() if SGroup_IsEmpty("sg_Convoy") == false and SGroup_IsEmpty("sg_Convoy") == false then local pos = SGroup_GetPosition(SGroup_FromName("sg_Convoy")) Cmd_MoveToSGroup("sg_convoyescort", "sg_Convoy") end end

function Rule_Convoy_Maker()

local i = g_Convoy_Maker 

	t_convoy = {
	sgroup_name = { "sg_Convoy"},  
	blueprint = {"space_marine_squad_land_raider"},
	marker_spawn = {"mkr_Convoy1"}, 
	squad_num = {1}, 
	squad_size = {1}, 
}

if g_Convoy_Maker <= table.getn(t_convoy.sgroup_name) and (SGroup_Exists(t_convoy.sgroup_name[i]) == false or SGroup_IsEmpty(t_convoy.sgroup_name[i])) then
	
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_convoy.sgroup_name[i], t_convoy.blueprint[i], t_convoy.marker_spawn[i], t_convoy.squad_num[i], t_convoy.squad_size[i])
				
	elseif g_Convoy_Maker > table.getn(t_convoy.sgroup_name) then
			g_Convoy_Maker = 0
			
			local ModID = Modifier_Create(MAT_EntityType, "speed_maximum_modifier", MUT_Multiplication, false, 0.088 , "land_raider")
			Modifier_ApplyToPlayer( ModID, g_Player3 )
			
			local ModID2 = Modifier_Create(MAT_EntityType, "health_maximum_modifier", MUT_Multiplication, false, 5 , "space_marine_tactical_bolter")
			Modifier_ApplyToPlayer( ModID2, g_Player3 )
			
			local ModID2 = Modifier_Create(MAT_EntityType, "health_maximum_modifier", MUT_Multiplication, false, 5 , "chaplain")
			Modifier_ApplyToPlayer( ModID2, g_Player3 )
			
			FOW_TagSGroup(g_Player1, "sg_Convoy")
			FOW_TagSGroup(g_Player2, "sg_Convoy")
			
			Rule_Remove(Rule_Convoy_Maker)
			Rule_Add(Rule_Convoy_Move)
			Rule_AddInterval(Rule_Mark1, 5)
			Rule_Add(Rule_Create_Eldar_Base)
			Rule_Add(Rule_Create_Eldar_Static_Base)
			Rule_Add(Rule_Create_Guard_Static_Base)
			Rule_AddIntervalDelay(Rule_TitanCrew_EscortMove, 25, 15)
			
			Rule_Add(Rule_Convoy_Health)
			
			g_destination = "mkr_Convoy2"
		
	end
g_Convoy_Maker = g_Convoy_Maker+1

end

function Rule_Convoy_Move()

local i = g_Move_iter 

--[[ Create Army ]]
if g_Move_iter <= table.getn(t_convoy.sgroup_name) then 
	
	Cmd_MoveToMarker(t_convoy.sgroup_name[i], g_destination)
	
elseif g_Move_iter > table.getn(t_convoy.sgroup_name) then

	Rule_Remove(Rule_Convoy_Move)
	
end

g_Move_iter = g_Move_iter+1

end

function Rule_Mark1()

if Player_AreSquadsNearMarker(g_Player3, "mkr_Convoy2") then
		Util_Ping_LoopingMkr("pg_Stop1", "mkr_Convoy2")
		Rule_AddInterval(Rule_TA1, 5)
		Rule_Remove(Rule_Mark1)
end

end

function Rule_TA1()

if g_Human_Player == 1 then
	Rule_AddOneShot(Rule_TA2, g_Wait)
	Rule_Remove(Rule_TA1)
	
else 
	Rule_AddOneShot(Rule_TA2, 120)
	Rule_Remove(Rule_TA1)
end

end

function Rule_TA2()

g_Move_iter = 1
g_destination = "mkr_Convoy3"
Rule_Add(Rule_Convoy_Move)
Util_Ping_Stop("pg_Stop1")
Rule_AddInterval(Rule_Mark2, 5)

end

function Rule_Mark2()

if Player_AreSquadsNearMarker(g_Player3, "mkr_Convoy3") then

	g_Move_iter = 1
	g_destination = "mkr_Convoy4"
	Rule_Add(Rule_Convoy_Move)
	Rule_Add(Rule_Mark3)
	Rule_Remove(Rule_Mark2)

end

end

function Rule_Mark3()

if Player_AreSquadsNearMarker(g_Player3, "mkr_Convoy4") then

		g_Move_iter = 1
		g_destination = "mkr_Convoy5"
		Rule_Add(Rule_Convoy_Move)
		Rule_Add(Rule_Mark4)
		Rule_Remove(Rule_Mark3)
end

end

function Rule_Mark4()

if Player_AreSquadsNearMarker(g_Player3, "mkr_Convoy5") then

		Rule_AddInterval(Rule_TB1C, 5)
		Util_Ping_LoopingMkr("pg_Stop2", "mkr_Convoy5")
		Rule_Remove(Rule_Mark4)

end

end

function Rule_TB1C()

Anim_PlayEGroupAnim("eg_Door1", "die") Rule_AddOneShot(Rule_TB1, 9) Rule_Remove(Rule_TB1C)

end

function Rule_TB1()

	EGroup_DeSpawn("eg_Door1")
	Rule_AddOneShot(Rule_TB2, 10)
	
	Rule_Remove(Rule_TB1)

end

function Rule_TB2()

g_Move_iter = 1
g_destination = "mkr_Convoy6"
Rule_Add(Rule_Convoy_Move)
Util_Ping_Stop("pg_Stop2")
Rule_AddInterval(Rule_Mark5, 5)
	

end

function Rule_Mark5()

if Player_AreSquadsNearMarker(g_Player3, "mkr_Convoy6") then

		EGroup_ReSpawn("eg_Door1")
		Anim_PlayEGroupAnim("eg_Door1", "default")
		Rule_AddInterval(Rule_TB1B, 5)
		Rule_Remove(Rule_Mark5)
end

end

function Rule_TB1B()

	Rule_AddOneShot(Rule_TB2B1, 9)
	Anim_PlayEGroupAnim("eg_Door2", "die")
	Rule_Remove(Rule_TB1B)

end

function Rule_TB2B1()

EGroup_DeSpawn("eg_Door2")
Rule_AddOneShot(Rule_TB2B,g_Wait)

end

function Rule_TB2B()

	g_Move_iter = 1
	g_destination = "mkr_Convoy7"
	Rule_Add(Rule_Convoy_Move)
	Rule_AddInterval(Rule_Mark6, 5)

end

function Rule_Mark6()

if Player_AreSquadsNearMarker(g_Player3, "mkr_Convoy7") then

		Rule_AddInterval(Rule_TC1, 5)
		Util_Ping_LoopingMkr("pg_Stop3", "mkr_Convoy7")
		Rule_Remove(Rule_Mark6)
end

end

function Rule_TC1()

EGroup_ReSpawn("eg_Door2")
Anim_PlayEGroupAnim("eg_Door2", "default")
Rule_AddOneShot(Rule_TC2, g_Wait)
Rule_Remove(Rule_TC1)

end

function Rule_TC2()

g_Move_iter = 1
g_destination = "mkr_Convoy8"
Rule_Add(Rule_Convoy_Move)
Util_Ping_Stop("pg_Stop3")
Rule_AddInterval(Rule_Mark7, 5)
	

end

function Rule_Mark7()

if Player_AreSquadsNearMarker(g_Player3, "mkr_Convoy8") then

		g_Move_iter = 1
		g_destination = "mkr_Convoy9"
		Rule_Add(Rule_Convoy_Move)
		Rule_AddInterval(Rule_Mark8, 5)
		Rule_Remove(Rule_Mark7)
end

end

function Rule_Mark8()

if Player_AreSquadsNearMarker(g_Player3, "mkr_Convoy9") then

		Rule_AddOneShot(Rule_TC3, g_Wait)
		Util_Ping_LoopingMkr("pg_Stop4", "mkr_Convoy9")
		Rule_Remove(Rule_Mark8)

end

end

function Rule_TC3()

Rule_AddOneShot(Rule_TC4, g_Wait)

end

function Rule_TC4()

	g_Move_iter = 1
	g_destination = "mkr_Convoy10"
	Rule_Add(Rule_Convoy_Move)
	Util_Ping_Stop("pg_Stop4")
	Rule_AddInterval(Rule_Mark9, 5)

end

function Rule_Mark9()

if Player_AreSquadsNearMarker(g_Player3, "mkr_Convoy10") then

	g_Move_iter = 1
	g_destination = "mkr_Convoy11"
	Rule_Add(Rule_Convoy_Move)
	Rule_AddInterval(Rule_Mark10, 5)
	Rule_Remove(Rule_Mark9)
	
end

end

function Rule_Mark10()

if Player_AreSquadsNearMarker(g_Player3, "mkr_Convoy11") then

	--	SGroup_SetPlayerOwner("sg_Convoy", g_Player6)
--		SGroup_SetPlayerOwner("sg_convoyescort", g_Player6)
		
		Util_CreateSquadsAtMarkerEx(g_Player3, "sg_Convoy_Capture", "space_marine_squad_tactical", "mkr_Convoy11", 1, 1)
		Cmd_Capture("sg_Convoy_Capture", "eg_Control_Building_Chaos")
		Rule_AddInterval(Rule_Capture_Control_Building, 5)
		Rule_Remove(Rule_Mark10)
end

end

function Rule_Capture_Control_Building()

if EGroup_IsCapturedByPlayer("eg_Control_Building_Chaos", g_Player3, true) then

	if g_gatesopen == false then
		Util_StartNIS(EVENTS.NIS_GateOpens)
	end
	
	g_Control_Chaos = false
	g_Control_Ork = false
	g_Move_iter = 1
	g_destination = "mkr_Convoy12"
	Rule_AddDelay(Rule_Convoy_Move, 10)
	Rule_AddInterval(Rule_Mark12, 5)
	Rule_Remove(Rule_Capture_Control_Building_Chaos)
	Rule_Remove(Rule_Capture_Control_Building)
	Rule_Remove(Rule_Count_Control)
	Rule_Remove(Rule_Control_Building_Health)

end

end

function Rule_Mark12()

if Player_AreSquadsNearMarker(g_Player3, "mkr_Convoy12") then

		g_Move_iter = 1
		g_destination = "mkr_Convoy13"
		Rule_Add(Rule_Convoy_Move)
		Rule_AddInterval(Rule_Mark13, 5)
		Rule_Remove(Rule_Mark12)
					
end

end

function Rule_Mark13()

if Player_AreSquadsNearMarker(g_Player3, "mkr_Convoy13") then

	g_Convoy = false
	

end

end


--[[ Chaos Control Check]]

function Rule_Capture_Control_Building_Chaos()

if EGroup_IsCapturedByPlayer("eg_Control_Building_Chaos", g_Player1, true) then

	g_Control_Chaos = true
	g_Control_Ork = false
	Rule_Remove(Rule_Capture_Control_Building_Chaos)

end

end


--[[ Convoy Health Check ]]

function Rule_Convoy_Health()

if SGroup_GetAvgHealth("sg_Convoy") <= 0 then

	Sound_PlayStinger("stinger_msd4_victoryisnear")

	UI_HideCountdown(890402)
	
	g_Convoy = true
	g_Control_Countdown = 300
	Rule_Remove(Rule_Convoy_Health)
end

end


--[[ Mid Nis Trigger ]]

function Rule_Mid_Nis_Trigger()

if Player_AreSquadsNearMarker(g_Player2, "mkr_Mid_Nis2") or Player_AreSquadsNearMarker(g_Player1, "mkr_Mid_Nis1") or Player_AreSquadsNearMarker(g_Player1, "mkr_Mid_Nis3")then
	
	Rule_Add(Rule_Control_Health_Check)
	Rule_Add(Rule_Farseer_Checker)
	SGroup_ReSpawn("sg_Control")
	Util_StartNIS(EVENTS.NIS_MidMSD3)
	Rule_Remove(Rule_Mid_Nis_Trigger)

end 

end


--[[ Breach of gate check ]]

function Rule_Check_Chaos_Entry()

if Player_AreSquadsNearMarker(g_Player1, "mkr_Gate_Entrance") then

	g_Chaos_Objectives = 3
	Rule_Remove(Rule_Check_Chaos_Entry)
	
	
elseif	Player_AreSquadsNearMarker(g_Player2, "mkr_Gate_Entrance") then

	g_Ork_Objectives = 4
	Rule_Remove(Rule_Check_Chaos_Entry)
	
end

end


--[[ Hq health ]]

function Rule_Check_HQ_Chaos()

if EGroup_Exists("eg_Chaos_HQ") == false or (EGroup_Exists("eg_Chaos_HQ") and EGroup_IsEmpty("eg_Chaos_HQ")) and g_Chaos_HQ == false then
	
	g_Chaos_HQ = true
	
	if g_Ork_HQ == true then
	
		Rule_Remove(Rule_Check_HQ_Chaos)
	
	elseif g_Human_Player == 1 and g_Nis == false then
		
		Util_StartNIS(EVENTS.NIS_Switch_Ork)
		Util_SGroupAbilityButton_Remove(g_buttonID1)
		Rule_Remove(Rule_Button_Click)
		Rule_AddDelay(Rule_Remove_Button_Delayed, 4)
		Rule_Remove(Rule_Check_HQ_Chaos)
		
	
	else
		
		Util_SGroupAbilityButton_Remove(g_buttonID1)
		Rule_Remove(Rule_Button_Click)
		Rule_AddDelay(Rule_Remove_Button_Delayed, 4)
		Rule_Remove(Rule_Check_HQ_Chaos)
		
	end
	
end

end

function Rule_Check_HQ_Ork()

if EGroup_Exists("eg_Ork_HQ") == false or (EGroup_Exists("eg_Ork_HQ") and EGroup_IsEmpty("eg_Ork_HQ")) and g_Ork_HQ == false then

	g_Ork_HQ = true
	
	if g_Chaos_HQ == true then
	
		Rule_Remove(Rule_Check_HQ_Ork)
	
	
	elseif g_Human_Player == 2 and g_Nis == false then
		
		Util_StartNIS(EVENTS.NIS_Switch_Chaos)
		Util_SGroupAbilityButton_Remove(g_buttonID1)
		Rule_Remove(Rule_Button_Click)
		Rule_AddDelay(Rule_Remove_Button_Delayed, 4)
		Rule_Remove(Rule_Check_HQ_Ork)
		
	
	else
		
		Util_SGroupAbilityButton_Remove(g_buttonID1)
		Rule_Remove(Rule_Button_Click)
		Rule_AddDelay(Rule_Remove_Button_Delayed, 4)
		Rule_Remove(Rule_Check_HQ_Ork)
		
	end
	

end

end

function Rule_Check_HQ_End()

if g_Chaos_HQ == true and g_Ork_HQ == true then
	
	Rule_Remove(Rule_Check_HQ_End)
	World_SetTeamWin( g_enemy, "" )
	Rule_AddIntervalEx( Rule_GameOver,5,1 )
	
end

end

function Rule_Remove_Button_Delayed()

Button_Remove(g_buttonID1)
Rule_Remove(Rule_Remove_Button_Delayed)

end


--[[ OBJECTIVES ]]


--[[ Destroy The Convoy ]]

function Rule_Objective_Convoy()

Objective_Convoy = { title_id = 891000, short_desc_id = 891001, help_tip_id = 891002 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Convoy.title_id) == false then
	

	Util_WXP_ObjectiveSubCreate( Objective_Convoy, 891018 )

-- Rule_Add(Rule_Convoy_Health)

	g_Convoy = nil
	
elseif Event_IsAnyRunning() == false and g_Convoy == true  then
	
	Util_ObjectiveComplete(Objective_Convoy.title_id)
	g_Chaos_Objectives = g_Chaos_Objectives +1
	Rule_Add(Rule_Autosave_Convoy_Destroyed)
	Rule_Remove(Rule_Objective_Convoy)
	
elseif Event_IsAnyRunning() == false and g_Convoy == false then
	
	Util_ObjectiveFail(Objective_Convoy.title_id)
	g_Chaos_Objectives = 100
	Rule_Remove(Rule_Objective_Convoy)
	
end

end


--[[Objective Take Over the Control building ]]

function Rule_Objective_Control_Chaos()

Objective_Control_Chaos = { title_id = 891003, short_desc_id = 891004, help_tip_id = 891005 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Control_Chaos.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate( Objective_Control_Chaos, 891018 )
	
	

	Rule_AddInterval(Rule_Capture_Control_Building_Chaos, 1)
	g_Control_Chaos = nil
	
	--[[adding pings]]
	MSD4_SwitchPings_Add(g_Player1, nil, "pg_Control_Chaos", "mkr_Control_Building_Trigger")
	g_objpng_controlID = Objective_PingMarker(Objective_Control_Chaos.title_id, "mkr_Control_Building_Trigger", true, "default")
	
elseif Event_IsAnyRunning() == false and g_Control_Chaos == true  then
	
	Util_ObjectiveComplete(Objective_Control_Chaos.title_id)
	g_Chaos_Objectives = g_Chaos_Objectives +1
	if g_gatesopen== false then
		Util_StartNIS(EVENTS.NIS_GateOpens)
		
	end
	
	MSD4_SwitchPings_RemovePing("pg_Control_Chaos")
	Objective_PingRemove(Objective_Control_Chaos.title_id, g_objpng_controlID)
	
	Rule_Add(Rule_Titan_Ping)
	Rule_Add(Rule_Autosave_Control_Building_Captured)
	Rule_Remove(Rule_Objective_Control_Chaos)
	
elseif Event_IsAnyRunning() == false and g_Control_Chaos == false then
	
	Util_ObjectiveFail(Objective_Control_Chaos.title_id)
	
	--[[removing pings]]
	MSD4_SwitchPings_RemovePing("pg_Control_Chaos")
	Objective_PingRemove(Objective_Control_Chaos.title_id, g_objpng_controlID)
	
	Rule_Remove(Rule_Objective_Control_Chaos)
	
end

end


--[[Objective Destroy Control Building ]]

function Rule_Objective_Control_Ork()

Objective_Control_Ork = { title_id = 891006, short_desc_id = 891007, help_tip_id = 891008 }
if g_Ork == true then
	if Event_IsAnyRunning() == false and Objective_Exists(Objective_Control_Ork.title_id) == false then
		
		Util_WXP_ObjectiveSubCreate( Objective_Control_Ork, 891021 )
		Rule_AddInterval(Rule_Control_Building_Health, 1)
		Rule_Add(Rule_Count_Control)
		
		--[[adding pings]]
		MSD4_SwitchPings_Add(g_Player2, nil, "pg_Control_Ork", "mkr_Ork_Control_Point")
		g_objpng_orkcontrolID = Objective_PingMarker(Objective_Control_Ork.title_id, "mkr_Ork_Control_Point", true, "attack")
		
		g_Control_Ork = nil
		
	elseif Event_IsAnyRunning() == false and g_Control_Ork == true  then
		
		Util_ObjectiveComplete(Objective_Control_Ork.title_id)
		g_Ork_Objectives = g_Ork_Objectives +1
		if g_gatesopen == false then
			Util_StartNIS(EVENTS.NIS_GateOpens)
						
		end
		Rule_Add(Rule_Titan_Ping)
		Rule_Add(Rule_Autosave_Control_Building_Destroyed)
		Rule_Remove(Rule_Objective_Control_Ork)
		
		--[[removing pings]]
		MSD4_SwitchPings_RemovePing("pg_Control_Ork")
		Objective_PingRemove(Objective_Control_Ork.title_id, g_objpng_orkcontrolID)

	elseif Event_IsAnyRunning() == false and g_Control_Ork == false then
		
		Util_ObjectiveFail(Objective_Control_Ork.title_id)
		
		--[[removing pings]]
		MSD4_SwitchPings_RemovePing("pg_Control_Ork")
		Objective_PingRemove(Objective_Control_Ork.title_id, g_objpng_orkcontrolID)
		
		Rule_Remove(Rule_Objective_Control_Ork)	
		
		
	end
end

end

function Rule_Count_Control()

if  EGroup_IsUnderAttackByPlayer("eg_Control_Building_Ork", true, g_Player2) then

	g_Ork_Attacker = true

end

end

function Rule_Control_Building_Health()

if EGroup_Exists("eg_Control_Building_Ork") == false and g_Ork_Attacker then
	
	g_Control_Ork = true
	g_Control_Chaos = false
	g_Stage = 6
	g_On = true
--	MSD4_SwitchPings_RemovePing("pg_Control_Ork")
	Rule_Remove(Rule_Capture_Control_Building_Chaos)
	Rule_Remove(Rule_Capture_Control_Building)
	Rule_Remove(Rule_Count_Control)
	Rule_Remove(Rule_Control_Building_Health)

elseif EGroup_Exists("eg_Control_Building_Ork") and EGroup_IsEmpty("eg_Control_Building_Ork") and g_Ork_Attacker then
	
	g_Control_Ork = true
	g_Control_Chaos = false
	g_Stage = 6
	g_On = true

-- MSD4_SwitchPings_RemovePing("pg_Control_Ork") Rule_Remove(Rule_Capture_Control_Building_Chaos) Rule_Remove(Rule_Capture_Control_Building) Rule_Remove(Rule_Count_Control) Rule_Remove(Rule_Control_Building_Health)

elseif EGroup_Exists("eg_Control_Building_Ork") and EGroup_IsEmpty("eg_Control_Building_Ork") then

	g_Control_Ork = false
	g_Control_Chaos = false
	g_Stage = 6
	g_On = true

-- MSD4_SwitchPings_RemovePing("pg_Control_Ork")

	if g_gatesopen == false then
		Util_StartNIS(EVENTS.NIS_GateOpens)
	end
	Rule_Remove(Rule_Capture_Control_Building_Chaos)
	Rule_Remove(Rule_Capture_Control_Building)
	Rule_Remove(Rule_Count_Control)
	Rule_Remove(Rule_Control_Building_Health)
	

end

end


--[[Objective Capture Bases ]]

function Rule_Objective_Switch_Side()

Objective_Switch_Side = { title_id = 891012, short_desc_id = 891013, help_tip_id = 891014 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Switch_Side.title_id) == false then
	

	Util_WXP_ObjectiveCreate( Objective_Switch_Side, true)		
	
	g_Side_Switch = nil
	
elseif Event_IsAnyRunning() == false and g_Side_Switch == true  then
	
	Util_ObjectiveComplete(Objective_Switch_Side.title_id)
	
	Rule_Remove(Rule_Objective_Switch_Side)
	
elseif Event_IsAnyRunning() == false and g_Side_Switch == false then
	
	Util_ObjectiveFail(Objective_Switch_Side.title_id)
		
	Rule_Remove(Rule_Objective_Switch_Side)
	
end

end


--[[Objective Destroy Eldar Base ]]

function Rule_Objective_Destroy_Eldar_Base()

Objective_Destroy_Eldar_Base = { title_id = 891015, short_desc_id = 891016, help_tip_id = 891017 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Destroy_Eldar_Base.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate( Objective_Destroy_Eldar_Base, 891021 )
	g_Eldar_Base_Destroy = nil
	
elseif Event_IsAnyRunning() == false and g_Eldar_Base_Destroy == true  then
	
	Util_ObjectiveComplete(Objective_Destroy_Eldar_Base.title_id)
	g_Ork_Objectives = g_Ork_Objectives +1
	Rule_Add(Rule_Autosave_Eldar_Base_Destroyed)
	Rule_Remove(Rule_Objective_Destroy_Eldar_Base)

end

end


--[[Overarching objective Chaos ]]

function Rule_Objective_Breach_Psychic_Shield()

Objective_Breach_Psychic_Shield = { title_id = 891018, short_desc_id = 891019, help_tip_id = 891020 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Breach_Psychic_Shield.title_id) == false then
	
	Util_WXP_ObjectiveCreate( Objective_Breach_Psychic_Shield, true, g_Player1 )
	Rule_AddInterval(Rule_Check_Chaos_Entry, 1)
	
	g_objpng_breachshieldID = Objective_PingMarker(Objective_Breach_Psychic_Shield.title_id, "mkr_Gate_Entrance", true, "attack")
	
elseif Event_IsAnyRunning() == false and g_Chaos_Objectives == 3  then
	
	Util_ObjectiveComplete(Objective_Breach_Psychic_Shield.title_id)
	Util_StartNIS(EVENTS.NIS_Closing1)
	Rule_Remove(Rule_Eldar_Relocation_Check)
	Rule_Remove(Rule_Objective_Breach_Psychic_Shield)
	Rule_Remove(Rule_EndGameLose)
	
	Objective_PingRemove(Objective_Breach_Psychic_Shield.title_id, g_objpng_breachshieldID)
	
elseif Event_IsAnyRunning() == false and g_Chaos_Objectives == 100 then
	
	Util_ObjectiveFail(Objective_Breach_Psychic_Shield.title_id)
	Util_ObjectiveFail(Objective_Reach_The_Titan.title_id)

	Rule_Remove(Rule_Objective_Breach_Psychic_Shield)
	
	Objective_PingRemove(Objective_Breach_Psychic_Shield.title_id, g_objpng_breachshieldID)
	
end

end


--[[Overarching objective Ork ]]

function Rule_Objective_Reach_The_Titan()

Objective_Reach_The_Titan = { title_id = 891021, short_desc_id = 891022, help_tip_id = 891023 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Reach_The_Titan.title_id) == false then
	
	Util_WXP_ObjectiveCreate( Objective_Reach_The_Titan, true, g_Player2 )
	
	g_objpng_reachtitanID = Objective_PingMarker(Objective_Reach_The_Titan.title_id, "mkr_Gate_Entrance", true, "attack")
	
elseif Event_IsAnyRunning() == false and g_Ork_Objectives == 4  then
	
	Util_ObjectiveComplete(Objective_Reach_The_Titan.title_id)
	
	Util_StartNIS(EVENTS.NIS_Closing2)
	
	Rule_Remove(Rule_Objective_Reach_The_Titan)
	Rule_Remove(Rule_EndGameLose)
	
	Objective_PingRemove(Objective_Reach_The_Titan.title_id, g_objpng_reachtitanID)
	
elseif Event_IsAnyRunning() == false and g_Chaos_Objectives == 100 then
	
	Util_ObjectiveFail(Objective_Reach_The_Titan.title_id)
	Util_ObjectiveFail(Objective_Breach_Psychic_Shield.title_id)
	World_SetTeamWin( g_enemy, "" )
	Rule_AddIntervalEx( Rule_GameOver,5,1 )
	Rule_Remove(Rule_Objective_Reach_The_Titan)
	
	Objective_PingRemove(Objective_Reach_The_Titan.title_id, g_objpng_reachtitanID)
	
end

end

function Rule_Titan_Ping()

Util_Ping_LoopingMkr("pg_Titan", "mkr_Gate_Entrance")
Rule_Remove(Rule_Titan_Ping)

end


--[[Objective Kill Farseer ]]

function Rule_Objective_Kill_The_Farseer()

Objective_Kill_The_Farseer = { title_id = 891024, short_desc_id = 891025, help_tip_id = 891026 }

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Kill_The_Farseer.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate( Objective_Kill_The_Farseer, 891021 )

elseif Event_IsAnyRunning() == false and g_Farseer == true and Misc_GetLocalPlayerID() == 1001  then
	
	Util_ObjectiveComplete(Objective_Kill_The_Farseer.title_id)
	g_Ork_Objectives = g_Ork_Objectives + 1
	Rule_Remove(Rule_Objective_Kill_The_Farseer)

elseif Event_IsAnyRunning() == false and g_Farseer == true and Misc_GetLocalPlayerID() == 1000  then

	Util_ObjectiveFail(Objective_Kill_The_Farseer.title_id)
	Util_SGroupAbilityButton_Remove(g_buttonID1)
	Rule_Remove(Rule_Button_Click)
	Rule_AddDelay(Rule_Remove_Button_Delayed, 4)
	Rule_Remove(Rule_Check_HQ_Ork)
	Rule_Remove(Rule_Objective_Kill_The_Farseer)
	g_Ork_HQ = true
	
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_StartNIS(EVENTS.NIS_Closing)
end

end]]


--[[ GAME OVER - Player Loses ]]

--[[ The Player Loses condition will be mission specific this version of the function detects if the player has lost their base and has no servitors left ]]

function Rule_EndGameLose()

g_building_exceptions = 
{
	"eldar_webway_gate",
	"space_marine_listening_post",
	"space_marine_turret_bolter"
}

g_unit_exceptions = 
{
	"space_marine_squad_terminator",
	"space_marine_squad_assault",
	"space_marine_squad_tactical",
	"space_marine_squad_rhino",
}

--[[ Lose because of Annihilation ]]	
if( Player_HasBuildingsExcept(g_Player1, g_building_exceptions) == false ) then
	if( Player_HasSquadsExcept(g_Player1, g_unit_exceptions ) == false ) and SGroup_CountDeSpawned(g_sgroupID0) == 0 then
		Rule_RemoveAll()
		Fade_Start(4, false)
		World_SetTeamWin( g_enemy, "" )
		Rule_AddIntervalEx( Rule_GameOver,5,1 )
		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

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


--[[ SWITCH MARKER FUNCTIONS ]]

--[[ The point of the following set of special, mission specific, util functions is to allow only the active player slot's Pings and Beacons to be visible at any point during play.

Since the player has the ability to switch back and forth on their own and Pings and Beacons are often created throughout the whole mission it became very confusing for them ALL to be visible at the same time.

This set of Add, Switch, and Remove functions is aimed at resolving this issue -deg ]]

--[[ MARKER ADD FUNCTION ]] function MSD4_SwitchPings_Add(playerid, beacon, ping, location)

if _switch == nil then
	_switch = {}
end

local player = 0

if playerid == g_Player1 then
	player = "g_Player1"
elseif playerid == g_Player2 then
	player = "g_Player2"
end


local count = table.getn(_switch)
local i = count+1
local pos = {x = 0, y = 0, z = 0}
if type(location) == "string" and Marker_Exists(location, "basic_marker") then
	pos = Marker_GetPosition(Marker_FromName(location, "basic_marker"))
else
	pos = location
end

local template = {id = player, loc = pos, be = beacon, beid = 0, ping = ping}
table.insert(_switch, i , template)

if _switch[i].be ~= nil then
	_switch[i].beid = Util_CreateBeaconPosition_Blue(_switch[i].loc)
end

if _switch[i].ping ~= nil then
	Util_Ping_LoopingPos(_switch[i].ping, _switch[i].loc)
end

end

--[[ MARKER SWITCH FUNCTION ]] function MSD4_SwitchPings_Switch(playerid)

local count = 0

if _switch ~= nil then
	count = table.getn(_switch)
end

local player = 0
if playerid == g_Player1 then
	player = "g_Player1"
elseif playerid == g_Player2 then
	player = "g_Player2"
end


if count > 0 then
	
	for i = 1, count do
		
		
		if _switch[i].id ~= player then
			
			if _switch[i].be ~= nil then
				Util_RemoveBeaconMarker(_switch[i].beid)
			end
			
			if _switch[i].ping ~= nil then
				Util_Ping_Stop(_switch[i].ping)
			end
		
		
		elseif _switch[i].id == player then

			if _switch[i].be ~= nil then
				_switch[i].beid = Util_CreateBeaconPosition_Blue(_switch[i].loc)
			end
			
			if _switch[i].ping ~= nil then
				Util_Ping_LoopingPos(_switch[i].ping, _switch[i].loc)
			end
			
		else
		
		end
		
	end
	
end

end

--[[ MARKER REMOVAL FUNCTIONS ]]

--[[ Remove Ping ]] function MSD4_SwitchPings_RemovePing(ping)

local count = table.getn(_switch)
if count > 0 then
	
	for i = count, 1, -1 do
		
		if _switch[i].ping == ping then
			
			Util_Ping_Stop(ping)
			table.remove(_switch, i)
			
			break
		end
		
	end
	
end

end

--[[ Remove Beacon ]] function MSD4_SwitchPings_RemoveBeacon(beacon)

local count = table.getn(_switch)
if count > 0 then
	
	for i = count, 1, -1 do
		
		if _switch[i].be == beacon then
			
			Util_RemoveBeaconMarker(_switch[i].beid)
			table.remove(_switch, i)
			
			break
		end
		
	end
	
end

end

--[[ Remove Beacon AND Ping ]] function MSD4_SwitchPings_RemoveBoth(beacon, ping)

local count = table.getn(_switch)
if count > 0 then
	
	for i = count, 1, -1 do
		
		if _switch[i].be == beacon then
			
			Util_RemoveBeaconMarker(_switch[i].beid)
			Util_Ping_Stop(ping)
			table.remove(_switch, i)
			
			break
		end
		
	end
	
end

end


--[[ AUTOSAVES ]]

function Rule_Autosave_MissionStart()

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

end

function Rule_Autosave_Convoy_Destroyed()

if not Event_IsAnyRunning() then
	Util_Autosave( "$890201" )
	Rule_Remove(Rule_Autosave_Convoy_Destroyed)
end

end

function Rule_Autosave_Eldar_Base_Destroyed()

if not Event_IsAnyRunning() then
	Util_Autosave( "$890202" )
	Rule_Remove(Rule_Autosave_Eldar_Base_Destroyed)
end

end

function Rule_Autosave_Control_Building_Captured()

if not Event_IsAnyRunning() then
	Util_Autosave( "$890203" )
	Rule_Remove(Rule_Autosave_Control_Building_Captured)
end

end

function Rule_Autosave_Control_Building_Destroyed()

if not Event_IsAnyRunning() then
	Util_Autosave( "$890204" )
	Rule_Remove(Rule_Autosave_Control_Building_Destroyed)
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




--[[ CHEATS ]]

--[[ function CheatClosing()

Rule_RemoveAll()
Util_StartNIS(EVENTS.NIS_Closing)

end

function CheatMissionMoment()

Rule_RemoveAll()
Util_StartNIS(EVENTS.NIS_Moment)

end

function CheatMissionTwist()

Rule_RemoveAll()
Util_StartNIS(EVENTS.NIS_Twist)

end

function CheatMidMissionName()

Rule_RemoveAll()
Util_StartNIS(EVENTS.NIS_MidName)

end ]]




--~ function Rule_Door()

--~ Anim_PlayEGroupAnim("eg_Door1", "die")

--~ end

--[[

function Rule_Bug_Test()

Util_StartNIS(EVENTS.NIS_GateOpens)

-- Rule_Remove(Rule_Cheat_Ork_Nis)

end]]

ゲームスタッツ
フォロワー
12
走行
62
プレイヤー
7
最近の実行
レベル: Trophies (Disorder 5 / Orks)
レベル: Blood for the Blood God! (Disorder 3)
レベル: Titan of the Emperor (Order 5 / Imperial guard)
モデレーター