Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fire rate and burst fire fix #7972

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions code/__DEFINES/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
//flags
#define UPGRADE_ITEMFLAGPLUS "item_flag_add"

// Weapon minimum fire_delay
#define GUN_MINIMUM_FIRETIME 1.1 // 110 MS , ~9 shots per second.

//Weapon upgrade defines

//Int multiplier
Expand Down
3 changes: 3 additions & 0 deletions code/__DEFINES/weapons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
#define STRUCTURE_DAMAGE_POWERFUL 2
#define STRUCTURE_DAMAGE_DESTRUCTIVE 3

// Weapon minimum fire_delay
#define GUN_MINIMUM_FIRETIME 1.1 // 110 MS , ~9 shots per second, 545 RPM

//Quick defines for fire modes
#define FULL_AUTO_300 list(mode_name = "full auto", mode_desc = "300 rounds per minute", mode_type = /datum/firemode/automatic, fire_delay = 4 , icon="auto")
#define FULL_AUTO_400 list(mode_name = "full auto", mode_desc = "400 rounds per minute", mode_type = /datum/firemode/automatic, fire_delay = 3, icon="auto")
Expand Down
15 changes: 7 additions & 8 deletions code/datums/datum_click_handlers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,17 @@
return TRUE

/datum/click_handler/fullauto/proc/shooting_loop()
while(target)
if(!owner || !owner.mob || owner.mob.resting)
return FALSE

if(!owner || !owner.mob || owner.mob.resting)
return FALSE
if(target)
owner.mob.face_atom(target)

while(time_since_last_shot < world.time)
do_fire()
time_since_last_shot = world.time + (reciever.fire_delay < GUN_MINIMUM_FIRETIME ? GUN_MINIMUM_FIRETIME : reciever.fire_delay) * min(world.tick_lag, 1)
while(time_since_last_shot < world.time)
do_fire()
time_since_last_shot += (reciever.fire_delay < GUN_MINIMUM_FIRETIME ? GUN_MINIMUM_FIRETIME : reciever.fire_delay) * min(world.tick_lag, 1)

spawn(1)
shooting_loop()
sleep(1)

/datum/click_handler/fullauto/MouseDrag(over_object, src_location, over_location, src_control, over_control, params)
src_location = resolve_world_target(src_location)
Expand Down
17 changes: 5 additions & 12 deletions code/modules/projectiles/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -360,24 +360,24 @@
return ..() //Pistolwhippin'

/obj/item/gun/proc/Fire(atom/target, mob/living/user, clickparams, pointblank=0, reflex=0)
if(!user || !target) return
if(!user || !target)
return

if(world.time < next_fire_time)
if (!suppress_delay_warning && world.time % 3) //to prevent spam
to_chat(user, SPAN_WARNING("[src] is not ready to fire again!"))
return


add_fingerprint(user)

if(!special_check(user))
return

currently_firing = TRUE

var/shoot_time = (burst - 1)* burst_delay
user.setClickCooldown(shoot_time) //no clicking on things while shooting
var/shoot_time = (burst - 1) * burst_delay + ((fire_delay < GUN_MINIMUM_FIRETIME ? GUN_MINIMUM_FIRETIME : fire_delay) * ((!twohanded && user.stats.getPerk(PERK_GUNSLINGER)) ? 0.66 : 1))
next_fire_time = world.time + shoot_time
user.setClickCooldown(shoot_time)

//actually attempt to shoot
var/turf/targloc = get_turf(target) //cache this in case target gets deleted during shooting, e.g. if it was a securitron that got destroyed.
Expand Down Expand Up @@ -427,18 +427,11 @@
update_icon()

if(i < burst)
next_fire_time = world.time + shoot_time
sleep(burst_delay)

if(!(target && target.loc))
target = targloc
pointblank = 0
if(!twohanded && user.stats.getPerk(PERK_GUNSLINGER))
next_fire_time = world.time + (fire_delay < GUN_MINIMUM_FIRETIME ? GUN_MINIMUM_FIRETIME : fire_delay) * 0.66
user.setClickCooldown(fire_delay * 0.66)
else
next_fire_time = world.time + fire_delay < GUN_MINIMUM_FIRETIME ? GUN_MINIMUM_FIRETIME : fire_delay
user.setClickCooldown(fire_delay)
pointblank = FALSE

user.set_move_cooldown(move_delay)
if(muzzle_flash)
Expand Down