2022-06-01 19:50:36 +01:00
-- This file is part of thesixthroc's Pirate Ship softmod, licensed under GPLv3 and stored at https://github.com/danielmartin0/ComfyFactorio-Pirates.
2021-10-13 09:21:53 +01:00
2022-03-19 21:20:55 +00:00
-- local Memory = require 'maps.pirates.memory'
2021-10-13 09:21:53 +01:00
local Math = require ' maps.pirates.math '
2022-03-19 21:20:55 +00:00
-- local Balance = require 'maps.pirates.balance'
-- local Structures = require 'maps.pirates.structures.structures'
-- local Common = require 'maps.pirates.common'
-- local Utils = require 'maps.pirates.utils_local'
local _inspect = require ' utils.inspect ' . inspect
-- local Ores = require 'maps.pirates.ores'
2021-10-13 09:21:53 +01:00
local IslandsCommon = require ' maps.pirates.surfaces.islands.common '
local Hunt = require ' maps.pirates.surfaces.islands.hunt '
local Public = { }
Public.Data = require ' maps.pirates.surfaces.islands.standard_variant.data '
function Public . noises ( args )
local ret = { }
ret.height = IslandsCommon.island_height_1 ( args )
ret.forest = args.noise_generator . forest
ret.forest_abs = function ( p ) return Math.abs ( ret.forest ( p ) ) end
ret.forest_abs_suppressed = function ( p ) return ret.forest_abs ( p ) - 1 * Math.slopefromto ( ret.height ( p ) , 0.17 , 0.11 ) end
ret.rock = args.noise_generator . rock
ret.rock_abs = function ( p ) return Math.abs ( ret.rock ( p ) ) end
ret.mood = args.noise_generator . mood
2022-03-04 17:57:58 +00:00
ret.farness = IslandsCommon.island_farness_1 ( args ) --isn't available on the iconized pass, only on actual generation; check args.iconized_generation before you use this
2021-10-13 09:21:53 +01:00
return ret
end
function Public . terrain ( args )
local noises = Public.noises ( args )
local p = args.p
2022-03-19 21:20:55 +00:00
2021-10-13 09:21:53 +01:00
if IslandsCommon.place_water_tile ( args ) then return end
if noises.height ( p ) < 0 then
args.tiles [ # args.tiles + 1 ] = { name = ' water ' , position = args.p }
return
end
2022-03-19 21:20:55 +00:00
2022-02-24 19:39:03 +00:00
if noises.height ( p ) < 0.04 then
2021-10-13 09:21:53 +01:00
args.tiles [ # args.tiles + 1 ] = { name = ' sand-1 ' , position = args.p }
2022-03-04 17:57:58 +00:00
if ( not args.iconized_generation ) and noises.farness ( p ) > 0.02 and noises.farness ( p ) < 0.6 and Math.random ( 500 ) == 1 then
2021-10-13 09:21:53 +01:00
args.specials [ # args.specials + 1 ] = { name = ' buried-treasure ' , position = args.p }
end
2022-02-24 19:39:03 +00:00
elseif noises.height ( p ) < 0.05 then
2021-10-13 09:21:53 +01:00
args.tiles [ # args.tiles + 1 ] = { name = ' sand-2 ' , position = args.p }
2022-02-24 19:39:03 +00:00
elseif noises.height ( p ) < 0.11 then
args.tiles [ # args.tiles + 1 ] = { name = ' dry-dirt ' , position = args.p }
elseif noises.height ( p ) < 0.12 then
args.tiles [ # args.tiles + 1 ] = { name = ' grass-4 ' , position = args.p }
2021-10-13 09:21:53 +01:00
else
if noises.forest_abs_suppressed ( p ) > 0.3 and noises.rock ( p ) < 0.3 then
args.tiles [ # args.tiles + 1 ] = { name = ' dirt-7 ' , position = args.p }
elseif noises.forest_abs_suppressed ( p ) > 0.15 and noises.rock ( p ) < 0.3 then
args.tiles [ # args.tiles + 1 ] = { name = ' grass-4 ' , position = args.p }
else
args.tiles [ # args.tiles + 1 ] = { name = ' grass-3 ' , position = args.p }
end
end
2022-02-24 19:39:03 +00:00
if noises.height ( p ) > 0.11 then
2021-10-13 09:21:53 +01:00
if noises.forest_abs_suppressed ( p ) > 0.7 then
2022-06-04 14:43:08 +01:00
if ( not args.iconized_generation ) and noises.forest_abs_suppressed ( p ) < 1 and Math.random ( 700 ) == 1 then -- high amounts of this
2021-10-13 09:21:53 +01:00
args.specials [ # args.specials + 1 ] = { name = ' chest ' , position = args.p }
else
local forest_noise = noises.forest ( p )
2022-02-24 19:39:03 +00:00
local treedensity = 0.7 * Math.slopefromto ( noises.forest_abs_suppressed ( p ) , 0.61 , 0.76 )
2021-10-13 09:21:53 +01:00
if forest_noise > 0 then
if noises.rock ( p ) > 0.05 then
if Math.random ( 1 , 100 ) < treedensity * 100 then args.entities [ # args.entities + 1 ] = { name = ' tree-08-red ' , position = args.p , visible_on_overworld = true } end
elseif noises.rock ( p ) < - 0.05 then
if Math.random ( 1 , 100 ) < treedensity * 100 then args.entities [ # args.entities + 1 ] = { name = ' tree-09-brown ' , position = args.p } end
end
elseif forest_noise < - 1.2 then
if Math.random ( 1 , 100 ) < treedensity * 100 then args.entities [ # args.entities + 1 ] = { name = ' tree-09 ' , position = args.p , visible_on_overworld = true } end
else
if Math.random ( 1 , 100 ) < treedensity * 100 then args.entities [ # args.entities + 1 ] = { name = ' tree-02-red ' , position = args.p } end
end
end
end
end
if noises.forest_abs_suppressed ( p ) < 0.45 then
if noises.height ( p ) > 0.12 then
if noises.rock_abs ( p ) > 0.25 then
local rockdensity = 1 / 600 * Math.slopefromto ( noises.rock_abs ( p ) , 0.25 , 0.6 ) + 1 / 5 * Math.slopefromto ( noises.rock_abs ( p ) , 2.4 , 2.6 )
local rockrng = Math.random ( )
if rockrng < rockdensity then
args.entities [ # args.entities + 1 ] = IslandsCommon.random_rock_1 ( args.p )
elseif rockrng < rockdensity * 1.5 then
args.decoratives [ # args.decoratives + 1 ] = { name = ' rock-medium ' , position = args.p }
elseif rockrng < rockdensity * 2 then
args.decoratives [ # args.decoratives + 1 ] = { name = ' rock-small ' , position = args.p }
elseif rockrng < rockdensity * 2.5 then
args.decoratives [ # args.decoratives + 1 ] = { name = ' rock-tiny ' , position = args.p }
end
end
end
end
2022-02-24 19:39:03 +00:00
if noises.height ( p ) > 0.18 and noises.mood ( p ) > 0.3 then
if noises.forest_abs ( p ) < 0.2 and noises.rock_abs ( p ) > 1.5 then
2022-03-09 21:39:47 +00:00
args.entities [ # args.entities + 1 ] = { name = ' coal ' , position = args.p , amount = 7 }
2022-02-24 19:39:03 +00:00
end
end
2021-10-13 09:21:53 +01:00
end
function Public . chunk_structures ( args )
local spec = function ( p )
local noises = Public.noises { p = p , noise_generator = args.noise_generator , static_params = args.static_params , seed = args.seed }
return {
placeable = noises.farness ( p ) > 0.3 ,
spawners_indestructible = false ,
-- spawners_indestructible = noises.farness(p) > 0.7,
density_perchunk = 25 * Math.slopefromto ( noises.mood ( p ) , 0.16 , - 0.1 ) * Math.slopefromto ( noises.farness ( p ) , 0.3 , 1 ) ^ 2 * args.biter_base_density_scale ,
}
end
IslandsCommon.enemies_1 ( args , spec )
local spec2 = function ( p )
local noises = Public.noises { p = p , noise_generator = args.noise_generator , static_params = args.static_params , seed = args.seed }
return {
2022-07-16 21:46:23 +03:00
-- placeable = noises.height(p) >= 0 and noises.forest_abs_suppressed(p) < 0.3 + Math.max(0, 0.2 - noises.height(p)),
2022-06-16 00:00:18 +03:00
placeable_strict = noises.height ( p ) >= 0.05 ,
placeable_optional = noises.forest_abs_suppressed ( p ) < 0.3 + Math.max ( 0 , 0.2 - noises.height ( p ) ) ,
chanceper4chunks = 0.1 * Math.slopefromto ( noises.farness ( p ) , 0.1 , 0.4 ) * Math.slopefromto ( noises.mood ( p ) , 0 , 0.25 ) ,
2021-10-13 09:21:53 +01:00
}
end
IslandsCommon.assorted_structures_1 ( args , spec2 )
end
2022-03-19 21:20:55 +00:00
-- function Public.break_rock(surface, p, entity_name)
-- -- return Ores.try_ore_spawn(surface, p, entity_name)
-- end
2021-10-13 09:21:53 +01:00
2022-07-03 17:58:44 +03:00
function Public . generate_silo_setup_position ( points_to_avoid )
return Hunt.silo_setup_position ( points_to_avoid )
2021-10-13 09:21:53 +01:00
end
return Public