Files
Bubberstation/code/modules/basketball/referee.dm
SmArtKar 4dd6cdeb72 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-01 12:02:07 -06:00

48 lines
1.7 KiB
Plaintext

/obj/item/clothing/mask/whistle/minigame
name = "referee whistle"
desc = "A referee whistle used to call fouls against players."
actions_types = list(/datum/action/innate/timeout)
action_slots = ALL
// should be /datum/action/item_action but it doesn't support InterceptClickOn()
/datum/action/innate/timeout
name = "Call foul"
desc = "Puts a person in a timeout for a few seconds."
button_icon = 'icons/obj/clothing/masks.dmi'
button_icon_state = "whistle"
click_action = TRUE
enable_text = span_cult("You prepare to call a foul on someone...")
disable_text = span_cult("You decide it was a bad call...")
COOLDOWN_DECLARE(whistle_cooldown_minigame)
/datum/action/innate/timeout/InterceptClickOn(mob/living/clicker, params, atom/clicked_on)
var/turf/clicker_turf = get_turf(clicker)
if(!isturf(clicker_turf))
return FALSE
if(!ishuman(clicked_on) || get_dist(clicker, clicked_on) > 7)
return FALSE
if(clicked_on == clicker) // can't call a foul on yourself
return FALSE
if(!COOLDOWN_FINISHED(src, whistle_cooldown_minigame))
clicker.balloon_alert(clicker, "cant cast for [COOLDOWN_TIMELEFT(src, whistle_cooldown_minigame) *0.1] seconds!")
unset_ranged_ability(clicker)
return FALSE
return ..()
/datum/action/innate/timeout/do_ability(mob/living/clicker, mob/living/carbon/human/target)
clicker.say("FOUL BY [target]!", forced = "whistle")
playsound(clicker, 'sound/items/whistle/whistle.ogg', 30, FALSE, 4)
new /obj/effect/timestop(get_turf(target), 0, 5 SECONDS, list(clicker), TRUE, TRUE)
COOLDOWN_START(src, whistle_cooldown_minigame, 1 MINUTES)
unset_ranged_ability(clicker)
to_chat(target, span_bold("[clicker] has given you a timeout for a foul!"))
to_chat(clicker, span_bold("You put [target] in a timeout!"))
return TRUE