Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggleable auto-catch and easy restock for revolvers #686

Merged
merged 22 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions code/datums/components/magazine_catcher.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
var/mob/living/carbon/human/wearer
///Parent storage in which we want to collect magazines
var/obj/item/storage/storage
////Auto catching empty magazines: FALSE - disabled, TRUE - enabled
var/auto_catch = TRUE

/datum/component/magazine_catcher/Initialize()
. = ..()
Expand All @@ -11,16 +13,20 @@
/datum/component/magazine_catcher/Destroy(force, silent)
storage = null
wearer = null
auto_catch = null
CheBokJam marked this conversation as resolved.
Show resolved Hide resolved
return ..()

/datum/component/magazine_catcher/RegisterWithParent()
. = ..()
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED_TO_SLOT, PROC_REF(equipped_to_slot))
RegisterSignals(parent, list(COMSIG_ITEM_EQUIPPED_NOT_IN_SLOT, COMSIG_ITEM_DROPPED), PROC_REF(removed_from_slot))
storage = parent
storage.verbs += /datum/component/magazine_catcher/verb/toggle_auto_catch

/datum/component/magazine_catcher/UnregisterFromParent()
. = ..()
if(storage)
storage.verbs -= /datum/component/magazine_catcher/verb/toggle_auto_catch
UnregisterSignal(parent, list(COMSIG_ITEM_EQUIPPED_TO_SLOT, COMSIG_ITEM_EQUIPPED_NOT_IN_SLOT, COMSIG_ITEM_DROPPED))

/datum/component/magazine_catcher/proc/equipped_to_slot(datum/source, mob/user, slot)
Expand All @@ -43,4 +49,16 @@
/datum/component/magazine_catcher/proc/try_to_catch_magazine(datum/source, obj/item/mag)
if(!storage.can_be_inserted(mag, FALSE))
return FALSE
if(!auto_catch)
return FALSE
return storage.handle_item_insertion(mag, TRUE)

/datum/component/magazine_catcher/proc/toggle_auto_catch()
set name = "Toggle Auto Catching Magazines/Speed Loaders"
set category = "Object"
var/datum/component/magazine_catcher/comp = GetComponent(/datum/component/magazine_catcher)
comp.auto_catch = !comp.auto_catch
Helg2 marked this conversation as resolved.
Show resolved Hide resolved
if(!comp.auto_catch)
to_chat(usr, "Auto catching disabled.")
else
to_chat(usr, "Auto catching enabled.")
3 changes: 3 additions & 0 deletions code/game/objects/items/storage/holsters.dm
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,13 @@
/obj/item/storage/holster/belt/revolver
name = "generic revolver belt"
desc = "A revolver belt that is not a pistol belt"
flags_equip_slot = ITEM_SLOT_BELT|ITEM_SLOT_SUITSTORE

/obj/item/storage/holster/belt/revolver/Initialize(mapload, ...)
. = ..()
AddComponent(/datum/component/tac_reload_storage)
AddComponent(/datum/component/magazine_catcher)
AddComponent(/datum/component/easy_restock)
Helg2 marked this conversation as resolved.
Show resolved Hide resolved

/obj/item/storage/holster/belt/revolver/t457
name = "\improper T457 pattern revolver holster rig"
Expand Down
3 changes: 2 additions & 1 deletion code/modules/projectiles/guns/revolvers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
if(istype(new_magazine.loc, /obj/item/storage))
var/obj/item/storage/S = new_magazine.loc
S.remove_from_storage(new_magazine, get_turf(user), user)
user.put_in_any_hand_if_possible(new_magazine)
if(!SEND_SIGNAL(user, COMSIG_MAGAZINE_DROP, new_magazine))
user.put_in_any_hand_if_possible(new_magazine)
reload(new_magazine, user)
if(!do_after(user, tac_reload_time * 0.2, IGNORE_USER_LOC_CHANGE, new_magazine) && loc == user)
return
Expand Down
Loading