From 024c1c331c815227cf3b917d0dd5cf89e4b33dc2 Mon Sep 17 00:00:00 2001 From: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Date: Wed, 21 Jun 2023 14:08:58 -0500 Subject: [PATCH] Fix guns without magazines loaded making no fire sounds (#76196) ## About The Pull Request Runtimed from `90 / null` here. What's the point in a `?` sanity check if you don't default it to any values? Come on guys ## Why It's Good For The Game Bugfix ## Changelog :cl: Melbert fix: Fix shooting guns without a magazine loaded making no fire sound effect /:cl: --- code/modules/projectiles/guns/ballistic.dm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/code/modules/projectiles/guns/ballistic.dm b/code/modules/projectiles/guns/ballistic.dm index cdb2c393f0b..540ad858bba 100644 --- a/code/modules/projectiles/guns/ballistic.dm +++ b/code/modules/projectiles/guns/ballistic.dm @@ -50,7 +50,7 @@ ///Whether the gun will spawn loaded with a magazine var/spawnwithmagazine = TRUE ///Compatible magazines with the gun - var/mag_type = /obj/item/ammo_box/magazine/m10mm //Removes the need for max_ammo and caliber info + var/obj/item/ammo_box/magazine/mag_type = /obj/item/ammo_box/magazine/m10mm //Removes the need for max_ammo and caliber info ///Whether the sprite has a visible magazine or not var/mag_display = TRUE ///Whether the sprite has a visible ammo display or not @@ -151,9 +151,11 @@ AddElement(/datum/element/weapon_description, attached_proc = PROC_REF(add_notes_ballistic)) /obj/item/gun/ballistic/fire_sounds() - var/frequency_to_use = sin((90/magazine?.max_ammo) * get_ammo()) + var/max_ammo = magazine?.max_ammo || initial(mag_type.max_ammo) + var/current_ammo = get_ammo() + var/frequency_to_use = sin((90 / max_ammo) * current_ammo) var/click_frequency_to_use = 1 - frequency_to_use * 0.75 - var/play_click = round(sqrt(magazine?.max_ammo * 2)) > get_ammo() + var/play_click = round(sqrt(max_ammo * 2)) > current_ammo if(suppressed) playsound(src, suppressed_sound, suppressed_volume, vary_fire_sound, ignore_walls = FALSE, extrarange = SILENCED_SOUND_EXTRARANGE, falloff_distance = 0) if(play_click && click_on_low_ammo)