Files
ef6fe48e08 [MIRROR] Refactors Object Possession into a Component (moar modular, less /mob vars) [MDB IGNORE] (#25534)
* Refactors Object Possession into a Component (moar modular, less `/mob` vars) (#80160)

## About The Pull Request

We have two verbs that allow any given mob to take control of an object
and move it ephemerally, `/proc/possess()` and `/proc/release()`. These
ones leveraged two vars present on every `/mob`: `name_archive` and
`control_object`. I don't like having vars clog up my VV and this just
injected snowflake behavior in a lot of spots - let's just make it a
component that'll clean everything else up.

This also opens up the ability to have more objects be under mob control
without giving someone verbs that spit out to the blackbox as an admin
verb + logs + message admins but that's a later thing. This just subs in
the behavior in a nice way.

Also, since it's a component, I added a small QoL that we can support
now: A screen alert that allows you to get out of the possession early
without navigating the stat panel for the specific verb. I think it's
neat. You can also trigger the aghost keybind if that's something you
want as well.

Also also, nothing actually ever cleaned up `control_object` by setting
it to null. This means that in the old framework, if a mob got qdelled
during a possession, that would have triggered a hung ref harddel. That
won't happen anymore.
## Why It's Good For The Game

Two less variables taking up crud space in the VSC debugger + view
variables panel. Better behavior injection that is far more reusable.
Component handling this behavior allows for better extensibility of this
function in the future.

![image](https://github.com/tgstation/tgstation/assets/34697715/a84238af-e014-4cff-9b4b-6cbaa36c44fd)
## Changelog
🆑
admin: Object Possession has been reworked, please report any potential
bugs.
qol: Object Possession should now throw a screen alert for you to
unpossess the object instead of you having to search the stat-panel for
the "release obj" verb. You can still use the verb but it's a lot nicer
now. Aghosting will also work now.
/🆑

* Refactors Object Possession into a Component (moar modular, less `/mob` vars)

* Refactor hydra quirk

The name_archive var is gone, let's store it in the quirk instead

---------

Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Giz <13398309+vinylspiders@users.noreply.github.com>
2023-12-09 21:58:57 -05:00

53 lines
2.3 KiB
Plaintext

/datum/quirk/hydra
name = "Hydra Heads"
desc = "You are a tri-headed creature. To use, format name like (Rucks-Sucks-Ducks)"
value = 0
mob_trait = TRAIT_HYDRA_HEADS
gain_text = span_notice("You hear two other voices inside of your head(s).")
lose_text = span_danger("All of your minds become singular.")
medical_record_text = "There are multiple heads and personalities affixed to one body."
icon = FA_ICON_HORSE_HEAD
// remember what the name was before activation
var/original_name
/datum/quirk/hydra/add(client/client_source)
var/mob/living/carbon/human/hydra = quirk_holder
var/datum/action/innate/hydra/spell = new(hydra)
var/datum/action/innate/hydrareset/resetspell = new(hydra)
spell.Grant(hydra)
spell.owner = hydra
resetspell.Grant(hydra)
resetspell.owner = hydra
/datum/action/innate/hydra
name = "Switch head"
desc = "Switch between each of the heads on your body."
button_icon = 'icons/mob/actions/actions_minor_antag.dmi'
button_icon_state = "art_summon"
/datum/action/innate/hydrareset
name = "Reset Speech"
desc = "Go back to speaking as a whole."
button_icon = 'icons/mob/actions/actions_minor_antag.dmi'
button_icon_state = "art_summon"
/datum/action/innate/hydrareset/Activate()
var/mob/living/carbon/human/hydra = owner
var/datum/quirk/hydra/hydra_quirk = hydra.get_quirk(/datum/quirk/hydra)
if(!hydra_quirk.original_name) // sets the archived 'real' name if not set.
hydra_quirk.original_name = hydra.real_name
hydra.real_name = hydra_quirk.original_name
hydra.visible_message(span_notice("[hydra.name] pushes all three heads forwards; they seem to be talking as a collective."), \
span_notice("You are now talking as [hydra_quirk.original_name]!"), ignored_mobs=owner)
/datum/action/innate/hydra/Activate() //Oops, all hydra!
var/mob/living/carbon/human/hydra = owner
var/datum/quirk/hydra/hydra_quirk = hydra.get_quirk(/datum/quirk/hydra)
if(!hydra_quirk.original_name) // sets the archived 'real' name if not set.
hydra_quirk.original_name = hydra.real_name
var/list/names = splittext(hydra_quirk.original_name,"-")
var/selhead = input("Who would you like to speak as?","Heads:") in names
hydra.real_name = selhead
hydra.visible_message(span_notice("[hydra.name] pulls the rest of their heads back; and puts [selhead]'s forward."), \
span_notice("You are now talking as [selhead]!"), ignored_mobs=owner)