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

port pirates pt1

Port pollution_statistics

port heading-3

port entity names

Decouple from base game evolution factors

Remove research_queue_enabled

global->storage

port rendering methods
This commit is contained in:
danielmartin0 2024-09-25 14:54:33 +01:00 committed by Gerkiz
parent b95413da30
commit 3230e1cb9e
24 changed files with 155 additions and 222 deletions

View File

@ -16,7 +16,7 @@ softmod_info_tips_1=Features of the game that are hard to work out alone
softmod_info_tips_2=• The captain (or officers) can steer the boat from the crow's nest by placing 50 rail signals in one of the blue boxes.\n• The quantity on an island is independent of the order in which you break rocks.\n• Passive pollution ramps up over time on each island.\n• Items dropped on the deck are transferred to the cabin when the boat moves for performance reasons.\n• When waiting for the captain's order to set sail, the free power supply is disabled.\n• Resources granted to the ship appear in the captain's cabin.\n• Useful commands: /classinfo {classname} command, /plank {player}, /officer {player}, /undock, /ccolor, /clear_north_tanks, /clear_south_tanks, /tax, /reset_password
softmod_info_1_1=v1.6.1–1.6.5 highlights
softmod_info_1_2=• Optional setting for new crews to disable blueprints.\n• Each island now has a grace period of 2 minutes before attacks.\n• Machines now deactivate after several minutes spent waiting at sea.\n• Private crews and captain-protected crews no longer revert to public crews when inactive. Runs now autodisband after 96 hours of inactivity.\n• Further slowing of gameplay for small crews.
softmod_info_1_2=• Optional setting for new crews to disable blueprint importing.\n• Each island now has a grace period of 2 minutes before attacks.\n• Machines now deactivate after several minutes spent waiting at sea.\n• Private crews and captain-protected crews no longer revert to public crews when inactive. Runs now autodisband after 96 hours of inactivity.\n• Further slowing of gameplay for small crews.
softmod_info_2_1=v1.6.0 highlights
softmod_info_2_2=• 7 simultaneous crews supported. Surface loading is paused if other crews are engaged in a fight at sea, or are loading themselves.\n• New runs begin on the top lane so that beginners are more likely to encounter docks.\n• Disconnecting players once again have their items temporarily saved. Items are returned to the crew if players don't reconnect quickly.\n• Players now die rather than being temporarily marooned if they miss the boat.\n• Melee classes can no longer hold weapons. New class added.\n• The pause at sea now occurs after the loading time for the next destination.\n• Balance tweaks:\n - Most maps now have some unkillable spawners.\n - Mining productivity increases naturally with leagues traveled.\n - Biter nighttime damage bonus nerfed.\n - Tweaks to radioactive islands.\n - Kovarex enrichment no longer researched at start of game.\n - Land mines only purchasable at docks, and drop your speed when placed.\n - Flamers nerf slightly increased.\n - 5% weapon and turret damage upgrade available at each island market.
@ -531,7 +531,7 @@ gui_runs_proposal_maker_run_name_2=Name
gui_runs_proposal_maker_capacity=Capacity
gui_runs_proposal_maker_propose=Propose
gui_runs_proposal_maker_no_limit=No limit
gui_runs_proposal_maker_blueprints_disabled=Blueprints disabled
gui_runs_proposal_maker_blueprints_disabled=Blueprint imports disabled
gui_runs_proposal_maker_protected=Captain-protected
gui_runs_proposal_maker_protected_tooltip=Captain-protected crew. If the captain leaves or becomes afk, and there are no officers, the captain role stays vacant.
gui_runs_proposal_maker_private=Private

View File

@ -458,7 +458,7 @@ function Public.try_spawner_spend_fraction_of_available_pollution_on_biters(spaw
temp_floating_pollution = temp_floating_pollution - unit_pollutioncost
budget = budget - unit_pollutioncost
-- flow statistics should reflect the number of biters generated. Therefore it should mismatch the actual pollution spent, because it should miss all the factors that can vary:
game.pollution_statistics.on_flow(name2, -CoreData.biterPollutionValues[name2])
game.get_pollution_statistics(surface).on_flow(name2, -CoreData.biterPollutionValues[name2])
return biter.unit_number
end
@ -550,22 +550,6 @@ function Public.nearest_target(surface, position)
return nearest
end
-- function Public.try_spend_pollution(surface, position, amount, flow_statistics_source)
-- local memory = Memory.get_crew_memory()
-- local force_name = memory.force_name
-- flow_statistics_source = flow_statistics_source or 'medium-biter'
-- if not (position and surface and surface.valid) then return end
-- local pollution = surface.get_pollution(position)
-- if pollution > amount then
-- surface.pollute(position, -amount)
-- game.forces[force_name].pollution_statistics.on_flow(flow_statistics_source, -amount)
-- return true
-- end
-- return false
-- end
function Public.is_biter_inactive(biter)
if (not biter.entity) or (not biter.entity.valid) then
return true
@ -876,7 +860,7 @@ function Public.try_boat_biters_attack()
end
end
local function on_entity_destroyed(event)
local function on_object_destroyed(event)
local registration_number = event.registration_number
local p
@ -928,7 +912,7 @@ end
local event = require 'utils.event'
event.add(defines.events.on_entity_destroyed, on_entity_destroyed)
event.add(defines.events.on_object_destroyed, on_object_destroyed)
return Public

View File

@ -1,6 +1,5 @@
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/ComfyFactory/ComfyFactorio and https://github.com/danielmartin0/ComfyFactorio-Pirates.
local Memory = require 'maps.pirates.memory'
local Balance = require 'maps.pirates.balance'
local Math = require 'maps.pirates.math'
@ -25,9 +24,7 @@ local Permissions = require 'maps.pirates.permissions'
-- local Ores = require 'maps.pirates.ores'
-- local Parrot = require 'maps.pirates.parrot'
local Kraken = require 'maps.pirates.surfaces.sea.kraken'
local Jailed = require 'utils.datastore.jail_data'
local Crew = require 'maps.pirates.crew'
local Quest = require 'maps.pirates.quest'
local Shop = require 'maps.pirates.shop.shop'
@ -36,7 +33,6 @@ local Task = require 'utils.task'
local Token = require 'utils.token'
local Classes = require 'maps.pirates.roles.classes'
local Ores = require 'maps.pirates.ores'
local Server = require 'utils.server'
-- local Modifers = require 'player_modifiers'
local GuiWelcome = require 'maps.pirates.gui.welcome'
@ -74,35 +70,6 @@ function Public.silo_die()
end
end
-- function Public.damage_silo(final_damage_amount)
-- if final_damage_amount == 0 then return end
-- local destination = Common.current_destination()
-- -- local memory = Memory.get_crew_memory()
-- -- if we are doing the 'no damage' quest, then damage in the first 20 seconds after landing doesn't count:
-- if destination and destination.dynamic_data and destination.dynamic_data.quest_type == Quest.enum.NODAMAGE then
-- if not (destination.dynamic_data.timer and destination.dynamic_data.timeratlandingtime and destination.dynamic_data.timer > destination.dynamic_data.timeratlandingtime + 20) then return end
-- end
-- -- manual 'resistance:'
-- local final_damage_amount2 = final_damage_amount / 4
-- destination.dynamic_data.rocketsilohp = Math.max(0, Math.floor(destination.dynamic_data.rocketsilohp - final_damage_amount2))
-- if destination.dynamic_data.rocketsilohp > destination.dynamic_data.rocketsilomaxhp then destination.dynamic_data.rocketsilohp = destination.dynamic_data.rocketsilomaxhp end
-- if destination.dynamic_data.rocketsilohp <= 0 then
-- -- if destination.dynamic_data.rocketsilohp <= 0 and (not destination.dynamic_data.rocketlaunched) then
-- Public.silo_die()
-- rendering.destroy(destination.dynamic_data.rocketsilohptext)
-- else
-- rendering.set_text(destination.dynamic_data.rocketsilohptext, 'HP: ' .. destination.dynamic_data.rocketsilohp .. ' / ' .. destination.dynamic_data.rocketsilomaxhp)
-- end
-- -- if destination.dynamic_data.rocketsilohp < destination.dynamic_data.rocketsilomaxhp / 2 and final_damage_amount > 0 then
-- -- Upgrades.trigger_poison()
-- -- end
-- end
local function biters_chew_stuff_faster(event)
local memory = Memory.get_crew_memory()
local destination = Common.current_destination()
@ -129,18 +96,6 @@ local function biters_chew_stuff_faster(event)
end
end
-- local function event_on_player_repaired_entity(event)
-- local entity = event.entity
-- if entity and entity.valid and entity.name and entity.name == 'artillery-turret' then
-- entity.health = entity.health - 2 --prevents repairing
-- end
-- --@TODO: somehow fix the fact that drones can repair the turret
-- end
local function handle_damage_in_restricted_areas(event)
-- local memory = Memory.get_crew_memory()
local entity = event.entity
@ -1358,7 +1313,7 @@ local function event_on_entity_died(event)
if not memory.elite_biters_stream_registrations then memory.elite_biters_stream_registrations = {} end
memory.elite_biters_stream_registrations[#memory.elite_biters_stream_registrations + 1] = {
number = script.register_on_entity_destroyed(stream),
number = script.register_on_object_destroyed(stream),
position = target_pos,
biter_name = entity.name,
surface_name = surface.name -- surface name is needed to know where biter died

View File

@ -475,7 +475,7 @@ function Public.pick_up_tick(tickinterval)
map.buried_treasure_position = p2
map.state = 'picked_up'
rendering.destroy(map.mapobject_rendering)
map.mapobject_rendering.destroy()
Common.notify_force_light(player.force, { 'pirates.find_map', player.name })
@ -529,7 +529,7 @@ function Public.pick_up_tick(tickinterval)
j = j + 1
end
if player then
rendering.destroy(ghost.ghostobject_rendering)
ghost.ghostobject_rendering.destroy()
ghost.state = 'picked_up'
@ -863,10 +863,10 @@ function Public.buried_treasure_check(tickinterval)
local maps = destination.dynamic_data.treasure_maps
for _, m in pairs(maps) do
if m.state == 'on_ground' then
rendering.destroy(m.mapobject_rendering)
m.mapobject_rendering.destroy()
elseif m.state == 'picked_up' and m.x_renderings and #m.x_renderings > 0 then
rendering.destroy(m.x_renderings[1])
rendering.destroy(m.x_renderings[2])
m.x_renderings[1].destroy()
m.x_renderings[2].destroy()
end
m = nil
end
@ -877,8 +877,8 @@ function Public.buried_treasure_check(tickinterval)
for _, m in pairs(maps) do
if m.state == 'picked_up' and m.buried_treasure_position and m.buried_treasure_position == p and m.x_renderings and #m.x_renderings > 0 then
m.state = 'inactive'
rendering.destroy(m.x_renderings[1])
rendering.destroy(m.x_renderings[2])
m.x_renderings[1].destroy()
m.x_renderings[2].destroy()
end
end
end
@ -1101,8 +1101,8 @@ function Public.loading_update(tickinterval)
if currentdestination.type == Surfaces.enum.LOBBY then
if memory.loadingticks >= 1260 then
if boat and boat.rendering_crewname_text and rendering.is_valid(boat.rendering_crewname_text) then
rendering.destroy(boat.rendering_crewname_text)
if boat and boat.rendering_crewname_text and boat.rendering_crewname_text.valid then
boat.rendering_crewname_text.destroy()
boat.rendering_crewname_text = nil
end
@ -1252,16 +1252,18 @@ function Public.silo_update(tickinterval)
local pollution = e / 1000000 * Balance.silo_total_pollution() / Balance.silo_energy_needed_MJ()
if p and pollution then
game.pollution_statistics.on_flow('rocket-silo', pollution)
local surface = game.surfaces[destination.surface_name]
game.get_pollution_statistics(surface).on_flow('rocket-silo', pollution)
if not memory.floating_pollution then memory.floating_pollution = 0 end
-- Eventually I want to reformulate pollution not to pull from the map directly, but to pull from pollution_statistics. Previously all the silo pollution went to the map, but this causes a lag ~1-2 minutes. So as a compromise, let's send some to floating_pollution directly, and some to the map:
memory.floating_pollution = memory.floating_pollution + 3 * pollution / 4
game.surfaces[destination.surface_name].pollute(p, pollution / 4)
surface.pollute(p, pollution / 4)
if memory.overworldx >= 0 and dynamic_data.rocketsiloenergyconsumed >= 0.25 * dynamic_data.rocketsiloenergyneeded and (not dynamic_data.parrot_silo_warned) then
dynamic_data.parrot_silo_warned = true
local spawnerscount = Common.spawner_count(game.surfaces[destination.surface_name])
local spawnerscount = Common.spawner_count(surface)
if spawnerscount > 0 then
Common.parrot_speak(memory.force, { 'pirates.parrot_silo_warning' })
end
@ -1292,11 +1294,14 @@ function Public.slower_boat_tick(tickinterval)
end
local p = memory.boat.position
if p and destination.subtype ~= IslandEnum.enum.RADIOACTIVE and destination.surface_name and game.surfaces[destination.surface_name] and game.surfaces[destination.surface_name].valid then --no locomotive pollute on radioactive islands
if p and destination.subtype ~= IslandEnum.enum.RADIOACTIVE and destination.surface_name then --no locomotive pollute on radioactive islands
local pollution = Balance.boat_passive_pollution_per_minute(destination.dynamic_data.timer) / 3600 * tickinterval
game.surfaces[destination.surface_name].pollute(p, pollution)
game.pollution_statistics.on_flow('locomotive', pollution)
local surface = game.surfaces[destination.surface_name]
if surface and surface.valid then
surface.pollute(p, pollution)
game.get_pollution_statistics(destination.surface_name).on_flow('locomotive', pollution)
end
end
-- if memory.enemyboats then

View File

@ -471,25 +471,13 @@ end
function Public.set_evo(evolution)
local memory = Memory.get_crew_memory()
memory.evolution_factor = evolution
if memory.enemy_force_name then
local ef = memory.enemy_force
if ef and ef.valid then
ef.evolution_factor = memory.evolution_factor
Public.set_biter_surplus_evo_modifiers()
end
end
Public.set_biter_surplus_evo_modifiers()
end
function Public.increment_evo(evolution)
local memory = Memory.get_crew_memory()
memory.evolution_factor = memory.evolution_factor + evolution
if memory.enemy_force_name then
local ef = memory.enemy_force
if ef and ef.valid then
ef.evolution_factor = memory.evolution_factor
Public.set_biter_surplus_evo_modifiers()
end
end
Public.set_biter_surplus_evo_modifiers()
end
function Public.current_destination()
@ -788,11 +776,11 @@ function Public.transfer_healthbar(old_unit_number, new_entity, location_overrid
Public.new_healthbar(old_healthbar.render2, new_entity, old_healthbar.max_health, old_healthbar.id, old_healthbar.health, old_healthbar.size, old_healthbar.extra_offset, location_override)
if rendering.is_valid(old_healthbar.render1) then
rendering.destroy(old_healthbar.render1)
if old_healthbar.render1 and old_healthbar.render1.valid then
old_healthbar.render1.destroy()
end
if old_healthbar.render2 and rendering.is_valid(old_healthbar.render2) then
rendering.destroy(old_healthbar.render2)
if old_healthbar.render2 and old_healthbar.render2.valid then
old_healthbar.render2.destroy()
end
location_override.healthbars[old_unit_number] = nil
@ -839,17 +827,17 @@ function Public.update_healthbar_rendering(new_healthbar, health)
if health > 0 then
local m = health / max_health
local x_scale = rendering.get_y_scale(render1) * 15
rendering.set_x_scale(render1, x_scale * m)
rendering.set_color(render1, { Math.floor(255 - 255 * m), Math.floor(200 * m), 0 })
local x_scale = render1.y_scale * 15
render1.x_scale = x_scale * m
render1.color = { Math.floor(255 - 255 * m), Math.floor(200 * m), 0 }
if render2 then
rendering.set_text(render2, string.format('HP: %d/%d', Math.ceil(health), Math.ceil(max_health)))
render2.text = string.format('HP: %d/%d', Math.ceil(health), Math.ceil(max_health))
end
else
rendering.destroy(render1)
render1.destroy()
if render2 then
rendering.destroy(render2)
render2.destroy()
end
end
end
@ -1592,9 +1580,9 @@ end
function Public.init_game_settings(technology_price_multiplier)
--== Tuned for Pirate Ship ==--
global.friendly_fire_history = {}
global.landfill_history = {}
global.mining_history = {}
storage.friendly_fire_history = {}
storage.landfill_history = {}
storage.mining_history = {}
game.difficulty_settings.technology_price_multiplier = technology_price_multiplier
@ -1645,7 +1633,7 @@ function Public.init_game_settings(technology_price_multiplier)
game.map_settings.pollution.diffusion_ratio = 0.035
--
-- game.forces.neutral.character_inventory_slots_bonus = 500
game.forces.enemy.evolution_factor = 0
-- game.forces.enemy.evolution_factor = 0
end
-- prefer memory.force_name if possible
@ -1699,7 +1687,7 @@ function Public.get_item_blacklist(tier)
-- blacklist['productivity-module'] = true
-- blacklist['productivity-module-2'] = true
-- blacklist['productivity-module-3'] = true
-- blacklist['effectivity-module-3'] = true
-- blacklist['efficiency-module-3'] = true
-- blacklist['space-science-pack'] = true
-- blacklist['rocket-control-unit'] = true
blacklist['artillery-wagon'] = true

View File

@ -945,7 +945,6 @@ function Public.reset_crew_and_enemy_force(id)
crew_force.laboratory_productivity_bonus = 0
crew_force.ghost_time_to_live = 12 * 60 * 60
crew_force.worker_robots_speed_modifier = 0.5
crew_force.research_queue_enabled = true
for k, v in pairs(Balance.player_ammo_damage_modifiers()) do
crew_force.set_ammo_damage_modifier(k, v)
@ -1065,9 +1064,9 @@ function Public.reset_crew_and_enemy_force(id)
-- crew_force.technologies['speed-module'].enabled = true
-- crew_force.technologies['speed-module-2'].enabled = false
-- crew_force.technologies['speed-module-3'].enabled = false
-- crew_force.technologies['effectivity-module'].enabled = true
-- crew_force.technologies['effectivity-module-2'].enabled = false
-- crew_force.technologies['effectivity-module-3'].enabled = false
-- crew_force.technologies['efficiency-module'].enabled = true
-- crew_force.technologies['efficiency-module-2'].enabled = false
-- crew_force.technologies['efficiency-module-3'].enabled = false
-- crew_force.technologies['automation-3'].enabled = false
-- crew_force.technologies['rocket-control-unit'].enabled = false
-- crew_force.technologies['rocket-silo'].enabled = false

View File

@ -941,13 +941,13 @@ function Public.update_gui(player)
-- local lives = memory.lives or 1
-- local button = pirates_flow.lives_piratebutton_frame.lives_piratebutton
-- if lives == 1 then
-- button.sprite = 'item/effectivity-module'
-- button.sprite = 'item/efficiency-module'
-- button.number = 1
-- elseif lives == 2 then
-- button.sprite = 'item/effectivity-module-2'
-- button.sprite = 'item/efficiency-module-2'
-- button.number = 2
-- elseif lives == 3 then
-- button.sprite = 'item/effectivity-module-3'
-- button.sprite = 'item/efficiency-module-3'
-- button.number = 3
-- end

View File

@ -78,7 +78,7 @@ function Public.flow_add_info_sections(flow, sections_list)
flow2 = flow.add { type = "label", caption = { "pirates.softmod_info_" .. i .. "_1" } }
flow2.style.font_color = GuiCommon.friendly_font_color
flow2.style.single_line = false
flow2.style.font = 'heading-3'
flow2.style.font = 'default-semibold'
flow2.style.bottom_margin = -4
flow2 = flow.add { type = "label", caption = { "pirates.softmod_info_" .. i .. "_2" } }

View File

@ -36,7 +36,7 @@ local function flow_add_proposal_slider(flow, name, displayname, indices_count,
type = 'label',
caption = displayname,
})
flow3.style.font = 'heading-3'
flow3.style.font = 'default-semibold'
flow3.style.height = 20
flow3.style.margin = 0
flow3.style.padding = 0
@ -109,7 +109,7 @@ end
-- type = 'label',
-- caption = displayname,
-- })
-- flow3.style.font = 'heading-3'
-- flow3.style.font = 'default-semibold'
-- flow3.style.height = 20
-- flow3.style.margin = 0
-- flow3.style.padding = 0
@ -325,7 +325,7 @@ function Public.toggle_window(player)
type = 'label',
caption = { 'pirates.gui_runs_proposal_maker_run_name' },
})
flow5.style.font = 'heading-3'
flow5.style.font = 'default-semibold'
flow5 = flow4.add({
name = 'namefield',
@ -375,7 +375,7 @@ function Public.toggle_window(player)
type = 'label',
caption = { 'pirates.gui_runs_proposal_maker_password' },
})
flow6.style.font = 'heading-3'
flow6.style.font = 'default-semibold'
flow6 = flow5.add({
name = 'password',
@ -392,7 +392,7 @@ function Public.toggle_window(player)
type = 'label',
caption = { 'pirates.gui_runs_proposal_maker_confirm_password' },
})
flow6.style.font = 'heading-3'
flow6.style.font = 'default-semibold'
flow6 = flow5.add({
name = 'confirm_password',

View File

@ -21,7 +21,7 @@ Public.buried_treasure_loot_data_raw = {
-- {100, 0, 1, false, 'electronic-circuit', 150, 250},
{ 70, 0, 1, false, 'advanced-circuit', 20, 40 },
{ 150, 0, 1, false, 'crude-oil-barrel', 25, 45 },
{ 70, 0, 1, false, 'effectivity-module-3', 3, 4 },
{ 70, 0, 1, false, 'efficiency-module-3', 3, 4 },
{ 70, 0, 1, false, 'speed-module-3', 3, 4 },
{ 70, 0, 1, false, 'plastic-bar', 40, 70 },
{ 60, 0, 1, false, 'chemical-science-pack', 12, 24 },
@ -56,7 +56,7 @@ Public.chest_loot_data_raw = {
{ 0.25, 0, 0.5, false, 'uranium-238', 5, 8 },
{ 8, 0, 1.2, true, 'steel-chest', 4, 12 },
{ 2, 0, 0.8, false, 'empty-barrel', 1, 10 },
{ 2, 0, 0.8, false, 'barrel', 1, 10 },
{ 5, -0.2, 0.8, true, 'iron-gear-wheel', 20, 80 },
{ 5, -0.2, 0.8, true, 'copper-cable', 30, 100 },
@ -113,9 +113,9 @@ Public.chest_loot_data_raw = {
{ 15, -1, 1, true, 'speed-module', 1, 3 },
{ 5, 0, 1.5, true, 'speed-module-2', 1, 2 },
{ 2, 0, 2, true, 'speed-module-3', 1, 1 },
{ 5, -1, 1, true, 'effectivity-module', 1, 3 },
{ 3, 0, 1, true, 'effectivity-module-2', 1, 3 },
{ 1, 0, 2, true, 'effectivity-module-3', 1, 1 },
{ 5, -1, 1, true, 'efficiency-module', 1, 3 },
{ 3, 0, 1, true, 'efficiency-module-2', 1, 3 },
{ 1, 0, 2, true, 'efficiency-module-3', 1, 1 },
@ -160,7 +160,7 @@ Public.chest_loot_data_raw = {
{ 0.5, 0.2, 1.4, true, 'construction-robot', 5, 15 },
{ 2, 0.5, 1.5, true, 'roboport', 1, 1 },
{ 2, 0.5, 1.5, false, 'logistic-chest-passive-provider', 2, 2 },
{ 2, 0.5, 1.5, false, 'passive-provider-chest', 2, 2 },
{ 2, 0.5, 1.5, false, 'logistic-robot', 5, 15 },
{ 4, 0.2, 1.2, true, 'lubricant-barrel', 1, 4 },
@ -418,7 +418,7 @@ Public.maze_treasure_data_raw = {
{ 0.5, 0, 1, false, 'nuclear-fuel', 1, 1 },
{ 1, 0, 0.8, false, 'speed-module-3', 2, 2 },
{ 1, 0, 0.8, false, 'effectivity-module-3', 3, 3 },
{ 1, 0, 0.8, false, 'efficiency-module-3', 3, 3 },
{ 2, 0, 1.5, true, 'production-science-pack', 20, 25 },
{ 2, 0, 2, true, 'utility-science-pack', 7, 8 },
@ -426,7 +426,7 @@ Public.maze_treasure_data_raw = {
{ 3, 0, 0.9, false, 'beacon', 1, 1 },
{ 1, 0, 1, false, 'construction-robot', 30, 40 },
{ 3, 0, 1, false, 'logistic-chest-passive-provider', 2, 2 },
{ 3, 0, 1, false, 'passive-provider-chest', 2, 2 },
{ 1, 0.2, 1.8, true, 'explosive-rocket', 6, 8 },
@ -489,7 +489,7 @@ Public.dredger_loot_raw = {
{ 0.05, 0, 1, false, 'speed-module-3', 1, 2 },
{ 0.05, 0, 1, false, 'effectivity-module-3', 1, 2 },
{ 0.05, 0, 1, false, 'efficiency-module-3', 1, 2 },
{ 0.1, 0, 1, false, 'rocket', 1, 3 },
{ 0.01, 0, 1, false, 'explosive-rocket', 1, 2 },

View File

@ -338,10 +338,10 @@ end
gMeta.__newindex = function (_, n, v)
log('Desync warning: attempt to write to undeclared var ' .. n)
global[n] = v
storage[n] = v
end
gMeta.__index = function (_, n)
return global[n]
return storage[n]
end
return Public

View File

@ -512,14 +512,14 @@ function Public.ensure_lane_generated_up_to(lane_yvalue, x)
-- a little hack that we're updating this here rather than Crowsnest, due to the dependency on Shop to avoid a loop... almost finished 1.0, so too late to figure out how to restructure things for now!
for _, dest in pairs(memory.destinations) do
if dest.static_params.upgrade_for_sale and dest.dynamic_data.crowsnest_renderings then
if rendering.is_valid(dest.dynamic_data.crowsnest_renderings.base_text_rendering) then
rendering.set_text(dest.dynamic_data.crowsnest_renderings.base_text_rendering, { '', Upgrades.crowsnest_display_form[dest.static_params.upgrade_for_sale], ':' })
if dest.dynamic_data.crowsnest_renderings.base_text_rendering.valid then
dest.dynamic_data.crowsnest_renderings.base_text_rendering.text = { '', Upgrades.crowsnest_display_form[dest.static_params.upgrade_for_sale], ':' }
end
for rendering_name, r in pairs(dest.dynamic_data.crowsnest_renderings) do
if type(r) == 'table' and r.text_rendering and rendering.is_valid(r.text_rendering) then
if type(r) == 'table' and r.text_rendering and r.text_rendering.valid then
for _, price_data in ipairs(Upgrades.upgrades_data[dest.static_params.upgrade_for_sale].market_item.price) do
if price_data[1] == rendering_name then
rendering.set_text(r.text_rendering, Utils.bignumber_abbrevform2(price_data[2]))
r.text_rendering.text = Utils.bignumber_abbrevform2(price_data[2])
break
end
end

View File

@ -382,7 +382,7 @@ Public.resourcecount_quest_data_raw = {
{ 1.1, 0, 1, false, 'transport-belt', 1600 },
{ 0.8, 0, 1, false, 'repair-pack', 350 },
-- {0.1, 0, 1, false, 'red-wire', 500},
{ 0.4, 0, 1, false, 'empty-barrel', 200 },
{ 0.4, 0, 1, false, 'barrel', 200 },
{ 0.7, 0, 0.5, false, 'underground-belt', 200 },
{ 0.7, 0, 0.5, false, 'splitter', 150 },
{ 0.35, 0.2, 1, false, 'fast-splitter', 60 },

View File

@ -125,12 +125,12 @@ function Public.class_renderings(tickinterval)
-- if Common.validate_player_and_character(player) and (c ~= Classes.enum.IRON_LEG or (memory.class_auxiliary_data[player_index] and memory.class_auxiliary_data[player_index].iron_leg_active)) then
if Common.validate_player_and_character(player) then
if class == c then
if r and rendering.is_valid(r) then
rendering.set_target(r, player.character)
if r and r.valid then
r.target = player.character
end
else
if r and rendering.is_valid(r) then
rendering.destroy(r)
if r and r.valid then
r.destroy()
end
if class == Classes.enum.QUARTERMASTER then
class_renderings[player_index] = {
@ -237,7 +237,7 @@ function Public.class_renderings(tickinterval)
end
else
if r then
rendering.destroy(r)
r.destroy()
end
class_renderings[player_index] = nil
end
@ -247,8 +247,8 @@ function Public.class_renderings(tickinterval)
for k, data in pairs(class_renderings) do
if not processed_players[k] then
local r = data.rendering
if r and rendering.is_valid(r) then
rendering.destroy(r)
if r and r.valid then
r.destroy()
end
class_renderings[k] = nil
end

View File

@ -50,11 +50,11 @@ Public.offers_default = {
{ price = { { 'coin', 1700 } }, offer = { type = 'give-item', item = 'flamethrower-ammo', count = 15 } },
{ price = { { 'coin', 1800 } }, offer = { type = 'give-item', item = 'flamethrower-ammo', count = 20 } },
{ price = { { 'coin', 1800 } }, offer = { type = 'give-item', item = 'flying-robot-frame', count = 5 } },
{ price = { { 'coin', 1000 } }, offer = { type = 'give-item', item = 'logistic-chest-storage', count = 5 } },
{ price = { { 'coin', 1000 } }, offer = { type = 'give-item', item = 'logistic-chest-passive-provider', count = 5 } },
{ price = { { 'coin', 2500 } }, offer = { type = 'give-item', item = 'logistic-chest-active-provider', count = 5 } },
{ price = { { 'coin', 2500 } }, offer = { type = 'give-item', item = 'logistic-chest-buffer', count = 5 } },
{ price = { { 'coin', 2500 } }, offer = { type = 'give-item', item = 'logistic-chest-requester', count = 5 } },
{ price = { { 'coin', 1000 } }, offer = { type = 'give-item', item = 'storage-chest', count = 5 } },
{ price = { { 'coin', 1000 } }, offer = { type = 'give-item', item = 'passive-provider-chest', count = 5 } },
{ price = { { 'coin', 2500 } }, offer = { type = 'give-item', item = 'active-provider-chest', count = 5 } },
{ price = { { 'coin', 2500 } }, offer = { type = 'give-item', item = 'buffer-chest', count = 5 } },
{ price = { { 'coin', 2500 } }, offer = { type = 'give-item', item = 'requester-chest', count = 5 } },
}

View File

@ -72,7 +72,7 @@ Public.market_sales = {
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'coin', count = 6000 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'roboport', count = 1 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'construction-robot', count = 10 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'logistic-chest-passive-provider', count = 2 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'passive-provider-chest', count = 2 } },
{ price = { { 'coin', 3000 } }, offer = { type = 'give-item', item = 'logistic-robot', count = 2 } },
{ price = { { 'transport-belt', 100 }, { 'coin', 800 } }, offer = { type = 'give-item', item = 'fast-transport-belt', count = 100 } },
{ price = { { 'fast-transport-belt', 100 }, { 'coin', 2500 } }, offer = { type = 'give-item', item = 'express-transport-belt', count = 100 } },

View File

@ -137,12 +137,12 @@ function Public.destroy_boat(boat, tile_type, flipped)
flipped = flipped or false
tile_type = tile_type or 'water'
if boat.rendering_crewname_text then
rendering.destroy(boat.rendering_crewname_text)
boat.rendering_crewname_text.destroy()
boat.rendering_crewname_text = nil
end
if boat.renderings_power and #boat.renderings_power > 0 then
for _, r in pairs(boat.renderings_power) do
rendering.destroy(r)
r.destroy()
end
end
Public.place_boat(boat, tile_type, false, true, flipped)
@ -180,7 +180,7 @@ function Public.update_EEIs(boat)
if boat.renderings_power and #boat.renderings_power > 0 then
for _, r in pairs(boat.renderings_power) do
rendering.destroy(r)
r.destroy()
end
end
Public.draw_power_renderings(boat)
@ -1128,15 +1128,15 @@ local function teleport_handle_renderings(boat, oldsurface_name, newsurface_name
if boat.renderings_power and #boat.renderings_power > 0 then
if oldsurface_name == newsurface_name then
for _, r in pairs(boat.renderings_power) do
if rendering.is_valid(r) then
local p = rendering.get_target(r).position
rendering.set_target(r, { x = p.x + vector.x, y = p.y + vector.y })
if r.valid then
local p = r.target.position
r.target = { x = p.x + vector.x, y = p.y + vector.y }
end
end
else
for _, r in pairs(boat.renderings_power) do
if rendering.is_valid(r) then
rendering.destroy(r)
if r.valid then
r.destroy()
end
end
Public.draw_power_renderings(boat)
@ -1147,9 +1147,9 @@ local function teleport_handle_renderings(boat, oldsurface_name, newsurface_name
local p = Utils.psum { boat.position, scope.Data.crewname_rendering_position }
if oldsurface_name == newsurface_name then
rendering.set_target(boat.rendering_crewname_text, p)
boat.rendering_crewname_text.target = p
else
rendering.destroy(boat.rendering_crewname_text)
boat.rendering_crewname_text.destroy()
boat.rendering_crewname_text = rendering.draw_text {
text = memory.name,
-- render_layer = '125', --does nothing

View File

@ -249,10 +249,10 @@ function Public.tick_quest_structure_entry_price_check()
if quest_structure_data.state == 'covered' then
if quest_structure_data.completion_counter >= entry_price.count then
quest_structure_data.state = 'uncovered'
rendering.destroy(quest_structure_data.rendering1)
rendering.destroy(quest_structure_data.rendering2)
rendering.destroy(quest_structure_data.rendering3)
rendering.destroy(quest_structure_data.rendering4)
quest_structure_data.rendering1.destroy()
quest_structure_data.rendering2.destroy()
quest_structure_data.rendering3.destroy()
quest_structure_data.rendering4.destroy()
local special = Utils.deepcopy(Public[enum.MARKET1].Data.step2)
special.position = quest_structure_data.position
@ -260,7 +260,7 @@ function Public.tick_quest_structure_entry_price_check()
destination.dynamic_data.structures_waiting_to_be_placed[#destination.dynamic_data.structures_waiting_to_be_placed + 1] = { data = special, tick = game.tick }
else
if quest_structure_data.rendering1 then
rendering.set_text(quest_structure_data.rendering1, { 'pirates.quest_structure_market_1', entry_price.count - quest_structure_data.completion_counter })
quest_structure_data.rendering1.text = { 'pirates.quest_structure_market_1', entry_price.count - quest_structure_data.completion_counter }
end
end
end
@ -339,12 +339,12 @@ function Public.tick_quest_structure_entry_price_check()
if quest_structure_data.completion_counter >= entry_price.count then
quest_structure_data.state = 'uncovered'
rendering.destroy(quest_structure_data.rendering0)
rendering.destroy(quest_structure_data.rendering1)
rendering.destroy(quest_structure_data.rendering2)
rendering.destroy(quest_structure_data.rendering3)
rendering.destroy(quest_structure_data.rendering4)
rendering.destroy(quest_structure_data.rendering5)
quest_structure_data.rendering0.destroy()
quest_structure_data.rendering1.destroy()
quest_structure_data.rendering2.destroy()
quest_structure_data.rendering3.destroy()
quest_structure_data.rendering4.destroy()
quest_structure_data.rendering5.destroy()
local special = Utils.deepcopy(Public[enum.FURNACE1].Data.step2)
special.position = quest_structure_data.position
@ -352,7 +352,7 @@ function Public.tick_quest_structure_entry_price_check()
destination.dynamic_data.structures_waiting_to_be_placed[#destination.dynamic_data.structures_waiting_to_be_placed + 1] = { data = special, tick = game.tick }
else
if quest_structure_data.rendering1 then
rendering.set_text(quest_structure_data.rendering1, entry_price.count - quest_structure_data.completion_counter .. ' x')
quest_structure_data.rendering1.text = entry_price.count - quest_structure_data.completion_counter .. ' x'
end
end
else

View File

@ -110,7 +110,7 @@ function Public.move_crowsnest(vectorx, vectory)
if memory.crowsnest_surfacename_rendering then
local p = rendering.get_target(memory.crowsnest_surfacename_rendering).position
rendering.set_target(memory.crowsnest_surfacename_rendering, { x = p.x + vectorx, y = p.y + vectory })
memory.crowsnest_surfacename_rendering.target = { x = p.x + vectorx, y = p.y + vectory }
end
if vectorx ~= 0 then
@ -128,30 +128,30 @@ function Public.update_destination_renderings()
if dest.overworld_position.x <= memory.overworldx + Public.Data.chartingdistance and dest.overworld_position.x >= memory.overworldx - Public.Data.chartingdistance then
for _, r in pairs(dest.dynamic_data.crowsnest_renderings) do
if type(r) == 'table' then
if rendering.is_valid(r.text_rendering) then
rendering.set_visible(r.text_rendering, true)
if r.text_rendering.valid then
r.text_rendering.visible = true
end
if rendering.is_valid(r.sprite_rendering) then
rendering.set_visible(r.sprite_rendering, true)
if r.sprite_rendering.valid then
r.sprite_rendering.visible = true
end
else
if rendering.is_valid(r) then
rendering.set_visible(r, true)
if r.valid then
r.visible = true
end
end
end
else
for _, r in pairs(dest.dynamic_data.crowsnest_renderings) do
if type(r) == 'table' then
if rendering.is_valid(r.text_rendering) then
rendering.set_visible(r.text_rendering, false)
if r.text_rendering.valid then
r.text_rendering.visible = false
end
if rendering.is_valid(r.sprite_rendering) then
rendering.set_visible(r.sprite_rendering, false)
if r.sprite_rendering.valid then
r.sprite_rendering.visible = false
end
else
if rendering.is_valid(r) then
rendering.set_visible(r, false)
if r.valid then
r.visible = false
end
end
end

View File

@ -250,7 +250,7 @@ function Public.create_hold_surface(nth)
else
if nth == 2 then
if memory.shiphold_rendering_1 then
rendering.set_text(memory.shiphold_rendering_1, { 'pirates.surface_label_hold_nth', 1 })
memory.shiphold_rendering_1.text = { 'pirates.surface_label_hold_nth', 1 }
end
end
rendering.draw_text {
@ -349,10 +349,10 @@ function Public.nth_hold_connect_linked_belts(nth) --assumes both are in standar
b1.connect_linked_belts(b2)
end
rendering.set_text(boat.hold_helper_renderings[nth][3], { 'pirates.hold_connections_label_from', nth - 1 })
rendering.set_text(boat.hold_helper_renderings[nth - 1][3], { 'pirates.hold_connections_label_to', nth })
rendering.set_text(boat.hold_helper_renderings[nth][4], { 'pirates.hold_connections_label_from', nth - 1 })
rendering.set_text(boat.hold_helper_renderings[nth - 1][4], { 'pirates.hold_connections_label_to', nth })
boat.hold_helper_renderings[nth][3].text = { 'pirates.hold_connections_label_from', nth - 1 }
boat.hold_helper_renderings[nth - 1][3].text = { 'pirates.hold_connections_label_to', nth }
boat.hold_helper_renderings[nth][4].text = { 'pirates.hold_connections_label_from', nth - 1 }
boat.hold_helper_renderings[nth - 1][4].text = { 'pirates.hold_connections_label_to', nth }
else
connections = {
{ 5, 5 },
@ -366,10 +366,10 @@ function Public.nth_hold_connect_linked_belts(nth) --assumes both are in standar
b1.connect_linked_belts(b2)
end
rendering.set_text(boat.hold_helper_renderings[nth][3], { 'pirates.hold_connections_label_from', nth - 1 })
rendering.set_text(boat.hold_helper_renderings[nth - 1][3], { 'pirates.hold_connections_label_to', nth })
rendering.set_text(boat.hold_helper_renderings[nth][4], { 'pirates.hold_connections_label_from', nth - 1 })
rendering.set_text(boat.hold_helper_renderings[nth - 1][4], { 'pirates.hold_connections_label_to', nth })
boat.hold_helper_renderings[nth][3].text = { 'pirates.hold_connections_label_from', nth - 1 }
boat.hold_helper_renderings[nth - 1][3].text = { 'pirates.hold_connections_label_to', nth }
boat.hold_helper_renderings[nth][4].text = { 'pirates.hold_connections_label_from', nth - 1 }
boat.hold_helper_renderings[nth - 1][4].text = { 'pirates.hold_connections_label_to', nth }
end
connections = {
{ 1, 9 },
@ -383,10 +383,10 @@ function Public.nth_hold_connect_linked_belts(nth) --assumes both are in standar
b1.connect_linked_belts(b2)
end
rendering.set_text(boat.hold_helper_renderings[nth][1], { 'pirates.hold_connections_label_to', 1 })
rendering.set_text(boat.hold_helper_renderings[1][1], { 'pirates.hold_connections_label_from', nth })
rendering.set_text(boat.hold_helper_renderings[nth][2], { 'pirates.hold_connections_label_to', 1 })
rendering.set_text(boat.hold_helper_renderings[1][2], { 'pirates.hold_connections_label_from', nth })
boat.hold_helper_renderings[nth][1].text = { 'pirates.hold_connections_label_to', 1 }
boat.hold_helper_renderings[1][1].text = { 'pirates.hold_connections_label_from', nth }
boat.hold_helper_renderings[nth][2].text = { 'pirates.hold_connections_label_to', 1 }
boat.hold_helper_renderings[1][2].text = { 'pirates.hold_connections_label_from', nth }
else
connections = {
{ 1, 1 },
@ -400,10 +400,10 @@ function Public.nth_hold_connect_linked_belts(nth) --assumes both are in standar
b1.connect_linked_belts(b2)
end
rendering.set_text(boat.hold_helper_renderings[nth][1], { 'pirates.hold_connections_label_from', nth - 1 })
rendering.set_text(boat.hold_helper_renderings[nth - 1][1], { 'pirates.hold_connections_label_to', nth })
rendering.set_text(boat.hold_helper_renderings[nth][2], { 'pirates.hold_connections_label_from', nth - 1 })
rendering.set_text(boat.hold_helper_renderings[nth - 1][2], { 'pirates.hold_connections_label_to', nth })
boat.hold_helper_renderings[nth][1].text = { 'pirates.hold_connections_label_from', nth - 1 }
boat.hold_helper_renderings[nth - 1][1].text = { 'pirates.hold_connections_label_to', nth }
boat.hold_helper_renderings[nth][2].text = { 'pirates.hold_connections_label_from', nth - 1 }
boat.hold_helper_renderings[nth - 1][2].text = { 'pirates.hold_connections_label_to', nth }
connections = {
{ 5, 9 },
@ -417,10 +417,10 @@ function Public.nth_hold_connect_linked_belts(nth) --assumes both are in standar
b1.connect_linked_belts(b2)
end
rendering.set_text(boat.hold_helper_renderings[nth][3], { 'pirates.hold_connections_label_to', 1 })
rendering.set_text(boat.hold_helper_renderings[1][1], { 'pirates.hold_connections_label_from', nth })
rendering.set_text(boat.hold_helper_renderings[nth][4], { 'pirates.hold_connections_label_to', 1 })
rendering.set_text(boat.hold_helper_renderings[1][2], { 'pirates.hold_connections_label_from', nth })
boat.hold_helper_renderings[nth][3].text = { 'pirates.hold_connections_label_to', 1 }
boat.hold_helper_renderings[1][1].text = { 'pirates.hold_connections_label_from', nth }
boat.hold_helper_renderings[nth][4].text = { 'pirates.hold_connections_label_to', 1 }
boat.hold_helper_renderings[1][2].text = { 'pirates.hold_connections_label_from', nth }
end
end
end

View File

@ -238,7 +238,7 @@ function Public.enemies_specworms_separate(args, spec)
local memory = Memory.get_crew_memory()
local enemy_force_name = memory.enemy_force_name
local evolution = game.forces[enemy_force_name].evolution_factor
local evolution = memory.evolution_factor
args.entities[#args.entities + 1] = { name = Common.get_random_worm_type(evolution + 0.05), position = p, force = enemy_force_name }
end

View File

@ -274,15 +274,17 @@ local function radioactive_tick()
pollution = 6 * (Common.difficulty_scale() ^ (1.1) * (memory.overworldx / 40) ^ (18 / 10) * (Balance.crew_scale()) ^ (1 / 5)) / 3600 * tickinterval * (1 + (Common.difficulty_scale() - 1) * 0.2 + 0.001 * timer)
end
if pollution > 0 then
memory.floating_pollution = memory.floating_pollution + pollution
game.pollution_statistics.on_flow('uranium-ore', pollution)
end
local surface = game.surfaces[destination.surface_name]
if surface and surface.valid and (not surface.freeze_daytime) and destination.dynamic_data.timer and destination.dynamic_data.timer >= CoreData.daynightcycle_types[Public.Data.static_params_default.daynightcycletype].ticksperday / 60 / 2 then --once daytime, never go back to night
surface.freeze_daytime = true
if surface and surface.valid then
if pollution > 0 then
memory.floating_pollution = memory.floating_pollution + pollution
game.get_pollution_statistics(surface).on_flow('uranium-ore', pollution)
end
if (not surface.freeze_daytime) and destination.dynamic_data.timer and destination.dynamic_data.timer >= CoreData.daynightcycle_types[Public.Data.static_params_default.daynightcycletype].ticksperday / 60 / 2 then --once daytime, never go back to night
surface.freeze_daytime = true
end
end
end
end

View File

@ -400,7 +400,7 @@ function Public.custom_biter_ai()
spawn(name)
end
game.pollution_statistics.on_flow(name, budget - initialbudget)
game.get_pollution_statistics(surface).on_flow(name, budget - initialbudget)
memory.floating_pollution = pollution_available
if (not units_created) or (not #units_created) or (#units_created == 0) then return end

View File

@ -216,7 +216,7 @@ function Public.kraken_tick(crew_id, kraken_id, step, substep)
max_range = 500,
speed = 0.1
}
memory.kraken_stream_registrations[#memory.kraken_stream_registrations + 1] = { number = script.register_on_entity_destroyed(stream), position = spit_target_pos }
memory.kraken_stream_registrations[#memory.kraken_stream_registrations + 1] = { number = script.register_on_object_destroyed(stream), position = spit_target_pos }
Effects.kraken_effect_4(surface, kraken_data.position)
end
@ -233,7 +233,7 @@ function Public.kraken_tick(crew_id, kraken_id, step, substep)
end
end
local function on_entity_destroyed(event)
local function on_object_destroyed(event)
local registration_number = event.registration_number
local p
@ -419,6 +419,6 @@ function Public.kraken_die(kraken_id)
end
local event = require 'utils.event'
event.add(defines.events.on_entity_destroyed, on_entity_destroyed)
event.add(defines.events.on_object_destroyed, on_object_destroyed)
return Public