mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-04 14:01:22 +00:00
Ruin placement will try very hard to place any ruins with negative costs before attempting any other ruins (#28973)
* Ruin placement will try very hard to place all 0-cost ruins before placing any ruins with actual costs * comment * account for ruin variants properly please * cost has a cost of 5 * tweak
This commit is contained in:
@@ -47,3 +47,5 @@ GLOBAL_VAR_INIT(cmp_field, "name")
|
||||
/proc/cmp_clockscripture_priority(datum/clockwork_scripture/A, datum/clockwork_scripture/B)
|
||||
return initial(A.sort_priority) - initial(B.sort_priority)
|
||||
|
||||
/proc/cmp_ruincost_priority(datum/map_template/ruin/A, datum/map_template/ruin/B)
|
||||
return initial(A.cost) - initial(B.cost)
|
||||
|
||||
@@ -210,7 +210,7 @@ SUBSYSTEM_DEF(mapping)
|
||||
var/list/banned = generateMapList("config/lavaruinblacklist.txt")
|
||||
banned += generateMapList("config/spaceruinblacklist.txt")
|
||||
|
||||
for(var/item in subtypesof(/datum/map_template/ruin))
|
||||
for(var/item in sortList(subtypesof(/datum/map_template/ruin), /proc/cmp_ruincost_priority))
|
||||
var/datum/map_template/ruin/ruin_type = item
|
||||
// screen out the abstract subtypes
|
||||
if(!initial(ruin_type.id))
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
How is there a wooden container filled with 18th century coinage in the middle of a lavawracked hellscape? \
|
||||
It is clearly a mystery."
|
||||
|
||||
var/cost = null
|
||||
var/cost = null //negative numbers will always be placed, with lower (negative) numbers being placed first; positive and 0 numbers will be placed randomly
|
||||
var/allow_duplicates = TRUE
|
||||
|
||||
var/prefix = null
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
id = "hierophant"
|
||||
description = "A strange, square chunk of metal of massive size. Inside awaits only death and many, many squares."
|
||||
suffix = "lavaland_surface_hierophant.dmm"
|
||||
cost = 0
|
||||
cost = -1
|
||||
allow_duplicates = FALSE
|
||||
|
||||
/datum/map_template/ruin/lavaland/ufo_crash
|
||||
|
||||
@@ -14,10 +14,20 @@
|
||||
var/overall_sanity = 100
|
||||
var/list/ruins = potentialRuins.Copy()
|
||||
|
||||
var/is_picking = FALSE
|
||||
var/last_checked_ruin_index = 0
|
||||
while(budget > 0 && overall_sanity > 0)
|
||||
// Pick a ruin
|
||||
var/datum/map_template/ruin/ruin = null
|
||||
if(ruins && ruins.len)
|
||||
last_checked_ruin_index++ //ruins with no cost come first in the ruin list, so they'll get picked really often
|
||||
if(is_picking)
|
||||
ruin = ruins[pick(ruins)]
|
||||
else
|
||||
var/ruin_key = ruins[last_checked_ruin_index] //get the ruin's key via index
|
||||
ruin = ruins[ruin_key] //use that key to get the ruin datum itself
|
||||
if(ruin.cost >= 0) //if it has a non-negative cost, cancel out and pick another, to ensure true randomness
|
||||
is_picking = TRUE
|
||||
ruin = ruins[pick(ruins)]
|
||||
else
|
||||
log_world("Ruin loader had no ruins to pick from with [budget] left to spend.")
|
||||
@@ -51,9 +61,14 @@
|
||||
|
||||
var/obj/effect/ruin_loader/R = new /obj/effect/ruin_loader(T)
|
||||
R.Load(ruins,ruin)
|
||||
if(ruin.cost >= 0)
|
||||
budget -= ruin.cost
|
||||
if(!ruin.allow_duplicates)
|
||||
ruins -= ruin.name
|
||||
for(var/m in ruins)
|
||||
var/datum/map_template/ruin/ruin_to_remove = ruins[m]
|
||||
if(ruin_to_remove.id == ruin.id) //remove all ruins with the same ID, to make sure that ruins with multiple variants work properly
|
||||
ruins -= ruin_to_remove.name
|
||||
last_checked_ruin_index--
|
||||
break
|
||||
|
||||
if(!overall_sanity)
|
||||
|
||||
Reference in New Issue
Block a user