Files
Bubberstation/code/datums/elements/haunted.dm
SkyratBot 5156e7ccbc [MIRROR] Fixes some AI related runtimes [MDB IGNORE] (#26046)
* Fixes some AI related runtimes (#80828)

## About The Pull Request

Namely this.

![image](https://github.com/tgstation/tgstation/assets/51863163/c6171a4e-afd3-4c07-8a96-1952ef76a3df)

## Changelog

🆑 Melbert
fix: Carps now migrate slightly better, probably.
fix: And Poly now talks better, probably.
/🆑

* Fixes some AI related runtimes

---------

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
2024-01-09 15:35:22 -05:00

36 lines
1.3 KiB
Plaintext

///Attaching this element to something will make it float, get a special ai controller, and gives it a spooky outline.
/datum/element/haunted
/datum/element/haunted/Attach(datum/target, haunt_color = "#f8f8ff")
. = ..()
if(!isitem(target))
return ELEMENT_INCOMPATIBLE
var/obj/item/master = target
if(istype(master.ai_controller, /datum/ai_controller/haunted))
return ELEMENT_INCOMPATIBLE
//Make em look spooky
master.add_filter("haunt_glow", 2, list("type" = "outline", "color" = haunt_color, "size" = 1))
master.ai_controller = new /datum/ai_controller/haunted(master)
master.AddElement(/datum/element/movetype_handler)
ADD_TRAIT(master, TRAIT_MOVE_FLYING, ELEMENT_TRAIT(type))
/datum/element/haunted/Detach(datum/source)
. = ..()
var/atom/movable/master = source
master.remove_filter("haunt_glow")
QDEL_NULL(master.ai_controller)
REMOVE_TRAIT(master, TRAIT_MOVE_FLYING, ELEMENT_TRAIT(type))
master.RemoveElement(/datum/element/movetype_handler)
/atom/movable/proc/make_haunted(source, color) //if not haunted, make haunted
if(!HAS_TRAIT(src, TRAIT_HAUNTED))
AddElement(/datum/element/haunted, color)
ADD_TRAIT(src, TRAIT_HAUNTED, source)
/atom/movable/proc/remove_haunted(source) //if haunted, make not haunted
REMOVE_TRAIT(src, TRAIT_HAUNTED, source)
if(!HAS_TRAIT(src, TRAIT_HAUNTED))
RemoveElement(/datum/element/haunted)