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

Fixes an exploit that allows you to infinitely stack damage multipliers #8180

Merged
merged 5 commits into from
Jan 21, 2025
Merged
Changes from all 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
12 changes: 7 additions & 5 deletions code/modules/projectiles/gun_attachables.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -2787,23 +2786,26 @@ 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)
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)
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]."))
playsound(user, gun_activate_sound, 60, 1)
G.active_attachable = src
gun_original_damage_mult = G.damage_mult
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)
Expand Down
Loading