function EIR_DefenseSetupChecks() local pid if World_GetGameTime() < (battleStartTime - 15) then sg_defense_temp = SGroup_CreateIfNotFound("sg_defense_temp") for i = 1, World_GetPlayerCount() do pid = Player_GetID(World_GetPlayerAt(i)) - 999 if players[pid].isAlive == 1 then if players[pid].faction == battleObjectiveDefender then SGroup_Clear(sg_defense_temp) if battleObjectiveAttacker == 0 then for n = 1, table.getn(offmappositions.allies) do World_GetSquadsNearPoint(World_GetPlayerAt(i), sg_defense_temp, offmappositions.allies[n], EIR_SpawnProtectionDistance, OT_Player) end elseif battleObjectiveAttacker == 1 then for n = 1, table.getn(offmappositions.axis) do World_GetSquadsNearPoint(World_GetPlayerAt(i), sg_defense_temp, offmappositions.axis[n], EIR_SpawnProtectionDistance, OT_Player) end end if SGroup_Count(sg_defense_temp) > 0 then if players[pid].spawnTimeWarned == nil then players[pid].spawnTimeWarned = 0 end if players[pid].spawnTimeArtillery == nil then players[pid].spawnTimeArtillery = World_GetGameTime() end -- Warn them every 8 seconds... if World_GetGameTime() - players[pid].spawnTimeWarned > 8 then if Player_GetID(World_GetPlayerAt(i)) == Player_GetID(Game_GetLocalPlayer()) then EIR_NotifyPlayer("You are too close to the attacking teams entry point and are subject to artillery rounds.") end players[pid].spawnTimeWarned = World_GetGameTime() end -- Give them 10 seconds to get the hell out of dodge... if World_GetGameTime() - players[pid].spawnTimeArtillery > 10 then EIR_GameStartArtillery() end SGroup_Clear(sg_defense_temp) else -- All Clear... players[pid].spawnTimeArtillery = World_GetGameTime() end end end end else EIR_GameStartArtillery() Rule_RemoveMe() endendfunction EIR_GameStartArtillery() local pid local unitCount = 0 sg_defense_temp = SGroup_CreateIfNotFound("sg_defense_temp") SGroup_Clear(sg_defense_temp) for i = 1, World_GetPlayerCount() do pid = Player_GetID(World_GetPlayerAt(i)) - 999 if players[pid].isAlive == 1 then if players[pid].faction == battleObjectiveDefender then players[pid].spawnTimeArtillery = World_GetGameTime() if battleObjectiveAttacker == 0 then for n = 1, table.getn(offmappositions.allies) do World_GetSquadsNearPoint(World_GetPlayerAt(i), sg_defense_temp, offmappositions.allies[n], EIR_SpawnProtectionDistance, OT_Player) end elseif battleObjectiveAttacker == 1 then for n = 1, table.getn(offmappositions.axis) do World_GetSquadsNearPoint(World_GetPlayerAt(i), sg_defense_temp, offmappositions.axis[n], EIR_SpawnProtectionDistance, OT_Player) end end end end end unitCount = SGroup_Count(sg_defense_temp) if unitCount > 0 then if players[Player_GetID(Game_GetLocalPlayer())-999].faction == battleObjectiveDefender then EIR_NotifyPlayer("Enemy artillery strikes are inbound to your forward positions. Move your units back!") elseif players[Player_GetID(Game_GetLocalPlayer())-999].faction == battleObjectiveAttacker then EIR_NotifyPlayer("Artillery strikes inbound to forward enemy positions. Be careful with your deployments.") end local _FireForEffect = function(gid, idx, sid) local target, entityid target = Squad_GetPosition(sid) if battleObjectiveAttacker == 0 then Cmd_Ability(playerAllies, EIRABILITY.ALLIED_ARTILLERY, target, nil, true) entityid = Entity_Create(EIREBP.SPAWN_MINE, playerAllies, target, Util_ScarPos(0,0)) Entity_Spawn(entityid) elseif battleObjectiveAttacker == 1 then Cmd_Ability(playerAxis, EIRABILITY.AXIS_ARTILLERY, target, nil, true) entityid = Entity_Create(EIREBP.SPAWN_MINE, playerAxis, target, Util_ScarPos(0,0)) Entity_Spawn(entityid) end Entity_Kill(entityid) end SGroup_ForEach(sg_defense_temp, _FireForEffect) endend