diff --git a/code/modules/projectiles/boxes_magazines/_box_magazine.dm b/code/modules/projectiles/boxes_magazines/_box_magazine.dm index 2ab54aaa908d..33e2191efe6f 100644 --- a/code/modules/projectiles/boxes_magazines/_box_magazine.dm +++ b/code/modules/projectiles/boxes_magazines/_box_magazine.dm @@ -188,6 +188,27 @@ temp_materials[material] = (bullet_cost[material] * stored_ammo.len) + base_cost[material] set_custom_materials(temp_materials) +/// Reverse tactical tac_reloads +/obj/item/ammo_box/magazine/attackby(obj/item/OB, mob/user, params) + .=..() + if(istype(OB, /obj/item/gun/ballistic)) + var/obj/item/gun/ballistic/Ballistic = OB; + if(Ballistic.tac_reloads == TRUE && do_after(user, 0.5 SECONDS, target=user)) + if (Ballistic.magazine != null) + Ballistic.eject_magazine(user, FALSE, src) + return + Ballistic.insert_magazine(user, src) + + +//handling MOSTLY for the bulldog shotgun +/obj/item/ammo_box/magazine/attackby_secondary(obj/item/OB, mob/user, params) + .=..() + if(istype(OB, /obj/item/gun/ballistic)) + var/obj/item/gun/ballistic/Ballistic = OB; + if(Ballistic.tac_reloads == TRUE && do_after(user, 0.5 SECONDS, target=user)) + Ballistic.replace_secondary_magazine(src, user) + return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN + ///Count of number of bullets in the magazine /obj/item/ammo_box/magazine/proc/ammo_count(countempties = TRUE) var/boolets = 0 diff --git a/code/modules/projectiles/guns/ballistic.dm b/code/modules/projectiles/guns/ballistic.dm index f5eb4bb7c71f..4d745a9bcff4 100644 --- a/code/modules/projectiles/guns/ballistic.dm +++ b/code/modules/projectiles/guns/ballistic.dm @@ -709,6 +709,9 @@ GLOBAL_LIST_INIT(gun_saw_types, typecacheof(list( chamber_round() update_appearance() +//modularization +/obj/item/gun/ballistic/proc/replace_secondary_magazine(obj/item/weapon, mob/user) + /obj/item/suppressor name = "suppressor" desc = "A syndicate small-arms suppressor for maximum espionage." diff --git a/code/modules/projectiles/guns/ballistic/shotgun.dm b/code/modules/projectiles/guns/ballistic/shotgun.dm index 32d98eceb6b8..e8c2d12ee75a 100644 --- a/code/modules/projectiles/guns/ballistic/shotgun.dm +++ b/code/modules/projectiles/guns/ballistic/shotgun.dm @@ -212,28 +212,12 @@ return SECONDARY_ATTACK_CALL_NORMAL /obj/item/gun/ballistic/shotgun/bulldog/attackby_secondary(obj/item/weapon, mob/user, params) - if(!istype(weapon, secondary_magazine_type)) - balloon_alert(user, "[weapon.name] doesn't fit!") - return SECONDARY_ATTACK_CALL_NORMAL - if(!user.transferItemToLoc(weapon, src)) - to_chat(user, span_warning("You cannot seem to get [src] out of your hands!")) - return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN - var/obj/item/ammo_box/magazine/old_mag = secondary_magazine - secondary_magazine = weapon - if(old_mag) - user.put_in_hands(old_mag) - balloon_alert(user, "secondary [magazine_wording] loaded") - playsound(src, load_empty_sound, load_sound_volume, load_sound_vary) - update_appearance() + replace_secondary_magazine(weapon, user) return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN /obj/item/gun/ballistic/shotgun/bulldog/alt_click_secondary(mob/user) if(secondary_magazine) - var/obj/item/ammo_box/magazine/old_mag = secondary_magazine - secondary_magazine = null - user.put_in_hands(old_mag) - update_appearance() - playsound(src, load_empty_sound, load_sound_volume, load_sound_vary) + unload_secondary_magazine(user) return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN /obj/item/gun/ballistic/shotgun/bulldog/proc/toggle_magazine() @@ -244,6 +228,28 @@ playsound(src, load_empty_sound, load_sound_volume, load_sound_vary) update_appearance() +/obj/item/gun/ballistic/shotgun/bulldog/proc/unload_secondary_magazine(mob/user) + var/obj/item/ammo_box/magazine/old_mag = secondary_magazine + secondary_magazine = null + user.put_in_hands(old_mag) + update_appearance() + playsound(src, load_empty_sound, load_sound_volume, load_sound_vary) + +/obj/item/gun/ballistic/shotgun/bulldog/replace_secondary_magazine(obj/item/weapon, mob/user) + if(!istype(weapon, secondary_magazine_type)) + balloon_alert(user, "[weapon.name] doesn't fit!") + return SECONDARY_ATTACK_CALL_NORMAL + if(!user.transferItemToLoc(weapon, src)) + to_chat(user, span_warning("You cannot seem to get [src] out of your hands!")) + return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN + var/obj/item/ammo_box/magazine/old_mag = secondary_magazine + secondary_magazine = weapon + if(old_mag) + user.put_in_hands(old_mag) + balloon_alert(user, "secondary [magazine_wording] loaded") + playsound(src, load_empty_sound, load_sound_volume, load_sound_vary) + update_appearance() + /obj/item/gun/ballistic/shotgun/bulldog/unrestricted pin = /obj/item/firing_pin /////////////////////////////