Skip to content

Commit

Permalink
Improves a little bit of cursed weapon code (#2676)
Browse files Browse the repository at this point in the history
  • Loading branch information
DeltaFire15 authored Jul 12, 2024
1 parent 7b2eb24 commit 08f874b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
38 changes: 18 additions & 20 deletions nsv13/code/modules/munitions/ship_weapons/_ship_weapon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 08f874b

Please sign in to comment.