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 <fenodyree.av@gmail.com>
Co-authored-by: SleepyGemmy <99297919+SleepyGemmy@users.noreply.github.com>
This commit is contained in:
FenodyreeAv
2026-03-17 16:19:54 +00:00
committed by GitHub
co-authored by SleepyGemmy
parent 6c4e9254b2
commit 13083e7c55
5 changed files with 87 additions and 15 deletions
+11 -10
View File
@@ -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)
@@ -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
@@ -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
+6
View File
@@ -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)