Files
Bubberstation/code/modules/tutorials/tutorials/switch_hands.dm
T
tonty f91de19b44 Implements [OPTIONAL] Swap Left/Right hand, changes [OPTIONAL] default keybinds to accomodate (#92659)
## About The Pull Request

- Adds **OPTIONAL** keybinds that lets you select a specific hand
- Alters **OPTIONAL** default keybinds as such:
  - Q: Swap to Right Hand (replacing Drop item)
  - E: Swap to Left Hand (replacing Quick equip)
  - R: Quick equip (replacing Toggle Throw Mode)
  - ShiftR: Quick equip belt
  - X: Drop item (replacing Swap hands)
  - Swap hands is Unbound

## Why It's Good For The Game

Swapping hands has always been somewhat awkward. Since it depends on the
currently selected hand, swapping your hands requires you to look away
from what you're doing and mentally process what you're holding and what
you have selected. In the heat of the moment (like a fight) it's really
easy to forget which hand you have selected and do something you did not
want to do (like accidentally hug your target instead of attack them).
This makes it so that, at the very least, you only need to check what
you're holding.

The **OPTIONAL** default keybinds **THAT ARE OPTIONAL YOU DON'T HAVE TO
USE THEM** were altered so that new players use this new feature,
hopefully alleviating some of the hiccups from learning hand swapping.
## Changelog

🆑
qol: Added [OPTIONAL] keybinds to for Swap Left/Right hands. Check your
keybinds. [NOT OPTIONAL]
/🆑
2025-08-25 22:00:25 -07:00

97 lines
2.7 KiB
Plaintext

#define TIME_TO_START_MOVING_HAND_ICON (0.5 SECONDS)
#define STAGE_SHOULD_SWAP_HAND "STAGE_SHOULD_SWAP_HAND"
#define STAGE_PICK_UP_ITEM "STAGE_PICK_UP_ITEM"
/// Tutorial for showing how to switch hands.
/// Fired when clicking on an item with another item with an empty inactive hand.
/datum/tutorial/switch_hands
grandfather_date = "2023-01-07"
var/stage = STAGE_SHOULD_SWAP_HAND
var/atom/movable/screen/hand_preview
// So that they don't just drop the item
var/hand_to_watch
/datum/tutorial/switch_hands/New(mob/user)
. = ..()
hand_to_watch = (user.active_hand_index % user.held_items.len) + 1
/datum/tutorial/switch_hands/Destroy(force)
user.client?.screen -= hand_preview
QDEL_NULL(hand_preview)
return ..()
/datum/tutorial/switch_hands/perform(list/modifiers)
create_hand_preview(modifiers[SCREEN_LOC])
addtimer(CALLBACK(src, PROC_REF(show_instructions)), TIME_TO_START_MOVING_HAND_ICON)
RegisterSignal(user, COMSIG_MOB_SWAP_HANDS, PROC_REF(on_swap_hands))
RegisterSignal(user, COMSIG_LIVING_PICKED_UP_ITEM, PROC_REF(on_pick_up_item))
/datum/tutorial/switch_hands/perform_completion_effects_with_delay()
UnregisterSignal(user, list(COMSIG_MOB_SWAP_HANDS, COMSIG_LIVING_PICKED_UP_ITEM))
return 0
/datum/tutorial/switch_hands/proc/create_hand_preview(initial_screen_loc)
hand_preview = animate_ui_element(
"hand_[user.held_index_to_dir(hand_to_watch)]",
initial_screen_loc,
ui_hand_position(hand_to_watch),
TIME_TO_START_MOVING_HAND_ICON,
)
/datum/tutorial/switch_hands/proc/show_instructions()
if (QDELETED(src))
return
switch (stage)
if (STAGE_SHOULD_SWAP_HAND)
var/datum/keybinding/mob/select_hand/hand_keybinding
var/hand_name
if (IS_RIGHT_INDEX(hand_to_watch))
hand_keybinding = /datum/keybinding/mob/select_hand/right
hand_name = "right"
else
hand_keybinding = /datum/keybinding/mob/select_hand/left
hand_name = "left"
show_instruction(keybinding_message(
hand_keybinding,
"Press '%KEY%' to use your [hand_name] hand",
"Click '<b>SWAP</b>' to use your [hand_name] hand",
))
if (STAGE_PICK_UP_ITEM)
show_instruction("Pick something up!")
/datum/tutorial/switch_hands/proc/on_swap_hands()
SIGNAL_HANDLER
//FIXME: this checking breaks easily
if (isnull(user.get_active_held_item()))
stage = STAGE_PICK_UP_ITEM
show_instructions()
else if (isnull(user.get_inactive_held_item()))
stage = STAGE_SHOULD_SWAP_HAND
show_instructions()
else
// You somehow got an item in both hands during the tutorial without switching hands.
// Good job I guess?
complete()
/datum/tutorial/switch_hands/proc/on_pick_up_item()
SIGNAL_HANDLER
if (user.active_hand_index != hand_to_watch)
return
complete()
#undef STAGE_PICK_UP_ITEM
#undef STAGE_SHOULD_SWAP_HAND
#undef TIME_TO_START_MOVING_HAND_ICON