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

New cave island

Changes:
- New island: Mysterious caves
- New market offers: logistic chests
This commit is contained in:
Piratux 2022-10-03 00:37:54 +03:00
parent 24ff99c6b4
commit 8542a783cf
21 changed files with 901 additions and 85 deletions

@ -1,6 +1,6 @@
require 'utils.data_stages'
_LIFECYCLE = _STAGE.control -- Control stage
_DEBUG = false
_DEBUG = true
_DUMP_ENV = false
require 'utils.server'
@ -113,7 +113,7 @@ require 'utils.freeplay'
--require 'maps.chronosphere.main'
--![[Adventure as a crew of pirates]]--
--require 'maps.pirates.main'
require 'maps.pirates.main'
--![[Launch rockets in increasingly harder getting worlds.]]--
--require 'maps.journey.main'

@ -50,6 +50,7 @@ location_displayname_standard_1=Isle of Buried Treasure
location_displayname_standard_variant_1=Secluded Dells
location_displayname_swamp_1=Poisonous Fen
location_displayname_walkways_1=Frozen Pools
location_displayname_cave_1=Mysterious Caves
location_displayname_sea_1=
location_displayname_dock_1=Dock
location_displayname_lobby_1=Starting Dock
@ -70,6 +71,7 @@ parrot_kraken_warning=400 leagues coming up? What are those pink things I spy...
parrot_radioactive_tip_1=We'll need uranium-235 to push away from this island...
parrot_radioactive_tip_2=The biters don't care if we pollute here, but they evolve fast.
parrot_maze_tip_1=Something seems wrong with our minimap.
parrot_cave_tip_1=That island looks suspiciously dark... I'm scared! Squawk!
parrot_captain_first_time_in_cabin_hint=Squawk! Captains and officers can buy rail signals to steer the ship!
parrot_cliff_explosive_tip=Cliff explosives? These look so powerful, they could blow away those annoying chests in the hold. Squawk!
parrot_burried_treasure_tip=Squawk! If X marks the spot - find an item to dig with!
@ -552,6 +554,8 @@ gui_questframe_find=Island Quest: Ghosts\n\nFind the ghosts for a bonus.
gui_questframe_resourceflow=Island Quest: Resource Flow\n\nAchieve a production rate of a particular item for a bonus.
gui_questframe_resourcecount=Island Quest: Item Production\n\nSimply complete production of these items for a bonus, anywhere on the map.
gui_questframe_nodamage=Island Quest: No Damage\n\nLaunch a rocket without the silo taking damage.
gui_questframe_fish=Island Quest: Fishing season\n\nCatch enough fish for a bonus.
gui_questframe_compilatron=Island Quest: To the rescue\n\nFind and rescue compilatrons from underneath the rocks for a bouns.
gui_crew_tooltip_1=Your Crew\n\nPerform crew actions. Captains can manage crew and its members here.
gui_crew_tooltip_2=Your Crew\n\nYou're a free agent, so there's nothing to do here.

@ -34,6 +34,7 @@ local Loot = require 'maps.pirates.loot'
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'
@ -690,15 +691,9 @@ end
function Public.load_some_map_chunks_random_order(destination_index, fraction) -- The reason we might want to do this is because of algorithms like the labyrinth code, which make directionally biased patterns if you don't generate chunks in a random order
local memory = Memory.get_crew_memory()
local destination_data = memory.destinations[destination_index]
if not destination_data then return end
local surface_name = destination_data.surface_name
if not surface_name then return end
local surface = game.surfaces[surface_name]
function Public.load_some_map_chunks_random_order(surface, destination_data, fraction) -- The reason we might want to do this is because of algorithms like the labyrinth code, which make directionally biased patterns if you don't generate chunks in a random order
if not surface then return end
if not destination_data then return end
local shuffled_chunks
if not destination_data.dynamic_data then destination_data.dynamic_data = {} end
@ -754,16 +749,18 @@ end
local function event_on_player_mined_entity(event)
if not event.player_index then return end
local player = game.players[event.player_index]
if not player.valid then return end
local entity = event.entity
if not entity.valid then return end
local crew_id = Common.get_id_from_force_name(player.force.name)
Memory.set_working_id(crew_id)
local memory = Memory.get_crew_memory()
local destination = Common.current_destination()
local entity = event.entity
if not entity.valid then return end
if player.surface.name == 'gulag' then
event.buffer.clear()
return
@ -843,15 +840,31 @@ local function event_on_player_mined_entity(event)
elseif entity.type == 'fish' then
if not event.buffer then return end
local fish_amount = 0
local to_give = {}
if memory.classes_table and memory.classes_table[event.player_index] and memory.classes_table[event.player_index] == Classes.enum.MASTER_ANGLER then
Common.give(player, {{name = 'raw-fish', count = Balance.base_caught_fish_amount + Balance.master_angler_fish_bonus}, {name = 'coin', count = Balance.master_angler_coin_bonus}}, entity.position)
fish_amount = Balance.base_caught_fish_amount + Balance.master_angler_fish_bonus
to_give[#to_give + 1] = {name = 'raw-fish', count = fish_amount}
to_give[#to_give + 1] = {name = 'coin', count = Balance.master_angler_coin_bonus}
elseif memory.classes_table and memory.classes_table[event.player_index] and memory.classes_table[event.player_index] == Classes.enum.DREDGER then
local to_give = {{name = 'raw-fish', count = Balance.base_caught_fish_amount + Balance.dredger_fish_bonus}}
fish_amount = Balance.base_caught_fish_amount + Balance.dredger_fish_bonus
to_give[#to_give + 1] = {name = 'raw-fish', count = fish_amount}
to_give[#to_give + 1] = Loot.dredger_loot()[1]
Common.give(player, to_give, entity.position)
else
Common.give(player, {{name = 'raw-fish', count = Balance.base_caught_fish_amount}}, entity.position)
fish_amount = Balance.base_caught_fish_amount
to_give[#to_give + 1] = {name = 'raw-fish', count = fish_amount}
end
Common.give(player, to_give, entity.position)
if destination and destination.dynamic_data and destination.dynamic_data.quest_type and (not destination.dynamic_data.quest_complete) then
if destination.dynamic_data.quest_type == Quest.enum.FISH then
destination.dynamic_data.quest_progress = destination.dynamic_data.quest_progress + fish_amount
Quest.try_resolve_quest()
end
end
event.buffer.clear()
@ -903,12 +916,35 @@ local function event_on_player_mined_entity(event)
-- local starting = destination.static_params.starting_rock_material
if available and destination.type == Surfaces.enum.ISLAND then
if destination and destination.subtype and destination.subtype == Islands.enum.MAZE then
if destination.subtype == Islands.enum.MAZE then
if Math.random(1, 35) == 1 then
tick_tack_trap(memory.enemy_force_name, entity.surface, entity.position)
return
end
elseif destination.subtype == Islands.enum.CAVE then
Ores.try_give_ore(player, entity.position, entity.name)
if Math.random(1, 35) == 1 then
tick_tack_trap(memory.enemy_force_name, entity.surface, entity.position)
elseif Math.random(1, 20) == 1 then
entity.surface.create_entity({name = 'compilatron', position = entity.position, force = memory.force})
if destination and destination.dynamic_data and destination.dynamic_data.quest_type and (not destination.dynamic_data.quest_complete) then
if destination.dynamic_data.quest_type == Quest.enum.COMPILATRON then
destination.dynamic_data.quest_progress = destination.dynamic_data.quest_progress + 1
Quest.try_resolve_quest()
end
end
elseif Math.random(1, 10) == 1 then
if Math.random(1, 4) == 1 then
entity.surface.create_entity{name = Common.get_random_worm_type(memory.evolution_factor), position = entity.position, force = memory.enemy_force_name}
else
entity.surface.create_entity{name = Common.get_random_unit_type(memory.evolution_factor), position = entity.position, force = memory.enemy_force_name}
end
end
else
local c = event.buffer.get_contents()
table.sort(c, function(a,b) return a.name < b.name end)
@ -1322,6 +1358,7 @@ local function event_on_player_joined_game(event)
if _DEBUG then
game.print('Debug mode on. Use /go to get started, /1 /4 /32 etc to change game speed.')
game.print('Current version: ' .. CoreData.version_string)
end
local crew_to_put_back_in = nil
@ -1632,7 +1669,7 @@ function Public.event_on_chunk_generated(event)
local memory = Memory.get_crew_memory()
if type == Surfaces.enum.ISLAND and memory.destinations and memory.destinations[chunk_destination_index] then
local destination = memory.destinations[chunk_destination_index]
scope = Surfaces.get_scope(destination)
scope = Surfaces.get_scope(surface_name_decoded)
static_params = destination.static_params
other_map_generation_data = destination.dynamic_data.other_map_generation_data or {}
terraingen_coordinates_offset = static_params.terraingen_coordinates_offset
@ -1738,11 +1775,11 @@ function Public.event_on_chunk_generated(event)
-- recoordinatize:
special.position = Utils.psum{special.position, {-1, terraingen_coordinates_offset}}
if special.name and special.name == 'buried-treasure' then
if special.name == 'buried-treasure' then
if destination.dynamic_data.buried_treasure and crewid ~= 0 then
destination.dynamic_data.buried_treasure[#destination.dynamic_data.buried_treasure + 1] = {treasure = Loot.buried_treasure_loot(), position = special.position}
end
elseif special.name and special.name == 'chest' then
elseif special.name == 'chest' then
local e = surface.create_entity{name = 'wooden-chest', position = special.position, force = memory.ancient_friendly_force_name}
if e and e.valid then
e.minable = false
@ -1764,6 +1801,17 @@ function Public.event_on_chunk_generated(event)
inv.insert(l)
end
end
elseif special.name == 'market' then
local e = surface.create_entity{name = 'market', position = special.position, force = memory.ancient_friendly_force_name}
if e and e.valid then
e.minable = false
e.rotatable = false
e.destructible = false
for _, o in pairs(special.offers) do
e.add_market_item(o)
end
end
end
if special.components then

@ -571,7 +571,7 @@ function Public.place_cached_structures(tickinterval)
surface.create_entity{
name = 'crude-oil',
position = p,
amount = Balance.pick_special_pumpjack_oil_amount()
amount = Balance.pick_default_oil_amount()
}
end
local e2 = surface.create_entity{name = c.name, position = p, direction = e.direction, force = force_name, amount = c.amount}
@ -818,7 +818,7 @@ function Public.boat_movement_tick(tickinterval)
Structures.Boats.currentdestination_move_boat_natural()
end
elseif boat.speedticker2 >= Common.boat_steps_at_a_time then
if surface_type and surface_type == Surfaces.enum.ISLAND and boat and boat.state and boat.state == Boats.enum_state.APPROACHING then
if surface_type == Surfaces.enum.ISLAND and boat and boat.state == Boats.enum_state.APPROACHING then
Structures.Boats.currentdestination_try_move_boat_steered()
end
boat.speedticker2 = 0
@ -1030,7 +1030,10 @@ function Public.loading_update(tickinterval)
Progression.progress_to_destination(destination_index)
memory.loadingticks = 0
else
PiratesApiEvents.load_some_map_chunks_random_order(destination_index, fraction) --random order is good for maze world
PiratesApiEvents.load_some_map_chunks_random_order(surface, currentdestination, fraction) --random order is good for maze world
if currentdestination.subtype == Surfaces.Island.enum.CAVE then
PiratesApiEvents.load_some_map_chunks_random_order(currentdestination.dynamic_data.cave_miner.cave_surface, currentdestination, fraction)
end
end
end

@ -635,10 +635,10 @@ end
-- a: scaling
-- When the formula needs adjustments, I suggest changing scaling variable
-- Note: 3333 crude oil amount ~= 1% = 0.1/sec
function Public.pick_special_pumpjack_oil_amount()
function Public.pick_default_oil_amount()
local scaling = 50
local amount = scaling * Math.sqrt(1000000 * Common.game_completion_progress())
local extra_random_amount = Math.random(Math.ceil(0.2 * amount))
local extra_random_amount = Math.random(Math.max(1, Math.ceil(0.2 * amount)))
return amount + extra_random_amount
end

@ -7,7 +7,7 @@ local _inspect = require 'utils.inspect'.inspect
local Public = {}
Public.scenario_id_name = 'pirates'
Public.version_string = '1.3.5' --major.minor.patch versioning, to match factorio mod portal
Public.version_string = '1.4.0' --major.minor.patch versioning, to match factorio mod portal
Public.blueprint_library_allowed = true
Public.blueprint_importing_allowed = true

@ -11,6 +11,7 @@ local CoreData = require 'maps.pirates.coredata'
local Server = require 'utils.server'
local Utils = require 'maps.pirates.utils_local'
local Surfaces = require 'maps.pirates.surfaces.surfaces'
local Islands = require 'maps.pirates.surfaces.islands.islands'
-- local Structures = require 'maps.pirates.structures.structures'
local Boats = require 'maps.pirates.structures.boats.boats'
local Crowsnest = require 'maps.pirates.surfaces.crowsnest'
@ -589,7 +590,11 @@ function Public.disband_crew(donotprint)
if game.surfaces[crowsnestname] then game.delete_surface(game.surfaces[crowsnestname]) end
for _, destination in pairs(memory.destinations) do
if game.surfaces[destination.surface_name] then game.delete_surface(game.surfaces[destination.surface_name]) end
if game.surfaces[destination.surface_name] then
game.delete_surface(game.surfaces[destination.surface_name])
end
Islands[Islands.enum.CAVE].cleanup_cave_surface(destination)
end
global_memory.crew_memories[id] = nil

@ -876,6 +876,12 @@ function Public.process_siloframe_and_questframe_updates(flowsilo, flowquest, bo
flow1.quest_label_3.caption = {'pirates.gui_questframe_fail'}
flow1.quest_label_3.style.font_color = GuiCommon.insufficient_font_color
end
elseif quest_type == Quest.enum.FISH then
if tooltip == '' then tooltip = {'pirates.gui_questframe_fish'} end
elseif quest_type == Quest.enum.COMPILATRON then
if tooltip == '' then tooltip = {'pirates.gui_questframe_compilatron'} end
end
end

@ -279,9 +279,9 @@ local function crew_tick()
memory.crew_disband_tick_message = nil
local message1 = {'pirates.crew_disband_tick_message', 30}
Common.notify_force(memory.force, message1)
Server.to_discord_embed_raw({'', '[' .. memory.name .. '] ', message1}, true)
end
end

@ -13,7 +13,57 @@ local simplex_noise = require 'utils.simplex_noise'.d2
local Public = {}
-- Gives less and less ore with every call, until given amount slowly converges to 1
-- For now used just for Cave island to give players ore when mining rocks
-- NOTE: Also gives some coins
function Public.try_give_ore(player, realp, source_name)
local destination = Common.current_destination()
local choices = destination.dynamic_data.hidden_ore_remaining_abstract
if choices and Utils.length(choices) > 0 then
local choices_possible = {}
local choices_to_prioitise = {}
local total_ore_left = 0
for k, v in pairs(choices) do
if v>0 then choices_possible[k] = v end
total_ore_left = total_ore_left + v
if (not destination.dynamic_data.ore_types_spawned[k]) then
choices_to_prioitise[#choices_to_prioitise + 1] = k
end
end
if Utils.length(choices_possible) > 0 then
local choice
if Utils.length(choices_to_prioitise) > 0 then
choice = choices_to_prioitise[Math.random(Utils.length(choices_to_prioitise))]
else
choice = Raffle.raffle2(choices_possible)
end
if not choice then return end
local coin_amount = 4 + Math.random(4)
local real_amount = Math.max(Common.minimum_ore_placed_per_tile, Common.ore_abstract_to_real(total_ore_left))
local given_amount = Math.ceil(real_amount * Math.random_float_in_range(0.004, 0.006))
if source_name == 'rock-huge' then
given_amount = given_amount * 1.5
coin_amount = coin_amount * 2
end
local to_give = {}
to_give[#to_give+1] = {name = choice, count = Math.ceil(given_amount)}
to_give[#to_give+1] = {name = 'coin', count = Math.ceil(coin_amount)}
Common.give(player, to_give, realp)
choices[choice] = Math.max(0, choices[choice] - Common.ore_real_to_abstract(given_amount))
end
end
end
function Public.try_ore_spawn(surface, realp, source_name, density_bonus)
density_bonus = density_bonus or 0

@ -8,7 +8,7 @@ local Balance = require 'maps.pirates.balance'
local Common = require 'maps.pirates.common'
local CoreData = require 'maps.pirates.coredata'
local Utils = require 'maps.pirates.utils_local'
local _inspect = require 'utils.inspect'.inspect
-- local _inspect = require 'utils.inspect'.inspect
-- local Server = require 'utils.server'
-- local Structures = require 'maps.pirates.structures.structures'
@ -16,7 +16,7 @@ local Boats = require 'maps.pirates.structures.boats.boats'
local Surfaces = require 'maps.pirates.surfaces.surfaces'
local Crowsnest = require 'maps.pirates.surfaces.crowsnest'
local Dock = require 'maps.pirates.surfaces.dock'
-- local Islands = require 'maps.pirates.surfaces.islands.islands'
local Islands = require 'maps.pirates.surfaces.islands.islands'
-- local Sea = require 'maps.pirates.surfaces.sea.sea'
local Crew = require 'maps.pirates.crew'
-- local Roles = require 'maps.pirates.roles.roles'
@ -43,11 +43,12 @@ local MAZE = Surfaces.Island.enum.MAZE
local RADIOACTIVE = Surfaces.Island.enum.RADIOACTIVE
local HORSESHOE = Surfaces.Island.enum.HORSESHOE
local STANDARD_VARIANT = Surfaces.Island.enum.STANDARD_VARIANT
local CAVE = Surfaces.Island.enum.CAVE
local A = {STANDARD_VARIANT, RED_DESERT, HORSESHOE, WALKWAYS}
local B = {NIL, NIL, NIL, STANDARD, STANDARD_VARIANT, RED_DESERT, HORSESHOE, WALKWAYS}
local C = {STANDARD, STANDARD_VARIANT, RED_DESERT, HORSESHOE, WALKWAYS}
local D = {NIL, NIL, NIL, STANDARD, STANDARD_VARIANT, RED_DESERT, HORSESHOE, WALKWAYS, SWAMP}
local A = {STANDARD_VARIANT, RED_DESERT, HORSESHOE, WALKWAYS, CAVE}
local B = {NIL, NIL, NIL, STANDARD, STANDARD_VARIANT, RED_DESERT, HORSESHOE, WALKWAYS, CAVE}
local C = {STANDARD, STANDARD_VARIANT, RED_DESERT, HORSESHOE, WALKWAYS, CAVE}
local D = {NIL, NIL, NIL, STANDARD, STANDARD_VARIANT, RED_DESERT, HORSESHOE, WALKWAYS, SWAMP, CAVE}
local destinationScheme = {
[0] = {DOCK, FIRST, NIL},
@ -123,7 +124,8 @@ function Public.generate_destination_type_and_subtype(overworld_position)
type2 = Surfaces.enum.ISLAND
end
return {type = type2, subtype = subtype}
return {type = Surfaces.enum.ISLAND, subtype = Surfaces.Island.enum.CAVE}
--return {type = type2, subtype = subtype}
end
@ -598,6 +600,8 @@ function Public.cleanup_old_destination_data() --we do actually access destinati
local memory = Memory.get_crew_memory()
for i, destination_data in pairs(memory.destinations) do
if destination_data.overworld_position.x < memory.overworldx then
Islands[Islands.enum.CAVE].cleanup_cave_surface(memory.destinations[i])
memory.destinations[i] = nil
end
end

@ -21,6 +21,8 @@ local enum = {
RESOURCEFLOW = 'Resource_Flow',
RESOURCECOUNT = 'Resource_Count',
WORMS = 'Worms',
FISH = 'Fish',
COMPILATRON = 'Compilatron', -- compilatron is robot that looks like sheep
}
Public.enum = enum
@ -31,6 +33,8 @@ Public.quest_icons = {
[enum.FIND] = '[img=utility.ghost_time_to_live_modifier_icon]',
[enum.RESOURCEFLOW] = '',
[enum.RESOURCECOUNT] = '',
[enum.FISH] = '[item=raw-fish]',
[enum.COMPILATRON] = '[entity=compilatron]',
}
@ -86,10 +90,14 @@ function Public.initialise_random_quest()
-- Public.initialise_time_quest()
end
function Public.initialise_random_cave_island_quest()
local rng = Math.random(100)
if rng <= 50 then
Public.initialise_fish_quest()
else
Public.initialise_compilatron_quest()
end
end
function Public.initialise_time_quest()
local destination = Common.current_destination()
@ -128,7 +136,7 @@ end
function Public.initialise_nodamage_quest()
local destination = Common.current_destination()
if not destination and destination.dynamic_data and destination.dynamic_data.rocketsilomaxhp then return end
if not destination and destination.dynamic_data and destination.dynamic_data.rocketsilomaxhp then return false end
destination.dynamic_data.quest_type = enum.NODAMAGE
destination.dynamic_data.quest_reward = Public.quest_reward()
@ -142,7 +150,7 @@ end
function Public.initialise_resourceflow_quest()
local destination = Common.current_destination()
if not destination and destination.dynamic_data and destination.dynamic_data.rocketsilomaxhp then return end
if not destination and destination.dynamic_data and destination.dynamic_data.rocketsilomaxhp then return false end
destination.dynamic_data.quest_type = enum.RESOURCEFLOW
destination.dynamic_data.quest_reward = Public.quest_reward()
@ -192,7 +200,7 @@ end
function Public.initialise_worms_quest()
local destination = Common.current_destination()
if not (destination.surface_name and game.surfaces[destination.surface_name]) then return end
if not (destination.surface_name and game.surfaces[destination.surface_name]) then return false end
local surface = game.surfaces[destination.surface_name]
@ -231,6 +239,33 @@ function Public.initialise_worms_quest()
end
end
-- Catch amount of fish (currently Cave island exclusive, because it's hard to calculate "quest_progressneeded")
function Public.initialise_fish_quest()
local destination = Common.current_destination()
if not destination and destination.dynamic_data then return false end
destination.dynamic_data.quest_type = enum.FISH
destination.dynamic_data.quest_reward = Public.quest_reward()
destination.dynamic_data.quest_progress = 0
destination.dynamic_data.quest_progressneeded = Math.random(300, 450) -- assuming that base caught fish amount is 3
return true
end
-- Rescue compilatrons under the heavy rocks (currently Cave island exclusive, because it's hard to calculate "quest_progressneeded")
function Public.initialise_compilatron_quest()
local destination = Common.current_destination()
if not destination and destination.dynamic_data then return false end
destination.dynamic_data.quest_type = enum.COMPILATRON
destination.dynamic_data.quest_reward = Public.quest_reward()
destination.dynamic_data.quest_progress = 0
destination.dynamic_data.quest_progressneeded = Math.random(30, 40) -- assuming that chance to find compilatron is 1/20
return true
end
function Public.try_resolve_quest()

@ -375,6 +375,7 @@ local function class_on_player_used_capsule(event)
end
end
if multiplier > 0 then
-- Idea behind this: A diminishing return for ore granted every time fish is eaten. But slowly "reset" the diminishing return overtime
local timescale = 60*30 * Math.max((Balance.game_slowness_scale())^(2/3),0.8)
if memory.gourmet_recency_tick then
multiplier = multiplier * Math.clamp(0.2, 5, (1/5)^((memory.gourmet_recency_tick - game.tick)/(60*300)))

@ -55,6 +55,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}},
}

@ -1,6 +1,7 @@
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/danielmartin0/ComfyFactorio-Pirates.
local SurfacesCommon = require 'maps.pirates.surfaces.common'
local Memory = require 'maps.pirates.memory'
local Math = require 'maps.pirates.math'
local Balance = require 'maps.pirates.balance'
@ -10,7 +11,7 @@ local Hold = require 'maps.pirates.surfaces.hold'
-- local Parrot = require 'maps.pirates.parrot'
local Cabin = require 'maps.pirates.surfaces.cabin'
local Utils = require 'maps.pirates.utils_local'
local _inspect = require 'utils.inspect'.inspect
-- local _inspect = require 'utils.inspect'.inspect
-- DEV NOTE: If making boat designs that have rails, make sure the boat is placed at odd co-ordinates before blueprinting.

@ -0,0 +1,235 @@
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/danielmartin0/ComfyFactorio-Pirates.
local Memory = require 'maps.pirates.memory'
local Math = require 'maps.pirates.math'
local Common = require 'maps.pirates.common'
local Utils = require 'maps.pirates.utils_local'
local SurfacesCommon = require 'maps.pirates.surfaces.common'
local BoatData = require 'maps.pirates.structures.boats.sloop.data'
local Event = require 'utils.event'
local Public = {}
Public.Data = require 'maps.pirates.surfaces.islands.cave.data'
-- Code imported from cave_miner_v2 scenario for cave generation
--lab-dark-1 > position has been copied
--lab-dark-2 > position has been visited
function Public.reveal(cave_miner, surface, source_surface, position, brushsize)
local tile = source_surface.get_tile(position)
if not tile.valid then return end
if tile.name == 'lab-dark-2' then
return
end
local tiles = {}
local copied_tiles = {}
local i = 0
local brushsize_square = brushsize ^ 2
local surface_name_decoded = SurfacesCommon.decode_surface_name(surface.name)
local chunk_destination_index = surface_name_decoded.destination_index
local memory = Memory.get_crew_memory()
local destination = memory.destinations[chunk_destination_index]
local terraingen_coordinates_offset = destination.static_params.terraingen_coordinates_offset
-- TODO: use radius search for "find_tiles_filtered" instead to avoid the check?
for _, tile in pairs(source_surface.find_tiles_filtered({area = {{position.x - brushsize, position.y - brushsize}, {position.x + brushsize, position.y + brushsize}}})) do
local tile_position = tile.position
if tile.name ~= 'lab-dark-2' and tile.name ~= 'lab-dark-1' and (position.x - tile_position.x) ^ 2 + (position.y - tile_position.y) ^ 2 < brushsize_square then
i = i + 1
copied_tiles[i] = {name = 'lab-dark-1', position = tile.position}
-- Avoid re-exploring these areas as they have been already revealed when map was loaded
-- Revealed areas when map gets loaded are: river and entrance (beach with sand)
local true_pos = Utils.psum{tile_position, {1, terraingen_coordinates_offset}}
true_pos = Utils.psum{true_pos, {x = 0.5, y = 0.5}}
local d = true_pos.x ^ 2 + true_pos.y ^ 2
local boat_height = Math.max(BoatData.height, 15) -- even if boat height is smaller, we need to be at least 10+ just so formulas below play out nicely
local spawn_radius = boat_height + 15
local entrance_radius = boat_height + 45
local river_width = boat_height + 40
-- Don't copy river upon which ship arrives + ship entrance
if not (true_pos.x < 0 and d >= spawn_radius ^ 2 and Math.abs(2 * true_pos.y) < river_width) then
tiles[i] = {name = tile.name, position = tile.position}
end
end
end
surface.set_tiles(tiles, true, false, false, false)
source_surface.set_tiles(copied_tiles, false, false, false, false)
for _, entity in pairs(source_surface.find_entities_filtered({area = {{position.x - brushsize, position.y - brushsize}, {position.x + brushsize, position.y + brushsize}}})) do
local entity_position = entity.position
if (position.x - entity_position.x) ^ 2 + (position.y - entity_position.y) ^ 2 < brushsize_square then
local e = entity.clone({position = entity_position, surface = surface})
if e.name == 'market' then
rendering.draw_light(
{
sprite = 'utility/light_medium',
scale = 7,
intensity = 0.8,
minimum_darkness = 0,
oriented = true,
color = {255, 255, 255},
target = e,
surface = surface,
visible = true,
only_in_alt_mode = false
}
)
end
if entity.force.index == 2 then
e.active = true
table.insert(cave_miner.reveal_queue, {entity.type, entity.position.x, entity.position.y})
end
entity.destroy()
end
end
source_surface.set_tiles({{name = 'lab-dark-2', position = position}}, false)
source_surface.request_to_generate_chunks(position, 3)
end
function Public.roll_source_surface(destination_data)
local map_gen_settings = {
['water'] = 0,
['starting_area'] = 1,
['cliff_settings'] = {cliff_elevation_interval = 0, cliff_elevation_0 = 0},
['default_enable_all_autoplace_controls'] = false,
['autoplace_settings'] = {
['entity'] = {treat_missing_as_default = false},
['tile'] = {treat_missing_as_default = false},
['decorative'] = {treat_missing_as_default = false}
},
autoplace_controls = {
['coal'] = {frequency = 0, size = 0, richness = 0},
['stone'] = {frequency = 0, size = 0, richness = 0},
['copper-ore'] = {frequency = 0, size = 0, richness = 0},
['iron-ore'] = {frequency = 0, size = 0, richness = 0},
['uranium-ore'] = {frequency = 0, size = 0, richness = 0},
['crude-oil'] = {frequency = 0, size = 0, richness = 0},
['trees'] = {frequency = 0, size = 0, richness = 0},
['enemy-base'] = {frequency = 0, size = 0, richness = 0}
},
}
local cave_miner = destination_data.dynamic_data.cave_miner
local island_surface_name = SurfacesCommon.decode_surface_name(destination_data.surface_name)
-- @FIXME: magic number (cave source island enum)
local cave_surface_name = SurfacesCommon.encode_surface_name(island_surface_name.crewid, island_surface_name.destination_index, island_surface_name.type, '11')
cave_miner.cave_surface = game.create_surface(cave_surface_name, map_gen_settings)
cave_miner.cave_surface.request_to_generate_chunks({x = 0, y = 0}, 2)
cave_miner.cave_surface.force_generate_chunk_requests()
end
function Public.cleanup_cave_surface(destination_data)
local dynamic_data = destination_data.dynamic_data
if dynamic_data and dynamic_data.cave_miner and dynamic_data.cave_miner.cave_surface then
game.delete_surface(dynamic_data.cave_miner.cave_surface)
end
end
local biomes = {}
function biomes.void(args)
args.tiles[#args.tiles + 1] = {name = 'out-of-map', position = args.p}
end
function biomes.entrance(args, square_distance)
if square_distance < (BoatData.height + 40) ^ 2 then
args.tiles[#args.tiles + 1] = {name = 'sand-1', position = args.p}
else
args.tiles[#args.tiles + 1] = {name = 'water-shallow', position = args.p}
end
end
function biomes.river(args)
args.tiles[#args.tiles + 1] = {name = 'water', position = args.p}
Public.Data.spawn_fish(args);
end
function Public.terrain(args)
local position = args.p
local d = position.x ^ 2 + position.y ^ 2
local boat_height = Math.max(BoatData.height, 15) -- even if boat height is smaller, we need to be at least 10+ just so formulas below play out nicely
local spawn_radius = boat_height + 15
local entrance_radius = boat_height + 45
local river_width = boat_height + 40
-- Spawn location for market
if d < spawn_radius ^ 2 then
biomes.void(args)
-- Cave entrance
elseif position.x < 0 and d < entrance_radius ^ 2 and Math.abs(2 * position.y) < river_width then
biomes.entrance(args, d)
-- River upon which ship arrives
elseif position.x < 0 and Math.abs(2 * position.y) < river_width then
biomes.river(args)
else
biomes.void(args)
end
-- fallback case when no tiles were placed
if #args.tiles == 0 then
args.tiles[#args.tiles + 1] = {name = 'dirt-7', position = args.p}
end
end
function Public.chunk_structures(args)
end
-- Launching rocket in caves sounds silly
function Public.generate_silo_setup_position(points_to_avoid)
end
local function on_player_changed_position(event)
if not event.player_index then return end
local player = game.players[event.player_index]
if not player.character then return end
if not player.character.valid then return end
local crew_id = Common.get_id_from_force_name(player.force.name)
if not crew_id then return end
Memory.set_working_id(crew_id)
local destination_data = Common.current_destination()
if destination_data.surface_name ~= player.surface.name then return end
-- @FIXME: magic number (cave island enum)
if not (destination_data and destination_data.subtype == '10') then return end
local cave_miner = destination_data.dynamic_data.cave_miner
-- TODO: make more reliable way to get island surface
Public.reveal(cave_miner, player.surface, cave_miner.cave_surface, {x = Math.floor(player.position.x), y = Math.floor(player.position.y)}, 11)
local reveal = cave_miner.reveal_queue[1]
if not reveal then
return
end
local brush_size = 5
Public.reveal(cave_miner, player.surface, cave_miner.cave_surface, {x = reveal[2], y = reveal[3]}, brush_size)
table.remove(cave_miner.reveal_queue, 1)
end
Event.add(defines.events.on_player_changed_position, on_player_changed_position)
return Public

@ -0,0 +1,332 @@
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/danielmartin0/ComfyFactorio-Pirates.
local Memory = require 'maps.pirates.memory'
local Math = require 'maps.pirates.math'
local Common = require 'maps.pirates.common'
local IslandsCommon = require 'maps.pirates.surfaces.islands.common'
local GetNoise = require 'utils.get_noise'
local BoatData = require 'maps.pirates.structures.boats.sloop.data'
local Balance = require 'maps.pirates.balance'
local ShopCovered = require 'maps.pirates.shop.covered'
local Classes = require 'maps.pirates.roles.classes'
local Public = {}
Public.Data = require 'maps.pirates.surfaces.islands.cave.data'
-- Code imported from cave_miner_v2 scenario for cave generation
local function spawn_market(args, is_main)
is_main = is_main or false
local destination_data = Common.current_destination()
--if not (destination_data and destination_data.dynamic_data and destination_data.dynamic_data.cave_miner) then return end
if not (destination_data and destination_data.dynamic_data) then return end
local offers = {}
if is_main then
offers = ShopCovered.market_generate_coin_offers(6)
if destination_data.static_params.class_for_sale then
offers[#offers+1] = {price={{'coin', Balance.class_cost(true)}}, offer={type="nothing", effect_description = {'pirates.market_description_purchase_class', Classes.display_form(destination_data.static_params.class_for_sale)}}}
end
offers[#offers+1] = {price = {{'coin', 200}}, offer = {type = 'give-item', item = 'small-lamp', count = 100}}
else
-- This doesn't really prevent markets spawning near each other, since markets aren't spawned immediately for a given chunk, but it helps a bit
local surface = destination_data.dynamic_data.cave_miner.cave_surface
local r = 64
if surface.count_entities_filtered({name = 'market', area = {{args.p.x - r, args.p.y - r}, {args.p.x + r, args.p.y + r}}}) > 0 then
return
end
offers = ShopCovered.market_generate_coin_offers(4)
end
args.specials[#args.specials + 1] = {name = 'market', position = args.p, offers = offers}
end
local function place_rock(args)
local a = (-49 + Math.random(0, 98)) * 0.01
local b = (-49 + Math.random(0, 98)) * 0.01
args.entities[#args.entities + 1] = IslandsCommon.random_rock_1({x = args.p.x + a, y = args.p.y + b})
end
local biomes = {}
function biomes.oasis(args, square_distance, noise)
local seed = args.seed
local position = args.p
if noise > 0.83 then
args.tiles[#args.tiles + 1] = {name = 'deepwater', position = args.p}
Public.Data.spawn_fish(args);
return
end
local noise_decoratives = GetNoise('decoratives', position, seed + 50000)
args.tiles[#args.tiles + 1] = {name = 'grass-1', position = args.p}
if Math.random(1, 16) == 1 and Math.abs(noise_decoratives) > 0.17 then
args.entities[#args.entities + 1] = {name = 'tree-04', position = args.p}
end
if Math.random(1, 50) == 1 then
args.entities[#args.entities + 1] = {name = 'crude-oil', position = args.p, amount = Balance.pick_default_oil_amount() * 2}
end
if noise < 0.73 then
place_rock(args)
end
end
function biomes.void(args)
args.tiles[#args.tiles + 1] = {name = 'out-of-map', position = args.p}
end
function biomes.pond_cave(args, square_distance, noise)
local seed = args.seed
local position = args.p
local noise_2 = GetNoise('cm_ponds', position, seed)
if Math.abs(noise_2) > 0.60 then
args.tiles[#args.tiles + 1] = {name = 'water', position = args.p}
Public.Data.spawn_fish(args);
return
end
if Math.abs(noise_2) > 0.25 then
place_rock(args)
return
end
if noise > -0.53 then
place_rock(args)
else
if Math.random(1, 512) == 1 then
spawn_market(args)
end
end
end
-- Spawn refers to the "middle of the map" where the market is located
function biomes.spawn(args, square_distance)
local seed = args.seed
local position = args.p
-- If coordinate iteration ever changes to xn instead of 0.5 + xn this will need to change
if Math.abs(position.x - 0.5) < 0.1 and Math.abs(position.y - 0.5) < 0.1 then
spawn_market(args, true)
end
local noise = GetNoise('decoratives', position, seed)
if Math.abs(noise) > 0.60 and square_distance < 900 and square_distance > 10 then
args.tiles[#args.tiles + 1] = {name = 'water', position = args.p}
Public.Data.spawn_fish(args);
return
end
if square_distance > 100 then
place_rock(args)
end
end
function biomes.ocean(args, square_distance, noise)
if noise > 0.66 then
args.tiles[#args.tiles + 1] = {name = 'deepwater', position = args.p}
Public.Data.spawn_fish(args);
return
end
if noise > 0.63 then
args.tiles[#args.tiles + 1] = {name = 'water', position = args.p}
Public.Data.spawn_fish(args);
return
end
place_rock(args)
end
function biomes.worm_desert(args, square_distance, noise)
local seed = args.seed
local position = args.p
local memory = Memory.get_crew_memory()
if noise > -0.65 then
place_rock(args)
return
end
local i = Math.floor((GetNoise('decoratives', position, seed) * 8) % 3) + 1
args.tiles[#args.tiles + 1] = {name = 'sand-' .. i, position = args.p}
if Math.random(1, 64) == 1 then
local name = Common.get_random_worm_type(memory.evolution_factor)
local force = memory.enemy_force_name
args.entities[#args.entities + 1] = {name = name, position = args.p, force = force}
return
end
if Math.random(1, 32) == 1 then
local n = GetNoise('decoratives', position, seed + 10000)
if n > 0.2 then
local trees = {'dead-grey-trunk', 'dead-grey-trunk', 'dry-tree'}
args.entities[#args.entities + 1] = {name = trees[Math.random(1, 3)], position = args.p}
return
end
end
if Math.random(1, 256) == 1 then
args.specials[#args.specials + 1] = {name = 'chest', position = args.p}
end
end
function biomes.cave(args, square_distance, noise)
local seed = args.seed
local position = args.p
local memory = Memory.get_crew_memory()
local noise_cave_rivers1 = GetNoise('cave_rivers_2', position, seed + 100000)
if Math.abs(noise_cave_rivers1) < 0.025 then
local noise_cave_rivers2 = GetNoise('cave_rivers_3', position, seed + 200000)
if noise_cave_rivers2 > 0 then
args.tiles[#args.tiles + 1] = {name = 'water-shallow', position = args.p}
Public.Data.spawn_fish(args);
return
end
end
local no_rocks_2 = GetNoise('no_rocks_2', position, seed)
if no_rocks_2 > 0.7 then
if no_rocks_2 > 0.73 then
if Math.random(1, 256) == 1 then
spawn_market(args)
end
end
args.tiles[#args.tiles + 1] = {name = 'dirt-' .. Math.floor(no_rocks_2 * 16) % 4 + 3, position = args.p}
return
end
if Math.abs(no_rocks_2) < 0.05 then
return
end
local noise_rock = GetNoise('small_caves', position, seed)
if noise_rock < 0.6 then
place_rock(args)
if Math.random(1, 512) == 1 then
args.specials[#args.specials + 1] = {name = 'chest', position = args.p}
end
return
end
if square_distance < 4096 then
return
end
if Math.random(1, 4096) == 1 then
spawn_market(args)
return
end
if Math.random(1, 64) == 1 then
local name
if Math.random(1, 2) == 1 then
name = 'biter-spawner'
else
name = 'spitter-spawner'
end
args.entities[#args.entities + 1] = {name = name, position = args.p, force = memory.enemy_force_name}
return
end
if Math.random(1, 64) == 1 then
local name = Common.get_random_worm_type(memory.evolution_factor)
local force = memory.enemy_force_name
args.entities[#args.entities + 1] = {name = name, position = args.p, force = force}
return
end
end
local function get_biome(args)
local position = args.p
local d = position.x ^ 2 + position.y ^ 2
local boat_height = Math.max(BoatData.height, 15) -- even if boat height is smaller, we need to be at least 10+ just so formulas below play out nicely
local spawn_radius = boat_height + 15
local entrance_radius = boat_height + 45
local river_width = boat_height + 40
-- Spawn location for market
if d < spawn_radius ^ 2 then
return biomes.spawn, d
end
-- River upon which ship arrives + ship entrance
if position.x < 0 and 2 * Math.abs(position.y) < river_width then
return biomes.void
end
-- Prevent cave expansion in west direction
-- NOTE: although "river_width ^ 2 - entrance_radius ^ 2" should never be "< 0", it's a small safe check
-- NOTE: the complex calculation here calculates wanted intersection of river and spawn area (or in other words line and circle intersection)
if position.x < 0 and -position.x + (river_width - Math.sqrt(Math.max(0, river_width ^ 2 - entrance_radius ^ 2))) > Math.abs(2 * position.y) then
return biomes.void
end
-- Actual cave generation below
local cm_ocean = GetNoise('cm_ocean', position, args.seed + 100000)
if cm_ocean > 0.6 then
return biomes.ocean, d, cm_ocean
end
local noise = GetNoise('cave_miner_01', position, args.seed)
local abs_noise = Math.abs(noise)
if abs_noise < 0.075 then
return biomes.cave, d, noise
end
if abs_noise > 0.25 then
noise = GetNoise('cave_rivers', position, args.seed)
if noise > 0.72 then
return biomes.oasis, d, noise
end
if cm_ocean < -0.6 then
return biomes.worm_desert, d, cm_ocean
end
if noise < -0.5 then
return biomes.pond_cave, d, noise
end
end
noise = GetNoise('cave_miner_02', position, args.seed)
if Math.abs(noise) < 0.085 then
return biomes.cave, d, noise
end
return biomes.void
end
function Public.terrain(args)
local biome, square_distance, noise = get_biome(args)
biome(args, square_distance, noise)
-- fallback case when no tiles were placed
if #args.tiles == 0 then
args.tiles[#args.tiles + 1] = {name = 'dirt-7', position = args.p}
end
end
function Public.chunk_structures(args)
end
-- Launching rocket in caves sounds silly (as well as hard to pick position for rocket)
function Public.generate_silo_setup_position(points_to_avoid)
end
return Public

@ -0,0 +1,36 @@
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/danielmartin0/ComfyFactorio-Pirates.
local Public = {}
Public.display_names = {{'pirates.location_displayname_cave_1'}}
Public.terraingen_frame_width = 640
Public.terraingen_frame_height = 640
Public.static_params_default = {
default_decoratives = true,
base_starting_treasure = 1000,
base_starting_rock_material = 800,
base_starting_wood = 1200,
base_starting_treasure_maps = 0,
starting_time_of_day = 0.43,
daynightcycletype = 1,
brightness_visual_weights = {0.92, 0.92, 0.92},
min_brightness = 0.08,
}
function Public.base_ores()
return {
['copper-ore'] = 0.7,
['iron-ore'] = 5.9,
['coal'] = 4.4,
['stone'] = 1.0,
}
end
function Public.spawn_fish(args)
if math.random(1, 16) == 1 then
args.entities[#args.entities + 1] = {name = 'fish', position = args.p}
end
end
return Public

@ -22,6 +22,8 @@ local enum = {
HORSESHOE = '7',
SWAMP = '8',
MAZE = '9',
CAVE = '10',
CAVE_SOURCE = '11', -- Used as extra layer for cave island
}
Public.enum = enum

@ -31,6 +31,8 @@ Public[enum.RED_DESERT] = require 'maps.pirates.surfaces.islands.red_desert.red_
Public[enum.HORSESHOE] = require 'maps.pirates.surfaces.islands.horseshoe.horseshoe'
Public[enum.SWAMP] = require 'maps.pirates.surfaces.islands.swamp.swamp'
Public[enum.MAZE] = require 'maps.pirates.surfaces.islands.maze.maze'
Public[enum.CAVE] = require 'maps.pirates.surfaces.islands.cave.cave'
Public[enum.CAVE_SOURCE] = require 'maps.pirates.surfaces.islands.cave.cave_source' -- Used as extra layer for cave island
Public['IslandsCommon'] = require 'maps.pirates.surfaces.islands.common'

@ -119,6 +119,16 @@ function Public.on_surface_generation(destination)
if subtype ~= Islands.enum.STANDARD and subtype ~= Islands.enum.STANDARD_VARIANT and subtype ~= Islands.enum.RADIOACTIVE and subtype ~= Islands.enum.RED_DESERT then
destination.dynamic_data.hidden_ore_remaining_abstract = Utils.deepcopy(destination.static_params.abstract_ore_amounts)
end
if subtype == Islands.enum.CAVE then
if not destination.dynamic_data.cave_miner then
destination.dynamic_data.cave_miner = {}
destination.dynamic_data.cave_miner.reveal_queue = {}
destination.dynamic_data.cave_miner.cave_surface = nil
Islands[Islands.enum.CAVE].roll_source_surface(destination)
end
end
destination.dynamic_data.wood_remaining = destination.static_params.starting_wood
destination.dynamic_data.rock_material_remaining = destination.static_params.starting_rock_material
destination.dynamic_data.treasure_remaining = destination.static_params.starting_treasure
@ -164,8 +174,11 @@ function Public.destination_on_collide(destination)
if destination.subtype == Islands.enum.RADIOACTIVE then
Common.parrot_speak(memory.force, {'pirates.parrot_radioactive_tip_1'})
else
elseif destination.subtype == Islands.enum.CAVE then
Common.parrot_speak(memory.force, {'pirates.parrot_cave_tip_1'})
else
local scheduled_raft_raids
-- temporarily placed this back here, as moving it to shorehit broke things:
local playercount = Common.activecrewcount()
@ -192,39 +205,42 @@ function Public.destination_on_collide(destination)
end
end
if memory.overworldx > 200 then
scheduled_raft_raids = {}
local times = {600, 360, 215, 210, 120, 30, 10, 5}
for i = 1, #times do
local t = times[i]
if Math.random(6) == 1 and #scheduled_raft_raids < 6 then
-- Currently biter boats don't spawn properly for cave island, so disabling it for now
if destination.subtype ~= Islands.enum.CAVE then
if memory.overworldx > 200 then
scheduled_raft_raids = {}
local times = {600, 360, 215, 210, 120, 30, 10, 5}
for i = 1, #times do
local t = times[i]
if Math.random(6) == 1 and #scheduled_raft_raids < 6 then
scheduled_raft_raids[#scheduled_raft_raids + 1] = {timeinseconds = t, max_evo = max_evo}
-- scheduled_raft_raids[#scheduled_raft_raids + 1] = {timeinseconds = t, max_bonus_evolution = 0.52}
end
end
elseif memory.overworldx == 200 then
local times
if playercount <= 2 then
times = {1, 5, 10, 15, 20}
elseif playercount <= 8 then
times = {1, 5, 10, 15, 20, 25}
elseif playercount <= 15 then
times = {1, 5, 10, 15, 20, 25, 30}
elseif playercount <= 21 then
times = {1, 5, 10, 15, 20, 25, 30, 35}
else
times = {1, 5, 10, 15, 20, 25, 30, 35, 40}
end
scheduled_raft_raids = {}
for _, t in pairs(times) do
-- scheduled_raft_raids[#scheduled_raft_raids + 1] = {timeinseconds = t, max_bonus_evolution = 0.62}
scheduled_raft_raids[#scheduled_raft_raids + 1] = {timeinseconds = t, max_evo = max_evo}
-- scheduled_raft_raids[#scheduled_raft_raids + 1] = {timeinseconds = t, max_bonus_evolution = 0.52}
end
end
elseif memory.overworldx == 200 then
local times
if playercount <= 2 then
times = {1, 5, 10, 15, 20}
elseif playercount <= 8 then
times = {1, 5, 10, 15, 20, 25}
elseif playercount <= 15 then
times = {1, 5, 10, 15, 20, 25, 30}
elseif playercount <= 21 then
times = {1, 5, 10, 15, 20, 25, 30, 35}
else
times = {1, 5, 10, 15, 20, 25, 30, 35, 40}
end
scheduled_raft_raids = {}
for _, t in pairs(times) do
-- scheduled_raft_raids[#scheduled_raft_raids + 1] = {timeinseconds = t, max_bonus_evolution = 0.62}
scheduled_raft_raids[#scheduled_raft_raids + 1] = {timeinseconds = t, max_evo = max_evo}
end
destination.static_params.scheduled_raft_raids = scheduled_raft_raids
end
destination.static_params.scheduled_raft_raids = scheduled_raft_raids
end
end
if memory.overworldx == 40*5 then
@ -266,7 +282,11 @@ function Public.destination_on_arrival(destination)
if destination.subtype ~= Islands.enum.FIRST and destination.subtype ~= Islands.enum.RADIOACTIVE and destination.destination_index ~= 2 then
-- if not destination.overworld_position.x ~= Common.first_cost_to_leave_macrox * 40 then
Quest.initialise_random_quest()
if destination.subtype == Islands.enum.CAVE then
Quest.initialise_random_cave_island_quest()
else
Quest.initialise_random_quest()
end
-- else
-- if _DEBUG then
-- Quest.initialise_random_quest()
@ -349,6 +369,16 @@ function Public.destination_on_arrival(destination)
end
end
if (memory.overworldx >= Balance.quest_structures_first_appear_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
end
-- Caves won't have these fancy things for now, because starting place for this island is so small, weird stuff happens (like quest structure spawning on ship)
if destination.subtype == Islands.enum.CAVE then
return
end
-- game.print('spawning silo')
if destination.subtype ~= Islands.enum.RADIOACTIVE then
local silo_position = Islands.spawn_silo_setup(points_to_avoid)
@ -360,9 +390,6 @@ function Public.destination_on_arrival(destination)
Islands.spawn_ores_on_arrival(destination, points_to_avoid)
if (memory.overworldx >= Balance.quest_structures_first_appear_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
local covered = Islands.spawn_quest_structure(destination, points_to_avoid)
if covered then
points_to_avoid[#points_to_avoid + 1] = {x = covered.x, y = covered.y, r = 25}
@ -372,7 +399,7 @@ function Public.destination_on_arrival(destination)
Islands.spawn_treasure_maps(destination, points_to_avoid)
Islands.spawn_ghosts(destination, points_to_avoid)
if destination.subtype and destination.subtype == Islands.enum.MAZE then
if destination.subtype == Islands.enum.MAZE then
local force = memory.force
force.manual_mining_speed_modifier = 1
end
@ -434,7 +461,7 @@ function Public.destination_on_crewboat_hits_shore(destination)
Common.parrot_speak(memory.force, {'pirates.parrot_maze_tip_1'})
end
if memory.merchant_ships_unlocked or _DEBUG then
if (memory.merchant_ships_unlocked or _DEBUG) and destination.subtype ~= Islands.enum.CAVE then
Islands.spawn_merchant_ship(destination)
ShopMerchants.generate_merchant_trades(destination.dynamic_data.merchant_market)
@ -484,7 +511,16 @@ function Public.generate_detailed_island_data(destination)
local p2 = {x = chunk_frameposition_topleft.x + x2, y = chunk_frameposition_topleft.y + y2}
local tiles3, entities3 = {}, {}
terrain_fn{p = p2, noise_generator = noise_generator, static_params = destination.static_params, tiles = tiles3, entities = entities3, decoratives = {}, seed = destination.seed, iconized_generation = true}
terrain_fn{
p = p2,
noise_generator = noise_generator,
static_params = destination.static_params,
tiles = tiles3,
entities = entities3,
decoratives = {},
seed = destination.seed,
iconized_generation = true
}
local tile = tiles3[1]
if modalcounts[tile.name] then
modalcounts[tile.name] = modalcounts[tile.name] + 1
@ -583,11 +619,20 @@ function Public.generate_detailed_island_data(destination)
-- get more precise understanding of left-hand shore
local xcorrection = 0
for ystep = -10, 10, 10 do
for xstep = 0,300,3 do
for xstep = 0, 300, 3 do
local x = leftboundary * 32 + 16 + xstep
local y = (topboundary*32 + bottomboundary*32)/2 + ystep
local tiles3 = {}
terrain_fn{p = {x = x, y = y}, noise_generator = noise_generator, static_params = destination.static_params, tiles = tiles3, entities = {}, decoratives = {}, seed = destination.seed, iconized_generation = true}
terrain_fn{
p = {x = x, y = y},
noise_generator = noise_generator,
static_params = destination.static_params,
tiles = tiles3,
entities = {},
decoratives = {},
seed = destination.seed,
iconized_generation = true
}
local tile = tiles3[1]
if (not Utils.contains(CoreData.water_tile_names, tile.name)) then
xcorrection = Math.max(xcorrection, xstep + Math.abs(ystep))
@ -713,6 +758,8 @@ function Public.clean_up(destination)
end
end
Islands[Islands.enum.CAVE].cleanup_cave_surface(destination)
destination.dynamic_data = {}
memory.scripted_biters = nil