mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-11 13:39:14 +02:00
commit
5957ab4997
@ -67,6 +67,7 @@ require 'modules.autostash'
|
||||
--require 'modules.wave_defense.main'
|
||||
--require 'modules.fjei.main'
|
||||
--require 'modules.charging_station'
|
||||
--require 'modules.nuclear_landmines'
|
||||
-----------------------------
|
||||
|
||||
---- enable maps here ---- (maps higher up in the list may be more actually playable)
|
||||
|
25
modules/nuclear_landmines.lua
Normal file
25
modules/nuclear_landmines.lua
Normal file
@ -0,0 +1,25 @@
|
||||
local math_random = math.random
|
||||
|
||||
local function detonate_nuke(entity)
|
||||
local surface = entity.surface
|
||||
surface.create_entity({name = "atomic-rocket", position = entity.position, force = entity.force, speed = 1, max_range = 800, target = entity, source = entity})
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then return end
|
||||
if entity.name == "land-mine" then
|
||||
if math_random(1,global.nuclear_landmines.chance) == 1 then
|
||||
detonate_nuke(entity)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_init()
|
||||
global.nuclear_landmines = {}
|
||||
global.nuclear_landmines.chance = 512
|
||||
end
|
||||
|
||||
local Event = require 'utils.event'
|
||||
Event.on_init(on_init)
|
||||
Event.add(defines.events.on_entity_died, on_entity_died)
|
@ -31,8 +31,8 @@ local function place_nest_near_unit_group(wave_defense_table)
|
||||
if math_random(1, 3) == 1 then name = "spitter-spawner" end
|
||||
local position = unit.surface.find_non_colliding_position(name, unit.position, 12, 1)
|
||||
if not position then return end
|
||||
local r = wave_defense_table.nest_building_density
|
||||
if unit.surface.count_entities_filtered({type = "unit-spawner", area = {{position.x - r, position.y - r},{position.x + r, position.y + r}}}) > 0 then return end
|
||||
local r = wave_defense_table.nest_building_density
|
||||
if unit.surface.count_entities_filtered({type = "unit-spawner", force = unit.force, area = {{position.x - r, position.y - r},{position.x + r, position.y + r}}}) > 0 then return end
|
||||
unit.surface.create_entity({name = name, position = position, force = unit.force})
|
||||
unit.surface.create_entity({name = "blood-explosion-huge", position = position})
|
||||
unit.surface.create_entity({name = "blood-explosion-huge", position = unit.position})
|
||||
@ -68,7 +68,7 @@ function Public.build_worm()
|
||||
local worm = BiterRolls.wave_defense_roll_worm_name()
|
||||
if not position then return end
|
||||
local r = wave_defense_table.worm_building_density
|
||||
if unit.surface.count_entities_filtered({type = "turret", area = {{position.x - r, position.y - r},{position.x + r, position.y + r}}}) > 0 then return end
|
||||
if unit.surface.count_entities_filtered({type = "turret", force = unit.force, area = {{position.x - r, position.y - r},{position.x + r, position.y + r}}}) > 0 then return end
|
||||
unit.surface.create_entity({name = worm, position = position, force = unit.force})
|
||||
unit.surface.create_entity({name = "blood-explosion-huge", position = position})
|
||||
unit.surface.create_entity({name = "blood-explosion-huge", position = unit.position})
|
||||
|
Loading…
x
Reference in New Issue
Block a user