Fixes things being statistically weighted to drop in security (#88788)

This commit is contained in:
The Sharkening
2025-01-07 13:09:20 -07:00
committed by GitHub
parent f2ea81b2a4
commit 7e20627406
14 changed files with 42 additions and 13 deletions

View File

@@ -376,6 +376,35 @@ Turf and target are separate in case you want to teleport some distance from a t
if (target)
return target
///Returns a random department of areas to pass into get_safe_random_station_turf() for more equal spawning.
/proc/get_safe_random_station_turf_equal_weight()
// Big list of departments, each with lists of each area subtype.
var/static/list/department_areas
if(isnull(department_areas))
department_areas = list(
subtypesof(/area/station/engineering), \
subtypesof(/area/station/medical), \
subtypesof(/area/station/science), \
subtypesof(/area/station/security), \
subtypesof(/area/station/service), \
subtypesof(/area/station/command), \
subtypesof(/area/station/hallway), \
subtypesof(/area/station/ai_monitored), \
subtypesof(/area/station/cargo)
)
var/list/area/final_department = pick(department_areas) // Pick a department
var/list/area/final_area_list = list()
for(var/area/checked_area as anything in final_department) // Check each area to make sure it exists on the station
if(checked_area in GLOB.the_station_areas)
final_area_list += checked_area
if(!final_area_list.len) // Failsafe
return get_safe_random_station_turf()
return get_safe_random_station_turf(final_area_list)
/**
* Checks whether the target turf is in a valid state to accept a directional construction
* such as windows or railings.

View File

@@ -70,7 +70,7 @@ SUBSYSTEM_DEF(market)
// Get random area, throw it somewhere there.
if(SHIPPING_METHOD_TELEPORT)
var/turf/targetturf = get_safe_random_station_turf()
var/turf/targetturf = get_safe_random_station_turf_equal_weight()
// This shouldn't happen.
if (!targetturf)
continue

View File

@@ -691,7 +691,7 @@
///Send a care package because it is not going well
/datum/station_trait/nebula/hostile/radiation/proc/send_care_package()
new /obj/effect/pod_landingzone (get_safe_random_station_turf(), new /obj/structure/closet/supplypod/centcompod (), new /obj/machinery/nebula_shielding/emergency/radiation ())
new /obj/effect/pod_landingzone (get_safe_random_station_turf_equal_weight(), new /obj/structure/closet/supplypod/centcompod (), new /obj/machinery/nebula_shielding/emergency/radiation ())
/datum/station_trait/nebula/hostile/radiation/send_instructions()
var/obj/machinery/nebula_shielding/shielder = /obj/machinery/nebula_shielding/radiation

View File

@@ -18,7 +18,7 @@
if(tgui_alert(user, "Are you sure you want to crash this market with no survivors?", "Protocol CRAB-17", list("Yes", "No")) == "Yes")
if(dumped || QDELETED(src)) //Prevents fuckers from cheesing alert
return FALSE
var/turf/targetturf = get_safe_random_station_turf()
var/turf/targetturf = get_safe_random_station_turf_equal_weight()
if (!targetturf)
return FALSE
var/list/accounts_to_rob = flatten_list(SSeconomy.bank_accounts_by_id)

View File

@@ -478,7 +478,7 @@ ADMIN_VERB(deadmin, R_NONE, "DeAdmin", "Shed your admin powers.", ADMIN_CATEGORY
ADMIN_VERB(populate_world, R_DEBUG, "Populate World", "Populate the world with test mobs.", ADMIN_CATEGORY_DEBUG, amount = 50 as num)
for (var/i in 1 to amount)
var/turf/tile = get_safe_random_station_turf()
var/turf/tile = get_safe_random_station_turf_equal_weight()
var/mob/living/carbon/human/hooman = new(tile)
hooman.equipOutfit(pick(subtypesof(/datum/outfit)))
testing("Spawned test mob at [get_area_name(tile, TRUE)] ([tile.x],[tile.y],[tile.z])")

View File

@@ -87,7 +87,7 @@ GLOBAL_LIST_EMPTY(blob_nodes)
break
else // no blob starts so look for an alternate
for(var/i in 1 to 16)
var/turf/picked_safe = get_safe_random_station_turf()
var/turf/picked_safe = get_safe_random_station_turf_equal_weight()
if(is_valid_turf(picked_safe))
T = picked_safe
break

View File

@@ -41,7 +41,7 @@
var/location_sanity = 0
while((length(smashes) + num_drained) < how_many_can_we_make && location_sanity < 100)
var/turf/chosen_location = get_safe_random_station_turf()
var/turf/chosen_location = get_safe_random_station_turf_equal_weight()
// We don't want them close to each other - at least 1 tile of separation
var/list/nearby_things = range(1, chosen_location)

View File

@@ -519,7 +519,7 @@
return
// Teleport them to a random safe coordinate on the station z level.
var/turf/open/floor/safe_turf = get_safe_random_station_turf()
var/turf/open/floor/safe_turf = get_safe_random_station_turf_equal_weight()
var/obj/effect/landmark/observer_start/backup_loc = locate(/obj/effect/landmark/observer_start) in GLOB.landmarks_list
if(!safe_turf)
safe_turf = get_turf(backup_loc)

View File

@@ -58,7 +58,7 @@ GLOBAL_LIST_EMPTY(voidwalker_void)
driver.add_traits(wisp_driver_traits, REF(src))
add_atom_colour(random_color(), FIXED_COLOUR_PRIORITY)
addtimer(CALLBACK(driver, TYPE_PROC_REF(/atom/movable, forceMove), get_safe_random_station_turf()), 60 SECONDS)
addtimer(CALLBACK(driver, TYPE_PROC_REF(/atom/movable, forceMove), get_safe_random_station_turf_equal_weight()), 60 SECONDS)
/obj/effect/wisp_mobile/relaymove(mob/living/user, direction)
if(can_move >= world.time)

View File

@@ -379,7 +379,7 @@
addtimer(CALLBACK(src, PROC_REF(send_away)), 2 SECONDS)
/obj/effect/temp_visual/teleporting_tornado/proc/send_away()
var/turf/ending_turfs = get_safe_random_station_turf()
var/turf/ending_turfs = get_safe_random_station_turf_equal_weight()
for(var/mob/stored_mobs as anything in pickedup_mobs)
do_teleport(stored_mobs, ending_turfs, channel = TELEPORT_CHANNEL_MAGIC)
animate(stored_mobs, pixel_y = null, time = 1 SECONDS)

View File

@@ -253,7 +253,7 @@
var/location_sanity = 0
// Copied from the influences manager, but we don't want to obey the cap on influences per heretic.
while(created < to_create && location_sanity < 100)
var/turf/chosen_location = get_safe_random_station_turf()
var/turf/chosen_location = get_safe_random_station_turf_equal_weight()
// We don't want them close to each other - at least 1 tile of separation
var/list/nearby_things = range(1, chosen_location)

View File

@@ -17,7 +17,7 @@
if(.)
return
if(tgui_alert(usr,question,name,list("Yes","No")) == "Yes" && Adjacent(user))
var/turf/T = zlevels ? find_safe_turf(zlevels=zlevels) : get_safe_random_station_turf()
var/turf/T = zlevels ? find_safe_turf(zlevels=zlevels) : get_safe_random_station_turf_equal_weight()
if(T)
var/atom/movable/AM = user.pulling

View File

@@ -22,7 +22,7 @@
var/list/epicentreList = list()
for(var/i in 1 to lightsoutAmount)
var/turf/T = get_safe_random_station_turf()
var/turf/T = get_safe_random_station_turf_equal_weight()
if(istype(T))
epicentreList += T

View File

@@ -181,7 +181,7 @@ GLOBAL_LIST_EMPTY(exodrone_launchers)
/// Crashes the drone somewhere random if there's no launchpad to be found.
/obj/item/exodrone/proc/drop_somewhere_on_station()
var/turf/random_spot = get_safe_random_station_turf()
var/turf/random_spot = get_safe_random_station_turf_equal_weight()
var/obj/structure/closet/supplypod/pod = podspawn(list(
"target" = random_spot,