diff --git a/code/modules/antagonists/eldritch_cult/eldritch_items.dm b/code/modules/antagonists/eldritch_cult/eldritch_items.dm
index ef4e849995b..86dfec56991 100644
--- a/code/modules/antagonists/eldritch_cult/eldritch_items.dm
+++ b/code/modules/antagonists/eldritch_cult/eldritch_items.dm
@@ -319,6 +319,10 @@
. = ..()
linked_action = new(src)
+/obj/item/melee/rune_knife/Destroy()
+ . = ..()
+ QDEL_NULL(linked_action)
+
/obj/item/melee/rune_knife/pickup(mob/user)
. = ..()
linked_action.Grant(user, src)
@@ -339,10 +343,10 @@
to_chat(user,"You can't draw runes that close to each other!")
return
- for(var/X in current_runes)
- var/obj/structure/trap/eldritch/eldritch = X
- if(QDELETED(eldritch) || !eldritch)
- current_runes -= eldritch
+ for(var/_rune_ref in current_runes)
+ var/datum/weakref/rune_ref = _rune_ref
+ if(!rune_ref.resolve())
+ current_runes -= rune_ref
if(current_runes.len >= max_rune_amt)
to_chat(user,"The blade cannot support more runes!")
@@ -369,7 +373,7 @@
drawing = FALSE
var/obj/structure/trap/eldritch/eldritch = new type(target)
eldritch.set_owner(user)
- current_runes += eldritch
+ current_runes += WEAKREF(eldritch)
/datum/action/innate/rune_shatter
name = "Rune break"
@@ -386,10 +390,10 @@
return ..()
/datum/action/innate/rune_shatter/Activate()
- for(var/X in sword.current_runes)
- var/obj/structure/trap/eldritch/eldritch = X
- if(!QDELETED(eldritch) && eldritch)
- qdel(eldritch)
+ for(var/_rune_ref in sword.current_runes)
+ var/datum/weakref/rune_ref = _rune_ref
+ qdel(rune_ref.resolve())
+ sword.current_runes.Cut()
/obj/item/eldritch_potion
name = "Brew of Day and Night"
diff --git a/code/modules/antagonists/eldritch_cult/eldritch_structures.dm b/code/modules/antagonists/eldritch_cult/eldritch_structures.dm
index c1d2ae4f1d0..f40b9bf082a 100644
--- a/code/modules/antagonists/eldritch_cult/eldritch_structures.dm
+++ b/code/modules/antagonists/eldritch_cult/eldritch_structures.dm
@@ -111,14 +111,14 @@
desc = "Collection of unknown symbols, they remind you of days long gone..."
icon = 'icons/obj/eldritch.dmi'
charges = 1
- ///Owner of the trap
- var/mob/owner
+ /// Weakref containing the owner of the trap
+ var/datum/weakref/owner
/obj/structure/trap/eldritch/Crossed(atom/movable/AM)
if(!isliving(AM))
return ..()
var/mob/living/living_mob = AM
- if((owner && living_mob == owner) || IS_HERETIC(living_mob) || IS_HERETIC_MONSTER(living_mob))
+ if(living_mob == owner?.resolve() || IS_HERETIC(living_mob) || IS_HERETIC_MONSTER(living_mob))
return
return ..()
@@ -128,8 +128,8 @@
qdel(src)
///Proc that sets the owner
-/obj/structure/trap/eldritch/proc/set_owner(mob/_owner)
- owner = _owner
+/obj/structure/trap/eldritch/proc/set_owner(mob/owner)
+ src.owner = WEAKREF(owner)
/obj/structure/trap/eldritch/alert
name = "alert carving"