You've already forked ComfyFactorio
mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2026-06-20 16:32:28 +02:00
tweaks
This commit is contained in:
+45
-40
@@ -267,23 +267,28 @@ commands.add_command(
|
|||||||
|
|
||||||
for k, v in pairs(game.connected_players) do
|
for k, v in pairs(game.connected_players) do
|
||||||
v.cheat_mode = true
|
v.cheat_mode = true
|
||||||
v.insert {name = 'power-armor-mk2', count = 1}
|
|
||||||
if v.character ~= nil then
|
if v.character ~= nil then
|
||||||
|
if v.get_inventory(defines.inventory.character_armor) then
|
||||||
|
v.get_inventory(defines.inventory.character_armor).clear()
|
||||||
|
end
|
||||||
|
v.insert {name = 'power-armor-mk2', count = 1}
|
||||||
local p_armor = v.get_inventory(5)[1].grid
|
local p_armor = v.get_inventory(5)[1].grid
|
||||||
p_armor.put({name = 'fusion-reactor-equipment'})
|
if p_armor and p_armor.valid then
|
||||||
p_armor.put({name = 'fusion-reactor-equipment'})
|
p_armor.put({name = 'fusion-reactor-equipment'})
|
||||||
p_armor.put({name = 'fusion-reactor-equipment'})
|
p_armor.put({name = 'fusion-reactor-equipment'})
|
||||||
p_armor.put({name = 'exoskeleton-equipment'})
|
p_armor.put({name = 'fusion-reactor-equipment'})
|
||||||
p_armor.put({name = 'exoskeleton-equipment'})
|
p_armor.put({name = 'exoskeleton-equipment'})
|
||||||
p_armor.put({name = 'exoskeleton-equipment'})
|
p_armor.put({name = 'exoskeleton-equipment'})
|
||||||
p_armor.put({name = 'energy-shield-mk2-equipment'})
|
p_armor.put({name = 'exoskeleton-equipment'})
|
||||||
p_armor.put({name = 'energy-shield-mk2-equipment'})
|
p_armor.put({name = 'energy-shield-mk2-equipment'})
|
||||||
p_armor.put({name = 'energy-shield-mk2-equipment'})
|
p_armor.put({name = 'energy-shield-mk2-equipment'})
|
||||||
p_armor.put({name = 'energy-shield-mk2-equipment'})
|
p_armor.put({name = 'energy-shield-mk2-equipment'})
|
||||||
p_armor.put({name = 'personal-roboport-mk2-equipment'})
|
p_armor.put({name = 'energy-shield-mk2-equipment'})
|
||||||
p_armor.put({name = 'night-vision-equipment'})
|
p_armor.put({name = 'personal-roboport-mk2-equipment'})
|
||||||
p_armor.put({name = 'battery-mk2-equipment'})
|
p_armor.put({name = 'night-vision-equipment'})
|
||||||
p_armor.put({name = 'battery-mk2-equipment'})
|
p_armor.put({name = 'battery-mk2-equipment'})
|
||||||
|
p_armor.put({name = 'battery-mk2-equipment'})
|
||||||
|
end
|
||||||
local item = game.item_prototypes
|
local item = game.item_prototypes
|
||||||
local i = 0
|
local i = 0
|
||||||
for _k, _v in pairs(item) do
|
for _k, _v in pairs(item) do
|
||||||
@@ -319,33 +324,33 @@ commands.add_command(
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local forces = {}
|
local forces = {}
|
||||||
for _, force in pairs(game.forces) do
|
for _, force in pairs(game.forces) do
|
||||||
if force.index == 1 or force.index > 3 then
|
if force.index == 1 or force.index > 3 then
|
||||||
table.insert(forces, force)
|
table.insert(forces, force)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local is_charted
|
local is_charted
|
||||||
local count = 0
|
local count = 0
|
||||||
for _, surface in pairs(game.surfaces) do
|
for _, surface in pairs(game.surfaces) do
|
||||||
for chunk in surface.get_chunks() do
|
for chunk in surface.get_chunks() do
|
||||||
is_charted = false
|
is_charted = false
|
||||||
for _, force in pairs(forces) do
|
for _, force in pairs(forces) do
|
||||||
if force.is_chunk_charted(surface, {chunk.x, chunk.y}) then
|
if force.is_chunk_charted(surface, {chunk.x, chunk.y}) then
|
||||||
is_charted = true
|
is_charted = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not is_charted then
|
if not is_charted then
|
||||||
surface.delete_chunk({chunk.x, chunk.y})
|
surface.delete_chunk({chunk.x, chunk.y})
|
||||||
count = count + 1
|
count = count + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local message = player.name .. " deleted " .. count .. " uncharted chunks!"
|
local message = player.name .. ' deleted ' .. count .. ' uncharted chunks!'
|
||||||
game.print(message, Color.warning)
|
game.print(message, Color.warning)
|
||||||
Server.to_discord_bold(table.concat {message})
|
Server.to_discord_bold(table.concat {message})
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ function Public.reset_map()
|
|||||||
wave_defense_table.spawn_position = {x = 0, y = 100}
|
wave_defense_table.spawn_position = {x = 0, y = 100}
|
||||||
WD.alert_boss_wave(true)
|
WD.alert_boss_wave(true)
|
||||||
WD.clear_corpses(false)
|
WD.clear_corpses(false)
|
||||||
WD.remove_entities(false)
|
WD.remove_entities(true)
|
||||||
WD.enable_threat_log(true)
|
WD.enable_threat_log(true)
|
||||||
WD.check_collapse_position(true)
|
WD.check_collapse_position(true)
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,21 @@ local function debug_print(msg)
|
|||||||
print('WaveDefense: ' .. msg)
|
print('WaveDefense: ' .. msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function is_closer(pos1, pos2, pos)
|
||||||
|
return ((pos1.x - pos.x) ^ 2 + (pos1.y - pos.y) ^ 2) < ((pos2.x - pos.x) ^ 2 + (pos2.y - pos.y) ^ 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function shuffle_distance(tbl, position)
|
||||||
|
local size = #tbl
|
||||||
|
for i = size, 1, -1 do
|
||||||
|
local rand = math_random(size)
|
||||||
|
if is_closer(tbl[i].position, tbl[rand].position, position) and i > rand then
|
||||||
|
tbl[i], tbl[rand] = tbl[rand], tbl[i]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return tbl
|
||||||
|
end
|
||||||
|
|
||||||
local function remove_trees(entity)
|
local function remove_trees(entity)
|
||||||
local surface = entity.surface
|
local surface = entity.surface
|
||||||
local radius = 10
|
local radius = 10
|
||||||
@@ -478,9 +493,10 @@ local function get_commmands(group)
|
|||||||
position = old_position,
|
position = old_position,
|
||||||
radius = step_length / 2,
|
radius = step_length / 2,
|
||||||
type = {'simple-entity', 'tree'},
|
type = {'simple-entity', 'tree'},
|
||||||
limit = 1
|
limit = 50
|
||||||
}
|
}
|
||||||
if obstacles then
|
if obstacles then
|
||||||
|
shuffle_distance(obstacles, old_position)
|
||||||
for i = 1, #obstacles, 1 do
|
for i = 1, #obstacles, 1 do
|
||||||
if obstacles[i].valid then
|
if obstacles[i].valid then
|
||||||
commands[#commands + 1] = {
|
commands[#commands + 1] = {
|
||||||
@@ -539,7 +555,7 @@ local function command_unit_group(group)
|
|||||||
group.set_command(
|
group.set_command(
|
||||||
{
|
{
|
||||||
type = defines.command.compound,
|
type = defines.command.compound,
|
||||||
structure_type = defines.compound_command.logical_and,
|
structure_type = defines.compound_command.return_last,
|
||||||
commands = get_commmands(group)
|
commands = get_commmands(group)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,69 +1,90 @@
|
|||||||
local WD = require "modules.wave_defense.table"
|
local WD = require 'modules.wave_defense.table'
|
||||||
local Public = {}
|
local Public = {}
|
||||||
local side_target_types = {
|
local side_target_types = {
|
||||||
["accumulator"] = true,
|
['accumulator'] = true,
|
||||||
["assembling-machine"] = true,
|
['assembling-machine'] = true,
|
||||||
["boiler"] = true,
|
['boiler'] = true,
|
||||||
["furnace"] = true,
|
['furnace'] = true,
|
||||||
["generator"] = true,
|
['generator'] = true,
|
||||||
["lab"] = true,
|
['lab'] = true,
|
||||||
["lamp"] = true,
|
['lamp'] = true,
|
||||||
["mining-drill"] = true,
|
['mining-drill'] = true,
|
||||||
["power-switch"] = true,
|
['power-switch'] = true,
|
||||||
["radar"] = true,
|
['radar'] = true,
|
||||||
["reactor"] = true,
|
['reactor'] = true,
|
||||||
["roboport"] = true,
|
['roboport'] = true,
|
||||||
["rocket-silo"] = true,
|
['rocket-silo'] = true,
|
||||||
["solar-panel"] = true,
|
['solar-panel'] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
local function get_random_target(wave_defense_table)
|
local function get_random_target(wave_defense_table)
|
||||||
local r = math.random(1, wave_defense_table.side_target_count)
|
local r = math.random(1, wave_defense_table.side_target_count)
|
||||||
if not wave_defense_table.side_targets[r] then
|
if not wave_defense_table.side_targets[r] then
|
||||||
table.remove(wave_defense_table.side_targets, r)
|
table.remove(wave_defense_table.side_targets, r)
|
||||||
wave_defense_table.side_target_count = wave_defense_table.side_target_count - 1
|
wave_defense_table.side_target_count = wave_defense_table.side_target_count - 1
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if not wave_defense_table.side_targets[r].valid then
|
if not wave_defense_table.side_targets[r].valid then
|
||||||
table.remove(wave_defense_table.side_targets, r)
|
table.remove(wave_defense_table.side_targets, r)
|
||||||
wave_defense_table.side_target_count = wave_defense_table.side_target_count - 1
|
wave_defense_table.side_target_count = wave_defense_table.side_target_count - 1
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
return wave_defense_table.side_targets[r]
|
return wave_defense_table.side_targets[r]
|
||||||
end
|
end
|
||||||
|
|
||||||
function Public.get_side_target()
|
function Public.get_side_target()
|
||||||
local wave_defense_table = WD.get_table()
|
local wave_defense_table = WD.get_table()
|
||||||
for _ = 1, 512, 1 do
|
for _ = 1, 512, 1 do
|
||||||
if wave_defense_table.side_target_count == 0 then return end
|
if wave_defense_table.side_target_count == 0 then
|
||||||
local target = get_random_target(wave_defense_table)
|
return
|
||||||
if target then return target end
|
end
|
||||||
end
|
local target = get_random_target(wave_defense_table)
|
||||||
|
if target then
|
||||||
|
return target
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function add_entity(entity)
|
local function add_entity(entity)
|
||||||
local wave_defense_table = WD.get_table()
|
local wave_defense_table = WD.get_table()
|
||||||
|
|
||||||
--skip entities that are on another surface
|
--skip entities that are on another surface
|
||||||
if entity.surface.index ~= wave_defense_table.surface_index then return end
|
if entity.surface.index ~= wave_defense_table.surface_index then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if wave_defense_table.side_target_count >= 512 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
--add entity to the side target list
|
--add entity to the side target list
|
||||||
table.insert(wave_defense_table.side_targets, entity)
|
table.insert(wave_defense_table.side_targets, entity)
|
||||||
wave_defense_table.side_target_count = wave_defense_table.side_target_count + 1
|
wave_defense_table.side_target_count = wave_defense_table.side_target_count + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_built_entity(event)
|
local function on_built_entity(event)
|
||||||
if not event.created_entity then return end
|
if not event.created_entity then
|
||||||
if not event.created_entity.valid then return end
|
return
|
||||||
if not side_target_types[event.created_entity.type] then return end
|
end
|
||||||
add_entity(event.created_entity)
|
if not event.created_entity.valid then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not side_target_types[event.created_entity.type] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
add_entity(event.created_entity)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_robot_built_entity(event)
|
local function on_robot_built_entity(event)
|
||||||
if not event.created_entity then return end
|
if not event.created_entity then
|
||||||
if not event.created_entity.valid then return end
|
return
|
||||||
if not side_target_types[event.created_entity.type] then return end
|
end
|
||||||
add_entity(event.created_entity)
|
if not event.created_entity.valid then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not side_target_types[event.created_entity.type] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
add_entity(event.created_entity)
|
||||||
end
|
end
|
||||||
|
|
||||||
local event = require 'utils.event'
|
local event = require 'utils.event'
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ function Public.reset_wave_defense()
|
|||||||
this.worm_raffle = {}
|
this.worm_raffle = {}
|
||||||
this.clear_corpses = false
|
this.clear_corpses = false
|
||||||
this.alert_boss_wave = false
|
this.alert_boss_wave = false
|
||||||
this.remove_entities = true
|
this.remove_entities = false
|
||||||
this.enable_threat_log = true
|
this.enable_threat_log = true
|
||||||
this.check_collapse_position = true
|
this.check_collapse_position = true
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user