Files
Bubberstation/code/datums/ai/hauntium/haunted_controller.dm
Bloop a9c80a29a3 [MISSED MIRROR] Implements a macro for checking mind traits (#76548) (#22447)
* Implements a macro for checking mind traits (#76548)

![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

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

hopefully not player facing

---------

Co-authored-by: san7890 <the@san7890.com>

* modular stuff

---------

Co-authored-by: ChungusGamer666 <82850673+ChungusGamer666@users.noreply.github.com>
Co-authored-by: san7890 <the@san7890.com>
2023-07-18 21:32:47 -04: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)