1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-07-15 01:04:17 +02:00

Merge branch 'develop' into develop

This commit is contained in:
Gerkiz
2024-07-29 12:12:05 +02:00
committed by GitHub
10 changed files with 329 additions and 260 deletions

View File

@ -277,17 +277,33 @@ local compare_player_and_train = function(player, entity)
local spidertron_warning_position = gap_between_zones.neg_gap + 50 local spidertron_warning_position = gap_between_zones.neg_gap + 50
local locomotive_distance_too_far = c_y - t_y > spidertron_warning_position local locomotive_distance_too_far = c_y - t_y > spidertron_warning_position
local spidertron_warning_position_pre_warning = spidertron_warning_position - 100
if locomotive_distance_too_far then local locomotive_distance_too_far_pre_warning = c_y - t_y > spidertron_warning_position_pre_warning
local surface = player.surface local surface = player.surface
local color = Color.yellow
if locomotive_distance_too_far_pre_warning and not locomotive_distance_too_far then
local msg = 'Warning! You are getting too far away from the train!'
surface.create_entity( surface.create_entity(
{ {
name = 'flying-text', name = 'flying-text',
position = position, position = position,
text = 'Warning! You are too far away from the main locomotive!', text = msg,
color = {r = 0.9, g = 0.0, b = 0.0} color = color
} }
) )
player.print(msg, color)
elseif locomotive_distance_too_far then
local msg = 'Warning! You are too far away from the train! TURN BACK!'
surface.create_entity(
{
name = 'flying-text',
position = position,
text = msg,
color = color
}
)
player.print(msg, color)
if entity.health then if entity.health then
if car and car.health_pool and car.health_pool.health then if car and car.health_pool and car.health_pool.health then
car.health_pool.health = car.health_pool.health - 500 car.health_pool.health = car.health_pool.health - 500

View File

@ -154,7 +154,7 @@ local pause_waves_custom_callback_token =
local wave_number = WD.get_wave() local wave_number = WD.get_wave()
if wave_number >= 200 then if wave_number >= 200 then
Collapse.start_now(event.start, not event.start) Collapse.start_now(event.start, not event.start)
local status_str = event.start and 'has stopped!' or 'is active once again!' local status_str = event.start and 'is active once again!' or 'has stopped!'
Alert.alert_all_players(30, 'Collapse ' .. status_str, nil, 'achievement/tech-maniac', 0.6) Alert.alert_all_players(30, 'Collapse ' .. status_str, nil, 'achievement/tech-maniac', 0.6)
end end
end end

View File

@ -490,7 +490,7 @@ local compare_collapse_and_train = function ()
if reverse_result > 200 then if reverse_result > 200 then
Collapse.reverse_start_now(true, false) Collapse.reverse_start_now(true, false)
Collapse.set_speed(1) Collapse.set_speed(1)
Collapse.set_amount(10) Collapse.set_amount(40)
else else
if Collapse.has_reverse_collapse_started() then if Collapse.has_reverse_collapse_started() then
Collapse.reverse_start_now(false, true) Collapse.reverse_start_now(false, true)
@ -502,7 +502,7 @@ local compare_collapse_and_train = function ()
if result > 200 then if result > 200 then
Collapse.start_now(true, false) Collapse.start_now(true, false)
Collapse.set_speed(1) Collapse.set_speed(1)
Collapse.set_amount(10) Collapse.set_amount(40)
else else
if Collapse.has_collapse_started() then if Collapse.has_collapse_started() then
Collapse.start_now(false, true) Collapse.start_now(false, true)

View File

@ -293,11 +293,11 @@ local restore_crafting_speed_token =
local restore_movement_speed_token = local restore_movement_speed_token =
Task.register( Task.register(
function() function (event)
local mc_rewards = Public.get('mc_rewards') local mc_rewards = Public.get('mc_rewards')
local force = game.forces.player local force = game.forces.player
if mc_rewards.temp_boosts.movement then if mc_rewards.temp_boosts.movement then
force.character_running_speed_modifier = force.character_running_speed_modifier - 0.2 force.character_running_speed_modifier = event.speed
mc_rewards.temp_boosts.movement = nil mc_rewards.temp_boosts.movement = nil
local message = ({ 'locomotive.movement_bonus_end' }) local message = ({ 'locomotive.movement_bonus_end' })
Alert.alert_all_players(10, message, nil, 'achievement/tech-maniac') Alert.alert_all_players(10, message, nil, 'achievement/tech-maniac')
@ -355,7 +355,7 @@ local mc_random_rewards = {
mc_rewards.temp_boosts.movement = true mc_rewards.temp_boosts.movement = true
Task.set_timeout_in_ticks(54000, restore_movement_speed_token) Task.set_timeout_in_ticks(54000, restore_movement_speed_token, { speed = force.character_running_speed_modifier })
force.character_running_speed_modifier = force.character_running_speed_modifier + 0.6 force.character_running_speed_modifier = force.character_running_speed_modifier + 0.6
local message = ({ 'locomotive.movement_bonus', player.name }) local message = ({ 'locomotive.movement_bonus', player.name })
Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac') Alert.alert_all_players(15, message, nil, 'achievement/tech-maniac')

View File

@ -197,7 +197,7 @@ Event.add(
return return
end end
launch_item.actual = launch_item.actual + slot.count launch_item.actual = launch_item.actual + 1
end end
end end
end end

View File

@ -43,7 +43,7 @@ Global.register(
end end
) )
local damage_types = { 'physical', 'electric', 'poison', 'laser' } local damage_types = { 'physical', 'explosion', 'laser' }
local buff_to_string = { local buff_to_string = {
['starting_items'] = 'Starting items', ['starting_items'] = 'Starting items',
@ -87,9 +87,17 @@ local function notify_season_over_to_discord()
for name, buff_data in pairs(stateful.buffs_collected) do for name, buff_data in pairs(stateful.buffs_collected) do
if type(buff_data.amount) ~= 'table' and name ~= 'starting_items' then if type(buff_data.amount) ~= 'table' and name ~= 'starting_items' then
if name == 'xp_level' or name == 'xp_bonus' or name == 'character_health_bonus' then if name == 'xp_level' or name == 'xp_bonus' or name == 'character_health_bonus' then
if buff_data.count and buff_to_string[name] then
buffs = buffs .. buff_to_string[name] .. ': ' .. buff_data.count buffs = buffs .. buff_to_string[name] .. ': ' .. buff_data.count
else else
buffs = buffs .. name .. ': Active'
end
else
if buff_data.count and buff_to_string[name] then
buffs = buffs .. buff_to_string[name] .. ': ' .. (buff_data.count * 100) .. '%' buffs = buffs .. buff_to_string[name] .. ': ' .. (buff_data.count * 100) .. '%'
else
buffs = buffs .. name .. ': Active'
end
end end
buffs = buffs .. '\n' buffs = buffs .. '\n'
end end
@ -874,24 +882,24 @@ end
local function get_random_spell() local function get_random_spell()
local items = { local items = {
{ 'small-biter', scale(1000, 10000) }, { 'small-biter', scale(100, 2500) },
{ 'small-spitter', scale(1000, 60000) }, { 'small-spitter', scale(100, 2500) },
{ 'medium-biter', scale(1000, 200000) }, { 'medium-biter', scale(100, 2500) },
{ 'medium-spitter', scale(1000, 100000) }, { 'medium-spitter', scale(100, 2500) },
{ 'shotgun-shell', scale(1000, 100000) }, { 'shotgun-shell', scale(100, 2500) },
{ 'grenade', scale(1000, 80000) }, { 'grenade', scale(100, 2500) },
{ 'cluster-grenade', scale(1000, 50000) }, { 'cluster-grenade', scale(100, 2500) },
{ 'cannon-shell', scale(1000, 100000) }, { 'cannon-shell', scale(100, 2500) },
{ 'explosive-cannon-shell', scale(1000, 50000) }, { 'explosive-cannon-shell', scale(100, 2500) },
{ 'uranium-cannon-shell', scale(1000, 100000) }, { 'uranium-cannon-shell', scale(100, 2500) },
{ 'rocket', scale(1000, 100000) }, { 'rocket', scale(100, 2500) },
{ 'acid-stream-spitter-big', scale(1000, 200000) }, { 'acid-stream-spitter-big', scale(100, 2500) },
{ 'explosives', scale(5000, 100000) }, { 'explosives', scale(100, 2500) },
{ 'distractor-capsule', scale(5000, 100000) }, { 'distractor-capsule', scale(100, 2500) },
{ 'defender-capsule', scale(5000, 100000) }, { 'defender-capsule', scale(100, 2500) },
{ 'destroyer-capsule', scale(5000, 100000) }, { 'destroyer-capsule', scale(100, 2500) },
{ 'warp-gate', scale(5000, 500000) }, { 'warp-gate', scale(100, 2500) },
{ 'haste', scale(5000, 500000) } { 'haste', scale(100, 2500) }
} }
shuffle(items) shuffle(items)
@ -918,7 +926,7 @@ local function get_random_research_recipe()
return { name = research_level_list[1], count = 1, research_count = 0 } return { name = research_level_list[1], count = 1, research_count = 0 }
end end
return { name = research_level_list[1], count = scale(2, 11, 1.03), research_count = 0 } return { name = research_level_list[1], count = scale(2, 9, 1.03), research_count = 0 }
end end
local function get_random_objectives() local function get_random_objectives()
@ -1551,7 +1559,7 @@ function Public.reset_stateful(refresh_gui, clear_buffs)
if not this.objectives.cast_spell_any or (this.objectives_completed ~= nil and this.objectives_completed.cast_spell_any) then if not this.objectives.cast_spell_any or (this.objectives_completed ~= nil and this.objectives_completed.cast_spell_any) then
this.objectives.cast_spell_any = { this.objectives.cast_spell_any = {
actual = 0, actual = 0,
expected = scale(1000, 4000000), expected = scale(100, 1000),
name = 'Any' name = 'Any'
} }
end end
@ -1559,7 +1567,7 @@ function Public.reset_stateful(refresh_gui, clear_buffs)
local item = get_random_handcrafted_item() local item = get_random_handcrafted_item()
this.objectives.launch_item = { this.objectives.launch_item = {
actual = 0, actual = 0,
expected = scale(10, 700), expected = scale(1, 50),
name = item.name name = item.name
} }
end end

View File

@ -1535,54 +1535,57 @@ local function event_on_player_joined_game(event)
player.force = Common.lobby_force_name player.force = Common.lobby_force_name
-- It was suggested to always spawn players in lobby, in hopes that they may want to create their crew increasing the popularity of scenario.
-- Auto-join the oldest crew: -- Auto-join the oldest crew:
local ages = {} -- local ages = {}
for _, memory in pairs(global_memory.crew_memories) do -- for _, memory in pairs(global_memory.crew_memories) do
if Common.is_id_valid(memory.id) -- if Common.is_id_valid(memory.id)
and (not memory.run_is_private) -- and (not memory.run_is_private)
and memory.crewstatus == Crew.enum.ADVENTURING -- and memory.crewstatus == Crew.enum.ADVENTURING
and memory.capacity -- and memory.capacity
and memory.crewplayerindices -- and memory.crewplayerindices
and #memory.crewplayerindices < memory.capacity -- and #memory.crewplayerindices < memory.capacity
and (not (memory.tempbanned_from_joining_data -- and (not (memory.tempbanned_from_joining_data
and memory.tempbanned_from_joining_data[player.index] -- and memory.tempbanned_from_joining_data[player.index]
and game.tick < memory.tempbanned_from_joining_data[player.index] + Common.ban_from_rejoining_crew_ticks)) then -- and game.tick < memory.tempbanned_from_joining_data[player.index] + Common.ban_from_rejoining_crew_ticks)) then
ages[#ages+1] = {id = memory.id, age = memory.age, large = (memory.capacity >= Common.minimum_run_capacity_to_enforce_space_for)} -- ages[#ages+1] = {id = memory.id, age = memory.age, large = (memory.capacity >= Common.minimum_run_capacity_to_enforce_space_for)}
end -- end
end -- end
table.sort( -- table.sort(
ages, -- ages,
function(a, b) --true if a should be to the left of b -- function(a, b) --true if a should be to the left of b
if a.large and (not b.large) then -- if a.large and (not b.large) then
return true -- return true
elseif (not a.large) and b.large then -- elseif (not a.large) and b.large then
return false -- return false
else -- else
return a.age > b.age -- return a.age > b.age
end -- end
end -- end
) -- )
if ages[1] then -- if ages[1] then
Crew.join_crew(player) -- Crew.join_crew(player)
local memory = global_memory.crew_memories[ages[1].id] -- local memory = global_memory.crew_memories[ages[1].id]
if (not memory.run_is_protected) and #memory.crewplayerindices <= 1 then -- if (not memory.run_is_protected) and #memory.crewplayerindices <= 1 then
Roles.make_captain(player) -- Roles.make_captain(player)
end -- end
if ages[2] then -- if ages[2] then
if ages[1].large and (not ages[#ages].large) then -- if ages[1].large and (not ages[#ages].large) then
Common.notify_player_announce(player, {'pirates.goto_oldest_crew_with_large_capacity'}) -- Common.notify_player_announce(player, {'pirates.goto_oldest_crew_with_large_capacity'})
else -- else
Common.notify_player_announce(player, {'pirates.goto_oldest_crew'}) -- Common.notify_player_announce(player, {'pirates.goto_oldest_crew'})
end -- end
end -- end
if memory.run_is_protected and (not Roles.captain_exists()) then -- if memory.run_is_protected and (not Roles.captain_exists()) then
Common.notify_player_expected(player, {'pirates.player_joins_protected_run_with_no_captain'}) -- Common.notify_player_expected(player, {'pirates.player_joins_protected_run_with_no_captain'})
Common.notify_player_expected(player, {'pirates.create_new_crew_tip'}) -- Common.notify_player_expected(player, {'pirates.create_new_crew_tip'})
end -- end
end -- end
end end
if not _DEBUG then if not _DEBUG then

View File

@ -79,9 +79,15 @@ function Public:new_target()
local chunk = surface.get_random_chunk() local chunk = surface.get_random_chunk()
local random_position = { x = (chunk.x + random()) * 32, y = (chunk.y + random()) * 32 } local random_position = { x = (chunk.x + random()) * 32, y = (chunk.y + random()) * 32 }
if not position then
entities = surface.find_entities_filtered { type = 'character', force = 'player' }
if entities and #entities > 0 then
position = entities[random(#entities)].position
end
if not position then if not position then
return random_position, random_position return random_position, random_position
end end
end
return position, random_position return position, random_position
end end

View File

@ -1393,6 +1393,36 @@ Event.add(
end end
) )
---@param event EventData.on_console_chat
Event.add(defines.events.on_console_chat, function (event)
if not event.player_index then
return
end
local player = game.get_player(event.player_index)
if not player or not player.valid then
return
end
local secs = Server.get_current_time()
if not secs then
return
end
local p_data = get_player_data(player)
if jailed[player.name] and p_data and p_data.locked then
p_data.ping = p_data.ping or 0
if string.match(event.message, "gps") ~= nil then
p_data.ping = p_data.ping + 1
if p_data.ping == 3 then
local gulag = get_super_gulag_permission_group()
gulag.add_player(player)
Utils.print_to(nil, module_name .. player.name .. ' tried to spammy spammy from the gulag but the warden denied their request.')
p_data.ping = nil
end
return
end
end
end)
Gui.on_text_changed( Gui.on_text_changed(
placeholder_jail_text_box, placeholder_jail_text_box,
function (event) function (event)

View File

@ -196,12 +196,18 @@ local function player_list_show(data)
} }
) )
if sort_by then if sort_by then
this.player_list.sorting_method[data.player.index] = sort_by this.player_list.sorting_method[data.player.index] = sort_by
else else
sort_by = this.player_list.sorting_method[data.player.index] sort_by = this.player_list.sorting_method[data.player.index]
end end
if this.player_list.sorting_method[data.player.index] == '_desc' or this.player_list.sorting_method[data.player.index] == '_asc' then
this.player_list.sorting_method[data.player.index] = 'total_time_desc'
end
if not sort_by then if not sort_by then
sort_by = 'total_time_desc' sort_by = 'total_time_desc'
end end
@ -387,10 +393,10 @@ Gui.on_click(
end end
if string.find(element.caption, symbol_desc) then if string.find(element.caption, symbol_desc) then
local data = {player = player, frame = frame, sort_by = parent.name .. '_asc'} local data = { player = player, frame = frame, sort_by = parent.name and parent.name:len() > 0 and parent.name .. '_asc' or nil }
player_list_show(data) player_list_show(data)
else else
local data = {player = player, frame = frame, sort_by = parent.name .. '_desc'} local data = { player = player, frame = frame, sort_by = parent.name and parent.name:len() > 0 and parent.name .. '_desc' or nil }
player_list_show(data) player_list_show(data)
end end
local is_spamming = SpamProtection.is_spamming(player, nil, 'PlayerList Gui Click') local is_spamming = SpamProtection.is_spamming(player, nil, 'PlayerList Gui Click')