Files
Bubberstation/code/datums/keybinding/mob.dm
T
John Willard 2ef5704c30 Adds a keybind for 'precise' dropping (like SS14) (#93790)
## About The Pull Request


https://github.com/user-attachments/assets/531f1456-72a1-4215-ae9e-4f4bf143b8c5

<img width="429" height="93" alt="image"
src="https://github.com/user-attachments/assets/1440fb60-a6b8-46c3-9bee-5a30017e2265"
/>

## Why It's Good For The Game

There's been SS14 players moving to SS13 and finding dropping in 14 is
better, which I kinda agree as it allows you to be more precise with x/y
dropping.

## Changelog

🆑
qol: There's a keybind (default is Ctrl+X, rebindable) for the drop
hotkey to drop where your mouse is (similar to SS14).
/🆑
2025-11-18 17:39:20 -07:00

256 lines
8.3 KiB
Plaintext

/datum/keybinding/mob
category = CATEGORY_HUMAN
weight = WEIGHT_MOB
/datum/keybinding/mob/stop_pulling
hotkey_keys = list("H", "Delete")
name = "stop_pulling"
full_name = "Stop pulling"
description = ""
keybind_signal = COMSIG_KB_MOB_STOPPULLING_DOWN
/datum/keybinding/mob/stop_pulling/down(client/user, turf/target, mousepos_x, mousepos_y)
. = ..()
if(.)
return
var/mob/M = user.mob
if(!M.pulling)
to_chat(user, span_notice("You are not pulling anything."))
else
M.stop_pulling()
return TRUE
/datum/keybinding/mob/swap_hands
hotkey_keys = list("Unbound")
name = "swap_hands"
full_name = "Swap hands"
description = ""
keybind_signal = COMSIG_KB_MOB_SWAPHANDS_DOWN
/datum/keybinding/mob/swap_hands/down(client/user, turf/target, mousepos_x, mousepos_y)
. = ..()
if(.)
return
var/mob/M = user.mob
M.swap_hand()
return TRUE
/datum/keybinding/mob/select_hand
var/hand_index = NONE
/datum/keybinding/mob/select_hand/right
hotkey_keys = list("Q")
name = "select_right_hand"
full_name = "Swap to Right Hand"
keybind_signal = COMSIG_KB_MOB_SELECTRIGHTHAND_DOWN
hand_index = RIGHT_HANDS
/datum/keybinding/mob/select_hand/left
hotkey_keys = list("E")
name = "select_left_hand"
full_name = "Swap to Left Hand"
keybind_signal = COMSIG_KB_MOB_SELECTLEFTHAND_DOWN
hand_index = LEFT_HANDS
/datum/keybinding/mob/select_hand/down(client/user, turf/target, mousepos_x, mousepos_y)
. = ..()
if(.)
return
var/mob/user_mob = user.mob
var/active_hand_set = ceil(user_mob.active_hand_index / 2) - 1 //offset
var/desired_hand_index = hand_index + (2 * active_hand_set)
user_mob.swap_hand(desired_hand_index)
return TRUE
/datum/keybinding/mob/activate_inhand
hotkey_keys = list("Z")
name = "activate_inhand"
full_name = "Activate in-hand"
description = "Uses whatever item you have inhand"
keybind_signal = COMSIG_KB_MOB_ACTIVATEINHAND_DOWN
/datum/keybinding/mob/activate_inhand/down(client/user, turf/target, mousepos_x, mousepos_y)
. = ..()
if(.)
return
var/mob/M = user.mob
M.mode()
return TRUE
/datum/keybinding/mob/drop_item
hotkey_keys = list("X")
name = "drop_item"
full_name = "Drop Item"
description = "Drops the item in your active hand to the ground."
keybind_signal = COMSIG_KB_MOB_DROPITEM_DOWN
/datum/keybinding/mob/drop_item/down(client/user, turf/target, mousepos_x, mousepos_y)
. = ..()
if(.)
return
if(iscyborg(user.mob)) //cyborgs can't drop items
return FALSE
var/mob/user_mob = user.mob
var/obj/item/item_dropped = user_mob.get_active_held_item()
if(!item_dropped)
to_chat(user, span_warning("You have nothing to drop in your hand!"))
return TRUE
user.mob.dropItemToGround(item_dropped)
return TRUE
/datum/keybinding/mob/drop_item_specific
hotkey_keys = list("CtrlX")
name = "drop_item_specific"
full_name = "Drop Item (Specific)"
description = "Drops the item in your active where your mouse cursor is, if in range."
keybind_signal = COMSIG_KB_MOB_DROPITEM_DOWN
/datum/keybinding/mob/drop_item_specific/down(client/user, turf/target, mousepos_x, mousepos_y)
. = ..()
if(.)
return
if(iscyborg(user.mob)) //cyborgs can't drop items
return FALSE
var/mob/user_mob = user.mob
var/obj/item/item_dropped = user_mob.get_active_held_item()
if(!item_dropped)
to_chat(user, span_warning("You have nothing to drop in your hand!"))
return TRUE
if(!user_mob.Adjacent(target) || target.is_blocked_turf(source_atom = item_dropped))
return TRUE
var/x_value = (mousepos_x >= 0) ? mousepos_x - ICON_SIZE_X / 2 : mousepos_x + ICON_SIZE_X / 2
var/y_value = (mousepos_y >= 0) ? mousepos_y - ICON_SIZE_Y / 2 : mousepos_y + ICON_SIZE_Y / 2
user_mob.transfer_item_to_turf(item_dropped, target, x_value, y_value)
return TRUE
/datum/keybinding/mob/target/down(client/user, turf/target, mousepos_x, mousepos_y)
. = ..()
if(.)
return .
var/original = user.mob.zone_selected
switch(keybind_signal)
if(COMSIG_KB_MOB_TARGETCYCLEHEAD_DOWN)
user.body_toggle_head()
if(COMSIG_KB_MOB_TARGETHEAD_DOWN)
user.body_head()
if(COMSIG_KB_MOB_TARGETEYES_DOWN)
user.body_eyes()
if(COMSIG_KB_MOB_TARGETMOUTH_DOWN)
user.body_mouth()
if(COMSIG_KB_MOB_TARGETRIGHTARM_DOWN)
user.body_r_arm()
if(COMSIG_KB_MOB_TARGETBODYCHEST_DOWN)
user.body_chest()
if(COMSIG_KB_MOB_TARGETLEFTARM_DOWN)
user.body_l_arm()
if(COMSIG_KB_MOB_TARGETRIGHTLEG_DOWN)
user.body_r_leg()
if(COMSIG_KB_MOB_TARGETBODYGROIN_DOWN)
user.body_groin()
if(COMSIG_KB_MOB_TARGETLEFTLEG_DOWN)
user.body_l_leg()
else
stack_trace("Target keybind pressed but not implemented! '[keybind_signal]'")
return FALSE
user.mob.log_manual_zone_selected_update("keybind", old_target = original)
/datum/keybinding/mob/target/head_cycle
hotkey_keys = list("Numpad8")
name = "target_head_cycle"
full_name = "Target: Cycle Head"
description = "Pressing this key targets the head, and continued presses will cycle to the eyes and mouth. This will impact where you hit people, and can be used for surgery."
keybind_signal = COMSIG_KB_MOB_TARGETCYCLEHEAD_DOWN
/datum/keybinding/mob/target/head
hotkey_keys = list("Unbound")
name = "target_head"
full_name = "Target: Head"
description = "Pressing this key targets the head. This will impact where you hit people, and can be used for surgery."
keybind_signal = COMSIG_KB_MOB_TARGETHEAD_DOWN
/datum/keybinding/mob/target/eyes
hotkey_keys = list("Numpad7")
name = "target_eyes"
full_name = "Target: Eyes"
description = "Pressing this key targets the eyes. This will impact where you hit people, and can be used for surgery."
keybind_signal = COMSIG_KB_MOB_TARGETEYES_DOWN
/datum/keybinding/mob/target/mouth
hotkey_keys = list("Numpad9")
name = "target_mouths"
full_name = "Target: Mouth"
description = "Pressing this key targets the mouth. This will impact where you hit people, and can be used for surgery."
keybind_signal = COMSIG_KB_MOB_TARGETMOUTH_DOWN
/datum/keybinding/mob/target/r_arm
hotkey_keys = list("Numpad4")
name = "target_r_arm"
full_name = "Target: right arm"
description = "Pressing this key targets the right arm. This will impact where you hit people, and can be used for surgery."
keybind_signal = COMSIG_KB_MOB_TARGETRIGHTARM_DOWN
/datum/keybinding/mob/target/body_chest
hotkey_keys = list("Numpad5")
name = "target_body_chest"
full_name = "Target: Body"
description = "Pressing this key targets the body. This will impact where you hit people, and can be used for surgery."
keybind_signal = COMSIG_KB_MOB_TARGETBODYCHEST_DOWN
/datum/keybinding/mob/target/left_arm
hotkey_keys = list("Numpad6")
name = "target_left_arm"
full_name = "Target: left arm"
description = "Pressing this key targets the body. This will impact where you hit people, and can be used for surgery."
keybind_signal = COMSIG_KB_MOB_TARGETLEFTARM_DOWN
/datum/keybinding/mob/target/right_leg
hotkey_keys = list("Numpad1")
name = "target_right_leg"
full_name = "Target: Right leg"
description = "Pressing this key targets the right leg. This will impact where you hit people, and can be used for surgery."
keybind_signal = COMSIG_KB_MOB_TARGETRIGHTLEG_DOWN
/datum/keybinding/mob/target/body_groin
hotkey_keys = list("Numpad2")
name = "target_body_groin"
full_name = "Target: Groin"
description = "Pressing this key targets the groin. This will impact where you hit people, and can be used for surgery."
keybind_signal = COMSIG_KB_MOB_TARGETBODYGROIN_DOWN
/datum/keybinding/mob/target/left_leg
hotkey_keys = list("Numpad3")
name = "target_left_leg"
full_name = "Target: left leg"
description = "Pressing this key targets the left leg. This will impact where you hit people, and can be used for surgery."
keybind_signal = COMSIG_KB_MOB_TARGETLEFTLEG_DOWN
/datum/keybinding/mob/prevent_movement
hotkey_keys = list("Alt")
name = "block_movement"
full_name = "Block movement"
description = "Prevents you from moving"
keybind_signal = COMSIG_KB_MOB_BLOCKMOVEMENT_DOWN
/datum/keybinding/mob/prevent_movement/down(client/user, turf/target, mousepos_x, mousepos_y)
. = ..()
if(.)
return
user.movement_locked = TRUE
/datum/keybinding/mob/prevent_movement/up(client/user, turf/target)
. = ..()
if(.)
return
user.movement_locked = FALSE
/datum/keybinding/living/view_pet_data
hotkey_keys = list("Shift")
name = "view_pet_commands"
full_name = "View Pet Commands"
description = "Hold down to see all the commands you can give your pets!"
keybind_signal = COMSIG_KB_LIVING_VIEW_PET_COMMANDS