Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions __DEFINES/procgen.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//Dedicated Z level
#define PG_Z 100

//Generator States
#define PG_INACTIVE -1
#define PG_INIT 0
#define PG_MAPPING 1
#define PG_DECORATION 2
#define PG_POPULATION 3
#define PG_LOOT 4
//#define PG_VAULT 5 //for spawning vaults

//Planet Types
#define PG_ASTEROIDS /datum/procedural_space_object/asteroids
#define PG_MOON /datum/procedural_space_object/moon
#define PG_PLANET /datum/procedural_space_object/planet
#define PG_XENO /datum/procedural_space_object/xeno

//Atmos Levels
#define PG_VACUUM /datum/procedural_atmosphere/vacuum
#define PG_THIN /datum/procedural_atmosphere/thin
#define PG_BREATHABLE /datum/procedural_atmosphere/breathable
#define PG_TOXIC /datum/procedural_atmosphere/toxic

//Preciptation Levels
#define PG_NO_PRECIP 0
#define PG_L_PRECIP 1
#define PG_M_PRECIP 2
#define PG_H_PRECIP 3
#define PG_VH_PRECIP 4

//Temperature Levels
#define PG_FROZEN 0
#define PG_COLD 1
#define PG_BRISK 2
#define PG_TEMPERATE 3
#define PG_WARM 4
#define PG_HOT 5
#define PG_LAVA 6

//Biomes
#define PG_PERMAFROST /datum/procedural_biome/permafrost
#define PG_ICE_SHEET /datum/procedural_biome/ice_sheet
#define PG_TUNDRA /datum/procedural_biome/tundra
#define PG_TAIGA /datum/procedural_biome/taiga
#define PG_FOREST /datum/procedural_biome/forest
#define PG_PLAINS /datum/procedural_biome/plains
#define PG_SHRUBLAND /datum/procedural_biome/shrubland
#define PG_SWAMPLAND /datum/procedural_biome/swamp
#define PG_RAINFOREST /datum/procedural_biome/rainforest
#define PG_SAVANNA /datum/procedural_biome/savanna
#define PG_DESERT /datum/procedural_biome/desert
#define PG_MAGMA /datum/procedural_biome/magma
#define PG_ASH /datum/procedural_biome/ash
#define PG_ASTEROID /datum/procedural_biome/asteroid
#define PG_COMET /datum/procedural_biome/comet
#define PG_ROCK /datum/procedural_biome/rock

//History
#define PG_UNEXPLORED /datum/procedural_civilization/unexplored
#define PG_YOUNG_CIV /datum/procedural_civilization/young
#define PG_OLD_CIV /datum/procedural_civilization/old
#define PG_FUTURE_CIV /datum/procedural_civilization/future

//Altitude
#define PG_LOW_ALT 9
#define PG_MED_ALT 7
#define PG_HIGH_ALT 5

//Water
#define PG_NO_WATER 0
#define PG_MED_WATER 1
#define PG_HIGH_WATER 2
7 changes: 5 additions & 2 deletions __DEFINES/subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define SS_INIT_GARBAGE 23
#define SS_INIT_JOB 22
#define SS_INIT_HUMANS 21
#define SS_INIT_MAP 20
#define SS_INIT_MAPPING 20
#define SS_INIT_COMPONENT 19.5
#define SS_INIT_POWER 19
#define SS_INIT_OBJECT 18
Expand All @@ -29,7 +29,7 @@
#define SS_INIT_PERSISTENCE_MAP -98
#define SS_INIT_PERSISTENCE_MISC -99
#define SS_INIT_PATHFINDER -100
#define SS_INIT_DAYNIGHT -200
#define SS_INIT_DAYNIGHT -200

#define SS_PRIORITY_TIMER 1000
#define FIRE_PRIORITY_RUNECHAT 410
Expand Down Expand Up @@ -60,6 +60,7 @@
#define SS_PRIORITY_THERM_DISS 19
#define SS_PRIORITY_AMBIENCE 18
#define SS_PRIORITY_DBCORE 17
#define SS_PRIORITY_MAPPING 16
#define SS_PRIORITY_SUN 3
#define SS_PRIORITY_GARBAGE 2
#define SS_PRIORITY_INACTIVITY 1
Expand All @@ -77,6 +78,7 @@
#define SS_WAIT_TICKER 2 SECONDS
#define SS_WAIT_ENGINES 30 SECONDS
#define SS_WAIT_BURNABLE 3 SECONDS
#define SS_WAIT_MAPPING 0.5 SECONDS

#define SS_DISPLAY_TIMER -110
#define SS_DISPLAY_GARBAGE -100
Expand All @@ -101,6 +103,7 @@
#define SS_DISPLAY_THERM_ENTROPY 13
#define SS_DISPLAY_THERM_DISS 14
#define SS_DISPLAY_DBCORE 15
#define SS_DISPLAY_MAPPING 16
#define SS_DISPLAY_DAYNIGHT 20
#define SS_DISPLAY_BURNABLE 21

Expand Down
4 changes: 4 additions & 0 deletions code/__HELPERS/maths.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ var/const/Sqrt2 = 1.41421356
return 1
return clamp( (b - x)/(b - a), min, max )

// Function to normalize a value from one range to another using min-max feature scaling
/proc/normalize(value, min_value, max_value, new_min, new_max)
return ((value - min_value) * (new_max - new_min)) / (max_value - min_value) + new_min

/proc/Mean(...)
var/values = 0
var/sum = 0
Expand Down
49 changes: 0 additions & 49 deletions code/controllers/subsystem/init/map.dm

This file was deleted.

138 changes: 138 additions & 0 deletions code/controllers/subsystem/mapping.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
var/datum/subsystem/mapping/SSMapping

/datum/subsystem/mapping
name = "Mapping"
init_order = SS_INIT_MAPPING
display_order = SS_DISPLAY_MAPPING
priority = SS_PRIORITY_MAPPING
wait = SS_WAIT_MAPPING
flags = SS_NO_FIRE
var/list/currentrun
// var/datum/procedural_generator/PG

/datum/subsystem/mapping/New()
NEW_SS_GLOBAL(SSMapping)

/datum/subsystem/mapping/Initialize()
// var/datum/procedural_generator/genpath = pick(typesof(/datum/procedural_generator) - /datum/procedural_generator)
// PG = new genpath
generate_roundstart_away_missions()
generate_roundstart_vaults()
load_default_zlevels()
load_procgen_zlevel()
spawn_map_pickspawners() //this is down here so that it calls after allll the vaults etc are done spawning - if in the future some pickspawners don't fire, it's because this needs moving
..()

// /datum/subsystem/mapping/stat_entry()
// ..("P:[PG.turfs_remaining]")

// /datum/subsystem/mapping/fire(resumed = FALSE)
// if(!resumed)
// currentrun = block(locate(1,PG.current_row,PG.procgen_z),locate(PG.map_size,PG.current_row+(PG.rows_per_tick-1),PG.procgen_z))

// while(currentrun.len)
// var/turf/T = currentrun[currentrun.len]
// currentrun.len--

// if(!T || T.gcDestroyed)
// continue

// PG.process(T)

// if(MC_TICK_CHECK)
// return

// PG.current_row += PG.rows_per_tick

/////////////////////////////////////////////////////////////////////////////////////////////////
// INIT PROCS ---------------------------------------------------------------------------------//
/////////////////////////////////////////////////////////////////////////////////////////////////
/datum/subsystem/mapping/proc/generate_roundstart_away_missions()
if (config.enable_roundstart_away_missions)
log_startup_progress("Attempting to generate an away mission...")
createRandomZlevel()

/datum/subsystem/mapping/proc/generate_roundstart_vaults()
if (!config.skip_vault_generation)
var/watch = start_watch()
log_startup_progress("Placing random space structures...")
generate_vaults()
generate_asteroid_secrets()
make_mining_asteroid_secrets() // loops 3 times
log_startup_progress(" Finished placing structures in [stop_watch(watch)]s.")
else
log_startup_progress("Not generating vaults - SKIP_VAULT_GENERATION found in config/config.txt")

//hobo shack generation, one shack will spawn, 1/3 chance of two shacks
generate_hoboshack()
if (rand(1,3) == 3)
generate_hoboshack()

/datum/subsystem/mapping/proc/load_default_zlevels()
var/watch_prim = start_watch()
for(var/datum/zLevel/z in map.zLevels)
var/watch = start_watch()
z.post_mapload()
log_debug("Finished with zLevel [z.z] in [stop_watch(watch)]s.", FALSE)
log_debug("Finished calling post on zLevels in [stop_watch(watch_prim)]s.", FALSE)

var/watch = start_watch()
map.map_specific_init()
log_debug("Finished map-specific inits in [stop_watch(watch)]s.", FALSE)

/datum/subsystem/mapping/proc/load_procgen_zlevel()
world.maxz += 1
map.addZLevel(new /datum/zLevel/procgen,world.maxz,TRUE,TRUE)
var/newz = map.zLevels.len
log_debug("Z-level [newz] reserved for procedural generation.")
configure_virtual_zlevels(newz)


/////////////////////////////////////////////////////////////////////////////////////////////////
// VIRTUAL Z LEVELS =--------------------------------------------------------------------------//
/////////////////////////////////////////////////////////////////////////////////////////////////
/turf/unsimulated/wall/edge
name = "edge"
desc = null
icon = 'icons/turf/space.dmi'
icon_state = "black"
layer = TURF_LAYER
plane = TURF_PLANE
mouse_opacity = 0
explosion_block = 50

/datum/subsystem/mapping/proc/configure_virtual_zlevels(var/z_id) //Splits a single z-level into 5 sub-maps (1 250x250, 2 200x200, 2 100x100)
var/list/cornerx1 = list(
"x1" = 251,
"x2" = 301,
"x3" = 0,
"x4" = 101,
"x5" = 0
)
var/list/cornerx2 = list(
"x1" = 299,
"x2" = 500,
"x3" = 299,
"x4" = 149,
"x5" = 299
)
var/list/cornery1 = list(
"y1" = 500,
"y2" = 299,
"y3" = 249,
"y4" = 150,
"y5" = 49
)
var/list/cornery2 = list(
"y1" = 0,
"y2" = 201,
"y3" = 151,
"y4" = 51,
"y5" = 0
)
for(var/i = 1, i <= cornerx1.len, i++)
for(var/turf/T in block(locate(cornerx1["x[i]"],cornery1["y[i]"],z_id),locate(cornerx2["x[i]"],cornery2["y[i]"],z_id)))
T.ChangeTurf(/turf/unsimulated/wall/edge)
addVLevel("Procedurally-Generated Planet Zone [i]", i, map.zLevels[world.maxz], round(cornerx1["x[i]"],10),round(cornerx2["x[i]"],10), round(cornery1["y[i]"],10), round(cornery2["y[i]"],world.maxz))

log_startup_progress("Created [vLevels.len] virtual z-levels at z-level [z_id].")
38 changes: 38 additions & 0 deletions code/datums/vlevels.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
var/list/vLevels = list()

/datum/virtual_level
/// An admin-facing name used to identify the virtual level. May be duplicate, or changed after instancing.
var/name = "Sub Map Zone"
var/id
/// Z level which contains this virtual level
var/datum/zLevel/parent_level
/// The low X boundary of the sub-zone
var/low_x
/// The low Y boundary of the sub-zone
var/low_y
/// The high X boundary of the sub-zone
var/high_x
/// The high Y boundary of the sub-zone
var/high_y
/// Distance in the X axis of the sub-zone
var/x_distance
/// Distance in the Y axis of the sub-zone
var/y_distance

/datum/virtual_level/proc/get_relative_coords(atom/A)
var/rel_x = A.x - low_x + 1
var/rel_y = A.y - low_y + 1
return list(rel_x, rel_y)

/proc/addVLevel(var/newname, var/newid, var/datum/zLevel/parent, var/x1, var/y1, var/x2, var/y2)
var/datum/virtual_level/vlevel = new /datum/virtual_level
vlevel.name = newname
vlevel.id = newid
vlevel.parent_level = parent
vlevel.low_x = x1
vlevel.low_y = y2
vlevel.high_x = x2
vlevel.high_y = y1
vlevel.x_distance = x2 - x1
vlevel.y_distance = y2 - y1
vLevels |= vlevel
4 changes: 4 additions & 0 deletions code/game/area/Space Station 13 areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3059,3 +3059,7 @@ var/list/shack_names = list("abandoned","deserted","forsaken","stranded","isolat
name = "\improper HELL"
requires_power = 0
dynamic_lighting = 0

//Procedurally-Generated Planets
/area/procplanet
name = "\improper Planet Surface"
2 changes: 1 addition & 1 deletion code/game/turfs/unsimulated/walls.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/turf/unsimulated/wall/isSmoothableNeighbor(atom/A, bordercheck)
return smooths && istype(A, src.type)

/turf/unsimulated/wall/canSmoothWith()
return smooths

Expand Down
1 change: 1 addition & 0 deletions code/modules/admin/admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ var/global/floorIsLava = 0
<A href='?src=\ref[src];secretsfun=gravanomalies'>Spawn a gravitational anomaly (aka lagitational anomolag)</A><BR>
<A href='?src=\ref[src];secretsfun=timeanomalies'>Spawn wormholes</A><BR>
<A href='?src=\ref[src];secretsfun=mobswarm'>Any mob infestation (specify type only)</A><BR>
<A href='?src=\ref[src];secretsfun=procgen'>Procedurally-generate a space object</A><BR>
<BR>
<B>Fun Secrets</B><BR>
<BR>
Expand Down
3 changes: 3 additions & 0 deletions code/modules/admin/topic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3896,6 +3896,9 @@ access_sec_doors,access_salvage_captain,access_cent_ert,access_syndicate,access_
var/mobtype = input("What mob would you like?", "Mob Swarm") as null|anything in typesof(/mob/living)
message_admins("[key_name_admin(usr)] triggered a mob swarm.")
new /datum/event/mob_swarm(mobtype, amt)
// if("procgen")
// var/datum/procedural_generator/genpath = pick(typesof(/datum/procedural_generator) - /datum/procedural_generator)
// new genpath
if("pick_event")
feedback_inc("admin_secrets_fun_used",1)
feedback_add_details("admin_secrets_fun_used","ALL")
Expand Down
Loading
Loading