From cb5d1bd72f6ec32fbee7b8d517dcb3b8ad6da4ee Mon Sep 17 00:00:00 2001 From: Pink-Chink Date: Tue, 20 Dec 2022 22:04:42 -0600 Subject: [PATCH 1/2] fixes fire delay overwriting burst delay click cooldown, adds Humon's FA shooting loop fix --- code/__DEFINES/items.dm | 3 --- code/__DEFINES/weapons.dm | 3 +++ code/datums/datum_click_handlers.dm | 15 +++++++-------- code/modules/projectiles/gun.dm | 17 +++++------------ 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/code/__DEFINES/items.dm b/code/__DEFINES/items.dm index 4481157dac0..92210e209d0 100644 --- a/code/__DEFINES/items.dm +++ b/code/__DEFINES/items.dm @@ -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 diff --git a/code/__DEFINES/weapons.dm b/code/__DEFINES/weapons.dm index 623b79eef75..593f108a304 100644 --- a/code/__DEFINES/weapons.dm +++ b/code/__DEFINES/weapons.dm @@ -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. + //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") diff --git a/code/datums/datum_click_handlers.dm b/code/datums/datum_click_handlers.dm index a54aee07b0c..34f3c9dc39a 100644 --- a/code/datums/datum_click_handlers.dm +++ b/code/datums/datum_click_handlers.dm @@ -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) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 0217b52f6a3..910710716b0 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -360,14 +360,14 @@ 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)) @@ -375,9 +375,9 @@ 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. @@ -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) From a6dbf4e96578dfe7d80b35d1054bdab6c5f7d270 Mon Sep 17 00:00:00 2001 From: Pink-Chink <95178278+Pink-Chink@users.noreply.github.com> Date: Wed, 21 Dec 2022 05:12:24 -0800 Subject: [PATCH 2/2] Update code/__DEFINES/weapons.dm Co-authored-by: Humonitarian <61586732+Humonitarian@users.noreply.github.com> --- code/__DEFINES/weapons.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/__DEFINES/weapons.dm b/code/__DEFINES/weapons.dm index 593f108a304..7ce416a55b3 100644 --- a/code/__DEFINES/weapons.dm +++ b/code/__DEFINES/weapons.dm @@ -55,7 +55,7 @@ #define STRUCTURE_DAMAGE_DESTRUCTIVE 3 // Weapon minimum fire_delay -#define GUN_MINIMUM_FIRETIME 1.1 // 110 MS , ~9 shots per second. +#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")