From 1eabf98222a94a0c712d03c313c5b0d654c27a3f Mon Sep 17 00:00:00 2001 From: Erika Fox <94164348+Erikafox@users.noreply.github.com> Date: Fri, 21 Feb 2025 18:01:17 -0500 Subject: [PATCH] Aiming Hotkey (#4123) ## About The Pull Request adds an aiming hotkey for mechs/guns ## Changelog :cl: add: aiming hotkey. default bound is shift+z /:cl: --- code/__DEFINES/keybinding.dm | 1 + code/datums/keybinding/human.dm | 17 +++++++++++-- code/modules/mob/mob.dm | 24 ++++++++++++++++++- .../manufacturer/hunter_pride/ballistics.dm | 5 ++-- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/code/__DEFINES/keybinding.dm b/code/__DEFINES/keybinding.dm index 6355c153374b..a3549ed7abed 100644 --- a/code/__DEFINES/keybinding.dm +++ b/code/__DEFINES/keybinding.dm @@ -48,6 +48,7 @@ #define COMSIG_KB_HUMAN_BAGEQUIP_DOWN "keybinding_human_bagequip_down" #define COMSIG_KB_HUMAN_EQUIPMENTSWAP_DOWN "keybinding_human_equipmentswap_down" #define COMSIG_KB_HUMAN_SUITEQUIP_DOWN "keybinding_human_suitequip_down" +#define COMSIG_KB_HUMAN_ADS "keybinding_human_ads" //Living #define COMSIG_KB_LIVING_RESIST_DOWN "keybinding_living_resist_down" diff --git a/code/datums/keybinding/human.dm b/code/datums/keybinding/human.dm index 034f1cffa2e7..aefb89aed5db 100644 --- a/code/datums/keybinding/human.dm +++ b/code/datums/keybinding/human.dm @@ -36,6 +36,21 @@ current_human.do_unique_action() return TRUE +/datum/keybinding/human/ads + hotkey_keys = list("ShiftZ") + name = "aim_down_sights" + full_name = "Aim down sighs" + description = "Aim down the sights of the currently wielded weapon." + keybind_signal = COMSIG_KB_HUMAN_ADS + +/datum/keybinding/human/ads/down(client/user) + . = ..() + if(.) + return + var/mob/living/carbon/human/current_human = user.mob + current_human.do_zoom() + return TRUE + /datum/keybinding/human/secondary_action hotkey_keys = list("ShiftSpace") name = "secondary_action" @@ -43,7 +58,6 @@ description = "" keybind_signal = COMSIG_KB_HUMAN_SECONDARYACTION - /datum/keybinding/human/secondary_action/down(client/user) . = ..() if(.) @@ -52,7 +66,6 @@ current_human.do_secondary_action() return TRUE - /datum/keybinding/human/quick_equip_belt hotkey_keys = list("ShiftE") name = "quick_equip_belt" diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 511f1a658131..a22b2a8b0427 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -662,6 +662,7 @@ return limb_attack_self() +///proc to call unique action on whatever we're holding. /mob/verb/do_unique_action() set name = "Do Unique Action" set category = "Object" @@ -682,6 +683,28 @@ I.unique_action(src) update_inv_hands() +///proc to call zoom on whatever we're holding. +/mob/verb/do_zoom() + set name = "Aim Down Sights" + set category = "Object" + set src = usr + + if(ismecha(loc)) + var/obj/mecha/mecha = loc + if(mecha.zoom_action) + mecha.zoom_action.Activate() + return + return + + var/obj/item/I = get_active_held_item() + if(istype(I, /obj/item/gun)) + var/obj/item/gun/our_gun = I + if(our_gun.wielded_fully) + our_gun.zoom(src, src.dir) + update_inv_hands() + return + return + /mob/verb/do_secondary_action() set name = "Do Secondary Action" set category = "Object" @@ -689,7 +712,6 @@ if(ismecha(loc)) return - if(incapacitated()) return diff --git a/code/modules/projectiles/guns/manufacturer/hunter_pride/ballistics.dm b/code/modules/projectiles/guns/manufacturer/hunter_pride/ballistics.dm index f9cc8b484a29..6ffd93cc7c19 100644 --- a/code/modules/projectiles/guns/manufacturer/hunter_pride/ballistics.dm +++ b/code/modules/projectiles/guns/manufacturer/hunter_pride/ballistics.dm @@ -401,7 +401,8 @@ EMPTY_GUN_HELPER(shotgun/doublebarrel) // sawn off beforehand /obj/item/gun/ballistic/shotgun/doublebarrel/presawn - name = "sawn-off double-barreled shotgun" + //init gives it the sawn_off name + name = "double-barreled shotgun" desc = "A break action shotgun cut down to the size of a sidearm. While the recoil is even harsher, it offers a lot of power in a very small package. Chambered in 12g." sawn_off = TRUE weapon_weight = WEAPON_MEDIUM @@ -883,7 +884,7 @@ EMPTY_GUN_HELPER(shotgun/doublebarrel/beacon) //pre sawn off beacon /obj/item/gun/ballistic/shotgun/doublebarrel/beacon/presawn - name = "sawn-off HP Beacon" + name = "HP Beacon" sawn_desc= "A single-shot break-action pistol chambered in .45-70. A bit difficult to aim." sawn_off = TRUE w_class = WEIGHT_CLASS_NORMAL