--[[ IMPORTS ]]
import("ScarUtil.scar") import("WXPScarUtil.scar")
--[[ GAME SETUP ]]
--[[ the OnGameSetup() function is mandatory! ]] function OnGameSetup()
g_Player1 = Setup_Player(0, "$690087", "ork_race", 0) -- Player Army
Misc_PlayerTeamColor(g_Player1,"default_4")
Player_DoNotPrecache(g_Player1, _t_MSD5O_Player1)
g_Player2 = Setup_Player(1, "$690082", "guard_race", 1) -- IG Titan piece defender
Player_DoNotPrecache(g_Player2, _t_MSD5O_Player2)
g_Player3 = Setup_Player(2, "$690088", "chaos_marine_race", 2) -- Crull's forces
Misc_PlayerTeamColor(g_Player3,"default_6")
Player_DoNotPrecache(g_Player3, _t_MSD5O_Player3)
g_Player4 = Setup_Player(3, "$910016", "npc_race", 3) -- placeholder Necrons
Player_DoNotPrecache(g_Player4, _t_MSD5O_Player4)
g_Player5 = Setup_Player(4, "$910018", "guard_race", 1) -- for titan piece
Player_DoNotPrecache(g_Player5, _t_MSD5O_Player5)
g_Player6 = Setup_Player(5, "$690087", "ork_race", 0) -- "allied" team for when player loses control of units during duel
Misc_PlayerTeamColor(g_Player6,"default_4")
Player_DoNotPrecache(g_Player6, _t_MSD5O_Player6)
--[[ DEFINE VARIABLES AND TABLES - define any preset values here for later use]]
g_firstrun = true
g_crull_mad = false
g_meetflag1 = false
g_meetflag2 = false
g_meetflag3 = false
g_meetflag4 = false
t_sgroup_titan_heavy_weapon = {}
t_monolith_reached_destination = {false, false, false}
t_sgroupnecronbattlegroup = {}
t_sgroup_necron_attackers = {}
t_sgroup_necron_monolith = {}
g_reached_destination_count = 0
--g_crull_retreat_complete = false
BlueprintTable = Util_MakeBlueprintTable("ork_squad_warboss")
g_gorgutz_enabled_for_duel = false
g_crull_bodyguard_a_retreat_complete = false
g_crull_bodyguard_b_retreat_complete = false
g_squiggoth_reinforced = false
g_mek_reinforced = false
g_mek_reinforced2 = false
--g_moved = false
g_bodycount = 0
t_outposttakeoverflag = {false, false, false, false}
g_bloodthirster_triggered = false
g_bloodthirster2_triggered = false
g_regeneration_on = true
g_chaos_raider1_deployed = false
g_chaos_raider2_deployed = false
g_titan_damaged = false
g_commissar_encounter = false
g_twist_encounter = false
g_random_ig_attack_on_ork_base_started = true
g_random_ig_attack_on_Outpost_base_started = true
--[[ define the "enemy" who will win if the player 'loses' ]] g_enemy = g_Player3
g_IG_Random_Outpost_Raid_Army_iter = 1
g_IG_Random_Raid_Army_iter = 1
g_random_spawn = 0
g_random_spawn2 = 0
g_monolith_attacking = false
g_sgroup_current_ork_count = 0
g_sgroup_current_ork_count_difference = 0
g_sgroup_previous_ork_count = 0
g_ork_losses = 0
t_bodyguardID = {}
g_back_to_base = false
g_trophies_sub_objectives_completed = 0
g_warboss_dead = false
g_crull_dead = false
g_titan_weapons_damaged = false
g_playerHasWon = false
g_crull_first_time = false
g_protection_fired_off = false
t_chaos_raiders_deployed = {true, true, true}
t_player_table = {g_Player1, g_Player2, g_Player3, g_Player4, g_Player5, g_Player6, g_Player7, g_Player8}
t_ork_unit_restrictions = {"ork_squad_looted_tank","ork_squad_squiggoth", "ork_squad_stormboy", "ork_squad_warboss"}
end
--[[ the OnGameRestore() function is mandatory!, this will only get called after loading a game ]] function OnGameRestore()
--[[ here you redefine the player slots]]
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 OnLoad()
FOW_Reset()
end
Scar_AddLoad(OnLoad)
--[[ ON INITIALIZATION ]]
function OnInit()
--[[ RESEARCH LEVEL ]]
-- sets the research level of the mission, locks researches, squads, and buildings
Rule_SetResearchLevel( 4 )
--[[ NIS PRESETS ]]
-- turn off event cues, set the viewable space to black (faded out) and preset letterboxing ]]
WXP_OpeningNISPreset()
--[[ START THE MUSIC ]]
-- call the function to load the jukebox with tunes]]
Rule_SetupMusicPlaylist()
--[[ SET AI ]]
-- call the function to set the pregame state of the AI ]]
Rule_PresetAI()
--[[ START NIS ]]
-- calls the NIS function located in the MissionName.nis file ]]
Util_StartNIS( EVENTS.NIS_Opening )
--[[ GET THE START PLAY MISSION READY TO ROLL ]]
Rule_Add( Rule_GameStart )
end
--[[ the Scar_AddInit(OnInit) function is mandatory! This registers your init function with scar. ]] Scar_AddInit(OnInit)
--[[ GAME RESTRICTIONS ]]
--[[ Disables, enables, and grants research items ]] function Rule_SetResearchLevel( resLevel )
--[[ WXP Specific ]]
WXP_Restrict( resLevel )
end
--[[ MUSIC ]]
function Rule_SetupMusicPlaylist() --[[ t_music = {"music_msd5o" } Playlist_Manager( PC_Music, t_music, true , false, {20, 40})]]
t_ambient = {"Snowy_wind_1", "Warhammer_XP_battle_BG" }
Playlist_Manager( PC_Ambient, t_ambient, true , true, {5, 10})
end
--[[ PRESET AI ]]
function Rule_PresetAI()
Cpu_EnableAll(false)
end
--[[ START PLAY ]]
--[[ NOW TO KICK OFF THE ACTUAL MISSION ONCE THE OPENING NIS IS DONE ]]
function Rule_GameStart()
if g_firstrun then
--[[ SET RESOURCES ]]
Player_SetAllResources(g_Player1, 2000, 200)
--[[ PREACTION ]]
-- Use this space to add core mission functions that should be in place during the opening NIS
--[[ DIFFICULTY LEVEL ]]
-- gets the difficulty level from the UI and passes it into the function
Rule_SetDifficultyLevel( Difficulty_Get() )
--[[ Army Kickoff ]] -- Spawn armies
Rule_AddOneShot(Rule_Player_Army_Kickoff, 0)
Rule_AddInterval(Rule_Gorgutz_Track, 5)
--[[ PERSISTENT CHARACTERS ]]
-- track and replace persistent characters
--Rule_AddInterval(Rule_TrackCharacters, 1)
g_firstrun = false
elseif Event_IsAnyRunning() == false then
--[[ Get the AI doing whatever after the NIS is over ]]
Rule_StartAI()
--[[ FOW ]]
World_EnablePlayerToPlayerFOW(g_Player2, g_Player1, true)
--[[ WIN CHECK ]]
Rule_AddInterval(Rule_EndGameWin, 1)
--[[ LOSE CHECK ]]
Rule_AddInterval(Rule_EndGameLose, 1)
--[[ ASSIGN OBJECTIVES ]]
Rule_AddInterval(Rule_Objective_Trophies, 0)
--[[ GENERATE ACTION ]]
--Rule_AddOneShot(Rule_IE_OpeningNIS, 0)
Rule_AddOneShot(Rule_IE_OpeningSpeech, 4)
Rule_AddOneShot(Rule_Reveal_Pieces_Control, 0)
--Rule_AddInterval(Rule_Commissar_Encounter, 2)
Rule_AddInterval(Rule_Lost_Boyz, 2)
Rule_AddInterval(Rule_Piece_Health_Check, 3) -- checks health of titan pieces
Rule_AddIntervalDelay(Rule_IG_Outpost_Track, 30, 1)
Rule_AddIntervalDelay(Rule_IG_Piece_Defender_Track, 15, 2)
Rule_AddIntervalDelay(Rule_IG_Anti_Chaos_Track, 15, 3) --2
Rule_AddIntervalDelay(Rule_Anti_Turtle_Attack, 120, 1680) -- launches anti-turtle attack at 30 mins
Rule_AddIntervalDelay(Rule_Random_IG_Attack_On_Ork_Base_Control_Kickoff, 20, 30) -- 30, 20
Rule_AddOneShot(Rule_Chaos_Army_Kickoff, 0)
Rule_AddIntervalDelay(Rule_Chaos_Anti_IG_Track, 15,3) --2
Rule_AddIntervalDelay(Rule_Chaos_Anti_IG_Track_Deployed, 15, 4)
Rule_AddInterval(Rule_Raider_Reactivate, 15)
Rule_AddOneShot(Rule_Imperial_Guard_Army_Kickoff, 0)
Rule_AddInterval(Rule_Assault_Music_Activate, 2)
Rule_AddInterval(Rule_Outpost_Objective_Kickoff, 2)
Rule_Check_AddInterval(Rule_Crull_Gorgutz_Proximity, 2)
--[[ AUTOSAVE AFTER NIS ]]
Rule_Add(Rule_Autosave_MissionStart)
-- Use this space to add all core mission functions
--[[ Clean up ]]
Rule_Remove(Rule_GameStart)
end
end
--[[ DIFFICULTY ]]
function Rule_SetDifficultyLevel( difficultyLevel )
--[[ STATIC MODIFIERS ]]
-- Use this space to set any Static Modifiers. Modifiers that will not change with the difficulty setting.
--Difficulty_SetForAll( difficultyLevel )
Difficulty_SetForPlayer( g_Player2, difficultyLevel )
Difficulty_SetForPlayer( g_Player3, difficultyLevel )
Difficulty_SetForPlayer( g_Player4, difficultyLevel )
Difficulty_SetForPlayer( g_Player5, difficultyLevel )
Difficulty_SetForPlayer( g_Player6, difficultyLevel )
--[[ DIFFICULTY GENERAL RULES ]]
--[[ Types of things that can me done include:
a) adding resource values
b) changing variables for the number of starting units a player recieves
b) or even activating new objectives (although we refrained from this in DoW as the increased testing requirements it dictates)
]]
-- easy
if difficultyLevel == DIFFICULTY_EASY then
--Cpu_SetDifficulty( g_Player2, AD_Standard )
-- medium
elseif difficultyLevel == DIFFICULTY_NORMAL then
-- hard
elseif difficultyLevel == DIFFICULTY_HARD then
end
end
--[[ AI ]]
function Rule_StartAI()
-- Cpu_EnableAll(false)
end
--[[ TRACK PERSISTENT CHARACTERS ]]
-- this section keeps track of the characters, and controls losing when they die. function Rule_TrackCharacters() --[[ if SGroup_Exists("sg_leader") then Util_TrackCharacterAndDropPodIn( g_Player1, "sg_leader", "chaos_squad_sorcerer", "mkr_summon" ) end ]] end
--[[ CORE GAME ]]
function Rule_Timer() g_time = g_time + 1 end
function Rule_Player_Army_Kickoff() -- Kicks off Player's Ork Army
Player_RestrictSquadList(g_Player1, t_ork_unit_restrictions)
-- defines initial warboss characteristics
local mod_gorgutzarmourincrease = Modifier_Create(MAT_EntityType, "armour_modifier", MUT_Multiplication, false, 4.5, "ork_warboss")
g_mod_gorgutzarmourincrease = Modifier_ApplyToPlayer( mod_gorgutzarmourincrease, g_Player1)
local mod_gorgutzhealthincrease = Modifier_Create(MAT_EntityType, "health_maximum_modifier", MUT_Multiplication, false, 4, "ork_warboss")
g_mod_gorgutzhealthincrease = Modifier_ApplyToPlayer( mod_gorgutzarmourincrease, g_Player1 )
-- defines warboss characteristics for the duel phase (after playerswitch mechanic is used)
local mod_gorgutzarmourincrease = Modifier_Create(MAT_EntityType, "armour_modifier", MUT_Multiplication, false, 4.5, "ork_warboss")
g_mod_gorgutzarmourincrease = Modifier_ApplyToPlayer( mod_gorgutzarmourincrease, g_Player6)
local mod_gorgutzhealthincrease = Modifier_Create(MAT_EntityType, "health_maximum_modifier", MUT_Multiplication, false, 4, "ork_warboss")
g_mod_gorgutzhealthincrease = Modifier_ApplyToPlayer( mod_gorgutzarmourincrease, g_Player6 )
Player_RestrictSquad(g_Player1, "ork_squad_stormboy")
end
--[[ Tracks Gorgutz ]]
function Rule_Gorgutz_Track()
local blueprinttable = Util_MakeBlueprintTable("ork_squad_warboss")
--[[ check to see if the group is empty AND if the boolean has been returned to false - this prevents duplicate rule adds ]]
if g_gorgutzreturn ~= true and SGroup_Exists("sg_gorgutz") and ( SGroup_IsEmpty("sg_gorgutz") or SGroup_ContainsBlueprints( "sg_gorgutz", blueprinttable, false) == false) then
--[[ prevents duplicate rule adds ]]
g_gorgutzreturn = true
--[[ 6 second delay, keeps it from being instantaneous ]]
Rule_AddOneShot(Rule_Gorgutz_Return, 6)
end
end
function Rule_Gorgutz_Return()
--[[ recreate the unit ]]
g_gorgutz_sgroupID = Util_CreateSquadsAtMarker(g_Player1, "sg_gorgutz", "ork_squad_warboss", "mkr_ork_start", 1)
--[[ play the fx ]]
World_FXEventSquad("data:Art/Events/Unit_Upgrade_Morale_FX/Reinforce_Trooper", SGroup_FromName("sg_gorgutz"))
--[[ reset the flag ]]
g_gorgutzreturn = false
--[[ if no messages have played recently, play the Intel Event - this keeps messages from flooding the player ]]
if Event_TimeSinceLast() > 10 then
local l_random_line_spoken = World_GetRand(1, 2)
if l_random_line_spoken == 1 then
Rule_AddOneShot(Rule_IE_Gorgutz_Returns, 0)
elseif l_random_line_spoken == 2 then
Rule_AddOneShot(Rule_IE_Gorgutz_Returns2, 0)
end
end
EventCue_DoEvent( "recruit_commander", "/Races/Shared/Upgrade_weapon", "$42890", "$42892" )
end
--[[Kicks off IG defenders -- Use FOR loops in the final mission draft]] function Rule_Imperial_Guard_Army_Kickoff()
FOW_RevealMarker("mkr_outpost2", 61)
FOW_RevealMarker("mkr_outpost3", 61)
EGroup_SetPlayerOwner("eg_titan_pieces_a", g_Player2)
-- gives ownership of 1 weapon to crull who "owns" it but can't use it. This was needed so that his troops wouldn't attack the weapon when they walked by, due to its placement
EGroup_SetPlayerOwner("eg_titan_piece3", g_Player3)
Player_GrantResearch(g_Player2, "guard_enable_leader_accuracy_bonus" )
Player_GrantResearch(g_Player2, "guard_guardsman_morale" )
Player_GrantResearch(g_Player2, "guard_upgrade_guardsmen_health" )
--Player_GrantResearch(g_Player2, "guard_upgrade_guardsmen_range" )
Player_GrantResearch(g_Player2, "guard_upgrade_ogryn_melee" )
Player_GrantResearch(g_Player2, "guard_upgrade_garrisoned_shoot" )
Util_CreateSquadsAtMarker(g_Player2, "sg_commissar", "guard_squad_commissar", "mkr_commissar", 1)
Util_CreateSquadsAtMarkerEx(g_Player2, "sg_executed_guardsman", "guard_squad_guardsmen", "mkr_executed_guardsman", 1,1)
for i = 1,3 do
Util_CreateSquadsAtMarkerEx(g_Player2, "sg_piece_defender"..i.."c", "guard_squad_guardsmen", "mkr_piece_defender"..i, 3, 9) --1,12
SGroup_AddLeaders("sg_piece_defender"..i.."c")
Cmd_SetStance("sg_piece_defender"..i.."c", STANCE_StandGround)
Util_CreateSquadsAtMarkerEx(g_Player2, "sg_ig_trench"..i, "guard_squad_guardsmen", "mkr_imperial_perimeter"..i, 1, 9)
Cmd_SetStance("sg_ig_trench"..i, STANCE_StandGround)
Util_CreateSquadsAtMarker(g_Player2, "sg_ig_tanks"..i, "guard_squad_lemanruss", "mkr_ig_tank_spawn"..i, 2)
Cmd_SetStance("sg_ig_tanks"..i, STANCE_StandGround)
Util_CreateSquadsAtMarkerEx(g_Player2, "sg_ig_ogryn"..i, "guard_squad_ogryns", "mkr_imperial_perimeter"..i, 1, 3)
Cmd_SetStance("sg_ig_ogryn"..i, STANCE_StandGround)
Util_CreateSquadsAtMarkerEx(g_Player2, "sg_chaos_defender"..i, "guard_squad_guardsmen", "mkr_ig_counter"..i, 2, 9) -- 1,12
SGroup_AddLeaders("sg_chaos_defender"..i)
Cmd_SetStance("sg_chaos_defender"..i, STANCE_StandGround)
end
for i = 2,4 do
Util_CreateSquadsAtMarkerEx(g_Player2, "sg_outpost_defender"..i.."a", "guard_squad_guardsmen", "mkr_outpost"..i, 1, 12) -- 2,12
Util_CreateSquadsAtMarkerEx(g_Player2, "sg_outpost_defender"..i.."b", "guard_squad_kasrkin", "mkr_outpost"..i, 1, 6) --1,6
Util_CreateSquadsAtMarkerEx(g_Player2, "sg_outpost_defender"..i.."c", "guard_squad_guardsmen", "mkr_outpost"..i, 1, 6) --1,6
Util_CreateSquadsAtMarker(g_Player2, "sg_outpost_commissar"..i, "guard_squad_commissar", "mkr_outpost_commissar"..i, 1)
end
for i = 2, 4 do
Cmd_AttachSquads("sg_outpost_defender"..i.."a", "sg_outpost_commissar"..i)
end
end
--[[tracks outpost defenders and regenerates them when they are dead]] function Rule_IG_Outpost_Track() for n = 2, 3 do if EGroup_Exists("eg_outpost"..n) and EGroup_IsEmpty("eg_outpost"..n) == false then --for i = 1, 2 do --1,4 -- "for i = 1, 2 do" if SGroup_Exists("sg_outpost_defender"..n.."a") and SGroup_IsEmpty("sg_outpost_defender"..n.."a") then Util_CreateSquadsAtMarkerEx(g_Player2, "sg_outpost_defender"..n.."a", "guard_squad_guardsmen", "mkr_outpost"..n.."_infantry_spawn", 1, 12) -- 1,12 end if SGroup_Exists("sg_outpost_defender"..n.."b") and SGroup_IsEmpty("sg_outpost_defender"..n.."b") then Util_CreateSquadsAtMarkerEx(g_Player2, "sg_outpost_defender"..n.."b", "guard_squad_kasrkin", "mkr_outpost"..n.."_infantry_spawn", 1, 6) --1,6 end if SGroup_Exists("sg_outpost_defender"..n.."c") and SGroup_IsEmpty("sg_outpost_defender"..n.."c") then Util_CreateSquadsAtMarkerEx(g_Player2, "sg_outpost_defender"..n.."c", "guard_squad_guardsmen", "mkr_outpost"..n.."_infantry_spawn", 1, 6) --1,6 end --end FOW_RevealMarker("mkr_outpost"..n, 30) elseif EGroup_Exists("eg_outpost"..n) and EGroup_IsEmpty("eg_outpost"..n) == true and t_outposttakeoverflag[n] == false then Util_Ping_Stop("ping_outpost"..n) t_outposttakeoverflag[n] = true end end end
--[[tracks the IG troops protecting the pieces. If they are depleted they will be respawned]] function Rule_IG_Piece_Defender_Track() for n = 1, 3 do if EGroup_Exists("eg_barracks"..n) and EGroup_IsEmpty("eg_barracks"..n) == false then --for i = 1,3 do --2, 4 if SGroup_Exists("sg_piece_defender"..n.."c") and SGroup_IsEmpty("sg_piece_defender"..n.."c") then Util_CreateSquadsAtMarkerEx(g_Player2, "sg_piece_defender"..n.."c", "guard_squad_guardsmen", "mkr_piece_defender"..n, 2, 9) -- 1,12 SGroup_AddLeaders("sg_piece_defender"..n.."c") end if SGroup_Exists("sg_ig_ogryn"..n) and SGroup_IsEmpty("sg_ig_ogryn"..n) then Util_CreateSquadsAtMarkerEx(g_Player2, "sg_ig_ogryn"..n, "guard_squad_ogryns", "mkr_imperial_perimeter"..n, 1, 3) end --end end end end
function Rule_IG_Anti_Chaos_Track() -- IG counter to Chaos attack if EGroup_Exists("eg_barracks1") and EGroup_IsEmpty("eg_barracks1") == false then if SGroup_Exists("sg_chaos_defender1") and SGroup_IsEmpty("sg_chaos_defender1") then Util_CreateSquadsAtMarkerEx(g_Player2, "sg_chaos_defender1", "guard_squad_guardsmen", "mkr_ig_counter1", 2, 9) -- 1,12 SGroup_AddLeaders("sg_chaos_defender1") --SGroup_SetMoraleInvulnerable("sg_chaos_defender1", true ) end end if EGroup_Exists("eg_barracks2") and EGroup_IsEmpty("eg_barracks2") == false then if SGroup_Exists("sg_chaos_defender2") and SGroup_IsEmpty("sg_chaos_defender2") then Util_CreateSquadsAtMarkerEx(g_Player2, "sg_chaos_defender2", "guard_squad_guardsmen", "mkr_ig_counter2", 2, 9) -- 1,12 SGroup_AddLeaders("sg_chaos_defender2") --SGroup_SetMoraleInvulnerable("sg_chaos_defender2", true ) end end if EGroup_Exists("eg_barracks3") and EGroup_IsEmpty("eg_barracks3") == false then if SGroup_Exists("sg_chaos_defender3") and SGroup_IsEmpty("sg_chaos_defender3") then Util_CreateSquadsAtMarkerEx(g_Player2, "sg_chaos_defender3", "guard_squad_guardsmen", "mkr_ig_counter3", 2, 9) -- 1,12 SGroup_AddLeaders("sg_chaos_defender3") --SGroup_SetMoraleInvulnerable("sg_chaos_defender3", true ) end end end
--[[kicks off Rule_Random_IG_Attack_On_Ork_Base_Control()]] function Rule_Random_IG_Attack_On_Ork_Base_Control_Kickoff()
if g_random_ig_attack_on_ork_base_started == true and (SGroup_Exists("sg_random_IG_attack") == false or (SGroup_Exists("sg_random_IG_attack") and SGroup_IsEmpty("sg_random_IG_attack"))) then
local l_random_time = World_GetRand(21, 31) -- 30, 45
Rule_AddOneShot(Rule_Random_IG_Attack_On_Ork_Base_Control, l_random_time)
--g_random_ig_attack_on_ork_base_started will be made "false" after the control is started, overriding the "true" value next.
g_random_ig_attack_on_ork_base_started = false
end
if (EGroup_Exists("eg_outpost2") and EGroup_IsEmpty("eg_outpost2")) and (EGroup_Exists("eg_outpost3") and EGroup_IsEmpty("eg_outpost3")) then
Rule_AddIntervalDelay(Rule_Random_IG_Attack_On_Outpost_Base_Control_Kickoff, 20, 60)
Rule_Remove(Rule_Random_IG_Attack_On_Ork_Base_Control_Kickoff)
end
end
function Rule_Random_IG_Attack_On_Ork_Base_Control()
g_random_spawn = World_GetRand(2, 3) -- need to spawn outside of unit generation so that there is a consistant area the enemies will spawn from. 2, 3 represent outpost 2 and 3
if g_random_ig_attack_on_ork_base_started == false and (SGroup_Exists("sg_random_IG_attack") == false or (SGroup_Exists("sg_random_IG_attack") and SGroup_IsEmpty("sg_random_IG_attack"))) then
Rule_AddInterval(Rule_IG_Random_Raid, 1)
end
end
function Rule_IG_Random_Raid()
local i = g_IG_Random_Raid_Army_iter
t_IG_Random_Raid_Army = {
sgroup_name = {"sg_IG_attack_type1", "sg_IG_attack_type2"},
blueprint = {"guard_squad_guardsmen", "guard_squad_guardsmen"},
marker_spawn = {"dummy_marker", "mkr_outpost2", "mkr_outpost3"},
stance = {STANCE_Attack, STANCE_Attack},
melee_stance = {MSTANCE_Ranged, MSTANCE_Ranged},
squad_num = {1, 2},
squad_size = {10, 10},
}
--local random_type = World_GetRand(1, table.getn(t_IG_Random_Raid_Army.blueprint))
--local random_spawn = World_GetRand(1, table.getn(t_IG_Random_Raid_Army.marker_spawn))
--local random_squad_number = World_GetRand(1, 2)
--local random_squad_size = World_GetRand(4, 8)
if EGroup_Exists("eg_outpost"..g_random_spawn) and EGroup_IsEmpty("eg_outpost"..g_random_spawn) == false then -- checks to see if the production facilities exist in the first place
if g_IG_Random_Raid_Army_iter <= table.getn(t_IG_Random_Raid_Army.sgroup_name) and (SGroup_Exists(t_IG_Random_Raid_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_IG_Random_Raid_Army.sgroup_name[i])) then
local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_IG_Random_Raid_Army.sgroup_name[i], t_IG_Random_Raid_Army.blueprint[i], t_IG_Random_Raid_Army.marker_spawn[g_random_spawn], t_IG_Random_Raid_Army.squad_num[i], t_IG_Random_Raid_Army.squad_size[i]) -- t_IG_Random_Raid_Army.squad_size[World_GetRand(4, 10)]
Cmd_SetStance(t_IG_Random_Raid_Army.sgroup_name[i], t_IG_Random_Raid_Army.stance[i])
Cmd_SetMeleeStance(t_IG_Random_Raid_Army.sgroup_name[i], t_IG_Random_Raid_Army.melee_stance[i])
SGroup_AddGroup(SGroup_CreateIfNotFound("sg_random_IG_attack"), SGroup_FromName(t_IG_Random_Raid_Army.sgroup_name[i]))
elseif g_IG_Random_Raid_Army_iter > table.getn(t_IG_Random_Raid_Army.sgroup_name) then -- table.getn(t_IG_Random_Raid_Army.sgroup_name)
g_IG_Random_Raid_Army_iter = 0
if SGroup_Exists("sg_random_IG_attack") and SGroup_IsEmpty("sg_random_IG_attack") == false then
Cmd_AttackMoveMarker("sg_random_IG_attack", "mkr_ork_start")
g_random_ig_attack_on_ork_base_started = true
Rule_Remove(Rule_IG_Random_Raid)
end
end
g_IG_Random_Raid_Army_iter = g_IG_Random_Raid_Army_iter +1
elseif EGroup_Exists("eg_outpost"..g_random_spawn) and EGroup_IsEmpty("eg_outpost"..g_random_spawn) then
g_random_ig_attack_on_ork_base_started = true
Rule_Remove(Rule_IG_Random_Raid)
end
end
function Rule_Anti_Turtle_Attack()
for i = 2, 3 do
if EGroup_Exists("eg_outpost"..i) and EGroup_IsEmpty("eg_outpost"..i) == false then
Util_CreateSquadsAtMarkerEx(g_Player2, "sg_turtle_attack_outpost"..i.."a", "guard_squad_guardsmen", "mkr_outpost"..i.."_infantry_spawn", 2, 10)
Cmd_SetStance("sg_turtle_attack_outpost"..i.."a", STANCE_Burn)
Cmd_AttackMoveMarker("sg_turtle_attack_outpost"..i.."a", "mkr_ork_start")
Util_CreateSquadsAtMarkerEx(g_Player2, "sg_turtle_attack_outpost"..i.."b", "guard_squad_ogryns", "mkr_outpost"..i.."_infantry_spawn_b", 1, 8)
Cmd_SetStance("sg_turtle_attack_outpost"..i.."b", STANCE_Burn)
Cmd_AttackMoveMarker("sg_turtle_attack_outpost"..i.."b", "mkr_ork_start")
Util_CreateSquadsAtMarkerEx(g_Player2, "sg_turtle_attack_outpost"..i.."c", "guard_squad_kasrkin", "mkr_outpost"..i.."_infantry_spawn_b", 1, 8)
Cmd_SetStance("sg_turtle_attack_outpost"..i.."c", STANCE_Burn)
Cmd_AttackMoveMarker("sg_turtle_attack_outpost"..i.."c", "mkr_ork_start")
end
end
end
function Rule_Random_IG_Attack_On_Outpost_Base_Control_Kickoff()
if g_random_ig_attack_on_Outpost_base_started == true and (SGroup_Exists("sg_random_outpost_IG_attack") == false or (SGroup_Exists("sg_random_outpost_IG_attack") and SGroup_IsEmpty("sg_random_outpost_IG_attack"))) then
local l_random_time = World_GetRand(21, 31) -- 30, 45
Rule_AddOneShot(Rule_Random_IG_Attack_On_Outpost_Base_Control, l_random_time)
--g_random_ig_attack_on_Outpost_base_started will be made "false" after the control is started, overriding the "true" value next.
g_random_ig_attack_on_Outpost_base_started = false
end
if (EGroup_Exists("eg_barracks1") and EGroup_IsEmpty("eg_barracks1")) and (EGroup_Exists("eg_barracks2") and EGroup_IsEmpty("eg_barracks2"))
and (EGroup_Exists("eg_barracks3") and EGroup_IsEmpty("eg_barracks3")) then
Rule_Remove(Rule_Random_IG_Attack_On_Outpost_Base_Control_Kickoff)
end
end
function Rule_Random_IG_Attack_On_Outpost_Base_Control()
g_random_spawn2 = World_GetRand(1, 3) -- need to spawn outside of unit generation so that there is a consistant area the enemies will spawn from. 2, 3 represent outpost 2 and 3
if g_random_ig_attack_on_Outpost_base_started == false and (SGroup_Exists("sg_random_outpost_IG_attack") == false or (SGroup_Exists("sg_random_outpost_IG_attack") and SGroup_IsEmpty("sg_random_outpost_IG_attack"))) then
Rule_AddInterval(Rule_IG_Random_Outpost_Raid, 1)
end
end
function Rule_IG_Random_Outpost_Raid()
local i = g_IG_Random_Outpost_Raid_Army_iter
t_IG_Random_Outpost_Raid_Army = {
sgroup_name = {"sg_IG_outpost_attack_type1", "sg_IG_outpost_attack_type2"},
blueprint = {"guard_squad_guardsmen", "guard_squad_guardsmen"},
marker_spawn = {"mkr_outpost_attack1", "mkr_outpost_attack2", "mkr_outpost_attack3"},
stance = {STANCE_CeaseFire, STANCE_CeaseFire},
melee_stance = {MSTANCE_Ranged, MSTANCE_Ranged},
squad_num = {1, 1},
squad_size = {10, 10},
}
--local random_type = World_GetRand(1, table.getn(t_IG_Random_Outpost_Raid_Army.blueprint))
--local random_spawn = World_GetRand(1, table.getn(t_IG_Random_Outpost_Raid_Army.marker_spawn))
--local random_squad_number = World_GetRand(1, 2)
--local random_squad_size = World_GetRand(4, 8)
if EGroup_Exists("eg_barracks"..g_random_spawn2 ) and EGroup_IsEmpty("eg_barracks"..g_random_spawn2 ) == false then -- checks to see if the production facilities exist in the first place
if g_IG_Random_Outpost_Raid_Army_iter <= table.getn(t_IG_Random_Outpost_Raid_Army.sgroup_name) and (SGroup_Exists(t_IG_Random_Outpost_Raid_Army.sgroup_name[i]) == false or SGroup_IsEmpty(t_IG_Random_Outpost_Raid_Army.sgroup_name[i])) then
local sgroupID = Util_CreateSquadsAtMarkerEx(g_Player2, t_IG_Random_Outpost_Raid_Army.sgroup_name[i], t_IG_Random_Outpost_Raid_Army.blueprint[i], t_IG_Random_Outpost_Raid_Army.marker_spawn[g_random_spawn2], t_IG_Random_Outpost_Raid_Army.squad_num[i], t_IG_Random_Outpost_Raid_Army.squad_size[i]) -- t_IG_Random_Outpost_Raid_Army.squad_size[World_GetRand(4, 10)]
Cmd_SetStance(t_IG_Random_Outpost_Raid_Army.sgroup_name[i], t_IG_Random_Outpost_Raid_Army.stance[i])
Cmd_SetMeleeStance(t_IG_Random_Outpost_Raid_Army.sgroup_name[i], t_IG_Random_Outpost_Raid_Army.melee_stance[i])
SGroup_AddGroup(SGroup_CreateIfNotFound("sg_random_outpost_IG_attack"), SGroup_FromName(t_IG_Random_Outpost_Raid_Army.sgroup_name[i]))
elseif g_IG_Random_Outpost_Raid_Army_iter > table.getn(t_IG_Random_Outpost_Raid_Army.sgroup_name) then -- table.getn(t_IG_Random_Outpost_Raid_Army.sgroup_name)
g_IG_Random_Outpost_Raid_Army_iter = 0
Cmd_SetStance("sg_random_outpost_IG_attack", STANCE_CeaseFire)
Cmd_MoveToMarker("sg_random_outpost_IG_attack", "mkr_ork_start")
g_random_ig_attack_on_Outpost_base_started = true
Rule_AddOneShot(Rule_Outpost_Raid_Army_CeaseFire_Off, 30)
Rule_Remove(Rule_IG_Random_Outpost_Raid)
end
g_IG_Random_Outpost_Raid_Army_iter = g_IG_Random_Outpost_Raid_Army_iter +1
elseif EGroup_Exists("eg_barracks"..g_random_spawn2 ) and EGroup_IsEmpty("eg_barracks"..g_random_spawn2 ) then
g_random_ig_attack_on_Outpost_base_started = true
Rule_Remove(Rule_IG_Random_Outpost_Raid)
if SGroup_Exists("sg_random_IG_attack") and SGroup_IsEmpty("sg_random_IG_attack") == false then
Cmd_AttackMoveMarker("sg_random_IG_attack", "mkr_ork_start")
end
end
end
function Rule_Outpost_Raid_Army_CeaseFire_Off()
Cmd_SetStance("sg_random_outpost_IG_attack", STANCE_Attack)
Cmd_AttackMoveMarker("sg_random_outpost_IG_attack", "mkr_ork_start")
end
function Rule_Chaos_Army_Kickoff() --Kicks off Chaos Army -- Use FOR loops in the final mission draft
Player_GrantResearch(g_Player3, "chaos_frag_grenade_research")
Player_GrantResearch(g_Player3, "chaos_accuracy_upgrade_research")
Player_GrantResearch(g_Player3, "chaos_sorcerer_research_1")
Player_GrantResearch(g_Player3, "chaos_health_upgrade_research")
Util_CreateSquadsAtMarker(g_Player3, "sg_crull", "chaos_squad_lord", "mkr_crull_origin", 1)
SGroup_SetHealthInvulnerable("sg_crull", true)
bodyguardID = SGroup_CreateIfNotFound("sg_bodyguard")
for i = 1, 3 do
Util_CreateSquadsAtMarkerEx(g_Player3, "sg_crull_bodyguard"..i.."a", "chaos_marine_squad", "mkr_crull_bodyguard_spawn"..i, 2, 9) --1,12
SGroup_AddLeaders("sg_crull_bodyguard"..i.."a")
Util_CreateSquadsAtMarkerEx(g_Player3, "sg_crull_bodyguard"..i.."b", "chaos_squad_horror", "mkr_crull_bodyguard_horror_spawn"..i, 1, 12)
SGroup_AddGroup(bodyguardID, SGroup_FromName("sg_crull_bodyguard"..i.."a"))
SGroup_AddGroup(bodyguardID, SGroup_FromName("sg_crull_bodyguard"..i.."b"))
Cmd_SetStance("sg_crull_bodyguard"..i.."a", STANCE_StandGround)
Cmd_SetStance("sg_crull_bodyguard"..i.."b", STANCE_StandGround)
end
Util_CreateSquadsAtMarkerEx(g_Player3, "sg_crull_raiders1", "chaos_marine_squad", "mkr_chaos_raider_spawn", 3, 6)
SGroup_AddLeaders("sg_crull_raiders1")
Util_CreateSquadsAtMarkerEx(g_Player3, "sg_crull_raiders1b", "chaos_squad_khorne_berserker", "mkr_chaos_raider_spawn", 1, 6) -- 1,12
Util_CreateSquadsAtMarkerEx(g_Player3, "sg_crull_raiders2", "chaos_marine_squad", "mkr_chaos_raider_spawn", 3, 6)
SGroup_AddLeaders("sg_crull_raiders2")
Util_CreateSquadsAtMarkerEx(g_Player3, "sg_crull_raiders2b", "chaos_squad_khorne_berserker", "mkr_chaos_raider_spawn", 1, 6) -- 1,12
--[[ Util_CreateSquadsAtMarkerEx(g_Player3, "sg_crull_raiders3", "chaos_marine_squad", "mkr_chaos_raider_spawn", 3, 6) SGroup_AddLeaders("sg_crull_raiders3") Util_CreateSquadsAtMarkerEx(g_Player3, "sg_crull_raiders3b", "chaos_squad_khorne_berserker", "mkr_chaos_raider_spawn", 1, 6) -- 1,12]]
for i = 1, 3 do
--Util_CreateSquadsAtMarker(g_Player3, "sg_crull_bodyguard"..i.."c", "chaos_squad_predator", "mkr_crull_tank_spawn"..i, 2)
Cmd_SetStance("sg_crull_bodyguard"..i.."c", STANCE_StandGround)
end
for i = 1, 2 do
Util_CreateSquadsAtMarker(g_Player3, "sg_crull_defiler"..i, "chaos_squad_defiler", "mkr_defiler"..i, 1)
Cmd_SetStance("sg_crull_defiler"..i, STANCE_StandGround)
end
Cmd_SetStance("sg_crull_raiders1", STANCE_Attack)
Cmd_SetStance("sg_crull_raiders1b", STANCE_Attack)
Cmd_SetStance("sg_crull_raiders2", STANCE_Attack)
Cmd_SetStance("sg_crull_raiders2b", STANCE_Attack)
Cmd_MoveToMarker("sg_crull_raiders1", "mkr_chaos_raiders1")
Cmd_MoveToMarker("sg_crull_raiders1b", "mkr_chaos_raiders1")
Cmd_MoveToMarker("sg_crull_raiders2", "mkr_chaos_raiders2")
Cmd_MoveToMarker("sg_crull_raiders2b", "mkr_chaos_raiders2")
local mod_crullarmourincrease = Modifier_Create(MAT_EntityType, "armour_modifier", MUT_Multiplication, false, 4.5, "chaos_lord")
g_mod_crullarmourincrease = Modifier_ApplyToPlayer( mod_crullarmourincrease, g_Player3)
local mod_crullhealthincrease = Modifier_Create(MAT_EntityType, "health_maximum_modifier", MUT_Multiplication, false, 4, "chaos_lord")
g_mod_crullhealthincrease = Modifier_ApplyToPlayer( mod_crullarmourincrease, g_Player3 )
FOW_RevealMarker("mkr_crull_origin", 3600)
end
function Rule_Chaos_Anti_IG_Track()
for i = 1, 2 do
if EGroup_Exists("eg_titan_piece"..i) and EGroup_IsEmpty("eg_titan_piece"..i) == false and g_titan_damaged == false and t_chaos_raiders_deployed[i] == false then
if (SGroup_Exists("sg_crull_raiders"..i) and SGroup_IsEmpty("sg_crull_raiders"..i) == true) and (SGroup_Exists("sg_crull_raiders"..i.."b") and SGroup_IsEmpty("sg_crull_raiders"..i.."b") == true) then
Util_CreateSquadsAtMarkerEx(g_Player3, "sg_crull_raiders"..i, "chaos_marine_squad", "mkr_chaos_raider_spawn", 3, 6) -- 1,12
SGroup_AddLeaders("sg_crull_raiders"..i)
Cmd_MoveToMarker("sg_crull_raiders"..i, "mkr_chaos_raiders"..i)
Util_CreateSquadsAtMarkerEx(g_Player3, "sg_crull_raiders"..i.."b", "chaos_squad_khorne_berserker", "mkr_chaos_raider_spawn", 1, 6) -- 1,12
Cmd_MoveToMarker("sg_crull_raiders"..i.."b", "mkr_chaos_raiders"..i)
t_chaos_raiders_deployed[i] = true
end
end
end
if g_titan_damaged == true then
Rule_Check_AddInterval(Rule_Raid_Focus, 5)
Rule_Remove(Rule_Chaos_Anti_IG_Track)
end
end
function Rule_Chaos_Anti_IG_Track_Deployed()
for i = 1, 2 do
if t_chaos_raiders_deployed[i] == true then
if (SGroup_Exists("sg_crull_raiders"..i) and SGroup_IsEmpty("sg_crull_raiders"..i) == false) and (SGroup_Exists("sg_crull_raiders"..i.."b") and SGroup_IsEmpty("sg_crull_raiders"..i.."b") == false) then
if SGroup_CheckActiveCommand("sg_crull_raiders"..i, SQUADSTATEID_Idle, true) or Prox_AnySquadNearMarker("sg_crull_raiders"..i, "mkr_chaos_raiders"..i) then
Cmd_AttackMoveMarker("sg_crull_raiders"..i, "mkr_piece_defender"..i)
end
if SGroup_CheckActiveCommand("sg_crull_raiders"..i.."b", SQUADSTATEID_Idle, true) or Prox_AnySquadNearMarker("sg_crull_raiders"..i.."b", "mkr_chaos_raiders"..i) then
Cmd_AttackMoveMarker("sg_crull_raiders"..i.."b", "mkr_piece_defender"..i)
end
t_chaos_raiders_deployed[i] = false
end
end
end
if g_titan_damaged == true then
Rule_Remove(Rule_Chaos_Anti_IG_Track_Deployed)
end
end
--[[makes the raiders activate again]] function Rule_Raider_Reactivate() Player_GetAllSquadsNearMarker(g_Player1, "sg_raider_trigger", "mkr_raider_reactivate") if SGroup_Exists("sg_raider_trigger") and SGroup_IsEmpty("sg_raider_trigger") == false then if Prox_AnySquadNearMarker("sg_raider_trigger", "mkr_raider_reactivate") then for i = 1, 2 do if SGroup_Exists("sg_crull_raiders"..i) and SGroup_IsEmpty("sg_crull_raiders"..i) == false then Cmd_SetStance("sg_crull_raiders"..i, STANCE_StandGround) end if SGroup_Exists("sg_crull_raiders"..i.."b") and SGroup_IsEmpty("sg_crull_raiders"..i.."b") == false then Cmd_SetStance("sg_crull_raiders"..i.."b", STANCE_StandGround) Cmd_SetMeleeStance("sg_crull_raiders"..i.."b", MSTANCE_Assault) end end Rule_Remove(Rule_Raider_Reactivate) end end end
--[[expends the leftover crull raiders by sending them to the Ork base]] function Rule_Raid_Focus()
for i = 1,2 do
if SGroup_Exists("sg_crull_raiders"..i) and SGroup_IsEmpty("sg_crull_raiders"..i) == false then
if SGroup_CheckActiveCommand("sg_crull_raiders"..i, SQUADSTATEID_Idle, true) then
Cmd_SetStance("sg_crull_raiders"..i, STANCE_Attack)
Cmd_AttackMoveMarker("sg_crull_raiders"..i, "mkr_ork_start")
end
end
if SGroup_Exists("sg_crull_raiders"..i.."b") and SGroup_IsEmpty("sg_crull_raiders"..i.."b") == false then
if SGroup_CheckActiveCommand("sg_crull_raiders"..i.."b", SQUADSTATEID_Idle, true) then
Cmd_SetStance("sg_crull_raiders"..i.."b", STANCE_Attack)
Cmd_AttackMoveMarker("sg_crull_raiders"..i.."b", "mkr_ork_start")
end
end
end
-- when I have time, move these all into one convenient sgroup -- DY
if (SGroup_Exists("sg_crull_raiders1") and SGroup_IsEmpty("sg_crull_raiders1") == true)
and (SGroup_Exists("sg_crull_raiders1b") and SGroup_IsEmpty("sg_crull_raiders1b") == true)
and (SGroup_Exists("sg_crull_raiders2") and SGroup_IsEmpty("sg_crull_raiders2") == true)
and (SGroup_Exists("sg_crull_raiders2b") and SGroup_IsEmpty("sg_crull_raiders2b") == true) then
Rule_Remove(Rule_Raid_Focus)
end
end
--[[kicks off piece reveal]] function Rule_Reveal_Pieces_Control()
FOW_RevealEGroup(EGroup_FromName("eg_titan_piece1"), 30)
FOW_RevealEGroup(EGroup_FromName("eg_titan_piece2"), 30)
FOW_RevealEGroup(EGroup_FromName("eg_titan_piece3"), 30)
FOW_RevealMarker("mkr_battle_reveal", 30) -- to reveal Imperial Base that isn't near the titan piece
Rule_AddInterval(Rule_Reveal_Pieces, 30) -- continues a continuous refresh of the FOW every 30 seconds
end
--[[continues piece reveal - is deactivated with rule remove later on]] function Rule_Reveal_Pieces()
FOW_RevealEGroup(EGroup_FromName("eg_titan_piece1"), 30)
FOW_RevealEGroup(EGroup_FromName("eg_titan_piece2"), 30)
FOW_RevealEGroup(EGroup_FromName("eg_titan_piece3"), 30)
FOW_RevealMarker("mkr_battle_reveal", 30) -- to reveal Imperial Base that isn't near the titan piece
end
--[[checks to see if titan weapons are damaged. originally the pieces themselves were supposed to be damaged but now they are only the weapons]] --[[if a piece gets damaged and has health below 90%, then the variable g_titan_weapons_damaged is set to true, which is what triggers the objective complete condition for Rule_Objective_Damage_Titan]] function Rule_Piece_Health_Check()
for i = 1, 3 do
if EGroup_Exists("eg_titan_piece"..i) and EGroup_IsEmpty("eg_titan_piece"..i) == false then
if EGroup_GetAvgHealth("eg_titan_piece"..i) <= 0.90 then
g_titan_weapons_damaged = true
Rule_Remove(Rule_Piece_Health_Check)
break
end
end
end
end
--[[determines Crull's bodyguard behaviour should the player attack a piece.]] function Rule_Crull_Protection()
for i = 1,3 do
if EGroup_IsUnderAttackByPlayer("eg_titan_piece"..i, false , g_Player1) then
if SGroup_Exists("sg_crull_bodyguard"..i.."a") and (SGroup_IsEmpty("sg_crull_bodyguard"..i.."a") == false) then
Cmd_SetStance("sg_crull_bodyguard"..i.."a", STANCE_Hold)
Cmd_AttackSGroup("sg_crull_bodyguard"..i.."a", "sg_gorgutz")
end
if SGroup_Exists("sg_crull_bodyguard"..i.."b") and (SGroup_IsEmpty("sg_crull_bodyguard"..i.."b") == false) then
Cmd_SetStance("sg_crull_bodyguard"..i.."b", STANCE_Hold)
Cmd_AttackSGroup("sg_crull_bodyguard"..i.."b", "sg_gorgutz")
end
--g_back_to_base = false
--[[
if SGroup_Exists("sg_crull_bodyguard"..i.."c") and (SGroup_IsEmpty("sg_crull_bodyguard"..i.."c") == false) then
Cmd_AttackSGroup("sg_crull_bodyguard"..i.."c", "sg_gorgutz")
end]]
end
end
for i = 1,3 do
if (EGroup_IsUnderAttackByPlayer("eg_titan_piece"..i, false, g_Player1) == false) then -- and g_back_to_base == false
if SGroup_Exists("sg_crull_bodyguard"..i.."a") and (SGroup_IsEmpty("sg_crull_bodyguard"..i.."a") == false) then
Cmd_SetStance("sg_crull_bodyguard"..i.."a", STANCE_CeaseFire)
Cmd_MoveToMarker("sg_crull_bodyguard"..i.."a", "mkr_crull_bodyguard_spawn"..i)
end
if SGroup_Exists("sg_crull_bodyguard"..i.."b") and (SGroup_IsEmpty("sg_crull_bodyguard"..i.."b") == false) then
Cmd_SetStance("sg_crull_bodyguard"..i.."b", STANCE_CeaseFire)
Cmd_MoveToMarker("sg_crull_bodyguard"..i.."b", "mkr_crull_bodyguard_spawn"..i)
end
end
end
end
--[[if any of the player's units reaches either of the markers, bodyguard units will stop and the twist nis will kick in]] function Rule_Crull_Gorgutz_Proximity()
Player_GetAllSquadsNearMarker(g_Player1, "sg_twist_trigger", "mkr_twist_trigger1")
Player_GetAllSquadsNearMarker(g_Player1, "sg_twist_trigger2", "mkr_twist_trigger2")
if (SGroup_Exists("sg_twist_trigger") and SGroup_IsEmpty("sg_twist_trigger") == false) or (SGroup_Exists("sg_twist_trigger2") and SGroup_IsEmpty("sg_twist_trigger2") == false) then
if (Prox_AnySquadNearMarker("sg_twist_trigger", "mkr_twist_trigger1") or Prox_AnySquadNearMarker("sg_twist_trigger2", "mkr_twist_trigger2")) and g_meetflag1 == false then
g_meetflag1 = true
g_protection_fired_off = true
Rule_Check_Remove(Rule_Crull_Protection)
for i = 1, 3 do
if SGroup_Exists("sg_crull_bodyguard"..i.."a") and SGroup_IsEmpty("sg_crull_bodyguard"..i.."a") == false then
Cmd_StopSquads("sg_crull_bodyguard"..i.."a")
Cmd_SetStance("sg_crull_bodyguard"..i.."a", STANCE_StandGround)
end
if SGroup_Exists("sg_crull_bodyguard"..i.."b") and SGroup_IsEmpty("sg_crull_bodyguard"..i.."b") == false then
Cmd_StopSquads("sg_crull_bodyguard"..i.."b")
Cmd_SetStance("sg_crull_bodyguard"..i.."b", STANCE_StandGround)
end
end
Util_StartNIS( EVENTS.NIS_Twist)
if g_crull_first_time == false then
Rule_Check_AddInterval(Rule_Objective_Reach_Crull_First_Time, 1)
end
end
if g_meetflag1 == true then
Rule_Remove(Rule_Crull_Gorgutz_Proximity)
end
end
end
--[[controls what happens after the Necron arrival NIS]] function Rule_Necron_Arrival()
Rule_AddInterval(Rule_Necron_Army_Track, 1)
Rule_AddOneShot(Rule_Second_Necron_Army_Kickoff, 90)
Rule_AddOneShot(Rule_Third_Necron_Army_Kickoff, 180)
Rule_AddInterval(Rule_Necron_Bodycount, 2)
Rule_AddInterval(Rule_Necron_Army_Deathmarch, 5)
Rule_AddInterval(Rule_Ork_Count, 20) --45
Rule_AddOneShot(Rule_Bloodthirster_Generator, 1)
Rule_Remove(Rule_IG_Anti_Chaos_Track)
Rule_AddOneShot(Rule_Deactivate_Invulnerable, 15)
Rule_Remove(Rule_Random_IG_Attack_On_Outpost_Base_Control_Kickoff)
Rule_AddInterval(Rule_Generate_Chaos_Base_Minions_Check, 2)
for i = 1,3 do
--Cmd_SetStance("sg_necron_battlegroup"..i, STANCE_Hold)
if SGroup_Exists("sg_necron_attackers"..i) and SGroup_IsEmpty("sg_necron_attackers"..i) == false then
Cmd_SetStance("sg_necron_attackers"..i, STANCE_Attack)
Cmd_AttackMoveMarker("sg_necron_attackers"..i, "mkr_imperial_perimeter"..i)
end
end
Rule_Add(Rule_Autosave_Necrons_Arrived)
end
function Rule_Deactivate_Invulnerable()
--SGroup_SetHealthInvulnerable("sg_crull", false)
SGroup_SetHealthInvulnerable("sg_gorgutz", false)
end
--[[creates second necron monolith and warriors]] function Rule_Second_Necron_Army_Kickoff()
t_sgroupnecronbattlegroup[2] = SGroup_CreateIfNotFound("sg_necron_battlegroup2") -- used table in case I want to direct 3 battlegroups of 1 monolith and 1 squad of necron warriors each
t_sgroup_necron_attackers[2] = Util_CreateSquadsAtMarkerEx(g_Player4, "sg_necron_attackers2", "npc_necron_warrior", "mkr_necron_warrior_appear2", 2, 12)
t_sgroup_necron_monolith[2] = Util_CreateSquadsAtMarker(g_Player4, "sg_necron_monolith2", "npc_necron_monolith", "mkr_necron_appear2", 1) --eldar_squad_fire_prism
FOW_RevealSGroup(t_sgroup_necron_monolith[2], 60 )
SGroup_AddGroup(t_sgroupnecronbattlegroup[2], t_sgroup_necron_attackers[2])
SGroup_AddGroup(t_sgroupnecronbattlegroup[2], t_sgroup_necron_monolith[2])
Anim_PlaySGroupAnim(SGroup_FromName("sg_necron_monolith2"), "land")
Cmd_SetStance("sg_necron_battlegroup2", STANCE_Attack) -- temporary
Rule_AddInterval(Rule_Necron_Army_Track2, 1)
end
--[[creates third necron monolith and warriors]] function Rule_Third_Necron_Army_Kickoff()
t_sgroupnecronbattlegroup[3] = SGroup_CreateIfNotFound("sg_necron_battlegroup3") -- used table in case I want to direct 3 battlegroups of 1 monolith and 1 squad of necron warriors each
t_sgroup_necron_attackers[3] = Util_CreateSquadsAtMarkerEx(g_Player4, "sg_necron_attackers3", "npc_necron_warrior", "mkr_necron_warrior_appear3", 2, 12)
t_sgroup_necron_monolith[3] = Util_CreateSquadsAtMarker(g_Player4, "sg_necron_monolith3", "npc_necron_monolith", "mkr_necron_appear3", 1) --eldar_squad_fire_prism
FOW_RevealSGroup(t_sgroup_necron_monolith[3], 60 )
SGroup_AddGroup(t_sgroupnecronbattlegroup[3], t_sgroup_necron_attackers[3])
SGroup_AddGroup(t_sgroupnecronbattlegroup[3], t_sgroup_necron_monolith[3])
Anim_PlaySGroupAnim(SGroup_FromName("sg_necron_monolith3"), "land")
Cmd_SetStance("sg_necron_battlegroup3", STANCE_Attack) -- temporary
Rule_AddInterval(Rule_Necron_Army_Track3, 1)
end
--[[Regenerates Necron for first monolith that appears]]
function Rule_Necron_Army_Track()
--for i = 1, 3 do
if SGroup_IsEmpty("sg_necron_attackers1") and SGroup_IsEmpty("sg_necron_monolith1") == false then -- will only regenerate when "Monoliths" (aka tanks) are alive
t_sgroup_necron_attackers[1] = Util_CreateSquadsAtPositionEx(g_Player4, "sg_necron_attackers1", "npc_necron_warrior", SGroup_GetPosition(t_sgroup_necron_monolith[1]), 2, 12) --SGroup_GetPosition(t_sgroup_necron_monolith[i])
Cmd_MoveToMarker("sg_necron_attackers1", "mkr_necron_warrior_appear1")
--Cmd_MoveToSGroup("sg_necron_attackers1", "sg_necron_monolith1")
Cmd_SetStance("sg_necron_attackers1", STANCE_Attack) -- temporary
--Cmd_SetStance("sg_necron_attackers1", STANCE_Hold) -- temporary
SGroup_AddGroup(t_sgroupnecronbattlegroup[1], t_sgroup_necron_attackers[1])
--Cmd_AttackMoveMarker("sg_necron_attackers1", "mkr_imperial_perimeter1")
g_bodycount = g_bodycount + 1
--end
end
end
--[[Regenerates Necron for second monolith that appears]] function Rule_Necron_Army_Track2() --for i = 1, 3 do if SGroup_IsEmpty("sg_necron_attackers2") and SGroup_IsEmpty("sg_necron_monolith2") == false then -- will only regenerate when "Monoliths" (aka tanks) are alive t_sgroup_necron_attackers[2] = Util_CreateSquadsAtPositionEx(g_Player4, "sg_necron_attackers2", "npc_necron_warrior", SGroup_GetPosition(t_sgroup_necron_monolith[2]), 2, 12) --SGroup_GetPosition(t_sgroup_necron_monolith[2]) Cmd_MoveToMarker("sg_necron_attackers2", "mkr_necron_warrior_appear2") --Cmd_MoveToSGroup("sg_necron_attackers2", "sg_necron_monolith2") Cmd_SetStance("sg_necron_attackers2", STANCE_Attack) -- temporary --Cmd_SetStance("sg_necron_attackers2", STANCE_Hold) -- temporary SGroup_AddGroup(t_sgroupnecronbattlegroup[2], t_sgroup_necron_attackers[2]) --Cmd_AttackMoveMarker("sg_necron_attackers2", "mkr_imperial_perimeter2") g_bodycount = g_bodycount + 1 --end end
end
--[[Regenerates Necron for third monolith that appears]]
function Rule_Necron_Army_Track3()
--for i = 1, 3 do
if SGroup_IsEmpty("sg_necron_attackers3") and SGroup_IsEmpty("sg_necron_monolith3") == false then -- will only regenerate when "Monoliths" (aka tanks) are alive
t_sgroup_necron_attackers[3] = Util_CreateSquadsAtPositionEx(g_Player4, "sg_necron_attackers3", "npc_necron_warrior", SGroup_GetPosition(t_sgroup_necron_monolith[3]), 2, 12) --SGroup_GetPosition(t_sgroup_necron_monolith[3])
Cmd_MoveToMarker("sg_necron_attackers3", "mkr_necron_warrior_appear3")
--Cmd_MoveToSGroup("sg_necron_attackers3", "sg_necron_monolith3")
Cmd_SetStance("sg_necron_attackers3", STANCE_Attack) -- temporary
--Cmd_SetStance("sg_necron_attackers3", STANCE_Hold) -- temporary
SGroup_AddGroup(t_sgroupnecronbattlegroup[3], t_sgroup_necron_attackers[3])
--Cmd_AttackMoveMarker("sg_necron_attackers3", "mkr_imperial_perimeter3")
g_bodycount = g_bodycount + 1
--end
end
end
--[[function for counting how many necron squads are destroyed]] function Rule_Necron_Bodycount()
if g_bodycount >= 30 then -- destroys all necrons after bodycount is reached
for i = 1,3 do
if SGroup_Exists("sg_necron_battlegroup"..i) and SGroup_IsEmpty("sg_necron_battlegroup"..i) == false then
SGroup_SelfDestroy("sg_necron_battlegroup"..i, true)
end
end
Rule_Remove(Rule_Necron_Bodycount)
end
end
--[[keeps Necron Monolith moving towards their destination]] function Rule_Necron_Army_Deathmarch()
for i = 2, 3 do
if ((SGroup_Exists("sg_necron_attackers"..i)) and (SGroup_IsEmpty("sg_necron_attackers"..i) == false)) and
((SGroup_Exists("sg_necron_monolith"..i)) and (SGroup_IsEmpty("sg_necron_monolith"..i) == false)) then
local pos = Marker_GetPosition(Marker_FromName("mkr_outpost"..i, "basic_marker"))
if (World_DistanceSGroupToPoint(SGroup_FromName("sg_necron_monolith"..i), pos, true) >= 10) and (t_monolith_reached_destination[i] == false) then
Cmd_AttackMoveMarker("sg_necron_monolith"..i, "mkr_outpost"..i)
--Cmd_MoveToSGroup("sg_necron_attackers"..i, "sg_necron_monolith"..i)
--Cmd_MoveToMarker("sg_necron_attackers"..i, "mkr_necron_warrior_appear"..i)
Cmd_AttackMoveMarker("sg_necron_attackers"..i, "mkr_outpost"..i)
elseif (World_DistanceSGroupToPoint(SGroup_FromName("sg_necron_monolith"..i), pos, true) <= 10) and (t_monolith_reached_destination[i] == false) then
t_monolith_reached_destination[i] = true
--Cmd_SetStance("sg_necron_monolith"..i, STANCE_Attack)
--Cmd_SetStance("sg_necron_monolith"..i, STANCE_Hold)
g_reached_destination_count = g_reached_destination_count + 1
end
end
end
if g_reached_destination_count == 2 then
Rule_AddIntervalDelay(Rule_Necron_Army_Deathmarch2, 10, 90)
Rule_Remove(Rule_Necron_Army_Deathmarch)
end
end
--[[after 90 seconds the Necron Warriors will start focusing their attacks on the Ork base once they are idle (i.e. not killing off enemies close by)]] function Rule_Necron_Army_Deathmarch2() for i = 2, 3 do
if ((SGroup_Exists("sg_necron_attackers"..i)) and (SGroup_IsEmpty("sg_necron_attackers"..i) == false)) and
((SGroup_Exists("sg_necron_monolith"..i)) and (SGroup_IsEmpty("sg_necron_monolith"..i) == false)) then
local pos = Marker_GetPosition(Marker_FromName("mkr_ork_start"..i, "basic_marker"))
if SGroup_CheckActiveCommand("sg_necron_attackers"..i, SQUADSTATEID_Idle, true) then
if (World_DistanceSGroupToPoint(SGroup_FromName("sg_necron_attackers"..i), pos, true) >= 10) then
Cmd_AttackMoveMarker("sg_necron_attackers"..i, "mkr_ork_start"..i)
end
end
end
end
end
--[[respawns crull at final duel position, and then starts the function that keeps track of the end NIS trigger]] function Rule_Crull_Retreat()
SGroup_ReSpawnMarker("sg_crull", "mkr_duel_location")
Rule_AddOneShot(Rule_IE_Crull_Detected, 0)
Util_Ping_LoopingMkr("ping_crull2", "mkr_duel_location")
FOW_RevealSGroup(SGroup_FromName("sg_crull"), 120)
Cmd_SetStance("sg_crull", STANCE_CeaseFire)
Cmd_SetMeleeStance("sg_crull", MSTANCE_Assault )
Rule_AddInterval(Rule_Duel2, 2)
FOW_UnRevealArea(6,5, 20)
--[[
if (SGroup_IsEmpty("sg_crull") == false) then
local pos = Marker_GetPosition(Marker_FromName("mkr_duel_location", "basic_marker"))
if (World_DistanceSGroupToPoint(SGroup_FromName("sg_crull"), pos, true) > 10) and (g_crull_retreat_complete == false) and (g_moved == false) then
Cmd_SetStance("sg_crull", STANCE_CeaseFire)
Cmd_MoveToMarker("sg_crull", "mkr_duel_location")
g_moved = true
elseif (World_DistanceSGroupToPoint(SGroup_FromName("sg_crull"), pos, true) <= 10) and (g_crull_retreat_complete == false) and (g_moved == true) then
Rule_AddOneShot(Rule_IE_Crull_Detected, 0)
Util_Ping_LoopingMkr("ping_crull2", "mkr_duel_location")
FOW_RevealSGroup(SGroup_FromName("sg_crull"), 120)
Cmd_SetStance("sg_crull", STANCE_CeaseFire)
Cmd_SetMeleeStance("sg_crull", MSTANCE_Assault )
g_crull_retreat_complete = true
local mod_crullarmourincrease = Modifier_Create(MAT_EntityType, "armour_modifier", MUT_Multiplication, false, 0.5, "chaos_lord")
g_mod_crullarmourincrease = Modifier_ApplyToPlayer( mod_crullarmourincrease, g_Player3)
local mod_crullhealthincrease = Modifier_Create(MAT_EntityType, "health_maximum_modifier", MUT_Multiplication, false, 0.5, "chaos_lord")
g_mod_crullhealthincrease = Modifier_ApplyToPlayer( mod_crullarmourincrease, g_Player3 )
--Rule_AddInterval(Rule_Unit_Detach, 0) -- kicks off the Gorgutz detach function
Rule_AddInterval(Rule_Duel2, 2)
end
end]]
end
--[[controls detection and handing over control of the extra Ork boyz located on the map]] function Rule_Lost_Boyz()
Player_GetAllSquadsNearMarker(g_Player1, "sg_lost_trigger", "mkr_lost_orks")
if SGroup_Exists("sg_lost_trigger") and SGroup_IsEmpty("sg_lost_trigger") == false then
if Prox_AnySquadNearMarker("sg_lost_trigger", "mkr_lost_orks") then
Rule_AddOneShot(Rule_IE_Lost_Boyz, 0)
Player_AddResource(g_Player1, RT_Requisition, 300 )
Player_AddResource(g_Player1, RT_Power, 200 )
FOW_RevealMarker("mkr_lost_ork_spawn", 180)
Util_CreateSquadsAtMarkerEx(g_Player1, "sg_lost_boyz1", "ork_squad_shoota_boy", "mkr_lost_ork_spawn", 1,15)
Util_CreateSquadsAtMarker(g_Player1, "sg_lost_boyz2", "ork_squad_killa_kan", "mkr_lost_ork_spawn", 1)
SGroup_Destroy(SGroup_FromName("sg_lost_trigger"))
Player_UnRestrictSquad(g_Player1, "ork_squad_looted_tank")
Rule_Remove(Rule_Lost_Boyz)
end
end
if SGroup_Exists("sg_lost_trigger") then
SGroup_Destroy(SGroup_FromName("sg_lost_trigger"))
end
end
--[[Generates a unit that will be sacrificed to become a bloodthirster]] function Rule_Bloodthirster_Generator()
Util_CreateSquadsAtMarker(g_Player3, "sg_bloodthirster1", "chaos_squad_sorcerer", "mkr_bloodthirster1", 1)
Player_GrantResearch(g_Player3, "chaos_bloodthirster_research")
Rule_AddOneShot(Rule_Bloodthirster_Possession, 1) -- calls possession to do the actual creation of a bloodthirster
Rule_AddInterval(Rule_Bloodthirster_Regeneration, 5) -- calls the regeneration function that keeps the bloodthirster at 100% health until player gets to it.
end
-- [[causes the unit in sg_bloodthirster1 to become a bloodthirster]] function Rule_Bloodthirster_Possession()
Cmd_Possesion("sg_bloodthirster1")
-- Cmd_Possesion("sg_bloodthirster2")
end
--[[regenerates bloodthirster health]] -- figure out better way to improve this function Rule_Bloodthirster_Regeneration()
local pos = Marker_GetPosition(Marker_FromName("mkr_bloodthirster_generation", "basic_marker"))
Player_GetAllSquadsNearMarker(g_Player1, "sg_bloodthirster_trigger", "mkr_bloodthirster_generation")
if SGroup_Exists("sg_bloodthirster_trigger") and SGroup_IsEmpty("sg_bloodthirster_trigger") == false then
if Prox_AnySquadNearMarker("sg_bloodthirster_trigger", "mkr_bloodthirster_generation") and g_bloodthirster_triggered == false then
SGroup_SetAvgHealth("sg_bloodthirster1", 1.0)
SGroup_Destroy(SGroup_FromName("sg_bloodthirster_trigger"))
g_bloodthirster_triggered = true
g_regeneration_on = false
Rule_Remove(Rule_Bloodthirster_Regeneration)
elseif g_regeneration_on == true then
SGroup_Destroy(SGroup_FromName("sg_bloodthirster_trigger"))
SGroup_SetAvgHealth("sg_bloodthirster1", 1.0)
end
end
if SGroup_Exists("sg_bloodthirster_trigger") then
SGroup_Destroy(SGroup_FromName("sg_bloodthirster_trigger"))
end
end
--[[ function Rule_Bloodthirster2_Check() -- checks to see if a squad triggers the generation of the second bloodthirster local pos1 = Marker_GetPosition(Marker_FromName("mkr_bloodthirster2_trigger1", "basic_marker")) local pos2 = Marker_GetPosition(Marker_FromName("mkr_bloodthirster2_trigger2", "basic_marker"))
Player_GetAllSquadsNearMarker(g_Player1, "sg_bloodthirster2_trigger1", "mkr_bloodthirster2_trigger1")
Player_GetAllSquadsNearMarker(g_Player1, "sg_bloodthirster2_trigger2", "mkr_bloodthirster2_trigger2")
if (SGroup_Exists("sg_bloodthirster2_trigger1") and SGroup_IsEmpty("sg_bloodthirster2_trigger1") == false) or (SGroup_Exists("sg_bloodthirster2_trigger2") and SGroup_IsEmpty("sg_bloodthirster2_trigger2") == false) then
if (Prox_AnySquadNearMarker("sg_bloodthirster2_trigger1", "mkr_bloodthirster2_trigger1") or Prox_AnySquadNearMarker("sg_bloodthirster2_trigger2", "mkr_bloodthirster2_trigger2")) and g_bloodthirster2_triggered == false then
if SGroup_Exists("sg_bloodthirster2") and SGroup_IsEmpty("sg_bloodthirster2") == false then
Cmd_Possesion("sg_bloodthirster2")
g_bloodthirster2_triggered = true
Rule_Remove(Rule_Bloodthirster2_Check)
end
end
end
end]]
--[[check function that detects if the player is near marker "mkr_chaos_minion_generation". If so, then the minions will be generated]] function Rule_Generate_Chaos_Base_Minions_Check()
local pos1 = Marker_GetPosition(Marker_FromName("mkr_chaos_minion_generation", "basic_marker"))
Player_GetAllSquadsNearMarker(g_Player1, "sg_minion_trigger", "mkr_chaos_minion_generation")
if SGroup_Exists("sg_minion_trigger") and SGroup_IsEmpty("sg_minion_trigger") == false then
if Prox_AnySquadNearMarker("sg_minion_trigger", "mkr_chaos_minion_generation") then
Rule_AddOneShot(Rule_Generate_Chaos_Base_Minions, 0)
Rule_Remove(Rule_Generate_Chaos_Base_Minions_Check)
end
end
end
--[[generates enemies at the chaos base]] function Rule_Generate_Chaos_Base_Minions()
Util_CreateSquadsAtMarkerEx(g_Player3, "sg_crull_minion1", "chaos_squad_khorne_berserker", "mkr_staging_area1", 1, 12) --1,12
SGroup_AddLeaders("sg_crull_minion1")
Util_CreateSquadsAtMarkerEx(g_Player3, "sg_crull_minion2", "chaos_squad_obliterator", "mkr_staging_area1", 1, 4)
Util_CreateSquadsAtMarkerEx(g_Player3, "sg_crull_minion3", "chaos_squad_raptor", "mkr_staging_area2", 1, 12)
SGroup_AddLeaders("sg_crull_minion3")
Util_CreateSquadsAtMarker(g_Player3, "sg_crull_minion4", "chaos_squad_sorcerer", "mkr_staging_area2", 1)
Util_CreateSquadsAtMarker(g_Player3, "sg_crull_minion5", "chaos_squad_predator", "mkr_staging_area1", 3)
Util_CreateSquadsAtMarkerEx(g_Player3, "sg_crull_minion6", "chaos_squad_cultist", "mkr_chaos_base_defender_spawn", 1,12)
Util_CreateSquadsAtMarkerEx(g_Player3, "sg_crull_minion7", "chaos_marine_squad", "mkr_chaos_base_defender_spawn2", 1, 8)
end
--[[counts how many squads died within the last cycle. If it is a high number, the game will give the player reinforcements]] function Rule_Ork_Count()
g_sgroup_current_ork_count = Player_GetSquadCount( g_Player1 )
g_sgroup_current_ork_count_difference = g_sgroup_current_ork_count - g_sgroup_previous_ork_count
g_sgroup_previous_ork_count = g_sgroup_current_ork_count
if g_sgroup_current_ork_count_difference < -2 then
g_ork_losses = g_ork_losses + 2
Rule_AddOneShot(Rule_Ork_Reinforcements, 1)
end
end
-- OR we can make it so that Rule_Ork_Reinforcements kicks in after IG are all dead.....
function Rule_Ork_Reinforcements() --DY - we might want to randomize the reinforcements in the final mission draft -- randomizes Ork reinforcements recieved after certain numbers of Necrons are killed
--[[
if (SGroup_IsEmpty("sg_necron_monolith3") == true) and (g_squiggoth_reinforced == false) then
Util_CreateSquadsAtMarker(g_Player1, "sg_trainer", "ork_squad_bad_dok", "mkr_ork_start", 1)
Util_CreateSquadsAtMarker(g_Player1, "sg_squiggoths", "ork_squad_squiggoth", "mkr_ork_start", 2)
g_squiggoth_reinforced = true
Rule_AddOneShot(Rule_IE_Ork_Reinforce1, 0)
end
if (SGroup_IsEmpty("sg_necron_monolith2") == true) and (g_mek_reinforced == false) then
--Util_CreateSquadsAtMarker(g_Player1, "sg_killakans", "ork_squad_killa_kan", "mkr_ork_start", 5)
g_mek_reinforced = true
--Rule_AddOneShot(Rule_IE_Ork_Reinforce2, 0)
end
if (SGroup_IsEmpty("sg_necron_monolith1") == true) and (g_mek_reinforced2 == false) then
--Util_CreateSquadsAtMarker(g_Player1, "sg_lootedtank", "ork_squad_looted_tank", "mkr_ork_start", 3)
g_mek_reinforced2 = true
--Rule_AddOneShot(Rule_IE_Ork_Reinforce2, 0)
end
if (g_squiggoth_reinforced == true) and (g_mek_reinforced == true) then
Rule_Remove(Rule_Ork_Reinforcements)
end]]
if (g_ork_losses == 6) and (g_squiggoth_reinforced == false) then
Util_CreateSquadsAtMarker(g_Player1, "sg_trainer", "ork_squad_bad_dok_sp_trainer", "mkr_ork_start", 1)
Util_CreateSquadsAtMarker(g_Player1, "sg_squiggoths", "ork_squad_squiggoth", "mkr_ork_start", 2)
g_squiggoth_reinforced = true
Rule_AddOneShot(Rule_IE_Ork_Reinforce1, 0)
end
if (g_ork_losses == 2) and (g_mek_reinforced == false) then
Util_CreateSquadsAtMarker(g_Player1, "sg_killakans", "ork_squad_killa_kan", "mkr_ork_start", 3)
g_mek_reinforced = true
Rule_AddOneShot(Rule_IE_Ork_Reinforce2, 0)
end
if (g_ork_losses == 4) and (g_mek_reinforced2 == false) then
Util_CreateSquadsAtMarker(g_Player1, "sg_lootedtank", "ork_squad_looted_tank", "mkr_ork_start", 3)
g_mek_reinforced2 = true
Player_UnRestrictSquad(g_Player1, "ork_squad_looted_tank")
Rule_AddOneShot(Rule_IE_Ork_Reinforce2, 0)
end
if (g_squiggoth_reinforced == true) and (g_mek_reinforced == true) and (g_mek_reinforced2 == true) then
--Rule_Remove(Rule_Ork_Reinforcements)
Rule_Remove(Rule_Ork_Count)
end
end
--[[Governs the duel at the end of the mission. If Gorgutz is dead, then g_warboss_dead is set to true so that the lose conditions kick in]]
function Rule_Duel2()
--local pos = Marker_GetPosition(Marker_FromName("mkr_duel_location", "basic_marker"))
Player_GetAllSquadsNearMarker(g_Player1, "sg_final_trigger_group", "mkr_second_duel_trigger")
local pos = SGroup_GetPosition(SGroup_FromName("sg_crull"))
if (SGroup_Exists("sg_gorgutz") == true) and (SGroup_IsEmpty("sg_gorgutz") == false) then
if SGroup_CountDeSpawned(SGroup_FromName("sg_gorgutz")) == 0 then
-- checks to see if gorgutz is close to the duel point.
if SGroup_Exists("sg_final_trigger_group") and SGroup_IsEmpty("sg_final_trigger_group") == false then
if (World_DistanceSGroupToPoint("sg_final_trigger_group", pos, true) <= 35) and (g_meetflag4 == false) then
SGroup_SetHealthInvulnerable("sg_crull", false)
g_meetflag4 = true
elseif (g_meetflag4 == true) then
Rule_Remove(Rule_Duel2)
end
end
end
elseif (SGroup_Exists("sg_gorgutz") == false) or (SGroup_IsEmpty("sg_gorgutz") == true) then
--g_warboss_dead = true
end
end
--[[checks to see if the player is at one of 4 markers that triggers the assault music to be played]] function Rule_Assault_Music_Activate()
local pos1 = Marker_GetPosition(Marker_FromName("mkr_titan_assault_music_start1", "basic_marker"))
local pos2 = Marker_GetPosition(Marker_FromName("mkr_titan_assault_music_start2", "basic_marker"))
local pos3 = Marker_GetPosition(Marker_FromName("mkr_titan_assault_music_start3", "basic_marker"))
local pos4 = Marker_GetPosition(Marker_FromName("mkr_titan_assault_music_start4", "basic_marker"))
Player_GetAllSquadsNearPos(g_Player1 , "sg_attack_trigger_group1", pos1, 12)
Player_GetAllSquadsNearPos(g_Player1 , "sg_attack_trigger_group2", pos2, 12)
Player_GetAllSquadsNearPos(g_Player1 , "sg_attack_trigger_group3", pos3, 12)
Player_GetAllSquadsNearPos(g_Player1 , "sg_attack_trigger_group3", pos4, 12)
for i = 1, 3 do
if Prox_AnySquadNearMarker("sg_attack_trigger_group"..i, "mkr_titan_assault_music_start"..i) then
Playlist_Manager( PC_Music, {"music_msd5o", "music_msd5o_perc"}, true , false, {1, 2})
Rule_Remove(Rule_Assault_Music_Activate)
break
end
end
end
function Rule_Outpost_Objective_Kickoff()
local pos1 = Marker_GetPosition(Marker_FromName("mkr_outpost_objective_kickoff1", "basic_marker"))
local pos2 = Marker_GetPosition(Marker_FromName("mkr_outpost_objective_kickoff2", "basic_marker"))
Player_GetAllSquadsNearPos(g_Player1 , "sg_outpost_trigger_group1", pos1, 12)
Player_GetAllSquadsNearPos(g_Player1 , "sg_outpost_trigger_group2", pos2, 12)
for i = 1, 2 do
if Prox_AnySquadNearMarker("sg_outpost_trigger_group"..i, "mkr_outpost_objective_kickoff"..i) then
Rule_Check_AddInterval(Rule_Objective_Destroy_Outposts, 1)
Rule_Remove(Rule_Outpost_Objective_Kickoff)
break
end
end
end
--~ function Rule_End_Shortcut() --~ --Util_StartNIS( EVENTS.NIS_Moment) --~ Util_StartNIS( EVENTS.NIS_Closing) --~ end
--~ function Rule_Twist_Shortcut() --~ Util_StartNIS( EVENTS.NIS_Twist) --~ end --[[ function Rule_Twist_Conditions() Util_ObjectiveComplete(Objective_Destroy_Outposts.title_id) Util_Ping_Stop("ping_outpost2") Util_Ping_Stop("ping_outpost3") Rule_Remove(Rule_Objective_Destroy_Outposts) Rule_AddInterval(Rule_Objective_Damage_Titan, 0) Rule_AddOneShot(Rule_Twist_Conditions2, 2) end
function Rule_Twist_Conditions2()
Util_ObjectiveComplete(Objective_Damage_Titan.title_id)
g_titan_damaged = true
--Rule_AddInterval(Rule_Crull_Protection, 5)
Rule_AddInterval(Rule_Crull_Gorgutz_Proximity, 2)
Rule_AddInterval(Rule_Objective_Reach_Crull_First_Time, 1)
Util_Ping_Stop("ping_outpost2")
Util_Ping_Stop("ping_outpost3")
Util_Ping_Stop("ping_piece1")
Util_Ping_Stop("ping_piece2")
Util_Ping_Stop("ping_piece3")
Rule_Remove(Rule_Reveal_Pieces)
Rule_Remove(Rule_Objective_Damage_Titan)
g_player2squads = Player_GetSquads(g_Player2)
--g_player3squads = Player_GetSquads(g_Player3)
SGroup_DeSpawn(SGroup_GetName(g_player2squads))
--SGroup_DeSpawn(SGroup_GetName(g_player3squads))
SGroup_ReSpawn("sg_crull")
SGroup_ReSpawn("sg_gorgutz")
end]]
--[[ GAME OVER - Player Wins ]]
function Rule_EndGameWin() -- Player wins when Crull is dead. --g_playerHasWon if Objective_Duel_Crull ~= nil and Objective_Exists(Objective_Duel_Crull.title_id) and Objective_GetState(Objective_Duel_Crull.title_id) == OS_Complete then Rule_RemoveAll() Util_StartNIS(EVENTS.NIS_Closing) end
end
--[[ GAME OVER - Player Loses ]]
--[[ The Player Loses condition will be mission specific this version of the function detects if the player has lost their base and has no servitors left ]]
function Rule_EndGameLose()
g_building_exceptions =
{
"eldar_webway_gate",
"space_marine_listening_post",
"space_marine_turret_bolter"
}
g_unit_exceptions =
{
"ork_squad_warboss"
}
--[[ Lose because of Annihilation ]]
if( Player_HasBuildingsExcept(g_Player1, g_building_exceptions) == false ) then
if( Player_HasSquadsExcept(g_Player1, g_unit_exceptions ) == false ) then
Rule_RemoveAll()
Fade_Start(4, false)
World_SetTeamWin( g_Player2, "" )
Rule_AddIntervalEx( Rule_GameOver,5,1 )
Rule_Remove( Rule_EndGameLose )
end
end
end
--[[ call this with an interval to ensure the mission ends ]] function Rule_GameOver() World_SetGameOver() end
--[[ OBJECTIVES ]]
--[[ Objective Name ]]
function Rule_Objective_Trophies()
Objective_Trophies = { title_id = 911036, short_desc_id = 911038, help_tip_id = 911040 }
if Event_IsAnyRunning() == false and Objective_Exists(Objective_Trophies.title_id) == false then
Util_WXP_ObjectiveCreate(Objective_Trophies, true)
--Rule_AddInterval(Rule_Objective_Destroy_Outposts, 1)
Rule_AddInterval(Rule_Objective_Damage_Titan, 1)
elseif Event_IsAnyRunning() == false and (g_trophies_sub_objectives_completed == 4) then
Util_ObjectiveComplete(Objective_Trophies.title_id)
Rule_Remove(Rule_Objective_Trophies)
end
end
function Rule_Objective_Destroy_Outposts()
Objective_Destroy_Outposts = { title_id = 911000, short_desc_id = 911002, help_tip_id = 911004 }
if Event_IsAnyRunning() == false and Objective_Exists(Objective_Destroy_Outposts.title_id) == false then
Rule_AddOneShot(Rule_IE_Imperial_Objective, 0) -- intel event for gorgutz talking about imperial objective
Util_WXP_ObjectiveCreate(Objective_Destroy_Outposts, false)
Util_Ping_LoopingMkr("ping_outpost2", "mkr_outpost2")
Util_Ping_LoopingMkr("ping_outpost3", "mkr_outpost3")
--[[
Util_Ping_LoopingMkr("ping_piece1", "mkr_piece_ping1")
Util_Ping_LoopingMkr("ping_piece2", "mkr_piece_ping2")
Util_Ping_LoopingMkr("ping_piece3", "mkr_piece_ping3")]]
g_destroy_outpost2_ping = Objective_PingMarker(Objective_Destroy_Outposts.title_id, "mkr_outpost2", true, "attack")
g_destroy_outpost3_ping = Objective_PingMarker(Objective_Destroy_Outposts.title_id, "mkr_outpost3", true, "attack")
elseif Event_IsAnyRunning() == false and (EGroup_IsEmpty("eg_outpost2") == true) and (EGroup_IsEmpty("eg_outpost3") == true) then
Util_ObjectiveComplete(Objective_Destroy_Outposts.title_id)
Util_Ping_Stop("ping_outpost2")
Util_Ping_Stop("ping_outpost3")
Objective_PingRemove(Objective_Destroy_Outposts.title_id, g_destroy_outpost2_ping)
Objective_PingRemove(Objective_Destroy_Outposts.title_id, g_destroy_outpost3_ping)
--g_trophies_sub_objectives_completed = g_trophies_sub_objectives_completed + 1
--Rule_AddInterval(Rule_Objective_Damage_Titan, 1)
Rule_Remove(Rule_Objective_Destroy_Outposts)
Rule_Add(Rule_Autosave_Outposts_Destroyed)
end
end
function Rule_Objective_Damage_Titan()
Objective_Damage_Titan = { title_id = 911006, short_desc_id = 911008, help_tip_id = 911010 }
if Event_IsAnyRunning() == false and Objective_Exists(Objective_Damage_Titan.title_id) == false then
Util_WXP_ObjectiveSubCreate(Objective_Damage_Titan, 911036)
Sound_PlayStinger("stinger_msd5o_attackingthetitan")
Util_Ping_LoopingMkr("ping_piece1", "mkr_piece_ping1")
Util_Ping_LoopingMkr("ping_piece2", "mkr_piece_ping2")
Util_Ping_LoopingMkr("ping_piece3", "mkr_piece_ping3")
t_piece_markers = {"mkr_piece_ping1", "mkr_piece_ping2", "mkr_piece_ping3"}
t_damage_titan_ping = {}
for i = 1, 3 do
t_damage_titan_ping[i] = Objective_PingMarker(Objective_Damage_Titan.title_id, t_piece_markers[i], true, "attack")
end
elseif Event_IsAnyRunning() == false and g_titan_weapons_damaged == true then --(EGroup_GetAvgHealth("eg_titan_pieces_a") <= 0.90)
Util_ObjectiveComplete(Objective_Damage_Titan.title_id)
g_titan_damaged = true
if g_protection_fired_off == false then
Rule_AddInterval(Rule_Crull_Protection, 5)
g_protection_fired_off = true
end
--Rule_AddInterval(Rule_Crull_Gorgutz_Proximity, 0)
if g_crull_first_time == false then
Rule_Check_AddInterval(Rule_Objective_Reach_Crull_First_Time, 1) -- if this objective is completed before Reach Crull First Time.
end
Util_Ping_Stop("ping_piece1")
Util_Ping_Stop("ping_piece2")
Util_Ping_Stop("ping_piece3")
for i = 1, 3 do
Objective_PingRemove(Objective_Damage_Titan.title_id, t_damage_titan_ping[i])
end
g_trophies_sub_objectives_completed = g_trophies_sub_objectives_completed + 1
--Rule_Remove(Rule_Reveal_Pieces)
Rule_Remove(Rule_Objective_Damage_Titan)
end
end
function Rule_Objective_Reach_Crull_First_Time()
Objective_Reach_Crull_First_Time = { title_id = 911012, short_desc_id = 911014, help_tip_id = 911016 }
if Event_IsAnyRunning() == false and Objective_Exists(Objective_Reach_Crull_First_Time.title_id) == false then
Util_WXP_ObjectiveSubCreate(Objective_Reach_Crull_First_Time, 911036)
Util_Ping_LoopingMkr("ping_crull1", "mkr_crull_origin")
g_crull_ping1 = Objective_PingMarker(Objective_Reach_Crull_First_Time.title_id, "mkr_crull_origin", true, "attack")
g_crull_first_time = true
if g_meetflag1 == false then
Rule_AddOneShot(Rule_IE_Crull_Duel_Challenge, 0)
end
elseif Event_IsAnyRunning() == false and (g_meetflag1 == true) then
Util_ObjectiveComplete(Objective_Reach_Crull_First_Time.title_id)
Objective_PingRemove(Objective_Reach_Crull_First_Time.title_id, g_crull_ping1)
Util_Ping_Stop("ping_crull1")
Rule_Check_AddOneShot(Rule_Necron_Arrival, 1)
Rule_Check_AddInterval(Rule_Objective_Defeat_Necrons, 0)
g_titan_weapons_damaged = true -- makes it so that the damage titan objective is completed too
Rule_Check_AddInterval(Rule_Objective_Destroy_Titan, 1)
--Rule_AddInterval(Rule_Objective_Duel_Crull, 1)
Rule_Remove(Rule_Crull_Gorgutz_Proximity)
--Rule_AddInterval(Rule_Crull_Gorgutz_Proximity2, 0)
SGroup_SetHealthInvulnerable("sg_crull", true)
g_trophies_sub_objectives_completed = g_trophies_sub_objectives_completed + 1
Rule_Remove(Rule_Objective_Reach_Crull_First_Time)
end
end
function Rule_Objective_Destroy_Titan()
Objective_Destroy_Titan = { title_id = 911018, short_desc_id = 911020, help_tip_id = 911022 }
if Event_IsAnyRunning() == false and Objective_Exists(Objective_Destroy_Titan.title_id) == false then
Util_WXP_ObjectiveCreate(Objective_Destroy_Titan, false)
t_piece_markers2 = {"mkr_piece_ping1", "mkr_piece_ping2", "mkr_piece_ping3"}
t_destroy_titan_ping = {}
for i = 1, 3 do
t_destroy_titan_ping[i] = Objective_PingMarker(Objective_Destroy_Titan.title_id, t_piece_markers2[i], true, "attack")
end
elseif Event_IsAnyRunning() == false and (EGroup_IsEmpty"eg_titan_pieces_a") then
Util_ObjectiveComplete(Objective_Destroy_Titan.title_id)
for i = 1, 3 do
Objective_PingRemove(Objective_Destroy_Titan.title_id, t_destroy_titan_ping[i])
end
Rule_Remove(Rule_Objective_Destroy_Titan)
end
end
function Rule_Objective_Defeat_Necrons()
Objective_Defeat_Necrons = { title_id = 911030, short_desc_id = 911032, help_tip_id = 911034 }
if Event_IsAnyRunning() == false and Objective_Exists(Objective_Defeat_Necrons.title_id) == false then
Util_WXP_ObjectiveSubCreate(Objective_Defeat_Necrons, 911036)
elseif Event_IsAnyRunning() == false
and SGroup_Exists ("sg_necron_battlegroup1") and SGroup_IsEmpty("sg_necron_battlegroup1")
and SGroup_Exists ("sg_necron_battlegroup2") and SGroup_IsEmpty("sg_necron_battlegroup2")
and SGroup_Exists ("sg_necron_battlegroup3") and SGroup_IsEmpty("sg_necron_battlegroup3") then
Sound_PlayStinger("music_msd5o_orch")
Util_ObjectiveComplete(Objective_Defeat_Necrons.title_id)
Rule_AddOneShot(Rule_IE_Necrons_Destroyed, 0)
Rule_AddInterval(Rule_Objective_Duel_Crull, 1)
Rule_Remove(Rule_Reveal_Pieces)
Rule_Remove(Rule_Objective_Defeat_Necrons)
Rule_Add(Rule_Autosave_Necrons_Defeated)
g_trophies_sub_objectives_completed = g_trophies_sub_objectives_completed + 1
end
end
function Rule_Objective_Duel_Crull()
Objective_Duel_Crull = { title_id = 911024, short_desc_id = 911026, help_tip_id = 911028 }
if Event_IsAnyRunning() == false and Objective_Exists(Objective_Duel_Crull.title_id) == false then
Util_WXP_ObjectiveSubCreate(Objective_Duel_Crull, 911036)
g_crull_ping2 = Objective_PingMarker(Objective_Duel_Crull.title_id, "mkr_duel_location", true, "attack")
Rule_AddOneShot(Rule_Crull_Retreat, 0) -- crull respawns
elseif Event_IsAnyRunning() == false and g_meetflag4 == true then --((SGroup_IsEmpty"sg_crull") or g_crull_dead == true)
Util_ObjectiveComplete(Objective_Duel_Crull.title_id)
Objective_PingRemove(Objective_Duel_Crull.title_id, g_crull_ping2)
Util_Ping_Stop("ping_crull2")
g_playerHasWon = true
g_trophies_sub_objectives_completed = g_trophies_sub_objectives_completed + 1
Rule_Remove(Rule_Objective_Duel_Crull)
end
end
--[[ AUTOSAVES ]]
function Rule_Autosave_MissionStart()
if not Event_IsAnyRunning() then
Util_Autosave( "$910200" )
Rule_Remove(Rule_Autosave_MissionStart)
end
end
function Rule_Autosave_Outposts_Destroyed()
if not Event_IsAnyRunning() then
Util_Autosave( "$910202" )
Rule_Remove(Rule_Autosave_Outposts_Destroyed)
end
end
function Rule_Autosave_Necrons_Arrived()
if not Event_IsAnyRunning() then
Util_Autosave( "$910204" )
Rule_Remove(Rule_Autosave_Necrons_Arrived)
end
end
function Rule_Autosave_Necrons_Defeated()
if not Event_IsAnyRunning() then
Util_Autosave( "$910206" )
Rule_Remove(Rule_Autosave_Necrons_Defeated)
end
end
--[[ INTEL EVENTS ]]
--[[ function Rule_IE_OpeningNIS()
Util_StartIntel(EVENTS.IE_OpeningNIS)
end]]
--[[ Intel Event 1 ]] function Rule_IE_OpeningSpeech()
Util_StartIntel(EVENTS.IE_OpeningSpeech)
end
function Rule_IE_Imperial_Objective()
Util_StartIntel(EVENTS.IE_Imperial_Objective)
end
--[[ New Objective Created ]] function Rule_IE_Objective_NameCreate()
Util_StartIntel(EVENTS.IE_Objective_NameCreate)
end
--[[ Objective Failed ]] function Rule_IE_Objective_NameComplete()
Util_StartIntel(EVENTS.IE_Objective_NameComplete)
end
--[[ Intel Event 1 ]] function Rule_IE_Objective_NameFailed()
Util_StartIntel(EVENTS.IE_Objective_NameFailed)
end
--[[ --[[ Necron Arrival ]] function Rule_IE_Necron_Arrival()
Util_StartIntel(EVENTS.IE_Necron_Arrival)
end]]
--[[Crull's escape]] --[[ function Rule_IE_Crull_Escape()
Util_StartIntel(EVENTS.IE_Crull_Escape)
end]]
--[[Crull stands on top of a cliff and is seen]] function Rule_IE_Crull_Detected()
Util_StartIntel(EVENTS.IE_Crull_Detected)
end
function Rule_IE_Crull_Duel_Challenge()
Util_StartIntel(EVENTS.IE_Crull_Duel_Challenge)
end
function Rule_IE_Gorgutz_Returns()
Util_StartIntel(EVENTS.IE_Gorgutz_Returns)
end
function Rule_IE_Gorgutz_Returns2()
Util_StartIntel(EVENTS.IE_Gorgutz_Returns2)
end
function Rule_IE_Ork_Reinforce1()
Util_StartIntel(EVENTS.IE_Ork_Reinforce1)
end
function Rule_IE_Ork_Reinforce2()
Util_StartIntel(EVENTS.IE_Ork_Reinforce2)
end
--[[Final duel]] --[[ function Rule_IE_Final_Duel()
Util_StartIntel(EVENTS.IE_Final_Duel)
end]] --[[ function Rule_IE_Commissar_Encourage()
Util_StartIntel(EVENTS.IE_Commissar_Encourage)
end]]
function Rule_IE_Lost_Boyz()
Util_StartIntel(EVENTS.IE_Lost_Boyz)
end --[[ function Rule_IE_Gorgutz_Orders_Attack_On_Necron() Util_StartIntel(EVENTS.IE_Gorgutz_Orders_Attack_On_Necron) end]]
function Rule_IE_Necrons_Destroyed() Util_StartIntel(EVENTS.IE_Necrons_Destroyed) end
--[[ CHEATS ]]
function CheatClosing()
Rule_RemoveAll()
Util_StartNIS(EVENTS.NIS_Closing)
end
function CheatMissionMoment()
Rule_RemoveAll()
Util_StartNIS(EVENTS.NIS_Moment)
end
function CheatMissionTwist()
Rule_RemoveAll()
Util_StartNIS(EVENTS.NIS_Twist)
end
function CheatMidMissionName()
Rule_RemoveAll()
Util_StartNIS(EVENTS.NIS_MidName)
end