From c3a817eb14e9e69ee130bda8b12697448c708dee Mon Sep 17 00:00:00 2001 From: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Date: Mon, 20 Jan 2025 13:14:42 +0000 Subject: [PATCH 1/5] Allows gun attachments to retain the gun's original damage --- code/modules/projectiles/gun_attachables.dm | 5 ----- 1 file changed, 5 deletions(-) diff --git a/code/modules/projectiles/gun_attachables.dm b/code/modules/projectiles/gun_attachables.dm index 12d9f787aa32..d2e30097974a 100644 --- a/code/modules/projectiles/gun_attachables.dm +++ b/code/modules/projectiles/gun_attachables.dm @@ -2793,17 +2793,12 @@ Defined in conflicts.dm of the #defines folder. to_chat(user, SPAN_NOTICE("You are no longer using [src].")) playsound(user, gun_deactivate_sound, 30, 1) G.active_attachable = null - var/diff = G.damage_mult - 1 //so that if we buffed gun in process, it still does stuff - //yeah you can cheat by placing BC after switching to underbarrell, but that is one time and we can skip it for sake of optimization - G.damage_mult = gun_original_damage_mult + diff icon_state = initial(icon_state) else if(!turn_off) if(user) to_chat(user, SPAN_NOTICE("You are now using [src].")) playsound(user, gun_activate_sound, 60, 1) G.active_attachable = src - gun_original_damage_mult = G.damage_mult - G.damage_mult = 1 icon_state += "-on" SEND_SIGNAL(G, COMSIG_GUN_INTERRUPT_FIRE) From 3596e5c188c9f493ee91a9c396f7bd91c0df1dd2 Mon Sep 17 00:00:00 2001 From: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Date: Mon, 20 Jan 2025 13:17:10 +0000 Subject: [PATCH 2/5] fix --- code/modules/projectiles/gun_attachables.dm | 1 - 1 file changed, 1 deletion(-) diff --git a/code/modules/projectiles/gun_attachables.dm b/code/modules/projectiles/gun_attachables.dm index d2e30097974a..db90efaa359e 100644 --- a/code/modules/projectiles/gun_attachables.dm +++ b/code/modules/projectiles/gun_attachables.dm @@ -2750,7 +2750,6 @@ Defined in conflicts.dm of the #defines folder. var/last_fired //When the attachment was last fired. var/attachment_firing_delay = 0 //the delay between shots, for attachments that fires stuff var/fire_sound = null //Sound to play when firing it alternately - var/gun_original_damage_mult = 1 //so you don't buff the underbarrell gun with charger for the wrong weapon var/gun_deactivate_sound = 'sound/weapons/handling/gun_underbarrel_deactivate.ogg'//allows us to give the attached gun unique activate and de-activate sounds. Not used yet. var/gun_activate_sound = 'sound/weapons/handling/gun_underbarrel_activate.ogg' var/unload_sound = 'sound/weapons/gun_shotgun_shell_insert.ogg' From 1ad00c7899bf4718d9031976be2d2023feb7eaa0 Mon Sep 17 00:00:00 2001 From: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Date: Mon, 20 Jan 2025 14:59:28 +0000 Subject: [PATCH 3/5] Undoes the damage mult stuff --- code/modules/projectiles/gun_attachables.dm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/modules/projectiles/gun_attachables.dm b/code/modules/projectiles/gun_attachables.dm index db90efaa359e..a19a312ce48d 100644 --- a/code/modules/projectiles/gun_attachables.dm +++ b/code/modules/projectiles/gun_attachables.dm @@ -2793,11 +2793,13 @@ Defined in conflicts.dm of the #defines folder. playsound(user, gun_deactivate_sound, 30, 1) G.active_attachable = null icon_state = initial(icon_state) + G.recalculate_attachment_bonuses() else if(!turn_off) if(user) to_chat(user, SPAN_NOTICE("You are now using [src].")) playsound(user, gun_activate_sound, 60, 1) G.active_attachable = src + G.damage_mult = 1 icon_state += "-on" SEND_SIGNAL(G, COMSIG_GUN_INTERRUPT_FIRE) From ac09e24018df32331f09668036413cd5774feb58 Mon Sep 17 00:00:00 2001 From: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Date: Mon, 20 Jan 2025 15:03:36 +0000 Subject: [PATCH 4/5] Makes the solution more concrete --- code/modules/projectiles/gun_attachables.dm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/modules/projectiles/gun_attachables.dm b/code/modules/projectiles/gun_attachables.dm index a19a312ce48d..ec50a792f95e 100644 --- a/code/modules/projectiles/gun_attachables.dm +++ b/code/modules/projectiles/gun_attachables.dm @@ -2786,6 +2786,10 @@ Defined in conflicts.dm of the #defines folder. SIGNAL_HANDLER target = get_turf(target) +/obj/item/attachable/attached_gun/proc/reset_damage_mult(obj/item/weapon/gun/gun) + SIGNAL_HANDLER + gun.damage_mult = 1 + /obj/item/attachable/attached_gun/activate_attachment(obj/item/weapon/gun/G, mob/living/user, turn_off) if(G.active_attachable == src) if(user) @@ -2794,12 +2798,14 @@ Defined in conflicts.dm of the #defines folder. G.active_attachable = null icon_state = initial(icon_state) G.recalculate_attachment_bonuses() + UnregisterSignal(G, COMSIG_GUN_RECALCULATE_ATTACHMENT_BONUSES) else if(!turn_off) if(user) to_chat(user, SPAN_NOTICE("You are now using [src].")) playsound(user, gun_activate_sound, 60, 1) G.active_attachable = src G.damage_mult = 1 + RegisterSignal(G, COMSIG_GUN_RECALCULATE_ATTACHMENT_BONUSES, PROC_REF(reset_damage_mult)) icon_state += "-on" SEND_SIGNAL(G, COMSIG_GUN_INTERRUPT_FIRE) From 7d25e74b64ecaa9903a65737e11e1e308a143c08 Mon Sep 17 00:00:00 2001 From: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Date: Mon, 20 Jan 2025 15:04:36 +0000 Subject: [PATCH 5/5] Fixes order --- code/modules/projectiles/gun_attachables.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/projectiles/gun_attachables.dm b/code/modules/projectiles/gun_attachables.dm index ec50a792f95e..7a847e817148 100644 --- a/code/modules/projectiles/gun_attachables.dm +++ b/code/modules/projectiles/gun_attachables.dm @@ -2797,8 +2797,8 @@ Defined in conflicts.dm of the #defines folder. playsound(user, gun_deactivate_sound, 30, 1) G.active_attachable = null icon_state = initial(icon_state) - G.recalculate_attachment_bonuses() UnregisterSignal(G, COMSIG_GUN_RECALCULATE_ATTACHMENT_BONUSES) + G.recalculate_attachment_bonuses() else if(!turn_off) if(user) to_chat(user, SPAN_NOTICE("You are now using [src]."))