Skip to content

Commit

Permalink
Adds weapon burst fire
Browse files Browse the repository at this point in the history
  • Loading branch information
covertcorvid committed Feb 28, 2024
1 parent a259535 commit 94a4f08
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions nsv13/code/modules/overmap/overmapJS/overmap_weapon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
/datum/virtual_weapon
var/name
// Firing rate stuff
var/time_between_projectiles = 0
var/time_between_bursts = 0 // If this is a single-shot weapon, leave this at zero
var/burst_size = 1 // TODO handle burst fire
var/seconds_between_projectiles = 0
var/seconds_between_bursts = 0 // If this is a single-shot weapon, leave this at zero
var/burst_size = 1
var/next_fire = 0
// Resupply rate stuff. We'll just make it linear for now.
var/max_time_between_resupplies = 0
Expand All @@ -61,6 +61,13 @@
var/firing_arc_center_rel_deg = 0
var/firing_arc_width_deg = 360 // Anything unspecified is omnidirectional

// I know this feels redundant, but it makes default values on subclasses work
/datum/virtual_weapon/New(firing_arc_center_rel_deg_ = firing_arc_center_rel_deg, firing_arc_width_deg_ = firing_arc_width_deg, seconds_between_projectiles_ = seconds_between_projectiles, seconds_between_bursts_ = seconds_between_bursts)
firing_arc_center_rel_deg = firing_arc_center_rel_deg_
firing_arc_width_deg = firing_arc_width_deg_
seconds_between_projectiles = seconds_between_projectiles_
seconds_between_bursts = seconds_between_bursts_

/datum/virtual_weapon/proc/fire(datum/overmap/src_overmap, angle)
var/proj_angle = angle
if(!src_overmap)
Expand All @@ -76,13 +83,16 @@
if(adjusted_angle > firing_arc_width_deg / 2)
to_chat(world, "adjusted angle [adjusted_angle] was out of range")
return FALSE

if(next_fire > world.time)
// Too soon
return FALSE

src_overmap.fire_projectile(proj_angle, shell_type)
next_fire = world.time + time_between_bursts
// And then if we're a burst weapon...
for(var/i = 1; i < burst_size; i++)
sleep(seconds_between_projectiles SECONDS)
src_overmap.fire_projectile(proj_angle, shell_type)
next_fire = world.time + seconds_between_bursts SECONDS
return TRUE
//TODO: Check if theyre the gunner. Roles... I don't care for now!

Expand Down

0 comments on commit 94a4f08

Please sign in to comment.