Skip to content

Commit

Permalink
Toggleable auto-catch and easy restock for revolvers (#686)
Browse files Browse the repository at this point in the history
* Auto catch toggleable

* Desc red

* Revolver catch/restock

* Fix invis magazine and non-reloadable T500/R-76

* Fix belt in suit slot auto_catch now working

* Fixes

* Fixes

* Fix 3

* Second way of implementation

* Stable

* Pomohite pojojda

* Mnogo fixikov

* Delete commentari

* Maybe fix

* Component modifying

* IconDiff naebka

* Fixeki 4

* verb to proc

* Fixeki 6

* Fixeki 7
  • Loading branch information
CheBokJam authored Dec 10, 2024
1 parent 051c259 commit bd65192
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
17 changes: 17 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 @@ -18,9 +20,12 @@
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/proc/toggle_auto_catch

/datum/component/magazine_catcher/UnregisterFromParent()
. = ..()
if(storage)
storage.verbs -= /datum/component/magazine_catcher/proc/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 +48,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
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 @@ -719,10 +719,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)

/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

0 comments on commit bd65192

Please sign in to comment.