Files
Bubberstation/code/modules/research/xenobiology/crossbreeding/_clothing.dm
SmArtKar 589cf0a904 Refactors how item actions are handled (#89654)
## About The Pull Request

This PR tackles our piss-poor item action handling. Currently in order
to make an item only have actions when its equipped to a certain slot
you need to override a proc, which I've changed by introducing an
action_slots variable. I've also cleaned up a ton of action code, and
most importantly moved a lot of Trigger effects on items to do_effect,
which allows actions to not call ui_action_click or attack_self on an
item without bypassing IsAvailible and comsigs that parent Trigger has.
This resolves issues like jump boots being usable from your hands, HUDs
being toggleable out of your pockets, etc. Also moved a few actions from
relying on attack_self to individual handling on their side.

This also stops welding masks/hardhats from showing their action while
you hold them, this part of the change is just something I thought
didn't make much sense - you can use their action by using them in-hand,
and flickering on your action bar can be annoying when reshuffling your
backpack.

Closes #89653

## Why It's Good For The Game
Makes action handling significantly less ass, allows us to avoid code
like this
```js
/obj/item/clothing/mask/gas/sechailer/ui_action_click(mob/user, action)
	if(istype(action, /datum/action/item_action/halt))
		halt()
	else
		adjust_visor(user)
```
2025-03-12 16:53:44 -04:00

155 lines
5.5 KiB
Plaintext

/*
Slimecrossing Armor
Armor added by the slimecrossing system.
Collected here for clarity.
*/
//Rebreather mask - Chilling Blue
/obj/item/clothing/mask/nobreath
name = "rebreather mask"
desc = "A transparent mask, resembling a conventional breath mask, but made of bluish slime. Seems to lack any air supply tube, though."
icon_state = "slime"
inhand_icon_state = "b_mask"
body_parts_covered = NONE
w_class = WEIGHT_CLASS_SMALL
clothing_traits = list(TRAIT_NOBREATH)
armor_type = /datum/armor/mask_nobreath
flags_cover = MASKCOVERSMOUTH
resistance_flags = NONE
interaction_flags_mouse_drop = NEED_HANDS
/datum/armor/mask_nobreath
bio = 50
/obj/item/clothing/mask/nobreath/equipped(mob/living/carbon/human/user, slot)
. = ..()
if(slot & ITEM_SLOT_MASK)
user.failed_last_breath = FALSE
user.clear_alert(ALERT_NOT_ENOUGH_OXYGEN)
user.apply_status_effect(/datum/status_effect/rebreathing)
/obj/item/clothing/mask/nobreath/dropped(mob/living/carbon/human/user)
..()
user.remove_status_effect(/datum/status_effect/rebreathing)
/obj/item/clothing/glasses/prism_glasses
name = "prism glasses"
desc = "The lenses seem to glow slightly, and reflect light into dazzling colors."
icon = 'icons/obj/science/slimecrossing.dmi'
icon_state = "prismglasses"
actions_types = list(/datum/action/item_action/change_prism_colour, /datum/action/item_action/place_light_prism)
forced_glass_color = TRUE
var/glasses_color = COLOR_WHITE
/obj/item/clothing/glasses/prism_glasses/Initialize(mapload)
. = ..()
AddElement(/datum/element/wearable_client_colour, /datum/client_colour/glass_colour, ITEM_SLOT_EYES, glasses_color, forced_glass_color)
/obj/structure/light_prism
name = "light prism"
desc = "A shining crystal of semi-solid light. Looks fragile."
icon = 'icons/obj/science/slimecrossing.dmi'
icon_state = "lightprism"
density = FALSE
anchored = TRUE
max_integrity = 10
/obj/structure/light_prism/Initialize(mapload, newcolor)
. = ..()
if(newcolor)
color = newcolor
set_light_color(newcolor)
set_light(5)
/obj/structure/light_prism/attack_hand(mob/user, list/modifiers)
to_chat(user, span_notice("You dispel [src]."))
qdel(src)
/datum/action/item_action/change_prism_colour
name = "Adjust Prismatic Lens"
button_icon = 'icons/obj/science/slimecrossing.dmi'
button_icon_state = "prismcolor"
/datum/action/item_action/change_prism_colour/do_effect(trigger_flags)
var/obj/item/clothing/glasses/prism_glasses/glasses = target
var/new_color = tgui_color_picker(owner, "Choose the lens color:", "Color change",glasses.glasses_color) // BUBBERSTATION EDIT: TGUI COLOR PICKER
if(!new_color)
return
RemoveElement(/datum/element/wearable_client_colour, /datum/client_colour/glass_colour, ITEM_SLOT_EYES, glasses.glasses_color, glasses.forced_glass_color)
glasses.glasses_color = new_color
AddElement(/datum/element/wearable_client_colour, /datum/client_colour/glass_colour, ITEM_SLOT_EYES, new_color, glasses.forced_glass_color)
/datum/action/item_action/place_light_prism
name = "Fabricate Light Prism"
button_icon = 'icons/obj/science/slimecrossing.dmi'
button_icon_state = "lightprism"
/datum/action/item_action/place_light_prism/do_effect(trigger_flags)
var/obj/item/clothing/glasses/prism_glasses/glasses = target
if(locate(/obj/structure/light_prism) in get_turf(owner))
to_chat(owner, span_warning("There isn't enough ambient energy to fabricate another light prism here."))
return
if(istype(glasses))
if(!glasses.glasses_color)
to_chat(owner, span_warning("The lens is oddly opaque..."))
return
to_chat(owner, span_notice("You channel nearby light into a glowing, ethereal prism."))
new /obj/structure/light_prism(get_turf(owner), glasses.glasses_color)
/obj/item/clothing/head/peaceflower
name = "heroine bud"
desc = "An extremely addictive flower, full of peace magic."
icon = 'icons/obj/science/slimecrossing.dmi'
worn_icon = 'icons/mob/clothing/head/costume.dmi'
icon_state = "peaceflower"
inhand_icon_state = null
slot_flags = ITEM_SLOT_HEAD
clothing_traits = list(TRAIT_PACIFISM)
body_parts_covered = NONE
force = 0
throwforce = 0
w_class = WEIGHT_CLASS_TINY
throw_speed = 1
throw_range = 3
/obj/item/clothing/head/peaceflower/proc/at_peace_check(mob/user)
if(iscarbon(user))
var/mob/living/carbon/carbon_user = user
if(src == carbon_user.head)
to_chat(user, span_warning("You feel at peace. <b style='color:pink'>Why would you want anything else?</b>"))
return TRUE
return FALSE
/obj/item/clothing/head/peaceflower/attack_hand(mob/user, list/modifiers)
if(at_peace_check(user))
return
return ..()
/obj/item/clothing/head/peaceflower/mouse_drop_dragged(atom/over, mob/user, src_location, over_location, params)
if(at_peace_check(user))
return
return ..()
/obj/item/clothing/suit/armor/heavy/adamantine
name = "adamantine armor"
desc = "A full suit of adamantine plate armor. Impressively resistant to damage, but weighs about as much as you do."
icon_state = "adamsuit"
icon = 'icons/obj/clothing/suits/armor.dmi'
worn_icon = 'icons/mob/clothing/suits/armor.dmi'
inhand_icon_state = null
flags_inv = NONE
item_flags = IMMUTABLE_SLOW
slowdown = 4
var/hit_reflect_chance = 40
/obj/item/clothing/suit/armor/heavy/adamantine/Initialize(mapload)
. = ..()
AddComponent(/datum/component/item_equipped_movement_rustle, SFX_PLATE_ARMOR_RUSTLE, 8)
/obj/item/clothing/suit/armor/heavy/adamantine/IsReflect(def_zone)
if((def_zone in list(BODY_ZONE_CHEST, BODY_ZONE_R_ARM, BODY_ZONE_L_ARM, BODY_ZONE_R_LEG, BODY_ZONE_L_LEG)) && prob(hit_reflect_chance))
return TRUE
else
return FALSE