Refactor spawning on vents into one proc

This commit is contained in:
mochi
2020-07-15 12:53:17 +02:00
parent bce3b7755d
commit 9f5e1cdbbc
7 changed files with 69 additions and 67 deletions

View File

@@ -3,7 +3,7 @@
var/highpop_trigger = 80
var/spawncount = 2
var/list/playercount
var/successSpawn = 0 //So we don't make a command report if nothing gets spawned.
var/successSpawn = FALSE //So we don't make a command report if nothing gets spawned.
/datum/event/alien_infestation/setup()
announceWhen = rand(announceWhen, announceWhen + 50)
@@ -13,19 +13,14 @@
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')
/datum/event/alien_infestation/start()
var/list/vents = list()
var/list/vents = get_valid_vent_spawns()
playercount = length(GLOB.clients)//grab playercount when event starts not when game starts
if(playercount >= highpop_trigger) //spawn with 4 if highpop
spawncount = 4
for(var/obj/machinery/atmospherics/unary/vent_pump/temp_vent in SSair.atmos_machinery)
if(is_station_level(temp_vent.loc.z) && !temp_vent.welded)
if(temp_vent.parent.other_atmosmch.len > 50) //Stops Aliens getting stuck in small networks. See: Security, Virology
vents += temp_vent
spawn()
var/list/candidates = pollCandidates("Do you want to play as an alien?", ROLE_ALIEN, 1)
while(spawncount > 0 && vents.len && candidates.len)
while(spawncount && length(vents) && length(candidates))
var/obj/vent = pick_n_take(vents)
var/mob/C = pick_n_take(candidates)
if(C)
@@ -37,4 +32,4 @@
SSticker.mode.xenos += new_xeno.mind
spawncount--
successSpawn = 1
successSpawn = TRUE

View File

@@ -1,9 +1,11 @@
/datum/event/blob
announceWhen = 180
endWhen = 240
var/successSpawn = FALSE //So we don't make a command report if nothing gets spawned.
/datum/event/blob/announce()
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')
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')
/datum/event/blob/start()
processing = FALSE //so it won't fire again in next tick
@@ -16,12 +18,9 @@
if(!candidates.len)
return kill()
var/list/vents = list()
for(var/obj/machinery/atmospherics/unary/vent_pump/temp_vent in GLOB.all_vent_pumps)
if(is_station_level(temp_vent.loc.z) && !temp_vent.welded)
if(temp_vent.parent.other_atmosmch.len > 50)
vents += temp_vent
var/list/vents = get_valid_vent_spawns()
if(!length(vents))
return
var/obj/vent = pick(vents)
var/mob/living/simple_animal/mouse/blobinfected/B = new(vent.loc)
var/mob/M = pick(candidates)
@@ -30,4 +29,5 @@
to_chat(B, "<span class='userdanger'>You are now a mouse, infected with blob spores. Find somewhere isolated... before you burst and become the blob! Use ventcrawl (alt-click on vents) to move around.</span>")
notify_ghosts("Infected Mouse has appeared in [get_area(B)].", source = B)
successSpawn = TRUE
processing = TRUE // Let it naturally end, if it runs successfully

View File

@@ -3,6 +3,7 @@ GLOBAL_VAR_INIT(sent_spiders_to_station, 0)
/datum/event/spider_infestation
announceWhen = 400
var/spawncount = 1
var/successSpawn = FALSE //So we don't make a command report if nothing gets spawned.
/datum/event/spider_infestation/setup()
announceWhen = rand(announceWhen, announceWhen + 50)
@@ -10,20 +11,15 @@ GLOBAL_VAR_INIT(sent_spiders_to_station, 0)
GLOB.sent_spiders_to_station = 1
/datum/event/spider_infestation/announce()
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')
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')
/datum/event/spider_infestation/start()
var/list/vents = list()
for(var/obj/machinery/atmospherics/unary/vent_pump/temp_vent in SSair.atmos_machinery)
if(is_station_level(temp_vent.loc.z) && !temp_vent.welded)
if(temp_vent.parent.other_atmosmch.len > 50)
vents += temp_vent
while((spawncount >= 1) && vents.len)
var/obj/vent = pick(vents)
var/list/vents = get_valid_vent_spawns()
while(spawncount && length(vents))
var/obj/vent = pick_n_take(vents)
var/obj/structure/spider/spiderling/S = new(vent.loc)
if(prob(66))
S.grow_as = /mob/living/simple_animal/hostile/poison/giant_spider/nurse
vents -= vent
spawncount--
successSpawn = TRUE

View File

@@ -2,25 +2,18 @@
/datum/event/spider_terror
announceWhen = 240
var/spawncount = 1
var/successSpawn = FALSE //So we don't make a command report if nothing gets spawned.
/datum/event/spider_terror/setup()
announceWhen = rand(announceWhen, announceWhen + 30)
spawncount = 1
/datum/event/spider_terror/announce()
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')
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')
/datum/event/spider_terror/start()
var/list/vents = list()
for(var/obj/machinery/atmospherics/unary/vent_pump/temp_vent in GLOB.all_vent_pumps)
if(is_station_level(temp_vent.loc.z) && !temp_vent.welded)
if(!temp_vent.parent)
// Issue happening more often with vents. Log and continue. Delete once solved
log_debug("spider_terror/start(), vent has no parent: [temp_vent], qdeled: [QDELETED(temp_vent)], loc: [temp_vent.loc]")
continue
if(temp_vent.parent.other_atmosmch.len > 50)
vents += temp_vent
var/list/vents = get_valid_vent_spawns()
var/spider_type
var/infestation_type = pick(1, 2, 3, 4, 5)
switch(infestation_type)
@@ -39,15 +32,9 @@
if(5)
spider_type = /mob/living/simple_animal/hostile/poison/terror_spider/princess
spawncount = 2
while(spawncount >= 1 && vents.len)
var/obj/machinery/atmospherics/unary/vent_pump/vent = pick(vents)
if(vent.welded)
vents -= vent
continue
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))
@@ -59,4 +46,5 @@
if(!hostiles_present)
new spider_type(vent.loc)
spawncount--
successSpawn = TRUE

View File

@@ -1094,21 +1094,14 @@ GLOBAL_LIST_INIT(slot_equipment_priority, list( \
return
//find a viable mouse candidate
var/mob/living/simple_animal/mouse/host
var/obj/machinery/atmospherics/unary/vent_pump/vent_found
var/list/found_vents = list()
for(var/obj/machinery/atmospherics/unary/vent_pump/v in SSair.atmos_machinery)
if(!v.welded && v.z == src.z)
found_vents.Add(v)
if(found_vents.len)
vent_found = pick(found_vents)
host = new /mob/living/simple_animal/mouse(vent_found.loc)
else
to_chat(src, "<span class='warning'>Unable to find any unwelded vents to spawn mice at.</span>")
if(host)
var/list/found_vents = get_valid_vent_spawns(min_network_size = 0, station_levels_only = FALSE, z_level = z)
if(length(found_vents))
var/obj/vent_found = pick(found_vents)
var/mob/living/simple_animal/mouse/host = new(vent_found.loc)
host.ckey = src.ckey
to_chat(host, "<span class='info'>You are now a mouse. Try to avoid interaction with players, and do not give hints away that you are more than a simple rodent.</span>")
else
to_chat(src, "<span class='warning'>Unable to find any unwelded vents to spawn mice at.</span>")
/mob/proc/assess_threat() //For sec bot threat assessment
return 5