1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-25 21:29:06 +02:00

Standardised island enum usage

Changes:
- Moved island enum to its own file to avoid dependency loops
- Standardised island enum usage to use IslandEnum.enum
This commit is contained in:
Piratux 2022-10-10 22:03:51 +03:00
parent f3f5f0a1b0
commit 9cda27df02
18 changed files with 103 additions and 88 deletions

View File

@ -14,7 +14,7 @@ local _inspect = require 'utils.inspect'.inspect
local Boats = require 'maps.pirates.structures.boats.boats'
local Surfaces = require 'maps.pirates.surfaces.surfaces'
local Islands = require 'maps.pirates.surfaces.islands.islands'
local IslandsCommon = require 'maps.pirates.surfaces.islands.common'
local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
-- local Sea = require 'maps.pirates.surfaces.sea.sea'
-- local Crew = require 'maps.pirates.crew'
-- local Quest = require 'maps.pirates.quest'
@ -61,7 +61,7 @@ function Public.Tick_actions(tickinterval)
end
-- if destination.subtype and destination.subtype == Islands.enum.RED_DESERT then return end -- This was a hack to stop biter boats causing attacks, but, it has the even worse effect of stopping all floating_pollution gathering.
-- if destination.subtype and destination.subtype == IslandEnum.enum.RED_DESERT then return end -- This was a hack to stop biter boats causing attacks, but, it has the even worse effect of stopping all floating_pollution gathering.
local minute_cycle = {-- warning: use even seconds only
@ -114,7 +114,7 @@ function Public.eat_up_fraction_of_all_pollution(surface, fraction_of_global_pol
surface.pollute(p, - pollution_to_eat)
-- Radioactive world doesn't absorb map pollution:
if not (Common.current_destination().subtype and Common.current_destination().subtype == Islands.enum.RADIOACTIVE) then
if not (Common.current_destination().subtype and Common.current_destination().subtype == IslandEnum.enum.RADIOACTIVE) then
pollution_available = pollution_available + pollution_to_eat
end
end
@ -411,7 +411,7 @@ function Public.try_spawner_spend_fraction_of_available_pollution_on_biters(spaw
if initial_spawner_count > 0 then
local spawnerscount = Common.spawner_count(surface)
if spawnerscount > 0 then
-- if Common.current_destination().subtype and Common.current_destination().subtype == Islands.enum.RADIOACTIVE then
-- if Common.current_destination().subtype and Common.current_destination().subtype == IslandEnum.enum.RADIOACTIVE then
-- -- destroying spawners doesn't do quite as much here:
-- base_pollution_cost_multiplier = (initial_spawner_count/spawnerscount)^(1/3)
-- else
@ -439,11 +439,11 @@ function Public.try_spawner_spend_fraction_of_available_pollution_on_biters(spaw
map_pollution_cost_multiplier = map_pollution_cost_multiplier * base_scripted_biters_pollution_cost_multiplier
if destination.subtype and destination.subtype == IslandsCommon.enum.SWAMP then
if destination.subtype and destination.subtype == IslandEnum.enum.SWAMP then
map_pollution_cost_multiplier = map_pollution_cost_multiplier * 0.95 --biters 5% more aggressive
end
-- if destination.subtype and destination.subtype == IslandsCommon.enum.MAZE then
-- if destination.subtype and destination.subtype == IslandEnum.enum.MAZE then
-- base_pollution_cost_multiplier = base_pollution_cost_multiplier * 1.2 --biters 20% less aggressive
-- end

View File

@ -14,7 +14,7 @@ local Ai = require 'maps.pirates.ai'
local Boats = require 'maps.pirates.structures.boats.boats'
local Surfaces = require 'maps.pirates.surfaces.surfaces'
-- local Progression = require 'maps.pirates.progression'
local Islands = require 'maps.pirates.surfaces.islands.islands'
local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
local Roles = require 'maps.pirates.roles.roles'
local Gui = require 'maps.pirates.gui.gui'
-- local Sea = require 'maps.pirates.surfaces.sea.sea'
@ -109,7 +109,7 @@ local function biters_chew_stuff_faster(event)
if (event.entity.force.index == 3 or event.entity.force.name == 'environment') then
event.entity.health = event.entity.health - event.final_damage_amount * 5
if destination and destination.type and destination.subtype and destination.type == Surfaces.enum.ISLAND and destination.subtype == Islands.enum.MAZE then
if destination and destination.type and destination.subtype and destination.type == Surfaces.enum.ISLAND and destination.subtype == IslandEnum.enum.MAZE then
event.entity.health = event.entity.health - event.final_damage_amount * 10
end
elseif event.entity.name == 'pipe' then
@ -528,7 +528,7 @@ local function swamp_resist_poison(event)
if not (event.damage_type.name and event.damage_type.name == 'poison') then return end
local destination = Common.current_destination()
if not (destination and destination.subtype and destination.subtype == Islands.enum.SWAMP) then return end
if not (destination and destination.subtype and destination.subtype == IslandEnum.enum.SWAMP) then return end
if not (destination.surface_name == entity.surface.name) then return end
@ -546,7 +546,7 @@ local function maze_walls_resistance(event)
if not entity.valid then return end
local destination = Common.current_destination()
if not (destination and destination.subtype and destination.subtype == Islands.enum.MAZE) then return end
if not (destination and destination.subtype and destination.subtype == IslandEnum.enum.MAZE) then return end
if not (destination.surface_name == entity.surface.name) then return end
@ -773,7 +773,7 @@ local function event_on_player_mined_entity(event)
if available and destination.type == Surfaces.enum.ISLAND then
if destination and destination.subtype and destination.subtype == Islands.enum.MAZE then
if destination and destination.subtype and destination.subtype == IslandEnum.enum.MAZE then
if Math.random(1, 38) == 1 then
tick_tack_trap(memory.enemy_force_name, entity.surface, entity.position)
return
@ -916,12 +916,12 @@ 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.subtype == Islands.enum.MAZE then
if destination.subtype == IslandEnum.enum.MAZE then
if Math.random(1, 35) == 1 then
tick_tack_trap(memory.enemy_force_name, entity.surface, entity.position)
end
elseif destination.subtype == Islands.enum.CAVE then
elseif destination.subtype == IslandEnum.enum.CAVE then
Ores.try_give_ore(player, entity.position, entity.name)
if Math.random(1, 35) == 1 then
@ -1037,7 +1037,7 @@ local function base_kill_rewards(event)
-- no worm loot in the maze except for chefs:
local maze = (destination.subtype and destination.subtype == Islands.enum.MAZE)
local maze = (destination.subtype and destination.subtype == IslandEnum.enum.MAZE)
if maze and not (entity_name == 'biter-spawner' or entity_name == 'spitter-spawner') and not (class_is_chef) then return end
local iron_amount

View File

@ -9,7 +9,7 @@ local Ai = require 'maps.pirates.ai'
local Structures = require 'maps.pirates.structures.structures'
local Boats = require 'maps.pirates.structures.boats.boats'
local Islands = require 'maps.pirates.surfaces.islands.islands'
local IslandsCommon = require 'maps.pirates.surfaces.islands.common'
local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
local Surfaces = require 'maps.pirates.surfaces.surfaces'
local PiratesApiEvents = require 'maps.pirates.api_events'
local Roles = require 'maps.pirates.roles.roles'
@ -134,7 +134,7 @@ function Public.check_all_spawners_dead(tickinterval)
local destination = Common.current_destination()
local boat = memory.boat
if destination.static_params and destination.static_params.base_cost_to_undock and (not (destination.subtype and destination.subtype == Islands.enum.RED_DESERT)) then
if destination.static_params and destination.static_params.base_cost_to_undock and (not (destination.subtype and destination.subtype == IslandEnum.enum.RED_DESERT)) then
if boat and boat.surface_name and boat.surface_name == destination.surface_name then
local surface = game.surfaces[destination.surface_name]
if not (surface and surface.valid) then return end
@ -310,7 +310,7 @@ function Public.periodic_free_resources(tickinterval)
Common.give_items_to_crew(Balance.periodic_free_resources_per_destination_5_seconds())
if game.tick % (300*30) == 0 and (destination and destination.subtype and destination.subtype == Islands.enum.RADIOACTIVE) then -- every 150 seconds
if game.tick % (300*30) == 0 and (destination and destination.subtype and destination.subtype == IslandEnum.enum.RADIOACTIVE) then -- every 150 seconds
local count = 2
Common.give_items_to_crew{{name = 'sulfuric-acid-barrel', count = count}}
local force = memory.force
@ -1033,7 +1033,7 @@ function Public.loading_update(tickinterval)
local total = Common.map_loading_ticks_atsea
if currentdestination.type == Surfaces.enum.DOCK then
total = Common.map_loading_ticks_atsea_dock
elseif currentdestination.type == Surfaces.enum.ISLAND and currentdestination.subtype == Surfaces.Island.enum.MAZE then
elseif currentdestination.type == Surfaces.enum.ISLAND and currentdestination.subtype == IslandEnum.enum.MAZE then
total = Common.map_loading_ticks_atsea_maze
end
@ -1053,7 +1053,7 @@ function Public.loading_update(tickinterval)
memory.loadingticks = 0
else
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
if currentdestination.subtype == IslandEnum.enum.CAVE then
PiratesApiEvents.load_some_map_chunks_random_order(currentdestination.dynamic_data.cave_miner.cave_surface, currentdestination, fraction)
end
end
@ -1192,7 +1192,7 @@ function Public.slower_boat_tick(tickinterval)
end
local p = memory.boat.position
if p and (not (destination.subtype and destination.subtype == IslandsCommon.enum.RADIOACTIVE)) and destination.surface_name and game.surfaces[destination.surface_name] and game.surfaces[destination.surface_name].valid then --no locomotive pollute on radioactive islands
if p and (not (destination.subtype and destination.subtype == IslandEnum.enum.RADIOACTIVE)) and destination.surface_name and game.surfaces[destination.surface_name] and game.surfaces[destination.surface_name].valid then --no locomotive pollute on radioactive islands
local pollution = Balance.boat_passive_pollution_per_minute(destination.dynamic_data.timer) / 3600 * tickinterval
game.surfaces[destination.surface_name].pollute(p, pollution)
@ -1240,7 +1240,7 @@ function Public.minimap_jam(tickinterval)
if memory.overworldx == Common.maze_minimap_jam_league and memory.boat and memory.boat.state == Boats.enum_state.LANDED then
local destination = Common.current_destination()
if destination.type == Surfaces.enum.ISLAND and destination.subtype == Surfaces.Island.enum.MAZE then
if destination.type == Surfaces.enum.ISLAND and destination.subtype == IslandEnum.enum.MAZE then
if not destination.surface_name then return end
local surface = game.surfaces[destination.surface_name]
local force = memory.force

View File

@ -12,6 +12,7 @@ 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 IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
-- local Structures = require 'maps.pirates.structures.structures'
local Boats = require 'maps.pirates.structures.boats.boats'
local Crowsnest = require 'maps.pirates.surfaces.crowsnest'
@ -594,7 +595,7 @@ function Public.disband_crew(donotprint)
game.delete_surface(game.surfaces[destination.surface_name])
end
Islands[Islands.enum.CAVE].cleanup_cave_surface(destination)
Islands[IslandEnum.enum.CAVE].cleanup_cave_surface(destination)
end
global_memory.crew_memories[id] = nil

View File

@ -26,6 +26,7 @@ local Surfaces = require 'maps.pirates.surfaces.surfaces'
local Roles = require 'maps.pirates.roles.roles'
local Event = require 'utils.event'
local CustomEvents = require 'maps.pirates.custom_events'
local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
local ComfyGui = require 'utils.gui'
ComfyGui.set_disabled_tab('Scoreboard', true)
@ -565,7 +566,7 @@ function Public.process_etaframe_update(player, flow1, bools)
local total = Common.map_loading_ticks_atsea
if destination.type == Surfaces.enum.DOCK then
total = Common.map_loading_ticks_atsea_dock
elseif destination.type == Surfaces.enum.ISLAND and destination.subtype == Surfaces.Island.enum.MAZE then
elseif destination.type == Surfaces.enum.ISLAND and destination.subtype == IslandEnum.enum.MAZE then
total = Common.map_loading_ticks_atsea_maze
end

View File

@ -30,20 +30,21 @@ local Upgrades = require 'maps.pirates.boat_upgrades'
local Kraken = require 'maps.pirates.surfaces.sea.kraken'
local Highscore = require 'maps.pirates.highscore'
local CustomEvents = require 'maps.pirates.custom_events'
local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
local NIL = 'none'
local DOCK = 'dock'
local FIRST = Surfaces.Island.enum.FIRST
local RED_DESERT = Surfaces.Island.enum.RED_DESERT
local SWAMP = Surfaces.Island.enum.SWAMP
local STANDARD = Surfaces.Island.enum.STANDARD
local WALKWAYS = Surfaces.Island.enum.WALKWAYS
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 FIRST = IslandEnum.enum.FIRST
local RED_DESERT = IslandEnum.enum.RED_DESERT
local SWAMP = IslandEnum.enum.SWAMP
local STANDARD = IslandEnum.enum.STANDARD
local WALKWAYS = IslandEnum.enum.WALKWAYS
local MAZE = IslandEnum.enum.MAZE
local RADIOACTIVE = IslandEnum.enum.RADIOACTIVE
local HORSESHOE = IslandEnum.enum.HORSESHOE
local STANDARD_VARIANT = IslandEnum.enum.STANDARD_VARIANT
local CAVE = IslandEnum.enum.CAVE
local A = {STANDARD_VARIANT, RED_DESERT, HORSESHOE, WALKWAYS}
local B = {NIL, NIL, NIL, STANDARD, STANDARD_VARIANT, RED_DESERT, HORSESHOE, WALKWAYS, CAVE}
@ -226,7 +227,7 @@ function Public.generate_destination_base_cost_to_undock(p, subtype)
end
end
-- override:
if subtype == Surfaces.Island.enum.RADIOACTIVE then
if subtype == IslandEnum.enum.RADIOACTIVE then
base_cost_to_undock = {
['uranium-235'] = Math.ceil(Math.ceil(80 + (macro_p.x - 1))),
-- ['uranium-235'] = Math.ceil(Math.ceil(80 + (macro_p.x)/2)), --tried adding beacons instead of this
@ -599,7 +600,7 @@ 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])
Islands[IslandEnum.enum.CAVE].cleanup_cave_surface(memory.destinations[i])
memory.destinations[i] = nil
end

View File

@ -9,6 +9,7 @@ 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 IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
local _inspect = require 'utils.inspect'.inspect
@ -113,8 +114,7 @@ end
function Public.initialise_find_quest()
local destination = Common.current_destination()
-- @FIXME: Magic numbers
if destination.subtype and destination.subtype == '1' or destination.subtype == '5' or destination.subtype == '6' then
if destination.subtype == IslandEnum.enum.STANDARD or destination.subtype == IslandEnum.enum.RADIOACTIVE or destination.subtype == IslandEnum.enum.STANDARD_VARIANT then
destination.dynamic_data.quest_type = enum.FIND
destination.dynamic_data.quest_reward = Public.quest_reward()
@ -136,6 +136,7 @@ end
function Public.initialise_nodamage_quest()
local destination = Common.current_destination()
-- @FIXME: this if check looks ill-formed when destination is nil
if not destination and destination.dynamic_data and destination.dynamic_data.rocketsilomaxhp then return false end
destination.dynamic_data.quest_type = enum.NODAMAGE

View File

@ -17,6 +17,7 @@ local _inspect = require 'utils.inspect'.inspect
local Public = {}
-- What is this even for?
local enum = {
TIME = 'Time',
}

View File

@ -9,7 +9,7 @@ local CoreData = require 'maps.pirates.coredata'
local Utils = require 'maps.pirates.utils_local'
local _inspect = require 'utils.inspect'.inspect
-- local CustomEvents = require 'maps.pirates.custom_events'
local IslandsCommon = require 'maps.pirates.surfaces.islands.common'
local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
-- local Raffle = require 'maps.pirates.raffle'
-- local ShopCovered = require 'maps.pirates.shop.covered'
-- local Classes = require 'maps.pirates.roles.classes'
@ -33,7 +33,7 @@ function Public.choose_quest_structure_type()
local rng = Math.random(3)
if rng == 1 or subtype and subtype == IslandsCommon.enum.WALKWAYS then
if rng == 1 or subtype and subtype == IslandEnum.enum.WALKWAYS then
return enum.MARKET1
else

View File

@ -8,6 +8,7 @@ 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 IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
local Public = {}
Public.Data = require 'maps.pirates.surfaces.islands.cave.data'
@ -123,8 +124,7 @@ function Public.roll_source_surface(destination_data)
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')
local cave_surface_name = SurfacesCommon.encode_surface_name(island_surface_name.crewid, island_surface_name.destination_index, island_surface_name.type, IslandEnum.enum.CAVE_SOURCE)
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)
@ -211,8 +211,7 @@ local function on_player_changed_position(event)
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
if not (destination_data and destination_data.subtype == IslandEnum.enum.CAVE) then return end
local cave_miner = destination_data.dynamic_data.cave_miner

View File

@ -8,24 +8,13 @@ local Structures = require 'maps.pirates.structures.structures'
local Common = require 'maps.pirates.common'
-- local Utils = require 'maps.pirates.utils_local'
-- local Ores = require 'maps.pirates.ores'
local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
local _inspect = require 'utils.inspect'.inspect
local Public = {}
local enum = {
STANDARD = '1',
FIRST = '2',
WALKWAYS = '3',
RED_DESERT = '4',
RADIOACTIVE = '5',
STANDARD_VARIANT = '6',
HORSESHOE = '7',
SWAMP = '8',
MAZE = '9',
CAVE = '10',
CAVE_SOURCE = '11', -- Used as extra layer for cave island
}
Public.enum = enum
Public.enum = IslandEnum.enum
function Public.place_water_tile(args)

View File

@ -0,0 +1,18 @@
local Public = {}
local enum = {
STANDARD = '1',
FIRST = '2',
WALKWAYS = '3',
RED_DESERT = '4',
RADIOACTIVE = '5',
STANDARD_VARIANT = '6',
HORSESHOE = '7',
SWAMP = '8',
MAZE = '9',
CAVE = '10',
CAVE_SOURCE = '11', -- Used as extra layer for cave island
}
Public.enum = enum
return Public

View File

@ -9,7 +9,6 @@ local Boats = require 'maps.pirates.structures.boats.boats'
local Common = require 'maps.pirates.common'
local CoreData = require 'maps.pirates.coredata'
local Utils = require 'maps.pirates.utils_local'
local IslandsCommon = require 'maps.pirates.surfaces.islands.common'
local Hunt = require 'maps.pirates.surfaces.islands.hunt'
local Ores = require 'maps.pirates.ores'
local Quest = require 'maps.pirates.quest'
@ -17,10 +16,10 @@ local _inspect = require 'utils.inspect'.inspect
local Token = require 'utils.token'
local Task = require 'utils.task'
local QuestStructures = require 'maps.pirates.structures.quest_structures.quest_structures'
local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
local Public = {}
local enum = IslandsCommon.enum
Public.enum = enum
local enum = IslandEnum.enum
Public[enum.FIRST] = require 'maps.pirates.surfaces.islands.first.first'
Public[enum.STANDARD] = require 'maps.pirates.surfaces.islands.standard.standard'

View File

@ -12,6 +12,7 @@ local Utils = require 'maps.pirates.utils_local'
local _inspect = require 'utils.inspect'.inspect
-- local Ores = require 'maps.pirates.ores'
local IslandsCommon = require 'maps.pirates.surfaces.islands.common'
local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
-- local Hunt = require 'maps.pirates.surfaces.islands.hunt'
local Public = {}
@ -269,7 +270,7 @@ local function radioactive_tick()
local tickinterval = 60
if destination.subtype == IslandsCommon.enum.RADIOACTIVE then
if destination.subtype == IslandEnum.enum.RADIOACTIVE then
-- faster evo (doesn't need difficulty scaling as higher difficulties have higher base evo):
local extra_evo = 0.22 * tickinterval/60 / Balance.expected_time_on_island()
Common.increment_evo(extra_evo)

View File

@ -12,6 +12,7 @@ local Utils = require 'maps.pirates.utils_local'
local _inspect = require 'utils.inspect'.inspect
-- local Ores = require 'maps.pirates.ores'
local IslandsCommon = require 'maps.pirates.surfaces.islands.common'
local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
local Hunt = require 'maps.pirates.surfaces.islands.hunt'
local Public = {}
@ -226,7 +227,7 @@ local function red_desert_tick()
local memory = Memory.get_crew_memory()
local destination = Common.current_destination()
if destination.subtype == IslandsCommon.enum.RED_DESERT then
if destination.subtype == IslandEnum.enum.RED_DESERT then
if memory.boat and memory.boat.surface_name and memory.boat.surface_name == destination.surface_name then
Public.underground_worms_ai()

View File

@ -10,6 +10,7 @@ local Common = require 'maps.pirates.common'
local _inspect = require 'utils.inspect'.inspect
local Ores = require 'maps.pirates.ores'
local IslandsCommon = require 'maps.pirates.surfaces.islands.common'
local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
local Hunt = require 'maps.pirates.surfaces.islands.hunt'
local Public = {}
@ -187,7 +188,7 @@ local function swamp_tick()
local memory = Memory.get_crew_memory()
local destination = Common.current_destination()
if destination.subtype and destination.subtype == IslandsCommon.enum.SWAMP then
if destination.subtype == IslandEnum.enum.SWAMP then
if memory.boat and memory.boat.surface_name and memory.boat.surface_name == destination.surface_name then
local surface = game.surfaces[destination.surface_name]
if not (surface and surface.valid) then return end

View File

@ -12,6 +12,7 @@ local _inspect = require 'utils.inspect'.inspect
-- local Data = require 'maps.pirates.surfaces.islands.walkways.data'
local Ores = require 'maps.pirates.ores'
local IslandsCommon = require 'maps.pirates.surfaces.islands.common'
local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
local Hunt = require 'maps.pirates.surfaces.islands.hunt'
local Public = {}
@ -144,7 +145,7 @@ local function walkways_tick()
local memory = Memory.get_crew_memory()
local destination = Common.current_destination()
if destination.subtype and destination.subtype == IslandsCommon.enum.WALKWAYS then
if destination.subtype == IslandEnum.enum.WALKWAYS then
for _, player in pairs(game.connected_players) do
if player.force.name == memory.force_name and player.surface == game.surfaces[destination.surface_name] and player.character and player.character.valid and game.surfaces[destination.surface_name].get_tile(player.position).name == 'water-shallow' then
player.character.damage(12, game.forces['environment'], 'fire')

View File

@ -22,6 +22,7 @@ local ShopMerchants = require 'maps.pirates.shop.merchants'
local SurfacesCommon = require 'maps.pirates.surfaces.common'
-- local Roles = require 'maps.pirates.roles.roles'
local Classes = require 'maps.pirates.roles.classes'
local IslandEnum = require 'maps.pirates.surfaces.islands.island_enum'
local Server = require 'utils.server'
@ -116,16 +117,16 @@ function Public.on_surface_generation(destination)
destination.dynamic_data.silocharged = false
destination.dynamic_data.rocketlaunched = false
if subtype ~= Islands.enum.STANDARD and subtype ~= Islands.enum.STANDARD_VARIANT and subtype ~= Islands.enum.RADIOACTIVE and subtype ~= Islands.enum.RED_DESERT then
if subtype ~= IslandEnum.enum.STANDARD and subtype ~= IslandEnum.enum.STANDARD_VARIANT and subtype ~= IslandEnum.enum.RADIOACTIVE and subtype ~= IslandEnum.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 subtype == IslandEnum.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)
Islands[IslandEnum.enum.CAVE].roll_source_surface(destination)
end
end
@ -172,10 +173,10 @@ function Public.destination_on_collide(destination)
if destination.subtype == Islands.enum.RADIOACTIVE then
if destination.subtype == IslandEnum.enum.RADIOACTIVE then
Common.parrot_speak(memory.force, {'pirates.parrot_radioactive_tip_1'})
elseif destination.subtype == Islands.enum.CAVE then
elseif destination.subtype == IslandEnum.enum.CAVE then
Common.parrot_speak(memory.force, {'pirates.parrot_cave_tip_1'})
else
@ -207,7 +208,7 @@ function Public.destination_on_collide(destination)
-- Currently biter boats don't spawn properly for cave island, so disabling it for now
if destination.subtype ~= Islands.enum.CAVE then
if destination.subtype ~= IslandEnum.enum.CAVE then
if memory.overworldx > 200 then
scheduled_raft_raids = {}
local times = {600, 360, 215, 210, 120, 30, 10, 5}
@ -272,17 +273,17 @@ function Public.destination_on_arrival(destination)
destination.dynamic_data.rocketsiloenergyneeded = Balance.silo_energy_needed_MJ() * 1000000
destination.dynamic_data.rocketcoalreward = Balance.rocket_launch_fuel_reward()
if destination.subtype == Islands.enum.RADIOACTIVE then
if destination.subtype == IslandEnum.enum.RADIOACTIVE then
destination.dynamic_data.time_remaining = -1
elseif destination.subtype == Islands.enum.MAZE then --more time
elseif destination.subtype == IslandEnum.enum.MAZE then --more time
destination.dynamic_data.time_remaining = Math.ceil(1.05 * Balance.max_time_on_island())
else
destination.dynamic_data.time_remaining = Math.ceil(Balance.max_time_on_island())
end
if destination.subtype ~= Islands.enum.FIRST and destination.subtype ~= Islands.enum.RADIOACTIVE and destination.destination_index ~= 2 then
if destination.subtype ~= IslandEnum.enum.FIRST and destination.subtype ~= IslandEnum.enum.RADIOACTIVE and destination.destination_index ~= 2 then
-- if not destination.overworld_position.x ~= Common.first_cost_to_leave_macrox * 40 then
if destination.subtype == Islands.enum.CAVE then
if destination.subtype == IslandEnum.enum.CAVE then
Quest.initialise_random_cave_island_quest()
else
Quest.initialise_random_quest()
@ -298,12 +299,12 @@ function Public.destination_on_arrival(destination)
Common.set_evo(base_evo)
destination.dynamic_data.evolution_accrued_leagues = base_evo
destination.dynamic_data.evolution_accrued_time = 0
if destination.subtype == Islands.enum.RED_DESERT then
if destination.subtype == IslandEnum.enum.RED_DESERT then
destination.dynamic_data.evolution_accrued_sandwurms = 0
else
destination.dynamic_data.evolution_accrued_nests = 0
end
if destination.subtype ~= Islands.enum.RADIOACTIVE then
if destination.subtype ~= IslandEnum.enum.RADIOACTIVE then
destination.dynamic_data.evolution_accrued_silo = 0
end
@ -311,8 +312,8 @@ function Public.destination_on_arrival(destination)
memory.scripted_unit_groups = {}
memory.floating_pollution = 0
if destination.subtype == Islands.enum.RADIOACTIVE then
Islands[Islands.enum.RADIOACTIVE].spawn_structures()
if destination.subtype == IslandEnum.enum.RADIOACTIVE then
Islands[IslandEnum.enum.RADIOACTIVE].spawn_structures()
end
-- -- invulnerable bases on islands 21-25
-- if memory.overworldx >= 21 and memory.overworldx < 25 then
@ -369,18 +370,18 @@ 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
if (memory.overworldx >= Balance.quest_structures_first_appear_at and destination.subtype ~= IslandEnum.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
if destination.subtype == IslandEnum.enum.CAVE then
return
end
-- game.print('spawning silo')
if destination.subtype ~= Islands.enum.RADIOACTIVE then
if destination.subtype ~= IslandEnum.enum.RADIOACTIVE then
local silo_position = Islands.spawn_silo_setup(points_to_avoid)
if silo_position then
points_to_avoid[#points_to_avoid + 1] = {x = silo_position.x, y = silo_position.y, r = 22}
@ -389,7 +390,7 @@ 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
if (memory.overworldx >= Balance.quest_structures_first_appear_at and destination.subtype ~= IslandEnum.enum.RADIOACTIVE) or _DEBUG then
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}
@ -399,7 +400,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 == Islands.enum.MAZE then
if destination.subtype == IslandEnum.enum.MAZE then
local force = memory.force
force.manual_mining_speed_modifier = 1
end
@ -416,7 +417,7 @@ function Public.destination_on_departure(destination)
Common.parrot_speak(memory.force, {'pirates.parrot_kraken_warning'})
end
if destination.subtype and destination.subtype == Islands.enum.MAZE then
if destination.subtype and destination.subtype == IslandEnum.enum.MAZE then
local force = memory.force
force.manual_mining_speed_modifier = 3 --put back to normal
end
@ -445,7 +446,7 @@ function Public.destination_on_crewboat_hits_shore(destination)
Common.parrot_speak(memory.force, {'pirates.parrot_night_warning'})
end
if destination.subtype == Islands.enum.RADIOACTIVE then
if destination.subtype == IslandEnum.enum.RADIOACTIVE then
-- replace all miners, so that they sit on uranium properly:
local surface = game.surfaces[destination.surface_name]
local miners = surface.find_entities_filtered({name = 'electric-mining-drill'})
@ -457,11 +458,11 @@ function Public.destination_on_crewboat_hits_shore(destination)
end
Common.parrot_speak(memory.force, {'pirates.parrot_radioactive_tip_2'})
elseif destination.subtype == Islands.enum.MAZE and memory.overworldx == Common.maze_minimap_jam_league then
elseif destination.subtype == IslandEnum.enum.MAZE and memory.overworldx == Common.maze_minimap_jam_league then
Common.parrot_speak(memory.force, {'pirates.parrot_maze_tip_1'})
end
if (memory.merchant_ships_unlocked or _DEBUG) and destination.subtype ~= Islands.enum.CAVE then
if (memory.merchant_ships_unlocked or _DEBUG) and destination.subtype ~= IslandEnum.enum.CAVE then
Islands.spawn_merchant_ship(destination)
ShopMerchants.generate_merchant_trades(destination.dynamic_data.merchant_market)
@ -758,7 +759,7 @@ function Public.clean_up(destination)
end
end
Islands[Islands.enum.CAVE].cleanup_cave_surface(destination)
Islands[IslandEnum.enum.CAVE].cleanup_cave_surface(destination)
destination.dynamic_data = {}