Add near/vis checks, log on event spawn failure

This commit is contained in:
mochi
2020-07-15 13:40:23 +02:00
parent 9f5e1cdbbc
commit 6172b075e8
6 changed files with 47 additions and 17 deletions
+22 -2
View File
@@ -517,14 +517,16 @@ proc/pollCandidates(Question, be_special_type, antag_age_check = FALSE, poll_tim
* Returns a list of vents that can be used as a potential spawn if they meet the criteria set by the arguments
*
* Will not include parent-less vents to the returned list.
* Only returns vents in the main station
* Arguments:
* * unwelded_only - Whether the list should only include vents that are unwelded
* * exclude_mobs_nearby - Whether to exclude vents that are near living mobs regardless of visibility
* * nearby_mobs_range - The range at which to look for living mobs around the vent for the above argument
* * exclude_visible_by_mobs - Whether to exclude vents that are visible to any living mob
* * min_network_size - The minimum length (non-inclusive) of the vent's parent network. A smaller number means vents in small networks (Security, Virology) will appear in the list
* * station_levels_only - Whether to only consider vents that are in a Z-level with a STATION_LEVEL trait
* * z_level - The Z-level number to look for vents in. Defaults to all
*/
/proc/get_valid_vent_spawns(unwelded_only = TRUE, min_network_size = 50, station_levels_only = TRUE, z_level = 0)
/proc/get_valid_vent_spawns(unwelded_only = TRUE, exclude_mobs_nearby = FALSE, nearby_mobs_range = world.view, exclude_visible_by_mobs = FALSE, min_network_size = 50, station_levels_only = TRUE, z_level = 0)
ASSERT(min_network_size >= 0)
ASSERT(z_level >= 0)
@@ -542,6 +544,24 @@ proc/pollCandidates(Question, be_special_type, antag_age_check = FALSE, poll_tim
continue
if(unwelded_only && vent.welded)
continue
if(exclude_mobs_nearby)
var/turf/T = get_turf(vent)
var/mobs_nearby = FALSE
for(var/mob/living/M in orange(nearby_mobs_range, T))
if(!M.is_dead())
mobs_nearby = TRUE
break
if(mobs_nearby)
continue
if(exclude_visible_by_mobs)
var/turf/T = get_turf(vent)
var/visible_by_mobs = FALSE
for(var/mob/living/M in viewers(world.view, T))
if(!M.is_dead())
visible_by_mobs = TRUE
break
if(visible_by_mobs)
continue
if(!vent.parent) // This seems to have been an issue in the past, so this is here until it's definitely fixed
log_debug("get_valid_vent_spawns(), vent has no parent: [vent], qdeled: [QDELETED(vent)], loc: [vent.loc]")
continue
@@ -13,6 +13,10 @@
/datum/event/borer_infestation/announce()
if(successSpawn)
GLOB.command_announcement.Announce("Unidentified lifesigns detected coming aboard [station_name()]. Secure any exterior access, including ducting and ventilation.", "Lifesign Alert", new_sound = 'sound/AI/aliens.ogg')
else
var/text = "Warning: Could not spawn any mobs for event Borer Infestation"
message_admins(text)
log_adminwarn(text)
/datum/event/borer_infestation/start()
var/list/vents = get_valid_vent_spawns()
+4
View File
@@ -11,6 +11,10 @@
/datum/event/alien_infestation/announce()
if(successSpawn)
GLOB.event_announcement.Announce("Unidentified lifesigns detected coming aboard [station_name()]. Secure any exterior access, including ducting and ventilation.", "Lifesign Alert", new_sound = 'sound/AI/aliens.ogg')
else
var/text = "Warning: Could not spawn any mobs for event Alien Infestation"
message_admins(text)
log_adminwarn(text)
/datum/event/alien_infestation/start()
var/list/vents = get_valid_vent_spawns()
+4
View File
@@ -6,6 +6,10 @@
/datum/event/blob/announce()
if(successSpawn)
GLOB.event_announcement.Announce("Confirmed outbreak of level 5 biohazard aboard [station_name()]. All personnel must contain the outbreak.", "Biohazard Alert", 'sound/AI/outbreak5.ogg')
else
var/text = "Warning: Could not spawn any mobs for event Blob"
message_admins(text)
log_adminwarn(text)
/datum/event/blob/start()
processing = FALSE //so it won't fire again in next tick
@@ -13,6 +13,10 @@ GLOBAL_VAR_INIT(sent_spiders_to_station, 0)
/datum/event/spider_infestation/announce()
if(successSpawn)
GLOB.event_announcement.Announce("Unidentified lifesigns detected coming aboard [station_name()]. Secure any exterior access, including ducting and ventilation.", "Lifesign Alert", new_sound = 'sound/AI/aliens.ogg')
else
var/text = "Warning: Could not spawn any mobs for event Spider Infestation"
message_admins(text)
log_adminwarn(text)
/datum/event/spider_infestation/start()
var/list/vents = get_valid_vent_spawns()
+9 -15
View File
@@ -11,9 +11,13 @@
/datum/event/spider_terror/announce()
if(successSpawn)
GLOB.command_announcement.Announce("Confirmed outbreak of level 3 biohazard aboard [station_name()]. All personnel must contain the outbreak.", "Biohazard Alert", 'sound/effects/siren-spooky.ogg')
else
var/text = "Warning: Could not spawn any mobs for event Terror Spiders"
message_admins(text)
log_adminwarn(text)
/datum/event/spider_terror/start()
var/list/vents = get_valid_vent_spawns()
var/list/vents = get_valid_vent_spawns(exclude_visible_by_mobs = TRUE)
var/spider_type
var/infestation_type = pick(1, 2, 3, 4, 5)
switch(infestation_type)
@@ -33,18 +37,8 @@
spider_type = /mob/living/simple_animal/hostile/poison/terror_spider/princess
spawncount = 2
while(spawncount && length(vents))
var/obj/vent = pick(vents)
// If the vent we picked has any living mob nearby, just remove it from the list, loop again, and pick something else.
var/turf/T = get_turf(vent)
var/hostiles_present = FALSE
for(var/mob/living/L in viewers(T))
if(L.stat != DEAD)
hostiles_present = TRUE
break
vents -= vent
if(!hostiles_present)
new spider_type(vent.loc)
spawncount--
successSpawn = TRUE
var/obj/vent = pick_n_take(vents)
new spider_type(vent.loc)
spawncount--
successSpawn = TRUE