Mission event file for Order mission 3
Gidsen
/
Mission event file for Order mission 3
Geüpdatet 4 years ago door Merric

--[[ IMPORTS ]]

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

--[[ To Do ]]

-- FIX THE WEBWAY GATE OBJECTIVE DETECTION... MARKERS WITHIN MARKERS, USE GET ALL ENTITIES WITHIN MARKER, GET ALL ENTITIES OF PLAYER (ARE THEY WIHTIN MARKERS etc.) -- REFER TO DRAWING -- Increase recharge rate of the relocate ability


--[[ GAME SETUP ]]

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

g_Player1 = Setup_Player(0, "$690083", "eldar_race", 0) -- player switch race 1
Misc_PlayerTeamColor(g_Player1,"default_5")
Player_DoNotPrecache(g_Player1, _t_MSO3_Player1)

g_Player2 = Setup_Player(1, "$690081", "guard_race", 1) 
Player_DoNotPrecache(g_Player2, _t_MSO3_Player2)

g_Player3 = Setup_Player(2, "$690087", "ork_race", 2) -- enemy race
Misc_PlayerTeamColor(g_Player3,"default_4")
Player_DoNotPrecache(g_Player3, _t_MSO3_Player3)

g_Player4 = Setup_Player(3, "$690082", "guard_race", 1) -- IG base defemders -- Contains Sturnn
Player_DoNotPrecache(g_Player4, _t_MSO3_Player4)

g_Player5 = Setup_Player(4, "$820018", "ork_race", TEAM_NEUTRAL) -- Sewers and stuff
Player_DoNotPrecache(g_Player5, _t_MSO3_Player5)

g_Player6 = Setup_Player(5, "$690081", "guard_race", TEAM_NEUTRAL) -- squads that need to be found
Player_DoNotPrecache(g_Player6, _t_MSO3_Player6)

--g_Player7 = Setup_Player(6, "$690081", "guard_race", TEAM_NEUTRAL) -- squads that need to be found
--g_Player8 = Setup_Player(7, "$690081", "guard_race", TEAM_NEUTRAL) -- squads that need to be found

--[[ DEFINE VARIABLES AND TABLES - define any preset values here for later use]]

g_firstrun = true

g_eldarbasefirstjumpsuccess = false
g_eldarbonesingeratIGBase = false
g_eldarmovedbasesuccessfully = false
g_countdown_on = false
g_thirtysecondsreached = false
g_bonesinger_dead = false
g_bonesinger_switched = false
g_first_section_complete = false
g_second_section_complete = false
g_patrolB = 1

g_ork_horde_attack_started = false

g_wave = 1
g_wave2 = 1

g_Ork_Horde_Army_iter = 1
g_Ork_Second_Location_Infantry_Army_iter = 1
g_Ork_Second_Location_Armor_Army_iter = 1


OrkAmbush = {} -- sets up the Ork Ambush Table
OrkAmbushTrack = {false, false, false, false, false, false} -- sets up a table that keeps track of whether an ambush has been triggered yet or not!
t_ork_manhole_triggered = {false, false, false, false}
t_ork_manhole_despawned = {false, false, false, false}
t_ork_manhole_troops_out = {false, false, false, false}

t_sgrouporkfinalassault = {}
t_sgrouporkmanholefinalassault = {}

g_number_of_ork_manholes_left = 4
--g_webway_gate_at_first_jump_location = false
--g_eldar_base_at_first_jump_location = false
g_webway_gate_at_ig_base = false

g_deactivation_of_manholes = false
g_sniper_triggered = false
g_HWP_triggered = false
g_stormboyz_deployed = false
g_tankbustaz_deployed = false

g_ork_assault_started = false
g_ork_wave_counter = 0
g_bonesinger_follow = true

g_first_revenge_wave_complete = false
g_revenge_wave_number = 0
g_first_jump_objective_added = false
g_webway_gate_at_first_jump_location = false
g_eldar_base_at_first_jump_location = false
g_webway_gate_at_second_jump_location = false
g_eldar_base_at_second_jump_location = false
g_eldar_base_at_final_jump_location = false
g_time_is_up = false
g_ork_stormboyz_final_attack = false
t_sgroup_ork_revenge_element = {}
t_ork_jumped_over_to_second_location = {false, false, false, false}
t_ork_tanks_subgroup = {}
t_ork_first_jump_assault_subgroup = {}
g_first_ork_attack_moved = false
g_eldar_second_location_attack_started = false

g_squiggoth_deployed = false
g_squiggoth_enabled = false

g_ork_horde_attack_started = false

g_jump_assault_first_wave = true

g_objectives_completed = 0

g_second_set_objectives_completed = 0

g_taldeerreturn = false
g_taldeerfirstreturn = false
g_taldeersecondreturn = false
g_taldeerfinalreturn = false
g_sturnnreturn = false

g_pipegate_destroyed = false

BlueprintTable = Util_MakeBlueprintTable("eldar_squad_bonesinger")

t_eldar_webway_gate = Util_MakeBlueprintTable("eldar_webway_gate")
t_eldar_building_restrictions = {"eldar_advanced_warp_generator", "eldar_hq", "eldar_mine_field", "eldar_support_platform_scatterlaser", "eldar_support_portal", "eldar_warp_generator"} --"eldar_listening_post", "eldar_aspect_portal", "eldar_soul_shrine", 
t_eldar_building_restrictions_after_move_to_ig = {"eldar_advanced_warp_generator", "eldar_hq", "eldar_soul_shrine"}
t_eldar_addon_restrictions = {"eldar_aspect_stone_wraithlord", "eldar_list_post_addon_2", "eldar_aspect_stone_warp_spider", "eldar_aspect_stone_dark_reapers",
												 "eldar_aspect_stone_banshees", "eldar_aspect_stone_fire_dragon"}
t_eldar_research_restrictions = {"eldar_research_farseerhealth_1", "eldar_research_farseerhealth_2", "eldar_requisition_research_2", "eldar_haywire_bomb_research", 
													"eldar_fleet_of_foot_research", "eldar_shroud_ability_research", "eldar_research_infantryhealth_2", "eldar_research_infantryaccuracy_2",
													"eldar_tier2_research", "eldar_exarch_ability_research", "eldar_exarch_ability_research_1", "eldar_warlock_ability_research", 
													"eldar_warlock_ability_research_1", "eldar_warlock_ability_research_2", "eldar_warlock_ability_research_3", "eldar_bonesinger_ability_research_1", "eldar_bonesinger_ability_research_2", "eldar_bonesinger_ability_research_3"}
--t_eldar_weapon_restrictions = {"eldar_reaper_launcher", "eldar_shuriken_cannon_darkreaperexarch", "eldar_power_sword_bansheeexarch"}
t_eldar_unit_restrictions = {"eldar_squad_farseer", "eldar_squad_farseer_sp", "eldar_squad_avatar", "eldar_squad_fire_dragon"}
t_eldar_ability_restrictions = {"eldar_wraithtomb", "eldar_entanglement"}

t_player_table = {g_Player1, g_Player2, g_Player3, g_Player4, g_Player5, g_Player6} -- g_Player7, g_Player8

end

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

--Sound_PlaylistStop(PC_Music )

end

function OnLoad()

Rule_Check_AddOneShot(Rule_Reload_Reset, 2)

end

Scar_AddLoad(OnLoad)

function CheatClosing()

Rule_RemoveAll()
--Util_StartNIS(EVENTS.NIS_Closing)

end


--[[ ON INITIALIZATION ]]

function OnInit()

--[[ RESEARCH LEVEL - sets the research level of the mission, locks researches, squads, and buildings for the appropriate mission number DOW specific! ]]
Rule_SetResearchLevel( 4 )

--[[ NIS PRESETS - turn off event cues, set the viewable space to black (faded out) and preset letterboxing ]]
EventCue_Enable(false)
Fade_Start( 0, false )	
W40k_Letterbox( true, 0 )	

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

--[[ Defining the OBJECTIVES ]]

Objective_Forward_Progress = {title_id = 821054, short_desc_id = 821056, help_tip_id = 821058}
Objective_Kill_Ork_Leader = {title_id = 821000, short_desc_id = 821002, help_tip_id = 821004}

Objective_First_WebwayBuilt = {title_id = 821006, short_desc_id = 821008, help_tip_id = 821010}
Objective_First_EldarBaseJump = {title_id = 821012, short_desc_id = 821014, help_tip_id = 821016}
Objective_Second_WebwayBuilt = {title_id = 821018, short_desc_id = 821020, help_tip_id = 821022}
Objective_Second_EldarBaseJump = {title_id = 821024, short_desc_id = 821026, help_tip_id = 821028}

Objective_Alliance_of_Convenience = {title_id = 821060, short_desc_id = 821062, help_tip_id = 821064}
Objective_Defend_Eldar_Relocating_To_IG_Base = {title_id = 821030, short_desc_id = 821032, help_tip_id = 821034}
Objective_Defend_IG_Base = {title_id = 821036, short_desc_id = 821038, help_tip_id = 821040}

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 )

--[[ DoW Specific!! Restrict_SpaceMarines( g_Player1, resLevel ) Unrestrict_ResearchWithAlerts( g_Player1, "marine_requisition_research_2", "none", "none" ) Unrestrict_ResearchWithAlerts( g_Player1, "marine_power_research_2", "none", "none" ) ]]

end


--[[ MUSIC ]]

--[[ function Playlist_Manager( channel, tracks, rand, silence) --[[ clear the ambient playlist ]] Sound_PlaylistClear( channel ) for i = 1, table.getn(tracks) do --[[ add tracks to the playlist ]] Sound_PlaylistAddTrack( channel, tracks[i] ) end --[[ mark these tracks to play randomly ]] Sound_PlaylistSetorder( channel, rand ) --[[ add 5 to 10 seconds silence between tracks ]] Sound_PlaylistSetSilence( channel, silence[1], silence[2] ) end]]

function Rule_SetupMusicPlaylist()

t_ambient = {"Snowy_wind_2" }
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_SetResource(g_Player1, RT_Requisition, 1500)
	Player_SetResource(g_Player1, RT_Power, 750)
	
	--Player_SetResource(g_Player4, RT_Requisition, 4000)
	--Player_SetResource(g_Player4, RT_Power, 2000)
		
	Rule_Player_Army_Kickoff()
	Rule_AddInterval(Rule_Taldeer_Track, 2)
	Rule_Imperial_Guard_Army_Kickoff()
	Rule_AddInterval(Rule_Sturnn_Track, 2)
	Rule_Ork_Army_Kickoff()
	
	Sound_PlaylistStop( PC_Music )
	
	--[[ DIFFICULTY LEVEL - gets the difficulty level from the UI and passes it into the function]]
	Rule_SetDifficultyLevel( Difficulty_Get() )
	
	--[[ Get the AI doing whatever after the NIS is over ]]
	Rule_StartAI()
	
	g_firstrun = false
	
	
elseif Event_IsAnyRunning() == false then		
	
	Rule_AddInterval(Rule_BaseleaderOrkPatrol, 20)
	Rule_AddInterval(Rule_BaseleaderOrkUnderAttack, 10)
	Rule_AddInterval(Rule_Ork_Horde_Army_Wave_Control_Proximity, 5) --proximity check to trip off the Horde!
	
	-- after 240 seconds the horde wave will start.  But if it's called earlier due to units being in proximity nothing will happen due to g_ork_horde_attack_started being "true"
	Rule_AddOneShot(Rule_Ork_Horde_Army_Wave_Control_Kickoff, 240) 
	UI_ShowCountdown(820306, 240) -- countdown associated with opening speech
	
		
	--[[ Set up a Win Check ]]
	Rule_AddInterval(Rule_EndGameWin, 1)
	
	--[[ Set up a Lose Check ]]
	Rule_AddInterval(Rule_EndGameLose, 1)
			
	--[[ Assigning objectives]]
	Rule_AddInterval(Rule__Objective_Forward_Progress, 1)
	Rule_AddOneShot(Rule_Initial_Objective_Ping_Kickoff, 0)
	
	--[[ Save as soon as the opening NIS is over ]]
	Rule_Add(Rule_Autosave_MissionStart)
	
	--[[Opening Intel Event]]
	Rule_AddOneShot(Rule_IE_OpeningSpeech, 4)
	
	--[[ Clean up ]]
	Rule_Remove(Rule_GameStart)
	
end

end


--[[ DIFFICULTY ]]

function Rule_SetDifficultyLevel( difficultyLevel )

--Difficulty_SetForAll( difficultyLevel )
Difficulty_SetForPlayer( g_Player2, difficultyLevel )
Difficulty_SetForPlayer( g_Player3, difficultyLevel )
Difficulty_SetForPlayer( g_Player5, difficultyLevel )
Difficulty_SetForPlayer( g_Player6, difficultyLevel )

-- easy
if difficultyLevel == DIFFICULTY_EASY then
-- 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_P1gopher") then
	Util_TrackCharacterAndDropPodIn( g_Player1, "sg_P1gopher", "space_marine_squad_sp_metiel", "mkr_p1_start" )
end

end ]] --function Rule_TrackPlayer()

--end

--[[ CORE GAME ]]


--[[ PLAYER ARMY ]]

function Rule_Player_Army_Kickoff()

--Player_SetMaxSupportCap(g_Player1, 12)
--Player_SetSupportCap(g_Player1, 10)

Player_GrantResearch( g_Player1, "eldar_farseer_ability_research_3")
Player_RestrictResearchList( g_Player1, t_eldar_research_restrictions )
Player_RestrictSquadList(g_Player1, t_eldar_unit_restrictions)

for i = 1, table.getn(t_eldar_ability_restrictions) do
	Player_RestrictAbility(g_Player1, t_eldar_ability_restrictions[i])
	end


Player_GrantResearch(g_Player1, "eldar_webway_gate_relocation_research")
--EGroup_SetPlayerOwner("eg_pipegate", g_Player1)
EGroup_SetHealthInvulnerable("eg_pipegate", true )	
EGroup_SetHealthInvulnerable("eg_pipegate2", true )	

Player_RestrictBuildingList(g_Player1, t_eldar_building_restrictions) -- restricts buildings player can use
Player_RestrictSquad(g_Player1, "eldar_squad_wraithlord") -- restricts player so that they can't build stormboys
Player_RestrictAddOnList(g_Player1, t_eldar_addon_restrictions) -- restricts add-ons player can use

--EGroup_DeSpawn("eg_eldarbuildings2") -- may not need anymore.  If so, delete associated buildings from the .SGB file
EGroup_DeSpawn("eg_pipegate1_side_destroyed")
EGroup_DeSpawn("eg_pipegate2_side_destroyed")
--EGroup_DeSpawn("eg_eldar_webway")

EGroup_SetPlayerOwner("eg_pipegate", g_Player1) -- will switch player owner later
EGroup_SetPlayerOwner("eg_pipegate2", g_Player1) -- will switch player owner later
--EGroup_SetPlayerOwner("eg_pipegate", g_Player1)

g_all_current_player1_squads = Player_GetSquads(g_Player1)

Rule_Check_AddInterval(Rule_Add_Eldar_Buildings, 2)

Rule_AddOneShot(Rule_Setup_No_Build_Zones, 1) -- creates no build zones

end

--[[ Tracks taldeer ]]

function Rule_Taldeer_Track()

local blueprinttable = Util_MakeBlueprintTable("eldar_squad_farseer")

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

end

function Rule_Taldeer_Return()

--[[ recreate the unit ]]
Util_CreateSquadsAtMarker(g_Player1, "sg_taldeer", "eldar_squad_farseer", "mkr_eldar_base_start", 1)
--[[ play the fx ]]
World_FXEventSquad("data:Art/Events/Unit_Upgrade_Morale_FX/Reinforce_Trooper", SGroup_FromName("sg_taldeer"))

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

--[[ if no messages have played recently, play the Intel Event - this keeps messages from flooding the player ]]
if Event_TimeSinceLast() > 10 then
	
	local l_random_line_spoken = World_GetRand(1, 2)
	
	if l_random_line_spoken == 1 then
		Rule_AddOneShot(Rule_IE_Taldeer_Returns, 0)
	elseif l_random_line_spoken == 2 then
		Rule_AddOneShot(Rule_IE_Taldeer_Returns2, 0)
	end
	
end
EventCue_DoEvent( "recruit_commander", "/Races/Shared/Upgrade_weapon", "$42890", "$42892" )

end

--[[ Tracks taldeer ]]

function Rule_Taldeer_First_Track()

--[[ check to see if the group is empty AND if the boolean has been returned to false - this prevents duplicate rule adds ]]

if SGroup_Exists("sg_taldeer") and SGroup_IsEmpty("sg_taldeer") and g_taldeerfirstreturn ~= true then

--[[ prevents duplicate rule adds ]]

g_taldeerfirstreturn = true

--[[ 6 second delay, keeps it from being instantaneous ]]

Rule_AddOneShot(Rule_Taldeer_First_Return, 6)

end

end

function Rule_Taldeer_First_Return()

--[[ recreate the unit ]]
Util_CreateSquadsAtMarker(g_Player1, "sg_taldeer", "eldar_squad_farseer", "mkr_eldarbasejump1", 1)

--[[ play the fx ]]

World_FXEventSquad("data:Art/Events/Unit_Upgrade_Morale_FX/Reinforce_Trooper", SGroup_FromName("sg_taldeer"))

--[[ reset the flag ]]

g_taldeerfirstreturn = false

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

if Event_TimeSinceLast() > 10 then
	
	local l_random_line_spoken = World_GetRand(1, 2)
	
	if l_random_line_spoken == 1 then
		Rule_AddOneShot(Rule_IE_Taldeer_Returns, 0)
	elseif l_random_line_spoken == 2 then
		Rule_AddOneShot(Rule_IE_Taldeer_Returns2, 0)
	end
	
end

end

function Rule_Taldeer_Second_Track()

--[[ check to see if the group is empty AND if the boolean has been returned to false - this prevents duplicate rule adds ]]

if SGroup_Exists("sg_taldeer") and SGroup_IsEmpty("sg_taldeer") and g_taldeersecondreturn ~= true then

--[[ prevents duplicate rule adds ]]

g_taldeersecondreturn = true

--[[ 6 second delay, keeps it from being instantaneous ]]

Rule_AddOneShot(Rule_Taldeer_Second_Return, 6)

end

end

function Rule_Taldeer_Second_Return()

--[[ recreate the unit ]]

Util_CreateSquadsAtMarker(g_Player1, "sg_taldeer", "eldar_squad_farseer", "mkr_eldarbasejump2", 1)

--[[ play the fx ]]

World_FXEventSquad("data:Art/Events/Unit_Upgrade_Morale_FX/Reinforce_Trooper", SGroup_FromName("sg_taldeer"))

--[[ reset the flag ]]

g_taldeersecondreturn = false

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

if Event_TimeSinceLast() > 10 then
	
	local l_random_line_spoken = World_GetRand(1, 2)
	
	if l_random_line_spoken == 1 then
		Rule_AddOneShot(Rule_IE_Taldeer_Returns, 0)
	elseif l_random_line_spoken == 2 then
		Rule_AddOneShot(Rule_IE_Taldeer_Returns2, 0)
	end
	
end

end

function Rule_Taldeer_Final_Track()

--[[ check to see if the group is empty AND if the boolean has been returned to false - this prevents duplicate rule adds ]]

if SGroup_Exists("sg_taldeer") and SGroup_IsEmpty("sg_taldeer") and g_taldeerfinalreturn ~= true then
	
	--[[ prevents duplicate rule adds ]]
	
	g_taldeerfinalreturn = true
	
	--[[ 6 final delay, keeps it from being instantaneous ]]
	
	Rule_AddOneShot(Rule_Taldeer_Final_Return, 6)
	
end

end

function Rule_Taldeer_Final_Return()

--[[ recreate the unit ]]

Util_CreateSquadsAtMarker(g_Player1, "sg_taldeer", "eldar_squad_farseer", "mkr_eldar_base_final_position", 1)

--[[ play the fx ]]

World_FXEventSquad("data:Art/Events/Unit_Upgrade_Morale_FX/Reinforce_Trooper", SGroup_FromName("sg_taldeer"))

--[[ reset the flag ]]

g_taldeerfinalreturn = false

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

if Event_TimeSinceLast() > 10 then
	
	local l_random_line_spoken = World_GetRand(1, 2)
	
	if l_random_line_spoken == 1 then
		Rule_AddOneShot(Rule_IE_Taldeer_Returns, 0)
	elseif l_random_line_spoken == 2 then
		Rule_AddOneShot(Rule_IE_Taldeer_Returns2, 0)
	end
	
end

end

--[[sets up no build zones so player can't exploit webway gates]] function Rule_Setup_No_Build_Zones()

--[[near orks]]
nobuildzoneID1 = W40k_NoBuildZoneMarker("mkr_no_build_zone1_start", "mkr_no_build_zone1_end")
nobuildzoneID2 = W40k_NoBuildZoneMarker("mkr_no_build_zone2_start", "mkr_no_build_zone2_end")
nobuildzoneID3 = W40k_NoBuildZoneMarker("mkr_no_build_zone3_start", "mkr_no_build_zone3_end")
nobuildzoneID4 = W40k_NoBuildZoneMarker("mkr_no_build_zone4_start", "mkr_no_build_zone4_end")
nobuildzoneID5 = W40k_NoBuildZoneMarker("mkr_no_build_zone5_start", "mkr_no_build_zone5_end")
nobuildzoneID6 = W40k_NoBuildZoneMarker("mkr_no_build_zone6_start", "mkr_no_build_zone6_end")
nobuildzoneID7 = W40k_NoBuildZoneMarker("mkr_no_build_zone7_start", "mkr_no_build_zone7_end")
nobuildzoneID8 = W40k_NoBuildZoneMarker("mkr_no_build_zone8_start", "mkr_no_build_zone8_end")
nobuildzoneID9 = W40k_NoBuildZoneMarker("mkr_no_build_zone9_start", "mkr_no_build_zone9_end")
nobuildzoneID10 = W40k_NoBuildZoneMarker("mkr_no_build_zone10_start", "mkr_no_build_zone10_end")
nobuildzoneID11 = W40k_NoBuildZoneMarker("mkr_no_build_zone11_start", "mkr_no_build_zone11_end")
nobuildzoneID12 = W40k_NoBuildZoneMarker("mkr_no_build_zone12_start", "mkr_no_build_zone12_end")
nobuildzoneID13 = W40k_NoBuildZoneMarker("mkr_no_build_zone13_start", "mkr_no_build_zone13_end")
nobuildzoneID14 = W40k_NoBuildZoneMarker("mkr_no_build_zone14_start", "mkr_no_build_zone14_end")
nobuildzoneID15 = W40k_NoBuildZoneMarker("mkr_no_build_zone15_start", "mkr_no_build_zone15_end")
	
--[[first jumpzone]]
nobuildzoneID16 = W40k_NoBuildZoneMarker("mkr_no_build_zone16_start", "mkr_no_build_zone16_end") -- centre area
nobuildzoneID17 = W40k_NoBuildZoneMarker("mkr_no_build_zone17_start", "mkr_no_build_zone17_end") -- boundary of permitted building area
nobuildzoneID18 = W40k_NoBuildZoneMarker("mkr_no_build_zone18_start", "mkr_no_build_zone18_end") -- boundary of permitted building area
nobuildzoneID19 = W40k_NoBuildZoneMarker("mkr_no_build_zone19_start", "mkr_no_build_zone19_end") -- boundary of permitted building area
nobuildzoneID20 = W40k_NoBuildZoneMarker("mkr_no_build_zone20_start", "mkr_no_build_zone20_end") -- boundary of permitted building area
nobuildzoneID21 = W40k_NoBuildZoneMarker("mkr_no_build_zone21_start", "mkr_no_build_zone21_end") -- boundary of permitted building area
nobuildzoneID22 = W40k_NoBuildZoneMarker("mkr_no_build_zone22_start", "mkr_no_build_zone22_end")
nobuildzoneID32 = W40k_NoBuildZoneMarker("mkr_no_build_zone32_start", "mkr_no_build_zone32_end")
nobuildzoneID33 = W40k_NoBuildZoneMarker("mkr_no_build_zone33_start", "mkr_no_build_zone33_end")
nobuildzoneID34 = W40k_NoBuildZoneMarker("mkr_no_build_zone34_start", "mkr_no_build_zone34_end")
nobuildzoneID35 = W40k_NoBuildZoneMarker("mkr_no_build_zone35_start", "mkr_no_build_zone35_end")

--[[second jumpzone]]
nobuildzoneID23 = W40k_NoBuildZoneMarker("mkr_no_build_zone23_start", "mkr_no_build_zone23_end") -- centre area
nobuildzoneID24 = W40k_NoBuildZoneMarker("mkr_no_build_zone24_start", "mkr_no_build_zone24_end") -- boundary of permitted building area
nobuildzoneID25 = W40k_NoBuildZoneMarker("mkr_no_build_zone25_start", "mkr_no_build_zone25_end") -- boundary of permitted building area 
nobuildzoneID26 = W40k_NoBuildZoneMarker("mkr_no_build_zone26_start", "mkr_no_build_zone26_end") -- boundary of permitted building area 
nobuildzoneID27 = W40k_NoBuildZoneMarker("mkr_no_build_zone27_start", "mkr_no_build_zone27_end") -- boundary of permitted building area 
nobuildzoneID28 = W40k_NoBuildZoneMarker("mkr_no_build_zone28_start", "mkr_no_build_zone28_end") -- boundary of permitted building area 
nobuildzoneID29 = W40k_NoBuildZoneMarker("mkr_no_build_zone29_start", "mkr_no_build_zone29_end")
--nobuildzoneID36 = W40k_NoBuildZoneMarker("mkr_no_build_zone36_start", "mkr_no_build_zone36_end")

--[[bridge]]
nobuildzoneID30 = W40k_NoBuildZoneMarker("mkr_no_build_zone30_start", "mkr_no_build_zone30_end") -- bridge
nobuildzoneID31 = W40k_NoBuildZoneMarker("mkr_no_build_zone31_start", "mkr_no_build_zone31_end") -- area in front of base
nobuildzoneID39 = W40k_NoBuildZoneMarker("mkr_no_build_zone39_start", "mkr_no_build_zone39_end") -- bridge by sandbags


nobuildzoneID37 = W40k_NoBuildZoneMarker("mkr_no_build_zone37_start", "mkr_no_build_zone37_end") -- 2nd orks area
nobuildzoneID38 = W40k_NoBuildZoneMarker("mkr_no_build_zone38_start", "mkr_no_build_zone38_end") -- 2nd orks area

end


--[[Imperial Guard Army Creation]]

function Rule_Imperial_Guard_Army_Kickoff()

Player_RestrictSquad(g_Player4, "guard_squad_command_squad")
Player_RestrictBuilding(g_Player4, "guard_mars_pattern")
Player_GrantResearch( g_Player4, "guard_enable_strafing_run")
EGroup_ForceAddOn("eg_guard_hq", "addon_guard_hq_1")

-- Base Defenders
Util_CreateSquadsAtMarkerEx(g_Player4, "sg_base_defender_guardsmen1", "guard_squad_guardsmen", "mkr_base_defender1", 1,12)
Cmd_SetStance("sg_base_defender_guardsmen1", STANCE_StandGround)
Util_CreateSquadsAtMarkerEx(g_Player4, "sg_base_defender_guardsmen2", "guard_squad_guardsmen", "mkr_base_defender2", 1,12)
Cmd_SetStance("sg_base_defender_guardsmen2", STANCE_StandGround)
for i = 1, SGroup_Count(SGroup_FromName("sg_base_defender_guardsmen2")) do
	Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_base_defender_guardsmen2"), i), "guard_lasgun_guardsmen", 5)
end

Util_CreateSquadsAtMarkerEx(g_Player4, "sg_base_defender_kasrkin1", "guard_squad_kasrkin", "mkr_base_defender_kasrkin1", 1, 8)
Util_CreateSquadsAtMarkerEx(g_Player4, "sg_base_defender_kasrkin2", "guard_squad_kasrkin", "mkr_base_defender_kasrkin2", 1, 8)
Util_CreateSquadsAtMarker(g_Player4, "sg_base_tank_hellhound", "guard_squad_hellhound", "mkr_base_defender_kasrkin2", 1)
Util_CreateSquadsAtMarker(g_Player4, "sg_base_sentinel", "guard_squad_sentinel", "mkr_base_defender_kasrkin1", 2)


Util_CreateSquadsAtMarker(g_Player4, "sg_enginseer", "guard_squad_enginseer", "mkr_base_defender_kasrkin2", 1)
Util_CreateSquadsAtMarker(g_Player4, "sg_sturnn", "guard_squad_command_squad", "mkr_base_defender_kasrkin2", 1)

local mod_sturnnhealthincrease = Modifier_Create(MAT_EntityType, "health_maximum_modifier", MUT_Multiplication, false, 4, "guard_leaders_captain")
g_mod_sturnnhealthincrease = Modifier_ApplyToPlayer( mod_sturnnhealthincrease, g_Player4)	

end

--[[ Tracks Sturnn ]]

function Rule_Sturnn_Track()

--[[ check to see if the group is empty AND if the boolean has been returned to false - this prevents duplicate rule adds ]]
if SGroup_Exists("sg_sturnn") and SGroup_IsEmpty("sg_sturnn") and g_sturnnreturn ~= true then
	
	--Player_RestrictSquad(g_Player4, "guard_squad_command_squad")
	
	--[[ prevents duplicate rule adds ]]
	g_sturnnreturn = true
	
	--[[ 6 second delay, keeps it from being instantaneous ]]
	Rule_AddOneShot(Rule_Sturnn_Return, 6)
	
end

end

function Rule_Sturnn_Return()

--[[ recreate the unit ]]
Util_CreateSquadsAtMarker(g_Player4, "sg_sturnn", "guard_squad_command_squad", "mkr_sturnn_respawn", 1)	

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

--Player_UnRestrictSquad(g_Player4, "guard_squad_command_squad")

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

--[[ if no messages have played recently, play the Intel Event - this keeps messages from flooding the player ]]
if Event_TimeSinceLast() > 10 then
	
	local l_random_line_spoken = World_GetRand(1, 2)
	
	if l_random_line_spoken == 1 then
		Rule_AddOneShot(Rule_IE_Sturnn_Returns, 0)
	elseif l_random_line_spoken == 2 then
		Rule_AddOneShot(Rule_IE_Sturnn_Returns2, 0)
	end
	
end
EventCue_DoEvent( "recruit_commander", "/Races/Shared/Upgrade_weapon", "$42890", "$42892" )

end


--[[Ork Army Creation]] function Rule_Ork_Army_Kickoff()

Player_GrantResearch(g_Player3, "ork_research_eavy_armour")
Player_GrantResearch(g_Player3, "ork_research_tougherorks")

--Util_CreateSquadsAtMarker(g_Player3, "sg_baseleader", "ork_squad_armored_nob", "mkr_ork_leader", 1) -- was armoured nob
--Cmd_SetStance("sg_baseleader", STANCE_Attack)

Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_base_defence", "ork_squad_slugga", "mkr_ork_basedefence", 1, 12) -- 1, 12
Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_horde_base_troops1", "ork_squad_slugga", "mkr_horde_base_troops1", 2, 8)

for i = 1, 5 do
	Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_bodyguard"..i, "ork_squad_slugga", "mkr_ork_bodyguard"..i, 1,8)	-- 1, 12
end

g_ork_tanks = SGroup_CreateIfNotFound("sg_ork_tanks")

for i = 1, 6 do 
	t_ork_tanks_subgroup[i] = Util_CreateSquadsAtMarker(g_Player3, "sg_ork_tank"..i, "ork_squad_looted_tank", "mkr_ork_tank_spawn"..i, 1)
	Cmd_SetStance("sg_ork_tank"..i, STANCE_StandGround)
	SGroup_AddGroup(g_ork_tanks, t_ork_tanks_subgroup[i])
end
--sgroupadvanceorkscout1 = Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_scouts", "ork_squad_slugga", "mkr_ork_scout_spawn", 1, 6)

--local mod_squiggotharmourincrease = Modifier_Create(MAT_EntityType, "armour_modifier", MUT_Multiplication, false, 2, "ork_squiggoth") --4.5
--g_mod_squiggotharmourincrease = Modifier_ApplyToPlayer( mod_squiggotharmourincrease, g_Player3)
local mod_squiggothhealthincrease = Modifier_Create(MAT_EntityType, "health_maximum_modifier", MUT_Multiplication, false, 3, "ork_squiggoth") --4
g_mod_squiggothhealthincrease = Modifier_ApplyToPlayer( mod_squiggothhealthincrease, g_Player3)	

end

--[[tracks tanks and makes sure they are replenished. they will not be replenished, however, after a certain point in the game]] function Rule_Ork_Tank_Track() for i = 1, 3 do if SGroup_Exists("sg_ork_tank"..i) and SGroup_IsEmpty("sg_ork_tank"..i) then t_ork_tanks_subgroup[i] = Util_CreateSquadsAtMarker(g_Player3, "sg_ork_tank"..i, "ork_squad_looted_tank", "mkr_ork_tank_origin1", 1) SGroup_AddGroup(g_ork_tanks, t_ork_tanks_subgroup[i]) Cmd_SetStance("sg_ork_tank"..i, STANCE_StandGround) Cmd_MoveToMarker("sg_ork_tank"..i, "mkr_ork_tank_spawn"..i) end end

for i = 4, 6 do
	if SGroup_Exists("sg_ork_tank"..i) and SGroup_IsEmpty("sg_ork_tank"..i) then
		t_ork_tanks_subgroup[i] = Util_CreateSquadsAtMarker(g_Player3, "sg_ork_tank"..i, "ork_squad_looted_tank", "mkr_ork_tank_origin2", 1)
		SGroup_AddGroup(g_ork_tanks, t_ork_tanks_subgroup[i])
		Cmd_SetStance("sg_ork_tank"..i, STANCE_StandGround)
		Cmd_MoveToMarker("sg_ork_tank"..i, "mkr_ork_tank_spawn"..i)
	end
end

end


function Rule_Initial_Objective_Ping_Kickoff()

FOW_RevealSGroup("sg_baseleader", 5)
Rule_AddInterval(Rule_Show_Leader, 5)

end

--[[shows the leader's FOW]] function Rule_Show_Leader() if SGroup_Exists("sg_baseleader") and SGroup_IsEmpty("sg_baseleader") == false then FOW_RevealSGroup("sg_baseleader", 5) end if SGroup_Exists("sg_baseleader") and SGroup_IsEmpty("sg_baseleader") == true then Rule_Remove(Rule_Show_Leader) end end

--[[ork base leader's patrol routine]] function Rule_BaseleaderOrkPatrol()

if SGroup_Exists("sg_baseleader") and SGroup_IsEmpty("sg_baseleader") ~= true then
	if SGroup_IsUnderAttackByPlayer("sg_baseleader", false, g_Player1) ~= true then
		if g_patrolB == 1 then
			Cmd_AttackMoveMarker("sg_baseleader", "mkr_ork_patrol1")
			g_patrolB = 2
		elseif g_patrolB == 2 then
			Cmd_AttackMoveMarker("sg_baseleader", "mkr_ork_patrol2")
			g_patrolB = 3
		elseif g_patrolB == 3 then
			Cmd_AttackMoveMarker("sg_baseleader", "mkr_ork_patrol3")
			g_patrolB = 4
		elseif g_patrolB == 4 then
			Cmd_AttackMoveMarker("sg_baseleader", "mkr_ork_patrol4")	
			g_patrolB = 5
		elseif g_patrolB == 5 then
			Cmd_AttackMoveMarker("sg_baseleader", "mkr_ork_patrol5")	
			g_patrolB = 1
		elseif g_patrolB == 6 then
			Cmd_AttackMoveMarker("sg_baseleader", "mkr_ork_patrol6")	
			g_patrolB = 1
		end
	end
elseif SGroup_Count(SGroup_FromName("sg_baseleader")) == 0 then
	Rule_Remove(Rule_BaseleaderOrkPatrol);
end

end

--[[what happens when the ork base leader is under attack]] function Rule_BaseleaderOrkUnderAttack()

if SGroup_Exists("sg_baseleader") and SGroup_IsEmpty("sg_baseleader") ~= true then
	
	if SGroup_IsUnderAttackByPlayer("sg_baseleader", false, g_Player1) then
		
		Cmd_SetStance("sg_baseleader", STANCE_Attack ) 
		g_all_current_player1_squads = Player_GetSquads(g_Player1)
		Cmd_AttackSGroup("sg_baseleader", SGroup_GetName(g_all_current_player1_squads))
		
	end
	
elseif SGroup_Count(SGroup_FromName("sg_baseleader")) == 0 then
	Rule_Remove(Rule_BaseleaderOrkUnderAttack);
end

end

function Rule_Ork_Horde_Army_Wave1()

local i = g_Ork_Horde_Army_iter 

t_Ork_Horde_Army = {
	
	sgroup_name = {"sg_ork_horde1a"},  
	blueprint = {"ork_squad_slugga"},
	marker_spawn = {"mkr_ork_horde_attack_spawn1"}, 
	stance = {STANCE_Attack},
	melee_stance = {MSTANCE_Assault},
	squad_num = {1}, 
	squad_size = {15}, 
}

if g_Ork_Horde_Army_iter <= table.getn(t_Ork_Horde_Army.sgroup_name) and (SGroup_Exists(t_Ork_Horde_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Ork_Horde_Army.sgroup_name[i])) then
	
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_Ork_Horde_Army.sgroup_name[i], t_Ork_Horde_Army.blueprint[i], t_Ork_Horde_Army.marker_spawn[i], t_Ork_Horde_Army.squad_num[i], t_Ork_Horde_Army.squad_size[i])
	
	Cmd_SetStance(t_Ork_Horde_Army.sgroup_name[i], t_Ork_Horde_Army.stance[i])
	Cmd_SetMeleeStance(t_Ork_Horde_Army.sgroup_name[i], t_Ork_Horde_Army.melee_stance[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ork_horde_attack"), SGroup_FromName(t_Ork_Horde_Army.sgroup_name[i]))
	
elseif g_Ork_Horde_Army_iter > table.getn(t_Ork_Horde_Army.sgroup_name) then
	
	g_Ork_Horde_Army_iter = 0
	g_wave = g_wave + 1
	Cmd_AttackMoveMarker("sg_ork_horde_attack", "mkr_eldar_base_start")
	Rule_Remove(Rule_Ork_Horde_Army_Wave1)
	
end

g_Ork_Horde_Army_iter = g_Ork_Horde_Army_iter+1

end

function Rule_Ork_Horde_Army_Wave2()

local i = g_Ork_Horde_Army_iter 

t_Ork_Horde_Army = {
	
	sgroup_name = {"sg_ork_horde2a", "sg_ork_horde2b"},  
	blueprint = {"ork_squad_slugga", "ork_squad_slugga"},
	marker_spawn = {"mkr_ork_horde_attack_spawn1", "mkr_ork_horde_attack_spawn1"}, 
	stance = {STANCE_Attack, STANCE_Attack},
	melee_stance = {MSTANCE_Assault, MSTANCE_Assault},
	squad_num = {1, 1}, 
	squad_size = {12, 12}, 
}

if g_Ork_Horde_Army_iter <= table.getn(t_Ork_Horde_Army.sgroup_name) and (SGroup_Exists(t_Ork_Horde_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Ork_Horde_Army.sgroup_name[i])) then
	
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_Ork_Horde_Army.sgroup_name[i], t_Ork_Horde_Army.blueprint[i], t_Ork_Horde_Army.marker_spawn[i], t_Ork_Horde_Army.squad_num[i], t_Ork_Horde_Army.squad_size[i])
	Cmd_SetStance(t_Ork_Horde_Army.sgroup_name[i], t_Ork_Horde_Army.stance[i])
	Cmd_SetMeleeStance(t_Ork_Horde_Army.sgroup_name[i], t_Ork_Horde_Army.melee_stance[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ork_horde_attack"), SGroup_FromName(t_Ork_Horde_Army.sgroup_name[i]))
	
elseif g_Ork_Horde_Army_iter > table.getn(t_Ork_Horde_Army.sgroup_name) then
	g_Ork_Horde_Army_iter = 0
	g_wave = g_wave + 1
	Cmd_AttackMoveMarker("sg_ork_horde_attack", "mkr_eldar_base_start")
	Rule_Remove(Rule_Ork_Horde_Army_Wave2)
	
end

g_Ork_Horde_Army_iter = g_Ork_Horde_Army_iter+1

end

function Rule_Ork_Horde_Army_Wave3()

local i = g_Ork_Horde_Army_iter 

t_Ork_Horde_Army = {
	
	sgroup_name = {"sg_ork_horde3a", "sg_ork_horde3b"},  
	blueprint = {"ork_squad_slugga", "ork_squad_shoota_boy"},
	marker_spawn = {"mkr_ork_horde_attack_spawn1", "mkr_ork_horde_attack_spawn1"}, 
	stance = {STANCE_Attack, STANCE_Attack},
	melee_stance = {MSTANCE_Assault, MSTANCE_Ranged},
	squad_num = {1, 1}, 
	squad_size = {13, 13}, 
}

if g_Ork_Horde_Army_iter <= table.getn(t_Ork_Horde_Army.sgroup_name) and (SGroup_Exists(t_Ork_Horde_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Ork_Horde_Army.sgroup_name[i])) then
	
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_Ork_Horde_Army.sgroup_name[i], t_Ork_Horde_Army.blueprint[i], t_Ork_Horde_Army.marker_spawn[i], t_Ork_Horde_Army.squad_num[i], t_Ork_Horde_Army.squad_size[i])
	Cmd_SetStance(t_Ork_Horde_Army.sgroup_name[i], t_Ork_Horde_Army.stance[i])
	Cmd_SetMeleeStance(t_Ork_Horde_Army.sgroup_name[i], t_Ork_Horde_Army.melee_stance[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ork_horde_attack"), SGroup_FromName(t_Ork_Horde_Army.sgroup_name[i]))
	
elseif g_Ork_Horde_Army_iter > table.getn(t_Ork_Horde_Army.sgroup_name) then
	g_Ork_Horde_Army_iter = 0
	g_wave = g_wave + 1
	Cmd_AttackMoveMarker("sg_ork_horde_attack", "mkr_eldar_base_start")
	Rule_Remove(Rule_Ork_Horde_Army_Wave3)
	
end

g_Ork_Horde_Army_iter = g_Ork_Horde_Army_iter+1

end

function Rule_Ork_Horde_Army_Wave4()

local i = g_Ork_Horde_Army_iter 

t_Ork_Horde_Army = {
	
	sgroup_name = {"sg_ork_horde4a", "sg_ork_horde4b"},  
	blueprint = {"ork_squad_shoota_boy", "ork_squad_shoota_boy"},
	marker_spawn = {"mkr_ork_horde_attack_spawn1", "mkr_ork_horde_attack_spawn1"}, 
	stance = {STANCE_Attack, STANCE_Attack},
	melee_stance = {MSTANCE_Ranged, MSTANCE_Ranged},
	squad_num = {1, 1}, 
	squad_size = {14, 14}, 
}

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_Ork_Horde_Army.sgroup_name[i], t_Ork_Horde_Army.blueprint[i], t_Ork_Horde_Army.marker_spawn[i], t_Ork_Horde_Army.squad_num[i], t_Ork_Horde_Army.squad_size[i])
	Cmd_SetStance(t_Ork_Horde_Army.sgroup_name[i], t_Ork_Horde_Army.stance[i])
	Cmd_SetMeleeStance(t_Ork_Horde_Army.sgroup_name[i], t_Ork_Horde_Army.melee_stance[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ork_horde_attack"), SGroup_FromName(t_Ork_Horde_Army.sgroup_name[i]))
	
elseif g_Ork_Horde_Army_iter > table.getn(t_Ork_Horde_Army.sgroup_name) then
	
	g_Ork_Horde_Army_iter = 0
	g_wave = g_wave + 1
	Cmd_AttackMoveMarker("sg_ork_horde_attack", "mkr_eldar_base_start")
	
	Rule_Remove(Rule_Ork_Horde_Army_Wave4)
	
end

g_Ork_Horde_Army_iter = g_Ork_Horde_Army_iter+1

end

function Rule_Ork_Horde_Army_Wave5()

local i = g_Ork_Horde_Army_iter 

t_Ork_Horde_Army = {
	
	sgroup_name = {"sg_ork_horde5a", "sg_ork_horde5b"},  
	blueprint = {"ork_squad_shoota_boy", "ork_squad_shoota_boy"},
	marker_spawn = {"mkr_ork_horde_attack_spawn1", "mkr_ork_horde_attack_spawn1"}, 
	stance = {STANCE_Attack, STANCE_Attack},
	melee_stance = {MSTANCE_Ranged, MSTANCE_Ranged},
	squad_num = {1, 1}, 
	squad_size = {15, 15}, 
}

if g_Ork_Horde_Army_iter <= table.getn(t_Ork_Horde_Army.sgroup_name) and (SGroup_Exists(t_Ork_Horde_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Ork_Horde_Army.sgroup_name[i])) then
	
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_Ork_Horde_Army.sgroup_name[i], t_Ork_Horde_Army.blueprint[i], t_Ork_Horde_Army.marker_spawn[i], t_Ork_Horde_Army.squad_num[i], t_Ork_Horde_Army.squad_size[i])
	Cmd_SetStance(t_Ork_Horde_Army.sgroup_name[i], t_Ork_Horde_Army.stance[i])
	Cmd_SetMeleeStance(t_Ork_Horde_Army.sgroup_name[i], t_Ork_Horde_Army.melee_stance[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ork_horde_attack"), SGroup_FromName(t_Ork_Horde_Army.sgroup_name[i]))
	
elseif g_Ork_Horde_Army_iter > table.getn(t_Ork_Horde_Army.sgroup_name) then
	
	g_Ork_Horde_Army_iter = 0
	g_wave = g_wave + 1
	Cmd_AttackMoveMarker("sg_ork_horde_attack", "mkr_eldar_base_start")
	Rule_Remove(Rule_Ork_Horde_Army_Wave5)
	
end

Util_CreateSquadsAtMarker(g_Player3, "sg_ork_horde_armor_attack", "ork_squad_wartrak", "mkr_ork_horde_armor_attack_spawn", 1)
Cmd_AttackMoveMarker("sg_ork_horde_armor_attack", "mkr_eldar_base_start")

g_Ork_Horde_Army_iter = g_Ork_Horde_Army_iter+1

end


function Rule_Ork_Horde_Army_Wave_Control()

t_wavefunctions = {Rule_Ork_Horde_Army_Wave1, Rule_Ork_Horde_Army_Wave2, Rule_Ork_Horde_Army_Wave3, Rule_Ork_Horde_Army_Wave4}

if SGroup_Exists("sg_ork_horde_attack") == false or  (SGroup_Exists("sg_ork_horde_attack") and SGroup_IsEmpty("sg_ork_horde_attack")) then
	
	if g_wave < 4 then
		Rule_AddInterval(t_wavefunctions[g_wave], 1)
	else
		Rule_AddInterval(t_wavefunctions[4], 1)
	end
	
end

if SGroup_Exists("sg_ork_horde_attack") and SGroup_IsEmpty("sg_ork_horde_attack") == false then
	
	if EGroup_IsCapturedByPlayer( "eg_eldar_capture_point", g_Player1, true )  == true then
		--print("capturing")
		Cmd_AttackMoveMarker("sg_ork_horde_attack", "mkr_eldar_capture")
		Cmd_Capture("sg_ork_horde_attack", "eg_eldar_capture_point")
	end
	
	if EGroup_IsCapturedByPlayer( "eg_eldar_capture_point", g_Player3, false ) == true and (EGroup_Exists("eg_remaining_buildings") and EGroup_IsEmpty("eg_remaining_structures")) then
		--print("eg_eldar_capture_point taken by Player 3 and eg_remaining structures is empty")
		if SGroup_Exists("sg_ork_horde_attack") and SGroup_IsEmpty("sg_ork_horde_attack") == false then
			--print("sg_ork_horde_attack DeSpawning?")
			SGroup_DeSpawn("sg_ork_horde_attack")
		end
		
		if SGroup_Exists("sg_ork_horde_base_troops1") and SGroup_IsEmpty("sg_ork_horde_base_troops1") == false then
			--print("sg_ork_horde_base_troops1 DeSpawning?")
			SGroup_DeSpawn("sg_ork_horde_base_troops1")
		end
		
		Rule_Remove(Rule_Ork_Horde_Army_Wave_Control)
		Rule_Remove(Rule_Ork_Horde_Army_Wave_Control_Proximity)
		
	end
	
end

end

function Rule_Ork_Horde_Army_Wave_Control_Kickoff()

if g_ork_horde_attack_started == false then
	Rule_AddInterval(Rule_Ork_Horde_Army_Wave_Control, 10)
	g_ork_horde_attack_started = true
end

end

function Rule_Ork_Horde_Army_Wave_Control_Proximity()

local pos = Marker_GetPosition(Marker_FromName("mkr_ork_horde_trigger", "basic_marker"))
Player_GetAllSquadsNearPos(g_Player1 , "sg_near_ork_horde_base", pos, 20)
local pos2 = Marker_GetPosition(Marker_FromName("mkr_ork_horde_trigger2", "basic_marker"))
Player_GetAllSquadsNearPos(g_Player1 , "sg_near_ork_horde_base2", pos2, 15)

if Prox_AnySquadNearMarker("sg_near_ork_horde_base", "mkr_ork_horde_trigger") or Prox_AnySquadNearMarker("sg_near_ork_horde_base2", "mkr_ork_horde_trigger2") then
	
	if g_ork_horde_attack_started == false then
		Rule_AddInterval(Rule_Ork_Horde_Army_Wave_Control, 10)
		UI_HideCountdown()
		g_ork_horde_attack_started = true
	end
	
	Rule_Remove(Rule_Ork_Horde_Army_Wave_Control_Proximity)
	
end

end

--[[controls what happens to the orks that retaliate in revenge for the death of their leader]] function Rule_Revenge_Control()

Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_revenge_start", "ork_squad_slugga", "mkr_ork_reinforcements", 2, 8)	--2,8

g_all_current_player1_squads = Player_GetSquads(g_Player1)

for i = 1, 5 do
	if SGroup_Exists("sg_ork_bodyguard"..i) and SGroup_IsEmpty("sg_ork_bodyguard"..i) == false then
		Cmd_AttackSGroup("sg_ork_bodyguard"..i, SGroup_GetName(g_all_current_player1_squads))
	end
end

Rule_AddOneShot(Rule_IE_Relocate_At_Once, 0)
Rule_AddInterval(Rule_Ork_Revenge, 15)
Rule_Remove(Rule_Revenge_Control)

end

function Rule_Ork_Revenge()

if g_first_revenge_wave_complete == false then

	g_sgroup_ork_revenge = SGroup_CreateIfNotFound("sg_ork_revenge")
	
	for i = 1, 3 do
		Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_revenge_subgroup"..i.."a", "ork_squad_slugga", "mkr_ork_reinforcements", 1, 8)	--2, 8
		Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_revenge_subgroup"..i.."b", "ork_squad_shoota_boy", "mkr_ork_reinforcements", 1, 4)
		SGroup_AddGroup(g_sgroup_ork_revenge, SGroup_FromName("sg_ork_revenge_subgroup"..i.."a"))
		SGroup_AddGroup(g_sgroup_ork_revenge, SGroup_FromName("sg_ork_revenge_subgroup"..i.."b"))
		Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_ork_revenge_subgroup"..i.."a"), 1), "ork_burna_slugga", 1)
		--SGroup_SetMoraleInvulnerable( "sg_ork_revenge", true )
	end
	--SGroup_SetMoraleInvulnerable("sg_ork_revenge", true )
	g_first_revenge_wave_complete = true
	Cmd_AttackMoveMarker("sg_ork_revenge", "mkr_eldar_base_start")
	g_revenge_wave_number = g_revenge_wave_number + 1
	
end

if g_first_revenge_wave_complete == true then
	
	if SGroup_IsEmpty("sg_ork_revenge") then 
		
		for i = 1, 3 do
			Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_revenge_subgroup"..i.."a", "ork_squad_slugga", "mkr_ork_reinforcements", 1, 8)	--2, 8
			Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_revenge_subgroup"..i.."b", "ork_squad_shoota_boy", "mkr_ork_reinforcements", 1, 8)
			SGroup_AddGroup(g_sgroup_ork_revenge, SGroup_FromName("sg_ork_revenge_subgroup"..i.."a"))
			SGroup_AddGroup(g_sgroup_ork_revenge, SGroup_FromName("sg_ork_revenge_subgroup"..i.."b"))
			Squad_ForceUpgradeWeapons(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_ork_revenge_subgroup"..i.."a"), 1), "ork_burna_slugga", 2)
		--SGroup_SetMoraleInvulnerable( "sg_ork_revenge", true )
		end
		--SGroup_SetMoraleInvulnerable("sg_ork_revenge", true )
		Cmd_AttackMoveMarker("sg_ork_revenge", "mkr_eldar_base_start")
		
		g_revenge_wave_number = g_revenge_wave_number + 1
		
	end
	
end

if SGroup_Exists("sg_ork_revenge") and SGroup_IsEmpty("sg_ork_revenge") == false then -- and Squad_GetActiveCommand(SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_ork_revenge"), 1)) == SQUADSTATEID_Idle then
	Cmd_AttackMoveMarker("sg_ork_revenge", "mkr_eldar_base_start")
end


for i = 1, 5 do
	
	if SGroup_Exists("sg_ork_bodyguard"..i) and SGroup_IsEmpty("sg_ork_bodyguard"..i) == false then
		Cmd_MoveToMarker("sg_ork_bodyguard"..i, "mkr_ork_bodyguard4")
		Cmd_AttackMoveMarker("sg_ork_bodyguard"..i, "mkr_eldar_base_start")
		--Cmd_AttackSGroup("sg_ork_bodyguard"..i, SGroup_GetName(g_all_current_player1_squads))
	end
	
end


if	g_first_jump_objective_added == false then
	
	Rule_AddInterval(Rule_Webway_Gate_At_First_Jump_Check, 1)
	Rule_AddInterval(Rule__Objective_First_WebwayBuilt, 1)
	g_first_jump_objective_added = true
	
end

if g_eldar_base_at_first_jump_location == true then
	
	Rule_AddInterval(Rule_Pipe_Attack, 15)
	
	Rule_Remove(Rule_Ork_Revenge)
	
end

end

--[[determines which units attack the pipe when the pipe is supposed to be under attack]] function Rule_Pipe_Attack()

if SGroup_Exists("sg_ork_revenge") and SGroup_IsEmpty("sg_ork_revenge") == false then
	--Cmd_AttackEGroup("sg_ork_revenge", "eg_pipegate")
	Cmd_SetStance("sg_ork_revenge", STANCE_CeaseFire)
	Cmd_MoveToMarker("sg_ork_revenge", "mkr_ork_bodyguard1")
end

if SGroup_Exists("sg_ork_base_defence") and SGroup_IsEmpty("sg_ork_base_defence") == false then
	Cmd_MoveToMarker("sg_ork_base_defence", "mkr_ork_patrol6")
	Cmd_SetMeleeStance("sg_ork_base_defence", MSTANCE_Ranged)
	Cmd_SetStance("sg_ork_base_defence", STANCE_StandGround)
end

if SGroup_Exists("sg_pipe_attackers") == false or SGroup_IsEmpty("sg_pipe_attackers") then
	Util_CreateSquadsAtMarkerEx(g_Player3, "sg_pipe_attackers", "ork_squad_slugga", "mkr_ork_reinforcements", 1, 8)	-- 3, 12
	Cmd_SetStance("sg_pipe_attackers", STANCE_Burn)
	Cmd_AttackMoveMarker("sg_pipe_attackers", "mkr_ork_pipe_action_reveal")
elseif SGroup_Exists("sg_pipe_attackers") or SGroup_IsEmpty("sg_pipe_attackers") == false then
	Cmd_SetStance("sg_pipe_attackers", STANCE_Burn)
	Cmd_AttackEGroup("sg_pipe_attackers", "eg_pipegate")
end

end

function Rule_Webway_Gate_At_First_Jump_Check() if (g_webway_gate_at_first_jump_location == false) then Player_GetAllEntitiesNearMarker(g_Player1, "eg_webway_gate_at_first_jump", "mkr_eldarbasejump1")

	if (EGroup_ContainsBlueprints(EGroup_FromName("eg_webway_gate_at_first_jump"), t_eldar_webway_gate, false) == true) and  (EGroup_GetAvgHealth("eg_webway_gate_at_first_jump") == 1.0) then
		
		g_webway_gate_at_first_jump_location = true
		Rule_AddInterval(Rule__Objective_First_EldarBaseJump, 1)
		Rule_AddInterval(Rule_Eldar_Base_First_Location_Jump_Check, 1)
		
	end
	EGroup_Destroy(EGroup_FromName("eg_webway_gate_at_first_jump"))
elseif (g_webway_gate_at_first_jump_location == true) then
	Rule_Remove(Rule_Webway_Gate_At_First_Jump_Check)
end

end

function Rule_Eldar_Base_First_Location_Jump_Check()

if (g_eldar_base_at_first_jump_location == false) and (g_webway_gate_at_first_jump_location == true) then
	
	if (Prox_AllEntitiesNearMarker("eg_eldar_hq", "mkr_allowed_radius_around_webway_gate1") == true) then
		g_eldar_base_at_first_jump_location = true
		
	end
	
elseif (g_eldar_base_at_first_jump_location == true) then 
		
	Rule_AddOneShot(Rule_IE_First_Move_Successful, 4)
	Util_Ping_Stop("ping_jump1ping")
	
	EGroup_SetPlayerOwner("eg_pipegate", g_Player1)  -- g_Player1
		
	Rule_AddInterval(Rule_Webway_Gate_At_Second_Jump_Check, 1)
	Rule_AddInterval(Rule__Objective_Second_WebwayBuilt, 1)
	Util_Ping_LoopingMkr("ping_jump2ping", "mkr_eldarbasejump2")
	
	-- 4.5 Minute Countdown until Eldar HQ can relocate (although 1 or 2 may jump before, all will not be able to do so until they recharge)
	UI_ShowCountdown(820300, 270)
	Rule_AddOneShot(Rule_Initiate_Pipe_Break_Moment, 280) -- calls moment after countdown ends + 10 seconds to allow player some time to move buildings before the onslaught
	
	
	if g_ork_horde_attack_started == false then
		
		g_raider_sgroup = SGroup_CreateIfNotFound("sg_ork_raiding_party")		
		sgrouporkraiders1 = Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_raiders1", "ork_squad_slugga", "mkr_ork_raider_spawn", 2, 12)
		sgrouporkraiders1b = Util_CreateSquadsAtMarker(g_Player3, "sg_ork_raiders3", "ork_squad_killa_kan", "mkr_ork_raider_spawn", 2)
		sgrouporkraiders1c = Util_CreateSquadsAtMarker(g_Player3, "sg_ork_raiders4", "ork_squad_looted_tank", "mkr_ork_raider_spawn", 2)
		--Cmd_JumpToMarker("sg_ork_raiders1", "mkr_eldar_base_start")
		Cmd_AttackMoveMarker("sg_ork_raiders1", "mkr_eldar_base_start")
		Cmd_AttackMoveMarker("sg_ork_raiders3", "mkr_eldar_base_start")
		Cmd_AttackMoveMarker("sg_ork_raiders4", "mkr_eldar_base_start")
		
		SGroup_AddGroup(g_raider_sgroup, sgrouporkraiders1)
		SGroup_AddGroup(g_raider_sgroup, sgrouporkraiders1b)
		SGroup_AddGroup(g_raider_sgroup, sgrouporkraiders1c)
		
	elseif g_ork_horde_attack_started == true then
		
		Util_CreateSquadsAtMarker(g_Player3, "sg_ork_raiders4", "ork_squad_looted_tank", "mkr_ork_raider_spawn", 2)
		Cmd_AttackMoveMarker("sg_ork_raiders4", "mkr_eldar_base_start")
		
	end
	
	Rule_Remove(Rule_Taldeer_Track)
	Rule_AddInterval(Rule_Taldeer_First_Track, 2)
	Rule_Check_AddOneShot(Rule_Find_Eldar_Buildings_At_First_Jump_Location, 1)
	
	g_raider_sgroup = SGroup_CreateIfNotFound("sg_ork_raiding_party")		
	sgrouporkraiders2 = Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_raiders2", "ork_squad_slugga", "mkr_ork_reinforcements", 2, 8)
	SGroup_AddGroup(g_raider_sgroup, sgrouporkraiders2)
	
	Cmd_AttackMoveMarker("sg_ork_raiders2", "mkr_ork_pipe_action_reveal")
	Cmd_SetMeleeStance("sg_ork_raiders2", MSTANCE_Ranged)
	--Cmd_AttackEGroup("sg_ork_raiders2", "eg_pipegate")
	Cmd_MoveToMarker("sg_ork_raiders2", "mkr_ork_bodyguard1")
	
	FOW_RevealMarker("mkr_ork_pipe_action_reveal", 290)
	Rule_AddOneShot(Rule_Ork_Attack_On_First_Jump_Location_Control, 0)
	
	Rule_AddInterval(Rule_Ork_Tank_Track, 5)
	
	Rule_Remove(Rule_Eldar_Base_First_Location_Jump_Check)
	
end

end

function Rule_Initiate_Pipe_Break_Moment() -- Starts pipe breaking moment -- not an NIS anymore

FOW_RevealMarker("mkr_eldarbasejump1", 120 )
FOW_RevealMarker("mkr_wraithlords_last_stand", 10 )
FOW_RevealMarker("mkr_ork_pipe_action_reveal", 10 )
Anim_PlayEGroupAnim(EGroup_FromName("eg_pipegate"), "die")
g_pipegate_destroyed = true
EGroup_DeSpawn("eg_pipegate1_side")
EGroup_ReSpawn("eg_pipegate1_side_destroyed")
Sound_PlayStinger("stinger_mso3_wraithlords")
Rule_AddOneShot(Rule_Pipegate_Despawn, 3) 

end

--[[ despawns gate a few seconds after the die effect is played, so that the object doesn't just disappear. also gives commands to Ork units behind the pipe]] function Rule_Pipegate_Despawn()

FOW_Reset()

EGroup_DeSpawn("eg_pipegate")
--[[
if SGroup_Exists("sg_ork_raiders4") and SGroup_IsEmpty("sg_ork_raiders4") == false then
	Cmd_AttackMoveMarker("sg_ork_raiders4", "mkr_eldarbasejump1")
end]]
	
if SGroup_Exists("sg_ork_revenge") and SGroup_IsEmpty("sg_ork_revenge") == false then
	Cmd_SetStance("sg_ork_revenge", STANCE_Attack)
	Cmd_AttackMoveMarker("sg_ork_raiders2", "mkr_eldarbasejump1")
end

if SGroup_Exists("sg_pipe_attackers") and SGroup_IsEmpty("sg_pipe_attackers") == false then
	Cmd_AttackMoveMarker("sg_pipe_attackers", "mkr_eldarbasejump1")
end

Rule_AddInterval(Rule_Pipe_Attackers_Focus, 10)

Rule_Remove(Rule_Pipe_Attack)

end

-- focuses attack on the eldar base at the first location. Puts pressure on, but not too much... The tanks will arrive once the ork infantry are dead. function Rule_Pipe_Attackers_Focus()

if SGroup_Exists("sg_pipe_attackers") and SGroup_IsEmpty("sg_pipe_attackers") == false then
	
	if SGroup_CheckActiveCommand("sg_pipe_attackers", SQUADSTATEID_Idle, true) then
		Cmd_AttackMoveMarker("sg_pipe_attackers", "mkr_eldarbasejump1")
	end
	
end

if SGroup_Exists("sg_ork_revenge") and SGroup_IsEmpty("sg_ork_revenge") == false then
	
	if SGroup_CheckActiveCommand("sg_ork_revenge", SQUADSTATEID_Idle, true) then
		Cmd_AttackMoveMarker("sg_ork_revenge", "mkr_eldarbasejump1")
	end
	
elseif SGroup_Exists("sg_ork_revenge") and SGroup_IsEmpty("sg_ork_revenge") == true then
	
	if SGroup_Exists("sg_ork_raiders4") and SGroup_IsEmpty("sg_ork_raiders4") == false then
		
		if SGroup_CheckActiveCommand("sg_ork_raiders4", SQUADSTATEID_Idle, true) then
			Cmd_AttackMoveMarker("sg_ork_raiders4", "mkr_eldarbasejump1")
		end
		
	end
	
end

end

function Rule_Find_Eldar_Buildings_At_First_Jump_Location()

Player_GetAllEntitiesNearMarker(g_Player1, "eg_add_remaining_structures", "mkr_eldar_base_start")

local buildingcount = EGroup_Count(EGroup_FromName("eg_add_remaining_structures"))	

for i = 1, buildingcount do
	local Indexed = EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_add_remaining_structures"), i)
	
	if Entity_IsBuilding(EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_add_remaining_structures"), i))	then
		if (Entity_GetBlueprintName(Indexed) == "eldar_webway_gate") or (Entity_GetBlueprintName(Indexed) == "eldar_listening_post") then
			EGroup_Add(EGroup_CreateIfNotFound("eg_remaining_structures"), Indexed)
		end
	end
end	

EGroup_Clear(EGroup_FromName("eg_add_remaining_structures"))

Rule_AddInterval(Rule_Raider_Control, 2)

end

function Rule_Raider_Control() --Player_GetAllEntitiesNearMarker(g_Player1, "eg_remaining_structures", "mkr_eldar_base_start")

if EGroup_Exists("eg_remaining_structures") and EGroup_IsEmpty("eg_remaining_structures") == false then
	
	if SGroup_Exists("sg_ork_raiders1") and SGroup_IsEmpty("sg_ork_raiders1") == false then
		--Cmd_AttackEGroup("sg_ork_raiders1", "eg_remaining_structures")
		Cmd_AttackMoveMarker("sg_ork_raiders1", "mkr_eldar_base_start")
	end
	
	if SGroup_Exists("sg_ork_raiders3") and SGroup_IsEmpty("sg_ork_raiders3") == false then
		--Cmd_AttackEGroup("sg_ork_raiders3", "eg_remaining_structures")
		Cmd_AttackMoveMarker("sg_ork_raiders3", "mkr_eldar_base_start")
	end
	--[[
	if SGroup_Exists("sg_ork_raiders4") and SGroup_IsEmpty("sg_ork_raiders4") == false then
		Cmd_AttackMoveMarker("sg_ork_raiders4", "mkr_eldar_base_start")
	end]]
	--Cmd_AttackEGroup("sg_ork_raiders4", "eg_remaining_structures")
end

if EGroup_Exists("eg_remaining_structures") and EGroup_IsEmpty("eg_remaining_structures") then
	
	if SGroup_Exists("sg_ork_raiders1") and SGroup_IsEmpty("sg_ork_raiders1") == false then
		Cmd_AttackMoveMarker("sg_ork_raiders1", "mkr_eldar_capture")
		
		Cmd_Capture("sg_ork_raiders1", "eg_eldar_capture_point")
	end
	
	Rule_AddInterval(Rule_Raider_Despawn_Control, 20)
	Rule_Remove(Rule_Raider_Control)
	
end

end

function Rule_Raider_Despawn_Control() -- can't use FOR loop because Raider 2 is needed. if (EGroup_Exists("eg_remaining_structures") and EGroup_IsEmpty("eg_remaining_structures")) and (EGroup_IsCapturedByPlayer( "eg_eldar_capture_point", g_Player3, true )) then

	Rule_Check_AddOneShot(Rule_Delayed_Raider_Despawn, 10)
	
	Rule_Remove(Rule_Raider_Despawn_Control)
end

end

function Rule_Delayed_Raider_Despawn() if SGroup_Exists("sg_ork_raiders1") and SGroup_IsEmpty("sg_ork_raiders1") == false then SGroup_DeSpawn("sg_ork_raiders1") end if SGroup_Exists("sg_ork_raiders3") and SGroup_IsEmpty("sg_ork_raiders3") == false then SGroup_DeSpawn("sg_ork_raiders3") end --[[ if SGroup_Exists("sg_ork_raiders4") and SGroup_IsEmpty("sg_ork_raiders4") == false then SGroup_DeSpawn("sg_ork_raiders4") end]] end

function Rule_Ork_Attack_On_First_Jump_Location_Control() local l_random_time_between_attacks = World_GetRand(10, 20) Rule_AddOneShot(Rule_Ork_Attack_On_First_Jump_Location, l_random_time_between_attacks) end

function Rule_Ork_Attack_On_First_Jump_Location()

if g_eldar_base_at_second_jump_location == false then
	
	local l_random_size = World_GetRand(4, 8) -- min 6, max 10
	local l_random_number_of_sgs = World_GetRand(1, 4) -- min 1, max 4
	
	if g_jump_assault_first_wave == true then
		
		g_ork_first_jump_assault = SGroup_CreateIfNotFound("sg_ork_first_jump_location_assault")
		
		for i = 1, 4 do
			
			if SGroup_Exists("sg_ork_first_jump_location_attackers"..i) == false or SGroup_IsEmpty("sg_ork_first_jump_location_attackers"..i) then
				
				t_ork_first_jump_assault_subgroup[i] = Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_first_jump_location_attackers"..i, "ork_squad_stormboy", "mkr_ork_first_jump_location_attackers"..i, 1, 4)
				SGroup_AddGroup(g_ork_first_jump_assault, t_ork_first_jump_assault_subgroup[i])
				Cmd_JumpToMarker("sg_ork_first_jump_location_attackers"..i, "mkr_ork_attackers_jump"..i)
				
			end
			
		end
		
		Rule_AddOneShot(Rule_Ork_Attack_On_First_Jump_Location_Control, 1)
		g_jump_assault_first_wave = false
		
	elseif g_jump_assault_first_wave == false then
		
		for i = 1, l_random_number_of_sgs do
			
			Cmd_JumpToMarker("sg_ork_first_jump_location_attackers"..i, "mkr_ork_attackers_jump"..i) --[[added by berger to fix problem with guys not attacking on loading autosave]]
			
			if SGroup_Exists("sg_ork_first_jump_location_attackers"..i) == false or SGroup_IsEmpty("sg_ork_first_jump_location_attackers"..i) then
				
				t_ork_first_jump_assault_subgroup[i] = Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_first_jump_location_attackers"..i, "ork_squad_stormboy", "mkr_ork_first_jump_location_attackers"..i, 1, l_random_size)
				SGroup_AddGroup(g_ork_first_jump_assault, t_ork_first_jump_assault_subgroup[i])
				Cmd_JumpToMarker("sg_ork_first_jump_location_attackers"..i, "mkr_ork_attackers_jump"..i)
				
			end
			
		end
		
		Rule_AddOneShot(Rule_Ork_Attack_On_First_Jump_Location_Control, 1)
		
	end
	
	Rule_Check_AddInterval(Rule_Ork_Attack_On_First_Jump_Location_Focus, 3)
	
--we may change the following elseif to kick much later if at all
	
elseif g_eldar_base_at_second_jump_location == true and g_first_ork_attack_moved == false then
	
	Cmd_AttackMoveMarker("sg_ork_first_jump_location_assault", "mkr_eldarbasejump1")
	g_first_ork_attack_moved = true
	
elseif Prox_AnySquadNearMarker("sg_ork_first_jump_location_assault", "mkr_eldarbasejump1") and g_first_ork_attack_moved == true then
		--Cmd_Capture("sg_ork_raiders1", "eg_eldar_capture_point2")	
end
	

end

function Rule_Ork_Attack_On_First_Jump_Location_Focus()

for i = 1, 4 do
	if SGroup_Exists("sg_ork_first_jump_location_attackers"..i) == false or SGroup_IsEmpty("sg_ork_first_jump_location_attackers"..i) then
		Cmd_AttackMoveMarker("sg_ork_first_jump_location_attackers"..i, "mkr_eldarbasejump1")
	end
end

end

function Rule_Webway_Gate_At_Second_Jump_Check()

if (g_webway_gate_at_second_jump_location == false) then
	
	Player_GetAllEntitiesNearMarker(g_Player1, "eg_webway_gate_at_second_jump", "mkr_eldarbasejump2")
	
	if (EGroup_ContainsBlueprints(EGroup_FromName("eg_webway_gate_at_second_jump"), t_eldar_webway_gate, false) == true) and  (EGroup_GetAvgHealth("eg_webway_gate_at_second_jump") == 1.0) then
		g_webway_gate_at_second_jump_location = true
		Rule_AddInterval(Rule__Objective_Second_EldarBaseJump, 1)
		Rule_AddInterval(Rule_Eldar_Base_Second_Location_Jump_Check, 1)
			
	end
	
	EGroup_Destroy(EGroup_FromName("eg_webway_gate_at_second_jump"))
	
elseif (g_webway_gate_at_second_jump_location == true) then
	
	Rule_Remove(Rule_Webway_Gate_At_Second_Jump_Check)
	
end

end

function Rule_Ork_Attack_On_Second_Jump_Location()

for i = 1,4 do
	
	if SGroup_Exists("sg_ork_first_jump_location_attackers"..i) and SGroup_IsEmpty("sg_ork_first_jump_location_attackers"..i) == false then
		
		Cmd_MoveToMarker("sg_ork_first_jump_location_attackers"..i, "mkr_pre_jump")
		
		if Prox_AnySquadNearMarker("sg_ork_first_jump_location_attackers"..i, "mkr_pre_jump") then
			Cmd_JumpToMarker("sg_ork_first_jump_location_attackers"..i, "mkr_eldarbasejump2")
			t_ork_jumped_over_to_second_location[i] = true
		end
		
		if t_ork_jumped_over_to_second_location[i] == true then
			Cmd_AttackMoveMarker("sg_ork_first_jump_location_attackers"..i, "mkr_eldarbasejump2")
			--Rule_Remove(Rule_Ork_Attack_On_Second_Jump_Location) -- removes rule, when in use in Rule_Ork_Attack_On_Eldar_Second_Location_Wave_Control
		end
		
		if t_ork_jumped_over_to_second_location[i] == true and g_eldar_base_at_final_jump_location == true then
			Cmd_AttackMoveMarker("sg_ork_first_jump_location_attackers"..i, "mkr_ork_destination")
			--Rule_Remove(Rule_Ork_Attack_On_Second_Jump_Location) -- removes rule, when in use in Rule_Ork_Attack_On_Eldar_Second_Location_Wave_Control
		end
		
	end
	
end

for i = 1,4 do
	
	local l_random_number = World_GetRand(4, 8)
	
	if SGroup_Exists("sg_ork_second_jump_location_attackers"..i) == false or SGroup_IsEmpty("sg_ork_second_jump_location_attackers"..i) == true then	
		Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_second_jump_location_attackers"..i, "ork_squad_slugga", "mkr_ork_finalpush2", 1, l_random_number) -- 1, 6
		Cmd_AttackMoveMarker("sg_ork_second_jump_location_attackers"..i, "mkr_eldarbasejump2")
	end
	
end	

end


function Rule_Ork_Attack_On_Eldar_Second_Location_Wave_Control()

if (g_wave2 == 1 and (SGroup_Exists("sg_ork_second_location_attack") == false)) or  ( g_wave2 == 1 and SGroup_Exists("sg_ork_second_location_attack") and SGroup_IsEmpty("sg_ork_second_location_attack")) then 
	Rule_AddInterval(Rule_Ork_Attack_On_Eldar_Second_Location_Infantry_Wave, 0)
elseif (g_wave2 == 2 and (SGroup_Exists("sg_ork_second_location_attack") == false)) or  (g_wave2 == 2 and SGroup_Exists("sg_ork_second_location_attack") and SGroup_IsEmpty("sg_ork_second_location_attack")) then 
	Rule_AddInterval(Rule_Ork_Attack_On_Eldar_Second_Location_Infantry_Wave2, 0)
elseif (g_wave2 == 3 and (SGroup_Exists("sg_ork_second_location_attack") == false)) or  (g_wave2 == 3 and SGroup_Exists("sg_ork_second_location_attack") and SGroup_IsEmpty("sg_ork_second_location_attack")) then 
	Rule_AddInterval(Rule_Ork_Attack_On_Eldar_Second_Location_Infantry_Wave3, 0)
elseif (g_wave2 == 4 and (SGroup_Exists("sg_ork_second_location_attack") == false)) or  (g_wave2 == 4 and SGroup_Exists("sg_ork_second_location_attack") and SGroup_IsEmpty("sg_ork_second_location_attack")) then 
	Rule_AddInterval(Rule_Ork_Attack_On_Eldar_Second_Location_Infantry_Wave4, 0)
elseif (g_wave2 >= 5 and (SGroup_Exists("sg_ork_second_location_attack") == false)) or  (g_wave2 >= 5 and SGroup_Exists("sg_ork_second_location_attack") and SGroup_IsEmpty("sg_ork_second_location_attack")) then 
	Rule_AddInterval(Rule_Ork_Attack_On_Eldar_Second_Location_Infantry_Wave5, 0)
end

--Rule_AddInterval(Rule_Ork_Attack_On_Second_Jump_Location, 1)

local random_armor = World_GetRand(1, 2)

if random_armor == 1 then
	if (g_wave2 >= 5 and (SGroup_Exists("sg_ork_second_location_armor_attack") == false)) or  ( g_wave2 >= 5 and SGroup_Exists("sg_ork_second_location_armor_attack") and SGroup_IsEmpty("sg_ork_second_location_armor_attack")) then 
		Rule_AddInterval(Rule_Ork_Attack_On_Eldar_Second_Location_Armor_Wave, 0)
	end
elseif random_armor == 2 then
end
g_eldar_second_location_attack_started = false

end

function Rule_Ork_Attack_On_Eldar_Second_Location_Wave_Control_Kickoff()

if g_eldar_second_location_attack_started == false and (SGroup_Exists("sg_ork_second_location_attack") == false or (SGroup_Exists("sg_ork_second_location_attack") and SGroup_IsEmpty("sg_ork_second_location_attack"))) then
	local l_random_time = World_GetRand(10, 20)
	
	Rule_AddOneShot(Rule_Ork_Attack_On_Eldar_Second_Location_Wave_Control, l_random_time) 
	
	g_eldar_second_location_attack_started = true
end

if g_eldar_base_at_final_jump_location == true then
	Rule_Remove(Rule_Ork_Attack_On_Eldar_Second_Location_Wave_Control_Kickoff)
end

end

function Rule_Ork_Attack_On_Eldar_Second_Location_Infantry_Wave()

local i = g_Ork_Second_Location_Infantry_Army_iter 

t_Ork_Second_Location_Infantry_Army = {
	
	sgroup_name = {"sg_ork_second_location_attack_type1", "sg_ork_second_location_attack_type2"},  
	blueprint = {"ork_squad_slugga", "ork_squad_slugga"},
	marker_spawn = {"mkr_ork_second_location_start1", "mkr_ork_second_location_start2"}, 
	stance = {STANCE_Attack, STANCE_Attack},
	melee_stance = {MSTANCE_Assault, MSTANCE_Assault},
	squad_num = {1, 1}, 
	squad_size = {6, 6}, 
}
--[[
local random_type = World_GetRand(1, 2)
local random_spawn = World_GetRand(1, 2)
local random_squad_number = World_GetRand(1, 2)
local random_squad_size = World_GetRand(4, 8)]]

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.blueprint[i], t_Ork_Second_Location_Infantry_Army.marker_spawn[i], t_Ork_Second_Location_Infantry_Army.squad_num[i], t_Ork_Second_Location_Infantry_Army.squad_size[i]) -- t_Ork_Second_Location_Infantry_Army.squad_size[World_GetRand(4, 10)]
	Cmd_SetStance(t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.stance[i])
	Cmd_SetMeleeStance(t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.melee_stance[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ork_second_location_attack"), SGroup_FromName(t_Ork_Second_Location_Infantry_Army.sgroup_name[i]))
	
	local l_eldar_count = Player_GetAllSquadsNearMarker(g_Player1, "sg_eldar_count", "mkr_allowed_radius_around_webway_gate2")
	
	if SGroup_Count(SGroup_FromName("sg_eldar_count")) >= 2 then 
		Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_supplement"..i, t_Ork_Second_Location_Infantry_Army.blueprint[i], t_Ork_Second_Location_Infantry_Army.marker_spawn[i], t_Ork_Second_Location_Infantry_Army.squad_num[i], t_Ork_Second_Location_Infantry_Army.squad_size[i]) -- t_Ork_Second_Location_Infantry_Army.squad_size[World_GetRand(4, 10)]
		Cmd_SetStance("sg_ork_supplement"..i, t_Ork_Second_Location_Infantry_Army.stance[i])
		Cmd_SetMeleeStance(t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.melee_stance[i])
		SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ork_second_location_attack"), SGroup_FromName("sg_ork_supplement"..i))
	end
	
elseif g_Ork_Second_Location_Infantry_Army_iter > table.getn(t_Ork_Second_Location_Infantry_Army.sgroup_name) then
	
	g_Ork_Second_Location_Infantry_Army_iter = 0
	--print("g_wave2 = "..g_wave2)
	g_wave2 = g_wave2 + 1
			
	if g_eldar_base_at_final_jump_location == false then
		Cmd_AttackMoveMarker("sg_ork_second_location_attack", "mkr_eldarbasejump2")
	elseif g_eldar_base_at_final_jump_location == true then
		Cmd_AttackMoveMarker("sg_ork_second_location_attack", "mkr_ork_destination")
	end
	
	Rule_Remove(Rule_Ork_Attack_On_Eldar_Second_Location_Infantry_Wave)
	
end

g_Ork_Second_Location_Infantry_Army_iter = g_Ork_Second_Location_Infantry_Army_iter+1

end

function Rule_Ork_Attack_On_Eldar_Second_Location_Infantry_Wave2()

local i = g_Ork_Second_Location_Infantry_Army_iter 

t_Ork_Second_Location_Infantry_Army = {
	sgroup_name = {"sg_ork_second_location_attack_type1", "sg_ork_second_location_attack_type2"},  
	blueprint = {"ork_squad_slugga", "ork_squad_shoota_boy"},
	marker_spawn = {"mkr_ork_second_location_start1", "mkr_ork_second_location_start2"}, 
	stance = {STANCE_Attack, STANCE_Attack},
	melee_stance = {MSTANCE_Assault, MSTANCE_Ranged},
	squad_num = {1, 1}, 
	squad_size = {8, 8}, 
}

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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.blueprint[i], t_Ork_Second_Location_Infantry_Army.marker_spawn[i], t_Ork_Second_Location_Infantry_Army.squad_num[i], t_Ork_Second_Location_Infantry_Army.squad_size[i]) -- t_Ork_Second_Location_Infantry_Army.squad_size[World_GetRand(4, 10)]
	Cmd_SetStance(t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.stance[i])
	Cmd_SetMeleeStance(t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.melee_stance[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ork_second_location_attack"), SGroup_FromName(t_Ork_Second_Location_Infantry_Army.sgroup_name[i]))
	local l_eldar_count = Player_GetAllSquadsNearMarker(g_Player1, "sg_eldar_count", "mkr_allowed_radius_around_webway_gate2")
	
	if SGroup_Count(SGroup_FromName("sg_eldar_count")) >= 2 then 
		Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_supplement"..i, t_Ork_Second_Location_Infantry_Army.blueprint[i], t_Ork_Second_Location_Infantry_Army.marker_spawn[i], t_Ork_Second_Location_Infantry_Army.squad_num[i], t_Ork_Second_Location_Infantry_Army.squad_size[i]) -- t_Ork_Second_Location_Infantry_Army.squad_size[World_GetRand(4, 10)]
		Cmd_SetStance("sg_ork_supplement"..i, t_Ork_Second_Location_Infantry_Army.stance[i])
		Cmd_SetMeleeStance(t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.melee_stance[i])
		SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ork_second_location_attack"), SGroup_FromName("sg_ork_supplement"..i))
	end
		
elseif g_Ork_Second_Location_Infantry_Army_iter > table.getn(t_Ork_Second_Location_Infantry_Army.sgroup_name) then

	g_Ork_Second_Location_Infantry_Army_iter = 0
		
	--print("g_wave2 = "..g_wave2)
		
	g_wave2 = g_wave2 + 1
	
	if g_eldar_base_at_final_jump_location == false then
		Cmd_AttackMoveMarker("sg_ork_second_location_attack", "mkr_eldarbasejump2")
	elseif g_eldar_base_at_final_jump_location == true then
		Cmd_AttackMoveMarker("sg_ork_second_location_attack", "mkr_ork_destination")
	end
	
	Rule_Remove(Rule_Ork_Attack_On_Eldar_Second_Location_Infantry_Wave2)
	
end

g_Ork_Second_Location_Infantry_Army_iter = g_Ork_Second_Location_Infantry_Army_iter+1

end

function Rule_Ork_Attack_On_Eldar_Second_Location_Infantry_Wave3()

local i = g_Ork_Second_Location_Infantry_Army_iter 

t_Ork_Second_Location_Infantry_Army = {
	
	sgroup_name = {"sg_ork_second_location_attack_type1", "sg_ork_second_location_attack_type2"},  
	blueprint = {"ork_squad_shoota_boy", "ork_squad_shoota_boy"},
	marker_spawn = {"mkr_ork_second_location_start1", "mkr_ork_second_location_start2"}, 
	stance = {STANCE_Attack, STANCE_Attack},
	melee_stance = {MSTANCE_Ranged, MSTANCE_Ranged},
	squad_num = {1, 1}, 
	squad_size = {10, 10}, 
}


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

	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.blueprint[i], t_Ork_Second_Location_Infantry_Army.marker_spawn[i], t_Ork_Second_Location_Infantry_Army.squad_num[i], t_Ork_Second_Location_Infantry_Army.squad_size[i]) -- t_Ork_Second_Location_Infantry_Army.squad_size[World_GetRand(4, 10)]
	Cmd_SetStance(t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.stance[i])
	Cmd_SetMeleeStance(t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.melee_stance[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ork_second_location_attack"), SGroup_FromName(t_Ork_Second_Location_Infantry_Army.sgroup_name[i]))
	
	
	local l_eldar_count = Player_GetAllSquadsNearMarker(g_Player1, "sg_eldar_count", "mkr_allowed_radius_around_webway_gate2")
	
	if SGroup_Count(SGroup_FromName("sg_eldar_count")) >= 2 then 
		Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_supplement"..i, t_Ork_Second_Location_Infantry_Army.blueprint[i], t_Ork_Second_Location_Infantry_Army.marker_spawn[i], t_Ork_Second_Location_Infantry_Army.squad_num[i], t_Ork_Second_Location_Infantry_Army.squad_size[i]) -- t_Ork_Second_Location_Infantry_Army.squad_size[World_GetRand(4, 10)]
		Cmd_SetStance("sg_ork_supplement"..i, t_Ork_Second_Location_Infantry_Army.stance[i])
		Cmd_SetMeleeStance(t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.melee_stance[i])
		SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ork_second_location_attack"), SGroup_FromName("sg_ork_supplement"..i))
	end
	
	
	
elseif g_Ork_Second_Location_Infantry_Army_iter > table.getn(t_Ork_Second_Location_Infantry_Army.sgroup_name) then
	
	g_Ork_Second_Location_Infantry_Army_iter = 0
	--print("g_wave2 = "..g_wave2)
		
	g_wave2 = g_wave2 + 1
	if g_eldar_base_at_final_jump_location == false then
		Cmd_AttackMoveMarker("sg_ork_second_location_attack", "mkr_eldarbasejump2")
	elseif g_eldar_base_at_final_jump_location == true then
		Cmd_AttackMoveMarker("sg_ork_second_location_attack", "mkr_ork_destination")
	end
	
	Rule_Remove(Rule_Ork_Attack_On_Eldar_Second_Location_Infantry_Wave3)
	
end

g_Ork_Second_Location_Infantry_Army_iter = g_Ork_Second_Location_Infantry_Army_iter+1

end

function Rule_Ork_Attack_On_Eldar_Second_Location_Infantry_Wave4()

local i = g_Ork_Second_Location_Infantry_Army_iter 

t_Ork_Second_Location_Infantry_Army = {
	
	sgroup_name = {"sg_ork_second_location_attack_type1", "sg_ork_second_location_attack_type2"},  
	blueprint = {"ork_squad_shoota_boy", "ork_squad_shoota_boy"},
	marker_spawn = {"mkr_ork_second_location_start1", "mkr_ork_second_location_start2"}, 
	stance = {STANCE_Attack, STANCE_Attack},
	melee_stance = {MSTANCE_Ranged, MSTANCE_Ranged},
	squad_num = {1, 1}, 
	squad_size = {12, 12}, 
}
--[[
local random_type = World_GetRand(1, 2)
local random_spawn = World_GetRand(1, 2)
local random_squad_number = World_GetRand(1, 2)
local random_squad_size = World_GetRand(4, 8)]]

if g_Ork_Second_Location_Infantry_Army_iter <= table.getn(t_Ork_Second_Location_Infantry_Army.sgroup_name) and (SGroup_Exists(t_Ork_Second_Location_Infantry_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Ork_Second_Location_Infantry_Army.sgroup_name[i])) then
	
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.blueprint[i], t_Ork_Second_Location_Infantry_Army.marker_spawn[i], t_Ork_Second_Location_Infantry_Army.squad_num[i], t_Ork_Second_Location_Infantry_Army.squad_size[i]) -- t_Ork_Second_Location_Infantry_Army.squad_size[World_GetRand(4, 10)]
	
	Cmd_SetStance(t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.stance[i])
	Cmd_SetMeleeStance(t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.melee_stance[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ork_second_location_attack"), SGroup_FromName(t_Ork_Second_Location_Infantry_Army.sgroup_name[i]))
	
	local l_eldar_count = Player_GetAllSquadsNearMarker(g_Player1, "sg_eldar_count", "mkr_allowed_radius_around_webway_gate2")
	
	if SGroup_Count(SGroup_FromName("sg_eldar_count")) >= 2 then 
		Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_supplement"..i, t_Ork_Second_Location_Infantry_Army.blueprint[i], t_Ork_Second_Location_Infantry_Army.marker_spawn[i], t_Ork_Second_Location_Infantry_Army.squad_num[i], t_Ork_Second_Location_Infantry_Army.squad_size[i]) -- t_Ork_Second_Location_Infantry_Army.squad_size[World_GetRand(4, 10)]
		Cmd_SetStance("sg_ork_supplement"..i, t_Ork_Second_Location_Infantry_Army.stance[i])
		Cmd_SetMeleeStance(t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.melee_stance[i])
		SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ork_second_location_attack"), SGroup_FromName("sg_ork_supplement"..i))
	end
	
		
elseif g_Ork_Second_Location_Infantry_Army_iter > table.getn(t_Ork_Second_Location_Infantry_Army.sgroup_name) then
	
	g_Ork_Second_Location_Infantry_Army_iter = 0
		--print("g_wave2 = "..g_wave2)
	
	g_wave2 = g_wave2 + 1
	
	if g_eldar_base_at_final_jump_location == false then
		Cmd_AttackMoveMarker("sg_ork_second_location_attack", "mkr_eldarbasejump2")
	elseif g_eldar_base_at_final_jump_location == true then
		Cmd_AttackMoveMarker("sg_ork_second_location_attack", "mkr_ork_destination")
	end
	
	Rule_Remove(Rule_Ork_Attack_On_Eldar_Second_Location_Infantry_Wave4)
	
end

g_Ork_Second_Location_Infantry_Army_iter = g_Ork_Second_Location_Infantry_Army_iter+1

end

function Rule_Ork_Attack_On_Eldar_Second_Location_Infantry_Wave5()

local i = g_Ork_Second_Location_Infantry_Army_iter 

t_Ork_Second_Location_Infantry_Army = {
	
	sgroup_name = {"sg_ork_second_location_attack_type1", "sg_ork_second_location_attack_type2"},  
	blueprint = {"ork_squad_shoota_boy", "ork_squad_shoota_boy"},
	marker_spawn = {"mkr_ork_second_location_start1", "mkr_ork_second_location_start2"}, 
	stance = {STANCE_Attack, STANCE_Attack},
	melee_stance = {MSTANCE_Ranged, MSTANCE_Ranged},
	squad_num = {1, 1}, 
	squad_size = {15, 15}, 
}
--[[
local random_type = World_GetRand(1, 2)
local random_spawn = World_GetRand(1, 2)
local random_squad_number = World_GetRand(1, 2)
local random_squad_size = World_GetRand(4, 8)]]

if g_Ork_Second_Location_Infantry_Army_iter <= table.getn(t_Ork_Second_Location_Infantry_Army.sgroup_name) and (SGroup_Exists(t_Ork_Second_Location_Infantry_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Ork_Second_Location_Infantry_Army.sgroup_name[i])) then
	
	local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player3, t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.blueprint[i], t_Ork_Second_Location_Infantry_Army.marker_spawn[i], t_Ork_Second_Location_Infantry_Army.squad_num[i], t_Ork_Second_Location_Infantry_Army.squad_size[i]) -- t_Ork_Second_Location_Infantry_Army.squad_size[World_GetRand(4, 10)]
	
	Cmd_SetStance(t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.stance[i])
	Cmd_SetMeleeStance(t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.melee_stance[i])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ork_second_location_attack"), SGroup_FromName(t_Ork_Second_Location_Infantry_Army.sgroup_name[i]))
	
	local l_eldar_count = Player_GetAllSquadsNearMarker(g_Player1, "sg_eldar_count", "mkr_allowed_radius_around_webway_gate2")
	
	if SGroup_Count(SGroup_FromName("sg_eldar_count")) >= 2 then 
		
		Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_supplement"..i, t_Ork_Second_Location_Infantry_Army.blueprint[i], t_Ork_Second_Location_Infantry_Army.marker_spawn[i], t_Ork_Second_Location_Infantry_Army.squad_num[i], t_Ork_Second_Location_Infantry_Army.squad_size[i]) -- t_Ork_Second_Location_Infantry_Army.squad_size[World_GetRand(4, 10)]
		Cmd_SetStance("sg_ork_supplement"..i, t_Ork_Second_Location_Infantry_Army.stance[i])
		Cmd_SetMeleeStance(t_Ork_Second_Location_Infantry_Army.sgroup_name[i], t_Ork_Second_Location_Infantry_Army.melee_stance[i])
		SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ork_second_location_attack"), SGroup_FromName("sg_ork_supplement"..i))
		
	end
	
	
elseif g_Ork_Second_Location_Infantry_Army_iter > table.getn(t_Ork_Second_Location_Infantry_Army.sgroup_name) then
	
	g_Ork_Second_Location_Infantry_Army_iter = 0
	--print("g_wave2 = "..g_wave2)
	
	g_wave2 = g_wave2 + 1
	if g_eldar_base_at_final_jump_location == false then
		Cmd_AttackMoveMarker("sg_ork_second_location_attack", "mkr_eldarbasejump2")
	elseif g_eldar_base_at_final_jump_location == true then
		Cmd_AttackMoveMarker("sg_ork_second_location_attack", "mkr_ork_destination")
	end
	
	Rule_Remove(Rule_Ork_Attack_On_Eldar_Second_Location_Infantry_Wave5)
	
end

g_Ork_Second_Location_Infantry_Army_iter = g_Ork_Second_Location_Infantry_Army_iter+1

end

function Rule_Ork_Attack_On_Eldar_Second_Location_Armor_Wave()

local i = g_Ork_Second_Location_Armor_Army_iter 

t_Ork_Second_Location_Armor_Army = {
	
	sgroup_name = {"sg_ork_second_location_armor_attack_type1", "sg_ork_second_location_armor_attack_type2"},  
	blueprint = {"ork_squad_wartrak", "ork_squad_trukk"},
	marker_spawn = {"mkr_ork_second_location_start1", "mkr_ork_second_location_start2"}, 
	stance = {STANCE_Attack, STANCE_Attack},
	melee_stance = {MSTANCE_Ranged, MSTANCE_Ranged},
	--squad_num = {1, 2, 3}, 
	--squad_size = {8, 8}, 
}

local random_type = World_GetRand(1, 2)
local random_spawn = World_GetRand(1, 2)
local random_squad_number = World_GetRand(1, 2)
--local random_squad_size = World_GetRand(4, 8)

if g_Ork_Second_Location_Armor_Army_iter <= table.getn(t_Ork_Second_Location_Armor_Army.sgroup_name) and (SGroup_Exists(t_Ork_Second_Location_Armor_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_Ork_Second_Location_Armor_Army.sgroup_name[i])) then
	
	local sgroupID = Util_CreateSquadsAtMarker(g_Player3, t_Ork_Second_Location_Armor_Army.sgroup_name[i], t_Ork_Second_Location_Armor_Army.blueprint[random_type], t_Ork_Second_Location_Armor_Army.marker_spawn[random_spawn], random_squad_number) -- t_Ork_Second_Location_Armor_Army.squad_size[World_GetRand(4, 10)]
	Cmd_SetStance(t_Ork_Second_Location_Armor_Army.sgroup_name[i], t_Ork_Second_Location_Armor_Army.stance[i])
	Cmd_SetMeleeStance(t_Ork_Second_Location_Armor_Army.sgroup_name[i], t_Ork_Second_Location_Armor_Army.melee_stance[World_GetRand(1, 2)])
	SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ork_second_location_armor_attack"), SGroup_FromName(t_Ork_Second_Location_Armor_Army.sgroup_name[i]))
	
elseif g_Ork_Second_Location_Armor_Army_iter > table.getn(t_Ork_Second_Location_Armor_Army.sgroup_name) then
	
	g_Ork_Second_Location_Armor_Army_iter = 0
		
	--g_wave2 = g_wave2 + 1
	--Cmd_AttackMoveMarker("sg_ork_second_location_armor_attack", "mkr_eldarbasejump2")
	
	--print("g_wave2 = "..g_wave2)
		
		
	if g_eldar_base_at_final_jump_location == false then
		Cmd_AttackMoveMarker("sg_ork_second_location_armor_attack", "mkr_eldarbasejump2")
	elseif g_eldar_base_at_final_jump_location == true then
		Cmd_AttackMoveMarker("sg_ork_second_location_armor_attack", "mkr_ork_destination")
	end
		
	Rule_Remove(Rule_Ork_Attack_On_Eldar_Second_Location_Armor_Wave)
		
end

g_Ork_Second_Location_Armor_Army_iter = g_Ork_Second_Location_Armor_Army_iter+1

end

-- "ork_squad_trukk", "ork_squad_wartrak", "ork_squad_killa_kan" --World_GetRand(1, 2)

function Rule_Second_Location_Attack_Focus() if SGroup_Exists("sg_ork_second_location_attack") and SGroup_IsEmpty("sg_ork_second_location_attack") == false then if SGroup_CheckActiveCommand("sg_ork_second_location_attack", SQUADSTATEID_Idle, true) then Cmd_AttackMoveMarker("sg_ork_second_location_attack", "mkr_eldarbasejump2") end

	if g_eldar_base_at_final_jump_location == true then
		Rule_Remove(Rule_Second_Location_Attack_Focus)
	end
	
end

end

function Rule_Eldar_Base_Second_Location_Jump_Check() if (g_eldar_base_at_second_jump_location == false) and (g_webway_gate_at_second_jump_location == true) then

	if (Prox_AllEntitiesNearMarker("eg_eldarbuildings", "mkr_allowed_radius_around_webway_gate2") == true) then
		g_eldar_base_at_second_jump_location = true
	end
	
elseif (g_eldar_base_at_second_jump_location == true) then 
	--Rule_AddOneShot(Rule_IE_Second_Move_Successful, 0)
	Util_Ping_Stop("ping_jump2ping")
	
	Rule_Remove(Rule_Taldeer_First_Track)
	
	Rule_AddInterval(Rule_Taldeer_Second_Track, 2)
			
	Rule_AddOneShot(Rule_Meeting_With_IG, 10)
	
	Rule_Remove(Rule_Pipe_Attackers_Focus)
	
	Rule_Remove(Rule_Eldar_Base_Second_Location_Jump_Check)
	
end

end

-- ADD EXTRA OBJECTIVE TO GET WEBWAY GATE TO BE BUILT AT IG BASE BEFORE RULE MEETING WITH IG IS CALLED

function Rule_Meeting_With_IG()

Util_StartNIS( EVENTS.NIS_MOMENT)
Rule_AddOneShot(Rule_After_Meeting_With_IG, 2)

end

function Rule_After_Meeting_With_IG() -- created to create a delay between the end of the moment and resumption of gameplay, to allow the objectives to appear

Rule_AddInterval(Rule__Objective_Alliance_of_Convenience, 1)

W40k_SwitchToPlayer( g_Player4, false ) -- switches to IG, will be done in NIS when that is implemented.  Make sure the bonesinger can't build
	
FOW_Reset()

Player_SetResource(g_Player4, RT_Requisition, 2000)
Player_SetResource(g_Player4, RT_Power, 1000)

--Rule_AddOneShot(Rule_Farseer_Builder_Move_Orders, 5) -- moved to NIS

if SGroup_Exists("sg_ork_revenge_start") then
	SGroup_DeSpawn("sg_ork_revenge_start")
end

if SGroup_Exists("sg_pipe_attackers") then
	SGroup_DeSpawn("sg_pipe_attackers")
end

if SGroup_Exists("sg_ork_base_defense") then
	SGroup_DeSpawn("sg_ork_base_defense")
end

--Rule_AddInterval(Rule_Taldeer_And_Builder_Control, 1) -- moved to NIS

Rule_AddInterval(Rule_Second_Pipegate_Attackers_Control, 10)

end

function Rule_Farseer_Builder_Move_Orders() --[[ if SGroup_Exists("sg_taldeer") and SGroup_IsEmpty("sg_taldeer") == false then if SGroup_CheckActiveCommand("sg_taldeer", SQUADSTATEID_Idle, true) then print("moving") Cmd_MoveToMarker("sg_taldeer", "mkr_eldar_base_final_position") end end]]

if SGroup_Exists("sg_gateway_bonesinger") and SGroup_IsEmpty("sg_gateway_bonesinger") == false then
	
	if SGroup_CheckActiveCommand("sg_gateway_bonesinger", SQUADSTATEID_Idle, true) then
		
		Cmd_AttackMoveMarker("sg_gateway_bonesinger", "mkr_eldar_base_final_position")
	end
	
end

end

function Rule_Taldeer_And_Builder_Control() --[[ if SGroup_IsUnderAttack("sg_taldeer", false) == false then Cmd_AttackMoveMarker("sg_taldeer", "mkr_eldar_base_final_position") end]]

if SGroup_Exists("sg_gateway_bonesinger") and SGroup_IsEmpty("sg_gateway_bonesinger") == false then
	
	if Prox_AnySquadNearMarker("sg_gateway_bonesinger", "mkr_eldar_base_final_position") then
		Rule_Remove(Rule_Farseer_Builder_Move_Orders)
		Rule_Check_AddInterval(Rule_BuildingManager, 2) -- governs the building of the webway gate at the final position
	end	
	--[[
	EGroup_ReSpawn("eg_eldar_webway")
	
	Rule_Remove(Rule_Taldeer_And_Builder_Control)
	Rule_Remove(Rule_Taldeer_Second_Track)
	Rule_AddInterval(Rule_Taldeer_Final_Track, 2)
	Rule_AddInterval(Rule_Eldar_Relocate_To_IG_Base_Control, 1)]]
end

end

function Rule_Eldar_Relocate_To_IG_Base_Control()

if Event_IsAnyRunning() == false then 
	UI_ShowCountdown(820302, 300) -- 270
	--show counter instead of how many Eldar buildings have jumped across?
	Rule_AddOneShot(Rule_Eldar_Relocation_Check_Kickoff, 300)  
	Rule_AddOneShot(Rule_Eldar_Jump_Control, 270)
	Rule_AddOneShot(Rule_IE_Hold_The_Line, 0)
	Sound_PlayStinger("stinger_ms03_theimperialguardhold")
	Rule_Remove(Rule_Eldar_Relocate_To_IG_Base_Control)
	
end		

end

function Rule_Add_Eldar_Buildings()

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

Player_GetAllEntitiesNearPos(g_Player1, "eg_add_eldarbuildings", pos, 40)

local buildingcount = EGroup_Count(EGroup_FromName("eg_add_eldarbuildings"))	

for i = 1, buildingcount do
	
	local Indexed = EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_add_eldarbuildings"), i)
	
	if Entity_IsBuilding(EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_add_eldarbuildings"), i))	then
		if (Entity_GetBlueprintName(Indexed) == "eldar_soul_shrine") or (Entity_GetBlueprintName(Indexed) == "eldar_aspect_portal") then
			EGroup_Add(EGroup_CreateIfNotFound("eg_eldarbuildings"), Indexed)
		end
	end
	
end	

EGroup_Clear(EGroup_FromName("eg_add_eldarbuildings"))

end

function Rule_Eldar_Jump_Control() -- jumps the Eldar buildings (now NOT under player control) at once

Cmd_EGroupRelocateMarker("eg_eldar_hq", "mkr_eldar_base_final_position_radius", 30 ) -- jumps the HQ a split second first

Cmd_EGroupRelocateMarker("eg_eldarbuildings", "mkr_eldar_base_final_position_radius", 30 )

Player_GetAllSquadsNearMarker(g_Player1, "sg_eldar_survivors", "mkr_eldar_survivor_radius")

if SGroup_Exists("sg_eldar_survivors") and SGroup_IsEmpty("sg_eldar_survivors") == false then
	Cmd_AttackMoveMarker("sg_eldar_survivors", "mkr_eldar_base_final_position_radius")
end

end

function Rule_Eldar_Relocation_Check_Kickoff() Rule_Check_AddInterval(Rule_Eldar_Relocation_Check, 1) end

function Rule_Eldar_Relocation_Check() --checks for HQ at final position, makes this independent of how many buildings the player builds in case the player builds so much that not all the buildings have enough room to fit by the webway gate

if EGroup_Exists("eg_eldar_hq") and EGroup_IsEmpty("eg_eldar_hq") == false then
	
	if Prox_AllEntitiesNearMarker("eg_eldar_hq", "mkr_eldar_base_final_position_radius") == true then
		
		g_eldar_base_at_final_jump_location = true
		
		Rule_AddInterval(Rule__Objective_Defend_IG_Base, 1)
		
		Rule_Remove(Rule_Taldeer_Second_Track)
		
		Rule_Check_AddInterval(Rule_Taldeer_Final_Track, 2)
		
		Rule_AddIntervalDelay(Rule_Ork_Final_Assault, 90, 0)
		
		Playlist_Manager(PC_Music, {"music_msd2"}, true, true, {1, 2}) 	
		
		Rule_AddIntervalDelay(Rule_Raid_Focus, 3, 15)
		
		Rule_Remove(Rule_Ork_Tank_Track)
		
		Rule_AddOneShot(Rule_IE_Hold_The_Line_2, 0)
		
		Rule_AddInterval(Rule_IG_Countdown_Control, 1)
		
		Rule_Remove(Rule_Eldar_Relocation_Check)
	end
	
end

end

function Rule_Initiate_Second_Pipe_Break_Moment()

Anim_PlayEGroupAnim(EGroup_FromName("eg_pipegate2"), "die")
EGroup_DeSpawn("eg_pipegate2_side")	
EGroup_ReSpawn("eg_pipegate2_side_destroyed")
Rule_AddOneShot(Rule_Pipegate2_Despawn, 3) 
Rule_Remove(Rule_Second_Pipegate_Attackers_Control)

end

function Rule_Pipegate2_Despawn()

EGroup_DeSpawn("eg_pipegate2")

end

function Rule_Second_Pipegate_Attackers_Control()

if SGroup_Exists("sg_second_pipe_attackers1") and SGroup_IsEmpty("sg_second_pipe_attackers1") == true then
	Util_CreateSquadsAtMarkerEx(g_Player3, "sg_second_pipe_attackers1", "ork_squad_slugga", "mkr_ork_second_pipe_attackers1", 2, 8)
	Cmd_SetStance("sg_second_pipe_attackers1", STANCE_Burn)
	if EGroup_Exists("eg_pipegate2") and EGroup_IsEmpty("eg_pipegate2") == false then
		Cmd_AttackEGroup("sg_second_pipe_attackers1", "eg_pipegate2")
	end
end

if SGroup_Exists("sg_second_pipe_attackers2") and SGroup_IsEmpty("sg_second_pipe_attackers2") == true then
	Util_CreateSquadsAtMarkerEx(g_Player3, "sg_second_pipe_attackers2", "ork_squad_shoota_boy", "mkr_ork_second_pipe_attackers2", 2, 8)
	Cmd_SetMeleeStance("sg_second_pipe_attackers2", MSTANCE_Ranged)
	Cmd_SetStance("sg_second_pipe_attackers2", STANCE_StandGround)
	if EGroup_Exists("eg_pipegate2") and EGroup_IsEmpty("eg_pipegate2") == false then
		Cmd_AttackEGroup("sg_second_pipe_attackers1", "eg_pipegate2")
	end
end

end

function Rule_IG_Countdown_Control()

if Event_IsAnyRunning() == false then 
	UI_ShowCountdown(820304, 600)
	
	Rule_AddOneShot(Rule_IG_Reinforcement_Countdown_Timer, 600)
	Rule_AddOneShot(Rule_Ork_Survivor_Attack, 10)
	Rule_AddOneShot(Rule_Ork_Squiggoth_Flag, 540) -- forces Squiggoth to appear at 1 min left until reinforcements arrive
	Rule_Remove(Rule_IG_Countdown_Control)
end		

end

function Rule_Ork_Survivor_Attack()

if SGroup_Exists("sg_ork_raiders2") and SGroup_IsEmpty("sg_ork_raiders2") == false then
	Cmd_AttackMoveMarker("sg_ork_raiders2", "mkr_eldarbasejump2")
end

if SGroup_Exists("sg_ork_revenge") and SGroup_IsEmpty("sg_ork_revenge") == false then
	Cmd_AttackMoveMarker("sg_ork_revenge", "mkr_eldarbasejump2")
end

if SGroup_Exists("sg_pipe_attackers") and SGroup_IsEmpty("sg_pipe_attackers") == false then
	Cmd_AttackMoveMarker("sg_pipe_attackers", "mkr_eldarbasejump2")
end

if SGroup_Exists("sg_second_pipe_attackers1") and SGroup_IsEmpty("sg_second_pipe_attackers1") == false then
	Cmd_AttackMoveMarker("sg_second_pipe_attackers1", "mkr_eldarbasejump2")
end

if SGroup_Exists("sg_second_pipe_attackers2") and SGroup_IsEmpty("sg_second_pipe_attackers2") == false then
	Cmd_AttackMoveMarker("sg_second_pipe_attackers2", "mkr_eldarbasejump2")
end

end

function Rule_IG_Reinforcement_Countdown_Timer()

Rule_AddOneShot(Rule_IG_Reinforcements_Arrive, 1)

end

function Rule_Ork_Squiggoth_Flag()

g_squiggoth_enabled = true -- independent squiggoth appearing flag
-- Originally at wave 3.  Squiggoth now appears a set time into the mission.  Also had originally planned it so that the squiggoth appears during the 7th wave's destruction or 1:30 until the end of the mission (which ever came first)
-- However, I decided that it would be better if we just made it appear at 1:30 left in the mission instead.  The checking flags are still there in case we want to switch it back to what it was before.

if (g_squiggoth_deployed == false) and (g_squiggoth_enabled == true) then 
	
	sgroupreinforcements2 = Util_CreateSquadsAtMarker(g_Player3, "sg_ork_squiggoth", "ork_squad_squiggoth", "mkr_squiggoth_spawn", 1)
	--SGroup_AddGroup(sgrouporkfinalgroup, sgroupreinforcements2)
	Cmd_AttackMoveMarker("sg_ork_squiggoth", "mkr_ork_destination")
	
	Rule_Check_AddInterval(Rule_Ork_Squiggoth_Track, 2)
	
	g_squiggoth_deployed = true
	
end

end

function Rule_Ork_Squiggoth_Track()

if SGroup_Exists("sg_ork_squiggoth") and SGroup_IsEmpty("sg_ork_squiggoth") == true then
	g_squiggoth_dead = true
	Rule_Check_AddOneShot(Rule_Ork_Last_Group_Standing_Control, 1) -- death of squiggoth triggers the function that grabs the last orks the player has to kill to pass the level
	Rule_Remove(Rule_Ork_Squiggoth_Track)
end

end

function Rule_Ork_Final_Assault()

--if g_ork_assault_started == false then	
	
	sgrouporkfinalgroup = SGroup_CreateIfNotFound("sg_ork_assault_force")
	
	for i = 1,2 do 
		t_sgrouporkfinalassault[i] = Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_assault"..i, "ork_squad_slugga", "mkr_ork_finalpush"..i, 3, 10) -- 3, 12
		SGroup_AddGroup(sgrouporkfinalgroup, t_sgrouporkfinalassault[i])
		Cmd_AttackMoveMarker("sg_ork_assault"..i, "mkr_ork_charge_"..i) --CALL ORK ASSAULT HERE
		if EGroup_Exists("eg_ig_base_front") and EGroup_IsEmpty("eg_ig_base_front") then
			Cmd_AttackMoveMarker("sg_ork_assault"..i, "mkr_ork_destination")
		end
	end
	g_ork_wave_counter = g_ork_wave_counter + 1
	--print("Ork Attack Wave: "..g_ork_wave_counter)
	
	
	if (g_ork_wave_counter == 2) then
		
		sgroupreinforcements1 = Util_CreateSquadsAtMarker(g_Player3, "sg_ork_final_stormboyz", "ork_squad_stormboy", "mkr_stormboy_spawn", 10) -- 12
		--SGroup_AddGroup(sgrouporkfinalgroup, sgroupreinforcements1)
		Cmd_MoveToMarker("sg_ork_final_stormboyz", "mkr_stormboyz_jumpoff")
		
		if SGroup_Exists("sg_ork_tank1") and SGroup_IsEmpty("sg_ork_tank1") == false then
			Cmd_AttackMoveMarker("sg_ork_tank1", "mkr_ork_destination")
		end
		
		Rule_AddInterval(Rule_Ork_Stormboyz_Assault_Control, 5)
		
	end
	
	if (g_ork_wave_counter == 4) then
		
		if SGroup_Exists("sg_ork_tank2") and SGroup_IsEmpty("sg_ork_tank2") == false then
			Cmd_AttackMoveMarker("sg_ork_tank2", "mkr_ork_destination")
		end
		
	end
	
	
	if (g_ork_wave_counter == 5) then -- originally at wave 3
	
		if (SGroup_Exists("sg_ork_raiding_party") == true) and (SGroup_IsEmpty("sg_ork_raiding_party") == false) then 
			Cmd_AttackMoveMarker("sg_ork_raiding_party", "mkr_ork_destination")
		end
		if (SGroup_Exists("sg_ork_revenge") == true) and (SGroup_IsEmpty("sg_ork_revenge") == false) then 
			Cmd_AttackMoveMarker("sg_ork_revenge", "mkr_ork_destination")
		end
		
	end
	
	if (g_ork_wave_counter == 6) then
		
		if SGroup_Exists("sg_ork_tank3") and SGroup_IsEmpty("sg_ork_tank3") == false then
			Cmd_AttackMoveMarker("sg_ork_tank3", "mkr_ork_destination")
		end
		if SGroup_Exists("sg_ork_tank4") and SGroup_IsEmpty("sg_ork_tank4") == false then
			Cmd_AttackMoveMarker("sg_ork_tank4", "mkr_ork_destination")
		end
		
	end
	
	if (g_ork_wave_counter == 8) then
		
		if SGroup_Exists("sg_ork_tank5") and SGroup_IsEmpty("sg_ork_tank5") == false then
			Cmd_AttackMoveMarker("sg_ork_tank5", "mkr_ork_destination")
		end
		if SGroup_Exists("sg_ork_tank6") and SGroup_IsEmpty("sg_ork_tank6") == false then
			Cmd_AttackMoveMarker("sg_ork_tank6", "mkr_ork_destination")
		end
		
	end
	
	if (g_ork_wave_counter >= 9) then
		
		for i = 1, 4 do
			if SGroup_Exists("sg_ork_raiders"..i) and SGroup_IsEmpty("sg_ork_raiders"..i) == false then
				Cmd_AttackMoveMarker("sg_ork_raiders"..i, "mkr_ork_destination")
			end
		end
		
	end
	
	g_ork_assault_started = true
	
--end
--[[
if SGroup_Exists("sg_ork_assault_force") and SGroup_IsEmpty("sg_ork_assault_force") then
	g_ork_assault_started = false
end]]

end

function Rule_Raid_Focus() -- prevents the ork assault units from going idle

for i = 1,2 do 
	
	if SGroup_Exists("sg_ork_assault"..i) and SGroup_IsEmpty("sg_ork_assault"..i) == false then
		if SGroup_CheckActiveCommand("sg_ork_assault"..i, SQUADSTATEID_Idle, true) then
			Cmd_AttackMoveMarker("sg_ork_assault"..i, "mkr_ork_destination")
		end
	end

	if SGroup_Exists("sg_ork_second_location_attack_type"..i) and SGroup_IsEmpty("sg_ork_second_location_attack_type"..i) == false then
		if SGroup_CheckActiveCommand("sg_ork_second_location_attack_type"..i, SQUADSTATEID_Idle, true) then
			Cmd_AttackMoveMarker("sg_ork_second_location_attack_type"..i, "mkr_ork_destination")
		end
	end
	
	if SGroup_Exists("sg_ork_second_location_armor_attack_type"..i) and SGroup_IsEmpty("sg_ork_second_location_armor_attack_type"..i) == false then
		if SGroup_CheckActiveCommand("sg_ork_second_location_armor_attack_type"..i, SQUADSTATEID_Idle, true) then
			Cmd_AttackMoveMarker("sg_ork_second_location_armor_attack_type"..i, "mkr_ork_destination")
		end
	end

	if SGroup_Exists("sg_second_pipe_attackers"..i) and SGroup_IsEmpty("sg_second_pipe_attackers"..i) == false then
		if SGroup_CheckActiveCommand("sg_second_pipe_attackers"..i, SQUADSTATEID_Idle, true) then
			Cmd_AttackMoveMarker("sg_second_pipe_attackers"..i, "mkr_ork_destination")
		end
	end

	if SGroup_Exists("sg_ork_supplement"..i) and SGroup_IsEmpty("sg_ork_supplement"..i) == false then
		if SGroup_CheckActiveCommand("sg_ork_supplement"..i, SQUADSTATEID_Idle, true) then
			Cmd_AttackMoveMarker("sg_ork_supplement"..i, "mkr_ork_destination")
		end
	end

end

--makes sure squiggoth is on track!
if SGroup_Exists("sg_ork_squiggoth") and SGroup_IsEmpty("sg_ork_squiggoth") == false then
	if SGroup_CheckActiveCommand("sg_ork_squiggoth", SQUADSTATEID_Idle, true) then
		Cmd_AttackMoveMarker("sg_ork_squiggoth", "mkr_ork_destination")
	end
end
	

end

function Rule_Ork_Last_Group_Standing_Control()

Player_GetAllSquadsNearMarker(g_Player3, "sg_ork_last_sgroup_standing", "mkr_last_ork_sgroup_area")
--[[
if SGroup_Exists("sg_ork_last_sgroup_standing") and SGroup_IsEmpty("sg_ork_last_sgroup_standing") then
	print("empty! win game")
	--g_no_orks_in_area = true
elseif SGroup_Exists("sg_ork_last_sgroup_standing") and SGroup_IsEmpty("sg_ork_last_sgroup_standing") == false then
	print("units exist!")
end]]

end

function Rule_Ork_Stormboyz_Assault_Control()

if SGroup_Exists("sg_ork_final_stormboyz") and SGroup_IsEmpty("sg_ork_final_stormboyz") == false and g_ork_stormboyz_final_attack == false then
	Cmd_JumpToMarker("sg_ork_final_stormboyz", "mkr_stormboyz_jump1")
	g_ork_stormboyz_final_attack = true
end

end

function Rule_IG_Reinforcements_Arrive() Rule_AddOneShot(Rule_IE_IG_Reinforcements_Arrived, 0)

Util_CreateSquadsAtMarkerEx(g_Player4, "sg_ig_reinforce", "guard_squad_guardsmen", "mkr_ig_reinforcements2", 3, 12)

Util_CreateSquadsAtMarker(g_Player4, "sg_ig_tank_reinforce", "guard_squad_baneblade", "mkr_ig_reinforcements1", 1)

local mod_banebladearmourincrease = Modifier_Create(MAT_EntityType, "armour_modifier", MUT_Multiplication, false, 3, "guard_vehicles_baneblade") --4.5
g_mod_banebladearmourincrease = Modifier_ApplyToPlayer( mod_banebladearmourincrease, g_Player4)
local mod_banebladehealthincrease = Modifier_Create(MAT_EntityType, "health_maximum_modifier", MUT_Multiplication, false, 2, "guard_vehicles_baneblade") --4
g_mod_banebladehealthincrease = Modifier_ApplyToPlayer( mod_banebladehealthincrease, g_Player4)	

Sound_PlayStinger("stinger_ms03_arrivalofimperialnavy")
Rule_Remove(Rule_Ork_Tank_Track)

Rule_AddOneShot(Rule_Time_Is_Up_Delay, 10)

Rule_Remove(Rule_Ork_Stormboyz_Assault_Control)

end

function Rule_Time_Is_Up_Delay() -- needed to add delay so that the IE plays and then the objective complete cues and ending NIS play afterwards, in case Ork forces destroyed first

g_time_is_up = true

end

function Rule_Reload_Reset()

FOW_Reset()

end

--[[ function Rule_Moment_Shortcut() --Util_CreateSquadsAtMarker(g_Player1, "sg_eldar_wraithlords1", "eldar_squad_wraithlord", "mkr_eldarbasejump1", 2) Util_CreateSquadsAtMarkerEx(g_Player3, "sg_ork_raiders2", "ork_squad_slugga", "mkr_ork_pipe_action_reveal", 2, 15) Util_StartNIS( EVENTS.NIS_MOMENT) end]]

--[[ function Rule_End_Shortcut() --Util_CreateSquadsAtMarker(g_Player1, "sg_eldar_wraithlords1", "eldar_squad_wraithlord", "mkr_eldarbasejump1", 2) Util_StartNIS( EVENTS.NIS_CLOSING) end]]


--Manages the "building" of the webway gate by the computer

function Rule_BuildingManager()

if EGroup_Exists("eg_eldar_webway_build_location") == false or EGroup_IsEmpty("eg_eldar_webway_build_location") then
	
	Rule_Check_AddInterval(Rule_Building_CreateBuilding, 3)
	Rule_Check_AddInterval(Rule_Building_CreateBuilder, 5)
	
	Rule_Remove(Rule_BuildingManager)
end

end

function Rule_Building_CreateBuilding()

--[[ check to see if the building exists ]]
if EGroup_Exists("eg_eldar_webway_build_location") == false or EGroup_IsEmpty("eg_eldar_webway_build_location") then
	
	--[[ if it doesn't, move everybody out of the way and call the building to be made ]]
	World_ScatterSquadsMarker( "mkr_cpu_build_webway_here" )
	
	--[[ you can use the following to get either variance or allow for buildings possibly being put in the way ]]
	local randx = World_GetRand(-5, 5)
	local randz = World_GetRand(-5, 5)
	local pos = Marker_GetPosition(Marker_FromName("mkr_cpu_build_webway_here", "basic_marker"))
	pos.x = pos.x+randx
	pos.z = pos.z+randz
	
	--[[ create the building ]]
	Entity_CreateBuildingPosition(g_Player1, "eg_eldar_webway_build_location", "eldar_webway_gate", pos, 0.01)
	
elseif EGroup_Exists("eg_eldar_webway_build_location") and EGroup_IsEmpty("eg_eldar_webway_build_location") == false then
	
	--[[ if the building exists, get the build progress ]]
	local entityID = EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_eldar_webway_build_location"), 1)
	
	if Entity_GetBuildingProgress(entityID) == 1 then
		
		--[[ trigger anything you want to happen when the building is done... ie kill the builder? ]]
		
		Rule_AddInterval(Rule_Eldar_Relocate_To_IG_Base_Control, 1) -- starts countdown for eldar relocation
		
		
		--[[ remove the rule ]]
		Rule_Remove(Rule_Building_CreateBuilding)
		--[[ add the manager back in ]]
		Rule_Check_AddInterval(Rule_BuildingManager, 1)
	end
	
end

end

function Rule_Building_CreateBuilder()

--[[ check the builder ]]
if SGroup_Exists("sg_gateway_bonesinger") == false or SGroup_IsEmpty("sg_gateway_bonesinger") then
	
	local taldeerposition = SGroup_GetPosition(SGroup_FromName("sg_taldeer"))
			
	--[[ if he's dead make another ]]
	--Util_CreateSquadsAtMarker(playerID, "sg_gateway_bonesinger", "eldar_webway_gate", "mkr_cpu_build_webway_here", 1)
	
	--Fix the egroup in the next line
	Entity_CreateBuildingPosition(g_Player1, "sg_gateway_bonesinger", "eldar_webway_gate", taldeerposition, 1)
	
elseif SGroup_IsEmpty("sg_gateway_bonesinger") == false then
	
	--[[ if he's not, check the target building ]]
	if EGroup_Exists("eg_eldar_webway_build_location") and EGroup_IsEmpty("eg_eldar_webway_build_location") == false then
		
		--[[ if the building exists, get the build progress ]]
		local entityID = EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_eldar_webway_build_location"), 1)
		if Entity_GetBuildingProgress(entityID) < 1 then
			
			--[[ if the build progress is less than 100% (or 1.0) tell the builder to build it ]]
			Command_SquadEntity( g_Player1, SGroup_FromName("sg_gateway_bonesinger"), SCMD_BuildStructure, EGroup_FromName("eg_eldar_webway_build_location") )
			
		elseif Entity_GetBuildingProgress(entityID) == 1 then
			
			--[[ trigger anything you want to happen when the building is done... ie kill the builder? ]]
			
			--[[ remove the rule ]]
			Rule_Remove(Rule_Building_CreateBuilder)
			--[[ add the manager back in ]]
			Rule_Check_AddInterval(Rule_BuildingManager, 1)
		end
	end
	
end

end

function Rule_Builder_Deploy()

Util_CreateSquadsAtMarker(g_Player1, "sg_gateway_bonesinger", "eldar_squad_bonesinger", "mkr_bonesinger_builder_spawn", 1)
Cmd_SetStance("sg_gateway_bonesinger", STANCE_CeaseFire)
Cmd_MoveToMarker("sg_gateway_bonesinger", "mkr_eldar_base_final_position")

end



--[[ GAME OVER - Player Wins ]]

function Rule_EndGameWin()

if (Objective_Exists(Objective_Alliance_of_Convenience.title_id) and Objective_GetState(Objective_Alliance_of_Convenience.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 = 
{

}

g_unit_exceptions = 
{
	"eldar_squad_farseer",
	"guard_squad_command_squad"
}

if EGroup_Exists("eg_eldar_hq") and EGroup_IsEmpty("eg_eldar_hq") == true then
	Rule_RemoveAll()
	Fade_Start(4, false)
	World_SetTeamWin( g_Player3, "" )
	Rule_AddIntervalEx( Rule_GameOver,5,1 )
	Rule_Remove( Rule_EndGameLose )
end

if EGroup_Exists("eg_guard_hq") and EGroup_IsEmpty("eg_guard_hq") == true then
	Rule_RemoveAll()
	Fade_Start(4, false)
	World_SetTeamWin( g_Player3, "" )
	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


--[[ OBJECTIVES ]]

function Rule__Objective_Forward_Progress()

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Forward_Progress.title_id) == false then
	
	Util_WXP_ObjectiveCreate(Objective_Forward_Progress, true, g_Player1)
	
	Rule_AddInterval(Rule__Objective_Kill_Ork_Leader, 1)
	
	
elseif Event_IsAnyRunning() == false and g_objectives_completed == 5 then
	
	Util_ObjectiveComplete(Objective_Forward_Progress.title_id)
	
	Rule_Remove(Rule__Objective_Forward_Progress)
end

end

function Rule__Objective_Kill_Ork_Leader()

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Kill_Ork_Leader.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate(Objective_Kill_Ork_Leader, 821054)
	
elseif Event_IsAnyRunning() == false and SGroup_IsEmpty("sg_baseleader") then
	
	Util_ObjectiveComplete(Objective_Kill_Ork_Leader.title_id)
	
	g_objectives_completed = g_objectives_completed + 1
	
	Rule_AddOneShot(Rule_Revenge_Control, 0)
	
	UI_HideCountdown() -- to make it so that the Ork Discovery countdown is hidden
	
	Rule_Remove(Rule__Objective_Kill_Ork_Leader)
end

end

function Rule__Objective_First_WebwayBuilt()

if Event_IsAnyRunning() == false and Objective_Exists(Objective_First_WebwayBuilt.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate(Objective_First_WebwayBuilt, 821054)
	
	Util_Ping_LoopingMkr("ping_jump1ping", "mkr_eldarbasejump1") -- for next objective
	
	W40k_NoBuildZoneRemove(nobuildzoneID16)
	
	g_web1_ping = Objective_PingMarker(Objective_First_WebwayBuilt.title_id, "mkr_eldarbasejump1", true, "default")
	
	
elseif Event_IsAnyRunning() == false and (g_webway_gate_at_first_jump_location == true) then
	
	Util_ObjectiveComplete(Objective_First_WebwayBuilt.title_id)
		
	Objective_PingRemove(Objective_First_WebwayBuilt.title_id, g_web1_ping)	
		
	g_objectives_completed = g_objectives_completed + 1
	
	Rule_Remove(Rule__Objective_First_WebwayBuilt)
	
end

end

function Rule__Objective_First_EldarBaseJump()

if Event_IsAnyRunning() == false and Objective_Exists(Objective_First_EldarBaseJump.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate(Objective_First_EldarBaseJump, 821054)
	
	W40k_NoBuildZoneRemove(nobuildzoneID16)
	W40k_NoBuildZoneRemove(nobuildzoneID17)
	W40k_NoBuildZoneRemove(nobuildzoneID18)
	W40k_NoBuildZoneRemove(nobuildzoneID19)
	W40k_NoBuildZoneRemove(nobuildzoneID20)
	W40k_NoBuildZoneRemove(nobuildzoneID21)
	
	g_jump1_ping = Objective_PingMarker(Objective_First_EldarBaseJump.title_id, "mkr_eldarbasejump1", true, "default")
	
elseif Event_IsAnyRunning() == false and (g_eldar_base_at_first_jump_location == true)  then
	
	Util_ObjectiveComplete(Objective_First_EldarBaseJump.title_id)
	
	Objective_PingRemove(Objective_First_EldarBaseJump.title_id, g_jump1_ping)	
	
	g_objectives_completed = g_objectives_completed + 1
	
	Rule_Remove(Rule__Objective_First_EldarBaseJump)
	
	Rule_Add(Rule_Autosave_First_Jump_Successful)
	
end

end

function Rule__Objective_Second_WebwayBuilt()

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Second_WebwayBuilt.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate(Objective_Second_WebwayBuilt, 821054)
	
	W40k_NoBuildZoneRemove(nobuildzoneID23)
	
	g_web2_ping = Objective_PingMarker(Objective_Second_WebwayBuilt.title_id, "mkr_eldarbasejump2", true, "default")
	
elseif Event_IsAnyRunning() == false and (g_webway_gate_at_second_jump_location == true) then
	
	Util_ObjectiveComplete(Objective_Second_WebwayBuilt.title_id)
	
	Objective_PingRemove(Objective_Second_WebwayBuilt.title_id, g_web2_ping)	
	
	g_objectives_completed = g_objectives_completed + 1
	
	Rule_Remove(Rule__Objective_Second_WebwayBuilt)
	
end

end

function Rule__Objective_Second_EldarBaseJump()

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Second_EldarBaseJump.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate(Objective_Second_EldarBaseJump, 821054)
	
	--W40k_NoBuildZoneRemove(nobuildzoneID24)
	W40k_NoBuildZoneRemove(nobuildzoneID25)
	W40k_NoBuildZoneRemove(nobuildzoneID26)
	W40k_NoBuildZoneRemove(nobuildzoneID27)
	W40k_NoBuildZoneRemove(nobuildzoneID28)
	
	g_jump2_ping = Objective_PingMarker(Objective_Second_EldarBaseJump.title_id, "mkr_eldarbasejump2", true, "default")
	
elseif Event_IsAnyRunning() == false and (g_eldar_base_at_second_jump_location == true)  then
	
	Util_ObjectiveComplete(Objective_Second_EldarBaseJump.title_id)
	
	Objective_PingRemove(Objective_Second_EldarBaseJump.title_id, g_jump2_ping)	
	
	g_objectives_completed = g_objectives_completed + 1
	
	Rule_Remove(Rule__Objective_Second_EldarBaseJump)
	
end

end

function Rule__Objective_Alliance_of_Convenience()

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Alliance_of_Convenience.title_id) == false then
	
	Util_WXP_ObjectiveCreate(Objective_Alliance_of_Convenience, true, g_Player4)
	
	Rule_AddInterval(Rule__Objective_Defend_Eldar_Relocating_To_IG_Base, 1)
	
elseif Event_IsAnyRunning() == false and g_second_set_objectives_completed == 2 then
		
	Util_ObjectiveComplete(Objective_Alliance_of_Convenience.title_id)
	
	Rule_Remove(Rule__Objective_Alliance_of_Convenience)
end

end

function Rule__Objective_Defend_Eldar_Relocating_To_IG_Base()

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Defend_Eldar_Relocating_To_IG_Base.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate(Objective_Defend_Eldar_Relocating_To_IG_Base, 821060)
	
	W40k_NoBuildZoneRemove(nobuildzoneID31)
	
	FOW_Reset()
	
	FOW_UnRevealArea(-130, -49, 20)
	
	g_defend_eldar_ping = Objective_PingMarker(Objective_Defend_Eldar_Relocating_To_IG_Base.title_id, "mkr_eldarbasejump2", true, "default")
	
	Rule_AddOneShot(Rule_Eldar_Deploy, 1)
	
	Rule_AddOneShot(Rule_Builder_Deploy, 2)
	
	Util_Ping_LoopingMkr("ping_objective3ping", "mkr_eldarbasejump2")
	
	Rule_AddIntervalDelay(Rule_Autosave_Defending_the_Eldar, 1, 5)
	
elseif Event_IsAnyRunning() == false and (g_eldar_base_at_final_jump_location == true)  then
	
	Rule_AddOneShot(Rule_Initiate_Second_Pipe_Break_Moment, 0)
	
	Util_ObjectiveComplete(Objective_Defend_Eldar_Relocating_To_IG_Base.title_id)
	
	Objective_PingRemove(Objective_Defend_Eldar_Relocating_To_IG_Base.title_id, g_defend_eldar_ping)	
	
	g_second_set_objectives_completed = g_second_set_objectives_completed + 1
	
	Util_Ping_Stop("ping_objective3ping")
	
	Rule_Remove(Rule__Objective_Defend_Eldar_Relocating_To_IG_Base)
	
elseif Event_IsAnyRunning() == false and EGroup_IsEmpty("eg_eldar_hq") then
	
	Util_ObjectiveFail(Objective_Defend_Eldar_Relocating_To_IG_Base.title_id)
	
	Rule_Remove(Rule__Objective_Defend_Eldar_Relocating_To_IG_Base)		
	
end

end

function Rule__Objective_Defend_IG_Base()

if Event_IsAnyRunning() == false and Objective_Exists(Objective_Defend_IG_Base.title_id) == false then
	
	Util_WXP_ObjectiveSubCreate(Objective_Defend_IG_Base,821060)
	
	g_protect_hq = Objective_PingMarker(Objective_Defend_IG_Base.title_id, "mkr_ork_destination", true, "default")
	
	Rule_Add(Rule_Autosave_Waiting_for_Reinforcements)
	
--[[	
elseif Event_IsAnyRunning() == false and (g_time_is_up == true) and (EGroup_IsEmpty("eg_imperial_guard_base") == false) and
(EGroup_IsEmpty("eg_eldar_hq") == false) and (SGroup_Exists("sg_ork_squiggoth") and SGroup_IsEmpty("sg_ork_squiggoth")) and
(SGroup_Exists("sg_ork_last_group_standing") and SGroup_IsEmpty("sg_ork_last_group_standing"))	then -- 	g_ork_wave_counter >= 6 ]]
	
elseif Event_IsAnyRunning() == false and (g_time_is_up == true) and (EGroup_IsEmpty("eg_imperial_guard_base") == false) and
(EGroup_IsEmpty("eg_eldar_hq") == false) and g_squiggoth_dead == true and
(SGroup_Exists("sg_ork_last_sgroup_standing") and SGroup_IsEmpty("sg_ork_last_sgroup_standing"))	then	

	Util_ObjectiveComplete(Objective_Defend_IG_Base.title_id)
	
	Objective_PingRemove(Objective_Defend_IG_Base.title_id, g_protect_hq)	
	
	
	g_second_set_objectives_completed = g_second_set_objectives_completed + 1
	
	Rule_Remove(Rule__Objective_Defend_IG_Base)
	
end

end

function Rule_Eldar_Deploy()

local sgroupID2 = SGroup_CreateIfNotFound("sg_eldar_all")
SGroup_AddGroup(sgroupID2, Player_GetSquads( g_Player1 ))

SGroup_ReSpawnMarker("sg_eldar_all", "mkr_eldarbasejump2")
World_FXEventSquad("data:Art/Events/Unit_Upgrade_Morale_FX/Reinforce_Trooper", sgroupID2)

Player_GetAllEntitiesNearMarker(g_Player1, "eg_webway_catchall", "mkr_eldar_base_start") --mkr_allowed_radius_around_webway_gate2
Cmd_EmptyBuilding("eg_webway_catchall")

g_emptyiter = 0
Rule_AddInterval(Rule_Eldar_Empty, 1)

end

function Rule_Eldar_Empty()

local sgroupID2 = SGroup_CreateIfNotFound("sg_eldar_all")
SGroup_AddGroup(sgroupID2, Player_GetSquads( g_Player1 ))

if g_emptyiter < 20 and SGroup_CountDeSpawned(sgroupID2) > 0 then
	Player_GetAllEntitiesNearMarker(g_Player1, "eg_webway_catchall", "mkr_eldar_base_start")
	Cmd_EmptyBuilding("eg_webway_catchall")
elseif g_emptyiter > 19 or SGroup_CountDeSpawned(sgroupID2) == 0 then
	Rule_Remove(Rule_Eldar_Empty)
end
g_emptyiter = g_emptyiter+1
	

end


--[[ AUTOSAVES ]]

function Rule_Autosave_MissionStart()

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

end

function Rule_Autosave_First_Jump_Successful()

if not Event_IsAnyRunning() then
	Rule_Remove(Rule_Autosave_First_Jump_Successful)
	Util_Autosave( "$820202" )
end

end

function Rule_Autosave_Defending_the_Eldar()

if not Event_IsAnyRunning() then
	Rule_Remove(Rule_Autosave_Defending_the_Eldar)
	Util_Autosave( "$820204" )
end

end

function Rule_Autosave_Waiting_for_Reinforcements()

if not Event_IsAnyRunning() then
	Rule_Remove(Rule_Autosave_Waiting_for_Reinforcements)
	Util_Autosave( "$820206" )
end

end


--[[ INTEL EVENTS ]]

--[[ Intel Event 1 ]]

function Rule_IE_OpeningSpeech()

Util_StartIntel(EVENTS.IE_OpeningSpeech)

end

function Rule_IE_Relocate_At_Once()

Util_StartIntel(EVENTS.IE_Relocate_At_Once)

end

function Rule_IE_First_Move_Successful()

Util_StartIntel(EVENTS.IE_First_Move_Successful)

end

function Rule_IE_Hold_The_Line()

Util_StartIntel(EVENTS.IE_Hold_The_Line)

end

function Rule_IE_Hold_The_Line_2()

Util_StartIntel(EVENTS.IE_Hold_The_Line_2)

end

function Rule_IE_IG_Reinforcements_Arrived()

Util_StartIntel(EVENTS.IE_IG_Reinforcements_Arrived)

end

function Rule_IE_Taldeer_Returns()

Util_StartIntel(EVENTS.IE_Taldeer_Returns)

end

function Rule_IE_Taldeer_Returns2()

Util_StartIntel(EVENTS.IE_Taldeer_Returns2)

end

function Rule_IE_Sturnn_Returns()

Util_StartIntel(EVENTS.IE_Sturnn_Returns)

end

function Rule_IE_Sturnn_Returns2()

Util_StartIntel(EVENTS.IE_Sturnn_Returns2)

end




Game statistieken
Volgers
12
Runs
62
Spelers
7
Recente runs
Niveau: Trophies (Disorder 5 / Orks)
Niveau: Blood for the Blood God! (Disorder 3)
Niveau: Titan of the Emperor (Order 5 / Imperial guard)
Moderators