--IMPORTS
import("ScarUtil.scar")
function SetResearchLevel(level)
Restrict_SpaceMarines( g_Player1, level )
-- grant
-- research
--~ Player_GrantResearch( g_Player1, "squad_cap_research" ) --~ Player_GrantResearch( g_Player1, "squad_cap_research_1" ) --~ Player_GrantResearch( g_Player1, "squad_cap_research_2" ) --~ --~ Player_GrantResearch( g_Player1, "support_cap_research" ) --~ Player_GrantResearch( g_Player1, "support_cap_research_1" ) --~ Player_GrantResearch( g_Player1, "support_cap_research_2" ) --~ Player_GrantResearch( g_Player1, "support_cap_research_3" )
end
--GAME SETUP
function OnGameSetup()
-- setup players. you only need to do this for players that have a starting point
g_Player1 = Setup_Player(0, "$291100", "space_marine_race", 1)
g_Player2 = Setup_Player(1, "$291102", "chaos_marine_race", 2)
g_Player3 = Setup_Player(2, "$291104", "space_marine_race", 1)
g_Player4 = Setup_Player(3, "$291106", "chaos_marine_race", 2)
g_Player5 = Setup_Player(4, "$291108", "npc_race", 2)
g_chaosunitlist = {
"chaos_marine_squad",
"chaos_squad_cultist",
"chaos_squad_horror",
"chaos_squad_raptor"
}
g_OutpostSpawnTable = {
{ "chaos_squad_cultist", "none", 2 },
{ "chaos_squad_cultist", "none", 2 },
{ "chaos_squad_cultist", "none", 2 },
{ "chaos_squad_cultist", "none", 2 }
}
g_outpostsaved = 0
g_RaptorAttacking = 1
end
-- this will only get called after loading a game function OnGameRestore() g_Player1 = World_GetPlayerAt(0) g_Player2 = World_GetPlayerAt(1) g_Player3 = World_GetPlayerAt(2) g_Player4 = World_GetPlayerAt(3) g_Player5 = World_GetPlayerAt(4)
end
function CheatClosing() Rule_RemoveAll() Util_StartNIS( EVENTS.NIS_Closing ) end
--ON INITIALIZATION
--OnInit should be used for pregame functions, things that should happen before the player officially enters the world.
function OnInit() -- FADE BLACK
Fade_Start( 0, false )
W40k_Letterbox( true, 0 )
-- MUSIC
SetupMusicPlaylist()
-- AI
SGroup_SetHealthInvulnerable( "sg_NIS_ChaosAtChasm", true )
SGroup_SetHealthInvulnerable( "sg_MarinesAtChasm", true )
SetupAI()
-- DIFFICULTY LEVEL
SetDifficultyLevel( Difficulty_Get() )
-- RESEARCH
SetResearchLevel( 8 )
Cmd_Infiltrate( "sg_NIS02_Sindri_1",true)
Cmd_Infiltrate( "sg_NIS02_Sindri_2",true)
Cmd_Infiltrate( "sg_NIS02_Sindri_3",true)
Cmd_Infiltrate( "sg_NIS02_Sindri_4",true)
Cmd_Infiltrate( "sg_NIS02_Sindri_5",true)
Cmd_Infiltrate( "sg_NIS02_Sindri_6",true)
Cmd_Infiltrate( "sg_NIS02_Sindri_7",true)
SGroup_DeSpawn( "sg_NIS02_Sindri_1" )
SGroup_DeSpawn( "sg_NIS02_Sindri_2" )
SGroup_DeSpawn( "sg_NIS02_Sindri_3" )
SGroup_DeSpawn( "sg_NIS02_Sindri_4" )
SGroup_DeSpawn( "sg_NIS02_Sindri_5" )
SGroup_DeSpawn( "sg_NIS02_Sindri_6" )
SGroup_DeSpawn( "sg_NIS02_Sindri_7" )
-- NIS
-- this reveals the chasm
for i=3,5 do
FOW_RevealMarker("mk_ChasmReveal_"..i, -1 )
end
SGroup_DeSpawn( "sg_NIS02_AllObjects" )
EGroup_DeSpawn( "eg_DeadBodies" )
Util_StartNIS( EVENTS.NIS_Opening )
-- OBJECTIVES
OBJ_PRIMARY_STOPCHAOS = { title_id = 290000, short_desc_id = 290002, help_tip_id = 290004 }
OBJ_PRIMARY_SAVEOUTPOST = { title_id = 290010, short_desc_id = 290012, help_tip_id = 290014 }
OBJ_PRIMARY_BREAKDOORS = { title_id = 290020, short_desc_id = 290022, help_tip_id = 290024 }
OBJ_PRIMARY_CLEANSEGUARD = { title_id = 290030, short_desc_id = 290032, help_tip_id = 290034 }
OBJ_SECONDARY_CLEANSECHAOS = { title_id = 290040, short_desc_id = 290042, help_tip_id = 290044 }
Rule_Add( Rule_InitAfterNIS )
-- ALL OTHER STUFF
SetCommanderPowerSword( g_Player1 )
Rule_AddInterval( Rule_MaintainOutpostAssault, 10 )
Rule_AddInterval( Rule_ReinforceSquadsAtChasm, 10 )
EGroup_ForceAddOn( "eg_Outpost_HQ", "space_marine_hq_addon_1" )
--~ EGroup_ForceAddOn( "eg_PlayersHQ", "space_marine_hq_addon_1" )
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)
-- GAME STATE
-- this controls the game state, ensures flow is properly controlled etc function Rule_InitAfterNIS() if Event_IsRunning( EVENTS.NIS_Opening ) == false then Util_ObjectiveCreate( OBJ_PRIMARY_STOPCHAOS, true ) Util_ObjectiveCreate( OBJ_PRIMARY_SAVEOUTPOST, true ) Util_ObjectiveCreate( OBJ_SECONDARY_CLEANSECHAOS, false )
SGroup_SetHealthInvulnerable( "sg_NIS_ChaosAtChasm", false )
SGroup_SetHealthInvulnerable( "sg_MarinesAtChasm", false )
Rule_AddInterval(Rule_ChaosCleansed, 2 )
Util_Ping_LoopingMkr("PING_OUTPOST", "mk_Ping_Outpost")
--~ EGroup_DestroyAllEntities( "eg_NIS01_Thunderhawk" )
-- save outpost
Rule_Add(Rule_InitOutpostAttack)
Rule_AddInterval(Rule_TrackCharacters,10)
-- chaos attacking base
Rule_Add(Rule_RaptorInit)
Rule_AddInterval( Rule_AssaultJump_1, 10 )
Rule_Remove(Rule_InitAfterNIS)
Rule_AddInterval(Rule_PlayerLoses,1)
Util_Autosave( "$291050" )
end
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
-- 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
function Rule_ReinforceSquadsAtChasm() Cmd_ReinforceTrooper( "sg_MarinesAtChasm", 10 ) Cmd_ReinforceTrooper( "sg_NIS_ChaosAtChasm", 10 ) end
function Rule_UnlockLandRaider() Unrestrict_SquadWithAlerts( g_Player1, "space_marine_squad_land_raider", "$42930", 408024 ) Rule_Remove(Rule_UnlockLandRaider) end
-- AI
-- this section has all functions regarding to AI
function SetupAI()
Cpu_Enable( g_Player3, 0 )
Cpu_Enable( g_Player4, 0 )
--~ Cpu_EnableComponent( g_Player2, false, CT_Resourcing )
--~ Cpu_AssignWaypoint( g_Player2, Marker_FromName("mk_AIWaypoint_PlayersBase", "basic_marker"), 20 ) --~ Cpu_AssignWaypoint( g_Player2, Marker_FromName("mk_AIWaypoint_Outpost", "basic_marker"), 10 ) --~ Cpu_AssignWaypoint( g_Player2, Marker_FromName("mk_AIWaypoint_ChapelDoors", "basic_marker"), 0 )
Player_RestrictSquad( g_Player2, "chaos_squad_bloodthirster" )
Player_RestrictSquad( g_Player2, "chaos_squad_sorcerer" )
Player_RestrictSquad( g_Player2, "chaos_squad_lord" )
Player_RestrictResearch( g_Player2, "chaos_bloodthirster_research" )
Cpu_EnableComponent( g_Player2, false, CT_Attacking )
--~ Cpu_SetClassPreference( g_Player2, UC_HeavyInfantryMed, 10.0 ) --~ Cpu_SetClassPreference( g_Player2, UC_HeavyInfantryHigh, 10.0 ) --~ Cpu_SetClassPreference( g_Player2, UC_LightInfantryLow, 5.0 ) --~ Cpu_SetClassPreference( g_Player2, UC_LightInfantryMed, 5.0 ) --~ Cpu_SetClassPreference( g_Player2, UC_LightInfantryHigh, 5.0 ) --~ Cpu_SetClassPreference( g_Player2, UC_VehicleLow, 0.0 ) --~ Cpu_SetClassPreference( g_Player2, UC_VehicleMed, 4.0 ) --~ Cpu_SetClassPreference( g_Player2, UC_VehicleHigh, 1.0 ) --~ Cpu_SetClassPreference( g_Player2, UC_Commander, 0.0 )
Cpu_LockSGroupAcrossPlayers( "sg_ChaosAttackingOutpost_1" )
Cpu_LockSGroupAcrossPlayers( "sg_ChaosAttackingOutpost_2" )
Cpu_LockSGroupAcrossPlayers( "sg_ChaosAttackingOutpost_3" )
Cpu_LockSGroupAcrossPlayers( "sg_ChaosAttackingOutpost_4" )
Cpu_LockSGroupAcrossPlayers( "sg_NIS_ChaosAtTemple" )
Cpu_LockSGroupAcrossPlayers( "sg_NIS_ChaosAtChasm" )
Cmd_SetStance( "sg_NIS_ChaosAtChasm",STANCE_StandGround )
Cmd_SetStance( "sg_MarinesAtChasm",STANCE_StandGround )
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
Cpu_SetDifficulty( g_Player2, AD_Standard )
Cpu_SetMaxPercentage( g_Player2, 0.2 )
-- medium
elseif difficultyLevel == DIFFICULTY_NORMAL then
Cpu_SetDifficulty( g_Player2, AD_Standard )
Cpu_SetMaxPercentage( g_Player2, 0.3 )
-- hard
elseif difficultyLevel == DIFFICULTY_HARD then
Cpu_SetDifficulty( g_Player2, AD_Insane )
Cpu_SetMaxPercentage( g_Player2, 0.8 )
end
end
-- MUSIC/SOUND
function SetupMusicPlaylist()
-- clear the current playlist
Sound_PlaylistClear( PC_Music )
-- add tracks to the playlist
Sound_PlaylistAddTrack( PC_Music, "music_invasion_theme" )
Sound_PlaylistAddTrack( PC_Music, "music_chant" )
Sound_PlaylistAddTrack( PC_Music, "music_theme_spacemarines_01" )
Sound_PlaylistAddTrack( PC_Music, "battle_ingame_01" )
Sound_PlaylistAddTrack( PC_Music, "ambient_ingame_02" )
-- mark these tracks to play randomly
Sound_PlaylistSetorder( PC_Music, true )
-- add 5 to 10 seconds silence between tracks
Sound_PlaylistSetSilence( PC_Music, 20, 70 )
-- don't play yet
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 )
end
-- CHARACTERS
-- this section keeps track of the characters, and controls losing when they die.
-- keeping track of the characters and keeping them alive. function Rule_TrackCharacters() if g_outpostsaved == 0 then Util_TrackCharacterAndDropPodIn( g_Player1, "sg_ForceCommander", "space_marine_squad_force_commander", "mk_ForceCommanderDropPodIn" ) Util_TrackCharacterAndDropPodIn( g_Player1, "sg_Librarian", "space_marine_squad_librarian", "mk_LibrarianDropPodIn" ) else Util_TrackCharacterAndDropPodIn( g_Player1, "sg_ForceCommander", "space_marine_squad_force_commander", "mk_FCSpawn_Outpost" ) Util_TrackCharacterAndDropPodIn( g_Player1, "sg_Librarian", "space_marine_squad_librarian", "mk_LIBSpawn_Outpost" ) end
end
--KEY RITUAL
-- chaos are performing a ritual to release the key, player must stop them
function Rule_PlayerWinsAfterNIS() if Event_IsRunning( EVENTS.NIS_Closing ) == false then
--~ Rule_Remove(Rule_RandomAttackOnOutpost)
World_SetTeamWin(g_Player1,"")
Rule_AddIntervalEx(Rule_GameOver,5,1)
Rule_Remove(Rule_PlayerWinsAfterNIS)
end
end
--CHAPEL DOORS
-- the doors that protect the chapel are almost indestructible
-- tell player to destroy the chapel doors with vehicles function Rule_DestroyChapelDoors() Util_StartIntel( EVENTS.IE_ChapelDoors ) Rule_Add(Rule_DestroyChapelDoors_Save)
Rule_Remove(Rule_DestroyChapelDoors)
end
function Rule_DestroyChapelDoors_Save() if not Event_IsRunning(EVENTS.IE_ChapelDoors) then
Util_ObjectiveCreate( OBJ_PRIMARY_BREAKDOORS, true)
Util_Ping_LoopingMkr("PING_DOORS", "mk_Ping_Doors")
Rule_Add(Rule_ChapelDoorsDestroyed)
Rule_AddInterval(Rule_UnlockLandRaider, 6 )
Rule_Remove(Rule_DestroyChapelDoors_Save)
Util_Autosave( "$291052" )
end
end
function Rule_ChapelDoorsDestroyed() if EGroup_Count("eg_ChapelDoors") == 0 then
Util_ObjectiveComplete( OBJ_PRIMARY_BREAKDOORS.title_id )
Util_Ping_Stop("PING_DOORS")
-- imperial guard arrive
Rule_Add(Rule_ImperialGuardArrive)
Rule_Remove(Rule_ChapelDoorsDestroyed)
end
end
-- SAVE THE OUTPOST
-- the outpost is under attack, get units over there and protect it.
function Rule_InitOutpostAttack() Rule_AddInterval(Rule_TrackBadGuysAttackingOutpost, 1 )
Rule_AddInterval(Rule_OutpostLost,1)
Rule_AddInterval(Rule_ReissueAttackCommand, 5 )
--~ Rule_AddInterval(Rule_RandomAttackOnOutpost,20)
Rule_AddInterval(Rule_OutpostSaved,1)
Rule_AddInterval(Rule_PlayerAtMachineCult_1,1)
Rule_AddInterval(Rule_PlayerAtMachineCult_2,1)
Rule_AddInterval(Rule_PlayerAtHQ_1,1)
Rule_AddInterval(Rule_PlayerAtTurret_1,1)
Rule_AddInterval(Rule_PlayerAtTurret_2,1)
Rule_AddInterval(Rule_PlayerAtTurret_3,1)
Rule_AddInterval(Rule_PlayerOwnsOutpost,1)
Rule_AddInterval(Rule_IncreaseAttack_1, 60*15)
Rule_AddInterval(Rule_IncreaseAttack_2, 60*25)
Rule_AddInterval(Rule_IncreaseAttack_3, 60*35)
Rule_AddInterval(Rule_IncreaseAttack_4, 60*45)
Rule_Remove( Rule_InitOutpostAttack )
end
-- these functions increase the intensity of the attack on the outpost over time to ensure the base wont be safe forever function Rule_IncreaseAttack_1() g_OutpostSpawnTable = { { "chaos_squad_cultist", "chaos_grenade_launcher", 10 }, { "chaos_squad_cultist", "none", 10 }, { "chaos_squad_cultist", "chaos_grenade_launcher", 10 }, { "chaos_squad_cultist", "none", 10 } } Rule_Remove(Rule_IncreaseAttack_1) end
function Rule_IncreaseAttack_2() g_OutpostSpawnTable = { { "chaos_squad_cultist", "chaos_grenade_launcher", 10 }, { "chaos_marine_squad", "none", 8 }, { "chaos_squad_cultist", "chaos_grenade_launcher", 10 }, { "chaos_marine_squad", "none", 8 } } Rule_Remove(Rule_IncreaseAttack_2) end
function Rule_IncreaseAttack_3() g_OutpostSpawnTable = { { "chaos_squad_cultist", "chaos_grenade_launcher", 10 }, { "chaos_marine_squad", "chaos_plasma_gun_tactical", 8 }, { "chaos_marine_squad", "chaos_plasma_gun_tactical", 8 }, { "chaos_marine_squad", "chaos_plasma_gun_tactical", 8 } } Rule_Remove(Rule_IncreaseAttack_3) end
function Rule_IncreaseAttack_4() g_OutpostSpawnTable = { { "chaos_squad_cultist", "chaos_grenade_launcher", 10 }, { "chaos_marine_squad", "chaos_missile_launcher_tactical", 8 }, { "chaos_marine_squad", "chaos_missile_launcher_tactical", 8 }, { "chaos_marine_squad", "chaos_missile_launcher_tactical", 8 } } Rule_Remove(Rule_IncreaseAttack_4) end
-- endlessly generates new guys to attack the outpost -- will stop once player has squads in proximity function Rule_MaintainOutpostAssault() Player_GetAllSquadsNearMarker( g_Player1, "sg_PlayerSquadsNearOutpost", "mk_Outpost" )
if SGroup_Count( "sg_PlayerSquadsNearOutpost" ) == 0 then
SGroup_CreateIfNotFound( "sg_CultistTemp" )
for i=1,3 do
if SGroup_Count( "sg_ChaosAttackingOutpost_"..i ) < 1 and not Player_CanSeePosition( g_Player1, Marker_GetPosition( Marker_FromName( "mk_ChaosAttackingOutpostSpawn_"..i, "basic_marker" ) ) ) then
Util_CreateSquadsAtMarker(g_Player2, "sg_CultistTemp", g_OutpostSpawnTable[i][1], "mk_ChaosAttackingOutpostSpawn_"..i, g_OutpostSpawnTable[i][3] )
if not g_OutpostSpawnTable[i][2] == "none" then
SGroup_ForEach( "sg_CultistTemp", function( sgroupid, itemindex, squadID ) return Squad_UpgradeWeapon( squadID, g_OutpostSpawnTable[i][2] ) end )
end
Cpu_LockSGroupAcrossPlayers( "sg_CultistTemp" )
--~ Cmd_AttackMoveMarker( "sg_CultistTemp", "mk_ChaosAttackingOutpostAttack_"..i ) if i==1 and not EGroup_Count("eg_Outpost_MC1") == 0 then Cmd_AttackEGroup( "sg_CultistTemp", "eg_Outpost_MC1" ) else Cmd_AttackEGroup( "sg_CultistTemp", "eg_Outpost" ) end SGroup_AddGroup( "sg_ChaosAttackingOutpost_"..i, "sg_CultistTemp" ) SGroup_Clear( "sg_CultistTemp" ) end
end
else
Rule_Remove(Rule_MaintainOutpostAssault)
Rule_Remove(Rule_ReissueAttackCommand)
end
end
-- need to reissue the attack command every once in awhile to ensure things dont go stale function Rule_ReissueAttackCommand() for i=1,3 do if i==1 and not EGroup_Count("eg_Outpost_MC1") == 0 then Cmd_AttackEGroup( "sg_ChaosAttackingOutpost_"..i, "eg_Outpost_MC1" ) else Cmd_AttackEGroup( "sg_ChaosAttackingOutpost_"..i, "eg_Outpost" ) end
end
end
-- track the bad guys attacking the outpost function Rule_TrackBadGuysAttackingOutpost() if SGroup_Count( "sg_ChaosAttackingOutpost_1" ) == 0 and SGroup_Count( "sg_ChaosAttackingOutpost_2" ) == 0 and SGroup_Count( "sg_ChaosAttackingOutpost_3" ) == 0 and SGroup_Count( "sg_PlayerSquadsNearOutpost" ) > 0 then g_outpostsaved = 1 Rule_Remove(Rule_TrackBadGuysAttackingOutpost) end end
-- the player has saved the outpost function Rule_OutpostSaved() if g_outpostsaved == 1 then if Rule_Exists(Rule_PlayerOwnsOutpost) then Rule_Remove(Rule_PlayerOwnsOutpost) end if Rule_Exists(Rule_TrackBadGuysAttackingOutpost) then Rule_Remove(Rule_TrackBadGuysAttackingOutpost) end if Rule_Exists(Rule_MaintainOutpostAssault) then Rule_Remove(Rule_MaintainOutpostAssault) end
-- we need to destroy force commander and librarian, but first we need to make sure they are the only ones in the group
local KillForceCommander = function( groupid, itemindex, itemid )
--~ if Squad_GetBlueprintName( itemid ) == "force_commander" then Squad_KillEntityWithBP( itemid, "force_commander" ) --~ end
end
local KillLibrarian = function( groupid, itemindex, itemid )
--~ if Squad_GetBlueprintName( itemid ) == "librarian" then --~ Squad_Destroy( itemid ) --~ end Squad_KillEntityWithBP( itemid, "librarian" ) end
SGroup_ForEach( "sg_ForceCommander", KillForceCommander )
SGroup_ForEach( "sg_Librarian", KillLibrarian )
--~ SGroup_DestroyAllSquads( "sg_ForceCommander" ) --~ SGroup_DestroyAllSquads( "sg_Librarian" )
Util_TrackCharacterAndDropPodIn( g_Player1, "sg_ForceCommander", "space_marine_squad_force_commander", "mk_FCSpawn_Outpost" )
Util_TrackCharacterAndDropPodIn( g_Player1, "sg_Librarian", "space_marine_squad_librarian", "mk_LIBSpawn_Outpost" )
Util_CreateSquadsAndDropPodIn( g_Player1, "sg_PlayersServitor", "space_marine_squad_servitor", Marker_GetPosition(Marker_FromName("mk_ServitorIncoming", "basic_marker")), 1, 1 )
Cpu_AssignWaypoint( g_Player2, Marker_FromName("mk_AIWaypoint_PlayersBase", "basic_marker"), 10 )
Cpu_AssignWaypoint( g_Player2, Marker_FromName("mk_AIWaypoint_Outpost", "basic_marker"), 5 )
Cpu_AssignWaypoint( g_Player2, Marker_FromName("mk_AIWaypoint_ChapelDoors", "basic_marker"), 20 )
EGroup_SetPlayerOwner("eg_Outpost", g_Player1 )
Util_ObjectiveComplete( OBJ_PRIMARY_SAVEOUTPOST.title_id )
Util_Ping_Stop("PING_OUTPOST")
-- now we tell the player they need to destroy the doors to the chapel with their vehicles
Rule_Add( Rule_DestroyChapelDoors )
Rule_Remove(Rule_OutpostSaved)
Rule_Remove(Rule_OutpostLost)
end
end
function Rule_OutpostLost() if EGroup_Count( "eg_Outpost_JustMCandHQ" ) == 0 then Util_ObjectiveFail( OBJ_PRIMARY_SAVEOUTPOST.title_id ) World_SetTeamWin(g_Player2,"") Rule_AddIntervalEx(Rule_GameOver,8,1) Rule_Remove(Rule_OutpostLost) end end
-- give player ownership of structures they are near function Rule_PlayerAtMachineCult_1() if Prox_PlayerSquadsInProximityOfEntities( g_Player1, "eg_Outpost_MC1", 10, 0 ) then EGroup_SetPlayerOwner( "eg_Outpost_MC1", g_Player1 ) Rule_Remove(Rule_PlayerAtMachineCult_1) end end
function Rule_PlayerAtMachineCult_2() if Prox_PlayerSquadsInProximityOfEntities( g_Player1, "eg_Outpost_MC2", 10, 0 ) then EGroup_SetPlayerOwner( "eg_Outpost_MC2", g_Player1 ) Rule_Remove(Rule_PlayerAtMachineCult_2) end end
function Rule_PlayerAtHQ_1() if Prox_PlayerSquadsInProximityOfEntities( g_Player1, "eg_Outpost_HQ", 10, 0 ) then EGroup_SetPlayerOwner( "eg_Outpost_HQ", g_Player1 ) Rule_Remove(Rule_PlayerAtHQ_1) end end
function Rule_PlayerAtTurret_1() if Prox_PlayerSquadsInProximityOfEntities( g_Player1, "eg_Outpost_Turrets_1", 10, 0 ) then EGroup_SetPlayerOwner( "eg_Outpost_Turrets_1", g_Player1 ) Rule_Remove(Rule_PlayerAtTurret_1) end end
function Rule_PlayerAtTurret_2() if Prox_PlayerSquadsInProximityOfEntities( g_Player1, "eg_Outpost_Turrets_2", 10, 0 ) then EGroup_SetPlayerOwner( "eg_Outpost_Turrets_2", g_Player1 ) Rule_Remove(Rule_PlayerAtTurret_2) end end
function Rule_PlayerAtTurret_3() if Prox_PlayerSquadsInProximityOfEntities( g_Player1, "eg_Outpost_Turrets_3", 10, 0 ) then EGroup_SetPlayerOwner( "eg_Outpost_Turrets_3", g_Player1 ) Rule_Remove(Rule_PlayerAtTurret_3) end end
-- once player has all the main structures then they have saved the outpost function Rule_PlayerOwnsOutpost() if (EGroup_ForEach( "eg_Outpost_MC1", function( egroupid, itemindex, entityID ) return Entity_GetPlayerOwner( entityID ) end ) ) == g_Player1 and (EGroup_ForEach( "eg_Outpost_MC2", function( egroupid, itemindex, entityID ) return Entity_GetPlayerOwner( entityID ) end ) ) == g_Player1 and (EGroup_ForEach( "eg_Outpost_HQ", function( egroupid, itemindex, entityID ) return Entity_GetPlayerOwner( entityID ) end ) ) == g_Player1 then g_outpostsaved = 1 Rule_Remove(Rule_PlayerOwnsOutpost) end end
-- create some random chaos guys and attack the outpost. this will probably be replaced with AI? function Rule_RandomAttackOnOutpost() if SGroup_Count( "sg_ChaosAttackingOutpost" ) <= 1 then SGroup_CreateIfNotFound("sg_ChaosAttackTemp") Util_CreateSquadsAtMarker(g_Player2, "sg_ChaosAttackTemp", g_chaosunitlist[World_GetRand(1,4)], "mk_ChaosToAttackOutpost", 1 ) Cmd_AttackMoveMarker( "sg_ChaosAttackTemp", "mk_ChaosAttackingOutpostAttack_1" ) Cpu_LockSGroupAcrossPlayers("sg_ChaosAttackTemp") SGroup_AddGroup("sg_ChaosAttackingOutpost", "sg_ChaosAttackTemp" ) end end
-- CHAOS ATTACKING BASE
-- spawns horrors at random locations and orders attack to players base
--~ function Rule_PrimaryTempleDestroyed() --~ if EGroup_Count( "eg_Chaos_PrimaryTemple" ) == 0 then --~ Cpu_LockEGroupAcrossPlayers( "eg_Chaos_BackupTemples" ) --~ Rule_Remove(Rule_PrimaryTempleDestroyed ) --~ end --~ end
--~ function Rule_AttackPlayersBase() --~ if SGroup_Count( "sg_HorrorsAttackingPlayersBase" ) <= 1 then --~ SGroup_CreateIfNotFound("sg_HorrorTemp") --~ Util_CreateSquadsAtMarker(g_Player2, "sg_HorrorTemp", g_chaosunitlist[3], "mk_HorrorSpawn_"..World_GetRand(1,3), 1 ) --~ Cmd_AttackMoveMarker( "sg_HorrorTemp", "mk_PlayersBase" ) --~ Cpu_LockSGroupAcrossPlayers("sg_HorrorTemp") --~ SGroup_AddGroup("sg_HorrorsAttackingPlayersBase", "sg_HorrorTemp" ) --~ end --~ end
-- check for completion of the secondary objective function Rule_ChaosCleansed() if Player_GetUnitCount( g_Player2 ) == 0 and Player_GetBuildingsCount( g_Player2 ) == 0 then Util_ObjectiveComplete( OBJ_SECONDARY_CLEANSECHAOS.title_id ) Rule_Remove( Rule_ChaosCleansed ) end end
-- JUMPING OVER CHASM
--- this controls the raptors that jump over the chasm
function Rule_RaptorInit() for i=1,4 do Cmd_SetStance( "sg_ChaosRaptors_"..i, STANCE_Attack ) end Rule_AddInterval(Rule_StartRaptorAttack, 1 ) Rule_Remove(Rule_RaptorInit) end
function Rule_StartRaptorAttack() Cmd_AttackMoveMarker( "sg_ChaosRaptors_"..g_RaptorAttacking, "mk_RaptorJumpFrom" ) Rule_AddInterval( Rule_RaptorJump, 0.5 ) Rule_Remove(Rule_StartRaptorAttack) end
function Rule_RaptorJump() if SGroup_Count( SGroup_FromName("sg_ChaosRaptors_"..g_RaptorAttacking) ) > 0 then if Prox_MarkerSGroup( "mk_RaptorJumpFrom", "sg_ChaosRaptors_"..g_RaptorAttacking, PROX_SHORTEST ) <= 3 then Rule_Remove( Rule_RaptorJump ) Rule_AddInterval(Rule_RaptorsActualJump, 2 ) end end end
function Rule_RaptorsActualJump() Cmd_JumpToMarker( "sg_ChaosRaptors_"..g_RaptorAttacking, "mk_RaptorJumpTo" ) Rule_Remove( Rule_RaptorsActualJump ) Rule_AddInterval(Rule_RaptorsAttackMoveToBase, 5 ) end
function Rule_RaptorsAttackMoveToBase() Cmd_AttackMoveMarker( "sg_ChaosRaptors_"..g_RaptorAttacking, "mk_PlayersBase" ) Rule_Remove(Rule_RaptorsAttackMoveToBase) g_RaptorAttacking = g_RaptorAttacking + 1 if g_RaptorAttacking <= 4 then Rule_AddInterval(Rule_StartRaptorAttack, 15 ) end end
function Rule_AssaultJump_1() Cmd_JumpToMarker( "sg_AssaultChasm_1", "mk_AssaultJump_1" ) Rule_Remove( Rule_AssaultJump_1 ) end
function Rule_AssaultJump_2() Cmd_JumpToMarker( "sg_AssaultChasm_2", "mk_AssaultJump_2" ) Rule_Remove( Rule_AssaultJump_2 ) end
-- IMPERIAL GUARD ARRIVE
-- once the chapel doors are destroyed the imperial guard arrive and waylay the player whilst the ritual completes.
function Rule_ImperialGuardArrive()
EGroup_DeSpawn( "eg_Key" )
SGroup_DeSpawn( "sg_CultistsRitual" )
Util_StartIntel( EVENTS.IE_TraitorousGuardsmen )
Rule_Add(Rule_ImperialGuardArrive_Save)
Util_CreateSquadsAtMarker(g_Player5, "sg_ImperialGuard", "guard_squad_soldier", "mk_ImperialGuardArriveLocation", 10 )
Util_CreateSquadsAtMarker(g_Player5, "sg_ImperialGuard", "guard_squad_soldier", "mk_ImperialGuardArriveLocation_2", 10 )
Rule_AddIntervalEx(Rule_ImperialsAttackPlayer, 1, 1 )
Rule_AddInterval(Rule_ChaosEscape, 1 )
Rule_Remove( Rule_ImperialGuardArrive )
end
function Rule_ImperialGuardArrive_Save() if not Event_IsRunning( EVENTS.IE_TraitorousGuardsmen ) then Util_ObjectiveCreate(OBJ_PRIMARY_CLEANSEGUARD, true) Util_Autosave("$291054")
--~ Rule_Remove(Rule_ImperialGuardArrive_Save) end end
-- tell the imperial guard to attack the player function Rule_ImperialsAttackPlayer() Cmd_AttackMoveMarker( "sg_ImperialGuard", "mk_ImperialGuardAttackMove" ) end
-- get the chaos guys off the map function Rule_ChaosEscape() if SGroup_Count( "sg_ImperialGuard" ) == 0 then Util_ObjectiveComplete(OBJ_PRIMARY_CLEANSEGUARD.title_id) Rule_Remove(Rule_ChaosEscape)
Rule_Add( Rule_PlayClosingNIS )
end
end
function Rule_PlayClosingNIS() Util_ObjectiveComplete( OBJ_PRIMARY_STOPCHAOS.title_id ) Util_StartNIS( EVENTS.NIS_Closing ) Rule_Remove(Rule_PlayClosingNIS) Rule_RemoveAll() Rule_Add(Rule_PlayerWinsAfterNIS) end