1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-03 13:12:11 +02:00

fix crafting disabled time

This commit is contained in:
danielmartin0 2024-09-11 17:09:47 +01:00
parent 95f16e7423
commit 74827d2208
5 changed files with 33 additions and 22 deletions

View File

@ -79,6 +79,7 @@ parrot_buried_treasure_tip=Squawk! If X marks the spot - use an item to dig!
parrot_captain_left_protected_run=The captain has disconnected. Since this crew is captain-protected, the captain role will not be redistributed for __1__ hours. Squawk!
parrot_player_joins_protected_run_with_no_captain=Hello there! Since this crew is captain-protected, you will have to wait for captain to return in order to control the ship.
parrot_create_new_crew_tip=You can always create or join another crew. To do this, press the red flag on top, click 'Quit Crew', then press 'Crews'.
parrot_crafters_disabled=Our machines have stopped whilst we're waiting at sea. Gotta keep moving!
difficulty_easy=Easy
difficulty_normal=Normal

View File

@ -101,12 +101,20 @@ function Public.apply_restrictions_to_machines(tickinterval)
local memory = Memory.get_crew_memory()
local boat = memory.boat
-- Skip redundant checks if there's nobody on the ship:
local disable_crafters = boat.state == Boats.enum_state.ATSEA_VICTORIOUS or (
boat.state == Boats.enum_state.ATSEA_WAITING_TO_SAIL and game.tick >= boat.at_sea_waiting_game_tick + Balance.at_sea_waiting_crafters_disable_time_seconds * 60
)
if Common.activecrewcount() == 0 and disable_crafters == memory.disable_crafters_last_seen then return end
memory.disable_crafters_last_seen = disable_crafters
if boat.state == Boats.enum_state.ATSEA_VICTORIOUS or Boats.enum_state.ATSEA_WAITING_TO_SAIL then
if boat.state == Boats.enum_state.ATSEA_VICTORIOUS then
memory.crafted_disabled = true
else
if not memory.crafters_disabled and (
game.tick > boat.at_sea_waiting_game_tick + Balance.max_time_crafting_while_waiting_seconds() * 60
) then
memory.crafters_disabled = true
Common.parrot_speak(memory.force, {'pirates.crafters_disabled'})
end
end
else
memory.crafters_disabled = false
end
local surfaces_to_check = {}
@ -141,7 +149,7 @@ function Public.apply_restrictions_to_machines(tickinterval)
for _, machine in ipairs(crafters) do
if machine and machine.valid then
machine.active = not disable_crafters
machine.active = not memory.crafters_disabled
end
end

View File

@ -90,7 +90,6 @@ Public.biter_boats_start_arrive_x = 40 * 5
Public.need_resources_to_undock_x = 40 * 20
Public.biters_spawned_on_elite_biter_death = 4
Public.walkways_frozen_pool_damage = 12
Public.at_sea_waiting_crafters_disable_time_seconds = 60 * 5
function Public.starting_boatEEIpower_production_MW()
-- return 3 * Math.sloped(Common.capacity_scale(), 1/2) / 2 --/2 as we have 2
@ -172,25 +171,28 @@ function Public.game_slowness_scale()
end
-- In seconds
function Public.max_time_on_island_formula() --always >0 --tuned
function Public.max_time_on_island_formula_seconds() --always >0 --tuned
-- return 60 * (
-- -- (32 + 2.2 * (Common.overworldx()/40)^(1/3))
-- (33 + 0.2 * (Common.overworldx()/40)^(1/3)) --based on observing x=2000, lets try killing the extra time
-- ) * Public.game_slowness_scale()
local minimum_mins_on_island = 30
return Math.ceil(60 * minimum_mins_on_island * Public.game_slowness_scale())
local minimum_mins = 30
return Math.ceil(60 * minimum_mins * Public.game_slowness_scale())
end
-- In seconds
function Public.max_time_on_island(island_subtype)
function Public.max_time_crafting_while_waiting_seconds()
local minimum_mins = 3
return Math.ceil(60 * minimum_mins * Public.game_slowness_scale())
end
function Public.max_time_on_island_seconds(island_subtype)
local x = Common.overworldx()
if x == 0 then
-- if Common.overworldx() == 0 or ((Common.overworldx()/40) > 20 and (Common.overworldx()/40) < 25) then
return -1
else
local time = Public.max_time_on_island_formula()
local time = Public.max_time_on_island_formula_seconds()
if x == 40 then -- it's important for this island to be somewhat chill, so that it's not such a shock to go here from the first lobby chill island
time = time * 1.2
@ -208,7 +210,7 @@ end
Public.expected_time_fraction = 0.7
function Public.expected_time_on_island() --always >0
return Public.expected_time_fraction * Public.max_time_on_island_formula()
return Public.expected_time_fraction * Public.max_time_on_island_formula_seconds()
end
function Public.fuel_depletion_rate_static()
@ -243,7 +245,7 @@ function Public.silo_total_pollution()
end
function Public.boat_passive_pollution_per_minute(time)
local T = Public.max_time_on_island_formula()
local T = Public.max_time_on_island_formula_seconds()
if (Common.overworldx()/40) > 25 then T = T * 0.9 end
local boost
@ -350,7 +352,7 @@ function Public.evolution_per_nest_kill() --it's important to have evo go up wit
local time = destination.dynamic_data.timer
-- local time_to_jump_to = Public.expected_time_on_island() * ((1/Public.expected_time_fraction)^(2/3))
local time_to_jump_to = Public.max_time_on_island_formula()
local time_to_jump_to = Public.max_time_on_island_formula_seconds()
if time > time_to_jump_to then return base_evo_jump
else
-- evo it 'would have' contributed:

View File

@ -174,8 +174,8 @@ function Public.update_EEIs(boat)
boat.EEIpower_production = Balance.starting_boatEEIpower_production_MW() * 1000000 / 60 * multiplier
boat.EEIelectric_buffer_size = Balance.starting_boatEEIelectric_buffer_size_MJ() * 1000000 * multiplier
local disable_EEIs = (boat.state == Public.enum_state.ATSEA_WAITING_TO_SAIL)
local disable_EEIs = boat.state == Public.enum_state.ATSEA_WAITING_TO_SAIL or boat.state == Public.enum_state.ATSEA_VICTORIOUS
for _, e in pairs(boat.EEIs) do
if e and e.valid then
if disable_EEIs then

View File

@ -234,7 +234,7 @@ function Public.destination_on_collide(destination)
-- end
-- end
local max_time = Balance.max_time_on_island(destination.subtype)
local max_time = Balance.max_time_on_island_seconds(destination.subtype)
local arrival_rate = Balance.biter_boat_average_arrival_rate()
local boat_count = Math.floor(max_time / arrival_rate) - 2 -- avoid spawning biter boats at very last seconds
@ -285,7 +285,7 @@ function Public.destination_on_arrival(destination)
destination.dynamic_data.rocketsiloenergyneeded = Balance.silo_energy_needed_MJ() * 1000000
destination.dynamic_data.time_remaining = Balance.max_time_on_island(destination.subtype)
destination.dynamic_data.time_remaining = Balance.max_time_on_island_seconds(destination.subtype)
if destination.subtype ~= IslandEnum.enum.FIRST and destination.subtype ~= IslandEnum.enum.RADIOACTIVE and destination.destination_index ~= 2 then
-- if not destination.overworld_position.x ~= Common.first_cost_to_leave_macrox * 40 then