Mission 7 Event File
Guider
/
Mission 7 Event File
Uppdaterad 3 years ago av Merric

-- RESEARCH FUNCS

-- Disables, enables, and grants research items

function SetResearchLevel() -- restrict -- buildings Player_RestrictBuilding( g_Player1, "space_marine_orbital_relay" ) -- research

-- units	
Player_RestrictSquad( g_Player1, "space_marine_squad_land_raider" ) 
Player_RestrictSquad( g_Player1, "space_marine_squad_terminator" ) 
Player_RestrictSquad( g_Player1, "space_marine_squad_terminator_assault" ) 

Player_RestrictSquad( g_Player4, "eldar_squad_farseer" ) 

-- grant -- research --~ Player_GrantResearch( g_Player1, String researchName )

Rule_Remove( SetResearchLevel )

end


--IMPORTS

import("ScarUtil.scar")


--GLOBAL VARIABLES

-- objectives. -- we create a list of objectives so we can iterate through them nicely -- set the state to 1 when the objective is marked complete g_objectiveList = {} g_objectiveList["CaptureMonument"] = {title="Capture the Monument", id=0 ,desc="Description of objective",priority="Primary", state=0} g_objectiveList["DestroyAvatar"] = {title="Destroy the Avatar", id=0 ,desc="Description of objective",priority="Secondary", state=0} g_objectiveList["CaptureRelics"] = {title="Secure Imperial Relics", id=0 ,desc="Description of objective",priority="Secondary", state=0} g_objectiveList["Transport"] = {title="Salvage Downed Transport", id=0 ,desc="Description of objective",priority="Secondary", state=0}


--GAME SETUP

function OnGameSetup() -- setup players. you only need to do this for players that have a starting point g_Player1 = Setup_Player(0, "$281200", "space_marine_race", 1) g_Player2 = Setup_Player(1, "$281202", "eldar_race", 2) g_Player3 = Setup_Player(2, "$281204", "eldar_race", 2) g_Player4 = Setup_Player(3, "$281204", "eldar_race", 2)

t_lockedsgroups = {
"sg_Vyper_1", 
"sg_RangerGroups",
"sg_SniperAlley", 	
"sg_FarseerRetinue", 
"sg_FirstEldarDefense" }

t_buildlimit = {
{"eldar_support_platform_scatterlaser", 10},
}

t_assignwaypoints = {
{"mk_ai_Monument", 8},
{"mk_ai_LastIntersection", 5},
{"mk_ai_BridgeDefense", 5},
{"mk_ai_Rooftops", 4},
{"mk_ai_FirstFront", 2}
}

--[[table to define where Avatar retreats to]]
t_Avatar_Markers = {"mk_AvatarPatrol_1", "mk_AvatarPatrol_2", "mk_AvatarPatrol_3", "mk_AvatarPatrol_4", "mk_AvatarPatrol_5", "mk_AvatarPatrol_6"}

t_Avatar_Markers_2 = {"mk_Avatar_Retreat_1", "mk_Avatar_Retreat_2" }

g_Stop_Attack = 0

g_AI_Gets_Vehicles = 0

g_Player_Owns_Bridge = 0

g_Avatar_Control = 0
g_Avatar_Aggression = 0

g_Difficulty_Level = 1

-- this function should actually be passing in the variable that defines what difficulty we are at
-- you can use this function to scale the value of difficulty level variblaes
	

end

function OnGameRestore() g_Player1 = World_GetPlayerAt(0) g_Player2 = World_GetPlayerAt(1) g_Player3 = World_GetPlayerAt(2) g_Player4 = World_GetPlayerAt(3) end

function CheatClosing() --~ SGroup_ReSpawn("sg_NIS_AllFinalNISSquads") Util_StartNIS( EVENTS.NIS_Closing )

Rule_AddInterval(Rule_FinalNISOver,1)	

Rule_Remove( Rule_AvatarPatrolStart )
Rule_Remove( Rule_AvatarPatrol_1 )
Rule_Remove( Rule_AvatarPatrol_2 )	
Rule_Remove( Rule_AvatarPatrol_3 )	
Rule_Remove( Rule_AvatarPatrol_4 )	
Rule_Remove( Rule_AvatarPatrol_5 )	
Rule_Remove( Rule_AvatarPatrol_6 )	
Rule_Remove( Rule_Avatar_Back_Off )
Rule_Remove( Rule_AvatarHurt )
Rule_Remove( Rule_AvatarAttack_Again )
Rule_Remove( Rule_AvatarRetreat )
Rule_Remove( Rule_AvatarDestroyed )

--~ print("cheat!") --~ Unrestrict_SquadWithAlerts( g_Player1, "space_marine_squad_assault", "$42908", 408006 ) end


--ON INITIALIZATION

--OnInit should be used for pregame functions, things that should happen before the player officially enters the world.

function OnInit()

Restrict_SpaceMarines( g_Player1, 7 )

DisableAI()

-- Starting first NIS
Rule_Add( Rule_StartNIS )

-- here you add any rules you want to have at the start of the mission
Rule_AddInterval(Rule_Avatar_DelayFunction,1)
Rule_AddInterval(Rule_CaptureRelics,2)
Rule_AddInterval( Rule_PlayerNearBridge,2 )
	
-- begin checking for all primary objectives complete
--Rule_AddInterval(Rule_PlayerHasWon,1) 

--Shows where the monument is.
FOW_RevealMarker("mk_Monument_Reveal",10000)

--Start triggers for Ambushes
Rule_AddInterval( Rule_VyperAmbush, 2)
Rule_AddInterval( Rule_BansheeAttack, 2)

--Research Restrictions
Rule_Add( SetResearchLevel )

-- MUSIC
SetupMusicPlaylist()
-- for now just play the music straight away
Sound_PlaylistStart( PC_Music )

--[[Safety Nets]]
Rule_AddInterval(Rule_TheReturners, 5)
--Rule_AddInterval(Rule_LIBDead, 5)

--setup for opening NIS
Fade_Start( 0, false )
W40k_Letterbox( true, 0 )

--start mission
Rule_AddOneShot( Mission_Start, 0 )

SetDifficultyLevel( Difficulty_Get() )

end

function Rule_Avatar_DelayFunction() if Event_IsAnyRunning() == false then Rule_AddInterval(Rule_DestroyAvatar,1.5) Rule_Remove(Rule_Avatar_DelayFunction) end end

-- This registers your init function with scar. This call has to be made after the defintion -- of the function and it must be called in global scope (global scope means not in any function -- or table) Scar_AddInit(OnInit)

function DisableAI() Cpu_LockSGroupAcrossPlayers( "sg_NisChaosUnits" ) Cpu_LockSGroupAcrossPlayers( "sg_NisEldarUnits" ) Cpu_LockSGroupAcrossPlayers( "sg_NisFinalGroup" ) Cpu_LockSGroupAcrossPlayers( "sg_Eldar_Emplaced" ) Cpu_LockEGroupAcrossPlayers( "eg_Eldar_Bridge_Attack_Support_Portal" ) SGroup_DeSpawn( "sg_NisFinalGroup" ) SGroup_DeSpawn("sg_FINALNIS_Sorceror_1") Cpu_EnableAll( 0 ) end

-- call this with an interval to ensure the mission ends after a period of time, instead of immediately function Rule_GameOver() World_SetGameOver() end

-- checks all the objectives and determines if the player needs to have won the mission -- add this rule to automatically complete the mission once all primary objectives are complete function Rule_PlayerHasWon() -- loop through all primary objectives. if all complete, then end local numberOfPrimaryObjectives = 0 local numberOfCompletePrimaryObjectives = 0 for k,v in pairs(g_objectiveList) do if v.priority == "Primary" then numberOfPrimaryObjectives = numberOfPrimaryObjectives + 1 if v.state == 1 then numberOfCompletePrimaryObjectives = numberOfCompletePrimaryObjectives + 1 end end end if numberOfPrimaryObjectives == numberOfCompletePrimaryObjectives then World_SetTeamWin(g_Player1,"youve won") Rule_AddIntervalEx(Rule_GameOver,5,1) Rule_Remove( Rule_PlayerHasWon ) end end

--Start Mission function Mission_Start()

	obj_table_P1 = { title_id = 280010, short_desc_id = 280011, help_tip_id = 280012 }
	obj_table_S1 = { title_id = 280020, short_desc_id = 280021, help_tip_id = 280022 }
	obj_table_S2 = { title_id = 280030, short_desc_id = 280031, help_tip_id = 280032 }
	obj_table_P2 = { title_id = 280040, short_desc_id = 280041, help_tip_id = 280042 }

end


-- DIFFICULTY LEVEL

-- the functions here set the difficulty level for the mission. Should be called from OnGameSetup function SetDifficultyLevel( difficultyLevel )

Difficulty_SetForAll( difficultyLevel )

-- easy
if difficultyLevel == DIFFICULTY_EASY then

	g_Difficulty_Level = 1
	
-- medium
elseif difficultyLevel == DIFFICULTY_NORMAL then

	g_Difficulty_Level = 2

-- hard
elseif difficultyLevel == DIFFICULTY_HARD then

	g_Difficulty_Level = 3
	
end

end


--PLAYER MUST HAVE UNITS

-- this function detects if the player has lost their base and has no servitors left function Rule_PlayerLoses()

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

g_unit_exceptions = 
{
	"space_marine_squad_librarian",
	"space_marine_squad_force_commander"
}

if( Player_HasBuildingsExcept(g_Player1, g_building_exceptions) == false ) then
	if( Player_HasSquadsExcept(g_Player1, g_unit_exceptions ) == false ) then
		World_SetTeamWin( g_Player2, "" )
		Rule_AddIntervalEx( Rule_GameOver,5,1 )
		Rule_Remove( Rule_PlayerLoses )
	end
end

end

--SAFETY NET

function Rule_TheReturners()

Util_TrackCharacterAndDropPodIn( g_Player1, "sg_Gabriel", "space_marine_squad_force_commander", "mk_FC_Rez" )
Util_TrackCharacterAndDropPodIn( g_Player1, "sg_Isador", "space_marine_squad_librarian", "mk_Librarian_Rez" )

end

--[[ Safety FC function Rule_FCDead()

SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ALL"), Player_GetSquads(g_Player1))
local blueprinttable = Util_MakeBlueprintTable("space_marine_squad_force_commander")

if not SGroup_ContainsBlueprints("sg_ALL", blueprinttable, false) then
	Rule_AddOneShot(Rule_FCResurrect, 1)
	Rule_Remove(Rule_FCDead)
end

SGroup_Clear( SGroup_CreateIfNotFound("sg_FC") )

end

function Rule_FCResurrect() Util_CreateSquadsAndDropPodIn(g_Player1, "sg_FC", "space_marine_squad_force_commander", Marker_GetPosition(Marker_FromName("mk_FC_Rez", "basic_marker")), 1, 1) Rule_AddInterval(Rule_FCDead, 5) end

--[[ Safety LIB ]] function Rule_LIBDead()

SGroup_AddGroup(SGroup_CreateIfNotFound("sg_ALL"), Player_GetSquads(g_Player1))
local blueprinttable = Util_MakeBlueprintTable("space_marine_squad_librarian")

if not SGroup_ContainsBlueprints("sg_ALL", blueprinttable, false) then
	Rule_AddOneShot(Rule_LIBResurrect, 1)
	Rule_Remove(Rule_LIBDead)
end

SGroup_Clear( SGroup_CreateIfNotFound("sg_LIB") )

end

function Rule_LIBResurrect() Util_CreateSquadsAndDropPodIn(g_Player1, "sg_LIB", "space_marine_squad_librarian", Marker_GetPosition(Marker_FromName("mk_Librarian_Rez", "basic_marker")), 1, 1) Rule_AddInterval(Rule_LIBDead, 5) end]]


-- MUSIC/SOUND

function SetupMusicPlaylist() -- clear the current playlist Sound_PlaylistClear( PC_Music ) -- add tracks to the playlist Sound_PlaylistAddTrack( PC_Music, "battle_ingame_01" ) Sound_PlaylistAddTrack( PC_Music, "music_evil_isador_theme" ) Sound_PlaylistAddTrack( PC_Music, "music_urban_wasteland" ) Sound_PlaylistAddTrack( PC_Music, "stinger_pressure_stinger" ) Sound_PlaylistAddTrack( PC_Music, "music_EldarThemev2" ) -- mark these tracks to play randomly Sound_PlaylistSetorder( PC_Music, false ) -- add 5 to 10 seconds silence between tracks Sound_PlaylistSetSilence( PC_Music, 30, 150 ) -- don't play yet Sound_PlaylistPlayNow( PC_Music, "stinger_tensedanger" )

Sound_PlaylistClear( PC_Ambient )
-- add tracks to the playlist    
Sound_PlaylistAddTrack( PC_Ambient, "ambient_city" )
-- mark these tracks to play randomly
Sound_PlaylistSetorder( PC_Ambient, false )
-- add 5 to 10 seconds silence between tracks
Sound_PlaylistSetSilence( PC_Ambient, 5, 10 )

-- don't play yet
Sound_PlaylistStart(PC_Ambient)

end



-------------------------------AI Stuff------------------------------------

function Rule_EnableAIPlayer2()

--Cpu_SetClassPreference(g_Player2, UC_LightInfantry, 10)
--Cpu_SetClassPreference(g_Player2, UC_HeavyInfantry, 3)
--Cpu_SetClassPreference(g_Player2, UC_Vehicle, 5)

Cpu_SetBuildingLimitsTable(g_Player2, t_buildlimit)

Player_GrantResearch( g_Player2, "eldar_ranger_infiltration_research" )
Player_GrantResearch( g_Player2, "eldar_shroud_ability_research" )
Player_GrantResearch( g_Player2, "eldar_webway_gate_relocation_research" )

Player_RestrictSquad( g_Player2, "eldar_squad_avatar" )
Player_RestrictSquad( g_Player4, "eldar_squad_avatar" )

--for i in t_assignwaypoints do
--	local markerID = Marker_FromName(t_assignwaypoints[i][1], "basic_marker")
--	Cpu_AssignWaypoint( g_Player2, markerID, t_assignwaypoints[i][2] )
--end

end

function Rule_EnableAIPlayer3()

--Cpu_SetClassPreference(g_Player3, UC_LightInfantry, 10)
--Cpu_SetClassPreference(g_Player3, UC_HeavyInfantry, 3)
--Cpu_SetClassPreference(g_Player3, UC_Vehicle, 5)

Cpu_SetBuildingLimitsTable(g_Player3, t_buildlimit)

Player_GrantResearch( g_Player3, "eldar_ranger_infiltration_research" )
Player_GrantResearch( g_Player3, "eldar_shroud_ability_research" )
Player_GrantResearch( g_Player3, "eldar_webway_gate_relocation_research" )

--for i in t_assignwaypoints do
--	local markerID = Marker_FromName(t_assignwaypoints[i][1], "basic_marker")
--	Cpu_AssignWaypoint( g_Player2, markerID, t_assignwaypoints[i][2] )
--end

end


---START OPENING NIS

function Rule_StartNIS()

Util_StartNIS( EVENTS.NIS_Opening ) 

Rule_Remove( Rule_StartNIS )

Rule_AddInterval(Rule_StartNISOver,1)

end

--gets everything going after NIS is over function Rule_StartNISOver()

if Event_IsRunning( EVENTS.NIS_Opening ) == false then

	Rule_AddInterval(Rule_CaptureMonument,1)
	
	--Rule_Add( Rule_EldarAttack )
	
	Rule_AddOneShot( Rule_AvatarPatrolStart, 90 )

	Cpu_Enable( g_Player2, 1 ) 
	Cpu_Enable( g_Player4, 1 )
	
	Cpu_UnlockSGroup( g_Player2, "sg_NisEldarUnits" ) 
	
	--SGroup_DestroyAllSquads( "sg_NisEldarExarch" )
			
	SGroup_DestroyAllSquads( "sg_NisChaosUnits" )
	
	Rule_AddOneShot( Rule_EnableAIPlayer2, 1 )
	Rule_AddOneShot( Rule_EnableAIPlayer3, 1 )
	
	Rule_AddInterval( Rule_Player_Near_River, 2 )
	
	Rule_AddInterval( Rule_AI_Vehicle_Counter, 1 )
	Rule_AddInterval( Rule_AI_Gets_Vehicles, 2 )
	
	Rule_AddInterval( Rule_PlayerLoses, 1 )
	
	Rule_AddOneShot( Rule_Make_Things_Interesting_1, 240 )

	if g_Difficulty_Level == 1 then
	
		Cpu_SetDifficultyForDummies( g_Player2, AD_Easy )
		Cpu_SetDifficultyForDummies( g_Player4, AD_Standard )
	
	end

	if g_Difficulty_Level == 2 then
	
		Cpu_SetDifficultyForDummies( g_Player2, AD_Standard )
		Cpu_SetDifficultyForDummies( g_Player4, AD_Hard )
			
	end

	if g_Difficulty_Level == 3 then
	
		Cpu_SetDifficultyForDummies( g_Player2, AD_Advanced )
		Cpu_SetDifficultyForDummies( g_Player4, AD_Insane )
	
	end
	
	if SGroup_Exists( "sg_OPENNIS_Dead_Scouts" ) == true then
	
		SGroup_DestroyAllSquads( "sg_OPENNIS_Dead_Scouts" )
		
	end

	SetCommanderPowerSword( g_Player1 )

	Rule_Remove( Rule_StartNISOver )

end

end

 ------------------------------------------------------------------

------------------PRIMARY OBJECTIVES SECTION------------------

 ------------------------------------------------------------------

--PLAYER MUST CAPTURE MONUMENT

function Rule_CaptureMonument()

-- save now
Util_Autosave( "$280100" ) 

Objective_Add( obj_table_P1, 1 )
	
Util_Ping_LoopingMkr( "Ping_Monument", "mk_Monument" )

Rule_AddInterval(Rule_MonumentIsCaptured,5)
	
--Util_StartIntel( EVENTS.IE_Monument )

Rule_Remove(Rule_CaptureMonument)
	

end

function Rule_MonumentIsCaptured()

-- This determines whether the player and or any Eldar units are near the monument.
Player_GetAllSquadsNearMarker(g_Player1,"sg_PlayerNearMonument","mk_Monument")
Player_GetAllSquadsNearMarker(g_Player3,"sg_EldarNearMonument","mk_Monument")

if  SGroup_IsEmpty("sg_PlayerNearMonument") == false and
	SGroup_IsEmpty("sg_EldarNearMonument") == true then

		Objective_SetState( obj_table_P1.title_id, OS_Complete )
		Util_Ping_Stop( "Ping_Monument" )			
		

--~ World_SetTeamWin(g_Player1,"youve won") --~ Rule_AddIntervalEx(Rule_GameOver,5,1)

--[[ Patch 1.1 - Fix for no remove all Rule_Remove( Rule_AvatarPatrolStart ) Rule_Remove( Rule_AvatarPatrol_1 ) Rule_Remove( Rule_AvatarPatrol_2 ) Rule_Remove( Rule_AvatarPatrol_3 ) Rule_Remove( Rule_AvatarPatrol_4 ) Rule_Remove( Rule_AvatarPatrol_5 ) Rule_Remove( Rule_AvatarPatrol_6 ) Rule_Remove( Rule_Avatar_Back_Off ) Rule_Remove( Rule_AvatarHurt ) Rule_Remove( Rule_AvatarAttack_Again ) Rule_Remove( Rule_AvatarRetreat ) Rule_Remove( Rule_AvatarDestroyed )

		Rule_Remove( Rule_MonumentIsCaptured )
]]
		Rule_RemoveAll()
		Util_StartNIS( EVENTS.NIS_Closing ) 
		
		Rule_AddInterval(Rule_FinalNISOver,1)			
			
end

end

function Rule_FinalNISOver()

if Event_IsRunning( EVENTS.NIS_Closing ) == false then

	World_SetTeamWin(g_Player1,"")
	Rule_AddIntervalEx(Rule_GameOver,5,1)
		
	Rule_Remove(Rule_FinalNISOver)		
	
end

end


---PLAYER NEARING BRIDGE

function Rule_PlayerNearBridge()

Player_GetAllSquadsNearMarker(g_Player1,"sg_PlayerNearBridge","mk_PlayerNearBridge")

if  SGroup_IsEmpty( "sg_PlayerNearBridge" ) == false then
	
	Util_StartIntel( EVENTS.IE_AllTheGuns )
	
	Objective_Add( obj_table_P2, 0 )
	
	FOW_RevealMarker( "mk_PlayerNearBridge", 600 )

	FOW_RevealMarker( "mk_FOW_Reveal_Bridge", 600 )
	
	Util_Ping_LoopingMkr( "Ping_Bridge", "mk_bridge_point" )	
	
	--[[ removed for patch fix -- moved down to Rule_Player_Captured_Bridge()
	Rule_AddInterval( Rule_Player_Bridge_Counter, 1 )
	Rule_AddInterval( Rule_Eldar_Recapture_Bridge, 15 )

]] if not Rule_Exists(Rule_Player_Captured_Bridge) then Rule_AddInterval( Rule_Player_Captured_Bridge, 1 ) end

	Rule_AddInterval( Rule_PlayerOwnsBridge, 2 )

	Rule_AddInterval( Rule_Bridge_Attack, 15 )
	
	Rule_AddInterval( Rule_Autosave_Delay_Bridge,5 )


	if Rule_Exists( Rule_Player_Near_River ) == true then
	
		Rule_Remove( Rule_Player_Near_River )
		
	end
	
	for i=1,3 do
		
		SGroup_Create( "sg_Eldar_Bridge_Attack_"..i )
		
		Cpu_LockSGroupAcrossPlayers( "sg_Eldar_Bridge_Attack_"..i ) 
		
	end
	
	Rule_Remove(Rule_PlayerNearBridge)
	
end

end

function Rule_Autosave_Delay_Bridge()

if Event_IsAnyRunning() == false then

	-- save now
	Util_Autosave( "$280106" ) 
	
	Rule_Remove( Rule_Autosave_Delay_Bridge )
	
end

end

function Rule_Player_Captured_Bridge()

if Player_OwnsEGroup( g_Player1, EGroup_FromName( "eg_bridge_point" ) ) == true then

	g_Player_Owns_Bridge = 0

	Util_StartIntel( EVENTS.IE_BridgePointCaptured )
	
	--[[ this section modified heavily for big fix #3396 ]]
	--[[ this rule added here instead of in Rule_PlayerNearBridge() ]]
	if not Rule_Exists(Rule_Player_Bridge_Counter) then
		Rule_AddInterval( Rule_Player_Bridge_Counter, 1 )
	end
	
	--[[ this rule added here instead of in Rule_PlayerNearBridge() ]]
	if not Rule_Exists(Rule_Eldar_Recapture_Bridge) then
		Rule_AddInterval( Rule_Eldar_Recapture_Bridge, 15 )
	end
	
	--[[ added "if not's" to all of these ]]
	if not Rule_Exists(Rule_Player_Held_Bridge) then
		Rule_AddInterval( Rule_Player_Held_Bridge, 1 )
	end
	
	if not Rule_Exists(Rule_Player_Lost_Bridge) then
		Rule_AddInterval( Rule_Player_Lost_Bridge, 1 )
	end
	
	if not Rule_Exists(Rule_Eldar_Second_Base) then
		Rule_AddOneShot( Rule_Eldar_Second_Base, 15 )
	end
	
	UI_ShowCountdown( 281220, 120 )
	
	Rule_Remove( Rule_Player_Captured_Bridge )

end

end

function Rule_Player_Held_Bridge()

if g_Player_Owns_Bridge >= 60 then

	Util_StartIntel( EVENTS.IE_BridgePointHeld )

	Rule_AddOneShot( Rule_Warp_Spider_Bridge_Attack, 10 )
	
	Rule_Remove( Rule_Player_Held_Bridge )

end

end

function Rule_Player_Bridge_Counter()

if Player_OwnsEGroup( g_Player1, EGroup_FromName( "eg_bridge_point" ) ) == true then

	g_Player_Owns_Bridge = g_Player_Owns_Bridge + 1
	
end

end

function Rule_Player_Lost_Bridge()

if Player_OwnsEGroup( g_Player1, EGroup_FromName( "eg_bridge_point" ) ) == false then

	g_Player_Owns_Bridge = 0
	
	if not Rule_Exists(Rule_Player_Captured_Bridge) then
		Rule_AddInterval( Rule_Player_Captured_Bridge, 1 )
	end
	
	--[[ added for bug fix #3396 - shut down the bridge functions ]]
	UI_HideCountdown()
	Rule_Remove( Rule_Player_Bridge_Counter )
	Rule_Remove( Rule_Eldar_Recapture_Bridge )
	
	Rule_Remove( Rule_Player_Lost_Bridge )
	
end

end

function Rule_Warp_Spider_Bridge_Attack()

if g_Difficulty_Level == 1 then

	Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Eldar_Bridge_Attack_Spiders_1","eldar_squad_warp_spider","mk_Spider_Ambush_Start_1",1,4)
	Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Eldar_Bridge_Attack_Spiders_2","eldar_squad_warp_spider","mk_Spider_Ambush_Start_1",1,4)

else

	Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Eldar_Bridge_Attack_Spiders_1","eldar_squad_warp_spider","mk_Spider_Ambush_Start_1",1,12)
	Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Eldar_Bridge_Attack_Spiders_2","eldar_squad_warp_spider","mk_Spider_Ambush_Start_1",1,12)

end

Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Eldar_Bridge_Attack_Across","eldar_guardian_squad","mk_PlayerAtBridge",2,12)

Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Eldar_Bridge_Attack_Across","eldar_squad_dark_reapers","mk_PlayerAtBridge",2,12)

Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Eldar_Bridge_Attack_Across","eldar_squad_banshees","mk_PlayerAtBridge",2,12)

Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Eldar_Bridge_Attack_Across","eldar_squad_wraithlord","mk_PlayerAtBridge",2,12)

Cpu_LockSGroupAcrossPlayers( "sg_Eldar_Bridge_Attack_Spiders_1" )

Cpu_LockSGroupAcrossPlayers( "sg_Eldar_Bridge_Attack_Spiders_2" )

Cpu_LockSGroupAcrossPlayers( "sg_Eldar_Bridge_Attack_Across" )
	
Cmd_JumpToMarker( "sg_Eldar_Bridge_Attack_Spiders_1", "mk_Spider_Ambush_1" )

Cmd_JumpToMarker( "sg_Eldar_Bridge_Attack_Spiders_2", "mk_Spider_Ambush_2" )

Rule_Remove( Rule_Warp_Spider_Bridge_Attack )

end

function Rule_Bridge_Attack()

if SGroup_IsEmpty( "sg_Eldar_Bridge_Attack_1" ) == true and 
	EGroup_IsEmpty( "eg_Eldar_Bridge_Attack_Aspect_Portal" ) == false then

	if g_Difficulty_Level == 1 then

		Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Eldar_Bridge_Attack_1","eldar_squad_banshees","mk_Eldar_Ambush_Base_Infantry_1",1,5)
	
	else
	
		Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Eldar_Bridge_Attack_1","eldar_squad_banshees","mk_Eldar_Ambush_Base_Infantry_1",1,12)
			
	end

end

if SGroup_IsEmpty( "sg_Eldar_Bridge_Attack_2" ) == true and 
	EGroup_IsEmpty( "eg_Eldar_Bridge_Attack_Webway" ) == false then

	if g_Difficulty_Level == 1 then
	
		Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Eldar_Bridge_Attack_2","eldar_squad_dark_reapers","mk_Eldar_Ambush_Base_Infantry_2",1,3)
		
	else

		Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Eldar_Bridge_Attack_2","eldar_squad_dark_reapers","mk_Eldar_Ambush_Base_Infantry_2",1,12)
		
	end

end

if SGroup_IsEmpty( "sg_Eldar_Bridge_Attack_3" ) == true and 
	EGroup_IsEmpty( "eg_Eldar_Bridge_Attack_Support_Portal" ) == false then

	Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Eldar_Bridge_Attack_3","eldar_squad_wraithlord","mk_Eldar_Ambush_Base_Vehicle",1,1)

end

if g_Player_Owns_Bridge >= 60 and g_Difficulty_Level >= 2 then

	if SGroup_IsEmpty( "sg_Eldar_Bridge_Attack_2" ) == true and 
		EGroup_IsEmpty( "eg_Eldar_Bridge_Attack_Webway" ) == false then

		Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Eldar_Bridge_Attack_2","eldar_squad_dark_reapers","mk_Eldar_Ambush_Base_Infantry_2",1,12)
		Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Eldar_Bridge_Attack_1","eldar_squad_seer_council","mk_Eldar_Ambush_Base_Infantry_1",1,15)

	end
	
end

for i=1,3 do

	Cpu_LockSGroupAcrossPlayers( "sg_Eldar_Bridge_Attack_"..i ) 

	Cmd_AttackMoveMarker( "sg_Eldar_Bridge_Attack_"..i, "mk_PlayerNearBridge" )

end

end

function Rule_Eldar_Recapture_Bridge()

Player_GetAllSquadsNearMarker(g_Player2,"sg_EldarNearBridge","mk_PlayerNearBridge")

if  SGroup_IsEmpty( "sg_EldarNearBridge" ) == false and
	SGroup_IsEmpty( "sg_Eldar_Bridge_Attack_1" ) == false then
	
	Cmd_Capture ( "sg_Eldar_Bridge_Attack_1", "eg_bridge_point" )
	
end

end

function Rule_PlayerOwnsBridge()

if g_Player_Owns_Bridge >= 120 then 

	Anim_PlayEGroupAnim( "eg_bridge_gate_1", "die" )

	Anim_PlayEGroupAnim( "eg_bridge_gate_2", "die" )
	
	Util_StartIntel( EVENTS.IE_BridgePointSucceed )
	
	Objective_SetState( obj_table_P2.title_id, OS_Complete )
	Util_Ping_Stop( "Ping_Bridge" )

	g_Stop_Attack = g_Stop_Attack +1

	Rule_AddInterval(Rule_SuggestSecondaryBase,2)

	Rule_AddInterval( Rule_BansheeAttack_2, 2)

	Rule_AddOneShot( Rule_BridgeDead, 10 )
	
	Rule_AddInterval( Rule_Autosave_Delay_Bridge_Owned,12 )
	
	--[[ shut down the bridge functions ]]
	UI_HideCountdown()

	Rule_Remove( Rule_Bridge_Attack )

	Rule_Remove( Rule_Player_Bridge_Counter )

	Rule_Remove( Rule_Eldar_Recapture_Bridge )

	Rule_Remove( Rule_PlayerOwnsBridge )
	
	Rule_Remove( Rule_Player_Lost_Bridge )

end

end

function Rule_Autosave_Delay_Bridge_Owned()

if Event_IsAnyRunning() == false then

	-- save now
	Util_Autosave( "$280105" ) 
	
	Cmd_AttackMoveMarker( "sg_Eldar_Bridge_Attack_Across", "mk_PlayerNearBridge" )
	
	Rule_Remove( Rule_Autosave_Delay_Bridge_Owned )
	
end

end

function Rule_BridgeDead()

EGroup_DestroyAllEntities( "eg_bridge_gate_1" )

EGroup_DestroyAllEntities( "eg_bridge_gate_2" )

Rule_Remove(Rule_BridgeDead)

end

 ------------------------------------------------------------------

------------------SECONDARY OBJECTIVES SECTION------------------

 ------------------------------------------------------------------

 

--DESTROY AVATAR

function Rule_DestroyAvatar()

if  Player_CanSeeSGroup( g_Player1, "sg_Avatar", false ) == true then

	Util_StartIntel( EVENTS.IE_AvatarYikes )

	Ping_Position( SGroup_GetPosition( SGroup_FromName( "sg_Avatar" )), false )

	Objective_Add( obj_table_S1, 0 )

	-- save now
	--Util_Autosave( "$280101" ) 

	Rule_AddInterval( Rule_AvatarDestroyed, 1 )
	
	Rule_Remove(Rule_DestroyAvatar)
	
end

end

function Rule_AvatarDestroyed()

if  SGroup_IsEmpty("sg_Avatar") == true then
	
	
	Objective_SetState( obj_table_S1.title_id, OS_Complete )

	-- mark the objective state to complete
	g_objectiveList["DestroyAvatar"].state = 1
	
	Util_StartIntel( EVENTS.IE_AvatarDestroyed )
	
	Rule_AddInterval( Rule_Autosave_Delay_Avatar_Owned,5 )
			
	Rule_Remove( Rule_AvatarPatrolStart )
	Rule_Remove( Rule_AvatarPatrol_1 )
	Rule_Remove( Rule_AvatarPatrol_2 )	
	Rule_Remove( Rule_AvatarPatrol_3 )	
	Rule_Remove( Rule_AvatarPatrol_4 )	
	Rule_Remove( Rule_AvatarPatrol_5 )	
	Rule_Remove( Rule_AvatarPatrol_6 )	
	Rule_Remove( Rule_Avatar_Back_Off )
	Rule_Remove( Rule_AvatarHurt )
	Rule_Remove( Rule_AvatarAttack_Again )
	Rule_Remove( Rule_AvatarRetreat )
	Rule_Remove( Rule_AvatarDestroyed )
	
end

end

function Rule_Autosave_Delay_Avatar_Owned()

if Event_IsAnyRunning() == false then

	-- save now
	Util_Autosave( "$280102" ) 
	
	Rule_Remove( Rule_Autosave_Delay_Avatar_Owned )
	
end

end


--CAPTURE RELICS

function Rule_CaptureRelics()

Player_GetAllSquadsNearMarker(g_Player1,"sg_PlayerNearRelic","mk_Relic1")
Player_GetAllSquadsNearMarker(g_Player1,"sg_PlayerNearRelic","mk_Relic2")
Player_GetAllSquadsNearMarker(g_Player1,"sg_PlayerNearRelic","mk_Relic3")

if  SGroup_IsEmpty( "sg_PlayerNearRelic" ) == false then
	
	Util_StartIntel( EVENTS.IE_ImperialRelics )

	-- save now
	--Util_Autosave( "$280103" ) 
	
	Objective_Add( obj_table_S2, 0 )
	
	Rule_AddInterval( Rule_RelicsCaptured, 1 )
	
	Rule_Remove(Rule_CaptureRelics)
	
end

end

function Rule_RelicsCaptured()

if  Player_OwnsEGroup(g_Player1,"eg_Relics") == true then


	-- mark the objective state to complete
	g_objectiveList["CaptureRelics"].state = 1
	
	Objective_SetState( obj_table_S2.title_id, OS_Complete )

	-- save now
	--Util_Autosave( "$280104" ) 
	
	Util_StartIntel( EVENTS.IE_RelicsCaptured )
	
	Unrestrict_SquadWithAlerts( g_Player1, "space_marine_squad_terminator_assault", "$42920", 408064 )
	Unrestrict_SquadWithAlerts( g_Player1, "space_marine_squad_terminator", "$42912", 408010 )
	Unrestrict_BuildingWithAlerts( g_Player1, "space_marine_orbital_relay", "$42960", 408056 )
	
	Rule_Remove(Rule_RelicsCaptured)
	
end

end

 ------------------------------------------------------------------

---------------------------COMBAT SECTION---------------------------

 ------------------------------------------------------------------

 

--AVATAR PATROL

--[[Gets Avatar on the move]]

function Rule_AvatarPatrolStart()

if 	SGroup_IsEmpty( "sg_Avatar" ) == false then

	if  Prox_AllSquadsNearMarker( "sg_Avatar", "mk_Avatar_Retreat_2" ) == true then 

		Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_3" )
		
		Rule_AddInterval(Rule_AvatarPatrol_3,30)
	
	else
	
		Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_1" )

		Rule_AddInterval(Rule_AvatarPatrol_1,30)
		
	end

end


if Rule_Exists( Rule_AvatarHurt ) == false then

	Rule_AddInterval( Rule_AvatarHurt, 2 )

end
	
Rule_Remove(Rule_AvatarPatrolStart)

end

--Avatar patrol. The Avatar moves between points. These rules are removed in the secondary objective of killing the Avatar function Rule_AvatarPatrol_1()

if g_Avatar_Control == 0 then

	if  Prox_AllSquadsNearMarker( "sg_Avatar", "mk_AvatarPatrol_1" ) == true then
	
		if 	SGroup_IsEmpty( "sg_Avatar" ) == false then

			Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_2" )

		end

		Rule_AddInterval(Rule_AvatarPatrol_2,30)

		Rule_Remove(Rule_AvatarPatrol_1)
	
	end

else

	if  Prox_AllSquadsNearMarker( "sg_Avatar", "mk_AvatarPatrol_1" ) == true then
	
		if (World_GetRand(0,2) >= 1 ) then

			if 	SGroup_IsEmpty( "sg_Avatar" ) == false then

				Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_2" )

			end

			Rule_AddInterval(Rule_AvatarPatrol_2,30)

			Rule_Remove(Rule_AvatarPatrol_1)

			else

			if 	SGroup_IsEmpty( "sg_Avatar" ) == false then

				Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_7" )

			end

			Rule_AddOneShot( Rule_Avatar_Back_Off, 1 )

			Rule_Remove(Rule_AvatarPatrol_1)

		end		
	
	end
	
end 

end

function Rule_AvatarPatrol_2()

if g_Avatar_Control == 0 then

	if  Prox_AllSquadsNearMarker( "sg_Avatar", "mk_AvatarPatrol_2" ) == true then
	
		if 	SGroup_IsEmpty( "sg_Avatar" ) == false then

			Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_3" )

		end

		Rule_AddInterval(Rule_AvatarPatrol_3,30)

		Rule_Remove(Rule_AvatarPatrol_2)
	
	end

else

	if  Prox_AllSquadsNearMarker( "sg_Avatar", "mk_AvatarPatrol_2" ) == true then
	
		if (World_GetRand(0,2) >= 1 ) then

			if 	SGroup_IsEmpty( "sg_Avatar" ) == false then

				Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_3" )

			end

			Rule_AddInterval(Rule_AvatarPatrol_3,30)

			Rule_Remove(Rule_AvatarPatrol_2)

			else

			if 	SGroup_IsEmpty( "sg_Avatar" ) == false then

				Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_7" )

			end

			Rule_AddOneShot( Rule_Avatar_Back_Off, 1 )

			Rule_Remove(Rule_AvatarPatrol_2)

		end		
	
	end
	
end 

end

function Rule_AvatarPatrol_3()

if g_Avatar_Control == 0 then

	if  Prox_AllSquadsNearMarker( "sg_Avatar", "mk_AvatarPatrol_3" ) == true then
	
		if 	SGroup_IsEmpty( "sg_Avatar" ) == false then
		
			Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_4" )

		end

		Rule_AddInterval(Rule_AvatarPatrol_4,30)

		Rule_Remove(Rule_AvatarPatrol_3)
	
	end

else

	if  Prox_AllSquadsNearMarker( "sg_Avatar", "mk_AvatarPatrol_3" ) == true then
	
		if (World_GetRand(0,2) >= 1 ) then

			if 	SGroup_IsEmpty( "sg_Avatar" ) == false then

				Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_4" )

			end

			Rule_AddInterval(Rule_AvatarPatrol_4,30)

			Rule_Remove(Rule_AvatarPatrol_3)

			else

			if 	SGroup_IsEmpty( "sg_Avatar" ) == false then

				Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_7" )

			end

			Rule_AddOneShot( Rule_Avatar_Back_Off, 1 )

			Rule_Remove(Rule_AvatarPatrol_3)

		end		
	
	end
	
end 

end

function Rule_AvatarPatrol_4()

if g_Avatar_Control == 0 then

	if  Prox_AllSquadsNearMarker( "sg_Avatar", "mk_AvatarPatrol_4" ) == true then
	
		if 	SGroup_IsEmpty( "sg_Avatar" ) == false then
		
			Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_5" )

		end

		Rule_AddInterval(Rule_AvatarPatrol_5,30)

		Rule_Remove(Rule_AvatarPatrol_4)
	
	end
	
else
	
	if  Prox_AllSquadsNearMarker( "sg_Avatar", "mk_AvatarPatrol_4" ) == true then
	
		if (World_GetRand(0,2) >= 1 ) then

			if 	SGroup_IsEmpty( "sg_Avatar" ) == false then
			
				Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_5" )

			end

			Rule_AddInterval(Rule_AvatarPatrol_5,30)

			Rule_Remove(Rule_AvatarPatrol_4)

			else

			if 	SGroup_IsEmpty( "sg_Avatar" ) == false then

				Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_7" )
				
			end

			Rule_AddOneShot( Rule_Avatar_Back_Off, 1 )

			Rule_Remove(Rule_AvatarPatrol_4)

		end		
	
	end
	
end 

end

function Rule_AvatarPatrol_5()

if g_Avatar_Control == 0 then

	if  Prox_AllSquadsNearMarker( "sg_Avatar", "mk_AvatarPatrol_5" ) == true then
	
		if 	SGroup_IsEmpty( "sg_Avatar" ) == false then
		
			Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_6" )
			
		end

		Rule_AddInterval(Rule_AvatarPatrol_6,30)

		Rule_Remove(Rule_AvatarPatrol_5)
	
	end
	
else
	
	if  Prox_AllSquadsNearMarker( "sg_Avatar", "mk_AvatarPatrol_5" ) == true then
	
		if (World_GetRand(0,2) >= 1 ) then

			if 	SGroup_IsEmpty( "sg_Avatar" ) == false then
			
				Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_6" )
				
			end

			Rule_AddInterval(Rule_AvatarPatrol_6,30)

			Rule_Remove(Rule_AvatarPatrol_5)

			else

			if 	SGroup_IsEmpty( "sg_Avatar" ) == false then
			
				Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_7" )

			end

			Rule_AddOneShot( Rule_Avatar_Back_Off, 1 )

			Rule_Remove(Rule_AvatarPatrol_5)

		end		
	
	end
	
end 

end

function Rule_AvatarPatrol_6()

if g_Avatar_Control == 0 then

	if  Prox_AllSquadsNearMarker( "sg_Avatar", "mk_AvatarPatrol_6" ) == true then
	
		if 	SGroup_IsEmpty( "sg_Avatar" ) == false then
		
			Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_1" )
			
		end

		Rule_AddInterval(Rule_AvatarPatrol_1,30)
		
		g_Avatar_Control = g_Avatar_Control + 1

		Rule_Remove(Rule_AvatarPatrol_6)
	
	end
	
else
	
	if  Prox_AllSquadsNearMarker( "sg_Avatar", "mk_AvatarPatrol_6" ) == true then
	
		if (World_GetRand(0,2) >= 1 ) then

			if 	SGroup_IsEmpty( "sg_Avatar" ) == false then
			
				Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_1" )
				
			end

			Rule_AddInterval(Rule_AvatarPatrol_1,30)

			Rule_Remove(Rule_AvatarPatrol_6)

			else

			if 	SGroup_IsEmpty( "sg_Avatar" ) == false then
			
				Cmd_AttackMoveMarker( "sg_Avatar", "mk_AvatarPatrol_7" )
				
			end

			Rule_AddOneShot( Rule_Avatar_Back_Off, 1 )

			Rule_Remove(Rule_AvatarPatrol_6)

		end		
	
	end
	
end 

end

function Rule_AvatarHurt()

--if SGroup_Count( "sg_Avatar" ) >= 1 then

	if SGroup_GetAvgHealth( "sg_Avatar" ) <= 0.5 then

		Rule_Remove( Rule_AvatarPatrol_1 )
		Rule_Remove( Rule_AvatarPatrol_2 )	
		Rule_Remove( Rule_AvatarPatrol_3 )	
		Rule_Remove( Rule_AvatarPatrol_4 )	
		Rule_Remove( Rule_AvatarPatrol_5 )	
		Rule_Remove( Rule_AvatarPatrol_6 )	
		Rule_Remove( Rule_Avatar_Back_Off )

		if 	SGroup_IsEmpty( "sg_Avatar" ) == false then
		
			Cmd_MoveToClosestMarker( "sg_Avatar", t_Avatar_Markers )
			
		end
	
		if Rule_Exists( Rule_AvatarRetreat ) == false then

			Rule_AddInterval( Rule_AvatarRetreat, 1 )

		end

		Rule_Remove( Rule_AvatarHurt )
	
	end

--end
	

end

function Rule_AvatarRetreat()

for i=1,6 do

	if  Prox_AllSquadsNearMarker( "sg_Avatar", "mk_AvatarPatrol_"..i ) == true then

		if 	SGroup_IsEmpty( "sg_Avatar" ) == false then
		
			Cmd_MoveToClosestMarker( "sg_Avatar", t_Avatar_Markers_2 )
			
			Util_StartIntel( EVENTS.IE_AvatarRetreating )

		end

		if Rule_Exists( Rule_AvatarAttack_Again_Timer ) == false then
		
			Rule_AddOneShot( Rule_AvatarAttack_Again_Timer, 120 )

		end

		Rule_Remove( Rule_AvatarRetreat )

		break
	end
	
end

end

function Rule_AvatarAttack_Again_Timer()

if Rule_Exists( Rule_AvatarAttack_Again ) == false then

	Rule_AddInterval( Rule_AvatarAttack_Again, 30 )

end

Rule_Remove( Rule_AvatarAttack_Again_Timer )

end

function Rule_AvatarAttack_Again()

if  Player_CanSeeSGroup( g_Player1, "sg_Avatar", false ) == false then

	SGroup_SetAvgHealth( "sg_Avatar", 0.7 )
	
	Rule_AddOneShot( Rule_AvatarPatrolStart, 1 )

	Rule_Remove( Rule_AvatarAttack_Again )

end

end

function Rule_Avatar_Back_Off()

if g_Avatar_Aggression == 0 then

	Rule_AddInterval(Rule_Avatar_Back_Off_Part_2,20)

end

if g_Avatar_Aggression == 1 then

	Rule_AddInterval(Rule_Avatar_Back_Off_Part_2,30)

end

if g_Avatar_Aggression == 2 then

	Rule_AddInterval(Rule_Avatar_Back_Off_Part_2,45)

end

if g_Avatar_Aggression == 3 then

	Rule_AddInterval(Rule_Avatar_Back_Off_Part_2,60)

end

if g_Avatar_Aggression == 4 then

	Rule_AddInterval(Rule_Avatar_Back_Off_Part_2,90)

end

g_Avatar_Aggression = g_Avatar_Aggression + 1

Rule_Remove( Rule_Avatar_Back_Off )

end

function Rule_Avatar_Back_Off_Part_2()

if 	SGroup_IsEmpty( "sg_Avatar" ) == false then

	Cmd_MoveToClosestMarker( "sg_Avatar", t_Avatar_Markers )
	
end

if Rule_Exists( Rule_AvatarRetreat ) == false then

	Rule_AddInterval( Rule_AvatarRetreat, 1 )

end

Rule_Remove( Rule_Avatar_Back_Off_Part_2 )

end


--VYPER AMBUSH

--Checks for player to reach a certain point function Rule_VyperAmbush()

Player_GetAllSquadsNearMarker(g_Player1,"sg_Player1","mk_VyperAmbush")

if  SGroup_IsEmpty( "sg_Player1" ) == false then
	
	Rule_Add(Rule_VyperStartAmbush)

	Rule_Remove(Rule_VyperAmbush)
	
end

end

--Once at the point the player is ambushed function Rule_VyperStartAmbush()

Cmd_AttackMoveMarker( "sg_Vyper_1", "mk_AvatarPatrol_2" )

Rule_Remove(Rule_VyperStartAmbush)

end


--BANSHEE ATTACK

--Checks for player to reach a certain point function Rule_BansheeAttack()

Player_GetAllSquadsNearMarker(g_Player1,"sg_Player1_1","mk_banshee_attack")

if  SGroup_IsEmpty( "sg_Player1_1" ) == false then
	
	Rule_Add(Rule_StartBansheeAttack)

	Rule_Remove(Rule_BansheeAttack)
	
end

end

--Once at the point the player is ambushed function Rule_StartBansheeAttack()

Cmd_AttackMoveMarker( "sg_banshee_attack", "mk_banshee_attack" )

Rule_Remove(Rule_StartBansheeAttack)

end


--BANSHEE ATTACK 2

--Checks for player to reach a certain point function Rule_BansheeAttack_2()

Player_GetAllSquadsNearMarker(g_Player1,"sg_Player1_2","mk_banshee_attack_2")

if  SGroup_IsEmpty( "sg_Player1_2" ) == false then
	
	Rule_Add(Rule_StartBansheeAttack_2)

	Rule_Remove(Rule_BansheeAttack_2)
	
end

end

--Once at the point the player is ambushed function Rule_StartBansheeAttack_2()

Cmd_AttackMoveMarker( "sg_banshee_attack", "mk_PlayerBase" )

Rule_Remove(Rule_StartBansheeAttack_2)

end


--ELDAR FIRST ATTACK

--Just making things interesting early on function Rule_EldarAttack()

Cmd_AttackMoveMarker( "sg_EldarGuardianAttack", "mk_PlayerBase" )

Rule_Remove(Rule_EldarAttack)

end


---SECONDARY BASE INTEL EVENT

function Rule_SuggestSecondaryBase()

Player_GetAllSquadsNearMarker(g_Player1,"sg_PlayerAtBridge","mk_PlayerAtBridge")

if  SGroup_IsEmpty( "sg_PlayerAtBridge" ) == false then
	
	Util_StartIntel( EVENTS.IE_AdvancedPosition )

	-- save now
	--Util_Autosave( "$280105" ) 
	
	Rule_Remove(Rule_SuggestSecondaryBase)
	
end

end

function Rule_Eldar_Second_Base()

if SGroup_Exists( "sg_bonesinger_second_base" ) == false then

	SGroup_Create( "sg_bonesinger_second_base" )

end

for i=1,2 do

	Util_CreateSquadsAtMarker( g_Player4, "sg_bonesinger_second_base", "eldar_squad_bonesinger", "mk_Eldar_Second_Base_"..i, 1 )

end

Player_AddResource( g_Player2, RT_Requisition, 50000 )
Player_AddResource( g_Player2, RT_Power, 50000 )
Player_AddResource( g_Player4, RT_Requisition, 50000 )
Player_AddResource( g_Player4, RT_Power, 50000 )
Player_SetSquadCap( g_Player4, 20 )
Player_SetSupportCap( g_Player4, 10 )

Rule_Remove( Rule_Eldar_Second_Base )

end


---CHECK FOR PLAYER NEAR RIVER

function Rule_Player_Near_River()

for i=1,2 do

	Player_GetAllSquadsNearMarker( g_Player1,"sg_PlayerNearRiver","mk_Near_River_"..i )

end

	if  SGroup_IsEmpty( "sg_PlayerNearRiver" ) == false then
	
		Util_StartIntel( EVENTS.IE_NeedToCrossRiver )

		Rule_Remove(Rule_Player_Near_River)
	
	end

end


---GIVE AI VEHICLES

function Rule_AI_Vehicle_Counter()

g_AI_Gets_Vehicles = g_AI_Gets_Vehicles + 1

end

function Rule_AI_Gets_Vehicles()

	if g_AI_Gets_Vehicles >= 300 then
		
		Cpu_UnlockEGroupAcrossPlayers( "eg_Eldar_Bridge_Attack_Support_Portal" )	
		
		Rule_Remove( Rule_AI_Vehicle_Counter )
		
		Rule_Remove( Rule_AI_Gets_Vehicles )
	
	end

end


---GIVE AI UNITS

function Rule_Make_Things_Interesting_1()

if SGroup_Exists( "sg_Some_Eldar" ) == false then

	SGroup_Create( "sg_Some_Eldar" )

end

if SGroup_IsEmpty( "sg_Some_Eldar" ) == true then


	if Player_CanSeePosition( g_Player1,Marker_GetPosition(Marker_FromName( "mk_Eldar_Second_Base_1", "basic_marker") )) == false then
	
		if g_Difficulty_Level == 1 then
	
			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_banshees","mk_Eldar_Second_Base_1",1,4)
			
		else
		
			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_banshees","mk_Eldar_Second_Base_1",1,12)
		
		end

	end

	if Player_CanSeePosition( g_Player1,Marker_GetPosition(Marker_FromName( "mk_Avatar_Retreat_1", "basic_marker") )) == false then

		if g_Difficulty_Level == 1 then
	
			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_Rangers","mk_Avatar_Retreat_1",1,4)
			
		else
		
			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_Rangers","mk_Avatar_Retreat_1",1,12)
		
		end

	end

	if Player_CanSeePosition( g_Player1,Marker_GetPosition(Marker_FromName( "mk_Eldar_Second_Base_4", "basic_marker") )) == false then
	
		if g_Difficulty_Level == 1 then

			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_warp_spider","mk_Eldar_Second_Base_4",1,4)
			
		else
		
			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_warp_spider","mk_Eldar_Second_Base_4",1,12)
		
		end
	
	end
		
end

if g_Stop_Attack == 0 then

	Rule_AddOneShot( Rule_Make_Things_Interesting_2, 120 )

end

Rule_Remove( Rule_Make_Things_Interesting_1 )

end

function Rule_Make_Things_Interesting_2()

if SGroup_Exists( "sg_Some_Eldar" ) == false then

	SGroup_Create( "sg_Some_Eldar" )

end

if SGroup_IsEmpty( "sg_Some_Eldar" ) == true then

	if Player_CanSeePosition( g_Player1,Marker_GetPosition(Marker_FromName( "mk_Eldar_Second_Base_4", "basic_marker") )) == false then

		if g_Difficulty_Level == 1 then

			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_banshees","mk_Eldar_Second_Base_4",1,4)
			
		else
		
			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_banshees","mk_Eldar_Second_Base_4",1,12)
		
		end

	end

	if Player_CanSeePosition( g_Player1,Marker_GetPosition(Marker_FromName( "mk_Eldar_Second_Base_1", "basic_marker") )) == false then
	
		if g_Difficulty_Level == 1 then
	
			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_Rangers","mk_Eldar_Second_Base_1",1,4)
			
		else
		
			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_Rangers","mk_Eldar_Second_Base_1",1,12)
		
		end
	
	end

	if Player_CanSeePosition( g_Player1,Marker_GetPosition(Marker_FromName( "mk_Avatar_Retreat_1", "basic_marker") )) == false then
	
		if g_Difficulty_Level == 1 then
	
			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_warp_spider","mk_Avatar_Retreat_1",1,4)
			
		else
		
			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_warp_spider","mk_Avatar_Retreat_1",1,12)
		
		end

	end
	
end

if g_Stop_Attack == 0 then

	Rule_AddOneShot( Rule_Make_Things_Interesting_3, 120 )

end

Rule_Remove( Rule_Make_Things_Interesting_2 )

end

function Rule_Make_Things_Interesting_3()

if SGroup_Exists( "sg_Some_Eldar" ) == false then

	SGroup_Create( "sg_Some_Eldar" )

end

if SGroup_IsEmpty( "sg_Some_Eldar" ) == true then

	if Player_CanSeePosition( g_Player1,Marker_GetPosition(Marker_FromName( "mk_Avatar_Retreat_1", "basic_marker") )) == false then

		if g_Difficulty_Level == 1 then
			
			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_banshees","mk_Avatar_Retreat_1",1,4)
			
		else
		
			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_banshees","mk_Avatar_Retreat_1",1,12)
					
		end
	
	end

	if Player_CanSeePosition( g_Player1,Marker_GetPosition(Marker_FromName( "mk_Eldar_Second_Base_4", "basic_marker") )) == false then
	
		if g_Difficulty_Level == 1 then

			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_Rangers","mk_Eldar_Second_Base_4",1,4)
			
		else
		
			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_Rangers","mk_Eldar_Second_Base_4",1,12)
			
		end
	
	end

	if Player_CanSeePosition( g_Player1,Marker_GetPosition(Marker_FromName( "mk_Eldar_Second_Base_1", "basic_marker") )) == false then
	
		if g_Difficulty_Level == 1 then
			
			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_warp_spider","mk_Eldar_Second_Base_1",1,4)
			
		else
		
			Util_CreateSquadsAtMarkerEx(g_Player2,"sg_Some_Eldar","eldar_squad_warp_spider","mk_Eldar_Second_Base_1",1,12)
		
		end

	end
		
end

if g_Stop_Attack == 0 then

	Rule_AddOneShot( Rule_Make_Things_Interesting_1, 120 )

end

Rule_Remove( Rule_Make_Things_Interesting_3 )

end

Spelstatistik
Följare
27
Körningar
99
Spelare
12
Senaste omgångarna
Senaste trådarna
Postad 5 years ago
3 svar
Postad 5 years ago
0 svar
Postad 7 years ago
0 svar