mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-13 13:49:33 +02:00
periodic attacks
This commit is contained in:
parent
d96eab95f1
commit
1c8178a8ba
@ -50,20 +50,36 @@ local function on_player_joined_game(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function on_entity_spawned(event)
|
local function on_entity_spawned(event)
|
||||||
if global.clean_up_wave_countdown <= 0 then
|
global.on_entity_spawned_counter = global.on_entity_spawned_counter + 1
|
||||||
|
|
||||||
|
if global.on_entity_spawned_counter % 128 == 0 then
|
||||||
local biter = event.entity
|
local biter = event.entity
|
||||||
local position = biter.surface.find_non_colliding_position("small-biter", {-32, biter.position.y}, 128, 8)
|
local position = biter.surface.find_non_colliding_position("small-biter", {-32, biter.position.y}, 128, 8)
|
||||||
if not position then return end
|
if position then
|
||||||
biter.release_from_spawner()
|
biter.release_from_spawner()
|
||||||
biter.set_command({
|
biter.set_command({
|
||||||
type = defines.command.attack_area,
|
type = defines.command.attack_area,
|
||||||
destination = position,
|
destination = position,
|
||||||
radius = 8,
|
radius = 8,
|
||||||
distraction = defines.distraction.by_anything,
|
distraction = defines.distraction.by_anything,
|
||||||
})
|
})
|
||||||
global.clean_up_wave_countdown = 128
|
end
|
||||||
else
|
end
|
||||||
global.clean_up_wave_countdown = global.clean_up_wave_countdown - 1
|
|
||||||
|
if global.on_entity_spawned_counter % 1024 == 512 then
|
||||||
|
local spawner = event.spawner
|
||||||
|
local biters = spawner.surface.find_enemy_units(spawner.position, 64, "player")
|
||||||
|
local position = spawner.surface.find_non_colliding_position("small-biter", {-32, spawner.position.y}, 128, 8)
|
||||||
|
if position and biters[1] then
|
||||||
|
local unit_group = spawner.surface.create_unit_group({position = spawner.position, force = "enemy"})
|
||||||
|
for _, unit in pairs(biters) do unit_group.add_member(unit) end
|
||||||
|
unit_group.set_command({
|
||||||
|
type = defines.command.attack_area,
|
||||||
|
destination = position,
|
||||||
|
radius = 8,
|
||||||
|
distraction = defines.distraction.by_anything,
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -232,7 +248,7 @@ end
|
|||||||
|
|
||||||
local function on_init()
|
local function on_init()
|
||||||
global.drop_schedule = {}
|
global.drop_schedule = {}
|
||||||
global.clean_up_wave_countdown = 0
|
global.on_entity_spawned_counter = 0
|
||||||
|
|
||||||
game.map_settings.enemy_evolution.destroy_factor = 0.001
|
game.map_settings.enemy_evolution.destroy_factor = 0.001
|
||||||
game.map_settings.enemy_evolution.pollution_factor = 0
|
game.map_settings.enemy_evolution.pollution_factor = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user