From 9e9b5ffdf326c2df27df6eae7529022b74ead0a6 Mon Sep 17 00:00:00 2001
From: Sun-Soaked <45698967+Sun-Soaked@users.noreply.github.com>
Date: Thu, 18 Apr 2024 23:48:16 -0400
Subject: [PATCH] Fixes Static Anomalies (#2897)
## About The Pull Request
bzzt. kss bzzt kzz (fixes the static anomaly, it no longer does a weird
runtime related to attempting to run mob code on a spawner effect. The
resulting fucked up chat message is also fixed.)
bzzzap kzzazz mmm bzzzaap (Adds a weakref on mob spawners pointing to
their spawned mob. This is also a surprise tool that'll help us later w.
stuff related to manipulating entities after they've been spawned. I'll
prolly port the full mob spawner rework at some point)
## Why It's Good For The Game
bzzz
## Changelog
:cl:
fix: planetary static anomalies no longer drop a broken spawner.
code: mob spawners now store a weakref on their spawned object
/:cl:
---
.../objects/effects/anomalies/anomalies_static.dm | 15 +++++++++------
code/modules/awaymissions/corpse.dm | 4 ++++
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/code/game/objects/effects/anomalies/anomalies_static.dm b/code/game/objects/effects/anomalies/anomalies_static.dm
index 205a8778d394..a00babe5844a 100644
--- a/code/game/objects/effects/anomalies/anomalies_static.dm
+++ b/code/game/objects/effects/anomalies/anomalies_static.dm
@@ -47,7 +47,7 @@
var/mob/living/carbon/victim = looking
var/obj/effect/anomaly/tvstatic/planetary/expansion
expansion = new(get_turf(victim))
- visible_message(" The static overtakes [victim], [expansion] taking their place!")
+ visible_message(span_warning("The static overtakes [victim], taking their place!"))
victim.death()
expansion.stored_mob = victim
victim.forceMove(expansion)
@@ -89,13 +89,13 @@
/obj/effect/anomaly/tvstatic/detonate()
for(var/mob/living/carbon/human/looking in range(effectrange, src))
- visible_message(" The static lashes out, agony filling your mind as its tendrils scrape your thoughts!")
+ visible_message(span_boldwarning(" The static lashes out, agony filling your mind as its tendrils scrape your thoughts!"))
if (!HAS_TRAIT(looking, TRAIT_MINDSHIELD) && looking.stat != DEAD)
looking.adjustOrganLoss(ORGAN_SLOT_BRAIN, 100, 200)
playsound(src, 'sound/effects/stall.ogg', 100)
if(stored_mob)
mangle_corpse()
- visible_message("The static sputters out [stored_mob], their body coming out in a burst of blood and gore!")
+ visible_message(span_warning("The static sputters out [stored_mob], their body coming out in a burst of blood and gore!"))
new /obj/effect/gibspawner/human(loc)
stored_mob.forceMove(get_turf(src))
stored_mob = null
@@ -111,7 +111,7 @@
var/turf/T = get_turf(src)
if(T)
if(stored_mob)
- visible_message("The static spits out [stored_mob], their body coming out in a burst!")
+ visible_message(span_warning("The static spits out [stored_mob], their body coming out in a burst!"))
stored_mob.forceMove(get_turf(src))
stored_mob = null
. = ..()
@@ -122,8 +122,11 @@
immobile = TRUE
/obj/effect/anomaly/tvstatic/planetary/Initialize(mapload)
- if(prob(25))
- stored_mob = /obj/effect/mob_spawn/human/corpse/damaged
+ if(prob(25) & !stored_mob)
+ var/obj/effect/mob_spawn/human/corpse/damaged/legioninfested/vicspawner = new (src)
+ var/mob/living/carbon/victim = (vicspawner.spawned_mob_ref)?.resolve()
+ src.stored_mob = victim
+ victim.forceMove(src)
. = ..()
/obj/effect/particle_effect/staticball
diff --git a/code/modules/awaymissions/corpse.dm b/code/modules/awaymissions/corpse.dm
index 8e8739a5acb0..40932634cfa4 100644
--- a/code/modules/awaymissions/corpse.dm
+++ b/code/modules/awaymissions/corpse.dm
@@ -32,6 +32,8 @@
var/show_flavour = TRUE
var/banType = ROLE_LAVALAND
var/ghost_usable = TRUE
+ /// Weakref to the mob this spawner created - just if you needed to do something with it.
+ var/datum/weakref/spawned_mob_ref
//ATTACK GHOST IGNORING PARENT RETURN VALUE
/obj/effect/mob_spawn/attack_ghost(mob/user)
@@ -128,6 +130,7 @@
MM.name = M.real_name
if(uses > 0)
uses--
+ spawned_mob_ref = WEAKREF(M)
if(!permanent && !uses)
qdel(src)
return M
@@ -220,6 +223,7 @@
if(istype(C))
C.sensor_mode = NO_SENSORS
+
var/obj/item/card/id/W = H.wear_id
if(W)
if(H.age)