diff --git a/maps/pirates/ai.lua b/maps/pirates/ai.lua index 24d0a9b8..07673866 100644 --- a/maps/pirates/ai.lua +++ b/maps/pirates/ai.lua @@ -5,6 +5,7 @@ local Common = require 'maps.pirates.common' local CoreData = require 'maps.pirates.coredata' -- local Utils = require 'maps.pirates.utils_local' local Math = require 'maps.pirates.math' +local Raffle = require 'maps.pirates.raffle' local _inspect = require 'utils.inspect'.inspect -- local Structures = require 'maps.pirates.structures.structures' @@ -532,7 +533,7 @@ function Public.generate_side_attack_target(surface, position) for index, _ in pairs(entities) do weights[#weights + 1] = 1 + Math.floor((#entities - index) / 2) end - return Math.raffle(entities, weights) + return Raffle.raffle(entities, weights) end function Public.nearest_target(surface, position) diff --git a/maps/pirates/balance.lua b/maps/pirates/balance.lua index 821f3bc8..3d3e6215 100644 --- a/maps/pirates/balance.lua +++ b/maps/pirates/balance.lua @@ -1,6 +1,7 @@ local Public = {} local Math = require 'maps.pirates.math' +local Raffle = require 'maps.pirates.raffle' -- local Memory = require 'maps.pirates.memory' local Common = require 'maps.pirates.common' local Utils = require 'maps.pirates.utils_local' @@ -626,15 +627,160 @@ function Public.covered1_entry_price() end end - local res = Utils.deepcopy(Math.raffle(types, weights)) + local res = Utils.deepcopy(Raffle.raffle(types, weights)) - res.price.count = Math.ceil(res.price.count * Public.covered_entry_price_scale()) + res.price.count = Math.ceil(res.price.count * Public.covered1_entry_price_scale()) for i, _ in pairs(res.raw_materials) do - res.raw_materials[i].count = Math.ceil(res.raw_materials[i].count * Public.covered_entry_price_scale() * (0.9 + 0.2 * Math.random())) + res.raw_materials[i].count = Math.ceil(res.raw_materials[i].count * Public.covered1_entry_price_scale() * (0.9 + 0.2 * Math.random())) end return res end + + + + + + + + + + +function Public.covered2_entry_price_scale() + return 0.85 * (1 + 0.033 * (Common.overworldx()/40 - 1)) * ((1 + Public.crew_scale())^(1/3)) * Math.sloped(Common.difficulty_scale(), 1/2) --whilst resource scales tend to be held fixed with crew size, we account slightly for the fact that more players tend to handcraft more +end + +Public.covered2EntryPriceData = {-- choose things which make interesting minifactories + ['electric-mining-drill'] = { + overallWeight = 1, + minLambda = -0.75, + maxLambda = 0.75, + shape = 'bump', + enabled = true, + baseAmount = 500, + itemBatchSize = 2, + batchRawMaterials = {['iron-plate'] = 46, ['copper-plate'] = 9}, + }, + ['fast-splitter'] = { + overallWeight = 1, + minLambda = -1, + maxLambda = 1, + shape = 'bump', + enabled = true, + baseAmount = 500, + itemBatchSize = 2, + batchRawMaterials = {['iron-plate'] = 92, ['copper-plate'] = 45}, + }, + ['assembling-machine-1'] = { + overallWeight = 1, + minLambda = -1, + maxLambda = 1, + shape = 'bump', + enabled = true, + baseAmount = 500, + itemBatchSize = 2, + batchRawMaterials = {['iron-plate'] = 44, ['copper-plate'] = 9}, + }, + ['filter-inserter'] = { + overallWeight = 1, + minLambda = 0, + maxLambda = 1, + shape = 'density', + enabled = true, + baseAmount = 500, + itemBatchSize = 2, + batchRawMaterials = {['iron-plate'] = 32, ['copper-plate'] = 24}, + }, + ['programmable-speaker'] = { + overallWeight = 1, + minLambda = 0, + maxLambda = 1, + shape = 'density', + enabled = true, + baseAmount = 500, + itemBatchSize = 2, + batchRawMaterials = {['iron-plate'] = 18, ['copper-plate'] = 17}, + }, + ['pump'] = { + overallWeight = 1, + minLambda = 0.05, + maxLambda = 1, + shape = 'density', + enabled = true, + baseAmount = 500, + itemBatchSize = 1, + batchRawMaterials = {['iron-plate'] = 15}, + }, + ['grenade'] = { + overallWeight = 1, + minLambda = 0.05, + maxLambda = 1, + shape = 'density', + enabled = true, + baseAmount = 500, + itemBatchSize = 1, + batchRawMaterials = {['iron-plate'] = 5, ['coal'] = 10}, + }, + ['assembling-machine-2'] = { + overallWeight = 1, + minLambda = 0.2, + maxLambda = 1.2, + shape = 'bump', + enabled = true, + baseAmount = 500, + itemBatchSize = 2, + batchRawMaterials = {['iron-plate'] = 160, ['copper-plate'] = 18}, + }, + ['pumpjack'] = { + overallWeight = 1, + minLambda = 0.35, + maxLambda = 1, + shape = 'density', + enabled = true, + baseAmount = 500, + itemBatchSize = 2, + batchRawMaterials = {['iron-plate'] = 120, ['copper-plate'] = 15}, + }, + ['oil-refinery'] = { + overallWeight = 1, + minLambda = 0.35, + maxLambda = 1, + shape = 'density', + enabled = true, + baseAmount = 500, + itemBatchSize = 1, + batchRawMaterials = {['iron-plate'] = 115, ['copper-plate'] = 15, ['stone-brick'] = 10}, + }, + ['chemical-plant'] = { + overallWeight = 1, + minLambda = 0.35, + maxLambda = 1, + shape = 'density', + enabled = true, + baseAmount = 500, + itemBatchSize = 2, + batchRawMaterials = {['iron-plate'] = 90, ['copper-plate'] = 15}, + }, +} + +function Public.generateCovered2EntryPrice() + local lambda = Math.max(Math.min(Math.sloped(Common.difficulty_scale(),1/2) * Common.game_completion_progress(), 1), 0) + + local item = Raffle.LambdaRaffle(Public.covered2EntryPriceData, lambda) + + local batchSize = Public.covered2EntryPriceData[item].itemBatchSize + + return { + name = item, + count = Math.ceil( + (0.9 + 0.2 * Math.random()) * Public.covered2EntryPriceData[item].baseAmount * Public.covered2_entry_price_scale() / batchSize + ) * batchSize, + batchSize = batchSize, + batchRawMaterials = Public.covered2EntryPriceData[item].batchRawMaterials, + } +end + + return Public \ No newline at end of file diff --git a/maps/pirates/common.lua b/maps/pirates/common.lua index 5423bedf..ea21ac57 100644 --- a/maps/pirates/common.lua +++ b/maps/pirates/common.lua @@ -1,5 +1,6 @@ local Math = require 'maps.pirates.math' +local Raffle = require 'maps.pirates.raffle' local Server = require 'utils.server' local Utils = require 'maps.pirates.utils_local' local CoreData = require 'maps.pirates.coredata' @@ -14,9 +15,10 @@ local _inspect = require 'utils.inspect'.inspect local Public = {} +--@TODO: decide on snakecase vs camelcase -- Public.active_crews_cap = 1 -Public.active_crews_cap = 2 -Public.minimum_capacity_slider_value = 1 +Public.activeCrewsCap = 2 +Public.minimumCapacitySliderValue = 1 Public.minimum_run_capacity_to_enforce_space_for = 32 -- auto-disbanding when there are no players left in the crew: Public.autodisband_ticks = nil @@ -33,10 +35,10 @@ Public.mapedge_distance_from_boat_starting_position = 272 -- to accommodate hors Public.deepwater_distance_from_leftmost_shore = 32 Public.lobby_spawnpoint = {x = -72, y = -8} -Public.quartermaster_range = 17 +Public.quartermaster_range = 19 Public.allow_barreling_off_ship = true -Public.fraction_of_map_loaded_atsea = 1 +Public.fraction_of_map_loaded_at_sea = 1 Public.map_loading_ticks_atsea = 68 * 60 Public.map_loading_ticks_atsea_maze = 80 * 60 Public.map_loading_ticks_atsea_dock = 20 * 60 @@ -242,7 +244,7 @@ function Public.raffle_from_processed_loot_data(processed_loot_data, how_many, g end for _ = 1, how_many do - local loot = Math.raffle(loot_types, loot_weights) + local loot = Raffle.raffle(loot_types, loot_weights) if loot then local low = Math.max(1, Math.ceil(loot.min_count)) local high = Math.max(1, Math.ceil(loot.max_count)) diff --git a/maps/pirates/coredata.lua b/maps/pirates/coredata.lua index 3bef46a9..910aba38 100644 --- a/maps/pirates/coredata.lua +++ b/maps/pirates/coredata.lua @@ -114,13 +114,13 @@ Public.difficulty_options = { {value = 0.6, icon = 'item/firearm-magazine', text = 'Easy', associated_color = {r = 50, g = 255, b = 50}}, {value = 1.0, icon = 'item/piercing-rounds-magazine', text = 'Normal', associated_color = {r = 255, g = 255, b = 50}}, {value = 1.4, icon = 'item/uranium-rounds-magazine', text = 'Hard', associated_color = {r = 255, g = 50, b = 50}}, - {value = 2.4, icon = 'item/atomic-bomb', text = 'Nightmare', associated_color = {r = 120, g = 35, b = 35}}, + {value = 2.1, icon = 'item/atomic-bomb', text = 'Nightmare', associated_color = {r = 120, g = 35, b = 35}}, } function Public.get_difficulty_name_from_value(difficulty_value) -- Functions will reference this when given a difficulty value and want to present a difficulty name to the player; just make it consistent with the above if difficulty_value <= 0.7 then return 'Easy' - elseif difficulty_value < 1.3 then + elseif difficulty_value < 1.2 then return 'Normal' elseif difficulty_value <= 2 then return 'Hard' diff --git a/maps/pirates/gui/common.lua b/maps/pirates/gui/common.lua index 049a4af5..2d32e05e 100644 --- a/maps/pirates/gui/common.lua +++ b/maps/pirates/gui/common.lua @@ -443,11 +443,11 @@ function Public.player_and_crew_state_bools(player) if character_on_deck_bool then local BoatData = Boats.get_scope(memory.boat).Data - on_deck_standing_near_loco_bool = Math.distance(player.character.position, Math.vector_sum(memory.boat.position, BoatData.loco_pos)) < 3 + on_deck_standing_near_loco_bool = Math.distance(player.character.position, Math.vector_sum(memory.boat.position, BoatData.loco_pos)) < 2.5 - on_deck_standing_near_cabin_bool = Math.distance(player.character.position, Math.vector_sum(memory.boat.position, BoatData.cabin_car)) < 2.5 + on_deck_standing_near_cabin_bool = Math.distance(player.character.position, Math.vector_sum(memory.boat.position, BoatData.cabin_car)) < 2.0 - on_deck_standing_near_crowsnest_bool = Math.distance(player.character.position, Math.vector_sum(memory.boat.position, BoatData.crowsnest_center)) < 2.7 + on_deck_standing_near_crowsnest_bool = Math.distance(player.character.position, Math.vector_sum(memory.boat.position, BoatData.crowsnest_center)) < 2.5 end approaching_dock_bool = destination.type == Surfaces.enum.DOCK and memory.boat.state == Boats.enum_state.APPROACHING diff --git a/maps/pirates/gui/runs.lua b/maps/pirates/gui/runs.lua index d7564b25..fec44924 100644 --- a/maps/pirates/gui/runs.lua +++ b/maps/pirates/gui/runs.lua @@ -477,7 +477,7 @@ function Public.full_update(player) -- flow.proposals.body.proposal_maker.body.proposal_cant_do_infinity_mode.visible = (flow.proposals.body.proposal_maker.body.options.mode.mode.switch.switch_state == 'right') -- flow.proposals.body.proposal_maker.body.proposal_disabled_low_crew_caps.visible = false - flow.proposals.body.proposal_maker.body.proposal_disabled_low_crew_caps.visible = (flow.proposals.body.proposal_maker.body.options.capacity.capacity.slider.slider_value < global_memory.minimum_capacity_slider_value) + flow.proposals.body.proposal_maker.body.proposal_disabled_low_crew_caps.visible = (flow.proposals.body.proposal_maker.body.options.capacity.capacity.slider.slider_value < global_memory.minimumCapacitySliderValue) flow.proposals.body.proposal_maker.body.propose_crew.visible = (flow.proposals.body.proposal_maker.body.proposal_disabled_low_crew_caps.visible == false) -- flow.proposals.body.proposal_maker.body.propose_crew.visible = (flow.proposals.body.proposal_maker.body.proposal_cant_do_infinity_mode.visible == false) and (flow.proposals.body.proposal_maker.body.proposal_disabled_low_crew_caps.visible == false) diff --git a/maps/pirates/loot.lua b/maps/pirates/loot.lua index ea5e1d57..5f9c096d 100644 --- a/maps/pirates/loot.lua +++ b/maps/pirates/loot.lua @@ -212,16 +212,16 @@ function Public.wooden_chest_loot() local num = 1 return Public.chest_loot(num, - Math.max(0,Math.min(1, Math.sloped(Common.difficulty_scale(),1/2) * Common.game_completion_progress())) --enforce 0 to 1 -) + Math.max(0,Math.min(1, Math.sloped(Common.difficulty_scale(),1/2) * Common.game_completion_progress())) --enforce 0 to 1 + ) end function Public.iron_chest_loot() local num = 2 local loot = Public.chest_loot(num, - Math.max(0,Math.min(1, Math.sloped(Common.difficulty_scale(),1/2) * (5/100 + Common.game_completion_progress()))) --enforce 0 to 1 -) --reward higher difficulties with better loot + Math.max(0,Math.min(1, Math.sloped(Common.difficulty_scale(),1/2) * (5/100 + Common.game_completion_progress())) ) --enforce 0 to 1 + ) --reward higher difficulties with better loot loot[#loot + 1] = {name = 'coin', count = Math.random(500,1500)} return loot @@ -231,12 +231,26 @@ function Public.covered_wooden_chest_loot() local num = 2 local loot = Public.chest_loot(num, - Math.max(0,Math.min(1, Math.sloped(Common.difficulty_scale(),1/2) * (10/100 + Common.game_completion_progress()))) --enforce 0 to 1 -) --reward higher difficulties with better loot + Math.max(0,Math.min(1, Math.sloped(Common.difficulty_scale(),1/2) * (15/100 + Common.game_completion_progress()) )) --enforce 0 to 1 + ) --reward higher difficulties with better loot return loot end +function Public.covered_wooden_chest_loot_1() + + return { + {name = 'iron-plate', count = 180}, + {name = 'copper-plate', count = 180} + } +end + +function Public.covered_wooden_chest_loot_2() + + return Common.raffle_from_processed_loot_data(Common.processed_loot_data(Public.chest_loot_data_raw), 2, + Math.max(0,Math.min(1, Math.sloped(Common.difficulty_scale(),1/2) * (12/100 + Common.game_completion_progress())))) +end + function Public.stone_furnace_loot() return { {name = 'coal', count = 50}, diff --git a/maps/pirates/main.lua b/maps/pirates/main.lua index f8282e7d..9023f0aa 100644 --- a/maps/pirates/main.lua +++ b/maps/pirates/main.lua @@ -97,8 +97,8 @@ local function on_init() Common.init_game_settings(Balance.technology_price_multiplier) - global_memory.active_crews_cap = Common.active_crews_cap - global_memory.minimum_capacity_slider_value = Common.minimum_capacity_slider_value + global_memory.active_crews_cap = Common.activeCrewsCap + global_memory.minimumCapacitySliderValue = Common.minimumCapacitySliderValue Surfaces.Lobby.create_starting_dock_surface() local lobby = game.surfaces[CoreData.lobby_surface_name] diff --git a/maps/pirates/math.lua b/maps/pirates/math.lua index d1cd8309..8fae8044 100644 --- a/maps/pirates/math.lua +++ b/maps/pirates/math.lua @@ -87,50 +87,6 @@ function Public.shuffle_distancebiased(tbl, position) return tbl end -function Public.raffle(values, weights) --arguments of the form {[a] = A, [b] = B, ...} and {[a] = a_weight, [b] = b_weight, ...} or just {a,b,c,...} and {1,2,3...} - - local total_weight = 0 - for k,w in pairs(weights) do - assert(values[k]) - if w > 0 then - total_weight = total_weight + w - end - -- negative weights treated as zero - end - if (not (total_weight > 0)) then return nil end - - local cumulative_probability = 0 - local rng = Public.random() - for k,v in pairs(values) do - assert(weights[k]) - cumulative_probability = cumulative_probability + (weights[k] / total_weight) - if rng <= cumulative_probability then - return v - end - end -end - -function Public.raffle2(table) --arguments of the form {v1 = w1, v2 = w2, ...} - - local total_weight = 0 - for k,w in pairs(table) do - if w > 0 then - total_weight = total_weight + w - end - -- negative weights treated as zero - end - assert(total_weight > 0) - - local cumulative_probability = 0 - local rng = Public.random() - for k,v in pairs(table) do - cumulative_probability = cumulative_probability + v/total_weight - if rng <= cumulative_probability then - return k - end - end -end - Public.points_in_m20t20_squared_sorted_by_distance_to_origin = {{0, 0}, {1, 0}, {0, 1}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}, {2, 0}, {0, 2}, {0, -2}, {-2, 0}, {2, 1}, {2, -1}, {1, 2}, {1, -2}, {-1, 2}, {-1, -2}, {-2, 1}, {-2, -1}, {2, 2}, {2, -2}, {-2, 2}, {-2, -2}, {3, 0}, {0, 3}, {0, -3}, {-3, 0}, {3, 1}, {3, -1}, {1, 3}, {1, -3}, {-1, 3}, {-1, -3}, {-3, 1}, {-3, -1}, {3, 2}, {3, -2}, {2, 3}, {2, -3}, {-2, 3}, {-2, -3}, {-3, 2}, {-3, -2}, {4, 0}, {0, 4}, {0, -4}, {-4, 0}, {4, 1}, {4, -1}, {1, 4}, {1, -4}, {-1, 4}, {-1, -4}, {-4, 1}, {-4, -1}, {3, 3}, {3, -3}, {-3, 3}, {-3, -3}, {4, 2}, {4, -2}, {2, 4}, {2, -4}, {-2, 4}, {-2, -4}, {-4, 2}, {-4, -2}, {5, 0}, {4, 3}, {4, -3}, {3, 4}, {3, -4}, {0, 5}, {0, -5}, {-3, 4}, {-3, -4}, {-4, 3}, {-4, -3}, {-5, 0}, {5, 1}, {5, -1}, {1, 5}, {1, -5}, {-1, 5}, {-1, -5}, {-5, 1}, {-5, -1}, {5, 2}, {5, -2}, {2, 5}, {2, -5}, {-2, 5}, {-2, -5}, {-5, 2}, {-5, -2}, {4, 4}, {4, -4}, {-4, 4}, {-4, -4}, {5, 3}, {5, -3}, {3, 5}, {3, -5}, {-3, 5}, {-3, -5}, {-5, 3}, {-5, -3}, {6, 0}, {0, 6}, {0, -6}, {-6, 0}, {6, 1}, {6, -1}, {1, 6}, {1, -6}, {-1, 6}, {-1, -6}, {-6, 1}, {-6, -1}, {6, 2}, {6, -2}, {2, 6}, {2, -6}, {-2, 6}, {-2, -6}, {-6, 2}, {-6, -2}, {5, 4}, {5, -4}, {4, 5}, {4, -5}, {-4, 5}, {-4, -5}, {-5, 4}, {-5, -4}, {6, 3}, {6, -3}, {3, 6}, {3, -6}, {-3, 6}, {-3, -6}, {-6, 3}, {-6, -3}, {7, 0}, {0, 7}, {0, -7}, {-7, 0}, {7, 1}, {7, -1}, {5, 5}, {5, -5}, {1, 7}, {1, -7}, {-1, 7}, {-1, -7}, {-5, 5}, {-5, -5}, {-7, 1}, {-7, -1}, {6, 4}, {6, -4}, {4, 6}, {4, -6}, {-4, 6}, {-4, -6}, {-6, 4}, {-6, -4}, {7, 2}, {7, -2}, {2, 7}, {2, -7}, {-2, 7}, {-2, -7}, {-7, 2}, {-7, -2}, {7, 3}, {7, -3}, {3, 7}, {3, -7}, {-3, 7}, {-3, -7}, {-7, 3}, {-7, -3}, {6, 5}, {6, -5}, {5, 6}, {5, -6}, {-5, 6}, {-5, -6}, {-6, 5}, {-6, -5}, {8, 0}, {0, 8}, {0, -8}, {-8, 0}, {8, 1}, {8, -1}, {7, 4}, {7, -4}, {4, 7}, {4, -7}, {1, 8}, {1, -8}, {-1, 8}, {-1, -8}, {-4, 7}, {-4, -7}, {-7, 4}, {-7, -4}, {-8, 1}, {-8, -1}, {8, 2}, {8, -2}, {2, 8}, {2, -8}, {-2, 8}, {-2, -8}, {-8, 2}, {-8, -2}, {6, 6}, {6, -6}, {-6, 6}, {-6, -6}, {8, 3}, {8, -3}, {3, 8}, {3, -8}, {-3, 8}, {-3, -8}, {-8, 3}, {-8, -3}, {7, 5}, {7, -5}, {5, 7}, {5, -7}, {-5, 7}, {-5, -7}, {-7, 5}, {-7, -5}, {8, 4}, {8, -4}, {4, 8}, {4, -8}, {-4, 8}, {-4, -8}, {-8, 4}, {-8, -4}, {9, 0}, {0, 9}, {0, -9}, {-9, 0}, {9, 1}, {9, -1}, {1, 9}, {1, -9}, {-1, 9}, {-1, -9}, {-9, 1}, {-9, -1}, {9, 2}, {9, -2}, {7, 6}, {7, -6}, {6, 7}, {6, -7}, {2, 9}, {2, -9}, {-2, 9}, {-2, -9}, {-6, 7}, {-6, -7}, {-7, 6}, {-7, -6}, {-9, 2}, {-9, -2}, {8, 5}, {8, -5}, {5, 8}, {5, -8}, {-5, 8}, {-5, -8}, {-8, 5}, {-8, -5}, {9, 3}, {9, -3}, {3, 9}, {3, -9}, {-3, 9}, {-3, -9}, {-9, 3}, {-9, -3}, {9, 4}, {9, -4}, {4, 9}, {4, -9}, {-4, 9}, {-4, -9}, {-9, 4}, {-9, -4}, {7, 7}, {7, -7}, {-7, 7}, {-7, -7}, {10, 0}, {8, 6}, {8, -6}, {6, 8}, {6, -8}, {0, 10}, {0, -10}, {-6, 8}, {-6, -8}, {-8, 6}, {-8, -6}, {-10, 0}, {10, 1}, {10, -1}, {1, 10}, {1, -10}, {-1, 10}, {-1, -10}, {-10, 1}, {-10, -1}, {10, 2}, {10, -2}, {2, 10}, {2, -10}, {-2, 10}, {-2, -10}, {-10, 2}, {-10, -2}, {9, 5}, {9, -5}, {5, 9}, {5, -9}, {-5, 9}, {-5, -9}, {-9, 5}, {-9, -5}, {10, 3}, {10, -3}, {3, 10}, {3, -10}, {-3, 10}, {-3, -10}, {-10, 3}, {-10, -3}, {8, 7}, {8, -7}, {7, 8}, {7, -8}, {-7, 8}, {-7, -8}, {-8, 7}, {-8, -7}, {10, 4}, {10, -4}, {4, 10}, {4, -10}, {-4, 10}, {-4, -10}, {-10, 4}, {-10, -4}, {9, 6}, {9, -6}, {6, 9}, {6, -9}, {-6, 9}, {-6, -9}, {-9, 6}, {-9, -6}, {11, 0}, {0, 11}, {0, -11}, {-11, 0}, {11, 1}, {11, -1}, {1, 11}, {1, -11}, {-1, 11}, {-1, -11}, {-11, 1}, {-11, -1}, {11, 2}, {11, -2}, {10, 5}, {10, -5}, {5, 10}, {5, -10}, {2, 11}, {2, -11}, {-2, 11}, {-2, -11}, {-5, 10}, {-5, -10}, {-10, 5}, {-10, -5}, {-11, 2}, {-11, -2}, {8, 8}, {8, -8}, {-8, 8}, {-8, -8}, {11, 3}, {11, -3}, {9, 7}, {9, -7}, {7, 9}, {7, -9}, {3, 11}, {3, -11}, {-3, 11}, {-3, -11}, {-7, 9}, {-7, -9}, {-9, 7}, {-9, -7}, {-11, 3}, {-11, -3}, {10, 6}, {10, -6}, {6, 10}, {6, -10}, {-6, 10}, {-6, -10}, {-10, 6}, {-10, -6}, {11, 4}, {11, -4}, {4, 11}, {4, -11}, {-4, 11}, {-4, -11}, {-11, 4}, {-11, -4}, {12, 0}, {0, 12}, {0, -12}, {-12, 0}, {12, 1}, {12, -1}, {9, 8}, {9, -8}, {8, 9}, {8, -9}, {1, 12}, {1, -12}, {-1, 12}, {-1, -12}, {-8, 9}, {-8, -9}, {-9, 8}, {-9, -8}, {-12, 1}, {-12, -1}, {11, 5}, {11, -5}, {5, 11}, {5, -11}, {-5, 11}, {-5, -11}, {-11, 5}, {-11, -5}, {12, 2}, {12, -2}, {2, 12}, {2, -12}, {-2, 12}, {-2, -12}, {-12, 2}, {-12, -2}, {10, 7}, {10, -7}, {7, 10}, {7, -10}, {-7, 10}, {-7, -10}, {-10, 7}, {-10, -7}, {12, 3}, {12, -3}, {3, 12}, {3, -12}, {-3, 12}, {-3, -12}, {-12, 3}, {-12, -3}, {11, 6}, {11, -6}, {6, 11}, {6, -11}, {-6, 11}, {-6, -11}, {-11, 6}, {-11, -6}, {12, 4}, {12, -4}, {4, 12}, {4, -12}, {-4, 12}, {-4, -12}, {-12, 4}, {-12, -4}, {9, 9}, {9, -9}, {-9, 9}, {-9, -9}, {10, 8}, {10, -8}, {8, 10}, {8, -10}, {-8, 10}, {-8, -10}, {-10, 8}, {-10, -8}, {13, 0}, {12, 5}, {12, -5}, {5, 12}, {5, -12}, {0, 13}, {0, -13}, {-5, 12}, {-5, -12}, {-12, 5}, {-12, -5}, {-13, 0}, {13, 1}, {13, -1}, {11, 7}, {11, -7}, {7, 11}, {7, -11}, {1, 13}, {1, -13}, {-1, 13}, {-1, -13}, {-7, 11}, {-7, -11}, {-11, 7}, {-11, -7}, {-13, 1}, {-13, -1}, {13, 2}, {13, -2}, {2, 13}, {2, -13}, {-2, 13}, {-2, -13}, {-13, 2}, {-13, -2}, {13, 3}, {13, -3}, {3, 13}, {3, -13}, {-3, 13}, {-3, -13}, {-13, 3}, {-13, -3}, {12, 6}, {12, -6}, {6, 12}, {6, -12}, {-6, 12}, {-6, -12}, {-12, 6}, {-12, -6}, {10, 9}, {10, -9}, {9, 10}, {9, -10}, {-9, 10}, {-9, -10}, {-10, 9}, {-10, -9}, {13, 4}, {13, -4}, {11, 8}, {11, -8}, {8, 11}, {8, -11}, {4, 13}, {4, -13}, {-4, 13}, {-4, -13}, {-8, 11}, {-8, -11}, {-11, 8}, {-11, -8}, {-13, 4}, {-13, -4}, {12, 7}, {12, -7}, {7, 12}, {7, -12}, {-7, 12}, {-7, -12}, {-12, 7}, {-12, -7}, {13, 5}, {13, -5}, {5, 13}, {5, -13}, {-5, 13}, {-5, -13}, {-13, 5}, {-13, -5}, {14, 0}, {0, 14}, {0, -14}, {-14, 0}, {14, 1}, {14, -1}, {1, 14}, {1, -14}, {-1, 14}, {-1, -14}, {-14, 1}, {-14, -1}, {14, 2}, {14, -2}, {10, 10}, {10, -10}, {2, 14}, {2, -14}, {-2, 14}, {-2, -14}, {-10, 10}, {-10, -10}, {-14, 2}, {-14, -2}, {11, 9}, {11, -9}, {9, 11}, {9, -11}, {-9, 11}, {-9, -11}, {-11, 9}, {-11, -9}, {14, 3}, {14, -3}, {13, 6}, {13, -6}, {6, 13}, {6, -13}, {3, 14}, {3, -14}, {-3, 14}, {-3, -14}, {-6, 13}, {-6, -13}, {-13, 6}, {-13, -6}, {-14, 3}, {-14, -3}, {12, 8}, {12, -8}, {8, 12}, {8, -12}, {-8, 12}, {-8, -12}, {-12, 8}, {-12, -8}, {14, 4}, {14, -4}, {4, 14}, {4, -14}, {-4, 14}, {-4, -14}, {-14, 4}, {-14, -4}, {13, 7}, {13, -7}, {7, 13}, {7, -13}, {-7, 13}, {-7, -13}, {-13, 7}, {-13, -7}, {14, 5}, {14, -5}, {11, 10}, {11, -10}, {10, 11}, {10, -11}, {5, 14}, {5, -14}, {-5, 14}, {-5, -14}, {-10, 11}, {-10, -11}, {-11, 10}, {-11, -10}, {-14, 5}, {-14, -5}, {15, 0}, {12, 9}, {12, -9}, {9, 12}, {9, -12}, {0, 15}, {0, -15}, {-9, 12}, {-9, -12}, {-12, 9}, {-12, -9}, {-15, 0}, {15, 1}, {15, -1}, {1, 15}, {1, -15}, {-1, 15}, {-1, -15}, {-15, 1}, {-15, -1}, {15, 2}, {15, -2}, {2, 15}, {2, -15}, {-2, 15}, {-2, -15}, {-15, 2}, {-15, -2}, {14, 6}, {14, -6}, {6, 14}, {6, -14}, {-6, 14}, {-6, -14}, {-14, 6}, {-14, -6}, {13, 8}, {13, -8}, {8, 13}, {8, -13}, {-8, 13}, {-8, -13}, {-13, 8}, {-13, -8}, {15, 3}, {15, -3}, {3, 15}, {3, -15}, {-3, 15}, {-3, -15}, {-15, 3}, {-15, -3}, {15, 4}, {15, -4}, {4, 15}, {4, -15}, {-4, 15}, {-4, -15}, {-15, 4}, {-15, -4}, {11, 11}, {11, -11}, {-11, 11}, {-11, -11}, {12, 10}, {12, -10}, {10, 12}, {10, -12}, {-10, 12}, {-10, -12}, {-12, 10}, {-12, -10}, {14, 7}, {14, -7}, {7, 14}, {7, -14}, {-7, 14}, {-7, -14}, {-14, 7}, {-14, -7}, {15, 5}, {15, -5}, {13, 9}, {13, -9}, {9, 13}, {9, -13}, {5, 15}, {5, -15}, {-5, 15}, {-5, -15}, {-9, 13}, {-9, -13}, {-13, 9}, {-13, -9}, {-15, 5}, {-15, -5}, {16, 0}, {0, 16}, {0, -16}, {-16, 0}, {16, 1}, {16, -1}, {1, 16}, {1, -16}, {-1, 16}, {-1, -16}, {-16, 1}, {-16, -1}, {16, 2}, {16, -2}, {14, 8}, {14, -8}, {8, 14}, {8, -14}, {2, 16}, {2, -16}, {-2, 16}, {-2, -16}, {-8, 14}, {-8, -14}, {-14, 8}, {-14, -8}, {-16, 2}, {-16, -2}, {15, 6}, {15, -6}, {6, 15}, {6, -15}, {-6, 15}, {-6, -15}, {-15, 6}, {-15, -6}, {16, 3}, {16, -3}, {12, 11}, {12, -11}, {11, 12}, {11, -12}, {3, 16}, {3, -16}, {-3, 16}, {-3, -16}, {-11, 12}, {-11, -12}, {-12, 11}, {-12, -11}, {-16, 3}, {-16, -3}, {13, 10}, {13, -10}, {10, 13}, {10, -13}, {-10, 13}, {-10, -13}, {-13, 10}, {-13, -10}, {16, 4}, {16, -4}, {4, 16}, {4, -16}, {-4, 16}, {-4, -16}, {-16, 4}, {-16, -4}, {15, 7}, {15, -7}, {7, 15}, {7, -15}, {-7, 15}, {-7, -15}, {-15, 7}, {-15, -7}, {14, 9}, {14, -9}, {9, 14}, {9, -14}, {-9, 14}, {-9, -14}, {-14, 9}, {-14, -9}, {16, 5}, {16, -5}, {5, 16}, {5, -16}, {-5, 16}, {-5, -16}, {-16, 5}, {-16, -5}, {12, 12}, {12, -12}, {-12, 12}, {-12, -12}, {17, 0}, {15, 8}, {15, -8}, {8, 15}, {8, -15}, {0, 17}, {0, -17}, {-8, 15}, {-8, -15}, {-15, 8}, {-15, -8}, {-17, 0}, {17, 1}, {17, -1}, {13, 11}, {13, -11}, {11, 13}, {11, -13}, {1, 17}, {1, -17}, {-1, 17}, {-1, -17}, {-11, 13}, {-11, -13}, {-13, 11}, {-13, -11}, {-17, 1}, {-17, -1}, {16, 6}, {16, -6}, {6, 16}, {6, -16}, {-6, 16}, {-6, -16}, {-16, 6}, {-16, -6}, {17, 2}, {17, -2}, {2, 17}, {2, -17}, {-2, 17}, {-2, -17}, {-17, 2}, {-17, -2}, {14, 10}, {14, -10}, {10, 14}, {10, -14}, {-10, 14}, {-10, -14}, {-14, 10}, {-14, -10}, {17, 3}, {17, -3}, {3, 17}, {3, -17}, {-3, 17}, {-3, -17}, {-17, 3}, {-17, -3}, {17, 4}, {17, -4}, {16, 7}, {16, -7}, {7, 16}, {7, -16}, {4, 17}, {4, -17}, {-4, 17}, {-4, -17}, {-7, 16}, {-7, -16}, {-16, 7}, {-16, -7}, {-17, 4}, {-17, -4}, {15, 9}, {15, -9}, {9, 15}, {9, -15}, {-9, 15}, {-9, -15}, {-15, 9}, {-15, -9}, {13, 12}, {13, -12}, {12, 13}, {12, -13}, {-12, 13}, {-12, -13}, {-13, 12}, {-13, -12}, {17, 5}, {17, -5}, {5, 17}, {5, -17}, {-5, 17}, {-5, -17}, {-17, 5}, {-17, -5}, {14, 11}, {14, -11}, {11, 14}, {11, -14}, {-11, 14}, {-11, -14}, {-14, 11}, {-14, -11}, {16, 8}, {16, -8}, {8, 16}, {8, -16}, {-8, 16}, {-8, -16}, {-16, 8}, {-16, -8}, {18, 0}, {0, 18}, {0, -18}, {-18, 0}, {18, 1}, {18, -1}, {17, 6}, {17, -6}, {15, 10}, {15, -10}, {10, 15}, {10, -15}, {6, 17}, {6, -17}, {1, 18}, {1, -18}, {-1, 18}, {-1, -18}, {-6, 17}, {-6, -17}, {-10, 15}, {-10, -15}, {-15, 10}, {-15, -10}, {-17, 6}, {-17, -6}, {-18, 1}, {-18, -1}, {18, 2}, {18, -2}, {2, 18}, {2, -18}, {-2, 18}, {-2, -18}, {-18, 2}, {-18, -2}, {18, 3}, {18, -3}, {3, 18}, {3, -18}, {-3, 18}, {-3, -18}, {-18, 3}, {-18, -3}, {16, 9}, {16, -9}, {9, 16}, {9, -16}, {-9, 16}, {-9, -16}, {-16, 9}, {-16, -9}, {17, 7}, {17, -7}, {13, 13}, {13, -13}, {7, 17}, {7, -17}, {-7, 17}, {-7, -17}, {-13, 13}, {-13, -13}, {-17, 7}, {-17, -7}, {18, 4}, {18, -4}, {14, 12}, {14, -12}, {12, 14}, {12, -14}, {4, 18}, {4, -18}, {-4, 18}, {-4, -18}, {-12, 14}, {-12, -14}, {-14, 12}, {-14, -12}, {-18, 4}, {-18, -4}, {15, 11}, {15, -11}, {11, 15}, {11, -15}, {-11, 15}, {-11, -15}, {-15, 11}, {-15, -11}, {18, 5}, {18, -5}, {5, 18}, {5, -18}, {-5, 18}, {-5, -18}, {-18, 5}, {-18, -5}, {17, 8}, {17, -8}, {8, 17}, {8, -17}, {-8, 17}, {-8, -17}, {-17, 8}, {-17, -8}, {16, 10}, {16, -10}, {10, 16}, {10, -16}, {-10, 16}, {-10, -16}, {-16, 10}, {-16, -10}, {18, 6}, {18, -6}, {6, 18}, {6, -18}, {-6, 18}, {-6, -18}, {-18, 6}, {-18, -6}, {19, 0}, {0, 19}, {0, -19}, {-19, 0}, {19, 1}, {19, -1}, {1, 19}, {1, -19}, {-1, 19}, {-1, -19}, {-19, 1}, {-19, -1}, {19, 2}, {19, -2}, {14, 13}, {14, -13}, {13, 14}, {13, -14}, {2, 19}, {2, -19}, {-2, 19}, {-2, -19}, {-13, 14}, {-13, -14}, {-14, 13}, {-14, -13}, {-19, 2}, {-19, -2}, {15, 12}, {15, -12}, {12, 15}, {12, -15}, {-12, 15}, {-12, -15}, {-15, 12}, {-15, -12}, {19, 3}, {19, -3}, {17, 9}, {17, -9}, {9, 17}, {9, -17}, {3, 19}, {3, -19}, {-3, 19}, {-3, -19}, {-9, 17}, {-9, -17}, {-17, 9}, {-17, -9}, {-19, 3}, {-19, -3}, {18, 7}, {18, -7}, {7, 18}, {7, -18}, {-7, 18}, {-7, -18}, {-18, 7}, {-18, -7}, {19, 4}, {19, -4}, {16, 11}, {16, -11}, {11, 16}, {11, -16}, {4, 19}, {4, -19}, {-4, 19}, {-4, -19}, {-11, 16}, {-11, -16}, {-16, 11}, {-16, -11}, {-19, 4}, {-19, -4}, {19, 5}, {19, -5}, {5, 19}, {5, -19}, {-5, 19}, {-5, -19}, {-19, 5}, {-19, -5}, {18, 8}, {18, -8}, {8, 18}, {8, -18}, {-8, 18}, {-8, -18}, {-18, 8}, {-18, -8}, {17, 10}, {17, -10}, {10, 17}, {10, -17}, {-10, 17}, {-10, -17}, {-17, 10}, {-17, -10}, {14, 14}, {14, -14}, {-14, 14}, {-14, -14}, {15, 13}, {15, -13}, {13, 15}, {13, -15}, {-13, 15}, {-13, -15}, {-15, 13}, {-15, -13}, {19, 6}, {19, -6}, {6, 19}, {6, -19}, {-6, 19}, {-6, -19}, {-19, 6}, {-19, -6}, {20, 0}, {16, 12}, {16, -12}, {12, 16}, {12, -16}, {0, 20}, {0, -20}, {-12, 16}, {-12, -16}, {-16, 12}, {-16, -12}, {-20, 0}, {20, 1}, {20, -1}, {1, 20}, {1, -20}, {-1, 20}, {-1, -20}, {-20, 1}, {-20, -1}, {20, 2}, {20, -2}, {2, 20}, {2, -20}, {-2, 20}, {-2, -20}, {-20, 2}, {-20, -2}, {18, 9}, {18, -9}, {9, 18}, {9, -18}, {-9, 18}, {-9, -18}, {-18, 9}, {-18, -9}, {20, 3}, {20, -3}, {3, 20}, {3, -20}, {-3, 20}, {-3, -20}, {-20, 3}, {-20, -3}, {19, 7}, {19, -7}, {17, 11}, {17, -11}, {11, 17}, {11, -17}, {7, 19}, {7, -19}, {-7, 19}, {-7, -19}, {-11, 17}, {-11, -17}, {-17, 11}, {-17, -11}, {-19, 7}, {-19, -7}, {20, 4}, {20, -4}, {4, 20}, {4, -20}, {-4, 20}, {-4, -20}, {-20, 4}, {-20, -4}, {15, 14}, {15, -14}, {14, 15}, {14, -15}, {-14, 15}, {-14, -15}, {-15, 14}, {-15, -14}, {18, 10}, {18, -10}, {10, 18}, {10, -18}, {-10, 18}, {-10, -18}, {-18, 10}, {-18, -10}, {20, 5}, {20, -5}, {19, 8}, {19, -8}, {16, 13}, {16, -13}, {13, 16}, {13, -16}, {8, 19}, {8, -19}, {5, 20}, {5, -20}, {-5, 20}, {-5, -20}, {-8, 19}, {-8, -19}, {-13, 16}, {-13, -16}, {-16, 13}, {-16, -13}, {-19, 8}, {-19, -8}, {-20, 5}, {-20, -5}, {17, 12}, {17, -12}, {12, 17}, {12, -17}, {-12, 17}, {-12, -17}, {-17, 12}, {-17, -12}, {20, 6}, {20, -6}, {6, 20}, {6, -20}, {-6, 20}, {-6, -20}, {-20, 6}, {-20, -6}, {19, 9}, {19, -9}, {9, 19}, {9, -19}, {-9, 19}, {-9, -19}, {-19, 9}, {-19, -9}, {18, 11}, {18, -11}, {11, 18}, {11, -18}, {-11, 18}, {-11, -18}, {-18, 11}, {-18, -11}, {20, 7}, {20, -7}, {7, 20}, {7, -20}, {-7, 20}, {-7, -20}, {-20, 7}, {-20, -7}, {15, 15}, {15, -15}, {-15, 15}, {-15, -15}, {16, 14}, {16, -14}, {14, 16}, {14, -16}, {-14, 16}, {-14, -16}, {-16, 14}, {-16, -14}, {17, 13}, {17, -13}, {13, 17}, {13, -17}, {-13, 17}, {-13, -17}, {-17, 13}, {-17, -13}, {19, 10}, {19, -10}, {10, 19}, {10, -19}, {-10, 19}, {-10, -19}, {-19, 10}, {-19, -10}, {20, 8}, {20, -8}, {8, 20}, {8, -20}, {-8, 20}, {-8, -20}, {-20, 8}, {-20, -8}, {18, 12}, {18, -12}, {12, 18}, {12, -18}, {-12, 18}, {-12, -18}, {-18, 12}, {-18, -12}, {20, 9}, {20, -9}, {16, 15}, {16, -15}, {15, 16}, {15, -16}, {9, 20}, {9, -20}, {-9, 20}, {-9, -20}, {-15, 16}, {-15, -16}, {-16, 15}, {-16, -15}, {-20, 9}, {-20, -9}, {19, 11}, {19, -11}, {11, 19}, {11, -19}, {-11, 19}, {-11, -19}, {-19, 11}, {-19, -11}, {17, 14}, {17, -14}, {14, 17}, {14, -17}, {-14, 17}, {-14, -17}, {-17, 14}, {-17, -14}, {18, 13}, {18, -13}, {13, 18}, {13, -18}, {-13, 18}, {-13, -18}, {-18, 13}, {-18, -13}, {20, 10}, {20, -10}, {10, 20}, {10, -20}, {-10, 20}, {-10, -20}, {-20, 10}, {-20, -10}, {19, 12}, {19, -12}, {12, 19}, {12, -19}, {-12, 19}, {-12, -19}, {-19, 12}, {-19, -12}, {16, 16}, {16, -16}, {-16, 16}, {-16, -16}, {17, 15}, {17, -15}, {15, 17}, {15, -17}, {-15, 17}, {-15, -17}, {-17, 15}, {-17, -15}, {18, 14}, {18, -14}, {14, 18}, {14, -18}, {-14, 18}, {-14, -18}, {-18, 14}, {-18, -14}, {20, 11}, {20, -11}, {11, 20}, {11, -20}, {-11, 20}, {-11, -20}, {-20, 11}, {-20, -11}, {19, 13}, {19, -13}, {13, 19}, {13, -19}, {-13, 19}, {-13, -19}, {-19, 13}, {-19, -13}, {20, 12}, {20, -12}, {12, 20}, {12, -20}, {-12, 20}, {-12, -20}, {-20, 12}, {-20, -12}, {17, 16}, {17, -16}, {16, 17}, {16, -17}, {-16, 17}, {-16, -17}, {-17, 16}, {-17, -16}, {18, 15}, {18, -15}, {15, 18}, {15, -18}, {-15, 18}, {-15, -18}, {-18, 15}, {-18, -15}, {19, 14}, {19, -14}, {14, 19}, {14, -19}, {-14, 19}, {-14, -19}, {-19, 14}, {-19, -14}, {20, 13}, {20, -13}, {13, 20}, {13, -20}, {-13, 20}, {-13, -20}, {-20, 13}, {-20, -13}, {17, 17}, {17, -17}, {-17, 17}, {-17, -17}, {18, 16}, {18, -16}, {16, 18}, {16, -18}, {-16, 18}, {-16, -18}, {-18, 16}, {-18, -16}, {19, 15}, {19, -15}, {15, 19}, {15, -19}, {-15, 19}, {-15, -19}, {-19, 15}, {-19, -15}, {20, 14}, {20, -14}, {14, 20}, {14, -20}, {-14, 20}, {-14, -20}, {-20, 14}, {-20, -14}, {18, 17}, {18, -17}, {17, 18}, {17, -18}, {-17, 18}, {-17, -18}, {-18, 17}, {-18, -17}, {19, 16}, {19, -16}, {16, 19}, {16, -19}, {-16, 19}, {-16, -19}, {-19, 16}, {-19, -16}, {20, 15}, {20, -15}, {15, 20}, {15, -20}, {-15, 20}, {-15, -20}, {-20, 15}, {-20, -15}, {18, 18}, {18, -18}, {-18, 18}, {-18, -18}, {19, 17}, {19, -17}, {17, 19}, {17, -19}, {-17, 19}, {-17, -19}, {-19, 17}, {-19, -17}, {20, 16}, {20, -16}, {16, 20}, {16, -20}, {-16, 20}, {-16, -20}, {-20, 16}, {-20, -16}, {19, 18}, {19, -18}, {18, 19}, {18, -19}, {-18, 19}, {-18, -19}, {-19, 18}, {-19, -18}, {20, 17}, {20, -17}, {17, 20}, {17, -20}, {-17, 20}, {-17, -20}, {-20, 17}, {-20, -17}, {19, 19}, {19, -19}, {-19, 19}, {-19, -19}, {20, 18}, {20, -18}, {18, 20}, {18, -20}, {-18, 20}, {-18, -20}, {-20, 18}, {-20, -18}, {20, 19}, {20, -19}, {19, 20}, {19, -20}, {-19, 20}, {-19, -20}, {-20, 19}, {-20, -19}, {20, 20}, {20, -20}, {-20, 20}, {-20, -20}} return Public \ No newline at end of file diff --git a/maps/pirates/ores.lua b/maps/pirates/ores.lua index 8fecde6a..dc238a51 100644 --- a/maps/pirates/ores.lua +++ b/maps/pirates/ores.lua @@ -2,6 +2,7 @@ -- local Balance = require 'maps.pirates.balance' -- local Memory = require 'maps.pirates.memory' local Math = require 'maps.pirates.math' +local Raffle = require 'maps.pirates.raffle' local CoreData = require 'maps.pirates.coredata' local _inspect = require 'utils.inspect'.inspect local Common = require 'maps.pirates.common' @@ -38,7 +39,7 @@ function Public.try_ore_spawn(surface, realp, source_name, density_bonus) if Utils.length(choices_to_prioitise) > 0 then choice = choices_to_prioitise[Math.random(Utils.length(choices_to_prioitise))] else - choice = Math.raffle2(choices_possible) + choice = Raffle.raffle2(choices_possible) end local placed diff --git a/maps/pirates/progression.lua b/maps/pirates/progression.lua index cee44fa3..9eda9045 100644 --- a/maps/pirates/progression.lua +++ b/maps/pirates/progression.lua @@ -196,6 +196,31 @@ local place_dock_jetty_and_boats = Token.register( +function Public.choose_quest_structures(destination_data) + local subtype = destination_data.subtype + + --@TODO: Finish writing this function + --@Package 'quest structures' into their own folder + + local rng = Math.random(2) + + if rng == 1 or subtype == Surfaces.Island.enum.WALKWAYS then + --Avoid furnace type on movement-restricted islands (like walkways) + local covered2_requirement = Balance.generateCovered2EntryPrice() + + -- market + destination_data.dynamic_data.quest_structure_requirements = {} + destination_data.dynamic_data.quest_structure_requirements[] = covered2_requirement + else + + -- furnace + local covered2_requirement = Balance.generateCovered2EntryPrice() + destination_data.dynamic_data.covered2_requirement[] = covered2_requirement + end +end + + + function Public.progress_to_destination(destination_index) local memory = Memory.get_crew_memory() if memory.game_lost then return end @@ -215,8 +240,7 @@ function Public.progress_to_destination(destination_index) local initial_boatspeed, starting_boatposition if type == Surfaces.enum.ISLAND then --moved from overworld generation, so that it updates properly - local covered1_requirement = Balance.covered1_entry_price() - destination_data.dynamic_data.covered1_requirement = covered1_requirement + Public.choose_quest_structures(destination_data) end if type == Surfaces.enum.DOCK then diff --git a/maps/pirates/quest.lua b/maps/pirates/quest.lua index 90163acb..33db97ef 100644 --- a/maps/pirates/quest.lua +++ b/maps/pirates/quest.lua @@ -5,6 +5,7 @@ local Balance = require 'maps.pirates.balance' local Common = require 'maps.pirates.common' -- local Utils = require 'maps.pirates.utils_local' local Math = require 'maps.pirates.math' +local Raffle = require 'maps.pirates.raffle' -- local Loot = require 'maps.pirates.loot' local CoreData = require 'maps.pirates.coredata' local _inspect = require 'utils.inspect'.inspect @@ -331,7 +332,7 @@ function Public.generate_flow_quest() end end - return Math.raffle(v, w) + return Raffle.raffle(v, w) end @@ -398,7 +399,7 @@ function Public.generate_resourcecount_quest() end end - return Math.raffle(v, w) + return Raffle.raffle(v, w) end diff --git a/maps/pirates/raffle.lua b/maps/pirates/raffle.lua new file mode 100644 index 00000000..ba3ad7a7 --- /dev/null +++ b/maps/pirates/raffle.lua @@ -0,0 +1,98 @@ +local Math = require 'maps.pirates.math' + +local Public = {} + +function Public.raffle(values, weights) --arguments of the form {[a] = A, [b] = B, ...} and {[a] = a_weight, [b] = b_weight, ...} or just {a,b,c,...} and {1,2,3...} + + local total_weight = 0 + for k,w in pairs(weights) do + assert(values[k]) + if w > 0 then + total_weight = total_weight + w + end + -- negative weights treated as zero + end + if (not (total_weight > 0)) then return nil end + + local cumulative_probability = 0 + local rng = Math.random() + for k,v in pairs(values) do + assert(weights[k]) + cumulative_probability = cumulative_probability + (weights[k] / total_weight) + if rng <= cumulative_probability then + return v + end + end +end + +function Public.raffle2(table) --arguments of the form {v1 = w1, v2 = w2, ...} + + local total_weight = 0 + for k,w in pairs(table) do + if w > 0 then + total_weight = total_weight + w + end + -- negative weights treated as zero + end + if (not (total_weight > 0)) then return nil end + + local cumulative_probability = 0 + local rng = Math.random() + for k,v in pairs(table) do + cumulative_probability = cumulative_probability + v/total_weight + if rng <= cumulative_probability then + return k + end + end +end + + +function Public.LambdaRaffle(data, lambda, extraConditionParameter) +-- example_argument = { +-- ['iron-stick'] = { +-- overallWeight = 1, +-- minLambda = 0, +-- maxLambda = 1, +-- shape = 'uniform', +-- condition = function(x) return x == 'ironIsland' end, +-- }, +-- } + local raffle = {} + + for k, v in pairs(data) do + if (not v.shape) or (v.shape == 'uniform' or v.shape == 'flat') then + if (not v.minLambda) or (lambda >= v.minLambda) then + if (not v.maxLambda) or (lambda <= v.maxLambda) then + if (not v.condition) or (extraConditionParameter and v.condition(extraConditionParameter)) then + raffle[k] = v.overallWeight + end + end + end + elseif (v.shape == 'density') then + if v.minLambda and v.maxLambda and v.maxLambda ~= v.minLambda and lambda >= v.minLambda and lambda <= v.maxLambda then + if (not v.condition) or (extraConditionParameter and v.condition(extraConditionParameter)) then + raffle[k] = v.overallWeight / (v.maxLambda - v.minLambda) + end + end + elseif (v.shape == 'bump') then + if v.minLambda and v.maxLambda and lambda >= v.minLambda and lambda <= v.maxLambda then + if (not v.condition) or (extraConditionParameter and v.condition(extraConditionParameter)) then + if v.minLambda == v.maxLambda and lambda == v.minLambda then + raffle[k] = v.overallWeight + else + local midpoint = (v.minLambda + v.maxLambda) / 2 + local peak = 2 * v.overallWeight + local slope = peak / ((v.maxLambda - v.minLambda) / 2) + local difference = Math.abs(lambda - midpoint) + raffle[k] = peak * (1 - difference * slope) + end + end + end + end + end + + return Public.raffle2(raffle) +end + + +return Public \ No newline at end of file diff --git a/maps/pirates/structures/island_structures/roc/data.lua b/maps/pirates/structures/island_structures/roc/data.lua index a6e3d7a3..0f718d9c 100644 --- a/maps/pirates/structures/island_structures/roc/data.lua +++ b/maps/pirates/structures/island_structures/roc/data.lua @@ -48,7 +48,6 @@ Public.shelter2 = { }, } - Public.lonely_storage_tank = { name = 'lonely_storage_tank', width = 4, @@ -150,6 +149,241 @@ Public.covered1b.wooden_chests = { } + +Public.covered2 = { + name = 'covered2', + width = 17, + height = 15, + components = { + --for some reason tile blueprints need to be offset... + { + type = 'tiles', + tile_name = 'orange-refined-concrete', + offset = {x = -9, y = -8}, + bp_string = [[0eNqVmMGKwjAURf8l6wreJG2S/srgwtEgAW1L7Qwj0n8fqy5m4YBnJcKxHrxc7sOr+Tx+5WEs3WTaqzl322E19avDWPbL+x/TKlXmcnsJc2XKru/Opv24geXQbY8LMl2GbFpTpnwylem2p+XdjduNecpm+VC3z8tz5k1lpnLMjwcM/blMpe+e37K+f8l6fvWEf2AR2BLYEdgTuCZwQ+BA4EjghEJhEaIMhUIUSlEoRqEc9WaQIh0Q6YBIB0Q6INIBkQ6IdECkAyIdEOmAUAeEOiDUAaEOCHVAqANCHbCkA5Z0wCJri6wdsXbE2iFrh6w9sfbE2iNrj6xrYl0T6xpZ18i6IdYNsW6QdYOsA7EOxDog64CsI7GOxDoi64isE7FOxDoh68RuFnS4C13uYseW4LXFzi12b8GJZBspNJJCKyk2k2I7KTSUQkspNpViWyk0lkJrKTaXYnspNJhCiyk2mWKbKTSaQqspNptiuyk0nELL+aQtoh2iPaJrRLNfMCA6IjqxdGCYLE2xOMXyFAtULNG3S4HuMqHD7ElbRDtEe0TXiGa/YEB0RHRi6cAwWZpicYrlKRaoWKKvS7GpHv+Tt3/+da/Mdx7P9wfYKB+SDd41Ptk4z7+pVIVy]], + }, + { + type = 'tiles', + tile_name = 'green-refined-concrete', + offset = {x = -4, y = 2}, + bp_string = [[0eNqV1NEKgjAUxvF3OdcLnO6k7lWiC9MhA52iKxLZuzeti6CCvsvBb+fwv9hWunRXM07WedIrza4aD344tJNttvOddCloIc1BkK0HN5M+RWZbV3Ub8MtoSJP1pidBruq3U3T1ZLyh7ZJrTJwiw1mQt515DhiH2Xo7uNeOZN+hwrcJH1giOEVwtuMEwRLBKYIzBP8ZqJBAhQQqJFAhgQoJZCSQkUBGAhkJZCTwiOAcwcVvHJ/u/sD122ch6Gameb+eFlLlZZqzkhknHMIDrYdkGw==]], + }, + { + type = 'tiles', + tile_name = 'out-of-map', + offset = {x = -7, y = -6}, + bp_string = [[0eNqd2c1qwkAYheF7mXUKnpn55ie3UrqwGiSgUTQtLZJ7r9EWurDg21URvqZw8mz6enav27fucOyH0bVndxqWh6dx/7Q59uv584drZY37vPwIU+P61X44ufb5cthvhuV2Phk/D51rXT92O9e4YbmbP13uVsdu7Nz8S8O6m58zvTRu7Lfd7QGH/akf+/3w/VcW1z+ymO494Y9jkWNPjgM5juTYyHEix5kcF3Jc0UthrxC9Qz34EkUsiVgSsSRiScSSiCURSyKWRCyJWBKyJGRJyJInljyx5IklTyx5YskTS55Y8sSSJ5Y8seSRJY8seWQpEEuBWArEUiCWArEUiKVALAViKRBLgVgKyFJAlgKyFImlSCxFYikSS5FYisRSJJYisRSJpUgsRWQpIktGdBjRYUSHER1GdBjRYUSHER1GdBjRYUiHIR2J6EhERyI6EtGRiI5EdCSiIxEdmeycyc6Z7JzJzpnsnMnOmeycyc6F7FzIzoXsXMjOhexcyM6F7FzIzpXsXMnOlexcyc6V7FzJzpXsXPnOhRxX9FLYK3z0/2qU8IQanlDEE6p4QhlPqOMJhTyhkieU8oRanljME6t5YoGOFTqW6FijY5GOVTqW6VinY6GOlTqY6vQfKQ+HX1TrhHKdUK8TCnZCxU4o2Qk1O6FoJ1TthLKdWLcTC3di5U4o3Qm1O6F4J1TvhPKdUL8TCnhCBU8o4Qk1PLGIJ1bxxDKeUMcTCnlCJU8o5Qm1PKGYJ1TzhHKeUM8TCnpiRU8s6f2c332dL83t+/f217f5jXvvjqfrA3xRzNVniwq2sGn6ArBHNd4=]], + }, + --this needs to appear last, so that the walls connect properly + { + type = 'static', + force = 'environment', + offset = {x = 0, y = 0}, + bp_string = [[0eNqlmNFuqzAMht8l1zBhQkjCq0zVEV2jCokGBGFbNfXdD7TaTnVWE5teVajw5Xfi38Z8iX07uX5ofBDVlxh93aehS49Dc1iuP0UFOhHn+UddEtG8dX4U1et8Y3P0dbvcEs69E5VogjuJRPj6tFyNofMu/ajbViyP+YNbSJck+qD77Ac3jmnb1Qc33D2cX3aJcD40oXE3CdeL8x8/nfbznRU8WjwRfTfOj3T+O5oXdQ0ne1GXRc5/kJwEydYhkgSR65CCBMnXIYoEUeuQkgQp1iH61wlP87kOx6Gbf9O9a8NvpL5DJt/p0k2hn4J4sIQh6SzXddoNOg1PJ2Qb1rDMNYhuiGQy0PwAEVcBzREQsQTQPAERUwDNFRCxBdB8ARFjgKZhInkLhlW5coRiWRRAimjGCwkRkwMPg6nh1XSDUCSLohFKwQsJE6N4GExNyTttrGdqFsYiFIO9A6B9AYBSCnP7ROux9+W28cgSMiNrNyztEshgywPnT/Qg4qbIJ1opcQmmnbAMlkw/ISksmX5C6p7k+QmQuicNc3MwOZbJQfQUGesFfembDzHA2x0Ms8UAP1B5Tc9DM7i32995PFkL3liACucNBihGbYhfEeLHa05RsqYRVLlmzSMohtFvnjh0mnl0RKzKWLMNiqG3k2VIeRh0GQ9a0d64bEwtzTAmhik2ZPrPRLO2AXiqK8Wbm1DtJW+MQzmaN4ChHMObwFCO5Y1gGKfMeDMYyuGOGhhnS1f5R42bbZfcvpdVd5/tEvHuhvFWkQwU2uZaFSBVNkv8C+RQcGE=]], + }, + }, +} + +Public.covered2.red_chests = { + {x = -1, y = 5}, + {x = 0, y = 5}, + {x = 1, y = 5}, +} +Public.covered2.blue_chest = {x = 0, y = 6} +Public.covered2.walls = { + {x = -8, y = -4}, + {x = -8, y = -3}, + {x = -8, y = -2}, + {x = -8, y = -1}, + {x = 8, y = -4}, + {x = 8, y = -3}, + {x = 8, y = -2}, + {x = 8, y = -1}, +} + +Public.covered2b = { + name = 'covered2b', + width = 17, + height = 15, + doNotDestroyExistingEntities = true, + components = { + { + type = 'tiles', + tile_name = 'orange-refined-concrete', + offset = {x = -7, y = -6}, + bp_string = [[0eNqV2M1qg0AYheF7+dYGcubHUW+ldJEmQxhIVIwtDcF7b0y76KItfZfCcYRn9To3ezm95nEq/WzdzS79btzMw+Y4lcP6/G6dYmVX6+qlsrIf+ot1T/ddOfa707qYr2O2zsqcz1ZZvzuvT/fdfspztvWl/pDXY5bnyuZyyp8HjMOlzGXovz6yfXxju/x0wi9jkbEjY0/GgYzj/8YiGiIaIhoiGiIaIhqOaDii4YiGIxqOaDii4YmGJxqeaHii4YmGJxqBaASiEYhGIBqBaASiEYlGJBqRaESiEYlGJBo10aiJRk00aqJRE42aaCSikYhGIhqJaCSikYhGQzQaotEQjYZoNESjIRot0WiJRks0WqLREo0W1ReKUaEaFcpRoR4VClKxImVJypqURSmrUpalqEuFwlSoTIXSVKhNheJUqE6F8lSoT4UCVahQhRJVqFGFIlWoUoUyVahThUJVf5Tq/c//cT/QfbtsqOwtT5fH+65RSK1LMcjHbVyWD41XTnY=]], + }, + { + type = 'static', + force = 'ancient-friendly', + offset = {x = 0, y = -6}, + bp_string = [[0eNqN01GLgzAMAOD/kuc6rNqp/SvHOPQWRkFTsd3tZPjf1+o9DO6oeQqB5CO0yRP64Y7TbMiDfoKjbsq8zW6zucb8B7RUApYQVgHmy5ID/RHqzI26IVb4ZULQYDyOIIC6MWbOW8Ls0Q0DxDa6YoTWiwAkb7zBXdmS5ZPuY49zKPivX8BkXWix9DtPftoHCnFdxR+kYCEyjZQs5JxGKhai0ohiIU0aObOQOo3UvIc9+J6GpbRppOWNUqQVmfOYg12RvLWV5QHDXNzqnQkHtR2efrtiAd84u62jaGRVt0WtKlmqPNS/ABFaQ/0=]], + }, + }, +} + +Public.covered2b.market = {x = -4, y = -5} +Public.covered2b.wooden_chests = { + {x = -7, y = -5}, + {x = -6, y = -5}, + {x = 6, y = -5}, + {x = 7, y = -5}, +} + + + + + + + +Public.v2_covered_market = { + name = 'v2_covered_market', + width = 15, + height = 18, + components = { + { + type = 'tiles', + tile_name = 'orange-refined-concrete', + offset = {x = -8, y = -9}, + bp_string = [[0eNqVmc1Kw0AYRd9l1hHmfvOfVxEX1QYJ1LS0URTJu9u0Llyo9KxK4DaBe3oDZ/rpHnevw+E4TrPrP91p2hzu5v3d83Hcrtfvrlfq3Mf5oy6dG5/208n19+fg+Dxtdmtk/jgMrnfjPLy4zk2bl/XqnHs6DvPg1i9N22G9z/LQuXncDdcbHPancR730/dT/OUhtvx2hz/CSreldUl7EhYJGwkHEo4kjNrIJFxIuJJwQ1AYQsRQCKIQRSGM7FctBFI3kjSyGCOLMbIYI4sxshgjizGyGCOLMbIYI4sxtBhDizG0GEOLMbQYQ4sxtBhDiwlkMYEsJpDFBLKYgMgERCYgMgGRCYhMJGQiIRMJmUjIRNReRO1F1F4i7SXSXiLtJdJeQu0l1F5C7WXSXibtZdJeJu1l1F5G7WXUXiHtFdJeIe0V0l5B79SC3qkFkSmITEFkKiFTCZlKyFRCpiIyFZGpiExFZCoi0wiZRsg01F9D/TXUX0P9NdSfPDos8Oi0wDN59Mwe4aGIZ/7oWY3szIUdukAHhxIOLRxqOPNwIREXMnEhFRdycSEZF7JxIR0X8nEhIRcycjElF3NyMSkXs3IxLRfzcjExFzNzITUXcnMhORey8+90ROmE0hmlWd8VpRujA2EymmI4xXiKARUjKob05g39dyDx0F3/++l//JPUubfheLrcwKpiaVZSVEg+LcsXIxltDQ==]], + }, + { + type = 'tiles', + tile_name = 'out-of-map', + offset = {x = -6, y = -7}, + bp_string = [[0eNqd2D1uwkAQQOG7TG0kZn+Yta8SURBYoZXAtmwnCkK+ezCkSJFEvJQrvZkpvm6v8np6y/1Q2kmaq4ztrl9N3eo4lMPy/pCmruQijfq5krLv2lGal1tXju3utBTTpc/SSJnyWSppd+fldev2Q56yLEPtId/W6LytZCqn/FjQd2OZStd+HVnfj7j5pw2/xJ7EgcSRxBsSG4kTiWsS6/q5WomKEhUlKkpUlKgoUVGiokRF/6GiiuonER0Rd0TcEXFHxB0Rd0TcEXFHxB0Sd0jcIXFPxD0R90TcE3FPxD0R90TcE3GPxD0S90g8EPFAxAMRD0Q8EPFAxAMRD0Q8IPFIVCJRiUQlEpVIVCJRiUQlEpWIVDb3GsVKYkdiT+JA4kjiDYmNxInENUJ5ktCItxFvI95GvI14G/E24m3E24i3EW9D3ol4J+KdiHci3ol4J+KdiHci3ol4J+Kd/vDeVo9/iebbJ0cl73kY7/MuabDaWQzq4zrO8yeeGHe9]], + }, + { + type = 'static', + force = 'environment', + offset = {x = 0, y = 0}, + bp_string = [[0eNqlmN2OmzAQhd/F16TCfxjyKtWqIhsrQiIGgdNutMq7F5JW3So5xIdcIRTzzbEzczz2p9i1J98PTYhi+ynGUPeb2G0OQ7Of3z/EVspMnKdHcclE896FUWy/TwObQ6jbeUg8915sRRP9UWQi1Mf5bYxd8JtfdduK+bOw9zPp8pYJH2ITG3+jXF/OP8LpuPPDNODR95nou3H6pAt/BOXf7FXR9LxcsjuISoLIZYhOgqhliEmC6GWITYKYZUiRBLHLEJcEKZYhZRLELUOqJEi5DJF5EqV6QknLWfkkaaWiUl8BiqZyH1EMRZGA8i9x/Uc/+HHcnCYbGA5DNz03O99GPL+ZmYl9M/j326/T8vz1mdCfongUsKBqFk3eUUWLKOWKyavnk+9OEc2+uovYdvUU8oFXPI5SJERROWUkYHWUpDwNURTlRyBNlaYoSIvhXABhLIdBcyooM9GA4jgxCFNSYkpAqSiKA7t6zk0JiNGk5yM1nOdL1KpoClMBCpnBUA2ZwkgOl8ISFJR2HAYUlC65HRGpuffoONRh7Lshgj3BfkX+vyk8ajhzOoDjAkg6QMEFUHSA8smqG031eRDDFgjisB4PctIUXE4agHGvtGlmRZ9myGIC+4rhdgSEsfkrnZpZ06pZybZqa5bZqvVmg9ZKJwt3QHiRINys+EfKVzLSWs4hQCnZgsOgVV5TkTJ/LSVL0pSQ9oqrbQuuK3KuthFGUmc5iFHUwRJiNHV2ghhDHZ4gxlIXMRBTcIcwhHHUjQ7ElFwFIkxFVsOV85bd7kC3X25UM/HTD+OtDEtpXKWcNVLbfBr/G8eu84M=]], + }, + }, +} + +Public.v2_covered_market.red_chest = {x = 0, y = -6} +Public.v2_covered_market.blue_chest = {x = 0, y = 6} +Public.v2_covered_market.walls = { + {x = -8, y = -5}, + {x = -8, y = -4}, + {x = -8, y = -3}, + {x = 8, y = -5}, + {x = 8, y = -4}, + {x = 8, y = -3}, +} + +Public.v2_covered_market_b = { + name = 'v2_covered_market_b', + width = 17, + height = 15, + components = { + { + type = 'tiles', + tile_name = 'orange-refined-concrete', + offset = {x = -7, y = -6}, + bp_string = [[0eNqd2D1uwkAQQOG7TG0kZn+Yta8SURBYoZXAtmwnCkK+ezCkSJFEvJQrvZkpvm6v8np6y/1Q2kmaq4ztrl9N3eo4lMPy/pCmruQijfq5krLv2lGal1tXju3utBTTpc/SSJnyWSppd+fldev2Q56yLEPtId/W6LytZCqn/FjQd2OZStd+HVnfj7j5pw2/xJ7EgcSRxBsSG4kTiWsS6/q5WomKEhUlKkpUlKgoUVGiokRF/6GiiuonER0Rd0TcEXFHxB0Rd0TcEXFHxB0Sd0jcIXFPxD0R90TcE3FPxD0R90TcE3GPxD0S90g8EPFAxAMRD0Q8EPFAxAMRD0Q8IPFIVCJRiUQlEpVIVCJRiUQlEpWIVDb3GsVKYkdiT+JA4kjiDYmNxInENUJ5ktCItxFvI95GvI14G/E24m3E24i3EW9D3ol4J+KdiHci3ol4J+KdiHci3ol4J+Kd/vDeVo9/iebbJ0cl73kY7/MuabDaWQzq4zrO8yeeGHe9]], + }, + { + type = 'static', + force = 'ancient-friendly', + offset = {x = 0, y = 0}, + bp_string = [[0eNqdkd0KgzAMhd8l11X8xa2vMsbwJ0hB09LGoYjvvlZ3MdjYhVfhkJMvh2SFZpjQWEUMcgVHtYlYR71VXdAzyFTAAjLfBKhWkwN58zbVUz0EAy8GQYJiHEEA1WNQOBuLzkVsa3JGW44aHBgCgjoMzO0uAIkVKzyIu1geNI0N2n3pf5YAo50f1/SOmcTlHjSNy20TX8DsNNBXH7xTFtujm/3A56fxWcjrr7FfUH58Q8ATrTs2XtKiumZVWaR5mXj/CzxjkfE=]], + }, + }, +} + +Public.v2_covered_market_b.market = {x = 3, y = -5} +Public.v2_covered_market_b.steel_chest = {x = 4, y = 2} +Public.v2_covered_market_b.wooden_chests = { + {x = 0, y = -3}, + {x = -4, y = 3}, + {x = -4, y = 4}, +} + + + +Public.v2_covered_furnace = { + name = 'v2_covered_furnace', + width = 14, + height = 15, + components = { + --for some reason tile blueprints need to be offset... + { + type = 'tiles', + tile_name = 'orange-refined-concrete', + offset = {x = -7, y = -8}, + bp_string = [[0eNqVmM1qwkAYRd9l1ink+5n8vUpxYXWQAU1CTEtF8u412kUXbfGsQuB4E7gH7phreDu+p3HK/Ry6azj32/FlHl4OU96v95+hEy/C5XaJSxHybujPoXu9gfnQb48rMl/GFLqQ53QKRei3p/Xuxu2mNKew/qjfpzVn2RRhzsf0CBiHc57z0H8/pXw8ZPkt4Q9YCWwEdgJHAlcErgncELglsJSIRh0KKlGebFHudElgIbASGL2zEzgSuCJwTeCGwC0qhVWIOhRUIjNPnqxRiadKPFXiqRJPlXiqxFMlnirxVImnSjxV5KkiTxV5qshTRZ4a8dSIp0Y8NeKpEU+NeGrEUyOeGvHUiKeGPDXkqSFPDXlqyFMn6jlRz4l6TtRzop6Tzh117qhzR5076jySFiOKrkh0haJrEl2j6IZENyi6JdEtOwqhv3QCT/js1A4PceioJWx5Be2joIEUtJCCJlLQRgoaSUErKWgmBe2ksKEUtpTCplL+28pN8fjk0v34gFOEjzSd7wHaiNet1tHFYhmX5QubhLg2]], + }, + { + type = 'tiles', + tile_name = 'out-of-map', + offset = {x = -5, y = -6}, + bp_string = [[0eNqV2EFuwjAQQNG7zDpIxJ6xTa5SsaBgIUuQREmoilDuXgJddNFW/KWl77Hkt5ubvJ8uuR9KO0lzk7Hd9aupWx2HcljOn9JsKrlKU9dzJWXftaM0b/euHNvdaSmma5+lkTLls1TS7s7L6d7thzxlWS61h3wfU8/bSqZyys8BfTeWqXTt9yPrxyM6/zbhj9hIHF6L60e8JnFNYkdiT2IlsZEYfV0kcSLxBqG8SOiItyPejng74u2ItyPejng74u2ItyPeDnl74u2Jtyfennh74u2Jtyfennh74u2Jt0feSryVeCvxVuKtxFuJtxJvJd5KvJV4K/I24m3E24i3EW8j3ka8jXgb8TbibcTbkHcg3oF4B+IdiHcg3oF4B+IdiHcg3oF4B+QdiXck3pF4R+IdiXck3pF4R+IdiXck3hF5J+KdiHci3ol4J+KdiHci3ol4J+KdiHf6x3tbPdcGzY8dRCUfeRgf912qNW5cNK29rW2evwC3J1mB]], + }, + --this needs to appear last, so that the walls connect properly + { + type = 'static', + force = 'environment', + offset = {x = 0, y = 0}, + bp_string = [[0eNqlmNtuozAURf/Fz1DhG7dfGVUjkngiJGoQmJlGVf59oOlDNJMdvMsTQsLrXNjn2Mcf4tDNbhhbH0T9ISbfDGno0/PYntb3d1FLk4jL8rDXRLTH3k+i/rF82J59062fhMvgRC3a4N5EInzztr5Nofcu/dN0nViX+ZNbSddkc6F7H0Y3TWnXNyc33i1W19dEOB/a0LqbC58vl59+fjssX9bykfFEDP20LOn9VzTZi72F82Kvqzv/QFQURD6H6P+imZcYxvPYL8/04LqAkYt/S8xfqennMMxBPDBhovxUz/20URD9HJJ/I1jNBVt8w4TiTJRRqTDPU1FFQexziMyiKPkGJa4aig1KXDmUGxQdV1QbapVxmpcbepUW9RpYkyZGQTKn+o8G3hU7eoe613rrkaMl5agCjlbRadRMGlUWzVUUV+7oU3GJVWpHn4o0oak+BUSmDEUBClCWq0eEyTkMiqmgVG0AhasNCygVlV9A0RlFARFpyaUXYRSHQTHdHY06dwxje0x/zaNvjg6XRgFYhvpXOaBYioJ8IUWMnCk4DPKGU3EJKBVFqR5TDKdiRCFVDEIypIqRN5o+QkgZ0d0Np2iZAfc4SUtwUDI5vcPHRVnQO3wclzzDo7C55o1+gs3I0yrikMpHYVnFiQLs1nbPbCtV3DBmyToARwJruWEeYfZMuNEh75lxo42U3K0BSkjF3RsATM7tDBAjuakbYRTnDaiPXHPTO/LGcOM7wlhufkeYnBzgEYc83kBOSXLQz6r2NDMTNbEV2Z7uEWlD7mkej2y8Jrdr2frudjgRv904fQJUKU1RqcIaqW225PYv7EY6nw==]], + }, + }, +} + +Public.v2_covered_furnace.red_chests = { + {x = -4, y = 2}, + {x = -3, y = 2}, + {x = -2, y = 2}, +} +Public.v2_covered_furnace.blue_chests = { + {x = -4, y = -2}, + {x = -3, y = -2}, + {x = -2, y = -2}, +} +Public.v2_covered_furnace.walls = { + {x = 3, y = -6}, + {x = 4, y = -6}, + {x = 5, y = -6}, + {x = 3, y = 6}, + {x = 4, y = 6}, + {x = 5, y = 6}, +} + +Public.v2_covered_furnace_b = { + name = 'v2_covered_furnace_b', + width = 17, + height = 15, + doNotDestroyExistingEntities = true, + components = { + { + type = 'tiles', + tile_name = 'orange-refined-concrete', + offset = {x = -7, y = -6}, + bp_string = [[0eNqV2M1qg0AYheF7+dYGcubHUW+ldJEmQxhIVIwtDcF7b0y76KItfZfCcYRn9To3ezm95nEq/WzdzS79btzMw+Y4lcP6/G6dYmVX6+qlsrIf+ot1T/ddOfa707qYr2O2zsqcz1ZZvzuvT/fdfspztvWl/pDXY5bnyuZyyp8HjMOlzGXovz6yfXxju/x0wi9jkbEjY0/GgYzj/8YiGiIaIhoiGiIaIhqOaDii4YiGIxqOaDii4YmGJxqeaHii4YmGJxqBaASiEYhGIBqBaASiEYlGJBqRaESiEYlGJBo10aiJRk00aqJRE42aaCSikYhGIhqJaCSikYhGQzQaotEQjYZoNESjIRot0WiJRks0WqLREo0W1ReKUaEaFcpRoR4VClKxImVJypqURSmrUpalqEuFwlSoTIXSVKhNheJUqE6F8lSoT4UCVahQhRJVqFGFIlWoUoUyVahThUJVf5Tq/c//cT/QfbtsqOwtT5fH+65RSK1LMcjHbVyWD41XTnY=]], + }, + { + type = 'static', + force = 'ancient-friendly', + offset = {x = 0, y = 0}, + bp_string = [[0eNqV01FvgyAQAOD/cs+4COpU/krTLNZeOxI9DGAz0/jfh2wPTYZdeSKX3H054O4Op2HGyShyIO9gqZsyp7OrUect/gJZMFhAcr4yUL0mC/Lg89SVumHLcMuEIEE5HIEBdeMWWYc4ZP0nWgdbHZ3RS3w9MkByyin8YUKwfNA8ntD4hCjAYNLW12j67Sh/q0JP/lxX9kcRaQqPK8VrCn+ulGnKzo2qB0UTZpfZUNdjxAlKETPe016ljndSpylNXGnSlDautGlvu6PwPHFcdv6Ivzi84j9HJA5ecPxihQ2UD+vM4IbGhgrR8LJuRV2VvKhyn/8NRt5ISg==]], + }, + }, +} + +Public.v2_covered_furnace_b.market = {x = 4, y = 0} +Public.v2_covered_furnace_b.wooden_chests = { + {x = 5, y = -5}, + {x = 5, y = -4}, + {x = 5, y = 4}, + {x = 5, y = 5}, +} + + + + + + Public.maze_defended_camp = { name = 'maze_defended_camp', width = 20, diff --git a/maps/pirates/structures/island_structures/roc/roc.lua b/maps/pirates/structures/island_structures/roc/roc.lua index 2de0f8c2..3d147821 100644 --- a/maps/pirates/structures/island_structures/roc/roc.lua +++ b/maps/pirates/structures/island_structures/roc/roc.lua @@ -6,10 +6,24 @@ Public.shelter1 = {} Public.shelter1.Data = Data.shelter1 Public.shelter2 = {} Public.shelter2.Data = Data.shelter2 + Public.covered1 = {} Public.covered1.Data = Data.covered1 Public.covered1b = {} Public.covered1b.Data = Data.covered1b +Public.covered2 = {} +Public.covered2.Data = Data.covered2 +Public.covered2b = {} +Public.covered2b.Data = Data.covered2b +Public.v2_covered_market = {} +Public.v2_covered_market.Data = Data.v2_covered_market +Public.v2_covered_market_b = {} +Public.v2_covered_market_b.Data = Data.v2_covered_market_b +Public.v2_covered_furnace = {} +Public.v2_covered_furnace.Data = Data.v2_covered_furnace +Public.v2_covered_furnace_b = {} +Public.v2_covered_furnace_b.Data = Data.v2_covered_furnace_b + Public.lonely_storage_tank = {} Public.lonely_storage_tank.Data = Data.lonely_storage_tank Public.swamp_lonely_storage_tank = {} diff --git a/maps/pirates/surfaces/islands/islands.lua b/maps/pirates/surfaces/islands/islands.lua index a852409e..0f21cbef 100644 --- a/maps/pirates/surfaces/islands/islands.lua +++ b/maps/pirates/surfaces/islands/islands.lua @@ -142,18 +142,22 @@ function Public.spawn_covered(destination, points_to_avoid) for i = 1, 1 do p = Hunt.mid_farness_position_1(args, points_to_avoid) - local structureData = Structures.IslandStructures.ROC.covered1.Data - local special = { - position = p, - components = structureData.components, - width = structureData.width, - height = structureData.height, - name = structureData.name, - } - if not destination.dynamic_data.structures_waiting_to_be_placed then - destination.dynamic_data.structures_waiting_to_be_placed = {} - end - destination.dynamic_data.structures_waiting_to_be_placed[#destination.dynamic_data.structures_waiting_to_be_placed + 1] = {data = special, tick = game.tick} + --@TODO: Figure out what to do about these two kinds of structure + local which = 'covered2' + + if which == 'covered1' then + local structureData = Structures.IslandStructures.ROC.covered1.Data + local special = { + position = p, + components = structureData.components, + width = structureData.width, + height = structureData.height, + name = structureData.name, + } + if not destination.dynamic_data.structures_waiting_to_be_placed then + destination.dynamic_data.structures_waiting_to_be_placed = {} + end + destination.dynamic_data.structures_waiting_to_be_placed[#destination.dynamic_data.structures_waiting_to_be_placed + 1] = {data = special, tick = game.tick} local requirement = destination.dynamic_data.covered1_requirement.price @@ -174,6 +178,7 @@ function Public.spawn_covered(destination, points_to_avoid) } destination.dynamic_data.covered_data = { + structure_type = structureData.name, position = p, state = 'covered', requirement = requirement, @@ -181,6 +186,50 @@ function Public.spawn_covered(destination, points_to_avoid) rendering2 = rendering2, } + elseif which == 'covered2' then + + local structureData = Structures.IslandStructures.ROC.covered2.Data + local special = { + position = p, + components = structureData.components, + width = structureData.width, + height = structureData.height, + name = structureData.name, + } + if not destination.dynamic_data.structures_waiting_to_be_placed then + destination.dynamic_data.structures_waiting_to_be_placed = {} + end + destination.dynamic_data.structures_waiting_to_be_placed[#destination.dynamic_data.structures_waiting_to_be_placed + 1] = {data = special, tick = game.tick} + + local requirement = destination.dynamic_data.covered2_requirement + + local rendering1 = rendering.draw_text{ + surface = surface, + target = {x = p.x + 2, y = p.y + 6.85}, + color = CoreData.colors.renderingtext_green, + scale = 1.5, + font = 'default-game', + alignment = 'right', + } + local rendering2 = rendering.draw_sprite{ + sprite = 'item/' .. requirement.name, + surface = surface, + target = {x = p.x + 2.85, y = p.y + 7.5}, + x_scale = 1.5, + y_scale = 1.5 + } + + destination.dynamic_data.covered_data = { + structure_type = structureData.name, + position = p, + state = 'covered', + rendering1 = rendering1, + rendering2 = rendering2, + requirement = requirement, + completion_counter = 0, + } + end + log('covered market position: ' .. p.x .. ', ' .. p.y) end diff --git a/maps/pirates/surfaces/islands/maze/maze.lua b/maps/pirates/surfaces/islands/maze/maze.lua index 222c23d6..b783ec7c 100644 --- a/maps/pirates/surfaces/islands/maze/maze.lua +++ b/maps/pirates/surfaces/islands/maze/maze.lua @@ -1,6 +1,7 @@ -- local Memory = require 'maps.pirates.memory' local Math = require 'maps.pirates.math' +local Raffle = require 'maps.pirates.raffle' -- local Balance = require 'maps.pirates.balance' local Structures = require 'maps.pirates.structures.structures' -- local Common = require 'maps.pirates.common' @@ -161,7 +162,7 @@ local function free_labyrinth_cell_type(args) end if not type then - type = Math.raffle2(free_labyrinth_cell_raffle) + type = Raffle.raffle2(free_labyrinth_cell_raffle) cell_types[tostring(reduced_p.x) .. '_' .. tostring(reduced_p.y)] = type end diff --git a/maps/pirates/surfaces/surfaces.lua b/maps/pirates/surfaces/surfaces.lua index 1d84dbca..ef5a3dc5 100644 --- a/maps/pirates/surfaces/surfaces.lua +++ b/maps/pirates/surfaces/surfaces.lua @@ -340,7 +340,7 @@ function Public.destination_on_arrival(destination) Islands.spawn_ores_on_arrival(destination, points_to_avoid) - if memory.overworldx >= Balance.covered_first_appears_at and destination.subtype ~= Islands.enum.RADIOACTIVE then + if (memory.overworldx >= Balance.covered_first_appears_at and destination.subtype ~= Islands.enum.RADIOACTIVE) or _DEBUG then local class_for_sale = Classes.generate_class_for_sale() destination.static_params.class_for_sale = class_for_sale diff --git a/maps/pirates/tick_functions.lua b/maps/pirates/tick_functions.lua index fd138515..ad68fc62 100644 --- a/maps/pirates/tick_functions.lua +++ b/maps/pirates/tick_functions.lua @@ -691,6 +691,114 @@ function Public.place_cached_structures(tickinterval) end covered_data.wooden_chests[#covered_data.wooden_chests + 1] = e end + + elseif special.name == 'covered2' then + local covered_data = destination.dynamic_data.covered_data + if not covered_data then return end + + local hardcoded_data = Structures.IslandStructures.ROC.covered2.Data + + covered_data.blue_chest = surface.create_entity{name = 'blue-chest', position = Math.vector_sum(special.position, hardcoded_data.blue_chest), force = 'environment'} + if covered_data.blue_chest and covered_data.blue_chest.valid then + covered_data.blue_chest.minable = false + covered_data.blue_chest.rotatable = false + covered_data.blue_chest.operable = false + covered_data.blue_chest.destructible = false + end + covered_data.red_chests = {} + for _, chest_position in pairs(hardcoded_data.red_chests) do + local e = surface.create_entity{name = 'red-chest', position = Math.vector_sum(special.position, chest_position), force = 'environment'} + if e and e.valid then + e.minable = false + e.rotatable = false + e.operable = false + e.destructible = false + covered_data.red_chests[#covered_data.red_chests+1] = e + end + end + covered_data.door_walls = {} + for _, p in pairs(hardcoded_data.walls) do + local e = surface.create_entity{name = 'stone-wall', position = Math.vector_sum(special.position, p), force = 'environment'} + if e and e.valid then + e.minable = false + e.rotatable = false + e.operable = false + e.destructible = false + end + covered_data.door_walls[#covered_data.door_walls + 1] = e + end + + elseif special.name == 'covered2b' then + local covered_data = destination.dynamic_data.covered_data + if not covered_data then return end + + local hardcoded_data = Structures.IslandStructures.ROC.covered2b.Data + + covered_data.market = surface.create_entity{name = 'market', position = Math.vector_sum(special.position, hardcoded_data.market), force = string.format('ancient-friendly-%03d', memory.id)} + if covered_data.market and covered_data.market.valid then + covered_data.market.minable = false + covered_data.market.rotatable = false + covered_data.market.destructible = false + + covered_data.market.add_market_item{price={{'pistol', 1}}, offer={type = 'give-item', item = 'coin', count = Balance.coin_sell_amount}} + covered_data.market.add_market_item{price={{'burner-mining-drill', 1}}, offer={type = 'give-item', item = 'iron-plate', count = 9}} + + local how_many_coin_offers = 4 + if Balance.crew_scale() >= 1.2 then how_many_coin_offers = 5 end + local coin_offers = ShopCovered.market_generate_coin_offers(how_many_coin_offers) + for _, o in pairs(coin_offers) do + covered_data.market.add_market_item(o) + end + + if destination.static_params.class_for_sale then + covered_data.market.add_market_item{price={{'coin', Balance.class_cost()}}, offer={type="nothing", effect_description = 'Purchase the class ' .. Classes.display_form[destination.static_params.class_for_sale] .. '.'}} + + -- destination.dynamic_data.market_class_offer_rendering = rendering.draw_text{ + -- text = 'Class available: ' .. Classes.display_form[destination.static_params.class_for_sale], + -- surface = surface, + -- target = Utils.psum{special.position, hardcoded_data.market, {x = 1, y = -3.9}}, + -- color = CoreData.colors.renderingtext_green, + -- scale = 2.5, + -- font = 'default-game', + -- alignment = 'center' + -- } + end + end + + for _, w in pairs(covered_data.door_walls) do + if w and w.valid then + w.destructible = true + w.destroy() + end + end + + covered_data.wooden_chests = {} + for k, p in ipairs(hardcoded_data.wooden_chests) do + local e = surface.create_entity{name = 'wooden-chest', position = Math.vector_sum(special.position, p), force = string.format('ancient-friendly-%03d', memory.id)} + if e and e.valid then + e.minable = false + e.rotatable = false + e.destructible = false + + local inv = e.get_inventory(defines.inventory.chest) + if k==1 then + inv.insert({name = 'coin', count = 2000}) + elseif k==4 then + local loot = Loot.covered_wooden_chest_loot_1() + for j = 1, #loot do + local l = loot[j] + inv.insert(l) + end + else + local loot = Loot.covered_wooden_chest_loot_2() + for j = 1, #loot do + local l = loot[j] + inv.insert(l) + end + end + end + covered_data.wooden_chests[#covered_data.wooden_chests + 1] = e + end end @@ -711,49 +819,113 @@ function Public.covered_requirement_check(tickinterval) local covered_data = destination.dynamic_data.covered_data if not covered_data then return end - local blue_chest = covered_data.blue_chest - local red_chest = covered_data.red_chest - if not (blue_chest and blue_chest.valid and red_chest and red_chest.valid) then return end - local blue_inv = covered_data.blue_chest.get_inventory(defines.inventory.chest) - local red_inv = covered_data.red_chest.get_inventory(defines.inventory.chest) + if covered_data.structure_type == 'covered1' then - local blue_contents = blue_inv.get_contents() - - local requirement = covered_data.requirement - - local got = 0 - for k, v in pairs(blue_contents) do - if covered_data.state == 'covered' and k == requirement.name then - got = v - else - -- @FIX: power armor loses components, items lose health! - red_inv.insert({name = k, count = v}); - blue_inv.remove({name = k, count = v}); - end - end - - if covered_data.state == 'covered' then - if got >= requirement.count then - blue_inv.remove({name = requirement.name, count = requirement.count}); - covered_data.state = 'uncovered' - rendering.destroy(covered_data.rendering1) - rendering.destroy(covered_data.rendering2) - - local structureData = Structures.IslandStructures.ROC.covered1b.Data - local special = { - position = covered_data.position, - components = structureData.components, - width = structureData.width, - height = structureData.height, - name = structureData.name, - } - destination.dynamic_data.structures_waiting_to_be_placed[#destination.dynamic_data.structures_waiting_to_be_placed + 1] = {data = special, tick = game.tick} - else - if covered_data.rendering1 then - rendering.set_text(covered_data.rendering1, 'Needs ' .. requirement.count - got .. ' x') + local blue_chest = covered_data.blue_chest + local red_chest = covered_data.red_chest + if not (blue_chest and blue_chest.valid and red_chest and red_chest.valid) then return end + local blue_inv = covered_data.blue_chest.get_inventory(defines.inventory.chest) + local red_inv = covered_data.red_chest.get_inventory(defines.inventory.chest) + + local blue_contents = blue_inv.get_contents() + + local requirement = covered_data.requirement + + local got = 0 + for k, v in pairs(blue_contents) do + if covered_data.state == 'covered' and k == requirement.name then + got = v + else + -- @FIX: power armor loses components, items lose health! + red_inv.insert({name = k, count = v}); + blue_inv.remove({name = k, count = v}); + end + end + + if covered_data.state == 'covered' then + if got >= requirement.count then + blue_inv.remove({name = requirement.name, count = requirement.count}); + covered_data.state = 'uncovered' + rendering.destroy(covered_data.rendering1) + rendering.destroy(covered_data.rendering2) + + local structureData = Structures.IslandStructures.ROC.covered1b.Data + local special = { + position = covered_data.position, + components = structureData.components, + width = structureData.width, + height = structureData.height, + name = structureData.name, + } + destination.dynamic_data.structures_waiting_to_be_placed[#destination.dynamic_data.structures_waiting_to_be_placed + 1] = {data = special, tick = game.tick} + else + if covered_data.rendering1 then + rendering.set_text(covered_data.rendering1, 'Needs ' .. requirement.count - got .. ' x') + end + end + end + + elseif covered_data.structure_type == 'covered2' then + local blue_chest = covered_data.blue_chest + local red_chests = covered_data.red_chests + if not (blue_chest and blue_chest.valid and red_chests and red_chests[1] and red_chests[1].valid and red_chests[2] and red_chests[2].valid and red_chests[3] and red_chests[3].valid) then return end + + local blue_inv = covered_data.blue_chest.get_inventory(defines.inventory.chest) + local red_inv_main = {} + red_inv_main[1] = covered_data.red_chests[1].get_inventory(defines.inventory.chest) + red_inv_main[2] = covered_data.red_chests[3].get_inventory(defines.inventory.chest) + local red_inv_other = covered_data.red_chests[2].get_inventory(defines.inventory.chest) + + local blue_contents = blue_inv.get_contents() + + local requirement = covered_data.requirement --fields {name, count, batchSize, batchRawMaterials} + + for k, v in pairs(blue_contents) do + + if covered_data.state == 'covered' and k == requirement.name and v >= requirement.batchSize then + local toRemove = v - (v % requirement.batchSize) + local batches = toRemove / requirement.batchSize + + covered_data.completion_counter = covered_data.completion_counter + toRemove + blue_inv.remove({name = k, count = toRemove}); + + local i = 1 + for k2, v2 in pairs(requirement.batchRawMaterials) do + red_inv_main[i].insert({name = k2, count = v2 * batches}) + if red_inv_main[i+1] then i = i + 1 end + end + elseif not (covered_data.state == 'covered' and k == requirement.name and v < requirement.batchSize) then + -- @FIX: power armor loses components, items lose health data! + red_inv_other.insert({name = k, count = v}); + blue_inv.remove({name = k, count = v}); + end + end + + if covered_data.state == 'covered' then + if covered_data.completion_counter >= requirement.count then + covered_data.state = 'uncovered' + rendering.destroy(covered_data.rendering1) + rendering.destroy(covered_data.rendering2) + + -- local structureData = Structures.IslandStructures.ROC.covered1b.Data + -- local structureData = Structures.IslandStructures.ROC.covered2b.Data + -- local special = { + -- position = covered_data.position, + -- components = structureData.components, + -- width = structureData.width, + -- height = structureData.height, + -- name = structureData.name, + -- } + local special = Utils.deepcopy(Structures.IslandStructures.ROC.covered2b.Data) + special.position = covered_data.position + + destination.dynamic_data.structures_waiting_to_be_placed[#destination.dynamic_data.structures_waiting_to_be_placed + 1] = {data = special, tick = game.tick} + else + if covered_data.rendering1 then + rendering.set_text(covered_data.rendering1, 'Needs ' .. requirement.count - covered_data.completion_counter .. ' x') + end end end - else end end @@ -1083,7 +1255,7 @@ function Public.loading_update(tickinterval) else local fraction = memory.loadingticks / (total + (memory.extra_time_at_sea or 0)) - if fraction > Common.fraction_of_map_loaded_atsea then + if fraction > Common.fraction_of_map_loaded_at_sea then Progression.progress_to_destination(destination_index) memory.loadingticks = 0 else @@ -1092,7 +1264,7 @@ function Public.loading_update(tickinterval) end elseif memory.boat.state == Boats.enum_state.LANDED then - local fraction = Common.fraction_of_map_loaded_atsea + (1 - Common.fraction_of_map_loaded_atsea) * memory.loadingticks / Common.map_loading_ticks_onisland + local fraction = Common.fraction_of_map_loaded_at_sea + (1 - Common.fraction_of_map_loaded_at_sea) * memory.loadingticks / Common.map_loading_ticks_onisland if fraction > 1 then memory.loadingticks = nil