Skip to content

Commit

Permalink
[MIRROR] Circuit multitools can now mark (visible) items worn/held by…
Browse files Browse the repository at this point in the history
… a mob (#1039)

* Circuit multitools can now mark (visible) items worn/held by a mob (#81215)

## About The Pull Request
Title. This includes a small change to the get_visible_items proc, only
used by phobias until now, to include worn accessories. Not really worth
of a changelog entry itself.

## Why It's Good For The Game
This makes the process of scanning oft worn equipment a bit easier,
perhaps weavering the need of consent for some pranks and shenanigans.


![immagine](https://github.com/tgstation/tgstation/assets/42542238/a0d62488-2ee1-4051-9737-62c9247a6137)

I've added a bit of contrast to the icon for the "mob" option since
then.

## Changelog

:cl:
qol: Circuit multitools can now mark (visible) items worn/held by a mob.
/:cl:

* Circuit multitools can now mark (visible) items worn/held by a mob

---------

Co-authored-by: Ghom <[email protected]>
  • Loading branch information
2 people authored and StealsThePRs committed Feb 18, 2024
1 parent 30dfd4c commit 256b4fe
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 31 deletions.
36 changes: 5 additions & 31 deletions code/modules/mob/living/carbon/human/inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -106,37 +106,11 @@
s_store,
)

/// Returns items which are currently visible on the mob
/mob/living/carbon/human/proc/get_visible_items()
var/static/list/visible_slots = list(
ITEM_SLOT_OCLOTHING,
ITEM_SLOT_ICLOTHING,
ITEM_SLOT_GLOVES,
ITEM_SLOT_EYES,
ITEM_SLOT_EARS,
ITEM_SLOT_MASK,
ITEM_SLOT_HEAD,
ITEM_SLOT_FEET,
ITEM_SLOT_ID,
ITEM_SLOT_BELT,
ITEM_SLOT_BACK,
ITEM_SLOT_NECK,
ITEM_SLOT_HANDS,
ITEM_SLOT_BACKPACK,
ITEM_SLOT_SUITSTORE,
ITEM_SLOT_HANDCUFFED,
ITEM_SLOT_LEGCUFFED,
)
var/list/obscured = check_obscured_slots()
var/list/visible_items = list()
for (var/slot in visible_slots)
if (obscured & slot)
continue
var/obj/item/equipped = get_item_by_slot(slot)
if (equipped)
visible_items += equipped
for (var/obj/item/held in held_items)
visible_items += held
/mob/living/carbon/human/get_visible_items()
var/list/visible_items = ..()
var/obj/item/clothing/under/under = w_uniform
if(istype(under) && length(under.attached_accessories) && (under in visible_items))
visible_items += under.attached_accessories
return visible_items

//This is an UNSAFE proc. Use mob_can_equip() before calling this one! Or rather use equip_to_slot_if_possible() or advanced_equip_to_slot_if_possible()
Expand Down
33 changes: 33 additions & 0 deletions code/modules/mob/living/carbon/inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,39 @@
legcuffed,
)

/// Returns items which are currently visible on the mob
/mob/living/carbon/proc/get_visible_items()
var/static/list/visible_slots = list(
ITEM_SLOT_OCLOTHING,
ITEM_SLOT_ICLOTHING,
ITEM_SLOT_GLOVES,
ITEM_SLOT_EYES,
ITEM_SLOT_EARS,
ITEM_SLOT_MASK,
ITEM_SLOT_HEAD,
ITEM_SLOT_FEET,
ITEM_SLOT_ID,
ITEM_SLOT_BELT,
ITEM_SLOT_BACK,
ITEM_SLOT_NECK,
ITEM_SLOT_HANDS,
ITEM_SLOT_BACKPACK,
ITEM_SLOT_SUITSTORE,
ITEM_SLOT_HANDCUFFED,
ITEM_SLOT_LEGCUFFED,
)
var/list/obscured = check_obscured_slots()
var/list/visible_items = list()
for (var/slot in visible_slots)
if (obscured & slot)
continue
var/obj/item/equipped = get_item_by_slot(slot)
if (equipped)
visible_items += equipped
for (var/obj/item/held in held_items)
visible_items += held
return visible_items

/mob/living/carbon/proc/equip_in_one_of_slots(obj/item/equipping, list/slots, qdel_on_fail = TRUE, indirect_action = FALSE)
for(var/slot in slots)
if(equip_to_slot_if_possible(equipping, slots[slot], disable_warning = TRUE, indirect_action = indirect_action))
Expand Down
52 changes: 52 additions & 0 deletions code/modules/wiremod/core/marker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
if(marked_atom || !user.Adjacent(target) || is_right_clicking)
return ..()

if(isliving(target))
INVOKE_ASYNC(src, PROC_REF(mark_mob_or_contents), user, target)
return TRUE

mark_target(target)

/obj/item/multitool/circuit/proc/mark_target(atom/target)
say("Marked [target].")
marked_atom = target
RegisterSignal(marked_atom, COMSIG_QDELETING, PROC_REF(cleanup_marked_atom))
Expand All @@ -40,6 +47,51 @@
playsound(src.loc, 'sound/misc/compiler-stage2.ogg', 30, TRUE)
return TRUE

/// Allow users to mark items equipped by the target that are visible.
/obj/item/multitool/circuit/proc/mark_mob_or_contents(mob/user, mob/living/target)
var/list/visible_items
var/mob/living/carbon/carbon_target
if(iscarbon(target))
carbon_target = target
visible_items = carbon_target.get_visible_items()
else
visible_items = target.get_equipped_items()

visible_items -= src // the multitool cannot mark itself.

if(!length(visible_items))
mark_target(target)
return

var/list/selectable_targets = list()
var/datum/radial_menu_choice/mob_choice = new
mob_choice.image = image(icon = 'icons/hud/radial.dmi', icon_state = "radial_mob")
mob_choice.name = target.name
selectable_targets[REF(target)] = mob_choice
for(var/obj/item/item as anything in visible_items)
var/datum/radial_menu_choice/item_choice = new

var/mutable_appearance/item_appearance = new(item)
item_appearance.layer = FLOAT_LAYER
item_appearance.plane = FLOAT_PLANE

item_choice.name = item.name
item_choice.image = item_appearance
selectable_targets[REF(item)] = item_choice

var/picked_ref = show_radial_menu(user, src, selectable_targets, uniqueid = TRUE, radius = 38, custom_check = CALLBACK(src, PROC_REF(check_menu), user, target), tooltips = TRUE)
if(!picked_ref)
return

var/atom/movable/chosen = locate(picked_ref)
if(chosen == target || (chosen in (carbon_target ? carbon_target.get_visible_items() : target.get_equipped_items())))
mark_target(chosen)
else
balloon_alert(user, "cannot mark entity")

/obj/item/multitool/circuit/proc/check_menu(mob/user, mob/living/target)
return !marked_atom && user.is_holding(src) && user.Adjacent(target)

/obj/item/multitool/circuit/update_overlays()
. = ..()
cut_overlays()
Expand Down
Binary file modified icons/hud/radial.dmi
Binary file not shown.

0 comments on commit 256b4fe

Please sign in to comment.