mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-08 00:39:30 +02:00
nest and worm building
This commit is contained in:
parent
71eb23cb8c
commit
8521ac29bf
@ -132,6 +132,12 @@ local function spawn_unit_group()
|
||||
if not biter then break end
|
||||
unit_group.add_member(biter)
|
||||
end
|
||||
for i = 1, #global.wave_defense.unit_groups, 1 do
|
||||
if not global.wave_defense.unit_groups[i] then
|
||||
global.wave_defense.unit_groups[i] = unit_group
|
||||
return true
|
||||
end
|
||||
end
|
||||
global.wave_defense.unit_groups[#global.wave_defense.unit_groups + 1] = unit_group
|
||||
return true
|
||||
end
|
||||
@ -328,7 +334,7 @@ local function on_tick()
|
||||
|
||||
if game.tick > global.wave_defense.next_wave then set_next_wave() end
|
||||
|
||||
if game.tick % 180 == 0 then
|
||||
if game.tick % 300 == 0 then
|
||||
if game.tick % 1800 == 0 then
|
||||
time_out_biters()
|
||||
end
|
||||
@ -337,6 +343,8 @@ local function on_tick()
|
||||
spawn_attack_groups()
|
||||
set_unit_group_count()
|
||||
give_commands_to_unit_groups()
|
||||
build_nest()
|
||||
build_worm()
|
||||
end
|
||||
end
|
||||
|
||||
@ -365,7 +373,11 @@ function reset_wave_defense()
|
||||
game_lost = false,
|
||||
threat = 0,
|
||||
simple_entity_shredding_count_modifier = 0.0003,
|
||||
simple_entity_shredding_cost_modifier = 0.01, --threat cost for one health
|
||||
simple_entity_shredding_cost_modifier = 0.01, --threat cost for one health
|
||||
nest_building_density = 16, --lower values = more dense building
|
||||
nest_building_chance = 8, --high value = less chance
|
||||
worm_building_density = 16, --lower values = more dense building
|
||||
worm_building_chance = 8, --high value = less chance
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -1,6 +1,58 @@
|
||||
local threat_values = require "modules.wave_defense.threat_values"
|
||||
local math_random = math.random
|
||||
|
||||
local function remove_unit(entity)
|
||||
if not global.wave_defense.active_biters[entity.unit_number] then return end
|
||||
global.wave_defense.active_biters[entity.unit_number] = nil
|
||||
global.wave_defense.active_biter_count = global.wave_defense.active_biter_count - 1
|
||||
end
|
||||
|
||||
function build_nest()
|
||||
if global.wave_defense.threat < 1000 then return end
|
||||
if math_random(1, global.wave_defense.nest_building_chance) ~= 1 then return end
|
||||
local group = global.wave_defense.unit_groups[math_random(1, #global.wave_defense.unit_groups)]
|
||||
if not group then return end
|
||||
if not group.valid then return end
|
||||
if not group.members then return end
|
||||
if not group.members[1] then return end
|
||||
local unit = group.members[math_random(1, #group.members)]
|
||||
if not unit.valid then return end
|
||||
local r = global.wave_defense.nest_building_density
|
||||
if unit.surface.count_entities_filtered({type = "unit-spawner", area = {{unit.position.x - r, unit.position.y - r},{unit.position.x + r, unit.position.y + r}}}) > 0 then return end
|
||||
local position = unit.surface.find_non_colliding_position("biter-spawner", unit.position, 5, 1)
|
||||
if not position then return end
|
||||
unit.surface.create_entity({name = "biter-spawner", 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})
|
||||
remove_unit(unit)
|
||||
unit.destroy()
|
||||
global.wave_defense.threat = global.wave_defense.threat - 500
|
||||
end
|
||||
|
||||
function build_worm()
|
||||
if global.wave_defense.threat < 1000 then return end
|
||||
if math_random(1, global.wave_defense.worm_building_chance) ~= 1 then return end
|
||||
local group = global.wave_defense.unit_groups[math_random(1, #global.wave_defense.unit_groups)]
|
||||
if not group then return end
|
||||
if not group.valid then return end
|
||||
if not group.members then return end
|
||||
if not group.members[1] then return end
|
||||
local unit = group.members[math_random(1, #group.members)]
|
||||
if not unit.valid then return end
|
||||
local r = global.wave_defense.worm_building_density
|
||||
if unit.surface.count_entities_filtered({type = "turret", area = {{unit.position.x - r, unit.position.y - r},{unit.position.x + r, unit.position.y + r}}}) > 0 then return end
|
||||
wave_defense_set_worm_raffle(global.wave_defense.wave_number)
|
||||
local worm = wave_defense_roll_worm_name()
|
||||
local position = unit.surface.find_non_colliding_position(worm, unit.position, 5, 1)
|
||||
if not position 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})
|
||||
remove_unit(unit)
|
||||
unit.destroy()
|
||||
global.wave_defense.threat = global.wave_defense.threat - threat_values[worm]
|
||||
end
|
||||
|
||||
local function get_circle_vectors(radius)
|
||||
local vectors = {}
|
||||
for x = radius * -1, radius, 1 do
|
||||
@ -22,7 +74,7 @@ local acid_nova_entities = {
|
||||
|
||||
local function acid_nova(entity)
|
||||
if not acid_nova_entities[entity.name] then return end
|
||||
if global.wave_defense.threat < 25000 then return end
|
||||
if global.wave_defense.threat < 50000 then return end
|
||||
if math_random(1, 16) ~= 1 then return end
|
||||
for _ = 1, acid_nova_entities[entity.name].amount, 1 do
|
||||
local i = math_random(1, #acid_nova_entities[entity.name].vectors)
|
||||
@ -40,12 +92,6 @@ local function acid_nova(entity)
|
||||
return true
|
||||
end
|
||||
|
||||
local function remove_unit(entity)
|
||||
if not global.wave_defense.active_biters[entity.unit_number] then return end
|
||||
global.wave_defense.active_biters[entity.unit_number] = nil
|
||||
global.wave_defense.active_biter_count = global.wave_defense.active_biter_count - 1
|
||||
end
|
||||
|
||||
local function create_particles(entity)
|
||||
local particle = "stone-particle"
|
||||
if entity.type == "tree" then particle = "branch-particle" end
|
||||
|
@ -7,8 +7,8 @@ return {
|
||||
["medium-spitter"] = 4,
|
||||
["small-biter"] = 1,
|
||||
["small-spitter"] = 1,
|
||||
["small-worm-turret"] = 16,
|
||||
["medium-worm-turret"] = 24,
|
||||
["big-worm-turret"] = 32,
|
||||
["behemoth-worm-turret"] = 48,
|
||||
["small-worm-turret"] = 32,
|
||||
["medium-worm-turret"] = 48,
|
||||
["big-worm-turret"] = 64,
|
||||
["behemoth-worm-turret"] = 80,
|
||||
}
|
Loading…
Reference in New Issue
Block a user