2022-03-19 21:20:55 +00:00
--luacheck: ignore
--luacheck ignores because mass requires is a code templating choice...
2021-10-13 09:21:53 +01:00
local Color = require ' utils.color_presets '
local Server = require ' utils.server '
local Math = require ' maps.pirates.math '
local Ai = require ' maps.pirates.ai '
local Memory = require ' maps.pirates.memory '
local Gui = require ' maps.pirates.gui.gui '
local Common = require ' maps.pirates.common '
local CoreData = require ' maps.pirates.coredata '
local PlayerColors = require ' maps.pirates.player_colors '
local Utils = require ' maps.pirates.utils_local '
local Balance = require ' maps.pirates.balance '
local Crew = require ' maps.pirates.crew '
local Roles = require ' maps.pirates.roles.roles '
local Structures = require ' maps.pirates.structures.structures '
local Boats = require ' maps.pirates.structures.boats.boats '
local Surfaces = require ' maps.pirates.surfaces.surfaces '
local Overworld = require ' maps.pirates.overworld '
local Islands = require ' maps.pirates.surfaces.islands.islands '
local Progression = require ' maps.pirates.progression '
local Crowsnest = require ' maps.pirates.surfaces.crowsnest '
local Hold = require ' maps.pirates.surfaces.hold '
local Interface = require ' maps.pirates.interface '
local Upgrades = require ' maps.pirates.boat_upgrades '
local Effects = require ' maps.pirates.effects '
local Kraken = require ' maps.pirates.surfaces.sea.kraken '
2022-03-19 21:20:55 +00:00
local _inspect = require ' utils.inspect ' . inspect
2021-10-13 09:21:53 +01:00
local simplex_noise = require ' utils.simplex_noise ' . d2
local Token = require ' utils.token '
local Task = require ' utils.task '
local Highscore = require ' maps.pirates.highscore '
2022-03-13 01:44:32 +00:00
local CustomEvents = require ' maps.pirates.custom_events '
2022-03-13 18:19:59 +00:00
local Classes = require ' maps.pirates.roles.classes '
2021-10-13 09:21:53 +01:00
2022-02-25 00:01:28 +00:00
local GUIcolor = require ' maps.pirates.gui.color '
2021-10-13 09:21:53 +01:00
commands.add_command (
' ok ' ,
2022-03-08 23:36:03 +00:00
' is used to accept captainhood. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
2022-02-26 18:25:48 +00:00
local player = game.players [ cmd.player_index ]
2021-10-13 09:21:53 +01:00
if not Common.validate_player ( player ) then return end
local crew_id = tonumber ( string.sub ( game.players [ cmd.player_index ] . force.name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
2022-03-01 15:57:23 +00:00
Roles.player_confirm_captainhood ( player )
2021-10-13 09:21:53 +01:00
end )
2022-02-27 16:42:25 +00:00
-- Disabled for information-flow reasons:
-- commands.add_command(
-- 'classes',
-- 'Prints the available classes in the game.',
-- function(cmd)
-- local player = game.players[cmd.player_index]
-- if not Common.validate_player(player) then return end
-- player.print('[color=gray]' .. Roles.get_classes_print_string() .. '[/color]')
-- end)
commands.add_command (
2022-03-13 18:19:59 +00:00
' classinfo ' ,
2022-03-08 23:36:03 +00:00
' {classname} returns the definition of the named class. ' ,
2022-02-27 16:42:25 +00:00
function ( cmd )
local param = tostring ( cmd.parameter )
local player = game.players [ cmd.player_index ]
if not Common.validate_player ( player ) then return end
if param and param ~= ' nil ' then
local string = Roles.get_class_print_string ( param )
if string then
Common.notify_player_expected ( player , ' Class definition for ' .. string )
else
2022-03-13 18:19:59 +00:00
Common.notify_player_error ( player , ' Command error: Class \' ' .. param .. ' \' not found. ' )
2022-02-27 16:42:25 +00:00
end
else
2022-03-13 18:19:59 +00:00
Common.notify_player_expected ( player , ' /classinfo {classname} returns the definition of the named class. ' )
end
end )
commands.add_command (
' take ' ,
' {classname} takes a spare class with the given name for yourself. ' ,
function ( cmd )
local param = tostring ( cmd.parameter )
local player = game.players [ cmd.player_index ]
if not Common.validate_player ( player ) then return end
if param and param ~= ' nil ' then
for _ , class in ipairs ( Classes.Class_List ) do
if Classes.display_form [ class ] : lower ( ) == param : lower ( ) then
Classes.assign_class ( player.index , class , true )
return true
end
end
--fallthrough:
Common.notify_player_error ( player , ' Command error: Class \' ' .. param .. ' \' not found. ' )
return false
else
Common.notify_player_expected ( player , ' /take {classname} takes a spare class with the given name for yourself. ' )
end
end )
commands.add_command (
' giveup ' ,
' gives up your current class, making it available for others. ' ,
function ( cmd )
local param = tostring ( cmd.parameter )
local player = game.players [ cmd.player_index ]
if not Common.validate_player ( player ) then return end
if param and param == ' nil ' then
2022-03-14 12:44:30 +00:00
Classes.try_renounce_class ( player , true )
2022-03-13 18:19:59 +00:00
else
Common.notify_player_error ( player , ' Command error: parameter not needed. ' )
2022-02-27 16:42:25 +00:00
end
end )
2021-10-13 09:21:53 +01:00
commands.add_command (
' ccolor ' ,
2022-03-08 23:36:03 +00:00
' is an extension to the built-in /color command, with more colors. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
local player_index = cmd.player_index
if player_index then
local player = game.players [ player_index ]
if player and player.valid then
2022-02-24 19:39:03 +00:00
if cmd.parameter then
2022-02-25 00:01:28 +00:00
if PlayerColors.colors [ param ] then
2022-02-25 00:15:32 +00:00
local rgb = PlayerColors.colors [ param ]
player.color = rgb
player.chat_color = rgb
2022-03-11 22:53:36 +00:00
local message = ' [color= ' .. rgb.r .. ' , ' .. rgb.g .. ' , ' .. rgb.b .. ' ] ' .. player.name .. ' chose the color ' .. param .. ' [/color] (via /ccolor). '
2022-02-27 16:42:25 +00:00
Common.notify_game ( message )
2022-02-24 19:39:03 +00:00
else
2022-03-13 18:19:59 +00:00
Common.notify_player_error ( player , ' Command error: Color \' ' .. param .. ' \' not found. ' )
2022-02-24 19:39:03 +00:00
end
2021-10-13 09:21:53 +01:00
else
2022-03-11 22:53:36 +00:00
local color = PlayerColors.bright_color_names [ Math.random ( # PlayerColors.bright_color_names ) ]
2022-02-25 00:15:32 +00:00
local rgb = PlayerColors.colors [ color ]
2022-02-26 13:55:36 +00:00
if not rgb then return end
2022-02-25 00:15:32 +00:00
player.color = rgb
player.chat_color = rgb
2022-03-14 12:44:30 +00:00
local message = ' [color= ' .. rgb.r .. ' , ' .. rgb.g .. ' , ' .. rgb.b .. ' ] ' .. player.name .. ' \' s color randomized to ' .. color .. ' [/color] (via /ccolor). ' --'randomly became' was amusing, but let's not
2022-02-27 16:42:25 +00:00
Common.notify_game ( message )
2022-02-25 00:01:28 +00:00
-- disabled due to lag:
-- GUIcolor.toggle_window(player)
2021-10-13 09:21:53 +01:00
end
end
end
end )
local go_2 = Token.register (
function ( data )
Memory.set_working_id ( 1 )
local memory = Memory.get_crew_memory ( )
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01:00
memory.mapbeingloadeddestination_index = 1
memory.loadingticks = 0
2022-03-07 18:41:42 +00:00
local surface = game.surfaces [ Common.current_destination ( ) . surface_name ]
-- surface.request_to_generate_chunks({x = 0, y = 0}, 10)
-- surface.force_generate_chunk_requests()
2021-10-13 09:21:53 +01:00
Progression.go_from_starting_dock_to_first_destination ( )
end
)
local go_1 = Token.register (
function ( data )
Memory.set_working_id ( 1 )
local memory = Memory.get_crew_memory ( )
Overworld.ensure_lane_generated_up_to ( 0 , Crowsnest.Data . visibilitywidth / 2 )
Overworld.ensure_lane_generated_up_to ( 24 , Crowsnest.Data . visibilitywidth / 2 )
Overworld.ensure_lane_generated_up_to ( - 24 , Crowsnest.Data . visibilitywidth / 2 )
memory.currentdestination_index = 1
2022-03-13 01:44:32 +00:00
script.raise_event ( CustomEvents.enum [ ' update_crew_progress_gui ' ] , { } )
2021-10-13 09:21:53 +01:00
Surfaces.create_surface ( Common.current_destination ( ) )
Task.set_timeout_in_ticks ( 60 , go_2 , { } )
end
)
2022-02-26 18:25:48 +00:00
local function check_admin ( cmd )
local Session = require ' utils.datastore.session_data '
2022-03-08 23:36:03 +00:00
local player = game.players [ cmd.player_index ]
2022-02-26 18:25:48 +00:00
local trusted = Session.get_trusted_table ( )
local p
if player then
if player ~= nil then
p = player.print
if not player.admin then
2022-03-08 23:36:03 +00:00
p ( ' [ERROR] Only admins are allowed to run this command! ' , Color.fail )
return false
end
else
p = log
end
end
return true
end
local function check_captain ( cmd )
2022-03-13 18:19:59 +00:00
local player = game.players [ cmd.player_index ]
local p
if player then
if player ~= nil then
p = player.print
if not Common.validate_player ( player ) then return end
local crew_id = tonumber ( string.sub ( game.players [ cmd.player_index ] . force.name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
if not ( Roles.player_privilege_level ( player ) >= Roles.privilege_levels . CAPTAIN ) then
p ( ' [ERROR] Only captains are allowed to run this command! ' , Color.fail )
return false
end
else
p = log
end
end
return true
end
local function check_captain_or_admin ( cmd )
2022-03-08 23:36:03 +00:00
local player = game.players [ cmd.player_index ]
local p
if player then
if player ~= nil then
p = player.print
if not Common.validate_player ( player ) then return end
local crew_id = tonumber ( string.sub ( game.players [ cmd.player_index ] . force.name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
if not ( player.admin or Roles.player_privilege_level ( player ) >= Roles.privilege_levels . CAPTAIN ) then
p ( ' [ERROR] Only captains are allowed to run this command! ' , Color.fail )
2022-02-26 18:25:48 +00:00
return false
2021-10-13 09:21:53 +01:00
end
2022-02-26 18:25:48 +00:00
else
p = log
2021-10-13 09:21:53 +01:00
end
2022-02-26 18:25:48 +00:00
end
return true
end
2021-10-13 09:21:53 +01:00
2022-02-26 18:25:48 +00:00
local function check_trusted ( cmd )
local Session = require ' utils.datastore.session_data '
2022-03-08 23:36:03 +00:00
local player = game.players [ cmd.player_index ]
2022-02-26 18:25:48 +00:00
local trusted = Session.get_trusted_table ( )
local p
if player then
if player ~= nil then
p = player.print
if not ( trusted [ player.name ] or player.admin ) then
p ( ' [ERROR] Only admins and trusted weebs are allowed to run this command! ' , Color.fail )
return false
end
else
p = log
2021-10-13 09:21:53 +01:00
end
2022-02-26 18:25:48 +00:00
end
return true
end
2021-10-13 09:21:53 +01:00
2022-03-04 17:57:58 +00:00
commands.add_command (
' set_max_crews ' ,
2022-03-08 23:36:03 +00:00
' is an admin command to set the maximum number of concurrent crews allowed on the server. ' ,
2022-03-04 17:57:58 +00:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local global_memory = Memory.get_global_memory ( )
2022-03-10 22:11:51 +00:00
if tonumber ( param ) then
global_memory.active_crews_cap = tonumber ( param )
Common.notify_player_expected ( player , ' The maximum number of concurrent crews has been set to ' .. param .. ' . ' )
end
2022-03-04 17:57:58 +00:00
end
end )
2022-03-08 23:36:03 +00:00
2022-02-28 16:36:46 +00:00
commands.add_command (
2022-03-08 23:36:03 +00:00
' plank ' ,
' is a captain command to remove a player by making them a spectator. ' ,
2022-02-28 16:36:46 +00:00
function ( cmd )
2022-03-08 23:36:03 +00:00
local player = game.players [ cmd.player_index ]
local param = tostring ( cmd.parameter )
2022-03-13 18:19:59 +00:00
if check_captain_or_admin ( cmd ) then
2022-03-08 23:36:03 +00:00
if param and game.players [ param ] and game.players [ param ] . index then
Crew.plank ( player , game.players [ param ] )
else
2022-03-13 18:19:59 +00:00
Common.notify_player_error ( player , ' Command error: Invalid player name. ' )
2022-03-08 23:36:03 +00:00
end
2022-02-28 16:36:46 +00:00
end
end )
2022-03-08 23:36:03 +00:00
commands.add_command (
' officer ' ,
2022-03-11 22:53:36 +00:00
' is a captain command to make a player into an officer, or remove them as one. ' ,
2022-03-08 23:36:03 +00:00
function ( cmd )
local player = game.players [ cmd.player_index ]
local param = tostring ( cmd.parameter )
2022-03-13 18:19:59 +00:00
if check_captain_or_admin ( cmd ) then
2022-03-08 23:36:03 +00:00
local memory = Memory.get_crew_memory ( )
if param and game.players [ param ] and game.players [ param ] . index then
if memory.officers_table and memory.officers_table [ game.players [ param ] . index ] then
Roles.unmake_officer ( player , game.players [ param ] )
else
Roles.make_officer ( player , game.players [ param ] )
end
else
2022-03-13 18:19:59 +00:00
Common.notify_player_error ( player , ' Command error: Invalid player name. ' )
2022-03-08 23:36:03 +00:00
end
end
end )
2022-02-28 16:36:46 +00:00
2022-03-11 22:53:36 +00:00
commands.add_command (
' undock ' ,
' is a captain command to undock the ship. ' ,
function ( cmd )
local param = tostring ( cmd.parameter )
2022-03-13 18:19:59 +00:00
if check_captain_or_admin ( cmd ) then
2022-03-11 22:53:36 +00:00
local player = game.players [ cmd.player_index ]
local memory = Memory.get_crew_memory ( )
if memory.boat . state == Boats.enum_state . DOCKED then
2022-03-12 11:51:11 +00:00
Progression.undock_from_dock ( true )
2022-03-11 22:53:36 +00:00
elseif memory.boat . state == Boats.enum_state . LANDED then
2022-03-14 12:44:30 +00:00
Progression.try_retreat_from_island ( player , true )
2022-03-11 22:53:36 +00:00
end
end
end )
2022-03-13 18:19:59 +00:00
commands.add_command (
2022-05-06 13:43:59 +01:00
' tax ' ,
' is a captain command to take a quarter of all coins, plus other game-critical items from the crew, into your inventory. ' ,
2022-03-13 18:19:59 +00:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_captain ( cmd ) then
local player = game.players [ cmd.player_index ]
local memory = Memory.get_crew_memory ( )
2022-05-06 13:43:59 +01:00
Roles.captain_tax ( memory.playerindex_captain )
2022-03-13 18:19:59 +00:00
end
end )
2022-02-28 16:36:46 +00:00
commands.add_command (
2022-03-08 23:36:03 +00:00
' dump_highscores ' ,
' is a dev command. ' ,
2022-02-28 16:36:46 +00:00
function ( cmd )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
if not Common.validate_player ( player ) then return end
local crew_id = tonumber ( string.sub ( game.players [ cmd.player_index ] . force.name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
2022-03-08 23:36:03 +00:00
Highscore.dump_highscores ( )
player.print ( ' Highscores dumped. ' )
2022-02-28 16:36:46 +00:00
end
end )
2022-02-26 18:25:48 +00:00
commands.add_command (
' setcaptain ' ,
2022-03-08 23:36:03 +00:00
' {player} is an admin command to set the crew \' s captain to {player}. ' ,
2022-02-26 18:25:48 +00:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
if param and game.players [ param ] and game.players [ param ] . index then
Roles.make_captain ( game.players [ param ] )
else
2022-03-13 18:19:59 +00:00
Common.notify_player_error ( player , ' Command error: Invalid player name. ' )
2021-10-13 09:21:53 +01:00
end
2022-02-26 18:25:48 +00:00
end
end )
2021-10-13 09:21:53 +01:00
2022-03-01 21:59:48 +00:00
commands.add_command (
' summoncrew ' ,
2022-03-08 23:36:03 +00:00
' is an admin command to summon the crew to the ship. ' ,
2022-03-01 21:59:48 +00:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
Crew.summon_crew ( )
end
end )
2022-03-04 17:57:58 +00:00
commands.add_command (
' setclass ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2022-03-04 17:57:58 +00:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
if not Common.validate_player ( player ) then return end
if not memory.classes_table then memory.classes_table = { } end
memory.classes_table [ player.index ] = tonumber ( param )
player.print ( ' Set own class to ' .. param .. ' . ' )
end
end )
2022-03-01 21:59:48 +00:00
commands.add_command (
' setevo ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2022-03-01 21:59:48 +00:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
Common.set_evo ( tonumber ( param ) )
end
end )
2022-02-26 18:25:48 +00:00
commands.add_command (
' modi ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2022-02-26 18:25:48 +00:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
local surface = game.surfaces [ Common.current_destination ( ) . surface_name ]
local entities = surface.find_entities_filtered { position = player.position , radius = 500 }
for _ , e in pairs ( entities ) do
if e and e.valid then
2022-03-04 17:57:58 +00:00
-- e.force = memory.force
2022-02-26 18:25:48 +00:00
e.minable = true
e.destructible = true
e.rotatable = true
2021-10-13 09:21:53 +01:00
end
end
2022-02-26 18:25:48 +00:00
player.print ( ' nearby entities made modifiable ' )
end
end )
2021-10-13 09:21:53 +01:00
2022-02-26 18:25:48 +00:00
commands.add_command (
' ret ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2022-02-26 18:25:48 +00:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
2022-03-12 11:51:11 +00:00
Progression.retreat_from_island ( true )
2022-02-26 18:25:48 +00:00
end
end )
2021-10-13 09:21:53 +01:00
2022-03-10 22:11:51 +00:00
commands.add_command (
' jump ' ,
' is a dev command. ' ,
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
Overworld.try_overworld_move_v2 ( { x = 40 , y = 0 } )
end
end )
commands.add_command (
' advu ' ,
' is a dev command. ' ,
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
Overworld.try_overworld_move_v2 { x = 0 , y = - 24 }
end
end )
commands.add_command (
' advd ' ,
' is a dev command. ' ,
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
Overworld.try_overworld_move_v2 { x = 0 , y = 24 }
end
end )
2022-02-26 18:25:48 +00:00
2022-03-15 18:50:19 +00:00
commands.add_command (
' overwrite_scores_specific ' ,
' is a dev command. ' ,
function ( cmd )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
if not Common.validate_player ( player ) then return end
local crew_id = tonumber ( string.sub ( game.players [ cmd.player_index ] . force.name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
if Highscore.overwrite_scores_specific ( ) then player.print ( ' Highscores overwritten. ' ) end
end
end )
2022-02-26 18:25:48 +00:00
if _DEBUG then
2021-10-13 09:21:53 +01:00
2022-03-04 17:57:58 +00:00
commands.add_command (
' go ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2022-03-04 17:57:58 +00:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
2022-03-19 21:20:55 +00:00
2022-03-04 17:57:58 +00:00
local proposal = {
capacity_option = 3 ,
difficulty_option = 2 ,
-- mode_option = 'left',
endorserindices = { 1 } ,
name = " AdminRun "
}
2022-03-19 21:20:55 +00:00
2022-03-04 17:57:58 +00:00
Memory.set_working_id ( 1 )
2022-03-19 21:20:55 +00:00
2022-03-04 17:57:58 +00:00
Crew.initialise_crew ( proposal )
Crew.initialise_crowsnest ( ) --contains a Task
2022-03-19 21:20:55 +00:00
2022-03-04 17:57:58 +00:00
local memory = Memory.get_crew_memory ( )
local boat = Utils.deepcopy ( Surfaces.Lobby . StartingBoats [ memory.id ] )
2022-03-19 21:20:55 +00:00
2022-03-04 17:57:58 +00:00
for _ , p in pairs ( game.connected_players ) do
p.teleport ( { x = - 30 , y = boat.position . y } , game.surfaces [ boat.surface_name ] )
end
2022-03-19 21:20:55 +00:00
2022-03-04 17:57:58 +00:00
Progression.set_off_from_starting_dock ( )
2022-03-19 21:20:55 +00:00
2022-03-04 17:57:58 +00:00
-- local memory = Memory.get_crew_memory()
-- local boat = Utils.deepcopy(Surfaces.Lobby.StartingBoats[memory.id])
-- memory.boat = boat
-- boat.dockedposition = boat.position
-- boat.decksteeringchests = {}
-- boat.crowsneststeeringchests = {}
2022-03-19 21:20:55 +00:00
2022-03-04 17:57:58 +00:00
Task.set_timeout_in_ticks ( 120 , go_1 , { } )
end
end )
2022-03-19 21:20:55 +00:00
2022-03-08 23:36:03 +00:00
commands.add_command (
' chnk ' ,
' is a dev command. ' ,
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
2022-03-19 21:20:55 +00:00
2022-03-08 23:36:03 +00:00
for i = 0 , 13 do
for j = 0 , 13 do
Interface.event_on_chunk_generated ( { surface = player.surface , area = { left_top = { x = - 7 * 32 + i * 32 , y = - 7 * 32 + j * 32 } } } )
end
end
game.print ( ' chunks generated ' )
end
end )
2022-03-19 21:20:55 +00:00
2022-03-08 23:36:03 +00:00
commands.add_command (
' spd ' ,
' is a dev command. ' ,
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
memory.boat . speed = 60
end
end )
2022-03-19 21:20:55 +00:00
2022-03-08 23:36:03 +00:00
commands.add_command (
' stp ' ,
' is a dev command. ' ,
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
memory.boat . speed = 0
end
end )
2022-03-19 21:20:55 +00:00
2022-03-08 23:36:03 +00:00
commands.add_command (
' rms ' ,
' is a dev command. ' ,
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local rms = 0
local n = 100000
local seed = Math.random ( n ^ 2 )
for i = 1 , n do
local noise = simplex_noise ( i , 7.11 , seed )
rms = rms + noise ^ 2
end
rms = rms / n
game.print ( rms )
end
end )
2022-03-19 21:20:55 +00:00
2022-03-08 23:36:03 +00:00
commands.add_command (
' pro ' ,
' is a dev command. ' ,
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local global_memory = Memory.get_global_memory ( )
2022-03-19 21:20:55 +00:00
2022-03-08 23:36:03 +00:00
local proposal = {
capacity_option = 3 ,
difficulty_option = 2 ,
-- mode_option = 'left',
endorserindices = { 2 } ,
name = " TestRun "
}
2022-03-19 21:20:55 +00:00
2022-03-08 23:36:03 +00:00
global_memory.crewproposals [ # global_memory.crewproposals + 1 ] = proposal
2022-03-19 21:20:55 +00:00
2022-03-08 23:36:03 +00:00
end
end )
2022-03-19 21:20:55 +00:00
2022-03-08 23:36:03 +00:00
commands.add_command (
' lev ' ,
' is a dev command. ' ,
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
Memory.set_working_id ( 1 )
local memory = Memory.get_crew_memory ( )
Progression.go_from_currentdestination_to_sea ( )
end
end )
2022-03-19 21:20:55 +00:00
2022-03-08 23:36:03 +00:00
commands.add_command (
' hld ' ,
' is a dev command. ' ,
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
Memory.set_working_id ( 1 )
local memory = Memory.get_crew_memory ( )
Upgrades.execute_upgade ( Upgrades.enum . EXTRA_HOLD )
end
end )
2022-03-19 21:20:55 +00:00
2022-03-08 23:36:03 +00:00
commands.add_command (
' pwr ' ,
' is a dev command. ' ,
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
Memory.set_working_id ( 1 )
local memory = Memory.get_crew_memory ( )
Upgrades.execute_upgade ( Upgrades.enum . MORE_POWER )
end
end )
2022-03-19 21:20:55 +00:00
2022-03-08 23:36:03 +00:00
commands.add_command (
' score ' ,
' is a dev command. ' ,
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
2022-03-19 21:20:55 +00:00
2022-03-08 23:36:03 +00:00
game.print ( ' faking a highscore... ' )
Highscore.write_score ( memory.secs_id , ' fakers ' , 0 , 40 , CoreData.version_float , 1 , 1 )
end
end )
2022-03-19 21:20:55 +00:00
2022-03-08 23:36:03 +00:00
commands.add_command (
' scrget ' ,
' is a dev command. ' ,
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
game.print ( ' running Highscore.load_in_scores() ' )
Highscore.load_in_scores ( )
end
end )
2021-10-13 09:21:53 +01:00
commands.add_command (
' tim ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
2021-10-13 09:21:53 +01:00
Memory.set_working_id ( 1 )
local memory = Memory.get_crew_memory ( )
Common.current_destination ( ) . dynamic_data.timer = 88
game.print ( ' time set to 88 seconds ' )
end
end )
commands.add_command (
' gld ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
2021-10-13 09:21:53 +01:00
Memory.set_working_id ( 1 )
local memory = Memory.get_crew_memory ( )
2022-02-24 19:39:03 +00:00
memory.stored_fuel = memory.stored_fuel + 20000
2021-10-13 09:21:53 +01:00
end
end )
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01:00
commands.add_command (
' bld ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
2021-10-13 09:21:53 +01:00
Memory.set_working_id ( 1 )
local memory = Memory.get_crew_memory ( )
memory.classes_table = { [ 1 ] = 1 }
end
end )
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01:00
commands.add_command (
' rad ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
2021-10-13 09:21:53 +01:00
Memory.set_working_id ( 1 )
local memory = Memory.get_crew_memory ( )
Islands.spawn_enemy_boat ( Boats.enum . RAFT )
local boat = memory.enemyboats [ 1 ]
2022-02-28 16:36:46 +00:00
Ai.spawn_boat_biters ( boat , 0.89 , Boats.get_scope ( boat ) . Data.capacity , Boats.get_scope ( boat ) . Data.width )
2021-10-13 09:21:53 +01:00
game.print ( ' enemy boat spawned ' )
end
end )
2022-03-19 21:20:55 +00:00
2022-02-28 16:36:46 +00:00
commands.add_command (
' rad2 ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2022-02-28 16:36:46 +00:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
Memory.set_working_id ( 1 )
local memory = Memory.get_crew_memory ( )
Islands.spawn_enemy_boat ( Boats.enum . RAFTLARGE )
local boat = memory.enemyboats [ 1 ]
Ai.spawn_boat_biters ( boat , 0.89 , Boats.get_scope ( boat ) . Data.capacity , Boats.get_scope ( boat ) . Data.width )
game.print ( ' large enemy boat spawned ' )
end
end )
2021-10-13 09:21:53 +01:00
commands.add_command (
' krk ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
2021-10-13 09:21:53 +01:00
Memory.set_working_id ( 1 )
local memory = Memory.get_crew_memory ( )
Kraken.try_spawn_kraken ( )
end
end )
commands.add_command (
' 1 ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
2021-10-13 09:21:53 +01:00
game.speed = 1
end
end )
2022-03-19 21:20:55 +00:00
2022-03-04 17:57:58 +00:00
commands.add_command (
' 2 ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2022-03-04 17:57:58 +00:00
function ( cmd )
local param = tostring ( cmd.parameter )
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
game.speed = 2
end
end )
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01:00
commands.add_command (
' 4 ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
2021-10-13 09:21:53 +01:00
game.speed = 4
end
end )
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01:00
commands.add_command (
' 8 ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
2021-10-13 09:21:53 +01:00
game.speed = 8
end
end )
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01:00
commands.add_command (
' 16 ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
2021-10-13 09:21:53 +01:00
game.speed = 16
end
end )
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01:00
commands.add_command (
' 32 ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
2021-10-13 09:21:53 +01:00
game.speed = 32
end
end )
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01:00
commands.add_command (
' 64 ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
2021-10-13 09:21:53 +01:00
game.speed = 64
end
end )
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01:00
commands.add_command (
' ef1 ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
2021-10-13 09:21:53 +01:00
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
local surface = game.surfaces [ Common.current_destination ( ) . surface_name ]
Effects.worm_movement_effect ( surface , { x = - 45 , y = 0 } , false , true )
end
end )
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01:00
commands.add_command (
' ef2 ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
2021-10-13 09:21:53 +01:00
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
local surface = game.surfaces [ Common.current_destination ( ) . surface_name ]
Effects.worm_movement_effect ( surface , { x = - 45 , y = 0 } , false , false )
end
end )
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01:00
commands.add_command (
' ef3 ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
2021-10-13 09:21:53 +01:00
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
local surface = game.surfaces [ Common.current_destination ( ) . surface_name ]
Effects.worm_movement_effect ( surface , { x = - 45 , y = 0 } , true , false )
end
end )
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01:00
commands.add_command (
' ef4 ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
2021-10-13 09:21:53 +01:00
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
local surface = game.surfaces [ Common.current_destination ( ) . surface_name ]
Effects.worm_emerge_effect ( surface , { x = - 45 , y = 0 } )
end
end )
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01:00
commands.add_command (
' ef5 ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
local crew_id = tonumber ( string.sub ( player.force . name , - 3 , - 1 ) ) or nil
2021-10-13 09:21:53 +01:00
Memory.set_working_id ( crew_id )
local memory = Memory.get_crew_memory ( )
local surface = game.surfaces [ Common.current_destination ( ) . surface_name ]
Effects.biters_emerge ( surface , { x = - 30 , y = 0 } )
end
end )
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01:00
commands.add_command (
' emoji ' ,
2022-03-08 23:36:03 +00:00
' is a dev command. ' ,
2021-10-13 09:21:53 +01:00
function ( cmd )
local param = tostring ( cmd.parameter )
2022-02-26 18:25:48 +00:00
if check_admin ( cmd ) then
local player = game.players [ cmd.player_index ]
2021-10-13 09:21:53 +01:00
Server.to_discord_embed_raw ( CoreData.comfy_emojis . monkas )
end
end )
end