Orbital Ion Cannon (SE Edition)


When you need to call down the thunder to deal with those pesky biters, launch a rocket with an ion cannon into orbit and show the bugs who's boss. Now compatible with the planets and moons from Space Exploration.

Content
11 months ago
1.0 - 1.1
76.5K
Combat

g Recommended addition for Biter Meteors

1 year, 7 months ago
(updated 1 year, 7 months ago)

I'm using SE, plus a radar mod that provides a larger visible radius (VisionRadar). From trial an error, it seems that the biter spawners created by Biter Meteors landing in SE do not trigger the on_biter_base_built event (which, looking at the description, sorta makes sense, it's supposed to fire when the biters expand, while SE simply creates the spawner). If these meteors land within the area my radars keep visible, they do not get hit by the radar scanning sweeps either, so neither of the auto-targeting event triggers is hit for these spawners.

To handle this, I added a third event trigger based on even on_entity_spawned, which appears to only fire when biters are spawned by spawners. The code I inserted (into autotargeter.lua) is below. I've only tested it on a mining world, so I'm not sure if there are other entity spawns that trigger this event, and if the code needs some additional conditionals, but it's tested working against those biter meteors on that mining world.

--- Called when an entity is spawned by a EnemySpawner
-- spawner :: LuaEntity
-- entity :: LuaEntity
-- name :: defines.events: Identifier of the event
-- tick :: uint: Tick the event was generated.
script.on_event(defines.events.on_entity_spawned, function(e)
  --print("on_entity_spawned", serpent.line(e.spawner.position))
  if not settings.global["ion-cannon-auto-target-visible"].value then return end
  -- Auto-Target New Nests in Visible Regions
  local biterBase = e.spawner
  local chunk = Chunk.from_position(biterBase.position)
  for _, force in pairs(game.forces) do
    if force.technologies["auto-targeting"].researched == true and force.is_chunk_visible(biterBase.surface, chunk) then
      --print("insert biter base to Queue")
      table.insert(global.forces_ion_cannon_table["Queue"], biterBase)
      return
    end
  end
end)

Edit: oh, this should probably also be behind a setting, and/or have a check for friendlies in the blast radius, because as written, it will very happily drop an ion cannon blast straight on player buildings that happened to get hit by a biter meteor.

New response