Fixes runtime in golem body swap, Fixes some hard deletes assocaited with golems and mind masters (#73373)

## About The Pull Request

Fixes #73368 

Golems didn't mind transfer on body swap until after the body was
finished creating, this created an issue as golems also did mind
assignment business while creating the body. So the
`mind.enslave_to_creator()` part runtime error'd and caused the create
to fail, which in turn caused the shell to not be consumed.

While sorting this out, I noticed that shells and golems hold a hard
reference to their owner. Yep, hard deletes. Changes mind `enslaved_to`
to a weakref, changes golem `owner` to a weakref, straight up removes
golem `owner` tracking on species because it was ONLY used for card
board golems when it could've just grabbed mind master

## Why It's Good For The Game

No more infinite golem shells

## Changelog

🆑 Melbert
fix: Transferring golem shells no longer make you a free man and also
results in infinite golem shells
fix: Servant golems are considerably less free
fix: Fixes some hard deletes related to mob minds being enslaved to
other mobs
/🆑
This commit is contained in:
MrMelbert
2023-02-17 16:06:49 -06:00
committed by GitHub
parent 75e5a0a5cb
commit e8d209c6f4
8 changed files with 87 additions and 65 deletions
+10 -6
View File
@@ -15,7 +15,7 @@
////Human specific stuff. Don't set these if you aren't using a human, the unit tests will put a stop to your sinful hand.
///sets the human as a species, use a typepath (example: /datum/species/skeleton)
var/mob_species
var/datum/species/mob_species
///equips the human with an outfit.
var/datum/outfit/outfit
///for mappers to override parts of the outfit. really only in here for secret away missions, please try to refrain from using this out of laziness
@@ -181,7 +181,15 @@
/obj/effect/mob_spawn/ghost_role/special(mob/living/spawned_mob, mob/mob_possessor)
. = ..()
if(mob_possessor)
spawned_mob.ckey = mob_possessor.ckey
if(mob_possessor.mind)
mob_possessor.mind.transfer_to(spawned_mob, force_key_move = TRUE)
else
spawned_mob.key = mob_possessor.key
var/datum/mind/spawned_mind = spawned_mob.mind
if(spawned_mind)
spawned_mob.mind.set_assigned_role_with_greeting(SSjob.GetJobType(spawner_job_path))
spawned_mind.name = spawned_mob.real_name
if(show_flavor)
var/output_message = "<span class='infoplain'><span class='big bold'>[you_are_text]</span></span>"
if(flavour_text != "")
@@ -189,10 +197,6 @@
if(important_text != "")
output_message += "\n[span_userdanger("[important_text]")]"
to_chat(spawned_mob, output_message)
var/datum/mind/spawned_mind = spawned_mob.mind
if(spawned_mind)
spawned_mob.mind.set_assigned_role(SSjob.GetJobType(spawner_job_path))
spawned_mind.name = spawned_mob.real_name
/// Checks if the spawner has zero uses left, if so, delete yourself... NOW!
/obj/effect/mob_spawn/ghost_role/proc/check_uses()