You've already forked ComfyFactorio
mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-11-25 22:32:18 +02:00
Mtn: Fix many bugs
This commit is contained in:
@@ -324,8 +324,6 @@ local function distance(player)
|
||||
local breached_wall = Public.get('breached_wall')
|
||||
local bonus_xp_on_join = Public.get('bonus_xp_on_join')
|
||||
local enable_arties = Public.get('enable_arties')
|
||||
local final_battle = Public.get('final_battle')
|
||||
|
||||
|
||||
local p = player.physical_position
|
||||
|
||||
@@ -421,7 +419,7 @@ local function distance(player)
|
||||
end
|
||||
end
|
||||
|
||||
if not Collapse.has_collapse_started() or not final_battle then
|
||||
if not Collapse.has_collapse_started() then
|
||||
clear_breach_text_and_render()
|
||||
Public.set('collapse_started', true)
|
||||
Collapse.start_now(true)
|
||||
|
||||
@@ -109,6 +109,15 @@ local reset_game =
|
||||
end
|
||||
)
|
||||
|
||||
local change_force_for_drills_token =
|
||||
Task.register(
|
||||
function (event)
|
||||
local entity = event.entity
|
||||
if not entity or not entity.valid then return end
|
||||
entity.force = 'bonus_drill'
|
||||
end
|
||||
)
|
||||
|
||||
local function get_random_weighted(player, weighted_table, item_index, weight_index)
|
||||
local total_weight = 0
|
||||
item_index = item_index or 1
|
||||
@@ -1507,7 +1516,7 @@ local function on_built_entity(event)
|
||||
}
|
||||
|
||||
if valid_drills[entity.name] then
|
||||
entity.force = 'bonus_drill'
|
||||
Task.set_timeout_in_ticks(30, change_force_for_drills_token, { entity = entity })
|
||||
return
|
||||
end
|
||||
|
||||
@@ -1598,7 +1607,7 @@ local function on_robot_built_entity(event)
|
||||
}
|
||||
|
||||
if valid_drills[entity.name] then
|
||||
entity.force = 'bonus_drill'
|
||||
Task.set_timeout_in_ticks(30, change_force_for_drills_token, { entity = entity })
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@@ -1567,11 +1567,8 @@ function Public.is_creativity_mode_on()
|
||||
end
|
||||
|
||||
function Public.disable_creative()
|
||||
local creative_enabled = Misc.get('creative_enabled')
|
||||
if creative_enabled then
|
||||
Misc.set('creative_enabled', false)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.on_player_respawned(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
|
||||
@@ -39,6 +39,18 @@ local function validate_entity(entity)
|
||||
return true
|
||||
end
|
||||
|
||||
local get_filters = function (points)
|
||||
local filters = {}
|
||||
for _, section in pairs(points.sections) do
|
||||
for _, filter in pairs(section.filters) do
|
||||
if filter and filter.value and filter.value.name then
|
||||
filters[#filters + 1] = filter
|
||||
end
|
||||
end
|
||||
end
|
||||
return filters
|
||||
end
|
||||
|
||||
---Returns the car from the unit_number.
|
||||
---@param unit_number any
|
||||
---@return table|boolean
|
||||
@@ -560,10 +572,11 @@ local function input_filtered(car_inv, chest, chest_inv, free_slots)
|
||||
local request_stacks = {}
|
||||
|
||||
local prototypes = prototypes.item
|
||||
for slot_index = 1, 30, 1 do
|
||||
local stack = chest.get_request_slot(slot_index)
|
||||
if stack then
|
||||
request_stacks[stack.name] = 10 * prototypes[stack.name].stack_size
|
||||
local logistics = chest.get_logistic_point(defines.logistic_member_index.logistic_container)
|
||||
local filters = get_filters(logistics)
|
||||
for _, filter in pairs(filters) do
|
||||
if filter.value.name then
|
||||
request_stacks[filter.value.name] = 10 * prototypes[filter.value.name].stack_size
|
||||
end
|
||||
end
|
||||
for i = 1, #car_inv - 1, 1 do
|
||||
@@ -606,7 +619,16 @@ local function input_cargo(car, chest)
|
||||
end
|
||||
end
|
||||
|
||||
if chest.get_request_slot(1) then
|
||||
local has_request_slot = false
|
||||
local logistics = chest.get_logistic_point(defines.logistic_member_index.logistic_container)
|
||||
local filters = get_filters(logistics)
|
||||
for _, filter in pairs(filters) do
|
||||
if filter.value.name then
|
||||
has_request_slot = true
|
||||
end
|
||||
end
|
||||
|
||||
if has_request_slot then
|
||||
input_filtered(car_inventory, chest, chest_inventory, free_slots)
|
||||
goto continue
|
||||
end
|
||||
|
||||
@@ -761,6 +761,7 @@ function Public.use_cargo_wagon_door_with_entity(icw, player, door)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if not door then
|
||||
return
|
||||
end
|
||||
@@ -1062,6 +1063,10 @@ function Public.toggle_minimap(icw, event)
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
if player.controller_type == defines.controllers.remote then
|
||||
return
|
||||
end
|
||||
|
||||
local is_spamming = SpamProtection.is_spamming(player, 5, 'ICW Toggle Minimap')
|
||||
if is_spamming then
|
||||
return
|
||||
|
||||
@@ -24,11 +24,18 @@ end
|
||||
local function on_player_driving_changed_state(event)
|
||||
local icw = ICW.get()
|
||||
local player = game.players[event.player_index]
|
||||
if player.controller_type == defines.controllers.remote then
|
||||
return
|
||||
end
|
||||
|
||||
Functions.use_cargo_wagon_door_with_entity(icw, player, event.entity)
|
||||
end
|
||||
|
||||
local function on_player_changed_surface(event)
|
||||
local player = game.players[event.player_index]
|
||||
if player.controller_type == defines.controllers.remote then
|
||||
return
|
||||
end
|
||||
Functions.kill_minimap(player)
|
||||
end
|
||||
|
||||
@@ -37,6 +44,7 @@ local function on_gui_closed(event)
|
||||
if not entity then
|
||||
return
|
||||
end
|
||||
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@@ -52,6 +60,10 @@ local function on_gui_closed(event)
|
||||
return
|
||||
end
|
||||
|
||||
if player.controller_type == defines.controllers.remote then
|
||||
return
|
||||
end
|
||||
|
||||
Functions.kill_minimap(player)
|
||||
end
|
||||
|
||||
@@ -77,6 +89,10 @@ local function on_gui_opened(event)
|
||||
return
|
||||
end
|
||||
|
||||
if player.controller_type == defines.controllers.remote then
|
||||
return
|
||||
end
|
||||
|
||||
Functions.draw_minimap(
|
||||
icw,
|
||||
player,
|
||||
|
||||
@@ -42,6 +42,7 @@ local JailData = require 'utils.datastore.jail_data'
|
||||
local RPG_Progression = require 'utils.datastore.rpg_data'
|
||||
local OfflinePlayers = require 'modules.clear_vacant_players'
|
||||
local Beam = require 'modules.render_beam'
|
||||
local Commands = require 'utils.commands'
|
||||
|
||||
-- Use these settings for live
|
||||
local send_ping_to_channel = Discord.channel_names.mtn_channel
|
||||
@@ -142,6 +143,15 @@ partial_reset = function ()
|
||||
Public.locomotive_spawn(surface, { x = -18, y = 25 }, this.adjusted_zones.reversed)
|
||||
end
|
||||
|
||||
init_bonus_drill_force()
|
||||
|
||||
Public.init_enemy_weapon_damage()
|
||||
|
||||
game.forces.player.manual_mining_speed_modifier = 0
|
||||
game.forces.player.set_ammo_damage_modifier('artillery-shell', -0.95)
|
||||
game.forces.player.worker_robots_battery_modifier = 4
|
||||
game.forces.player.worker_robots_storage_bonus = 15
|
||||
|
||||
Public.render_train_hp()
|
||||
Public.render_direction(surface, this.adjusted_zones.reversed)
|
||||
end
|
||||
@@ -185,7 +195,6 @@ function Public.reset_map()
|
||||
Group.alphanumeric_only(false)
|
||||
|
||||
Public.disable_tech()
|
||||
init_bonus_drill_force()
|
||||
|
||||
local surface = game.surfaces[this.active_surface_index]
|
||||
|
||||
@@ -204,11 +213,6 @@ function Public.reset_map()
|
||||
|
||||
Beam.reset_valid_targets()
|
||||
|
||||
game.forces.player.manual_mining_speed_modifier = 0
|
||||
game.forces.player.set_ammo_damage_modifier('artillery-shell', -0.95)
|
||||
game.forces.player.worker_robots_battery_modifier = 4
|
||||
game.forces.player.worker_robots_storage_bonus = 15
|
||||
|
||||
BiterHealthBooster.set_active_surface(tostring(surface.name))
|
||||
BiterHealthBooster.acid_nova(true)
|
||||
BiterHealthBooster.check_on_entity_died(true)
|
||||
@@ -216,7 +220,6 @@ function Public.reset_map()
|
||||
BiterHealthBooster.enable_boss_loot(false)
|
||||
BiterHealthBooster.enable_randomize_stun_and_slowdown_sticker(true)
|
||||
|
||||
Public.init_enemy_weapon_damage()
|
||||
|
||||
-- AntiGrief.whitelist_types('tree', true)
|
||||
AntiGrief.enable_capsule_warning(false)
|
||||
@@ -296,6 +299,7 @@ function Public.reset_map()
|
||||
Public.set_difficulty()
|
||||
Public.disable_creative()
|
||||
Public.boost_difficulty()
|
||||
Commands.restore_states()
|
||||
|
||||
if this.adjusted_zones.reversed then
|
||||
if not surface.is_chunk_generated({ x = -20, y = -22 }) then
|
||||
|
||||
@@ -519,6 +519,7 @@ local search_corpse_token =
|
||||
Task.register(
|
||||
function (event)
|
||||
local player_index = event.player_index
|
||||
if not player_index then return end
|
||||
local player = game.get_player(player_index)
|
||||
|
||||
if not player or not player.valid then
|
||||
|
||||
@@ -109,10 +109,9 @@ Commands.new('stats', 'Check what stats a user has!')
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
if _DEBUG then
|
||||
Commands.new('give_xp', 'Give a player XP!')
|
||||
Commands.new('rpg_give_xp', 'Give players XP!')
|
||||
:require_admin()
|
||||
:require_validation("Running this again will grant EVERY player XP. Are you sure you want to continue?")
|
||||
:add_parameter('amount', false, 'number')
|
||||
:callback(
|
||||
function (_, amount)
|
||||
@@ -121,6 +120,8 @@ if _DEBUG then
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
if _DEBUG then
|
||||
Commands.new('rpg_debug_module', 'Toggle debug mode for RPG module!')
|
||||
:require_admin()
|
||||
:callback(
|
||||
|
||||
@@ -157,18 +157,18 @@ end
|
||||
|
||||
local function add_gui_increase_stat(element, name, player)
|
||||
local rpg_t = Public.get_value_from_player(player.index)
|
||||
local sprite = 'virtual-signal/signal-red'
|
||||
local symbol = '✚'
|
||||
local e = element.add({ type = 'sprite-button', name = name, caption = symbol })
|
||||
if rpg_t.points_left <= 0 then
|
||||
sprite = 'virtual-signal/signal-black'
|
||||
e.style.font_color = { 0, 0, 0 }
|
||||
else
|
||||
e.style.font_color = { 195, 0, 0 }
|
||||
end
|
||||
local e = element.add({ type = 'sprite-button', name = name, caption = symbol, sprite = sprite })
|
||||
e.style.maximal_height = 38
|
||||
e.style.minimal_height = 38
|
||||
e.style.maximal_width = 38
|
||||
e.style.minimal_width = 38
|
||||
e.style.font = 'default-large-semibold'
|
||||
e.style.font_color = { 0, 0, 0 }
|
||||
e.style.horizontal_align = 'center'
|
||||
e.style.vertical_align = 'center'
|
||||
e.style.padding = 0
|
||||
|
||||
@@ -64,9 +64,6 @@ local function on_gui_click(event)
|
||||
if element.caption ~= '✚' then
|
||||
return
|
||||
end
|
||||
if element.sprite ~= 'virtual-signal/signal-red' then
|
||||
return
|
||||
end
|
||||
|
||||
local rpg_t = Public.get_value_from_player(player.index)
|
||||
|
||||
|
||||
@@ -1109,7 +1109,7 @@ spells[#spells + 1] = {
|
||||
|
||||
local surface = data.surface
|
||||
|
||||
local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5)
|
||||
local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0)
|
||||
if pos then
|
||||
player.teleport(pos, surface)
|
||||
else
|
||||
@@ -1145,7 +1145,7 @@ spells[#spells + 1] = {
|
||||
|
||||
Public.register_cooldown_for_spell(player)
|
||||
|
||||
local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5)
|
||||
local pos = surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0)
|
||||
if pos then
|
||||
player.teleport(pos, surface)
|
||||
else
|
||||
|
||||
@@ -523,6 +523,14 @@ function Public:set_default(defaults)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Restores the command_activated state for each command
|
||||
function Public.restore_states()
|
||||
for _, command in pairs(this.commands) do
|
||||
command.validated_command = false
|
||||
command.command_activated = false
|
||||
end
|
||||
end
|
||||
|
||||
--- Registers the command to the game. Will return the player/server and the args as separate arguments.
|
||||
---@param func function
|
||||
function Public:callback(func)
|
||||
|
||||
@@ -318,7 +318,7 @@ local function clear_corpses(cmd)
|
||||
|
||||
local radius = { { x = (pos.x + -param), y = (pos.y + -param) }, { x = (pos.x + param), y = (pos.y + param) } }
|
||||
|
||||
for _, entity in pairs(player.surface.find_entities_filtered { area = radius, type = 'corpse' }) do
|
||||
for _, entity in pairs(player.surface.find_entities_filtered { area = radius, type = { 'corpse' } }) do
|
||||
if entity.corpse_expires then
|
||||
entity.destroy()
|
||||
i = i + 1
|
||||
|
||||
Reference in New Issue
Block a user