Files
Bubberstation/code/_onclick/click_alt.dm
SkyratBot 8e8ded47d3 [MIRROR] [no gbp] can no longer cheese blindness with lootpanel range (#27835)
* [no gbp] can no longer cheese blindness with lootpanel range (#83401)

## About The Pull Request
`in viewers` does not take into account blindness so you can open the
lootpanel at range as a blind person to see item names, icons etc

This limits their alt click range to 1 tile away and removes the
names/tooltips from the items in the ui
## Why It's Good For The Game
Realism and since this is a blindness nerf (as if they need one) I won't
be mad this gets closed
## Changelog
🆑
fix: You can no longer open the loot panel at range as a blind person
and cheese item names
/🆑

* [no gbp] can no longer cheese blindness with lootpanel range

---------

Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com>
2024-05-25 20:52:00 +02:00

74 lines
2.3 KiB
Plaintext

/**
* ### Base proc for alt click interaction.
*
* If you wish to add custom `click_alt` behavior for a single type, use that proc.
*/
/mob/proc/base_click_alt(atom/target)
SHOULD_NOT_OVERRIDE(TRUE)
// Check if they've hooked in to prevent src from alt clicking anything
if(SEND_SIGNAL(src, COMSIG_MOB_ALTCLICKON, target) & COMSIG_MOB_CANCEL_CLICKON)
return
// Is it visible (and we're not wearing it (our clothes are invisible))?
if(!CAN_I_SEE(target))
return
if(is_blind() && !IN_GIVEN_RANGE(src, target, 1))
return
var/turf/tile = get_turf(target)
// Ghosties just see loot
if(isobserver(src) || isrevenant(src))
client.loot_panel.open(tile)
return
// Turfs don't have a click_alt currently, so this saves some time.
if(!isturf(target) && can_perform_action(target, (target.interaction_flags_click | SILENT_ADJACENCY)))
// If it has a signal handler that returns a click action, done.
if(SEND_SIGNAL(target, COMSIG_CLICK_ALT, src) & CLICK_ACTION_ANY)
return
// If it has a custom click_alt that returns success/block, done.
if(target.click_alt(src) & CLICK_ACTION_ANY)
return
// No alt clicking to view turf from beneath
if(HAS_TRAIT(src, TRAIT_MOVE_VENTCRAWLING))
return
client.loot_panel.open(tile)
/**
* ## Custom alt click interaction
* Override this to change default alt click behavior. Return `CLICK_ACTION_SUCCESS`, `CLICK_ACTION_BLOCKING` or `NONE`.
*
* ### Guard clauses
* Consider adding `interaction_flags_click` before adding unique guard clauses.
*
* ### Return flags
* Forgetting your return will cause the default alt click behavior to occur thereafter.
*
* The difference between NONE and BLOCKING can get hazy, but I like to keep NONE limited to guard clauses and "never" cases.
*
* A good usage for BLOCKING over NONE is when it's situational for the item and there's some feedback indicating this.
*
* ### Examples:
* User is a ghost, alt clicks on item with special disk eject: NONE
*
* Machine broken, no feedback: NONE
*
* Alt click a pipe to max output but its already max: BLOCKING
*
* Alt click a gun that normally works, but is out of ammo: BLOCKING
*
* User unauthorized, machine beeps: BLOCKING
*
* @param {mob} user - The person doing the alt clicking.
*/
/atom/proc/click_alt(mob/user)
SHOULD_CALL_PARENT(FALSE)
return NONE