Files
Bubberstation/code/datums/ai/hauntium/haunted_controller.dm
ChungusGamer666 4f2227baf3 Implements a macro for checking mind traits (#76548)
## About The Pull Request


![image](https://github.com/tgstation/tgstation/assets/82850673/f85d0556-1806-40bf-92b8-597e46ccb4af)
Seeing this pattern repeated over various sections of code was starting
to piss me off

## Why It's Good For The Game

Lessens chance to cause errors with mind traits, ensures consistent
behavior, makes it easier to change how mind traits work if necessary.

## Changelog

hopefully not player facing

---------

Co-authored-by: san7890 <the@san7890.com>
2023-07-06 11:45:46 -06:00

48 lines
1.7 KiB
Plaintext

/datum/ai_controller/haunted
movement_delay = 0.4 SECONDS
blackboard = list(
BB_TO_HAUNT_LIST = list(),
BB_LIKES_EQUIPPER = FALSE,
BB_HAUNT_TARGET,
BB_HAUNTED_THROW_ATTEMPT_COUNT,
)
planning_subtrees = list(/datum/ai_planning_subtree/haunted)
idle_behavior = /datum/idle_behavior/idle_ghost_item
/datum/ai_controller/haunted/TryPossessPawn(atom/new_pawn)
if(!isitem(new_pawn))
return AI_CONTROLLER_INCOMPATIBLE
RegisterSignal(new_pawn, COMSIG_ITEM_EQUIPPED, PROC_REF(on_equip))
return ..() //Run parent at end
/datum/ai_controller/haunted/UnpossessPawn()
UnregisterSignal(pawn, COMSIG_ITEM_EQUIPPED)
return ..() //Run parent at end
///Signal response for when the item is picked up; stops listening for follow up equips, just waits for a drop.
/datum/ai_controller/haunted/proc/on_equip(datum/source, mob/equipper, slot)
SIGNAL_HANDLER
UnregisterSignal(pawn, COMSIG_ITEM_EQUIPPED)
var/haunt_equipper = TRUE
if(isliving(equipper))
var/mob/living/possibly_cool = equipper
if(possibly_cool.mob_biotypes & MOB_UNDEAD || HAS_MIND_TRAIT(possibly_cool, TRAIT_MORBID))
haunt_equipper = FALSE
if(haunt_equipper)
//You have now become one of the victims of the HAAAAUNTTIIIINNGGG OOOOOO~~~
set_blackboard_key_assoc(BB_TO_HAUNT_LIST, equipper, HAUNTED_ITEM_AGGRO_ADDITION)
else
set_blackboard_key(BB_LIKES_EQUIPPER, TRUE)
RegisterSignal(pawn, COMSIG_ITEM_DROPPED, PROC_REF(on_dropped))
///Flip it so we listen for equip again but not for drop.
/datum/ai_controller/haunted/proc/on_dropped(datum/source, mob/user)
SIGNAL_HANDLER
set_blackboard_key(BB_LIKES_EQUIPPER, FALSE)
RegisterSignal(pawn, COMSIG_ITEM_EQUIPPED, PROC_REF(on_equip))
UnregisterSignal(pawn, COMSIG_ITEM_DROPPED)