Skip to content

Commit

Permalink
[MIRROR] Alt click no longer conflicts with mech suit [no gbp] (#2984)
Browse files Browse the repository at this point in the history
Alt click no longer conflicts with mech suit [no gbp]

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: Jeremiah <[email protected]>
Co-authored-by: Bloop <[email protected]>
Co-authored-by: Iajret <[email protected]>
  • Loading branch information
5 people authored Apr 20, 2024
1 parent 37b3a6d commit 2da6dfa
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 23 deletions.
6 changes: 5 additions & 1 deletion code/_onclick/click_alt.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
/mob/proc/base_click_alt(atom/target)
SHOULD_NOT_OVERRIDE(TRUE)

var/turf/tile = isturf(target) ? target : get_turf(target)
// 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

var/turf/tile = get_turf(target)

if(isobserver(src) || isrevenant(src))
open_lootpanel(tile)
Expand Down
20 changes: 20 additions & 0 deletions code/modules/vehicles/mecha/_mecha.dm
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,26 @@
target.mech_melee_attack(src, user)
TIMER_COOLDOWN_START(src, COOLDOWN_MECHA_MELEE_ATTACK, melee_cooldown)


/// Driver alt clicks anything while in mech
/obj/vehicle/sealed/mecha/proc/on_click_alt(mob/user, atom/target, params)
SIGNAL_HANDLER

. = COMSIG_MOB_CANCEL_CLICKON // Cancel base_click_alt

if(target != src)
return

if(!(user in occupants))
return

if(!(user in return_controllers_with_flag(VEHICLE_CONTROL_DRIVE)))
to_chat(user, span_warning("You're in the wrong seat to control movement."))
return

toggle_strafe()


/// middle mouse click signal wrapper for AI users
/obj/vehicle/sealed/mecha/proc/on_middlemouseclick(mob/user, atom/target, params)
SIGNAL_HANDLER
Expand Down
14 changes: 3 additions & 11 deletions code/modules/vehicles/mecha/mecha_actions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,16 @@

chassis.toggle_strafe()

/obj/vehicle/sealed/mecha/click_alt(mob/living/user)
if(!(user in occupants))
return CLICK_ACTION_BLOCKING
if(!(user in return_controllers_with_flag(VEHICLE_CONTROL_DRIVE)))
to_chat(user, span_warning("You're in the wrong seat to control movement."))
return CLICK_ACTION_BLOCKING

toggle_strafe()
return CLICK_ACTION_SUCCESS

/obj/vehicle/sealed/mecha/proc/toggle_strafe()
if(!(mecha_flags & CAN_STRAFE))
to_chat(occupants, "this mecha doesn't support strafing!")
return

strafe = !strafe

to_chat(occupants, "strafing mode [strafe?"on":"off"].")
for(var/mob/occupant in occupants)
balloon_alert(occupant, "strafing [strafe?"on":"off"]")
occupant.playsound_local(src, 'sound/machines/terminal_eject.ogg', 50, TRUE)
log_message("Toggled strafing mode [strafe?"on":"off"].", LOG_MECHA)

for(var/occupant in occupants)
Expand Down
24 changes: 13 additions & 11 deletions code/modules/vehicles/mecha/mecha_mob_interaction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -159,24 +159,26 @@
setDir(SOUTH)
return ..()

/obj/vehicle/sealed/mecha/add_occupant(mob/M, control_flags)
RegisterSignal(M, COMSIG_MOB_CLICKON, PROC_REF(on_mouseclick), TRUE)
RegisterSignal(M, COMSIG_MOB_SAY, PROC_REF(display_speech_bubble), TRUE)
RegisterSignal(M, COMSIG_MOVABLE_KEYBIND_FACE_DIR, PROC_REF(on_turn), TRUE)
/obj/vehicle/sealed/mecha/add_occupant(mob/driver, control_flags)
RegisterSignal(driver, COMSIG_MOB_CLICKON, PROC_REF(on_mouseclick), TRUE)
RegisterSignal(driver, COMSIG_MOB_SAY, PROC_REF(display_speech_bubble), TRUE)
RegisterSignal(driver, COMSIG_MOVABLE_KEYBIND_FACE_DIR, PROC_REF(on_turn), TRUE)
RegisterSignal(driver, COMSIG_MOB_ALTCLICKON, PROC_REF(on_click_alt))
. = ..()
update_appearance()

/obj/vehicle/sealed/mecha/remove_occupant(mob/M)
UnregisterSignal(M, list(
/obj/vehicle/sealed/mecha/remove_occupant(mob/driver)
UnregisterSignal(driver, list(
COMSIG_MOB_CLICKON,
COMSIG_MOB_SAY,
COMSIG_MOVABLE_KEYBIND_FACE_DIR,
COMSIG_MOB_ALTCLICKON,
))
M.clear_alert(ALERT_CHARGE)
M.clear_alert(ALERT_MECH_DAMAGE)
if(M.client)
M.update_mouse_pointer()
M.client.view_size.resetToDefault()
driver.clear_alert(ALERT_CHARGE)
driver.clear_alert(ALERT_MECH_DAMAGE)
if(driver.client)
driver.update_mouse_pointer()
driver.client.view_size.resetToDefault()
zoom_mode = FALSE
. = ..()
update_appearance()
Expand Down

0 comments on commit 2da6dfa

Please sign in to comment.