refactor: Biohazard stats (again) (#26424)

This commit is contained in:
warriorstar-orion
2024-08-08 12:35:12 -04:00
committed by GitHub
parent eeea962245
commit 2a3a84b438
4 changed files with 48 additions and 81 deletions
+35 -74
View File
@@ -125,7 +125,7 @@ SUBSYSTEM_DEF(ticker)
current_state = GAME_STATE_FINISHED
if(GAME_STATE_FINISHED)
if(SSshuttle.emergency.mode >= SHUTTLE_ENDGAME && !mode.station_was_nuked)
event_blackbox(outcome = ROUND_END_CREW_TRANSFER)
record_biohazard_results()
current_state = GAME_STATE_FINISHED
Master.SetRunLevel(RUNLEVEL_POSTGAME) // This shouldnt process more than once, but you never know
auto_toggle_ooc(TRUE) // Turn it on
@@ -801,79 +801,20 @@ SUBSYSTEM_DEF(ticker)
records.Cut()
flagged_antag_rollers.Cut()
/// This proc is for recording biohazard events, and blackboxing if they lived, died, or ended the round. This currently applies to: Terror spiders, Xenomorphs, and Blob.
/datum/controller/subsystem/ticker/proc/event_blackbox(outcome = ROUND_END_CREW_TRANSFER)
for(var/I in SSevents.biohazards_this_round)
switch(I)
if(TS_INFESTATION_GREEN_SPIDER, TS_INFESTATION_PRINCE_SPIDER, TS_INFESTATION_WHITE_SPIDER, TS_INFESTATION_PRINCESS_SPIDER, TS_INFESTATION_QUEEN_SPIDER)
var/output = "unknown spider type"
switch(I)
if(TS_INFESTATION_GREEN_SPIDER)
output = "Green Terrors"
if(TS_INFESTATION_PRINCE_SPIDER)
output = "Prince Terror"
if(TS_INFESTATION_WHITE_SPIDER)
output = "White Terrors"
if(TS_INFESTATION_PRINCESS_SPIDER)
output = "Princess Terrors"
if(TS_INFESTATION_QUEEN_SPIDER)
output = "Queen Terrors"
var/spiders = 0
for(var/mob/living/simple_animal/hostile/poison/terror_spider/S in GLOB.ts_spiderlist)
if(S.ckey)
spiders++
if(spiders >= 5 || (output == "Prince Terror" && spiders == 1)) //If a prince lives, record as win.
switch(outcome)
if(ROUND_END_NUCLEAR)
SSblackbox.record_feedback("tally", "Biohazard nuclear victories", 1, output)
if(ROUND_END_CREW_TRANSFER)
SSblackbox.record_feedback("tally", "Biohazard survives to normal round end", 1, output)
if(ROUND_END_FORCED)
SSblackbox.record_feedback("tally", "Biohazard survives to admin round end", 1, output)
else
switch(outcome)
if(ROUND_END_NUCLEAR)
SSblackbox.record_feedback("tally", "Biohazard dies station nuked", 1, output)
if(ROUND_END_CREW_TRANSFER)
SSblackbox.record_feedback("tally", "Biohazard dies normal end", 1, output)
if(ROUND_END_FORCED)
SSblackbox.record_feedback("tally", "Biohazard dies admin round end", 1, output)
if("Xenomorphs")
var/living_xenos = count_xenomorps()
if(living_xenos > 5)
switch(outcome)
if(ROUND_END_NUCLEAR)
SSblackbox.record_feedback("tally", "Xeno nuclear victories", 1, "Xenomorphs")
if(ROUND_END_CREW_TRANSFER)
SSblackbox.record_feedback("tally", "Xeno survives to normal round end", 1, "Xenomorphs")
if(ROUND_END_FORCED)
SSblackbox.record_feedback("tally", "Xeno survives to admin round end", 1, "Xenomorphs")
else
switch(outcome)
if(ROUND_END_NUCLEAR)
SSblackbox.record_feedback("tally", "Xeno dies station nuked", 1, "Xenomorphs")
if(ROUND_END_CREW_TRANSFER)
SSblackbox.record_feedback("tally", "Xeno dies normal end", 1, "Xenomorphs")
if(ROUND_END_FORCED)
SSblackbox.record_feedback("tally", "Xeno dies admin round end", 1, "Xenomorphs")
if("Blob")
if(length(SSticker.mode.blob_overminds))
switch(outcome)
if(ROUND_END_NUCLEAR)
SSblackbox.record_feedback("tally", "Blob nuclear victories", 1, "Blob")
if(ROUND_END_CREW_TRANSFER)
SSblackbox.record_feedback("tally", "Blob survives to normal round end", 1, "Blob")
if(ROUND_END_FORCED)
SSblackbox.record_feedback("tally", "Blob survives to admin round end", 1, "Blob")
else
switch(outcome)
if(ROUND_END_NUCLEAR)
SSblackbox.record_feedback("tally", "Blob dies station nuked", 1, "Blob")
if(ROUND_END_CREW_TRANSFER)
SSblackbox.record_feedback("tally", "Blob dies normal end", 1, "Blob")
if(ROUND_END_FORCED)
SSblackbox.record_feedback("tally", "Blob dies admin round end", 1, "Blob")
/// This proc is for recording biohazard events, and blackboxing if they lived,
/// died, or ended the round. This currently applies to: Terror spiders,
/// Xenomorphs, and Blob.
///
/// This code is predicated on the assumption that multiple midrounds
/// of the same type are either extremely rare or impossible. We don't want to get
/// into the insanity of trying to record if the first xeno biohazard was defeated
/// but the second xeno biohazard was nuked.
/datum/controller/subsystem/ticker/proc/record_biohazard_results()
for(var/biohazard in SSevents.biohazards_this_round)
if(biohazard_active_threat(biohazard))
SSblackbox.record_feedback("nested tally", "biohazards", 1, list("survived", biohazard))
else
SSblackbox.record_feedback("nested tally", "biohazards", 1, list("defeated", biohazard))
/datum/controller/subsystem/ticker/proc/count_xenomorps()
. = 0
@@ -881,3 +822,23 @@ SUBSYSTEM_DEF(ticker)
if(xeno_mind.current?.stat == DEAD)
continue
.++
/// Return whether or not a given biohazard is an active threat.
/// For blobs, this is simply if there are any overminds left. For terrors and
/// xenomorphs, this is whether they have overwhelming numbers.
/datum/controller/subsystem/ticker/proc/biohazard_active_threat(biohazard)
switch(biohazard)
if(TS_INFESTATION_GREEN_SPIDER, TS_INFESTATION_WHITE_SPIDER, TS_INFESTATION_PRINCESS_SPIDER, TS_INFESTATION_QUEEN_SPIDER)
var/spiders = 0
for(var/mob/living/simple_animal/hostile/poison/terror_spider/S in GLOB.ts_spiderlist)
if(S.ckey)
spiders++
return spiders >= 5
if(TS_INFESTATION_PRINCE_SPIDER)
return length(GLOB.ts_spiderlist)
if(BIOHAZARD_XENO)
return count_xenomorps() > 5
if(BIOHAZARD_BLOB)
return length(SSticker.mode.blob_overminds)
return FALSE