Skip to content

Commit

Permalink
[MIRROR] Fixes sight range on lootpanel [no gbp] (#2109) (#2997)
Browse files Browse the repository at this point in the history
* Fixes sight range on lootpanel [no gbp] (#82765)

## About The Pull Request
When asked to make lootpanel visible at range they did not just mean
_any range_
AI alt click was a little weird (still is) but now it works

(TM BUG)
Fixes #82768

* Fixes sight range on lootpanel [no gbp]

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: Jeremiah <[email protected]>
  • Loading branch information
3 people authored Apr 21, 2024
1 parent d80c346 commit 40388f3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
20 changes: 19 additions & 1 deletion code/_onclick/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
ShiftClickOn(A)
return
if(LAZYACCESS(modifiers, ALT_CLICK)) // alt and alt-gr (rightalt)
A.ai_click_alt(src)
ai_base_click_alt(A)
return
if(LAZYACCESS(modifiers, CTRL_CLICK))
CtrlClickOn(A)
Expand Down Expand Up @@ -121,6 +121,24 @@
target.AICtrlClick(src)


/// Reimplementation of base_click_alt for AI
/mob/living/silicon/ai/proc/ai_base_click_alt(atom/target)
// If for some reason we can't alt click
if(SEND_SIGNAL(src, COMSIG_MOB_ALTCLICKON, target) & COMSIG_MOB_CANCEL_CLICKON)
return

if(!isturf(target) && can_perform_action(target, (target.interaction_flags_click | SILENT_ADJACENCY)))
// Signal intercept
if(SEND_SIGNAL(target, COMSIG_CLICK_ALT, src) & CLICK_ACTION_ANY)
return

// AI alt click interaction succeeds
if(target.ai_click_alt(src) & CLICK_ACTION_ANY)
return

client.loot_panel.open(get_turf(target))


/*
The following criminally helpful code is just the previous code cleaned up;
I have no idea why it was in atoms.dm instead of respective files.
Expand Down
22 changes: 11 additions & 11 deletions code/_onclick/click_alt.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@
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(!(src in viewers(7, target)) && !CanReach(target))
return

var/turf/tile = get_turf(target)

// Ghosties just see loot
if(isobserver(src) || isrevenant(src))
open_lootpanel(tile)
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

open_lootpanel(tile)


/// Helper for opening the lootpanel
/mob/proc/open_lootpanel(turf/target)
// No alt clicking to view turf from beneath
if(HAS_TRAIT(src, TRAIT_MOVE_VENTCRAWLING))
return

var/datum/lootpanel/panel = client?.loot_panel
if(isnull(panel))
return

panel.open(target)
client.loot_panel.open(tile)


/**
Expand Down
3 changes: 2 additions & 1 deletion code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,8 @@
if(!Adjacent(target) && (target.loc != src) && !recursive_loc_check(src, target))
if(HAS_SILICON_ACCESS(src) && !ispAI(src))
if(!(action_bitflags & ALLOW_SILICON_REACH)) // silicons can ignore range checks (except pAIs)
to_chat(src, span_warning("You are too far away!"))
if(!(action_bitflags & SILENT_ADJACENCY))
to_chat(src, span_warning("You are too far away!"))
return FALSE
else // just a normal carbon mob
if((action_bitflags & FORBID_TELEKINESIS_REACH))
Expand Down

0 comments on commit 40388f3

Please sign in to comment.