--IMPORTS
import("ScarUtil.scar")
--GAME SETUP
function OnGameSetup()
g_Player1 = Setup_Player(0, "$241200", "space_marine_race", 1)
g_Player2 = Setup_Player(1, "$241202", "ork_race", 2)
g_Player3 = Setup_Player(2, "$241204", "ork_race", 2)
g_Player4 = Setup_Player(3, "$241206", "ork_race", 2)
g_Player5 = Setup_Player(4, "$241208", "space_marine_race", 1)
g_Player6 = Setup_Player(5, "$241210", "ork_race", 2)
g_orkbuildling_exceptions =
{
"ork_mine_field",
"ork_waagh_banner",
"ork_gork_totem"
}
g_aienabled = 0
g_objectivescompleted = 0
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) g_Player6 = World_GetPlayerAt(5)
end
function CheatClosing() SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Player2All"), Player_GetSquads(g_Player2)) EGroup_AddGroup(EGroup_CreateIfNotFound("eg_Player2All"), Player_GetEntities(g_Player2))
SGroup_DestroyAllSquads( "sg_Player2All" )
EGroup_DestroyAllEntities( "eg_Player2All" )
SGroup_AddGroup(SGroup_CreateIfNotFound("sg_Player6All"), Player_GetSquads(g_Player6))
EGroup_AddGroup(EGroup_CreateIfNotFound("eg_Player6All"), Player_GetEntities(g_Player6))
SGroup_DestroyAllSquads( "sg_Player6All" )
EGroup_DestroyAllEntities( "eg_Player6All" )
Rule_AddOneShot(Rule_StartFinalNIS, 0)
end
--ON INITIALIZATION
--OnInit should be used for pregame functions, things that should happen before the player officially enters the world. --Despawn Reserve Units, Set Groups and Start commands for persistent behaviors.
function OnInit() -- DIFFICULTY LEVEL SetDifficultyLevel( Difficulty_Get() )
-- make player whilrwinds invulnerable so that they don't get damaged during the NIS
SGroup_SetHealthInvulnerable("sg_PlayersWhirlwinds", true)
-- RESEARCH
SetResearchLevel( 4 )
-- FADE BLACK
EventCue_Enable(false)
Fade_Start( 0, false )
W40k_Letterbox( true, 0 )
-- MUSIC
SetupMusicPlaylist()
-- AI
SetupAI()
-- NIS
-- load the orks in the buildings
Cmd_EnterBuilding( "sg_ShootasAtStart", "eg_BoyzHut_1" )
-- disable offset
Util_StartNIS( EVENTS.NIS_Opening )
SGroup_DeSpawn( "sg_NIS_Nob" )
SGroup_DeSpawn("sg_NIS02_NonDummy")
SGroup_DeSpawn( "sg_NIS02_Thunderhawk" )
SGroup_DeSpawn("sg_NIS01_Squiggoth" )
-- despawn the players HQ for now
EGroup_DeSpawn( "eg_PlayersHQ" )
EGroup_DeSpawn("eg_PlayersChapel")
EGroup_DeSpawn("eg_PlayersArmoury")
EGroup_DeSpawn("eg_PlayersGenerator")
-- despawn end nis objects
SGroup_DeSpawn("sg_NIS_AllFinalNISSquads")
Cmd_SetStance( "sg_PlayersWhirlwinds", STANCE_CeaseFire )
Rule_Add( Rule_InitAfterNIS )
-- OBJECTIVES
OBJ_PRIMARY_KILLWARBOSS = { title_id = 240000, short_desc_id = 240002, help_tip_id = 240004 }
OBJ_PRIMARY_ESTABLISHBASE = { title_id = 240010, short_desc_id = 240012, help_tip_id = 240014 }
OBJ_PRIMARY_DESTROYSECONDORKS = { title_id = 240020, short_desc_id = 240022, help_tip_id = 240024 }
OBJ_SECONDARY_FINDANOTHERPATH = { title_id = 240030, short_desc_id = 240032, help_tip_id = 240034 }
OBJ_SECONDARY_ESTABLISHSECONDBASE = { title_id = 240040, short_desc_id = 240042, help_tip_id = 240044 }
OBJ_SECONDARY_RESEARCHMELTA = { title_id = 240050, short_desc_id = 240052, help_tip_id = 240054 }
-- ALL OTHER STUFF
SetCommanderPowerSword( g_Player1 )
SetCommanderPowerSword( g_Player5 )
EGroup_ForceAddOn( "eg_OrkHQ", "ork_hq_addon" )
Rule_UpdatePlayerSGroups()
Rule_AddInterval( Rule_UpdatePlayerSGroups, 0.5 )
local modifier_hqconstructionspeed = Modifier_Create(
MAT_EntityType, -- This modifier will be applied to a weapon type
"construction_speed_modifier", -- Modify the max range of the weapon
MUT_Multiplication, -- use multiplication
false,
4,
"servitor" -- Do this to the sniper rifle
)
g_modifier_hqconstructionspeed = Modifier_ApplyToPlayer( modifier_hqconstructionspeed, g_Player1 )
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
-- this function serves the same purpose as OnInit, but it allows us to play the NIS then start checking all the rules. function Rule_InitAfterNIS() if Event_IsRunning( EVENTS.NIS_Opening ) == false then
-- player whirlwinds were invulnerable during the NIS so that they wouldn't get damaged
SGroup_SetHealthInvulnerable("sg_PlayersWhirlwinds", false)
-- apply modifier to orkamungus, give him mega health
local modifier = Modifier_Create(
MAT_EntityType, -- This modifier will be applied to an entity blueprint
"health_maximum_modifier", -- Modify entity sight radius
MUT_Multiplication, -- Multiply sight radius by 0.5 non exclusive
false,
4,
"ork_warboss" -- Do this to all entities in the entity list
)
-- apply it to the player
local modID1 = Modifier_ApplyToPlayer( modifier, g_Player6 )
local modifier = Modifier_Create(
MAT_EntityType, -- This modifier will be applied to an entity blueprint
"health_maximum_modifier", -- Modify entity sight radius
MUT_Multiplication, -- Multiply sight radius by 0.5 non exclusive
false,
2,
"ork_squiggoth" -- Do this to all entities in the entity list
)
-- apply it to the player
local modID2 = Modifier_ApplyToPlayer( modifier, g_Player6 )
SGroup_DestroyAllSquads("sg_NIS01_AllOrkToDestroy")
Cmd_MoveToMarker( "sg_NIS01_Squiggoth", "mk_NIS01_SquiggothMoveTo" )
SGroup_DeSpawn( "sg_NIS_Whirlwind_1")
SGroup_DeSpawn( "sg_NIS_Whirlwind_2" )
SGroup_DeSpawn( "sg_NIS_Whirlwind_3" )
SGroup_DeSpawn( "sg_NIS01_DummyAssMarines" )
SGroup_DeSpawn( "sg_NIS_Assault_1" )
SGroup_DeSpawn( "sg_NIS_Assault_2" )
-- despawn start nis squads
SGroup_DeSpawn("sg_NIS_AllStartNISSquads")
SGroup_Clear( "sg_NIS_AllStartNISSquads" )
SGroup_DeSpawn("sg_NIS01_TrukkUnloadingNob")
SGroup_Clear( "sg_NIS01_TrukkUnloadingNob" )
SGroup_DeSpawn("sg_NIS01_MiscSqads")
SGroup_Clear( "sg_NIS01_MiscSqads" )
-- killwarboss
Rule_AddInterval(Rule_OrkamungusDead,1)
Rule_AddInterval( Rule_SquiggothRampages, 1 )
Rule_AddInterval(Rule_EstablishBase, 1)
-- destroysecondorks
--~ Rule_AddInterval(Rule_DestroySecondOrks, 1)
-- remove groups from AI control when attacked
Rule_AddInterval( Rule_ReleaseOnAttack_BigMek,1 )
Rule_AddInterval( Rule_ReleaseOnAttack_Warboss,1 )
Rule_AddInterval( Rule_ReleaseOnAttack_Squiggoth,1 )
Rule_AddInterval( Rule_ReleaseOnAttack_Wartraks,1 )
Rule_AddInterval( Rule_ReleaseOnAttack_P3KillaKan, 1 )
Rule_AddInterval( Rule_ReleaseOnAttack_P2KillaKan, 1 )
Rule_AddInterval( Rule_PlayerWins, 1 )
Rule_AddInterval( Rule_PlayerLoses, 1 )
Util_Autosave( "$241050" )
Rule_Remove(Rule_InitAfterNIS)
end
end
-- call this with an interval to ensure the mission ends 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
-- RESEARCH FUNCS
-- Disables, enables, and grants research items function SetResearchLevel( resLevel ) 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
--OPTIMIZATIONS
-- these functions are just here for optimization
-- this is just a temp function that is called once per second to reduce the number of times Player_GetSquads is called -- eventually Player_GetSquads wont be so slow, but as of now, it is. function Rule_UpdatePlayerSGroups() -- look up table indexed by player id g_PlayerSGroups = {} g_PlayerSGroups[Player_GetID(World_GetPlayerAt(0))] = Player_GetSquads( World_GetPlayerAt( 0 ) ) g_PlayerSGroups[Player_GetID(World_GetPlayerAt(1))] = Player_GetSquads( World_GetPlayerAt( 1 ) ) g_PlayerSGroups[Player_GetID(World_GetPlayerAt(2))] = Player_GetSquads( World_GetPlayerAt( 2 ) ) g_PlayerSGroups[Player_GetID(World_GetPlayerAt(3))] = Player_GetSquads( World_GetPlayerAt( 3 ) ) g_PlayerSGroups[Player_GetID(World_GetPlayerAt(4))] = Player_GetSquads( World_GetPlayerAt( 4 ) ) g_PlayerSGroups[Player_GetID(World_GetPlayerAt(5))] = Player_GetSquads( World_GetPlayerAt( 5 ) ) end
function Custom_Player_AreSquadsNearMarker( player, markername, checkinf )
local sgroup = g_PlayerSGroups[ Player_GetID( player ) ]
-- call Player_GetSquads if sgroup is not in look up table
if( sgroup == nil ) then
sgroup = Player_GetSquads( player )
end
if checkinf then
-- create a temp group containing everyone but the infiltrated units
local temp = SGroup_CreateIfNotFound( "custom_player_aresquadsnearmkr" )
SGroup_Clear( temp )
local IsInfil = function( groupid, idx, id )
if not Squad_IsInfiltrated( id ) then
-- add to temp group
SGroup_Add( temp, id )
end
end
SGroup_ForEach( sgroup, IsInfil )
return Prox_AnySquadNearMarker( SGroup_GetName( temp ), markername )
end
return Prox_AnySquadNearMarker( SGroup_GetName( sgroup ), markername )
end
-- AI
-- this section has all functions regarding to AI
function SetupAI()
Cpu_EnableAll(false)
Cmd_SetStance( "sg_SecondOrksStormboyz_1", STANCE_Burn )
Cmd_SetStance( "sg_SecondOrksStormboyz_2", STANCE_Burn )
Cmd_SetStance( "sg_SecondOrksStormboyz_3", STANCE_Burn )
end
function Rule_ReleaseOnAttack_BigMek() if SGroup_GetAvgHealth( "sg_Player3BigMek" ) < 1 then Cpu_UnlockSGroupAcrossPlayers( "sg_Player3BigMek" ) Rule_Remove( Rule_ReleaseOnAttack_BigMek ) end end
function Rule_ReleaseOnAttack_Warboss() if SGroup_GetAvgHealth( "sg_OrkWarboss" ) < 1 then Cpu_UnlockSGroupAcrossPlayers( "sg_OrkWarboss" ) Rule_Remove( Rule_ReleaseOnAttack_Warboss ) end end
function Rule_ReleaseOnAttack_Squiggoth() if SGroup_GetAvgHealth( "sg_NIS01_Squiggoth" ) < 1 then Cpu_UnlockSGroupAcrossPlayers( "sg_NIS01_Squiggoth" ) Rule_Remove( Rule_ReleaseOnAttack_Squiggoth ) end end
function Rule_ReleaseOnAttack_Wartraks() if SGroup_GetAvgHealth( "sg_NIS01_WartraksMovingToPosition" ) < 1 then Cpu_UnlockSGroupAcrossPlayers( "sg_NIS01_WartraksMovingToPosition" ) Rule_Remove( Rule_ReleaseOnAttack_Wartraks ) end end
function Rule_ReleaseOnAttack_P3KillaKan() if SGroup_GetAvgHealth( "sg_P3_KillaKans" ) < 1 then Cpu_UnlockSGroupAcrossPlayers( "sg_P3_KillaKans" ) Rule_Remove( Rule_ReleaseOnAttack_P3KillaKan ) end end
function Rule_ReleaseOnAttack_P2KillaKan() if SGroup_GetAvgHealth( "sh_P2_KillaKan" ) < 1 then Cpu_UnlockSGroupAcrossPlayers( "sh_P2_KillaKan" ) Rule_Remove( Rule_ReleaseOnAttack_P2KillaKan ) end end
function Rule_BaseCreatedTurnOnAI() if EGroup_GetAvgHealth("eg_PlayersHQ") >= 0.9 or EGroup_GetAvgHealth("eg_PlayersChapel") >= 0.9 or Player_AreSquadsNearMarker( g_Player1, "mk_PlayerEnteredAI" ) then if g_aienabled == 0 then EnableAI() end
Rule_Remove(Rule_BaseCreatedTurnOnAI)
Rule_AddInterval( Rule_PlayerAtCornerBeginAttack, 1 )
end
end
function EnableAI()
g_aienabled = 1
Cpu_EnableAll(true)
Cpu_Enable(g_Player5, false)
Cpu_LockSGroupAcrossPlayers( "sg_SecondOrksStormboyz_1" )
Cpu_LockSGroupAcrossPlayers( "sg_SecondOrksStormboyz_2" )
Cpu_LockSGroupAcrossPlayers( "sg_SecondOrksStormboyz_3" )
Cpu_LockSGroupAcrossPlayers( "sg_ShootaBoyzInCover" )
Cpu_LockSGroupAcrossPlayers( "sg_LootedTank_2" )
Cpu_LockSGroupAcrossPlayers( "sg_LootedTank_4" )
Cpu_LockSGroupAcrossPlayers( "sg_Player3BigMek" )
Cpu_LockSGroupAcrossPlayers( "sg_P3_KillaKans" )
Cpu_LockSGroupAcrossPlayers( "sh_P2_KillaKan" )
Cpu_LockSGroupAcrossPlayers( "sg_OrkWarboss" )
Cpu_LockSGroupAcrossPlayers( "sg_NIS01_AllObjects" )
Player_RestrictSquad( g_Player2, "ork_squad_trukk" )
Player_RestrictSquad( g_Player2, "ork_squad_warboss" )
Player_RestrictSquad( g_Player2, "ork_squad_mek_boy" )
Player_RestrictSquad( g_Player3, "ork_squad_warboss" )
Player_RestrictSquad( g_Player3, "ork_squad_trukk" )
Cpu_EnableComponent( g_Player3, false, CT_Attacking )
end
function Rule_PlayerAtCornerBeginAttack() if Player_AreSquadsNearMarker( g_Player1, "mk_StartAIAttacking" ) then Cpu_EnableComponent( g_Player3, true, CT_Attacking ) Rule_Remove( Rule_PlayerAtCornerBeginAttack ) end end
-- CHARACTERS
-- this section keeps track of the characters, and controls losing when they die. function Rule_TrackCharacters() 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" ) 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_SetDifficulty( g_Player3, AD_Easy )
-- medium
elseif difficultyLevel == DIFFICULTY_NORMAL then
Cpu_SetDifficulty( g_Player2, AD_Standard )
Cpu_SetDifficulty( g_Player3, AD_Standard )
-- hard
elseif difficultyLevel == DIFFICULTY_HARD then
Cpu_SetDifficulty( g_Player2, AD_Hard )
Cpu_SetDifficulty( g_Player3, AD_Standard )
end
end
-- MUSIC/SOUND
function SetupMusicPlaylist()
-- clear the current playlist
Sound_PlaylistClear( PC_Music )
-- add tracks to the playlist
Sound_PlaylistAddTrack( PC_Music, "music_ork_theme" )
Sound_PlaylistAddTrack( PC_Music, "music_invasion_theme" )
Sound_PlaylistAddTrack( PC_Music, "music_force_commander_theme" )
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_wind" )
-- 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
function PrecacheNISSpeech() W40k_CacheSpeech( 253000, 253042 ) end
-- KILL ORKAMUNGUS
-- quite simple, go ahead and destroy the big freakin warboss!
function Rule_AttackBuilding_2() if EGroup_Count("eg_OrkBaseBuilding_1") == 0 then Cmd_AttackEGroup("sg_NIS_Whirlwind_1", "eg_OrkBaseBuilding_2" ) Cmd_AttackEGroup("sg_NIS_Whirlwind_2", "eg_OrkBaseBuilding_2" ) Cmd_AttackEGroup("sg_NIS_Whirlwind_3", "eg_OrkBaseBuilding_2" ) Rule_Remove(Rule_AttackBuilding_2) end end
function Rule_AttackBuilding_3() if EGroup_Count("eg_OrkBaseBuilding_2") == 0 then Cmd_AttackEGroup("sg_NIS_Whirlwind_1", "eg_OrkBaseBuilding_3" ) Cmd_AttackEGroup("sg_NIS_Whirlwind_2", "eg_OrkBaseBuilding_3" ) Cmd_AttackEGroup("sg_NIS_Whirlwind_3", "eg_OrkBaseBuilding_3" ) Rule_Remove(Rule_AttackBuilding_3) end end
function Rule_AttackBuilding_4() if EGroup_Count("eg_OrkBaseBuilding_3") == 0 then Cmd_AttackEGroup("sg_NIS_Whirlwind_1", "eg_OrkBaseBuilding_4" ) Cmd_AttackEGroup("sg_NIS_Whirlwind_2", "eg_OrkBaseBuilding_4" ) Cmd_AttackEGroup("sg_NIS_Whirlwind_3", "eg_OrkBaseBuilding_4" ) Rule_Remove(Rule_AttackBuilding_4) end end
function Rule_AttackBuilding_5() if EGroup_Count("eg_OrkBaseBuilding_4") == 0 then Cmd_AttackEGroup("sg_NIS_Whirlwind_1", "eg_OrkBaseBuilding_5" ) Cmd_AttackEGroup("sg_NIS_Whirlwind_2", "eg_OrkBaseBuilding_5" ) Cmd_AttackEGroup("sg_NIS_Whirlwind_3", "eg_OrkBaseBuilding_5" ) Rule_Remove(Rule_AttackBuilding_5) end end
function Rule_WhirlwindsLeaveWhenBuildingsGone() if EGroup_Count("eg_OrkBuildingsAtStart" ) == 0 then World_EnablePlayerToPlayerFOW(g_Player1, g_Player5, 1) SGroup_SetPlayerOwner("sg_PlayersWhirlwinds", g_Player5 ) Cmd_MoveToMarker("sg_PlayersWhirlwinds","mk_NIS01_WhirlwindMove_1" ) Rule_Remove(Rule_WhirlwindsLeaveWhenBuildingsGone) end end
function Rule_SquiggothRampages() if Custom_Player_AreSquadsNearMarker( g_Player1, "mk_PlayerOnBridge", true ) then
Cmd_RampageMarker( "sg_NIS01_Squiggoth", "mk_SquiggRampageTo" )
Rule_Add(Rule_SquiggothSighted)
-- turn on orkamungus
Rule_AddInterval( Rule_OrkamungusAttacks, 20 )
Rule_Remove( Rule_SquiggothRampages )
end
end
function Rule_SquiggothSighted() if Player_CanSeeSGroup( g_Player1, "sg_NIS01_Squiggoth", 0 ) then Util_StartIntel( EVENTS.IE_Squiggoth ) Rule_Remove( Rule_SquiggothSighted ) end end
-- orkamungus is "dead" -- all of his buildings are gone as well function Rule_OrkamungusDead()
if SGroup_Count( SGroup_FromName("sg_OrkWarboss")) == 0 and
Player_HasBuildingsExcept( g_Player2, g_orkbuildling_exceptions ) == false and
Event_IsAnyRunning() == false then
Util_ObjectiveComplete( OBJ_PRIMARY_KILLWARBOSS.title_id )
Util_Ping_Stop("PING_KILLWARBOSS")
Rule_Remove(Rule_OrkamungusDead)
g_objectivescompleted = g_objectivescompleted + 1
end
end
function Rule_PlayerWins() if g_objectivescompleted == 2 then Rule_AddInterval( Rule_StartFinalNIS, 3 ) Rule_Remove( Rule_PlayerWins ) end end
function Rule_StartFinalNIS() Util_StartNIS( EVENTS.NIS_Closing ) Rule_Remove(Rule_StartFinalNIS) Rule_RemoveAll() Rule_Add( Rule_ClosingNISIsFinished ) end
-- orkamungus is "dead"f function Rule_ClosingNISIsFinished() if Event_IsRunning( EVENTS.NIS_Closing ) == false then
World_SetTeamWin(g_Player1,"")
Rule_AddIntervalEx(Rule_GameOver,5,1)
Rule_Remove(Rule_ClosingNISIsFinished)
end
end
-- logic for controlling orkamungus
-- orkamungus needs to run out and attack when his health is high enough function Rule_OrkamungusAttacks() if SGroup_GetAvgHealth( "sg_OrkWarboss" ) > 0.95 then
if SGroup_Count( SGroup_FromName( "sg_ForceCommander" ) ) > 0 then
-- attack to force commanders position
Cmd_AttackMovePos( "sg_OrkWarboss", SGroup_GetPosition( SGroup_FromName( "sg_ForceCommander" ) ) )
elseif SGroup_Count( SGroup_FromName( "sg_Librarian" ) ) > 0 then
-- else atatck to librarians position
Cmd_AttackMovePos( "sg_OrkWarboss", SGroup_GetPosition( SGroup_FromName( "sg_Librarian" ) ) )
else
-- otherwise just atatck move to players base
Cmd_AttackMoveMarker( "sg_OrkWarboss", "mk_PlayerStartingBaseLocation" )
end
-- now start checking for run away
Rule_AddInterval( Rule_OrkamungusRetreats, 1 )
Rule_Remove(Rule_OrkamungusAttacks)
end
end
-- when orkamungus health is too low he runs back function Rule_OrkamungusRetreats() if SGroup_GetAvgHealth( "sg_OrkWarboss" ) < 0.5 then Cmd_MoveToMarker( "sg_OrkWarboss", "mk_Ping_Warboss" ) -- now start checking for attack Rule_AddInterval( Rule_OrkamungusAttacks, 1 ) Rule_Remove(Rule_OrkamungusRetreats) end end
-- ESTABLISH BASE
-- player must wipe out the orks at the bottom of the map and establish a base there
-- tell player to clear out orks and establish the base function Rule_EstablishBase() if Event_IsRunning( EVENTS.NIS_Opening ) == false then
-- stop Looted tanks from moving about
Cmd_SetStance("sg_LootedTank_2", STANCE_StandGround )
Cmd_SetStance("sg_LootedTank_4", STANCE_StandGround )
Util_ObjectiveCreate( OBJ_PRIMARY_KILLWARBOSS, true )
Util_Ping_LoopingMkr("PING_KILLWARBOSS", "mk_Ping_Warboss")
Util_ObjectiveCreate( OBJ_PRIMARY_ESTABLISHBASE, true )
Util_Ping_LoopingMkr("PING_ESTABLISHBASE", "mk_Ping_EstablishBase")
Rule_AddInterval( Rule_CreateMoreOrks, 1 )
Rule_AddInterval( Rule_GrotsRepairStructures, 1 )
Rule_Add(Rule_OrksAttackMarines)
Rule_Add( Rule_OrksDeadCreateBase )
Rule_Add(Rule_PlayerGoneTooFar)
Rule_Remove(Rule_EstablishBase)
end
end
-- if there is still some boyz huts, create some more Orks from it function Rule_CreateMoreOrks() boyzHutArray = {} if ( SGroup_Count("sg_OrksAtStart") <= 1 ) then if EGroup_Count( "eg_BoyzHut_1" ) > 0 then Util_CreateSquadsAtPositionEx( g_Player4, "sg_OrksAtStart", "ork_squad_slugga", EGroup_GetPosition("eg_BoyzHut_1"), 1, 10 ) elseif EGroup_Count( "eg_BoyzHut_2" ) > 0 then Util_CreateSquadsAtPositionEx( g_Player4, "sg_OrksAtStart", "ork_squad_slugga", EGroup_GetPosition("eg_BoyzHut_2"), 1, 10 ) else Rule_Remove(Rule_CreateMoreOrks) end end end
-- get the grots repairing structures that take damage, funny cause it makes them fly more :) function Rule_GrotsRepairStructures() if (SGroup_Count( "sg_GrotsAtStart" ) >= 1 ) then if ( EGroup_GetAvgHealth( "eg_BoyzHut_1" ) < 1 ) then Command_SquadEntity( g_Player4, "sg_GrotsAtStart", SCMD_Repair, "eg_BoyzHut_1" ) end if ( EGroup_GetAvgHealth( "eg_BoyzHut_2" ) < 1 ) then Command_SquadEntity( g_Player4, "sg_GrotsAtStart", SCMD_Repair, "eg_BoyzHut_2" ) end else Rule_Remove( Rule_GrotsRepairStructures ) end end
-- regardless of artillery, when the assault marines come in the orks go haywire function Rule_OrksAttackMarines()
if ( Player_AreSquadsNearMarker( g_Player1, "mk_SpawnPlayersHQ" ) ) then
orksFallingBack = 0
Cmd_AttackSGroup("sg_OrksAtStart", "sg_PlayersAssaultMarinesAtStart" )
Rule_Remove(Rule_OrksAttackMarines)
end
end
-- once all the orks and their buildings are destroyed, create the HQ function Rule_OrksDeadCreateBase()
if SGroup_Count( Player_GetSquads( g_Player4 ) ) == 0 and EGroup_Count( Player_GetEntities( g_Player4 ) ) == 0 then
-- spawn a new base for the player
Util_CreateSquadsAndDropPodIn( g_Player1, "sg_PlayersServitor", "space_marine_squad_servitor", Marker_GetPosition(Marker_FromName("mk_SpawnServitors", "basic_marker")), 2, 1 )
Util_CreateSquadsAndDropPodIn( g_Player1, "sg_ForceCommander", "space_marine_squad_force_commander", Marker_GetPosition(Marker_FromName("mk_ForceCommanderDropPodIn_Start", "basic_marker")), 1, 1 )
Util_CreateSquadsAndDropPodIn( g_Player1, "sg_Librarian", "space_marine_squad_librarian", Marker_GetPosition(Marker_FromName("mk_LibrarianDropPodIn_Start", "basic_marker")), 1, 1 )
Rule_AddInterval(Rule_TrackCharacters,10)
Rule_AddOneShot(Rule_BaseCreation, 5 )
Rule_AddInterval(Rule_BaseCreatedTurnOnAI, 1 )
if Rule_Exists(Rule_PlayerGoneTooFar) then Rule_Remove(Rule_PlayerGoneTooFar) end
-- change the ownership of the whirlwinds at the start of the mission (up on hill)
SGroup_SetPlayerOwner("sg_PlayersWhirlwinds", g_Player5 )
Cmd_MoveToMarker("sg_PlayersWhirlwinds","mk_NIS01_WhirlwindMove_1" )
Rule_AddInterval( Rule_RemoveWhirlwinds, 10 )
Util_ObjectiveComplete( OBJ_PRIMARY_ESTABLISHBASE.title_id )
Util_Ping_Stop("PING_ESTABLISHBASE")
Rule_Remove( Rule_OrksDeadCreateBase )
Rule_AddInterval(Rule_DestroySecondOrks, 1)
--~ Rule_AddInterval( Rule_PlayerLoses, 1 )
end
end
function Rule_RemoveWhirlwinds() World_EnablePlayerToPlayerFOW(g_Player1, g_Player5, 1) SGroup_DeSpawn("sg_PlayersWhirlwinds") Rule_Remove(Rule_RemoveWhirlwinds) end
function Rule_BaseCreation() EGroup_ReSpawn("eg_PlayersHQ") Util_ResetAndRebuild( "eg_PlayersHQ", "sg_PlayersServitor" )
EGroup_ReSpawn("eg_PlayersChapel")
EGroup_ResetConstructionState("eg_PlayersChapel")
EGroup_ReSpawn("eg_PlayersArmoury")
EGroup_ResetConstructionState("eg_PlayersArmoury")
EGroup_ReSpawn("eg_PlayersGenerator")
EGroup_ResetConstructionState("eg_PlayersGenerator")
end
-- you cheating bastard, youve moved ahead, now your gonna have to pay function Rule_PlayerGoneTooFar() if Player_AreSquadsNearMarker( g_Player1, "mk_PlayerGoneTooFar" ) or Player_AreSquadsNearMarker( g_Player1, "mk_StartAIAttacking" ) or Player_AreSquadsNearMarker( g_Player1, "mk_SecondBase" ) then
if g_aienabled == 0 then
EnableAI()
end
Rule_Remove(Rule_PlayerGoneTooFar)
end
end
-- DESTROY SECOND ORKS
-- Theres another ork base between the player and orkamungus. player must destroy them
function Rule_DestroySecondOrks() if Objective_GetState( OBJ_PRIMARY_ESTABLISHBASE.title_id ) == OS_Complete and Event_IsAnyRunning() == false then
EGroup_SetAvgHealth( "eg_BustedBridges", 0 )
Util_StartIntel( EVENTS.IE_MoreOrks )
Rule_AddInterval(Rule_LootedTanksAttackGround,1)
Rule_AddIntervalEx( Rule_SecondStormBoyzAttack_1, 120, 1 )
Rule_AddIntervalEx( Rule_SecondStormBoyzAttack_2, 320, 1 )
Rule_AddInterval( Rule_SecondStormBoyzAttack_3, 1 )
Rule_Add(Rule_DestroySecondOrks_Save)
Rule_AddInterval(Rule_PlayerCompletedHQ,1)
Rule_AddInterval( Rule_PlayerCompletedHQAddon, 1 )
Rule_AddInterval(Rule_PlayerCompletedMachineCult,1)
Rule_AddInterval( Rule_PlayerCompletedChapel, 1 )
--~ Rule_AddInterval(Rule_BaseCreatedTurnOnAI,1)
Rule_Remove(Rule_DestroySecondOrks)
end
end
function Rule_DestroySecondOrks_Save() if not Event_IsRunning( EVENTS.IE_MoreOrks ) then
Util_ObjectiveCreate( OBJ_PRIMARY_DESTROYSECONDORKS, true )
Rule_Add(Rule_SecondOrksDestroyed)
Util_Ping_LoopingMkr("PING_SECONDORKS", "mk_Ping_SecondOrks")
Rule_Remove(Rule_DestroySecondOrks_Save)
Util_Autosave("$241054")
end
end
-- after awhile, jump in some stormboyz to attack players base function Rule_SecondStormBoyzAttack_1() Cmd_JumpToMarker( "sg_SecondOrksStormboyz_1", "mk_SecondStormBoyzJumpToPoint" ) end
-- after a bit longer, jump in some more stormboyz to attack players base function Rule_SecondStormBoyzAttack_2() Cmd_JumpToMarker( "sg_SecondOrksStormboyz_2", "mk_SecondStormBoyzJumpToPoint" ) end
function Rule_SecondStormBoyzAttack_3() if Player_AreSquadsNearMarker( g_Player1, "mk_TriggerStormBoyz_3" ) then Cmd_JumpToMarker( "sg_SecondOrksStormboyz_3", "mk_StormBoyzJump_3" ) Rule_Remove(Rule_SecondStormBoyzAttack_3) end end
-- start the looted tanks attacking the path the player must take function Rule_LootedTanksAttackGround() if Player_AreSquadsNearMarker( g_Player1, "mk_LootedTankAttack_2" ) then Cmd_AttackGroundMarker( "sg_LootedTank_2", "mk_LootedTankAttack_2" ) end if Player_AreSquadsNearMarker( g_Player1, "mk_LootedTankAttack_4" ) then Cmd_AttackGroundMarker( "sg_LootedTank_4", "mk_LootedTankAttack_4" ) end Rule_Remove(Rule_LootedTanksAttackGround) end
-- if player has destroyed the second orks HQ function Rule_SecondOrksDestroyed() if EGroup_Count( "eg_SecondOrkHQ" ) == 0 then
Util_ObjectiveComplete( OBJ_PRIMARY_DESTROYSECONDORKS.title_id )
Util_Ping_Stop("PING_SECONDORKS")
g_objectivescompleted = g_objectivescompleted + 1
Rule_Add(Rule_BlowUpBridges)
Rule_Remove( Rule_SecondOrksDestroyed )
Util_Autosave( "$241056" )
end
end
-- once the player has completed the HQ we tell them they can build the Machine Cult function MS04_AddonIsDone(addonname, boolean) EGroup_AddGroup(EGroup_CreateIfNotFound("eg_Player1All"), Player_GetEntities(g_Player1)) if not EGroup_IsEmpty("eg_Player1All") then if EGroup_ContainsAddOn("eg_Player1All", addonname, false) == boolean then return true end end end
function Rule_PlayerCompletedHQAddon() if MS04_AddonIsDone("space_marine_hq_addon_1", true) and not Event_IsAnyRunning() then Unrestrict_BuildingWithAlerts( g_Player1, "space_marine_vehicle_building", "$42956", 408052 ) Unrestrict_ResearchWithAlerts( g_Player1, "support_cap_research_2", "none", "none" ) Rule_Remove(Rule_PlayerCompletedHQAddon) end end
function Rule_PlayerCompletedHQ() if Player_HasBuildingType( g_Player1, "space_marine_hq" ) then Modifier_Remove( g_modifier_hqconstructionspeed ) Rule_Remove(Rule_PlayerCompletedHQ) end end
-- once the player has completed a machine cult let them know about the whirlwinds function Rule_PlayerCompletedMachineCult() if Player_HasBuildingType( g_Player1, "space_marine_vehicle_building" ) and not Event_IsAnyRunning() then Unrestrict_SquadWithAlerts( g_Player1, "space_marine_squad_whirlwind", "$42926", 408020 ) Rule_Remove(Rule_PlayerCompletedMachineCult) end end
-- once the player has completed the chapel we tell them they can build the Machine Cult function Rule_PlayerCompletedChapel() --~ if (EGroup_ForEach( EGroup_FromName("eg_PlayersChapel"), function( egroupid, itemindex, entityID ) return Entity_GetBuildingProgress( entityID ) end ) ) == 1 then if Player_HasBuildingType( g_Player1, "space_marine_armoury" ) and Player_HasBuildingType( g_Player1, "space_marine_barracks" ) and not Event_IsAnyRunning() then Unrestrict_SquadWithAlerts( g_Player1, "space_marine_squad_assault", "$42908", 408006 ) Rule_Remove(Rule_PlayerCompletedChapel) end end
-- FIND ANOTHER PATH
function Rule_BlowUpBridges() -- when the player is close enough, bridges explode if Objective_GetState(OBJ_PRIMARY_DESTROYSECONDORKS.title_id) == OS_Complete then
Util_StartIntel( EVENTS.IE_TakingDownBridges )
Rule_Remove(Rule_BlowUpBridges)
Rule_Add(Rule_BlowUpBridges_Save)
end
end
function Rule_BlowUpBridges_Save() if not Event_IsRunning( EVENTS.IE_TakingDownBridges ) then
Util_ObjectiveCreate( OBJ_SECONDARY_ESTABLISHSECONDBASE, false )
Rule_Add(Rule_PlayerHasEstablishedSecondaryBase)
Rule_AddInterval(Rule_CanSeePowerSpot, 2 )
Rule_Remove(Rule_BlowUpBridges_Save)
end
end
function Rule_CanSeePowerSpot() if Player_CanSeeEGroup( g_Player1, "eg_PowerSpot", false ) and not Event_IsAnyRunning() then Unrestrict_BuildingWithAlerts( g_Player1, "space_marine_thermo_generator", "$42964", 408060 ) Rule_Remove( Rule_CanSeePowerSpot ) end end
-- player has found the alternate bridge function Rule_PlayerFoundPath() if Player_CanSeePosition( g_Player1, Marker_GetPosition( Marker_FromName("mk_AlternatePath", "basic_marker") ) ) then
Util_Autosave( "$241058" )
Util_ObjectiveComplete( OBJ_SECONDARY_FINDANOTHERPATH.title_id )
Util_Ping_Stop("PING_ANOTHERPATH")
Rule_Remove(Rule_PlayerFoundPath)
end
end
-- ESTABLISH SECOND BASE
-- its recommended that the player establish a secondary base closer to the warboss -- we do this once the bridges have blown up
-- if the player has a second HQ then they succeed this objective function Rule_PlayerHasEstablishedSecondaryBase() EGroup_AddGroup(EGroup_CreateIfNotFound("eg_Player1All"), Player_GetEntities(g_Player1)) if MS04_EGBlueprintCount("eg_Player1All", "space_marine_hq", 2, true ) then
Util_ObjectiveComplete( OBJ_SECONDARY_ESTABLISHSECONDBASE.title_id )
Rule_Remove(Rule_PlayerHasEstablishedSecondaryBase)
Util_Autosave("$241060")
end
end
--[[Blueprint counter]] function MS04_EGBlueprintCount(egroupname, blueprint, num, boolean) local blueprinttable = { { name = blueprint, count = 1 } }
local local_blueprint = blueprint
local buildingcount = 0
local Rule_CountBuilt = function( egroupid, itemindex, entityID )
if Entity_GetBlueprintName(entityID) == local_blueprint and Entity_GetBuildingProgress(entityID) == 1.0 then
buildingcount = buildingcount+1
else
return false
end
if buildingcount >= num then
return true
end
end
if EGroup_ContainsBlueprints(egroupname, blueprinttable, true) == boolean then
if EGroup_ForEach(EGroup_FromName(egroupname), Rule_CountBuilt) == boolean then
return true
end
end
end