General fixes and adding a general helper

This commit is contained in:
Archie
2022-09-13 15:30:13 -03:00
parent d4f4ef4b64
commit 58e8aef49d
5 changed files with 84 additions and 72 deletions
+74
View File
@@ -0,0 +1,74 @@
// This list was originally created to narrow the list of safe areas for mobs to spawn in the station. If an area is considered too dangerous for something to spawn in, kindly add it to this list.
GLOBAL_LIST_INIT(basic_safe_area_list, typecacheof(list(
/area/space,
/area/shuttle,
/area/mine,
/area/holodeck,
/area/ruin,
/area/hallway,
/area/hallway/primary,
/area/hallway/secondary,
/area/hallway/secondary/entry,
/area/engine/supermatter,
/area/engine/atmospherics_engine,
/area/engine/engineering/reactor_core,
/area/engine/engineering/reactor_control,
/area/ai_monitored/turret_protected,
/area/layenia/cloudlayer,
/area/asteroid/nearstation,
/area/science/server,
/area/science/explab,
/area/science/xenobiology,
/area/security/processing)))
// Performance intensive check for picking an area with turfs that are considered the safest possible to spawn something in.
//Only use this for creatures, as it considers people around, temperature, area size and more.
/proc/get_safest_possible_turfs(list/blacklisted_areas, spawncount)
var/list/area/stationAreas = list()
var/list/area/eligible_areas = list()
var/validFound = FALSE
var/list/turf/validTurfs = list()
var/area/pickedArea
if(!blacklisted_areas.len)
blacklisted_areas = GLOB.basic_safe_area_list
for(var/area/A in world) // Get the areas in the Z level
if(A.z == SSmapping.station_start)
stationAreas += A
for(var/area/place in stationAreas) // first we check if it's a valid area
if(place.outdoors)
continue
if(place.areasize < 16)
continue
if(is_type_in_typecache(place, blacklisted_areas))
continue
eligible_areas += place
for(var/area/place in eligible_areas) // now we check if there are people in that area
var/numOfPeople
for(var/mob/living/carbon/H in place)
numOfPeople++
break
if(numOfPeople > 0)
eligible_areas -= place // removes this area from the list of eligible areas, it has people in it
while(!validFound || !eligible_areas.len)
pickedArea = pick_n_take(eligible_areas)
var/list/turf/t = get_area_turfs(pickedArea, SSmapping.station_start)
for(var/turf/thisTurf in t) // now we check if it's a closed turf, cold turf or occupied turf and yeet it
if(isopenturf(thisTurf))
var/turf/open/tempGet = thisTurf
if(tempGet.air.temperature <= T0C)
t -= thisTurf
continue
if(isclosedturf(thisTurf))
t -= thisTurf
else
for(var/obj/O in thisTurf)
if(O.density && !(istype(O, /obj/structure/table)))
t -= thisTurf
break
if(t.len >= spawncount) //Is the number of available turfs equal or bigger than spawncount?
validFound = TRUE
validTurfs = t
return validTurfs
if(!validFound)
message_admins("A function attempted to get safe turfs, but we found none.")
return null
+1 -1
View File
@@ -67,7 +67,7 @@
var/whitelist_type = ""
//load characters loadout on spawn
var loadout = TRUE
var/loadout = TRUE
//Only override this proc
//H is usually a human unless an /equip override transformed it
@@ -83,6 +83,8 @@
var/radio_key = /obj/item/encryptionkey/headset_medsci
/obj/machinery/safety_tether/Initialize()
//ensures light is properly centered around the tether. Removes lighting system's pixel approximation that breaks it.
light_source = get_turf(src)
. = ..()
//Adds this to the global list of safety tethers in the world to pull from when chasms attempt to drop mobs
@@ -95,10 +97,7 @@
radio.canhear_range = 0
radio.recalculateChannels()
//ensures light is properly centered around the tether. Removes lighting system's pixel approximation that breaks it.
light_source = get_turf(src)
update_icon()
power_change() //Here to start lights on ititialization.
/obj/machinery/safety_tether/Destroy()
QDEL_NULL(radio)
@@ -228,7 +227,8 @@
SPEAKCOMMON("The Safety Tether's shut down from a lack of power.")
light_source.set_light(0)
else
SPEAKCOMMON("The Safety Tether is back online.")
if(SSticker.HasRoundStarted())
SPEAKCOMMON("The Safety Tether is back online.")
light_source.set_light(brightness_on, light_power, light_color)
update_icon()
@@ -251,4 +251,4 @@
//#undef SPEAK
#undef SPEAKCOMMON
#undef SPEAKMEDICAL
#undef SPEAKSCIENCE
#undef SPEAKSCIENCE
+3 -66
View File
@@ -322,26 +322,6 @@
/datum/round_event/mimic_infestation
announceWhen = 200
var/static/list/mimic_station_areas_blacklist = typecacheof(/area/space,
/area/shuttle,
/area/mine,
/area/holodeck,
/area/ruin,
/area/hallway,
/area/hallway/primary,
/area/hallway/secondary,
/area/hallway/secondary/entry,
/area/engine/supermatter,
/area/engine/atmospherics_engine,
/area/engine/engineering/reactor_core,
/area/engine/engineering/reactor_control,
/area/ai_monitored/turret_protected,
/area/layenia/cloudlayer,
/area/asteroid/nearstation,
/area/science/server,
/area/science/explab,
/area/science/xenobiology,
/area/security/processing)
var/spawncount = 1
fakeable = FALSE
@@ -353,54 +333,11 @@
priority_announce("Unidentified lifesigns detected aboard [station_name()]. Secure any exterior access, including ducting and ventilation.", "Lifesign Alert", 'sound/ai/aliens.ogg')
/datum/round_event/mimic_infestation/start()
var/list/area/stationAreas = list()
var/list/area/eligible_areas = list()
for(var/area/A in world) // Get the areas in the Z level
if(A.z == SSmapping.station_start)
stationAreas += A
for(var/area/place in stationAreas) // first we check if it's a valid area
if(place.outdoors)
continue
if(place.areasize < 16)
continue
if(is_type_in_typecache(place, mimic_station_areas_blacklist))
continue
eligible_areas += place
for(var/area/place in eligible_areas) // now we check if there are people in that area
var/numOfPeople
for(var/mob/living/carbon/H in place)
numOfPeople++
break
if(numOfPeople > 0)
eligible_areas -= place
var/validFound = FALSE
var/list/turf/validTurfs = list()
var/area/pickedArea
while(!validFound || !eligible_areas.len)
pickedArea = pick_n_take(eligible_areas)
var/list/turf/t = get_area_turfs(pickedArea, SSmapping.station_start)
for(var/turf/thisTurf in t) // now we check if it's a closed turf, cold turf or occupied turf and yeet it
if(isopenturf(thisTurf))
var/turf/open/tempGet = thisTurf
if(tempGet.air.temperature <= T0C)
t -= thisTurf
continue
if(isclosedturf(thisTurf))
t -= thisTurf
else
for(var/obj/O in thisTurf)
if(O.density && !(istype(O, /obj/structure/table)))
t -= thisTurf
break
if(t.len >= spawncount) //Is the number of available turfs equal or bigger than spawncount?
validFound = TRUE
validTurfs = t
if(!eligible_areas.len)
var/list/turf/validTurfs = get_safest_possible_turfs(GLOB.basic_safe_area_list, spawncount)
if(!validTurfs.len)
message_admins("No eligible areas for spawning mimics.")
return WAITING_FOR_SOMETHING
var/area/pickedArea = get_area(pick(validTurfs))
notify_ghosts("A group of mimics has spawned in [pickedArea]!", source=pickedArea, action=NOTIFY_ATTACK, flashwindow = FALSE)
while(spawncount > 0 && validTurfs.len)
spawncount--
+1
View File
@@ -159,6 +159,7 @@
#include "code\__HELPERS\typelists.dm"
#include "code\__HELPERS\unique_ids.dm"
#include "code\__HELPERS\unsorted.dm"
#include "code\__HELPERS\unsorted_hyper.dm"
#include "code\__HELPERS\verbs.dm"
#include "code\__HELPERS\view.dm"
#include "code\__HELPERS\sorts\__main.dm"