--IMPORTS
import("ScarUtil.scar")
--GAME SETUP
function OnGameSetup()
-- setup players. you only need to do this for players that have a starting point
g_Player1 = Setup_Player(0, "$223011", "space_marine_race", 1)
g_Player2 = Setup_Player(1, "$223012", "ork_race", 2)
g_Player3 = Setup_Player(2, "$223013", "npc_race", 1)
g_Player4 = Setup_Player(3, "$223014", "space_marine_race", TEAM_NEUTRAL)
g_Player5 = Setup_Player(4, "$223012", "ork_race", 2)
--[[variables]]
g_lockedtank = 0
g_lockedkan = 0
g_lockedtrak = 0
g_fighttrigger = 0
g_artycounter = 0
t_capturegroups = {"eg_point1", "eg_point2", "eg_point3", "eg_point4", "eg_point5", "eg_point6", "eg_point7", "eg_point8", "eg_point9" }
t_capturespawn = {"mkr_orkbase1"}
g_capturelevel = 0
g_vehicletrigger = 0
g_previous = 0
t_difficulty = {}
t_diff_normal = {hqarmour = 0.95, banneraccuracy = 0.3, postaccuracy = 0.3, turretaccuracy = 0.3, tanknum = 1, kannum = 1, traknum = 2, angrymob = 1, RT_Pop = 30, RT_Power = 500, RT_Requisition = 500 }
t_diff_hard = {hqarmour = 1, banneraccuracy = 0.7, postaccuracy = 0.7, turretaccuracy = 0.7, tanknum = 2, kannum = 2, traknum = 3, angrymob = 2, RT_Pop = 50, RT_Power = 700, RT_Requisition = 700 }
t_diff_advance = {hqarmour = 1.1, banneraccuracy = 1, postaccuracy = 1, turretaccuracy = 1, tanknum = 2, kannum = 2, traknum = 5, angrymob = 3, RT_Pop = 80, RT_Power = 1000, RT_Requisition = 1000 }
g_cividelay = 0
g_civilimit = 0
g_civigen = 1
g_tooearlyfortraks = 1
g_tooearlyforkans = 1
g_tooearlyforlootaz = 1
g_vehiclecontroliterations = 0
t_BaseDefense = {
sgroup = { "sg_hut1", "sg_hut2", "sg_hut3", "sg_hut4", "sg_hut5"},
egroup = { "eg_hut1", "eg_hut2", "eg_hut3", "eg_hut4", "eg_hut5"},
blueprint = {"ork_squad_slugga", "ork_squad_shoota_boy", "ork_squad_slugga", "ork_squad_shoota_boy", "ork_squad_slugga"},
marker = {"mkr_hut1", "mkr_hut2", "mkr_hut3", "mkr_hut4", "mkr_hut5"},
num = {1,1,1,1,1,1,1,1},
size = {6, 6, 7, 8, 7, 1, 1, 1},
}
end
function OnGameRestore()
g_Player1 = World_GetPlayerAt(0)
g_Player2 = World_GetPlayerAt(1)
g_Player3 = World_GetPlayerAt(2)
g_Player4 = World_GetPlayerAt(3)
g_Player5 = World_GetPlayerAt(4)
end
--ON INITIALIZATION
function OnInit()
--[[event cue]]
EventCue_Enable(false)
--[[hide things]]
EGroup_DeSpawn("eg_END_buildings")
--[[FOW]]
FOW_RevealAll()
World_EnablePlayerToPlayerFOW(g_Player1, g_Player3, false);
World_EnablePlayerToPlayerFOW(g_Player1, g_Player4, true);
--[[Set Cpu]]
Cpu_Enable(g_Player1, 0)
Cpu_Enable(g_Player2, 0)
Cpu_Enable(g_Player3, 0)
Cpu_Enable(g_Player4, 0)
Cpu_Enable(g_Player5, 0)
--[[FC sword]]
SetCommanderPowerSword(g_Player1)
--[[ Preset Stage for NIS]] Fade_Start( 0, false ) W40k_Letterbox( true, 0 )
--[[Music]]
Rule_AddOneShot(SetupMusicPlaylist, 0.0)
--[[ --[[ making artillery blasts ]] Rule_AddInterval(Rule_TriggerRandomFX1,1); Rule_AddInterval(Rule_TriggerRandomFX2, 1); Rule_AddInterval(Rule_TriggerRandomFX3, 1); ]] Util_StartNIS(EVENTS.NIS_Opening); Rule_AddOneShot(Rule_FadeIn, 4)
--[[Get the Game Ready to Run]]
Rule_Add(Rule_MissionStart);
Rule_AddOneShot(SetDifficultyLevel, 0.0)
end
Scar_AddInit(OnInit)
function Rule_FadeIn()
Fade_Start(2, true)
end
-- MUSIC/SOUND
function SetupMusicPlaylist()
-- clear the current playlist Sound_PlaylistClear( PC_Music )
-- add tracks to the playlist
Sound_PlaylistAddTrack( PC_Music, "music_tank_march" )
Sound_PlaylistAddTrack( PC_Music, "music_urban_wasteland" )
Sound_PlaylistAddTrack( PC_Music, "music_theme_spacemarines_01" )
Sound_PlaylistAddTrack( PC_Music, "music_ork_theme" )
Sound_PlaylistAddTrack( PC_Music, "battle_ingame_01" )
-- mark these tracks to play randomly
Sound_PlaylistSetorder( PC_Music, false )
-- add 5 to 10 seconds silence between tracks
Sound_PlaylistSetSilence( PC_Music, 20, 70 )
Sound_PlaylistClear( PC_Ambient )
-- add tracks to the playlist
Sound_PlaylistAddTrack( PC_Ambient, "ambient_city" )
-- mark these tracks to play randomly
Sound_PlaylistSetorder( PC_Ambient, false )
-- add 5 to 10 seconds silence between tracks
Sound_PlaylistSetSilence( PC_Ambient, 5, 10 )
-- don't play yet
Sound_PlaylistStart(PC_Ambient)
Sound_PlaylistStart(PC_Music)
end
-- DIFFICULTY LEVEL
-- the functions here set the difficulty level for the mission. Should be called from OnGameSetup function SetDifficultyLevel()
local difficultyLevel = Difficulty_Get()
-- easy
if difficultyLevel == DIFFICULTY_EASY then
Difficulty_SetForPlayer(g_Player2, 0)
Cpu_SetDifficultyForDummies(g_Player2, AD_Standard)
Difficulty_SetForPlayer(g_Player5, 0)
Cpu_SetDifficultyForDummies(g_Player5, AD_Standard)
t_difficulty = t_diff_normal
-- medium
elseif difficultyLevel == DIFFICULTY_NORMAL then
Difficulty_SetForPlayer(g_Player2, 1)
Cpu_SetDifficultyForDummies(g_Player2, AD_Hard)
Difficulty_SetForPlayer(g_Player5, 1)
Cpu_SetDifficultyForDummies(g_Player5, AD_Hard)
t_difficulty = t_diff_hard
-- hard
elseif difficultyLevel == DIFFICULTY_HARD then
Difficulty_SetForPlayer(g_Player2, 2)
Cpu_SetDifficultyForDummies(g_Player2, AD_Advanced)
Difficulty_SetForPlayer(g_Player5, 2)
Cpu_SetDifficultyForDummies(g_Player5, AD_Advanced)
t_difficulty = t_diff_advance
end
Rule_AddOneShot(Rule_OrkDifficultyModifiers, 0.0)
end
function Rule_OrkDifficultyModifiers()
--[[Mod the armourclass of the Ork HQ]] local modifier_buildingarmourdecrease = Modifier_Create( MAT_EntityType, -- This modifier will be applied to a weapon type "armour_modifier", -- Modify the max range of the weapon MUT_Multiplication, -- use multiplication false, t_difficulty.hqarmour, "ork_hq" -- Do this to the sniper rifle )
g_modifier_buildingarmourdecrease = Modifier_ApplyToPlayer( modifier_buildingarmourdecrease, g_Player2 )
--[[Mod the accuracy of the Waaagh Banners]]
local modifier_weaponaccuracydecrease1 = Modifier_Create(
MAT_WeaponType, -- This modifier will be applied to a weapon type
"accuracy_weapon_modifier", -- Modify the max range of the weapon
MUT_Multiplication, -- use multiplication
false,
t_difficulty.banneraccuracy,
"ork_shoota_turret_waaaghbanner" -- Do this to the sniper rifle
)
g_modifier_weaponaccuracydecrease1 = Modifier_ApplyToPlayer( modifier_weaponaccuracydecrease1, g_Player2 )
--[[Mod the accuracy of the Ork Listening Posts]]
local modifier_weaponaccuracydecrease2 = Modifier_Create(
MAT_WeaponType, -- This modifier will be applied to a weapon type
"accuracy_weapon_modifier", -- Modify the max range of the weapon
MUT_Multiplication, -- use multiplication
false,
t_difficulty.postaccuracy,
"ork_shoota_turret_listeningpost" -- Do this to the sniper rifle
)
g_modifier_weaponaccuracydecrease2 = Modifier_ApplyToPlayer( modifier_weaponaccuracydecrease2, g_Player2 )
--[[Mod the accuracy of the Ork Boy Hutz]]
local modifier_weaponaccuracydecrease3 = Modifier_Create(
MAT_WeaponType, -- This modifier will be applied to a weapon type
"accuracy_weapon_modifier", -- Modify the max range of the weapon
MUT_Multiplication, -- use multiplication
false,
t_difficulty.turretaccuracy,
"ork_shoota_turret" -- Do this to the sniper rifle
)
g_modifier_weaponaccuracydecrease2 = Modifier_ApplyToPlayer( modifier_weaponaccuracydecrease3, g_Player2 )
end
--[[ RANDOM FX FOR THE NIS ]]
function Rule_TriggerRandomFX1() local markername = "mkr_guardpost2" local eventfile = "data:Art/Events/ground_impact/Impact_Artillery_L_Dirt.events" local radius = 30 local frequency = 3
if 1 < World_GetRand(1, frequency) then
Deg_RandomAreaFX(markername, eventfile, radius)
end
end
function Rule_TriggerRandomFX2() local markername = "mkr_guardpost1" local eventfile = "data:Art/Events/ground_impact/Impact_Artillery_L_Dirt.events" local radius = 30 local frequency = 3
if 1 < World_GetRand(1, frequency) then
Deg_RandomAreaFX(markername, eventfile, radius)
end
end
function Rule_TriggerRandomFX3() local markername = "mkr_center" local eventfile = "data:Art/Events/ground_impact/Impact_Artillery_L_Dirt.events" local radius = 25 local frequency = 3
if 1 < World_GetRand(1, frequency) then
Deg_RandomAreaFX(markername, eventfile, radius)
end
end
function Deg_RandomAreaFX (markername, eventfile, radius)
local t_pos = Marker_GetPosition ( Marker_FromName( markername, "basic_marker" ) );
-- World_GetRandseed(t_pos.x) local t_posfinal = t_pos t_posfinal.z = t_posfinal.z + World_GetRand ((-1radius), radius); t_posfinal.x = t_posfinal.x + World_GetRand ((-1radius), radius);
World_FXEvent (eventfile, t_posfinal)
end
--[[ MAIN SCRIPT ]] function Rule_MissionStart()
if not W40k_IsLetterboxed() then
Sound_PlaylistPlayNow(PC_Music, "music_ork_theme")
--[[FOW]]
-- FOW_Reset()
--[[Lock Stuff]]
Restrict_SpaceMarines( g_Player1, 3 )
--[[Grant Stuff]]
Player_SetResource(g_Player1, RT_Requisition, 1000)
Player_SetResource(g_Player1, RT_Power, 500)
--[[Make Marine Base]]
Rule_AddInterval(Rule_VehicleShop, 2)
--[[Start Conflicts]]
Cpu_Enable(g_Player2, true)
--[[Safety Nets]]
Rule_AddInterval(Rule_TheReturners, 3)
--[[ Check on Guard ]]
Rule_AddOneShot(Rule_EarlyFights, 0)
--[[Spawn Orks]]
--[[ Rule_AddOneShot(Rule_StartOrksMoving, 0.0) ]] Rule_AddInterval(Rule_BaseDefense, 30) Rule_AddInterval(Rule_DefaultDefenders, 10) Rule_AddInterval(Rule_ControlPlayer2Vehicles, 10)
--[[ork angry mob]]
Rule_AddOneShot(Rule_AngryOrks, 30)
Cpu_Enable(g_Player5, true)
--[[Set Objectives]]
obj_table_RetakeCity = { title_id = 224001, short_desc_id = 224002, help_tip_id = 224003 }
obj_table_CapturePoints = { title_id = 224011, short_desc_id = 224012, help_tip_id = 224013 }
obj_table_DestroyBuildings = { title_id = 224021, short_desc_id = 224022, help_tip_id = 224023 }
obj_table_LostTroop = { title_id = 224025, short_desc_id = 224026, help_tip_id = 224027 }
Rule_AddOneShot(Rule_Objective_RetakeCity, 0.0)
Rule_AddOneShot(Rule_Objective_CapturePoints, 30)
Rule_AddInterval(Rule_Objective_LostTroop_Trigger, 2)
Rule_AddInterval(Rule_Objective_DestroyBuildings_Trigger, 2)
--[[ End game ]]
Rule_AddInterval(Rule_FinalBaseDead, 10)
Rule_AddInterval(Rule_AllOrkHutsDead, 5)
Rule_AddInterval(Rule_AllPointsCaptured, 6)
Rule_AddOneShot(Rule_Unrestrict_Cheat, 5)
--[[Keep Player 2 afloat with resources]]
Rule_AddInterval(Rule_Player2Income, 2)
Rule_AddOneShot(Rule_Player2Lock, 0.0)
--[[Add Civis]]
Rule_AddInterval(Rule_Civis, 1)
Rule_AddInterval(Rule_PlayerLoses, 1)
Rule_Remove(Rule_MissionStart)
Rule_AddInterval(Rule_Autosave_223020, 1)
end
end
function Rule_Autosave_223020() if not Event_IsAnyRunning() then Rule_Remove(Rule_Autosave_223020) Util_Autosave("$223020") end end
--[[Keep player 2 afloat with resources]] function Rule_Player2Income()
if Player_GetResource(g_Player2, RT_Requisition) < t_difficulty.RT_Requisition then
Player_AddResource(g_Player2, RT_Requisition, 10)
-- print("player 2 has "..Player_GetResource(g_Player2, RT_Requisition).." requisition") end
if Player_GetResource(g_Player2, RT_Power) < t_difficulty.RT_Power then
Player_AddResource(g_Player2, RT_Power, 10)
-- print("player 2 has "..Player_GetResource(g_Player2, RT_Power).." power") end
if Player_GetResource(g_Player2, RT_Pop) < t_difficulty.RT_Pop then
Player_AddResource(g_Player2, RT_Pop, 1)
-- print("player 2 has "..Player_GetResource(g_Player2, RT_Pop).." orks") end
end
function Rule_ControlPlayer2Vehicles() local sgID = Player_GetSquads(g_Player2) local egID = Player_GetEntities(g_Player1) if EGroup_ContainsAddOn(egID, "space_marine_hq_addon_1", false) == false and g_vehiclecontroliterations < 30 then -- print("nothing allowd")
elseif Player_HasBuildingType(g_Player1, "space_marine_vehicle_building") == false and g_vehiclecontroliterations < 60 then
if g_tooearlyfortraks == 1 then
Player_UnRestrictSquad(g_Player2, "ork_squad_wartrak")
t_BaseDefense = {
sgroup = { "sg_hut1", "sg_hut2", "sg_hut3", "sg_hut4", "sg_hut5", "sg_shop1", "sg_shop2", "sg_shop3"},
egroup = { "eg_hut1", "eg_hut2", "eg_hut3", "eg_hut4", "eg_hut5", "eg_shop1", "eg_shop2", "eg_shop3"},
blueprint = {"ork_squad_slugga", "ork_squad_shoota_boy", "ork_squad_slugga", "ork_squad_shoota_boy", "ork_squad_slugga", "ork_squad_wartrak", "ork_squad_wartrak", "ork_squad_wartrak"},
marker = {"mkr_hut1", "mkr_hut2", "mkr_hut3", "mkr_hut4", "mkr_hut5", "mkr_shop1", "mkr_shop2", "mkr_shop3"},
num = {1,1,1,1,1,1,1,1},
size = {6, 6, 7, 8, 7, 1, 1, 1},
}
end
g_tooearlyfortraks = 0
-- print("traks allowed")
elseif g_vehiclecontroliterations > 120 and g_vehiclecontroliterations < 122 then
if g_tooearlyforkans == 1 then
Player_UnRestrictSquad(g_Player2, "ork_squad_killa_kan")
end
g_tooearlyfortraks = 0
g_tooearlyforkans = 0
-- print("traks and kans")
else
if g_tooearlyforlootaz == 1 then
Player_UnRestrictSquad(g_Player2, "ork_squad_looted_tank")
end
g_tooearlyfortraks = 0
g_tooearlyforkans = 0
g_tooearlyforlootaz = 0
-- print("traks and kans and tanks")
Rule_Remove(Rule_ControlPlayer2Vehicles)
end
g_vehiclecontroliterations = g_vehiclecontroliterations+1
end
--[[ Player 5 Aggressive Ork]] function Rule_AngryOrks()
Cpu_ForceAttack(g_Player5, g_Player1)
Rule_AddInterval(Rule_AngryOrkArmy, 30)
end
function Rule_AngryOrkArmy()
SGroup_CreateIfNotFound("sg_angrymob")
if SGroup_IsEmpty("sg_angrymob") then
local sgID = Player_GetSquads(g_Player2)
local count = SGroup_CountSpawned(sgID)
if count ~= 0 then
for i = count, 1, -1 do
if Squad_GetBlueprintName(SGroup_GetSpawnedSquadAt(sgID, i)) ~= "ork_squad_grot" then
if g_tooearlyfortraks == 1 then
if Squad_GetBlueprintName(SGroup_GetSpawnedSquadAt(sgID, i)) ~= "ork_squad_wartrak" or Squad_GetBlueprintName(SGroup_GetSpawnedSquadAt(sgID, i)) ~= "ork_squad_looted_tank" or Squad_GetBlueprintName(SGroup_GetSpawnedSquadAt(sgID, i)) ~= "ork_squad_killa_kan" then
SGroup_Add(SGroup_FromName("sg_angrymob"), SGroup_GetSpawnedSquadAt(sgID, i))
end
elseif g_tooearlyforkans == 1 then
if Squad_GetBlueprintName(SGroup_GetSpawnedSquadAt(sgID, i)) ~= "ork_squad_looted_tank" or Squad_GetBlueprintName(SGroup_GetSpawnedSquadAt(sgID, i)) ~= "ork_squad_killa_kan" then
SGroup_Add(SGroup_FromName("sg_angrymob"), SGroup_GetSpawnedSquadAt(sgID, i))
end
elseif g_tooearlyforlootaz == 1 then
if Squad_GetBlueprintName(SGroup_GetSpawnedSquadAt(sgID, i)) ~= "ork_squad_looted_tank" then
SGroup_Add(SGroup_FromName("sg_angrymob"), SGroup_GetSpawnedSquadAt(sgID, i))
end
else
SGroup_Add(SGroup_FromName("sg_angrymob"), SGroup_GetSpawnedSquadAt(sgID, i))
end
else
local num = World_GetRand(1, 2)
if num == 1 then
SGroup_Add(SGroup_CreateIfNotFound("sg_angrygrotz"), SGroup_GetSpawnedSquadAt(sgID, i))
Cpu_LockSGroup(g_Player2, "sg_angrygrotz")
Cmd_AttackMoveMarker("sg_angrygrotz", "mkr_city")
end
end
if SGroup_Count(SGroup_FromName("sg_angrymob")) == t_difficulty.angrymob then
break
end
end
SGroup_SetPlayerOwner("sg_angrymob", g_Player5)
SGroup_Clear(SGroup_FromName("sg_angrymob"))
else
Rule_Remove(Rule_AngryOrkArmy)
end
end
end
--[[Locking Player 2 Shwagg]] function Rule_Player2Lock()
Player_RestrictSquad(g_Player2, "ork_squad_bad_dok")
Player_RestrictSquad(g_Player2, "ork_squad_mek_boy")
Player_RestrictSquad(g_Player2, "ork_squad_nob")
Player_RestrictSquad(g_Player2, "ork_squad_squiggoth")
Player_RestrictSquad(g_Player2, "ork_squad_stormboy")
Player_RestrictSquad(g_Player2, "ork_squad_warboss")
Player_RestrictSquad(g_Player2, "ork_squad_trukk")
Player_RestrictSquad(g_Player2, "ork_squad_wartrak")
Player_RestrictSquad(g_Player2, "ork_squad_killa_kan")
Player_RestrictSquad(g_Player2, "ork_squad_looted_tank")
--[[Track the limit of higher end vehicles]]
Rule_AddInterval(Rule_TrackPlayer2Limits, 5)
end
function Rule_TrackPlayer2Limits() --[[ SGroup_AddGroup(SGroup_CreateIfNotFound("sg_player2monkeybottom"), Player_GetSquads(g_Player2)) SGroup_AddGroup(SGroup_CreateIfNotFound("sg_player2monkeybottom"), Player_GetSquads(g_Player5))
--[[checking looted tanks]]
tankblueprint = {
{ name = "ork_squad_looted_tank", count = 1 }
}
if SGroup_ContainsBlueprints("sg_player2monkeybottom", tankblueprint, true)
and Player_GetBlueprintCount(g_Player2, "ork_squad_looted_tank") >= t_difficulty.tanknum then
g_tanktoomany = 1
elseif SGroup_ContainsBlueprints("sg_player2monkeybottom", tankblueprint, true) then
--and Player_GetBlueprintCount(g_Player2, "ork_squad_looted_tank") < t_difficulty.tanknum then
g_tanktoomany = 0
end
if g_tanktoomany == 1 and g_lockedtank == 0 then
Player_RestrictSquad(g_Player2, "ork_squad_looted_tank")
g_lockedtank = 1
elseif g_tanktoomany == 0 and g_lockedtank == 1 then
Player_UnRestrictSquad(g_Player2, "ork_squad_looted_tank")
g_lockedtank = 0
end
--[[checking for kanz]]
kanblueprint = {
{ name = "ork_squad_killa_kan", count = 1 }
}
if SGroup_ContainsBlueprints("sg_player2monkeybottom", kanblueprint, true)
and Player_GetBlueprintCount(g_Player2, "ork_squad_killa_kan") > t_difficulty.kannum then
g_kantoomany = 1
elseif SGroup_ContainsBlueprints("sg_player2monkeybottom", kanblueprint, true) then
--and Player_GetBlueprintCount(g_Player2, "ork_squad_killa_kan") < t_difficulty.kannum then
g_kantoomany = 0
end
if g_kantoomany == 1 and g_lockedkan == 0 then
Player_RestrictSquad(g_Player2, "ork_squad_killa_kan")
g_lockedkan = 1
elseif g_kantoomany == 0 and g_lockedkan == 1 then
Player_UnRestrictSquad(g_Player2, "ork_squad_killa_kan")
g_lockedkan = 0
end
--[[checking for traks]]
trakblueprint = {
{ name = "ork_squad_wartrak", count = 1 }
}
if SGroup_ContainsBlueprints("sg_player2monkeybottom", trakblueprint, true)
and Player_GetBlueprintCount(g_Player2, "ork_squad_wartrak") > t_difficulty.traknum then
g_traktoomany = 1
elseif SGroup_ContainsBlueprints("sg_player2monkeybottom", trakblueprint, true) then
--and Player_GetBlueprintCount(g_Player2, "ork_squad_wartrak") < t_difficulty.traknum then
g_traktoomany = 0
end
if g_traktoomany == 1 and g_lockedtrak == 0 then
Player_RestrictSquad(g_Player2, "ork_squad_wartrak")
g_lockedtrak = 1
elseif g_traktoomany == 0 and g_lockedtrak == 1 then
Player_UnRestrictSquad(g_Player2, "ork_squad_wartrak")
g_lockedtrak = 0
end
]]
end
function Rule_TheReturners()
Util_TrackCharacterAndDropPodIn( g_Player1, "sg_NISgab", "space_marine_squad_force_commander", "mkr_city" )
Util_TrackCharacterAndDropPodIn( g_Player1, "sg_NISis", "space_marine_squad_librarian", "mkr_city" )
end
--[[Unlocking Player 1 Shwagg]] function Rule_Unrestrict_Cheat() Unrestrict_BuildingWithAlerts( g_Player1, "space_marine_turret_bolter", "$42950", 408046 )
Unrestrict_BuildingWithAlerts( g_Player1, "space_marine_mine_field", "$42954", 408050 )
Unrestrict_ResearchWithAlerts( g_Player1, "marine_health_upgrade_research_2", "none", "none" )
Unrestrict_ResearchWithAlerts( g_Player1, "marine_accuracy_upgrade_research_2", "none", "none" )
Unrestrict_ResearchWithAlerts( g_Player1, "marine_sergeant_melee_upgrade_2", "none", "none" )
Unrestrict_ResearchWithAlerts( g_Player1, "marine_sergeant_ranged_upgrade_1", "none","none" )
-- Unrestrict_ResearchWithAlerts( g_Player1, "marine_force_commander_research_2", "none", "none" )
-- Unrestrict_ResearchWithAlerts( g_Player1, "marine_librarian_research_2", "none", "none" )
-- Unrestrict_ResearchWithAlerts( g_Player1, "marine_commander_health_research_2", "none", "none" )
-- Unrestrict_ResearchWithAlerts( g_Player1, "marine_melta_bomb_research", "none", "none" )
-- Unrestrict_ResearchWithAlerts( g_Player1, "marine_smoke_launcher_research", "none", "none" )
-- Unrestrict_ResearchWithAlerts( g_Player1, "support_cap_research_1", "none", "none" ) -- Unrestrict_ResearchWithAlerts( g_Player1, "support_cap_research_2", "none", "none" )
-- Unrestrict_ResearchWithAlerts( g_Player1, "marine_requisition_research_1", "none", "none" )
Unrestrict_ResearchWithAlerts( g_Player1, "marine_power_research_1", "none", "none" )
end
--[[ MAIN SCRIPT ]] --[[OBJECTIVES ]] function Rule_Objective_RetakeCity() Util_StartIntel(EVENTS.IE_Objective_RetakeCity) Util_ObjectiveCreate(obj_table_RetakeCity, true) end
function Rule_Objective_CapturePoints() Util_StartIntel(EVENTS.IE_Objective_CapturePoints) Util_ObjectiveCreate(obj_table_CapturePoints, false) --[[ Rule_AddOneShot(Rule_IE_HoldRelics, 0.5) ]] end
function Rule_Objective_DestroyBuildings_Trigger() Player_GetAllSquadsNearPos(g_Player1, "sg_nearOrkHutz", Marker_GetPosition(Marker_FromName("mkr_hut1", "basic_marker")), 30) Player_GetAllSquadsNearPos(g_Player1, "sg_nearOrkHutz", Marker_GetPosition(Marker_FromName("mkr_hut2", "basic_marker")), 30) Player_GetAllSquadsNearPos(g_Player1, "sg_nearOrkHutz", Marker_GetPosition(Marker_FromName("mkr_hut3", "basic_marker")), 30) if SGroup_IsEmpty("sg_nearOrkHutz") == false then Rule_AddOneShot(Rule_Objective_DestroyBuildings, 0.0) Rule_Remove(Rule_Objective_DestroyBuildings_Trigger) end end
function Rule_Objective_DestroyBuildings() Util_StartIntel(EVENTS.IE_Objective_DestroyBuildings) Util_ObjectiveCreate(obj_table_DestroyBuildings, true) end
function Rule_Objective_LostTroop_Trigger() Player_GetAllSquadsNearPos(g_Player1, "sg_nearMachineCult", Marker_GetPosition(Marker_FromName("mkr_reinforce1_trigger", "basic_marker")), 45) if SGroup_IsEmpty("sg_nearMachineCult") == false then Rule_AddOneShot(Rule_Objective_LostTroop, 0.0) Rule_Remove(Rule_Objective_LostTroop_Trigger) end end
function Rule_Objective_LostTroop() Util_StartIntel(EVENTS.IE_Objective_LostTroop) Util_ObjectiveCreate(obj_table_LostTroop, false) end
--[[OBJ Conditions]]
function Rule_AllOrkHutsDead()
if EGroup_IsEmpty("eg_hut1") and EGroup_IsEmpty("eg_hut2") and EGroup_IsEmpty("eg_hut3") and EGroup_IsEmpty("eg_shop1") then
Util_ObjectiveComplete(obj_table_DestroyBuildings.title_id)
Rule_Remove(Rule_AllOrkHutsDead)
Rule_AddInterval(Rule_Autosave_223024, 1)
end
end
function Rule_Autosave_223024() if not Event_IsAnyRunning() then Rule_Remove(Rule_Autosave_223024) Util_Autosave("$223024") end end
function Rule_AllPointsCaptured()
if EGroup_IsCapturedByPlayer("eg_point1", g_Player1, false)
and EGroup_IsCapturedByPlayer("eg_point2", g_Player1, false)
and EGroup_IsCapturedByPlayer("eg_point3", g_Player1, false)
and EGroup_IsCapturedByPlayer("eg_point4", g_Player1, false)
and EGroup_IsCapturedByPlayer("eg_point5", g_Player1, false)
and EGroup_IsCapturedByPlayer("eg_point6", g_Player1, false)
and EGroup_IsCapturedByPlayer("eg_point7", g_Player1, false)
and EGroup_IsCapturedByPlayer("eg_point8", g_Player1, false)
and EGroup_IsCapturedByPlayer("eg_point9", g_Player1, false)
then
Util_ObjectiveComplete(obj_table_CapturePoints.title_id)
Rule_Remove(Rule_AllPointsCaptured)
end
end
--[[INTEL EVENTS ]] function Rule_IE_TothCommand() Util_StartIntel(EVENTS.IE_TothCommand) end
function Rule_IE_GabrielArrives() Util_StartIntel(EVENTS.IE_GabrielArrives) end
function Rule_IE_CaptureRelics() Util_StartIntel(EVENTS.IE_CaptureRelics) end
function Rule_IE_DestroyBases() Util_StartIntel(EVENTS.IE_DestroyBases) end
function Rule_IE_HoldRelics() Util_StartIntel(EVENTS.IE_HoldRelics) end
--[[ Early Fights ]] function Rule_EarlyFights()
-- if g_fighttrigger == 0 then
Util_CreateSquadsAtMarkerRandomEx(g_Player1, "sg_guardpost1", "guard_squad_soldier", "mkr_guardpost1", 2, 8)
-- Util_CreateSquadsAtMarkerRandomEx(g_Player2, "sg_orkpost1", "ork_squad_slugga", "mkr_guardpost1", 2, 5)
Util_CreateSquadsAtMarkerRandomEx(g_Player1, "sg_guardpost2", "guard_squad_soldier", "mkr_guardpost2", 2, 8)
--[[ Util_CreateSquadsAtMarkerRandomEx(g_Player2, "sg_orkpost2", "ork_squad_slugga", "mkr_guardpost2", 2, 5)
g_fighttrigger = 1
else
SGroup_CreateIfNotFound("sg_guardposts")
SGroup_Clear(SGroup_FromName("sg_guardposts"))
Player_GetAllSquadsNearMarker(g_Player1, "sg_guardposts", "mkr_guardpost1")
Player_GetAllSquadsNearMarker(g_Player1, "sg_guardposts", "mkr_guardpost2")
if SGroup_IsEmpty("sg_guardposts") ~= true then
SGroup_SetPlayerOwner("sg_guardpost1", g_Player1)
SGroup_SetPlayerOwner("sg_guardpost2", g_Player1)
Ping_Marker("mkr_guardpost1", false)
Ping_Marker("mkr_guardpost2", false)
Rule_Remove(Rule_EarlyFights)
end
end
]] end
--[[ MARINE VEHICLE UPGRADE ]] function Rule_VehicleShop()
if g_vehicletrigger == 0 then
EGroup_SetPlayerOwner("eg_smreinforce", g_Player4)
Entity_ResetConstructionState(EGroup_GetSpawnedEntityAt(EGroup_FromName("eg_smreinforce"), 1))
Util_CreateSquadsAtMarker(g_Player4,"eg_smreinforce1", "space_marine_squad_dreadnought", "mkr_reinforce1", 1)
-- Util_CreateSquadsAtMarker(g_Player4,"eg_smreinforce1", "space_marine_squad_dreadnought_hellfire", "mkr_reinforce1", 1)
g_vehicletrigger = 1
else
SGroup_CreateIfNotFound("sg_smreinforce1")
SGroup_Clear(SGroup_FromName("sg_smreinforce1"))
local sgroupID = Player_GetAllSquadsNearMarker(g_Player1, "sg_smreinforce1", "mkr_reinforce1")
if SGroup_IsEmpty("sg_smreinforce1") ~= true then
EGroup_SetPlayerOwner("eg_smreinforce", g_Player1)
SGroup_SetPlayerOwner("eg_smreinforce1", g_Player1)
Ping_Marker("mkr_reinforce1", false)
Util_StartIntel(EVENTS.IE_Objective_LostTroop_Complete)
Util_ObjectiveComplete(obj_table_LostTroop.title_id)
Unrestrict_ResearchWithAlerts( g_Player1, "support_cap_research", "none", "none" )
Player_UnRestrictBuilding(g_Player1, "space_marine_vehicle_building")
Rule_AddInterval(Rule_VehicleshopConstructed, 1)
Rule_Remove(Rule_VehicleShop)
Rule_AddInterval(Rule_Autosave_223022, 1)
end
end
end
function Rule_Autosave_223022() if not Event_IsAnyRunning() then Rule_Remove(Rule_Autosave_223022) Util_Autosave("$223022") end end
function Rule_VehicleshopConstructed() if Player_HasBuildingType(g_Player1, "space_marine_vehicle_building") then Unrestrict_SquadWithAlerts( g_Player1, "space_marine_squad_dreadnought", "$42922", 408018 ) Rule_Remove(Rule_VehicleshopConstructed) end end
--[[ THE ORKS! ]] function Rule_StartOrksMoving()
--[[ Ork Rally Points ]]
Rule_AddInterval(Rule_RallyManagerBasic, 32)
t_rallymarker = {"mkr_deeprally1", "mkr_deeprally2", "mkr_deeprally3"}
--[[ Ork Strike Teams ]]
Rule_AddInterval(Rule_OrkTeams, 32)
Rule_AddOneShot(Rule_tempKanDelay, 500)
Rule_AddInterval(Rule_ArtilleryTeams, 67)
--[[Ork Base Defense ]]
Rule_AddInterval(Rule_BaseDefense, 2)
--[[ Capturing Orks
Rule_AddInterval(Rule_OrkCapturing, 14)
Rule_AddInterval(Rule_BuildDaPosts, 18)
]] end
function Rule_tempKanDelay()
Rule_AddInterval(Rule_KanzTeams, 45)
end
--[[ MAKING ORKS TO CAPTURE THE POINTS!!! ]] --[[ CREATE SOME NOBZ TO SET ABOUT CAPTURING POINTS, ONE POINT AT A TIME ]] function Rule_OrkCapturing()
if EGroup_IsEmpty("eg_OrkHQ") then
Rule_Remove(Rule_OrkCapturing)
end
SGroup_CreateIfNotFound("sg_capturingnobz")
if SGroup_IsEmpty("sg_capturingnobz") then
Util_CreateSquadsAtMarkerRandom(g_Player2, "sg_capturingnobz", "ork_squad_nob", t_capturespawn[1], 1)
end
for i = 1, table.getn(t_capturegroups) do
if EGroup_IsCapturedByPlayer(t_capturegroups[i], g_Player2, false) == true then
g_capturelevel = t_capturegroups[i]
if i == table.getn(t_capturegroups) then
Rule_Remove(Rule_OrkCapturing);
break
end
elseif EGroup_IsCapturedByPlayer(t_capturegroups[i], g_Player2, false) ~= true then
if not EGroup_HasStrategicPointWithStructure(t_capturegroups[i]) then
Cmd_Capture("sg_capturingnobz", t_capturegroups[i])
end
break
elseif EGroup_IsCapturedByPlayer(t_capturegroups[i], g_Player1, false) == true then
Cmd_AttackMovePos("sg_capturingnobz", Entity_GetPosition(EGroup_GetSpawnedEntityAt(EGroup_FromName(t_capturegroups[i]), 1)))
break
end
end
end
--[[ MAKE DA GROTZ ]] function Rule_BuildDaPosts()
if EGroup_IsEmpty("eg_OrkHQ") then
Rule_Remove(Rule_BuildDaPosts)
end
if g_previous ~= g_capturelevel then
local num = Util_GetTrailingNumber(g_capturelevel)
SGroup_CreateIfNotFound("sg_capturegrotz")
if SGroup_IsEmpty("sg_capturegrotz") then
Util_CreateSquadsAtMarkerEx(g_Player2, "sg_capturegrotz", "ork_squad_grot", t_capturespawn[1], 1, 9)
end
if not EGroup_Exists("eg_post"..num) then
EGroup_CreateIfNotFound("eg_post"..num)
if EGroup_IsEmpty("eg_post"..num) and EGroup_IsCapturedByPlayer("eg_point"..num, g_Player2, false) then
Cmd_ConstructBlueprintOnEGroup("sg_capturegrotz", "ork_gork_totem", g_capturelevel)
end
elseif EGroup_IsEmpty("eg_post"..num) and EGroup_IsCapturedByPlayer("eg_point"..num, g_Player2, false) then
Cmd_ConstructBlueprintOnEGroup("sg_capturegrotz", "ork_gork_totem", g_capturelevel)
end
end
g_previous = g_capturelevel
end
--[[ MAKING ORK STRIKE TEAMS ]]
--[[ Ork Teams ]] function Rule_OrkTeams()
t_OrkTeams = {
sgroup = { "sg_orkhut1", "sg_orkhut2", "sg_orkhut3"},
egroup = { "eg_hut1", "eg_hut2", "eg_hut3"},
egroup2 = { "eg_hut4", "eg_hut5", "eg_hut5"},
blueprint = {"ork_squad_grot", "ork_squad_shoota_boy", "ork_squad_slugga"},
marker = {"mkr_hut1", "mkr_hut2", "mkr_hut3"},
marker2 = {"mkr_hut4", "mkr_hut5", "mkr_hut5"},
num = {1,1, 1},
upgrade = {0, 0, 0},
load = {1},
weapon = {"weapon"}
}
if table.getn(t_OrkTeams.sgroup) < 1 then
Rule_Remove(Rule_OrkTeams)
else
SGroup_CreateIfNotFound("sg_nearOrkTeambase")
--[[ going to iterate over the group ]] for i = table.getn(t_OrkTeams.egroup), 1, -1 do
SGroup_CreateIfNotFound(t_OrkTeams.sgroup[i])
local rand = World_GetRand(4, 7)
--[[ checking to see if the first set of Boy Hutz still exists ]]--------------------------------------------------------------------------------------------------------- if not EGroup_IsEmpty(t_OrkTeams.egroup[i]) then
SGroup_Clear(SGroup_FromName("sg_nearOrkTeambase"))
local sgroupID = Player_GetAllSquadsNearMarker(g_Player1, "sg_nearOrkTeambase", t_OrkTeams.marker[i])
if SGroup_IsEmpty("sg_nearOrkTeambase") == true and SGroup_Count(SGroup_FromName( t_OrkTeams.sgroup[i])) < 2 then
local num = World_GetRand(1, table.getn(t_OrkTeams.blueprint))
Util_CreateSquadsAtMarkerEx(g_Player2, t_OrkTeams.sgroup[i],t_OrkTeams.blueprint[num],t_OrkTeams.marker[i], t_OrkTeams.num[i], rand)
if t_OrkTeams.upgrade[i] == 1 then
for y = 1,t_OrkTeams.load[i] do
SGroup_ForEach( t_OrkTeams.sgroup[i], function( sgroupid, itemindex, squadID ) Squad_UpgradeWeapon( squadID, t_OrkTeams.weapon[i]) end )
end
end
Cmd_SetStance(t_OrkTeams.sgroup[i], STANCE_Attack)
Cmd_AttackMoveMarker(t_OrkTeams.sgroup[i], t_rallymarker[i])
end
--[[ if the first Boy Hut is empty, check the second ]]--------------------------------------------------------------------------------------------------------- elseif EGroup_IsEmpty(t_OrkTeams.egroup2[i]) ~= true then
SGroup_Clear(SGroup_FromName("sg_nearOrkTeambase"))
local sgroupID = Player_GetAllSquadsNearMarker(g_Player1, "sg_nearOrkTeambase", t_OrkTeams.marker[i])
if SGroup_IsEmpty("sg_nearOrkTeambase") == true and SGroup_Count(SGroup_FromName( t_OrkTeams.sgroup[i])) < 2 then
local num = World_GetRand(1, table.getn(t_OrkTeams.blueprint))
Util_CreateSquadsAtMarkerEx(g_Player2, t_OrkTeams.sgroup[i],t_OrkTeams.blueprint[num],t_OrkTeams.marker2[i], t_OrkTeams.num[i], rand)
if t_OrkTeams.upgrade[i] == 1 then
for y = 1,t_OrkTeams.load[i] do
SGroup_ForEach( t_OrkTeams.sgroup[i], function( sgroupid, itemindex, squadID ) Squad_UpgradeWeapon( squadID, t_OrkTeams.weapon[i]) end )
end
end
Cmd_SetStance(t_OrkTeams.sgroup[i], STANCE_Attack)
Cmd_AttackMoveMarker(t_OrkTeams.sgroup[i], t_rallymarker[i])
end
--[[ if both Hutz are destroyed then remove the sgroup ]]--------------------------------------------------------------------------------------------------------- else table.remove(t_OrkTeams.egroup2, i) table.remove(t_OrkTeams.egroup, i) table.remove(t_OrkTeams.sgroup, i) table.remove(t_OrkTeams.marker2, i) table.remove(t_OrkTeams.marker, i) end end
end
end
--[[ KANZ Teams ]] function Rule_KanzTeams()
t_KanzTeams = {
sgroup = { "sg_shopkan1", "sg_shopkan2", "sg_shopkan3"},
egroup = { "eg_shop1", "eg_shop2", "eg_shop3"},
marker = {"mkr_shop1", "mkr_shop2", "mkr_shop3"},
num = {1,1, 1},
}
if table.getn(t_KanzTeams.sgroup) < 1 then
Rule_Remove(KanzTeams)
else
SGroup_CreateIfNotFound("sg_nearKanbase")
for i = table.getn(t_KanzTeams.egroup), 1, -1 do
SGroup_CreateIfNotFound(t_KanzTeams.sgroup[i])
if not EGroup_IsEmpty(t_KanzTeams.egroup[i]) then
SGroup_Clear(SGroup_FromName("sg_nearKanbase"))
local sgroupID = Player_GetAllSquadsNearMarker(g_Player1, "sg_nearKanbase", t_KanzTeams.marker[i])
if SGroup_IsEmpty("sg_nearKanbase") == true and SGroup_Count(SGroup_FromName(t_KanzTeams.sgroup[i])) < 1 then
Util_CreateSquadsAtMarker(g_Player2, t_KanzTeams.sgroup[i], "ork_squad_killa_kan", t_KanzTeams.marker[i], t_KanzTeams.num[i])
Cmd_SetStance(t_KanzTeams.sgroup[i], STANCE_Attack)
Cmd_AttackMoveMarker(t_KanzTeams.sgroup[i], t_rallymarker[i])
end
else
table.remove(t_KanzTeams.egroup, i)
table.remove(t_KanzTeams.sgroup, i)
table.remove(t_KanzTeams.marker, i)
end
end
end
end
--[[ Artillery ]] function Rule_ArtilleryTeams()
t_ArtilleryTeams = {
sgroup = { "sg_shoparty1", "sg_shoparty2", "sg_shoparty3", "sg_shoparty4"},
egroup = { "eg_shop1", "eg_shop1", "eg_shop3", "eg_shop2"},
marker = {"mkr_shop1", "mkr_shop1", "mkr_shop3", "mkr_shop2"},
marker2 = {"mkr_arty1", "mkr_arty2", "mkr_arty3", "mkr_arty4"},
num = {1,1, 1, 1},
}
if table.getn(t_ArtilleryTeams.sgroup) < 1 then
Rule_Remove(ArtilleryTeams)
else
SGroup_CreateIfNotFound("sg_nearArtbase")
for i = table.getn(t_ArtilleryTeams.egroup), 1, -1 do
SGroup_CreateIfNotFound(t_ArtilleryTeams.sgroup[i])
if not EGroup_IsEmpty(t_ArtilleryTeams.egroup[i]) then
SGroup_Clear(SGroup_FromName("sg_nearArtbase"))
local sgroupID = Player_GetAllSquadsNearMarker(g_Player1, "sg_nearArtbase", t_ArtilleryTeams.marker[i])
if SGroup_IsEmpty("sg_nearArtbase") == true and SGroup_Count(SGroup_FromName(t_ArtilleryTeams.sgroup[i])) < 1 then
if g_artycounter < 30 then
g_artycounter = g_artycounter+1
else
Util_CreateSquadsAtMarker(g_Player2, t_ArtilleryTeams.sgroup[i], "ork_squad_looted_tank", t_ArtilleryTeams.marker[i], t_ArtilleryTeams.num[i])
Cmd_SetStance(t_ArtilleryTeams.sgroup[i], STANCE_Attack)
Cmd_AttackMoveMarker(t_ArtilleryTeams.sgroup[i], t_ArtilleryTeams.marker2[i])
g_artycounter = 0
end
end
else
table.remove(t_ArtilleryTeams.egroup, i)
table.remove(t_ArtilleryTeams.sgroup, i)
table.remove(t_ArtilleryTeams.marker, i)
end
end
end
end
--[[ CONTROLLING THE RALLY MARKERS ]]
function Rule_RallyManagerBasic()
if EGroup_IsEmpty("eg_hut1") and EGroup_IsEmpty("eg_hut2") and EGroup_IsEmpty("eg_hut3") then
t_rallymarker = {"mkr_midrally1", "mkr_midrally2", "mkr_midrally3"}
elseif Deg_GroupCapturedbyPlayer(g_Player1, {"eg_point7", "eg_point8"}) == true then
t_rallymarker = {"mkr_frontrally1", "mkr_frontrally2", "mkr_frontrally3"}
elseif Deg_GroupCapturedbyPlayer(g_Player1, {"eg_point7", "eg_point8"}) == false then
t_rallymarker = {"mkr_deeprally1", "mkr_deeprally2", "mkr_deeprally3"}
end
end
function Deg_GroupCapturedbyPlayer(playername, tablename)
local capture = 0
for i = 1, table.getn(tablename) do
if EGroup_IsCapturedByPlayer(tablename[i], playername, false) then
capture = 1
else
capture = 0
break
end
end
if objexists == 1 then
return true
else
return false
end
end
function Rule_FinalBaseDead()
--[[ EGroup_AddGroup(EGroup_CreateIfNotFound("eg_Player2All"), Player_GetEntities(g_Player2))
local blueprinttable = {
{ name = "ork_boy_hut", count = 1 },
{ name = "ork_generator", count = 1 },
{ name = "ork_hq", count = 1 },
{ name = "ork_mek_shop", count = 1 },
{ name = "ork_pile_o_guns", count = 1 }
}
local Rule_AddBuildings = function( egroupid, itemindex, entityID )
if Entity_GetBlueprintName(entityID) == "ork_boy_hut"
or Entity_GetBlueprintName(entityID) == "ork_generator"
or Entity_GetBlueprintName(entityID) == "ork_hq"
or Entity_GetBlueprintName(entityID) == "ork_mek_shop"
or Entity_GetBlueprintName(entityID) == "ork_pile_o_guns"
then
EGroup_Add(EGroup_CreateIfNotFound("eg_Orkendbase"), entityID)
end
end
]]
if Player_HasBuildingType(g_Player2, "ork_boy_hut") == false
and Player_HasBuildingType(g_Player2, "ork_generator") == false
and Player_HasBuildingType(g_Player2, "ork_hq") == false
and Player_HasBuildingType(g_Player2, "ork_mek_shop") == false
and Player_HasBuildingType(g_Player2, "ork_pile_o_guns") == false then
-- print("Player 2's bases have been Anihilated") Util_ObjectiveComplete(obj_table_RetakeCity.title_id) if Objective_Exists(obj_table_LostTroop.title_id) and Objective_GetState(obj_table_LostTroop.title_id) == OS_Incomplete then Util_ObjectiveFail(obj_table_LostTroop.title_id) end if Objective_Exists(obj_table_CapturePoints.title_id) and Objective_GetState(obj_table_CapturePoints.title_id) == OS_Incomplete then Util_ObjectiveFail(obj_table_CapturePoints.title_id) end if Objective_Exists(obj_table_DestroyBuildings.title_id) and Objective_GetState(obj_table_DestroyBuildings.title_id) == OS_Incomplete then Util_ObjectiveFail(obj_table_DestroyBuildings.title_id) end Rule_AddOneShot(Rule_CallEndNIS, 4) g_baseisdead = 1 --Rule_Remove(Rule_FinalBaseDead) else -- EGroup_ForEach(EGroup_FromName("eg_Player2All"), Rule_AddBuildings) g_baseisdead = 0 -- print("Player 2's base complex has "..EGroup_Count(EGroup_FromName("eg_Orkendbase")).." entities") end
end
function Rule_CallEndNIS() Rule_RemoveAll() Util_StartNIS(EVENTS.NIS_Closing) end
--[[ Default Defenders]] function Rule_DefaultDefenders()
SGroup_AddGroup(SGroup_CreateIfNotFound("sg_player2army"), Player_GetSquads(g_Player2))
-- print("player 2's army has "..SGroup_Count(SGroup_FromName("sg_player2army")).." squads in it")
if table.getn(t_BaseDefense.egroup) < 1 then
Rule_Remove(Rule_DefaultDefenders)
elseif SGroup_Count(SGroup_FromName("sg_player2army")) < 5 then
-- for i = table.getn(t_BaseDefense.egroup), 1, -1 do local i = World_GetRand(1, table.getn(t_BaseDefense.egroup))
SGroup_CreateIfNotFound(t_BaseDefense.sgroup[i])
if not EGroup_IsEmpty(t_BaseDefense.egroup[i]) then
Util_CreateSquadsAtMarkerEx(g_Player2, t_BaseDefense.sgroup[i],t_BaseDefense.blueprint[i],t_BaseDefense.marker[i], t_BaseDefense.num[i], t_BaseDefense.size[i])
else
table.remove(t_BaseDefense.egroup, i)
table.remove(t_BaseDefense.sgroup, i)
table.remove(t_BaseDefense.marker, i)
end
-- end
end
end
--[[ BASE DEFENSE]] function Rule_BaseDefense()
SGroup_AddGroup(SGroup_CreateIfNotFound("sg_player2army_2"), Player_GetSquads(g_Player2))
t_BaseDefense_v2 = {
sgroup = { "sg_hut1v2", "sg_hut2v2", "sg_hut3v2", "sg_hut4v2", "sg_hut5v2", "sg_shop1v2", "sg_shop2v2", "sg_shop3v2", "sg_breach1v2", "sg_breach2v2", "sg_breach3v2"},
egroup = { "eg_hut1", "eg_hut2", "eg_hut3", "eg_hut4", "eg_hut5", "eg_shop1", "eg_shop2", "eg_shop3", "eg_hut5", "eg_shop3", "eg_shop2"},
marker = {"mkr_hut1", "mkr_hut2", "mkr_hut3", "mkr_hut4", "mkr_hut5", "mkr_shop1", "mkr_shop2", "mkr_shop3", "mkr_breach1", "mkr_breach2", "mkr_breach3"},
}
if table.getn(t_BaseDefense_v2.egroup) < 1 then
Rule_Remove(Rule_BaseDefense)
else
SGroup_CreateIfNotFound("sg_nearbasev2")
for i = table.getn(t_BaseDefense_v2.egroup), 1, -1 do
SGroup_CreateIfNotFound(t_BaseDefense_v2.sgroup[i])
if not EGroup_IsEmpty(t_BaseDefense_v2.egroup[i]) then
SGroup_Clear(SGroup_FromName("sg_nearbasev2"))
local sgroupID = Player_GetAllSquadsNearMarker(g_Player1, "sg_nearbasev2", t_BaseDefense_v2.marker[i])
if SGroup_IsEmpty("sg_nearbasev2") == false then
local count = SGroup_Count(SGroup_FromName("sg_player2army_2"))
for y = 1, math.ceil(count*0.25) do
SGroup_Add (SGroup_FromName(t_BaseDefense_v2.sgroup[i]), SGroup_GetSpawnedSquadAt(SGroup_FromName("sg_player2army_2"), y) )
end
Cpu_LockSGroup(g_Player2, t_BaseDefense_v2.sgroup[i])
Cmd_SetStance(t_BaseDefense_v2.sgroup[i], STANCE_Attack)
Cmd_AttackMoveMarker(t_BaseDefense_v2.sgroup[i], t_BaseDefense_v2.marker[i])
elseif SGroup_IsEmpty("sg_nearbasev2") and SGroup_IsEmpty( t_BaseDefense_v2.sgroup[i]) == false then
Cpu_UnlockSGroup(g_Player2, t_BaseDefense_v2.sgroup[i])
end
else
table.remove(t_BaseDefense_v2.egroup, i)
table.remove(t_BaseDefense_v2.sgroup, i)
table.remove(t_BaseDefense_v2.marker, i)
end
end
end
end
function Rule_Civis()
t_civibunker = { "mkr_civibunker1", "mkr_civibunker2", "mkr_civibunker3"}
--[[civi trigger]]
for i = 1, table.getn(t_civibunker) do
-- local sgID = Player_GetAllSquadsNearMarker(g_Player1, "sg_nearcivis", t_civibunker[i]) if Player_CanSeePosition(g_Player1, Marker_GetPosition(Marker_FromName(t_civibunker[i], "basic_marker"))) == false then SGroup_CreateIfNotFound("sg_civis"..i) -- print("there are "..SGroup_Count("sg_nearcivis").." squads near "..t_civibunker[i]) if g_civilimit < g_cividelay and SGroup_IsEmpty("sg_civis"..i) then --[[ make civis]] t_kiddies = {"guard_squad_civilian_child_a", "guard_squad_civilian_child_b", "guard_squad_civilian_child_c", "guard_squad_civilian_child_d"} local kids = World_GetRand(1, 5) for k = 1, kids do local rand = World_GetRand(1, table.getn(t_kiddies)) Util_CreateSquadsAtMarker(g_Player4, "sg_civis"..i, t_kiddies[rand], t_civibunker[i], 1) end
t_adults = {"guard_squad_civilian_female_a", "guard_squad_civilian_female_b", "guard_squad_civilian_female_d", "guard_squad_civilian_male_a", "guard_squad_civilian_male_b", "guard_squad_civilian_male_c", "guard_squad_civilian_male_d"}
local dults = World_GetRand(2, 5)
for a = 1, dults do
local rand = World_GetRand(1, table.getn(t_adults))
Util_CreateSquadsAtMarker(g_Player4, "sg_civis"..i, t_adults[rand], t_civibunker[i], 1)
end
Cmd_MoveToMarker("sg_civis"..i, "mkr_civihome")
g_cividelay = 0
g_civilimit = World_GetRand(10, 30)
-- SGroup_Clear("sg_nearcivis") break end -- SGroup_Clear("sg_nearcivis") end end
g_cividelay = g_cividelay+1
--[[civi cleanup]]
for y = 1, table.getn(t_civibunker) do
if SGroup_Exists("sg_civis"..y) and SGroup_IsEmpty("sg_civis"..y) == false then
if Prox_AllSquadsNearMarker("sg_civis"..y, "mkr_civihome") and Player_CanSeeSGroup(g_Player1, "sg_civis"..y, false) == false then
SGroup_DeSpawn("sg_civis"..y)
SGroup_DestroyAllSquads("sg_civis"..y)
else
Cmd_MoveToMarker("sg_civis"..y, "mkr_civihome")
end
end
end
end
--END GAMES
-- 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
Rule_RemoveAll()
World_SetTeamWin( g_Player2, "" )
Rule_AddIntervalEx( Rule_GameOver,5,1 )
Rule_Remove( Rule_PlayerLoses )
end
end
end
function CheatClosing()
Rule_RemoveAll()
Util_StartNIS(EVENTS.NIS_Closing)
end