From 08f874bef30144024d1e93a39b7794ff7dbcc4c8 Mon Sep 17 00:00:00 2001 From: DeltaFire <46569814+DeltaFire15@users.noreply.github.com> Date: Fri, 12 Jul 2024 20:10:55 +0200 Subject: [PATCH] Improves a little bit of cursed weapon code (#2676) --- .../munitions/ship_weapons/_ship_weapon.dm | 38 +++++++++---------- .../ballistic_weapons/broadsides.dm | 5 ++- .../hybrid_weapons/hybrid_railgun.dm | 3 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/nsv13/code/modules/munitions/ship_weapons/_ship_weapon.dm b/nsv13/code/modules/munitions/ship_weapons/_ship_weapon.dm index dabaa7495f4..3072234350b 100644 --- a/nsv13/code/modules/munitions/ship_weapons/_ship_weapon.dm +++ b/nsv13/code/modules/munitions/ship_weapons/_ship_weapon.dm @@ -481,27 +481,8 @@ * Returns projectile if successfully fired, FALSE otherwise. */ /obj/machinery/ship_weapon/proc/fire(atom/target, shots = weapon_type.burst_size, manual = TRUE) + //Fun fact: set [waitfor, etc] is special, and is inherited by child procs even if they do not call parent! set waitfor = FALSE //As to not hold up any feedback messages. - - // Energy weapons fire behavior - if(istype(src, /obj/machinery/ship_weapon/energy)) // Now 100% more modular! - if(can_fire(target, shots)) - if(manual) - linked.last_fired = overlay - for(var/i = 0, i < shots, i++) - do_animation() - - local_fire() - overmap_fire(target) - charge -= charge_per_shot - - after_fire() - if(shots > 1) - sleep(weapon_type.burst_fire_delay) - return TRUE - return FALSE - - // Default weapons fire behavior if(can_fire(target, shots)) if(manual) linked.last_fired = overlay @@ -525,6 +506,23 @@ if(semi_auto) chamber(rapidfire = TRUE) after_fire() + . = TRUE //waitfor = FALSE early return returns the current . value at the time of sleeping, so this makes it return the correct value for burst fire weapons. + if(shots > 1) + sleep(weapon_type.burst_fire_delay) + return TRUE + return FALSE + +/obj/machinery/ship_weapon/energy/fire(atom/target, shots = weapon_type.burst_size, manual = TRUE) + if(can_fire(target, shots)) + if(manual) + linked.last_fired = overlay + for(var/i = 0, i < shots, i++) + do_animation() + local_fire() + overmap_fire(target) + charge -= charge_per_shot + after_fire() + . = TRUE if(shots > 1) sleep(weapon_type.burst_fire_delay) return TRUE diff --git a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/broadsides.dm b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/broadsides.dm index 33aae729fbe..3ee8b764174 100644 --- a/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/broadsides.dm +++ b/nsv13/code/modules/munitions/ship_weapons/ballistic_weapons/broadsides.dm @@ -129,8 +129,9 @@ animate_projectile(target) /obj/machinery/ship_weapon/broadside/fire(atom/target, shots = weapon_type.burst_size, manual = TRUE) - ..() - new /obj/effect/particle_effect/muzzleflash(loc) + . = ..() + if(.) + new /obj/effect/particle_effect/muzzleflash(loc) /obj/machinery/ship_weapon/broadside/local_fire(shots = weapon_type.burst_size, atom/target) //For the broadside cannons, we want to eject spent casings var/obj/R = new /obj/item/ship_weapon/parts/broadside_casing(get_ranged_target_turf(src, NORTH, 4)) //Right diff --git a/nsv13/code/modules/munitions/ship_weapons/hybrid_weapons/hybrid_railgun.dm b/nsv13/code/modules/munitions/ship_weapons/hybrid_weapons/hybrid_railgun.dm index 9636688c7f1..5e787963587 100644 --- a/nsv13/code/modules/munitions/ship_weapons/hybrid_weapons/hybrid_railgun.dm +++ b/nsv13/code/modules/munitions/ship_weapons/hybrid_weapons/hybrid_railgun.dm @@ -95,7 +95,6 @@ say("Cycling complete: Configuration - 400mm Slug Selected") /obj/machinery/ship_weapon/hybrid_rail/fire(atom/target, shots = weapon_type.burst_size, manual = TRUE) - set waitfor = FALSE //As to not hold up any feedback messages. if(can_fire(target, shots)) if(manual) linked.last_fired = overlay @@ -114,6 +113,8 @@ else state = STATE_NOTLOADED after_fire() + . = TRUE + return TRUE //I don't know why it didn't return true if successful but I assume someone just forgot. return FALSE /obj/machinery/ship_weapon/hybrid_rail/can_fire(target, shots = weapon_type.burst_size) //Target is for the passed target variable, Shots is for the burst fire size