From 13083e7c55b917ba7784757ff4a264253ac7db09 Mon Sep 17 00:00:00 2001 From: FenodyreeAv Date: Tue, 17 Mar 2026 16:19:54 +0000 Subject: [PATCH] Fixes Modular Lasers (#22054) Fixes very old bugs with modular lasers that prevented them from taking damage when fired. Fixes a multiply by zero error that removed their fire delay. Fixes the weapon analyzer, so it correctly shows their damage and number of shots. Fixes the shot-multiplier of the two capacitor mods. Tweaks the damage chance, so that it's not a guarantee that you gun breaks on the first shot if you have more than 1 mod. Reduces the size of components, so that people can pick them up and put them in their bags after their guns break. Forum thread about these changes: https://forums.aurorastation.org/topic/22876-modular-laser-rework-and-fix/ --------- Signed-off-by: FenodyreeAv Co-authored-by: SleepyGemmy <99297919+SleepyGemmy@users.noreply.github.com> --- .../projectiles/guns/energy/modular.dm | 21 +++--- .../modules/projectiles/modular/laser_base.dm | 7 +- .../projectiles/modular/laser_components.dm | 4 +- code/modules/research/weaponsanalyzer.dm | 6 ++ .../Fenodyree-ModularWeaponsFixes.yml | 64 +++++++++++++++++++ 5 files changed, 87 insertions(+), 15 deletions(-) create mode 100644 html/changelogs/Fenodyree-ModularWeaponsFixes.yml diff --git a/code/modules/projectiles/guns/energy/modular.dm b/code/modules/projectiles/guns/energy/modular.dm index b268b5a35f2..ca018e6d570 100644 --- a/code/modules/projectiles/guns/energy/modular.dm +++ b/code/modules/projectiles/guns/energy/modular.dm @@ -107,7 +107,7 @@ fire_delay = capacitor.fire_delay max_shots = capacitor.shots - power_supply.maxcharge = max_shots*charge_cost + dispersion = focusing_lens.dispersion accuracy = focusing_lens.accuracy burst += focusing_lens.burst @@ -116,10 +116,11 @@ if(gun_mods.len) handle_mod() - fire_delay_wielded = min(0,(fire_delay - fire_delay*3)) + max_shots = max_shots * burst + power_supply.maxcharge = max_shots*charge_cost + fire_delay_wielded = fire_delay * 0.75 accuracy_wielded = accuracy + accuracy/4 scoped_accuracy = accuracy_wielded + accuracy/4 - max_shots = max_shots * burst w_class = gun_type reliability = max(reliability, 1) @@ -160,7 +161,7 @@ if(modifier.scope_name) zoomdevicename = modifier.scope_name -/obj/item/gun/energy/laser/prototype/consume_next_projectile(var/bypass_degrade = FALSE) +/obj/item/gun/energy/laser/prototype/consume_next_projectile(var/mob/user, var/bypass_degrade = FALSE) if(!power_supply) return null if(!ispath(projectile_type)) @@ -177,17 +178,17 @@ for(var/obj/item/laser_components/modifier/modifier in gun_mods) damage_coeff *= modifier.damage if(burst > 1) - A.damage = A.damage/(burst - 1) + A.damage = A.damage/(max(1, burst - 1)) //Damage is divided by the number of shots damage_coeff *= modulator.damage A.damage *= damage_coeff - A.damage = min(A.damage, 60) //let's not get too ridiculous here + A.damage = min(A.damage, 60) //Caps the maximum damage one shot can do, this matches the laser cannon if(!bypass_degrade) - for(var/obj/item/laser_components/modifier/modifier in gun_mods) - if(prob((gun_mods.len * 10 * damage_coeff)/(max(1,(burst - 1))))) + for(var/obj/item/laser_components/modifier/modifier in gun_mods) //This repeats for EVERY MOD, fail chance goes up quadratically with the number of mods + if(prob((gun_mods.len * 2 * damage_coeff)/(max(1,(burst - 1))))) capacitor.degrade(modifier.malus) - if(prob((gun_mods.len * 10 * damage_coeff)/(max(1,(burst - 1))))) + if(prob((gun_mods.len * 2 * damage_coeff)/(max(1,(burst - 1))))) focusing_lens.degrade(modifier.malus) - if(prob((33 + capacitor.damage)/(max(1,(burst - 1))))) + if(prob((33 + capacitor.damage)/(max(1,(burst - 1))))) //Firing a gun with a damaged capacitor risks arcing to other components, damaging them modifier.degrade(1) updatetype(ismob(loc) ? loc : null) diff --git a/code/modules/projectiles/modular/laser_base.dm b/code/modules/projectiles/modular/laser_base.dm index 5ffde6f52cb..95a6fb893ad 100644 --- a/code/modules/projectiles/modular/laser_base.dm +++ b/code/modules/projectiles/modular/laser_base.dm @@ -2,11 +2,12 @@ icon = 'icons/obj/guns/modular_laser.dmi' icon_state = "bfg" contained_sprite = TRUE + w_class = WEIGHT_CLASS_TINY //A dissasembled gun is easier to carry, this lets people bring bits of their broken gun back to R&D. var/reliability = 0 var/damage = 1 - var/fire_delay = 0 + var/fire_delay = 1 var/condition = 0 //inverse health of the component. subtracted from reliability. - var/shots = 0 + var/shots = 1 var/burst = 0 var/accuracy = 0 var/obj/item/repair_item @@ -73,6 +74,7 @@ shots = 5 damage = 10 reliability = 50 + fire_delay = 5 repair_item = /obj/item/stack/cable_coil /obj/item/laser_components/capacitor/condition_hints(mob/user, distance, is_adjacent) @@ -137,7 +139,6 @@ /obj/item/laser_assembly name = "laser assembly (small)" desc = "A case for shoving things into. Hopefully they work." - w_class = WEIGHT_CLASS_SMALL icon = 'icons/obj/guns/modular_laser.dmi' var/base_icon_state = "small" contained_sprite = TRUE diff --git a/code/modules/projectiles/modular/laser_components.dm b/code/modules/projectiles/modular/laser_components.dm index 5d7f13cc2e9..b89032b22b5 100644 --- a/code/modules/projectiles/modular/laser_components.dm +++ b/code/modules/projectiles/modular/laser_components.dm @@ -3,14 +3,14 @@ /obj/item/laser_assembly/medium name = "laser assembly (medium)" base_icon_state = "medium" - w_class = WEIGHT_CLASS_NORMAL + w_class = WEIGHT_CLASS_SMALL size = CHASSIS_MEDIUM modifier_cap = 4 /obj/item/laser_assembly/large name = "laser assembly (large)" base_icon_state = "large" - w_class = WEIGHT_CLASS_BULKY + w_class = WEIGHT_CLASS_NORMAL size = CHASSIS_LARGE modifier_cap = 5 diff --git a/code/modules/research/weaponsanalyzer.dm b/code/modules/research/weaponsanalyzer.dm index 13a2e370d80..73db862b20f 100644 --- a/code/modules/research/weaponsanalyzer.dm +++ b/code/modules/research/weaponsanalyzer.dm @@ -188,8 +188,12 @@ if(istype(gun, /obj/item/gun/energy/laser/prototype)) var/obj/item/gun/energy/laser/prototype/E_prototype = gun var/list/mods = list() + var/l_modified_damage = 1 //E_prototype.capacitor.damage * E_prototype.modulator.damage + var/l_modified_max_shots = 1 //E_prototype.capacitor.shots for(var/i in list(E_prototype.capacitor, E_prototype.focusing_lens, E_prototype.modulator) + E_prototype.gun_mods) var/obj/item/laser_components/l_component = i + l_modified_damage *= l_component.damage + l_modified_max_shots *= l_component.shots var/l_repair_name = initial(l_component.repair_item.name) ? initial(l_component.repair_item.name) : "nothing" mods += list(list( "name" = initial(l_component.name), @@ -201,6 +205,8 @@ "accuracy_modifier" = initial(l_component.accuracy), "repair_tool" = l_repair_name )) + data["gun"]["damage"] = l_modified_damage + data["gun"]["max_shots"] = l_modified_max_shots data["gun_mods"] = mods if(E.secondary_projectile_type) diff --git a/html/changelogs/Fenodyree-ModularWeaponsFixes.yml b/html/changelogs/Fenodyree-ModularWeaponsFixes.yml new file mode 100644 index 00000000000..5cf7b668a44 --- /dev/null +++ b/html/changelogs/Fenodyree-ModularWeaponsFixes.yml @@ -0,0 +1,64 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# - (fixes bugs) +# wip +# - (work in progress) +# qol +# - (quality of life) +# soundadd +# - (adds a sound) +# sounddel +# - (removes a sound) +# rscadd +# - (adds a feature) +# rscdel +# - (removes a feature) +# imageadd +# - (adds an image or sprite) +# imagedel +# - (removes an image or sprite) +# spellcheck +# - (fixes spelling or grammar) +# experiment +# - (experimental change) +# balance +# - (balance changes) +# code_imp +# - (misc internal code change) +# refactor +# - (refactors code) +# config +# - (makes a change to the config files) +# admin +# - (makes changes to administrator tools) +# server +# - (miscellaneous changes to server) +################################# + +# Your name. +author: Fenodyree + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, this gets changed to [] after reading. Just remove the brackets when you add new shit. +# Please surround your changes in double quotes ("). It works without them, but if you use certain characters it screws up compiling. The quotes will not show up in the changelog. +changes: + - bugfix: "The weapon analyzer now correctly shows the damage and number of shots for modular lasers." + - bugfix: "Modular lasers can break again when fired by mobs." + - bugfix: "Modular lasers now have working fire delay." + - bugfix: "Backup Capacitors and Capacitor Overcharge now correctly reduce or increase the max number of shots." + - balance: "Chance per mod to break a component was decreased from 10 * Number of Mods * Damage Mult, to 2 * Number of Mods * Damage Mult" + - balance: "Components were reduced in size, so that the components of a gun aren't ten times the size of the finished product." +