Files
Bloop 4d8b1ff5af Stops hauntium from trying to haunt objects it is incapable of haunting (#94528)
## About The Pull Request

<img width="578" height="377" alt="dreamseeker_Gg1rgahTpr"
src="https://github.com/user-attachments/assets/051571f5-5671-40e1-ad94-1607a70f2e71"
/>

This proc should only work on items since that's the only thing the
haunted element works on.

## Why It's Good For The Game

Fixes runtime log spam

## Changelog

Not player-facing
2025-12-19 10:21:33 -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)
/obj/item/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)
/obj/item/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)