Files
Bubberstation/code/datums/elements/ai_held_item.dm
MrMelbert 48bbd6fddf Reworks examine (a little) (#86506)
## About The Pull Request

Basically, reworks how examining things looks to the user.

#86497 is required even though this pretty much replaces the entire PR.

Examining random objects and simplemobs:


![image](https://github.com/user-attachments/assets/a2634a7f-b337-483a-a4e7-699586b4d6ac)


![image](https://github.com/user-attachments/assets/84cfa824-4cb3-4bc1-831c-8db3ccd6b162)

Examining a person:


![image](https://github.com/user-attachments/assets/91dc5492-9ba6-44d1-a284-5c97190b12c6)


![image](https://github.com/user-attachments/assets/7af83bea-e364-4daf-9090-551d2ec2b1a1)

Examining an ID card a person is wearing (by clicking the hyperlink
adorning the ID card when examining them):
(Note, you can only pull up this if you are within 3 tiles of the
person)


![image](https://github.com/user-attachments/assets/d9658605-0830-4cd2-9b6a-3821f19555c6)

## Why It's Good For The Game

Examine is very old and very inconsistent between atoms and mobs. So I
thought I could spruce it up a bit while bringing some consistency
along.

This should also help with losing certain details in massive walls of
examine text - stuff like names will stick out more.

## Changelog

🆑 Melbert
qol: The way examine looks has been updated.
qol: A person's ID card no longer appears with a big icon on examine.
You can now click on their ID card (in the chat box) to get a bigger
picture of it, as well as information about them.
refactor: Much of examine backend code has been refactored, report any
odd looking text.
/🆑
2024-09-10 22:47:58 +02:00

70 lines
2.6 KiB
Plaintext

/**
* # AI Held Item Element
*
* Manages holding an item for a mob which doesn't have hands but needs to for AI purposes.
*/
/datum/element/ai_held_item
/datum/element/ai_held_item/Attach(datum/target)
. = ..()
if (!isliving(target))
return ELEMENT_INCOMPATIBLE
var/mob/living/living_target = target
if (!living_target.ai_controller)
return ELEMENT_INCOMPATIBLE // If there's no blackboard this would need to be a component
RegisterSignal(target, COMSIG_ATOM_ATTACK_HAND, PROC_REF(on_click))
RegisterSignal(target, COMSIG_ATOM_EXITED, PROC_REF(atom_exited))
RegisterSignal(target, COMSIG_ATOM_EXAMINE, PROC_REF(on_examined))
RegisterSignals(target, list(COMSIG_QDELETING, COMSIG_LIVING_DEATH), PROC_REF(on_death))
/// Returns the item held in a mob's blackboard, if it has one
/datum/element/ai_held_item/proc/get_held_item(mob/living/source)
return source.ai_controller.blackboard[BB_SIMPLE_CARRY_ITEM]
/// Someone's interacting with us by hand, if we have an item and like them we'll hand it over
/datum/element/ai_held_item/proc/on_click(mob/living/source, mob/living/user)
SIGNAL_HANDLER
if (user.combat_mode)
return
if (!(user in source.ai_controller.blackboard[BB_FRIENDS_LIST]))
return // We don't care about this bozo
var/obj/item/carried_item = get_held_item(source)
if (!carried_item)
return
source.visible_message(span_danger("[source] drops [carried_item] at [user]'s feet!"))
carried_item.forceMove(get_turf(user))
source.ai_controller.clear_blackboard_key(BB_SIMPLE_CARRY_ITEM)
/// If our held item is removed from our atom then take it off the blackboard
/datum/element/ai_held_item/proc/atom_exited(mob/living/source, atom/movable/gone)
SIGNAL_HANDLER
var/obj/item/carried_item = get_held_item(source)
if (carried_item == gone)
source.ai_controller.clear_blackboard_key(BB_SIMPLE_CARRY_ITEM)
/// Report that we're holding an item.
/datum/element/ai_held_item/proc/on_examined(mob/living/source, mob/user, list/examine_text)
SIGNAL_HANDLER
var/obj/item/carried_item = get_held_item(source)
if (!carried_item)
return
examine_text += span_notice("[source.p_They()] [source.p_are()] carrying [carried_item.examine_title(user)].")
/// If we died, drop anything we were carrying
/datum/element/ai_held_item/proc/on_death(mob/living/ol_yeller)
SIGNAL_HANDLER
var/obj/item/carried_item = get_held_item(ol_yeller)
if(!carried_item)
return
ol_yeller.visible_message(span_danger("[ol_yeller] drops [carried_item] as [ol_yeller.p_they()] die[ol_yeller.p_s()]."))
carried_item.forceMove(ol_yeller.drop_location())
ol_yeller.ai_controller.clear_blackboard_key(BB_SIMPLE_CARRY_ITEM)