1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-25 21:29:06 +02:00

More module fixes

Fixes autostash filtering not working
Fixes wave defense being broken
Remove unused modules as they are part of base game now
This commit is contained in:
Gerkiz 2024-10-27 23:15:43 +01:00
parent 7ef0fa30e1
commit 8e8724a34e
18 changed files with 248 additions and 382 deletions

View File

@ -21,10 +21,6 @@ turret_filler_label_amount=Amount:
turret_filler_ammo_type=Select Ammo:
turret_filler_ammo_lower=Enable lower tiers?
blueprint_requesting=Blueprint Requesting
blueprint_requesting_desc=Placing blueprints into [entity=logistic-chest-requester] or [entity=logistic-chest-buffer] will set the chest requests to match the blueprint costs. Happens when chest is closed.
blueprint_requesting_notify=This server has Blueprint Requesting feature enabled. Placing blueprints into [entity=logistic-chest-requester] or [entity=logistic-chest-buffer] will match the requests to the blueprint costs. You can disable this feature for yourself in Comfy menu -> Config.
[modules_towny]
map_info=__1__\n\n__2__\n\n__3__\n\n__4__\n\n__5__
map_info1=To ally or settle with another town, drop a fish on their market or character. (Default Hotkey Z)\nThey will have to do the same to you to complete the request.\nCoal yields the opposite result, as it will make foes or banish settlers.

View File

@ -17,9 +17,6 @@ turret_filler_label_enabled=Включено:
turret_filler_label_amount=Количество:
turret_filler_ammo_type=Боеприпасы:
turret_filler_ammo_lower=Включить предыдущие уровни?
blueprint_requesting=Запрос по чертежу
blueprint_requesting_desc=Если положить чертёж в [entity=logistic-chest-requester] или [entity=logistic-chest-buffer], то сундук запросит предметы, нужные для постройки чертежа. Запрос формируется при закрытии сундука.
blueprint_requesting_notify=На этом сервере включена функция "Запрос по чертежу". Если положить чертёж в [entity=logistic-chest-requester] или [entity=logistic-chest-buffer], то сундук запросит предметы, нужные для постройки чертежа. Вы можете отключить функцию в меню Comfy -> Config.
[modules_towny]
map_info=__1__\n\n__2__\n\n__3__\n\n__4__\n\n__5__

View File

@ -1896,6 +1896,7 @@ function Public.set_player_to_spectator(player)
return false
end
if player.driving then
return player.print('[color=blue][Spectate][/color] Please exit the vehicle before continuing', { color = Color.warning })
end

View File

@ -1,5 +1,6 @@
local Event = require 'utils.event'
local Public = require 'maps.mountain_fortress_v3.table'
local Color = require 'utils.color_presets'
local RPG = require 'modules.rpg.main'
local IC_Gui = require 'maps.mountain_fortress_v3.ic.gui'
local IC_Minimap = require 'maps.mountain_fortress_v3.ic.minimap'
@ -101,6 +102,7 @@ local function spectate_button(player)
return
end
if Public.get('final_battle') then
return
end
@ -684,6 +686,11 @@ Gui.on_click(
return
end
if Public.get('spectate_button_disable') then
player.print('Spectate button is disabled until a bug has been fixed in the base game.', { color = Color.yellow })
return
end
if player.character and player.character.valid then
local success = Public.set_player_to_spectator(player)
if success then

View File

@ -39,18 +39,6 @@ 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
@ -573,7 +561,7 @@ local function input_filtered(car_inv, chest, chest_inv, free_slots)
local prototypes = prototypes.item
local logistics = chest.get_logistic_point(defines.logistic_member_index.logistic_container)
local filters = get_filters(logistics)
local filters = Core.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
@ -621,10 +609,12 @@ local function input_cargo(car, chest)
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
if logistics then
local filters = Core.get_filters(logistics)
for _, filter in pairs(filters) do
if filter.value.name then
has_request_slot = true
end
end
end

View File

@ -28,7 +28,7 @@ function Public.reset()
for k, _ in pairs(this) do
this[k] = nil
end
this.debug_mode = true
this.debug_mode = false
this.restore_on_theft = false
this.doors = {}
this.cars = {}

View File

@ -234,7 +234,11 @@ local function connect_power_pole(entity, wagon_area_left_top_y)
}
for _, pole in pairs(surface.find_entities_filtered({ area = area, name = entity.name })) do
if pole.position.y < wagon_area_left_top_y then
entity.connect_neighbour(pole)
local source_wire = entity.get_wire_connector(5)
local target_wire = pole.get_wire_connector(5)
if source_wire and target_wire then
source_wire.connect_to(target_wire, false)
end
return
end
end

View File

@ -19,18 +19,17 @@ function Public.add_player_to_permission_group(player, group, forced)
local session = Session.get_session_table()
local AG = Antigrief.get()
if not AG then
log('Antigrief not found.')
return
end
local default_group = game.permissions.get_group('Default')
if not default_group then
log('Default group not found.')
return
end
if not valid_groups[string.lower(player.permission_group.name)] then
log('Invalid group.')
return
end
@ -43,102 +42,74 @@ function Public.add_player_to_permission_group(player, group, forced)
default_group.set_allows_action(defines.input_action.deconstruct, false)
end
if not game.permissions.get_group('limited') then
local limited_group = game.permissions.create_group('limited')
if not limited_group then
return
end
limited_group.set_allows_action(defines.input_action.cancel_craft, false)
limited_group.set_allows_action(defines.input_action.drop_item, false)
-- limited_group.set_allows_action(defines.input_action.upgrade, false) -- fixes factorio base issue
-- limited_group.set_allows_action(defines.input_action.upgrade_opened_blueprint_by_item, false)
-- limited_group.set_allows_action(defines.input_action.upgrade_opened_blueprint_by_record, false)
-- limited_group.set_allows_action(defines.input_action.cancel_upgrade, false)
if allow_decon then
limited_group.set_allows_action(defines.input_action.deconstruct, true)
else
limited_group.set_allows_action(defines.input_action.deconstruct, false)
end
local limited_group = game.permissions.get_group('limited') or game.permissions.create_group('limited')
limited_group.set_allows_action(defines.input_action.cancel_craft, false)
limited_group.set_allows_action(defines.input_action.drop_item, false)
if allow_decon then
limited_group.set_allows_action(defines.input_action.deconstruct, true)
else
limited_group.set_allows_action(defines.input_action.deconstruct, false)
end
if not game.permissions.get_group('init_island') then
local init_island = game.permissions.create_group('init_island')
if not init_island then
return
end
init_island.set_allows_action(defines.input_action.cancel_craft, false)
init_island.set_allows_action(defines.input_action.drop_item, false)
init_island.set_allows_action(defines.input_action.gui_click, false)
init_island.set_allows_action(defines.input_action.deconstruct, false)
init_island.set_allows_action(defines.input_action.gui_checked_state_changed, false)
init_island.set_allows_action(defines.input_action.gui_click, false)
init_island.set_allows_action(defines.input_action.gui_confirmed, false)
init_island.set_allows_action(defines.input_action.gui_elem_changed, false)
init_island.set_allows_action(defines.input_action.gui_hover, false)
init_island.set_allows_action(defines.input_action.gui_leave, false)
init_island.set_allows_action(defines.input_action.gui_location_changed, false)
init_island.set_allows_action(defines.input_action.gui_selected_tab_changed, false)
init_island.set_allows_action(defines.input_action.gui_selection_state_changed, false)
init_island.set_allows_action(defines.input_action.gui_switch_state_changed, false)
init_island.set_allows_action(defines.input_action.gui_text_changed, false)
init_island.set_allows_action(defines.input_action.gui_value_changed, false)
local init_island = game.permissions.get_group('init_island') or game.permissions.create_group('init_island')
init_island.set_allows_action(defines.input_action.cancel_craft, false)
init_island.set_allows_action(defines.input_action.drop_item, false)
init_island.set_allows_action(defines.input_action.gui_click, false)
init_island.set_allows_action(defines.input_action.deconstruct, false)
init_island.set_allows_action(defines.input_action.gui_checked_state_changed, false)
init_island.set_allows_action(defines.input_action.gui_click, false)
init_island.set_allows_action(defines.input_action.gui_confirmed, false)
init_island.set_allows_action(defines.input_action.gui_elem_changed, false)
init_island.set_allows_action(defines.input_action.gui_hover, false)
init_island.set_allows_action(defines.input_action.gui_leave, false)
init_island.set_allows_action(defines.input_action.gui_location_changed, false)
init_island.set_allows_action(defines.input_action.gui_selected_tab_changed, false)
init_island.set_allows_action(defines.input_action.gui_selection_state_changed, false)
init_island.set_allows_action(defines.input_action.gui_switch_state_changed, false)
init_island.set_allows_action(defines.input_action.gui_text_changed, false)
init_island.set_allows_action(defines.input_action.gui_value_changed, false)
local near_locomotive_group = game.permissions.get_group('near_locomotive') or game.permissions.create_group('near_locomotive')
near_locomotive_group.set_allows_action(defines.input_action.cancel_craft, false)
near_locomotive_group.set_allows_action(defines.input_action.drop_item, false)
if allow_decon_main_surface then
near_locomotive_group.set_allows_action(defines.input_action.deconstruct, true)
else
near_locomotive_group.set_allows_action(defines.input_action.deconstruct, false)
end
if not game.permissions.get_group('near_locomotive') then
local near_locomotive_group = game.permissions.create_group('near_locomotive')
if not near_locomotive_group then
return
end
near_locomotive_group.set_allows_action(defines.input_action.cancel_craft, false)
near_locomotive_group.set_allows_action(defines.input_action.drop_item, false)
if allow_decon_main_surface then
near_locomotive_group.set_allows_action(defines.input_action.deconstruct, true)
else
near_locomotive_group.set_allows_action(defines.input_action.deconstruct, false)
end
local main_surface_group = game.permissions.get_group('main_surface') or game.permissions.create_group('main_surface')
if allow_decon_main_surface then
main_surface_group.set_allows_action(defines.input_action.deconstruct, true)
else
main_surface_group.set_allows_action(defines.input_action.deconstruct, false)
end
if not game.permissions.get_group('main_surface') then
local main_surface_group = game.permissions.create_group('main_surface')
if not main_surface_group then
return
end
if allow_decon_main_surface then
main_surface_group.set_allows_action(defines.input_action.deconstruct, true)
else
main_surface_group.set_allows_action(defines.input_action.deconstruct, false)
end
end
local not_trusted = game.permissions.get_group('not_trusted') or game.permissions.create_group('not_trusted')
if not game.permissions.get_group('not_trusted') then
local not_trusted = game.permissions.create_group('not_trusted')
if not not_trusted then
return
end
not_trusted.set_allows_action(defines.input_action.cancel_craft, false)
not_trusted.set_allows_action(defines.input_action.edit_permission_group, false)
not_trusted.set_allows_action(defines.input_action.import_permissions_string, false)
not_trusted.set_allows_action(defines.input_action.delete_permission_group, false)
not_trusted.set_allows_action(defines.input_action.add_permission_group, false)
not_trusted.set_allows_action(defines.input_action.admin_action, false)
not_trusted.set_allows_action(defines.input_action.drop_item, false)
not_trusted.set_allows_action(defines.input_action.cancel_research, false)
not_trusted.set_allows_action(defines.input_action.disconnect_rolling_stock, false)
not_trusted.set_allows_action(defines.input_action.connect_rolling_stock, false)
not_trusted.set_allows_action(defines.input_action.open_train_gui, false)
not_trusted.set_allows_action(defines.input_action.open_train_station_gui, false)
not_trusted.set_allows_action(defines.input_action.open_trains_gui, false)
not_trusted.set_allows_action(defines.input_action.change_train_stop_station, false)
not_trusted.set_allows_action(defines.input_action.change_train_wait_condition, false)
not_trusted.set_allows_action(defines.input_action.change_train_wait_condition_data, false)
not_trusted.set_allows_action(defines.input_action.drag_train_schedule, false)
not_trusted.set_allows_action(defines.input_action.drag_train_wait_condition, false)
not_trusted.set_allows_action(defines.input_action.go_to_train_station, false)
not_trusted.set_allows_action(defines.input_action.remove_train_station, false)
not_trusted.set_allows_action(defines.input_action.set_trains_limit, false)
not_trusted.set_allows_action(defines.input_action.set_train_stopped, false)
not_trusted.set_allows_action(defines.input_action.deconstruct, false)
end
not_trusted.set_allows_action(defines.input_action.cancel_craft, false)
not_trusted.set_allows_action(defines.input_action.edit_permission_group, false)
not_trusted.set_allows_action(defines.input_action.import_permissions_string, false)
not_trusted.set_allows_action(defines.input_action.delete_permission_group, false)
not_trusted.set_allows_action(defines.input_action.add_permission_group, false)
not_trusted.set_allows_action(defines.input_action.admin_action, false)
not_trusted.set_allows_action(defines.input_action.drop_item, false)
not_trusted.set_allows_action(defines.input_action.cancel_research, false)
not_trusted.set_allows_action(defines.input_action.disconnect_rolling_stock, false)
not_trusted.set_allows_action(defines.input_action.connect_rolling_stock, false)
not_trusted.set_allows_action(defines.input_action.open_train_gui, false)
not_trusted.set_allows_action(defines.input_action.open_train_station_gui, false)
not_trusted.set_allows_action(defines.input_action.open_trains_gui, false)
not_trusted.set_allows_action(defines.input_action.change_train_stop_station, false)
not_trusted.set_allows_action(defines.input_action.change_train_wait_condition, false)
not_trusted.set_allows_action(defines.input_action.change_train_wait_condition_data, false)
not_trusted.set_allows_action(defines.input_action.drag_train_schedule, false)
not_trusted.set_allows_action(defines.input_action.drag_train_wait_condition, false)
not_trusted.set_allows_action(defines.input_action.go_to_train_station, false)
not_trusted.set_allows_action(defines.input_action.remove_train_station, false)
not_trusted.set_allows_action(defines.input_action.set_trains_limit, false)
not_trusted.set_allows_action(defines.input_action.set_train_stopped, false)
not_trusted.set_allows_action(defines.input_action.deconstruct, false)
if not AG.enabled then
default_group.add_player(player)
@ -151,26 +122,15 @@ function Public.add_player_to_permission_group(player, group, forced)
playtime = player.online_time + session[player.name]
end
local limited_group = game.permissions.get_group('limited')
local main_surface_group = game.permissions.get_group('main_surface')
local near_locomotive_group = game.permissions.get_group('near_locomotive')
if limited_group then
limited_group.set_allows_action(defines.input_action.delete_blueprint_library, false)
limited_group.set_allows_action(defines.input_action.delete_blueprint_record, false)
end
if main_surface_group then
main_surface_group.set_allows_action(defines.input_action.delete_blueprint_library, false)
main_surface_group.set_allows_action(defines.input_action.delete_blueprint_record, false)
end
if near_locomotive_group then
near_locomotive_group.set_allows_action(defines.input_action.delete_blueprint_library, false)
near_locomotive_group.set_allows_action(defines.input_action.delete_blueprint_record, false)
end
if default_group then
default_group.set_allows_action(defines.input_action.delete_blueprint_library, false)
default_group.set_allows_action(defines.input_action.delete_blueprint_record, false)
end
limited_group.set_allows_action(defines.input_action.delete_blueprint_library, false)
limited_group.set_allows_action(defines.input_action.delete_blueprint_record, false)
main_surface_group.set_allows_action(defines.input_action.delete_blueprint_library, false)
main_surface_group.set_allows_action(defines.input_action.delete_blueprint_record, false)
near_locomotive_group.set_allows_action(defines.input_action.delete_blueprint_library, false)
near_locomotive_group.set_allows_action(defines.input_action.delete_blueprint_record, false)
default_group.set_allows_action(defines.input_action.delete_blueprint_library, false)
default_group.set_allows_action(defines.input_action.delete_blueprint_record, false)
if enable_permission_group_disconnect then
if limited_group then
@ -200,44 +160,19 @@ function Public.add_player_to_permission_group(player, group, forced)
end
end
if playtime < required_playtime and not forced then
local not_trusted = game.permissions.get_group('not_trusted')
if not not_trusted then
log('Not trusted group not found.')
return
end
if not Session.get_trusted_player(player) and playtime < required_playtime and not forced then
if not player.admin then
not_trusted.add_player(player)
end
else
if group == 'limited' then
local limited_group_inner = game.permissions.get_group('limited')
if not limited_group_inner then
return
end
limited_group_inner.add_player(player)
limited_group.add_player(player)
elseif group == 'main_surface' then
local main_surface_group_inner = game.permissions.get_group('main_surface')
if not main_surface_group_inner then
return
end
main_surface_group_inner.add_player(player)
main_surface_group.add_player(player)
elseif group == 'init_island' then
local init_island = game.permissions.get_group('init_island')
if not init_island then
return
end
init_island.add_player(player)
elseif group == 'near_locomotive' then
local near_locomotive_group_inner = game.permissions.get_group('near_locomotive')
if not near_locomotive_group_inner then
return
end
near_locomotive_group_inner.add_player(player)
near_locomotive_group.add_player(player)
elseif group == 'default' then
default_group.add_player(player)
end

View File

@ -102,53 +102,6 @@ local is_position_near_tbl = function (position, tbl)
return status
end
local function preinit_task()
local this = Public.get()
game.speed = 1
if this.health_text and this.health_text.valid then this.health_text.destroy() end
if this.caption and this.caption.valid then this.caption.destroy() end
if this.circle and this.circle.valid then this.circle.destroy() end
if this.current_season and this.current_season.valid then this.current_season.destroy() end
if this.counter and this.counter.valid then this.counter.destroy() end
if this.direction_attack and this.direction_attack.valid then this.direction_attack.destroy() end
if this.zone1_text1 and this.zone1_text1.valid then this.zone1_text1.destroy() end
if this.zone1_text2 and this.zone1_text2.valid then this.zone1_text2.destroy() end
if this.zone1_text3 and this.zone1_text3.valid then this.zone1_text3.destroy() end
for i = 1, 5 do
if this['direction_' .. i] and this['direction_' .. i].valid then
this['direction_' .. i].destroy()
end
end
WD.set('game_lost', true)
local players = game.connected_players
for i = 1, #players do
local player = players[i]
Score.init_player_table(player, true)
Misc.insert_all_items(player)
Modifiers.reset_player_modifiers(player)
if player.gui.left['mvps'] then
player.gui.left['mvps'].destroy()
end
WD.destroy_wave_gui(player)
ICMinimap.kill_minimap(player)
Event.raise(Public.events.reset_map, { player_index = player.index })
Public.add_player_to_permission_group(player, 'init_island', true)
player.print(mapkeeper .. ' Map is resetting, please wait a moment. All GUI buttons are disabled at the moment.')
end
Public.reset_func_table()
RPG.reset_table()
Public.sr_reset_forces()
WD.set('wave_interval', 4500)
end
local is_locomotive_valid = function ()
local locomotive = Public.get('locomotive')
if game.ticks_played < 1000 then return end
@ -421,6 +374,83 @@ local nth_1000_tick = function ()
Public.is_creativity_mode_on()
end
function Public.pre_init_task(current_task)
local this = Public.get()
game.speed = 1
current_task.done = nil
current_task.step = 1
if this.health_text and this.health_text.valid then this.health_text.destroy() end
if this.caption and this.caption.valid then this.caption.destroy() end
if this.circle and this.circle.valid then this.circle.destroy() end
if this.current_season and this.current_season.valid then this.current_season.destroy() end
if this.counter and this.counter.valid then this.counter.destroy() end
if this.direction_attack and this.direction_attack.valid then this.direction_attack.destroy() end
if this.zone1_text1 and this.zone1_text1.valid then this.zone1_text1.destroy() end
if this.zone1_text2 and this.zone1_text2.valid then this.zone1_text2.destroy() end
if this.zone1_text3 and this.zone1_text3.valid then this.zone1_text3.destroy() end
for i = 1, 5 do
if this['direction_' .. i] and this['direction_' .. i].valid then
this['direction_' .. i].destroy()
end
end
WD.reset_wave_defense()
WD.alert_boss_wave(true)
WD.enable_side_target(false)
WD.remove_entities(true)
WD.enable_threat_log(false) -- creates waaaay to many entries in the global table
WD.check_collapse_position(true)
WD.set_disable_threat_below_zero(true)
WD.increase_boss_health_per_wave(true)
WD.increase_damage_per_wave(true)
WD.increase_health_per_wave(true)
WD.increase_average_unit_group_size(true)
WD.increase_max_active_unit_groups(true)
WD.enable_random_spawn_positions(true)
WD.set_track_bosses_only(true)
WD.set_pause_waves_custom_callback(Public.pause_waves_custom_callback_token)
WD.set_threat_event_custom_callback(Public.check_if_spawning_near_train_custom_callback)
WD.set('surface_index', this.active_surface_index)
WD.set('nest_building_density', 32)
WD.set('spawn_position', { x = 0, y = 84 })
WD.set('game_lost', true)
local players = game.connected_players
for i = 1, #players do
local player = players[i]
Score.init_player_table(player, true)
Misc.insert_all_items(player)
Modifiers.reset_player_modifiers(player)
if player.gui.left['mvps'] then
player.gui.left['mvps'].destroy()
end
WD.destroy_wave_gui(player)
ICMinimap.kill_minimap(player)
Event.raise(Public.events.reset_map, { player_index = player.index })
Public.add_player_to_permission_group(player, 'init_island', true)
player.print(mapkeeper .. ' Map is resetting, please wait a moment. All GUI buttons are disabled at the moment.')
end
Public.reset_func_table()
RPG.reset_table()
Public.stateful.clear_all_frames()
Public.sr_reset_forces()
WD.set('wave_interval', 4500)
current_task.message = 'Pre init done!'
current_task.state = 'init_stateful'
end
function Public.post_init_task(current_task)
Public.stateful.increase_enemy_damage_and_health()
current_task.message = 'Post init done!'
current_task.state = 'create_locomotive'
end
function Public.create_locomotive(current_task)
if Public.get('disable_startup_notification') then return end
local adjusted_zones = Public.get('adjusted_zones')
@ -446,6 +476,11 @@ function Public.create_locomotive(current_task)
Public.render_train_hp()
Public.render_direction(surface, adjusted_zones.reversed)
local locomotive = Public.get('locomotive')
if locomotive and locomotive.valid then
WD.set_main_target(locomotive)
end
current_task.message = 'Created locomotive!'
current_task.delay = game.tick + 60
current_task.state = 'announce_new_map'
@ -458,7 +493,7 @@ function Public.announce_new_map(current_task)
Server.to_discord_named_raw(send_ping_to_channel, role_to_mention .. ' ** Mtn Fortress was just reset! **')
end
current_task.message = 'Announced new map!'
current_task.state = 'move_players_to_nauvis'
current_task.state = 'to_nauvis'
current_task.surface_name = 'nauvis'
current_task.delay = game.tick + 200
end
@ -469,11 +504,6 @@ function Public.move_players(current_task)
return
end
current_task.done = nil
current_task.step = 1
preinit_task()
for _, player in pairs(game.players) do
local pos = surface.find_non_colliding_position("character", { x = 0, y = 0 }, 3, 0)
if pos then
@ -484,10 +514,10 @@ function Public.move_players(current_task)
end
current_task.message = 'Moved players to initial surface!'
current_task.delay = game.tick + 200
current_task.state = 'init_stateful'
current_task.state = 'pre_init_task'
end
function Public.move_players_to_nauvis(current_task)
function Public.to_nauvis(current_task)
local surface = game.get_surface(current_task.surface_name)
if not surface or not surface.valid then
return
@ -537,7 +567,6 @@ function Public.init_stateful(current_task)
Public.reset_main_table()
Public.stateful.enable(true)
Public.stateful.reset_stateful(false, true)
Public.stateful.increase_enemy_damage_and_health()
Public.stateful.apply_startup_settings()
current_task.message = 'Initialized stateful!'
current_task.state = 'clear_nauvis'
@ -569,13 +598,12 @@ end
function Public.reset_map(current_task)
local this = Public.get()
local wave_defense_table = WD.get_table()
Misc.reset()
LinkedChests.reset()
Public.stateful.clear_all_frames()
BottomFrame.reset()
Public.reset_buried_biters()
@ -630,12 +658,7 @@ function Public.reset_map(current_task)
game.forces.player.worker_robots_battery_modifier = 4
game.forces.player.worker_robots_storage_bonus = 15
WD.reset_wave_defense()
wave_defense_table.surface_index = this.active_surface_index
wave_defense_table.target = this.locomotive
wave_defense_table.nest_building_density = 32
wave_defense_table.game_lost = false
wave_defense_table.spawn_position = { x = 0, y = 84 }
-- WD.set_es_unit_limit(400) -- moved to stateful
Event.raise(WD.events.on_game_reset, {})
@ -697,11 +720,9 @@ function Public.reset_map(current_task)
WD.disable_spawning_biters(true)
end
current_task.message = 'Reset map done!'
current_task.delay = game.tick + 60
current_task.state = 'create_locomotive'
current_task.state = 'post_init_task'
end
function Public.init_mtn()

View File

@ -1381,8 +1381,6 @@ local apply_settings_token =
end
this.objectives = {}
Public.increase_enemy_damage_and_health()
end
)

View File

@ -190,6 +190,7 @@ function Public.reset_main_table()
this.block_non_trusted_opening_trains = true
this.block_non_trusted_trigger_collapse = true
this.allow_decon_main_surface = true
this.spectate_button_disable = true
this.flamethrower_damage = {}
this.mined_scrap = 0
this.print_tech_to_discord = true

View File

@ -2580,7 +2580,7 @@ end
local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
local p = { x = x, y = y }
local seed = data.seed
local seed = data.seed + 10000
local buildings = data.buildings
local tiles = data.tiles
local entities = data.entities
@ -2594,7 +2594,7 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
local cave_rivers = Public.get_noise('cave_rivers', p, seed)
local no_rocks = Public.get_noise('no_rocks', p, seed)
if smol_areas < 0.057 and smol_areas > -0.021 then
if smol_areas < 0.07 and smol_areas > -0.03 then
tiles[#tiles + 1] = { name = void_or_lab, position = p }
if random(1, 32) == 1 then
Public.spawn_random_buildings(buildings, p)
@ -2611,21 +2611,21 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
end
--Chasms
if noise_cave_ponds < 0.105 and noise_cave_ponds > -0.112 then
if small_caves > 0.52 then
if noise_cave_ponds < 0.12 and noise_cave_ponds > -0.08 then
if small_caves > 0.45 then
tiles[#tiles + 1] = { name = void_or_lab, position = p }
return
end
if small_caves < -0.52 then
if small_caves < -0.45 then
tiles[#tiles + 1] = { name = void_or_lab, position = p }
return
end
end
--Water Ponds
if noise_cave_ponds > 0.6 then
if noise_cave_ponds > 0.74 then
tiles[#tiles + 1] = { name = 'acid-refined-concrete', position = p }
if noise_cave_ponds > 0.65 then
if noise_cave_ponds > 0.75 then
tiles[#tiles + 1] = { name = 'blue-refined-concrete', position = p }
if random(1, 4) == 1 then
markets[#markets + 1] = p
end
@ -2642,8 +2642,8 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
end
--Rivers
if cave_rivers < 0.044 and cave_rivers > -0.072 then
if noise_cave_ponds > 0.1 then
if cave_rivers < 0.05 and cave_rivers > -0.05 then
if noise_cave_ponds > 0.15 then
tiles[#tiles + 1] = { name = 'water-shallow', position = p }
if random(1, 64) == 1 then
entities[#entities + 1] = { name = 'fish', position = p }
@ -2652,9 +2652,9 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
end
end
if noise_cave_ponds > 0.622 then
if noise_cave_ponds > 0.542 then
if cave_rivers > -0.302 then
if noise_cave_ponds > 0.68 then
if noise_cave_ponds > 0.55 then
if cave_rivers > -0.35 then
tiles[#tiles + 1] = { name = 'refined-hazard-concrete-right', position = p }
end
end
@ -2665,9 +2665,9 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
end
--Worm oil Zones
if no_rocks < 0.029 and no_rocks > -0.245 then
if small_caves > 0.081 then
tiles[#tiles + 1] = { name = 'brown-refined-concrete', position = p }
if no_rocks < 0.04 and no_rocks > -0.22 then
if small_caves > 0.1 then
tiles[#tiles + 1] = { name = 'nuclear-ground', position = p }
if random(1, 250) == 1 then
entities[#entities + 1] = { name = 'crude-oil', position = p, amount = get_oil_amount(p) }
end
@ -2691,7 +2691,7 @@ local function starting_zone(x, y, data, void_or_lab, adjusted_zones)
end
--Main Rock Terrain
if no_rocks_2 > 0.334 and no_rocks_2 < 0.544 then
if no_rocks_2 > 0.35 and no_rocks_2 < 0.55 then
local success = place_wagon(data, adjusted_zones)
if success then
return

View File

@ -2,6 +2,7 @@
-- modified by gerkiz
local Global = require 'utils.global'
local Core = require 'utils.core'
local SpamProtection = require 'utils.spam_protection'
local Color = require 'utils.color_presets'
local Event = require 'utils.event'
@ -40,18 +41,6 @@ local bps_blacklist = {
['blueprint'] = true
}
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
local on_init_token =
Task.register(
function ()
@ -149,12 +138,12 @@ local function chest_is_valid(chest)
) do
if e.name ~= 'long-handed-inserter' then
if e.position.x == chest.position.x then
if e.direction == 0 or e.direction == 4 then
if e.direction == 0 or e.direction == 8 then
return false
end
end
if e.position.y == chest.position.y then
if e.direction == 2 or e.direction == 6 then
if e.direction == 4 or e.direction == 12 then
return false
end
end
@ -272,13 +261,13 @@ local function check_if_valid_requests(chest)
return false
end
if chest.type == 'logistic-container' then
local logistics = chest.get_logistic_point(defines.logistic_member_index.logistic_container)
local filters = get_filters(logistics)
local logistics = chest.get_logistic_point(defines.logistic_member_index.logistic_container)
if logistics then
local filters = Core.get_filters(logistics)
return #filters > 0
else
return false
end
return false
end
local function insert_to_furnace(player_inventory, chests, name, count, floaty_text_list)
@ -430,7 +419,7 @@ local function insert_into_wagon_filtered(stack, chests, name, floaty_text_list)
if chest.type == 'logistic-container' then
local chest_inventory = chests.inventory[chestnr]
local logistics = chest.get_logistic_point(defines.logistic_member_index.logistic_container)
local filters = get_filters(logistics)
local filters = Core.get_filters(logistics)
for _, filter in pairs(filters) do
if filter.value.name == name then
local inserted_count = chest_inventory.insert(stack)
@ -469,7 +458,7 @@ local function insert_item_into_chest(stack, chests, filtered_chests, name, floa
if chest.type == 'logistic-container' then
local chest_inventory = chests.inventory[chestnr]
local logistics = chest.get_logistic_point(defines.logistic_member_index.logistic_container)
local filters = get_filters(logistics)
local filters = Core.get_filters(logistics)
for _, filter in pairs(filters) do
if filter.value.name == name then
local inserted_count = chest_inventory.insert(stack)

View File

@ -1,63 +0,0 @@
--module by Hanakocz
local Event = require 'utils.event'
local Global = require 'utils.global'
local Public = {}
local this = {}
Global.register(
this,
function(tbl)
this = tbl
end
)
local function on_gui_closed(event)
local player_index = event.player_index
if this[player_index] and this[player_index].disabled then return end -- player disabled usage of this module in config tab for his actions
local entity = event.entity
if not entity or not entity.valid then return end
if entity.name == 'logistic-chest-requester' or entity.name == 'logistic-chest-buffer' then
if not this[player_index] or not this[player_index].notified then
local player = game.get_player(player_index)
player.print({'modules.blueprint_requesting_notify'}, {r= 0.88, g = 0.66, b = 0.02})
this[player_index] = this[player_index] or {}
this[player_index].notified = true
end
local inventory = entity.get_inventory(defines.inventory.chest)
if not inventory or not inventory.valid then return end
if inventory.get_item_count('blueprint') > 0 then
local items = {}
for i = 1, #inventory, 1 do
if inventory[i].valid_for_read and inventory[i].is_blueprint then
local cost = inventory[i].cost_to_build
for name, amount in pairs(cost) do
items[name] = (items[name] or 0) + amount
end
end
end
if entity.request_slot_count > 0 then
for slot = 1, entity.request_slot_count, 1 do
entity.clear_request_slot(slot)
end
end
local slot_index = 1
for item, amount in pairs(items) do
entity.set_request_slot({name = item, count = amount}, slot_index)
slot_index = slot_index + 1
end
end
end
end
function Public.get(key)
if key then
return this[key]
else
return this
end
end
Event.add(defines.events.on_gui_closed, on_gui_closed)
return Public

View File

@ -1626,7 +1626,7 @@ function Public.global_pool(players, count)
end
end
rpg_extra.global_pool = rpg_extra.leftover_pool or 0
rpg_extra.global_pool = round(rpg_extra.leftover_pool or 0, 8)
end
local damage_player_over_time_token =

View File

@ -1,7 +1,8 @@
local Public = require 'modules.wave_defense.table'
local round = math.round
function Public.wave_defense_roll_biter_name()
local biter_raffle = Public.get('biter_raffle')
local biter_raffle = Public.get('biter_raffle') --[[@as table]]
local max_chance = 0
for _, v in pairs(biter_raffle) do
max_chance = max_chance + v
@ -17,7 +18,7 @@ function Public.wave_defense_roll_biter_name()
end
function Public.wave_defense_roll_spitter_name()
local spitter_raffle = Public.get('spitter_raffle')
local spitter_raffle = Public.get('spitter_raffle') --[[@as table]]
local max_chance = 0
for _, v in pairs(spitter_raffle) do
max_chance = max_chance + v
@ -36,8 +37,8 @@ function Public.wave_defense_set_unit_raffle(level)
Public.set(
'biter_raffle',
{
['small-biter'] = 1000 - level * 1.75,
['medium-biter'] = level,
['small-biter'] = round(1000 - level * 1.75, 6),
['medium-biter'] = round(level, 6),
['big-biter'] = 0,
['behemoth-biter'] = 0
}
@ -46,24 +47,24 @@ function Public.wave_defense_set_unit_raffle(level)
Public.set(
'spitter_raffle',
{
['small-spitter'] = 1000 - level * 1.75,
['medium-spitter'] = level,
['small-spitter'] = round(1000 - level * 1.75, 6),
['medium-spitter'] = round(level, 6),
['big-spitter'] = 0,
['behemoth-spitter'] = 0
}
)
local biter_raffle = Public.get('biter_raffle')
local spitter_raffle = Public.get('spitter_raffle')
local biter_raffle = Public.get('biter_raffle') --[[@as table]]
local spitter_raffle = Public.get('spitter_raffle') --[[@as table]]
if level > 500 then
biter_raffle['medium-biter'] = 500 - (level - 500)
spitter_raffle['medium-spitter'] = 500 - (level - 500)
biter_raffle['big-biter'] = (level - 500) * 2
spitter_raffle['big-spitter'] = (level - 500) * 2
biter_raffle['medium-biter'] = round(500 - (level - 500), 6)
spitter_raffle['medium-spitter'] = round(500 - (level - 500), 6)
biter_raffle['big-biter'] = round((level - 500) * 2, 6)
spitter_raffle['big-spitter'] = round((level - 500) * 2, 6)
end
if level > 800 then
biter_raffle['behemoth-biter'] = (level - 800) * 2.75
spitter_raffle['behemoth-spitter'] = (level - 800) * 2.75
biter_raffle['behemoth-biter'] = round((level - 800) * 2.75, 6)
spitter_raffle['behemoth-spitter'] = round((level - 800) * 2.75, 6)
end
for k, _ in pairs(biter_raffle) do
if biter_raffle[k] < 0 then
@ -78,7 +79,7 @@ function Public.wave_defense_set_unit_raffle(level)
end
function Public.wave_defense_roll_worm_name()
local worm_raffle = Public.get('worm_raffle')
local worm_raffle = Public.get('worm_raffle') --[[@as table]]
local max_chance = 0
for _, v in pairs(worm_raffle) do
max_chance = max_chance + v
@ -97,20 +98,20 @@ function Public.wave_defense_set_worm_raffle(level)
Public.set(
'worm_raffle',
{
['small-worm-turret'] = 1000 - level * 1.75,
['medium-worm-turret'] = level,
['small-worm-turret'] = round(1000 - level * 1.75, 6),
['medium-worm-turret'] = round(level, 6),
['big-worm-turret'] = 0,
['behemoth-worm-turret'] = 0
}
)
local worm_raffle = Public.get('worm_raffle')
local worm_raffle = Public.get('worm_raffle') --[[@as table]]
if level > 500 then
worm_raffle['medium-worm-turret'] = 500 - (level - 500)
worm_raffle['big-worm-turret'] = (level - 500) * 2
worm_raffle['medium-worm-turret'] = round(500 - (level - 500), 6)
worm_raffle['big-worm-turret'] = round((level - 500) * 2, 6)
end
if level > 800 then
worm_raffle['behemoth-worm-turret'] = (level - 800) * 3
worm_raffle['behemoth-worm-turret'] = round((level - 800) * 3, 6)
end
for k, _ in pairs(worm_raffle) do
if worm_raffle[k] < 0 then

View File

@ -38,6 +38,18 @@ function Public.print_except(msg, player, color)
end
end
function Public.get_filters(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
function Public.print_to(player_ident, msg, color)
local player = Public.validate_player(player_ident)
color = color or Color.yellow
@ -398,7 +410,7 @@ function Public.validate_player(player_ident, check_admin)
local data_type = type(player_ident)
local player
if data_type == 'table' and player_ident.valid then
if data_type == 'userdata' and player_ident.valid then
local is_player = player_ident.is_player()
if is_player then
player = player_ident

View File

@ -126,18 +126,6 @@ local functions = {
game.get_player(event.player_index).spectator = false
end
end,
['blueprint_requesting'] = function (event)
local BPRequests = is_loaded('modules.blueprint_requesting')
local Module = BPRequests.get()
if not Module[event.player_index] then
Module[event.player_index] = {}
end
if event.element.switch_state == 'left' then
Module[event.player_index].disabled = false
else
Module[event.player_index].disabled = true
end
end,
['top_location'] = function (event)
local player = game.get_player(event.player_index)
local data = BottomFrame.get_player_data(player)
@ -562,17 +550,6 @@ local function build_config_gui(data)
scroll_pane.add({ type = 'line' })
end
local BPRequests = is_loaded('modules.blueprint_requesting')
if BPRequests then
local Module = BPRequests.get()
switch_state = 'left'
if Module[player.index] and Module[player.index].disabled then
switch_state = 'right'
end
add_switch(scroll_pane, switch_state, 'blueprint_requesting', { 'modules.blueprint_requesting' }, { 'modules.blueprint_requesting_desc' })
scroll_pane.add({ type = 'line' })
end
if BottomFrame.is_custom_buttons_enabled() then
label = scroll_pane.add({ type = 'label', caption = 'Bottom Buttons Settings' })
label.style.font = 'default-bold'