mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-27 10:32:08 +00:00
Merge branch 'master' into updates_the_nbt
# Conflicts: # code/__defines/misc.dm # code/game/machinery/machinery.dm # maps/_common/mapsystem/map.dm
This commit is contained in:
32
code/modules/maps/helper_landmarks.dm
Normal file
32
code/modules/maps/helper_landmarks.dm
Normal file
@@ -0,0 +1,32 @@
|
||||
/obj/effect/landmark/map_load_mark
|
||||
name = "map loader landmark"
|
||||
var/list/templates //list of template types to pick from
|
||||
|
||||
//Clears walls
|
||||
/obj/effect/landmark/clear
|
||||
name = "clear turf"
|
||||
icon = 'icons/effects/landmarks.dmi'
|
||||
icon_state = "clear"
|
||||
delete_me = TRUE
|
||||
|
||||
/obj/effect/landmark/clear/Initialize()
|
||||
var/turf/simulated/wall/W = get_turf(src)
|
||||
if(istype(W))
|
||||
W.dismantle_wall(TRUE, TRUE)
|
||||
var/turf/simulated/mineral/M = W
|
||||
if(istype(M))
|
||||
M.GetDrilled()
|
||||
. = ..()
|
||||
|
||||
//Applies fire act to the turf
|
||||
/obj/effect/landmark/scorcher
|
||||
name = "fire"
|
||||
icon = 'icons/effects/landmarks.dmi'
|
||||
icon_state = "fire"
|
||||
var/temp = T0C + 3000
|
||||
|
||||
/obj/effect/landmark/scorcher/Initialize()
|
||||
var/turf/simulated/T = get_turf(src)
|
||||
if(istype(T))
|
||||
T.fire_act(temp)
|
||||
. = ..()
|
||||
@@ -21,52 +21,113 @@
|
||||
name = rename
|
||||
|
||||
/datum/map_template/proc/preload_size(path)
|
||||
var/bounds = maploader.load_map(file(path), 1, 1, 1, cropMap=FALSE, measureOnly=TRUE)
|
||||
if(bounds)
|
||||
width = bounds[MAP_MAXX] // Assumes all templates are rectangular, have a single Z level, and begin at 1,1,1
|
||||
height = bounds[MAP_MAXY]
|
||||
var/list/bounds = list(1.#INF, 1.#INF, 1.#INF, -1.#INF, -1.#INF, -1.#INF)
|
||||
var/z_offset = 1 // needed to calculate z-bounds correctly
|
||||
var/datum/map_load_metadata/M = maploader.load_map(file(path), 1, 1, z_offset, cropMap=FALSE, measureOnly=TRUE)
|
||||
if(M)
|
||||
bounds = extend_bounds_if_needed(bounds, M.bounds)
|
||||
z_offset++
|
||||
else
|
||||
return FALSE
|
||||
width = bounds[MAP_MAXX] - bounds[MAP_MINX] + 1
|
||||
height = bounds[MAP_MAXY] - bounds[MAP_MINX] + 1
|
||||
return bounds
|
||||
|
||||
/datum/map_template/proc/initTemplateBounds(var/list/bounds)
|
||||
var/list/obj/structure/cable/cables = list()
|
||||
var/list/atom/atoms = list()
|
||||
/datum/map_template/proc/load_new_z(var/no_changeturf = TRUE)
|
||||
var/x = round((world.maxx - width)/2)
|
||||
var/y = round((world.maxy - height)/2)
|
||||
var/initial_z = world.maxz + 1
|
||||
|
||||
for(var/L in block(locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]),
|
||||
locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ])))
|
||||
if (x < 1) x = 1
|
||||
if (y < 1) y = 1
|
||||
|
||||
var/list/bounds = list(1.#INF, 1.#INF, 1.#INF, -1.#INF, -1.#INF, -1.#INF)
|
||||
var/list/atoms_to_initialise = list()
|
||||
var/shuttle_state = pre_init_shuttles()
|
||||
|
||||
var/turf/B = L
|
||||
if (!B.initialized)
|
||||
atoms += B
|
||||
|
||||
if (TURF_IS_DYNAMICALLY_LIT_UNSAFE(B) && !B.lighting_overlay)
|
||||
new /atom/movable/lighting_overlay(B)
|
||||
|
||||
for(var/thing in B)
|
||||
if(istype(thing, /obj/structure/cable))
|
||||
cables += thing
|
||||
|
||||
var/atom/movable/AM = thing
|
||||
if (!AM.initialized)
|
||||
atoms += AM
|
||||
|
||||
SSatoms.InitializeAtoms(atoms)
|
||||
SSmachinery.setup_template_powernets(cables)
|
||||
|
||||
/datum/map_template/proc/load_new_z()
|
||||
var/x = round(world.maxx / 2)
|
||||
var/y = round(world.maxy / 2)
|
||||
|
||||
var/list/bounds = maploader.load_map(file(mappath), x, y, no_changeturf = TRUE)
|
||||
if(!bounds)
|
||||
var/datum/map_load_metadata/M = maploader.load_map(file(mappath), x, y, no_changeturf = no_changeturf)
|
||||
if (M)
|
||||
bounds = extend_bounds_if_needed(bounds, M.bounds)
|
||||
atoms_to_initialise += M.atoms_to_initialise
|
||||
else
|
||||
return FALSE
|
||||
|
||||
for (var/z_index = bounds[MAP_MINZ]; z_index <= bounds[MAP_MAXZ]; z_index++)
|
||||
if (accessibility_weight)
|
||||
current_map.accessible_z_levels[num2text(z_index)] = accessibility_weight
|
||||
if (base_turf_for_zs)
|
||||
current_map.base_turf_by_z[num2text(z_index)] = base_turf_for_zs
|
||||
current_map.player_levels |= z_index
|
||||
|
||||
smooth_zlevel(world.maxz)
|
||||
resort_all_areas()
|
||||
|
||||
//initialize things that are normally initialized after map load
|
||||
initTemplateBounds(bounds)
|
||||
init_atoms(atoms_to_initialise)
|
||||
init_shuttles(shuttle_state)
|
||||
after_load(initial_z)
|
||||
for(var/light_z = initial_z to world.maxz)
|
||||
create_lighting_overlays_zlevel(light_z)
|
||||
log_game("Z-level [name] loaded at [x], [y], [world.maxz]")
|
||||
loaded++
|
||||
|
||||
return locate(world.maxx/2, world.maxy/2, world.maxz)
|
||||
|
||||
/datum/map_template/proc/pre_init_shuttles()
|
||||
. = SSshuttle.block_queue
|
||||
SSshuttle.block_queue = TRUE
|
||||
|
||||
/datum/map_template/proc/init_shuttles(var/pre_init_state)
|
||||
for (var/shuttle_type in shuttles_to_initialise)
|
||||
LAZYADD(SSshuttle.shuttles_to_initialize, shuttle_type) // queue up for init.
|
||||
SSshuttle.block_queue = pre_init_state
|
||||
SSshuttle.clear_init_queue() // We will flush the queue unless there were other blockers, in which case they will do it.
|
||||
|
||||
/datum/map_template/proc/init_atoms(var/list/atoms)
|
||||
if (SSatoms.initialized == INITIALIZATION_INSSATOMS)
|
||||
return // let proper initialisation handle it later
|
||||
|
||||
var/list/turf/turfs = list()
|
||||
var/list/obj/machinery/atmospherics/atmos_machines = list()
|
||||
var/list/obj/machinery/machines = list()
|
||||
var/list/obj/structure/cable/cables = list()
|
||||
|
||||
for(var/atom/A in atoms)
|
||||
if(istype(A, /turf))
|
||||
turfs += A
|
||||
if(istype(A, /obj/structure/cable))
|
||||
cables += A
|
||||
if(istype(A, /obj/machinery/atmospherics))
|
||||
atmos_machines += A
|
||||
if(istype(A, /obj/machinery))
|
||||
machines += A
|
||||
if(istype(A,/obj/effect/landmark/map_load_mark))
|
||||
LAZYADD(subtemplates_to_spawn, A)
|
||||
|
||||
var/notsuspended
|
||||
if(!SSmachinery.suspended)
|
||||
SSmachinery.suspend()
|
||||
notsuspended = TRUE
|
||||
|
||||
SSatoms.InitializeAtoms() // The atoms should have been getting queued there. This flushes the queue.
|
||||
|
||||
SSmachinery.setup_template_powernets(cables)
|
||||
SSmachinery.setup_atmos_machinery(atmos_machines)
|
||||
if(notsuspended)
|
||||
SSmachinery.wake()
|
||||
|
||||
for (var/i in machines)
|
||||
var/obj/machinery/machine = i
|
||||
machine.power_change()
|
||||
|
||||
for (var/i in turfs)
|
||||
var/turf/T = i
|
||||
T.post_change()
|
||||
if(template_flags & TEMPLATE_FLAG_NO_RUINS)
|
||||
T.flags |= TURF_NORUINS
|
||||
if(istype(T,/turf/simulated))
|
||||
var/turf/simulated/sim = T
|
||||
sim.update_air_properties()
|
||||
|
||||
/datum/map_template/proc/load(turf/T, centered = FALSE)
|
||||
if(centered)
|
||||
@@ -78,12 +139,18 @@
|
||||
if(T.y + height > world.maxy)
|
||||
return
|
||||
|
||||
var/list/bounds = maploader.load_map(file(mappath), T.x, T.y, T.z, cropMap=TRUE, no_changeturf = FALSE)
|
||||
if(!bounds)
|
||||
return
|
||||
var/list/atoms_to_initialise = list()
|
||||
var/shuttle_state = pre_init_shuttles()
|
||||
|
||||
var/datum/map_load_metadata/M = maploader.load_map(file(mappath), T.x, T.y, T.z, cropMap=TRUE, no_changeturf = FALSE)
|
||||
if (M)
|
||||
atoms_to_initialise += M.atoms_to_initialise
|
||||
else
|
||||
return FALSE
|
||||
|
||||
//initialize things that are normally initialized after map load
|
||||
initTemplateBounds(bounds)
|
||||
init_atoms(atoms_to_initialise)
|
||||
init_shuttles(shuttle_state)
|
||||
|
||||
log_game("[name] loaded at [T.x], [T.y], [T.z]")
|
||||
return TRUE
|
||||
@@ -95,3 +162,21 @@
|
||||
if(corner)
|
||||
placement = corner
|
||||
return block(placement, locate(placement.x + width-1, placement.y + height-1, placement.z))
|
||||
|
||||
/datum/map_template/proc/extend_bounds_if_needed(var/list/existing_bounds, var/list/new_bounds)
|
||||
var/list/bounds_to_combine = existing_bounds.Copy()
|
||||
for (var/min_bound in list(MAP_MINX, MAP_MINY, MAP_MINZ))
|
||||
bounds_to_combine[min_bound] = min(existing_bounds[min_bound], new_bounds[min_bound])
|
||||
for (var/max_bound in list(MAP_MAXX, MAP_MAXY, MAP_MAXZ))
|
||||
bounds_to_combine[max_bound] = max(existing_bounds[max_bound], new_bounds[max_bound])
|
||||
return bounds_to_combine
|
||||
|
||||
/datum/map_template/proc/after_load(z)
|
||||
for(var/obj/effect/landmark/map_load_mark/mark in subtemplates_to_spawn)
|
||||
subtemplates_to_spawn -= mark
|
||||
if(LAZYLEN(mark.templates))
|
||||
var/template = pick(mark.templates)
|
||||
var/datum/map_template/M = new template()
|
||||
M.load(get_turf(mark), TRUE)
|
||||
qdel(mark)
|
||||
LAZYCLEARLIST(subtemplates_to_spawn)
|
||||
@@ -42,8 +42,7 @@
|
||||
smoothing_iterations = 4
|
||||
land_type = /turf/simulated/floor/exoplanet/desert
|
||||
|
||||
flora_prob = 5
|
||||
flora_diversity = 4
|
||||
flora_prob = 0
|
||||
fauna_types = list(/mob/living/simple_animal/thinbug, /mob/living/simple_animal/tindalos)
|
||||
|
||||
/datum/random_map/noise/exoplanet/desert/get_additional_spawns(var/value, var/turf/T)
|
||||
@@ -52,7 +51,6 @@
|
||||
return
|
||||
var/v = noise2value(value)
|
||||
if(v > 6)
|
||||
T.icon_state = "desert[v-1]"
|
||||
if(prob(10))
|
||||
new/obj/structure/quicksand(T)
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
var/global/use_preloader = FALSE
|
||||
var/global/dmm_suite/preloader/_preloader = new
|
||||
|
||||
/datum/map_load_metadata
|
||||
var/bounds
|
||||
var/list/atoms_to_initialise
|
||||
|
||||
/dmm_suite
|
||||
// /"([a-zA-Z]+)" = \(((?:.|\n)*?)\)\n(?!\t)|\((\d+),(\d+),(\d+)\) = \{"([a-zA-Z\n]*)"\}/g
|
||||
var/static/regex/dmmRegex = new/regex({""(\[a-zA-Z]+)" = \\(((?:.|\n)*?)\\)\n(?!\t)|\\((\\d+),(\\d+),(\\d+)\\) = \\{"(\[a-zA-Z\n]*)"\\}"}, "g")
|
||||
@@ -60,6 +64,7 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
var/key_len = 0
|
||||
|
||||
var/stored_index = 1
|
||||
var/list/atoms_to_initialise = list()
|
||||
|
||||
while(dmmRegex.Find(tfile, stored_index))
|
||||
stored_index = dmmRegex.next
|
||||
@@ -156,7 +161,9 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
if(!no_afterchange || (model_key != space_key))
|
||||
if(!grid_models[model_key])
|
||||
throw EXCEPTION("Undefined model key in DMM.")
|
||||
parse_grid(grid_models[model_key], model_key, xcrd, ycrd, zcrd, no_changeturf || zexpansion)
|
||||
var/datum/grid_load_metadata/M = parse_grid(grid_models[model_key], model_key, xcrd, ycrd, zcrd, no_changeturf || zexpansion)
|
||||
if (M)
|
||||
atoms_to_initialise += M.atoms_to_initialise
|
||||
#ifdef TESTING
|
||||
else
|
||||
++turfsSkipped
|
||||
@@ -179,7 +186,15 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
var/turf/T = t
|
||||
//we do this after we load everything in. if we don't; we'll have weird atmos bugs regarding atmos adjacent turfs
|
||||
T.post_change(TRUE)
|
||||
return bounds
|
||||
var/datum/map_load_metadata/M = new
|
||||
M.bounds = bounds
|
||||
M.atoms_to_initialise = atoms_to_initialise
|
||||
return M
|
||||
|
||||
/datum/grid_load_metadata
|
||||
var/list/atoms_to_initialise
|
||||
var/list/atoms_to_delete
|
||||
|
||||
|
||||
/**
|
||||
* Fill a given tile with its area/turf/objects/mobs
|
||||
@@ -308,23 +323,35 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
|
||||
//turn off base new Initialization until the whole thing is loaded
|
||||
SSatoms.map_loader_begin()
|
||||
//since we've switched off autoinitialisation, record atoms to initialise later
|
||||
var/list/atoms_to_initialise = list()
|
||||
|
||||
//instanciate the first /turf
|
||||
var/turf/T
|
||||
if(members[first_turf_index] != /turf/template_noop)
|
||||
T = instance_atom(members[first_turf_index],members_attributes[first_turf_index],crds,no_changeturf)
|
||||
atoms_to_initialise += T
|
||||
|
||||
if(T)
|
||||
//if others /turf are presents, simulates the underlays piling effect
|
||||
index = first_turf_index + 1
|
||||
while(index <= members.len - 1) // Last item is an /area
|
||||
crash_with("Tried to load additional turf at [model_key].")
|
||||
var/underlay = T.appearance
|
||||
T = instance_atom(members[index],members_attributes[index],crds,no_changeturf)//instance new turf
|
||||
T.underlays += underlay
|
||||
index++
|
||||
atoms_to_initialise += T
|
||||
|
||||
//finally instance all remainings objects/mobs
|
||||
for(index in 1 to first_turf_index-1)
|
||||
instance_atom(members[index],members_attributes[index],crds,no_changeturf)
|
||||
atoms_to_initialise += instance_atom(members[index],members_attributes[index],crds,no_changeturf)
|
||||
//Restore initialization to the previous value
|
||||
SSatoms.map_loader_stop()
|
||||
|
||||
var/datum/grid_load_metadata/M = new
|
||||
M.atoms_to_initialise = atoms_to_initialise
|
||||
return M
|
||||
|
||||
////////////////
|
||||
//Helpers procs
|
||||
////////////////
|
||||
|
||||
@@ -18,7 +18,7 @@ var/list/banned_ruin_ids = list()
|
||||
for(var/datum/map_template/ruin/ruin in potentialRuins)
|
||||
if (ruin.id in banned_ruin_ids)
|
||||
continue
|
||||
if(!(SSatlas.current_sector.name in ruin.sectors) && !length(ruin.sectors))
|
||||
if(!(SSatlas.current_sector.name in ruin.sectors))
|
||||
continue
|
||||
available[ruin] = ruin.spawn_weight
|
||||
|
||||
@@ -27,7 +27,7 @@ var/list/banned_ruin_ids = list()
|
||||
|
||||
while (remaining > 0 && length(available))
|
||||
var/datum/map_template/ruin/ruin = pickweight(available)
|
||||
if (ruin.cost > budget)
|
||||
if (ruin.spawn_cost > budget)
|
||||
available -= ruin
|
||||
continue
|
||||
|
||||
@@ -52,12 +52,12 @@ var/list/banned_ruin_ids = list()
|
||||
if (!valid)
|
||||
continue
|
||||
|
||||
log_admin("Ruin \"[ruin.name]\" placed at ([choice.x], [choice.y], [choice.z])")
|
||||
log_admin("Ruin \"[ruin.name]\" placed at ([choice.x], [choice.y], [choice.z])!")
|
||||
|
||||
load_ruin(choice, ruin)
|
||||
selected += ruin
|
||||
if (ruin.cost > 0)
|
||||
remaining -= ruin.cost
|
||||
if (ruin.spawn_cost > 0)
|
||||
remaining -= ruin.spawn_cost
|
||||
if (!(ruin.template_flags & TEMPLATE_FLAG_ALLOW_DUPLICATES))
|
||||
banned_ruin_ids += ruin.id
|
||||
available -= ruin
|
||||
@@ -78,7 +78,7 @@ var/list/banned_ruin_ids = list()
|
||||
var/turf/T = i
|
||||
for(var/mob/living/simple_animal/monster in T)
|
||||
qdel(monster)
|
||||
template.load(central_turf,centered = TRUE)
|
||||
template.load(central_turf, TRUE)
|
||||
var/datum/map_template/ruin = template
|
||||
if(istype(ruin))
|
||||
new /obj/effect/landmark/ruin(central_turf, ruin)
|
||||
|
||||
Reference in New Issue
Block a user