From 4db773c688fb5144b19508cd8d66a3be9464a309 Mon Sep 17 00:00:00 2001 From: John Doe Date: Wed, 26 Jul 2023 05:39:02 -0700 Subject: [PATCH] automatic guns real???? --- code/__DEFINES/conflict.dm | 2 +- code/datums/components/autofire/autofire.dm | 7 +++++-- code/modules/projectiles/gun.dm | 4 +++- code/modules/projectiles/gun_attachables.dm | 4 ++-- code/modules/projectiles/guns/energy.dm | 2 ++ code/modules/projectiles/guns/flamer/flamer.dm | 1 + code/modules/projectiles/guns/misc.dm | 2 ++ code/modules/projectiles/guns/pistols.dm | 1 + code/modules/projectiles/guns/rifles.dm | 14 ++++++++++++-- code/modules/projectiles/guns/shotguns.dm | 1 + code/modules/projectiles/guns/smartgun.dm | 1 + code/modules/projectiles/guns/smgs.dm | 7 +++++++ 12 files changed, 38 insertions(+), 8 deletions(-) diff --git a/code/__DEFINES/conflict.dm b/code/__DEFINES/conflict.dm index 7a1b322a19ee..dab539bce8df 100644 --- a/code/__DEFINES/conflict.dm +++ b/code/__DEFINES/conflict.dm @@ -68,7 +68,7 @@ #define GUN_ANTIQUE (1<<13) /// Whether the gun has been fired by its current user (reset upon `dropped()`) #define GUN_RECOIL_BUILDUP (1<<14) -/// support weapon, bipod will grant IFF +/// support weapon, bipod will grant autofire #define GUN_SUPPORT_PLATFORM (1<<15) /// No gun description, only base desc #define GUN_NO_DESCRIPTION (1<<16) diff --git a/code/datums/components/autofire/autofire.dm b/code/datums/components/autofire/autofire.dm index 31ca255f1b88..571848763f06 100644 --- a/code/datums/components/autofire/autofire.dm +++ b/code/datums/components/autofire/autofire.dm @@ -15,6 +15,8 @@ var/have_to_reset_at_burst_end = FALSE ///If we are in a burst var/bursting = FALSE + /// The multiplier for how much slower the parent should fire in automatic mode. 1 is normal, 1.2 is 20% slower, 2 is 100% slower, etc. + var/automatic_delay_mult = 1 ///Callback to set bursting mode on the parent var/datum/callback/callback_bursting ///Callback to ask the parent to reset its firing vars @@ -26,7 +28,7 @@ ///Callback to set parent's fa_firing var/datum/callback/callback_set_firing -/datum/component/automatedfire/autofire/Initialize(auto_fire_shot_delay = 0.3 SECONDS, burstfire_shot_delay, burst_shots_to_fire = 3, fire_mode = GUN_FIREMODE_SEMIAUTO, datum/callback/callback_bursting, datum/callback/callback_reset_fire, datum/callback/callback_fire, datum/callback/callback_display_ammo, datum/callback/callback_set_firing) +/datum/component/automatedfire/autofire/Initialize(auto_fire_shot_delay = 0.3 SECONDS, burstfire_shot_delay, burst_shots_to_fire = 3, fire_mode = GUN_FIREMODE_SEMIAUTO, automatic_delay_mult = 1, datum/callback/callback_bursting, datum/callback/callback_reset_fire, datum/callback/callback_fire, datum/callback/callback_display_ammo, datum/callback/callback_set_firing) . = ..() RegisterSignal(parent, COMSIG_GUN_FIRE_MODE_TOGGLE, PROC_REF(modify_fire_mode)) @@ -40,6 +42,7 @@ src.burstfire_shot_delay = burstfire_shot_delay src.burst_shots_to_fire = burst_shots_to_fire src.fire_mode = fire_mode + src.automatic_delay_mult = automatic_delay_mult src.callback_bursting = callback_bursting src.callback_reset_fire = callback_reset_fire src.callback_fire = callback_fire @@ -131,7 +134,7 @@ next_fire = world.time + burstfire_shot_delay if(GUN_FIREMODE_AUTOMATIC) callback_set_firing.Invoke(TRUE) - next_fire = world.time + auto_fire_shot_delay + next_fire = world.time + (auto_fire_shot_delay * automatic_delay_mult) if(GUN_FIREMODE_SEMIAUTO) return schedule_shot() diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 54e066e05544..9a25ad45a48c 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -228,6 +228,8 @@ VAR_PROTECTED/start_semiauto = TRUE /// If this gun should spawn with automatic fire. Protected due to it never needing to be edited. VAR_PROTECTED/start_automatic = FALSE + /// The multiplier for how much slower this should fire in automatic mode. 1 is normal, 1.2 is 20% slower, 2 is 100% slower, etc. Protected due to it never needing to be edited. + VAR_PROTECTED/autofire_slow_mult = 1.2 /** @@ -274,7 +276,7 @@ AddElement(/datum/element/drop_retrieval/gun, auto_retrieval_slot) update_icon() //for things like magazine overlays gun_firemode = gun_firemode_list[1] || GUN_FIREMODE_SEMIAUTO - AddComponent(/datum/component/automatedfire/autofire, fire_delay, burst_delay, burst_amount, gun_firemode, CALLBACK(src, PROC_REF(set_bursting)), CALLBACK(src, PROC_REF(reset_fire)), CALLBACK(src, PROC_REF(fire_wrapper)), CALLBACK(src, PROC_REF(display_ammo)), CALLBACK(src, PROC_REF(set_auto_firing))) //This should go after handle_starting_attachment() and setup_firemodes() to get the proper values set. + AddComponent(/datum/component/automatedfire/autofire, fire_delay, burst_delay, burst_amount, gun_firemode, autofire_slow_mult, CALLBACK(src, PROC_REF(set_bursting)), CALLBACK(src, PROC_REF(reset_fire)), CALLBACK(src, PROC_REF(fire_wrapper)), CALLBACK(src, PROC_REF(display_ammo)), CALLBACK(src, PROC_REF(set_auto_firing))) //This should go after handle_starting_attachment() and setup_firemodes() to get the proper values set. /obj/item/weapon/gun/proc/set_gun_attachment_offsets() attachable_offset = null diff --git a/code/modules/projectiles/gun_attachables.dm b/code/modules/projectiles/gun_attachables.dm index 001cd9fbe10c..90350558d688 100644 --- a/code/modules/projectiles/gun_attachables.dm +++ b/code/modules/projectiles/gun_attachables.dm @@ -2657,7 +2657,7 @@ Defined in conflicts.dm of the #defines folder. UnregisterSignal(user, COMSIG_MOB_MOVE_OR_LOOK) if(G.flags_gun_features & GUN_SUPPORT_PLATFORM) - G.remove_bullet_trait("iff") + G.remove_firemode(GUN_FIREMODE_AUTOMATIC) if(!QDELETED(G)) playsound(user,'sound/items/m56dauto_rotate.ogg', 55, 1) @@ -2693,7 +2693,7 @@ Defined in conflicts.dm of the #defines folder. RegisterSignal(user, COMSIG_MOB_MOVE_OR_LOOK, PROC_REF(handle_mob_move_or_look)) if(G.flags_gun_features & GUN_SUPPORT_PLATFORM) - G.add_bullet_trait(BULLET_TRAIT_ENTRY_ID("iff", /datum/element/bullet_trait_iff)) + G.add_firemode(GUN_FIREMODE_AUTOMATIC) else to_chat(user, SPAN_NOTICE("You retract [src].")) diff --git a/code/modules/projectiles/guns/energy.dm b/code/modules/projectiles/guns/energy.dm index 25efbd420ec6..0216a1f6f711 100644 --- a/code/modules/projectiles/guns/energy.dm +++ b/code/modules/projectiles/guns/energy.dm @@ -181,6 +181,7 @@ fire_sound = 'sound/weapons/Laser4.ogg' has_charge_meter = FALSE charge_icon = "+laz_uzi_empty" + start_automatic = TRUE /obj/item/weapon/gun/energy/laz_uzi/set_gun_config_values() ..() @@ -194,6 +195,7 @@ scatter_unwielded = SCATTER_AMOUNT_TIER_6 damage_mult = BASE_BULLET_DAMAGE_MULT recoil_unwielded = RECOIL_AMOUNT_TIER_5 + fa_scatter_peak = SCATTER_AMOUNT_TIER_8 //############################ Taser ################## // Lots of bits for it so splitting off an area diff --git a/code/modules/projectiles/guns/flamer/flamer.dm b/code/modules/projectiles/guns/flamer/flamer.dm index f327a92ffc9c..3125468ee56f 100644 --- a/code/modules/projectiles/guns/flamer/flamer.dm +++ b/code/modules/projectiles/guns/flamer/flamer.dm @@ -367,6 +367,7 @@ desc = "A prototyped model of the M240-T incinerator unit, it was discontinued after its automatic mode was deemed too expensive to deploy in the field." start_semiauto = FALSE start_automatic = TRUE + autofire_slow_mult = 1 /obj/item/weapon/gun/flamer/M240T/auto/set_gun_config_values() . = ..() diff --git a/code/modules/projectiles/guns/misc.dm b/code/modules/projectiles/guns/misc.dm index 2aa6b2dfc4d3..6a1f13b68380 100644 --- a/code/modules/projectiles/guns/misc.dm +++ b/code/modules/projectiles/guns/misc.dm @@ -17,6 +17,7 @@ gun_category = GUN_CATEGORY_HEAVY start_semiauto = FALSE start_automatic = TRUE + autofire_slow_mult = 1 /obj/item/weapon/gun/minigun/Initialize(mapload, spawn_empty) . = ..() @@ -86,6 +87,7 @@ ) start_semiauto = FALSE start_automatic = TRUE + autofire_slow_mult = 1 var/cover_open = FALSE //if the gun's feed-cover is open or not. diff --git a/code/modules/projectiles/guns/pistols.dm b/code/modules/projectiles/guns/pistols.dm index 47b80f7b9218..8da9e7460491 100644 --- a/code/modules/projectiles/guns/pistols.dm +++ b/code/modules/projectiles/guns/pistols.dm @@ -790,6 +790,7 @@ It is a modified Beretta 93R, and can fire three-round burst or single fire. Whe ) start_semiauto = FALSE start_automatic = TRUE + autofire_slow_mult = 1 /obj/item/weapon/gun/pistol/skorpion/set_gun_attachment_offsets() attachable_offset = list("muzzle_x" = 29, "muzzle_y" = 18,"rail_x" = 16, "rail_y" = 21, "under_x" = 23, "under_y" = 15, "stock_x" = 23, "stock_y" = 15) diff --git a/code/modules/projectiles/guns/rifles.dm b/code/modules/projectiles/guns/rifles.dm index 09a0e2b683cf..bc6029b395ab 100644 --- a/code/modules/projectiles/guns/rifles.dm +++ b/code/modules/projectiles/guns/rifles.dm @@ -75,6 +75,7 @@ flags_gun_features = GUN_AUTO_EJECTOR|GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER starting_attachment_types = list(/obj/item/attachable/attached_gun/grenade, /obj/item/attachable/stock/rifle/collapsible) map_specific_decoration = TRUE + start_automatic = TRUE /obj/item/weapon/gun/rifle/m41a/set_gun_attachment_offsets() attachable_offset = list("muzzle_x" = 32, "muzzle_y" = 18,"rail_x" = 12, "rail_y" = 23, "under_x" = 24, "under_y" = 13, "stock_x" = 24, "stock_y" = 13) @@ -88,7 +89,6 @@ accuracy_mult = BASE_ACCURACY_MULT + HIT_ACCURACY_MULT_TIER_4 + 2*HIT_ACCURACY_MULT_TIER_1 accuracy_mult_unwielded = BASE_ACCURACY_MULT - HIT_ACCURACY_MULT_TIER_7 scatter = SCATTER_AMOUNT_TIER_8 - //fa_scatter_peak = FULL_AUTO_SCATTER_PEAK_TIER_8 //Zonenote burst_scatter_mult = SCATTER_AMOUNT_TIER_10 scatter_unwielded = SCATTER_AMOUNT_TIER_2 damage_mult = BASE_BULLET_DAMAGE_MULT + BULLET_DAMAGE_MULT_TIER_2 @@ -150,6 +150,8 @@ /obj/item/attachable/attached_gun/flamer/advanced, ) start_semiauto = FALSE + start_automatic = TRUE + autofire_slow_mult = 1.1 /obj/item/weapon/gun/rifle/nsg23/Initialize(mapload, spawn_empty) . = ..() @@ -171,6 +173,7 @@ damage_mult = BASE_BULLET_DAMAGE_MULT + BULLET_DAMAGE_MULT_TIER_8 recoil_unwielded = RECOIL_AMOUNT_TIER_2 damage_falloff_mult = 0 + fa_max_scatter = SCATTER_AMOUNT_TIER_5 /obj/item/weapon/gun/rifle/nsg23/handle_starting_attachment() ..() @@ -383,6 +386,7 @@ flags_gun_features = GUN_AUTO_EJECTOR|GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER starting_attachment_types = list(/obj/item/attachable/attached_gun/grenade/mk1, /obj/item/attachable/stock/rifle/collapsible) + start_automatic = TRUE /obj/item/weapon/gun/rifle/m41aMK1/set_gun_attachment_offsets() attachable_offset = list("muzzle_x" = 32, "muzzle_y" = 18,"rail_x" = 12, "rail_y" = 23, "under_x" = 23, "under_y" = 13, "stock_x" = 24, "stock_y" = 14) @@ -485,6 +489,7 @@ indestructible = TRUE auto_retrieval_slot = WEAR_J_STORE map_specific_decoration = TRUE + autofire_slow_mult = 1 var/mob/living/carbon/human/linked_human var/is_locked = TRUE @@ -528,6 +533,7 @@ scatter_unwielded = SCATTER_AMOUNT_TIER_2 damage_mult = BASE_BULLET_DAMAGE_MULT + BULLET_DAMAGE_MULT_TIER_3 recoil_unwielded = RECOIL_AMOUNT_TIER_2 + fa_max_scatter = SCATTER_AMOUNT_TIER_7 /obj/item/weapon/gun/rifle/m46c/able_to_fire(mob/user) . = ..() @@ -633,9 +639,11 @@ if(iff_enabled) modify_fire_delay(FIRE_DELAY_TIER_10) remove_firemode(GUN_FIREMODE_BURSTFIRE) + remove_firemode(GUN_FIREMODE_AUTOMATIC) else add_firemode(GUN_FIREMODE_BURSTFIRE) + add_firemode(GUN_FIREMODE_AUTOMATIC) /obj/item/weapon/gun/rifle/m46c/proc/name_after_co(mob/living/carbon/human/H) @@ -719,6 +727,7 @@ ) flags_gun_features = GUN_AUTO_EJECTOR|GUN_CAN_POINTBLANK + start_automatic = TRUE @@ -1232,7 +1241,7 @@ /obj/item/attachable/magnetic_harness, ) - flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER|GUN_WIELDED_FIRING_ONLY + flags_gun_features = GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER|GUN_WIELDED_FIRING_ONLY|GUN_SUPPORT_PLATFORM gun_category = GUN_CATEGORY_HEAVY /obj/item/weapon/gun/rifle/lmg/set_gun_attachment_offsets() @@ -1297,6 +1306,7 @@ flags_gun_features = GUN_AUTO_EJECTOR|GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER flags_equip_slot = SLOT_BACK + start_automatic = TRUE /obj/item/weapon/gun/rifle/type71/set_gun_attachment_offsets() attachable_offset = list("muzzle_x" = 32, "muzzle_y" = 18,"rail_x" = 18, "rail_y" = 23, "under_x" = 20, "under_y" = 13, "stock_x" = 24, "stock_y" = 13) diff --git a/code/modules/projectiles/guns/shotguns.dm b/code/modules/projectiles/guns/shotguns.dm index 8903be95db95..c5fe94773ed4 100644 --- a/code/modules/projectiles/guns/shotguns.dm +++ b/code/modules/projectiles/guns/shotguns.dm @@ -327,6 +327,7 @@ can cause issues with ammo types getting mixed up during the burst. flags_gun_features = GUN_CAN_POINTBLANK|GUN_INTERNAL_MAG auto_retrieval_slot = WEAR_J_STORE start_automatic = TRUE + autofire_slow_mult = 1 /obj/item/weapon/gun/shotgun/combat/marsoc/Initialize(mapload, spawn_empty) . = ..() diff --git a/code/modules/projectiles/guns/smartgun.dm b/code/modules/projectiles/guns/smartgun.dm index 859f99b17908..c29c46030318 100644 --- a/code/modules/projectiles/guns/smartgun.dm +++ b/code/modules/projectiles/guns/smartgun.dm @@ -65,6 +65,7 @@ auto_retrieval_slot = WEAR_J_STORE start_semiauto = FALSE start_automatic = TRUE + autofire_slow_mult = 1 /obj/item/weapon/gun/smartgun/Initialize(mapload, ...) diff --git a/code/modules/projectiles/guns/smgs.dm b/code/modules/projectiles/guns/smgs.dm index 699f05ed318c..efe7eb5395f4 100644 --- a/code/modules/projectiles/guns/smgs.dm +++ b/code/modules/projectiles/guns/smgs.dm @@ -20,6 +20,7 @@ flags_gun_features = GUN_AUTO_EJECTOR|GUN_CAN_POINTBLANK gun_category = GUN_CATEGORY_SMG + start_automatic = TRUE /obj/item/weapon/gun/smg/Initialize(mapload, spawn_empty) . = ..() @@ -32,6 +33,7 @@ /obj/item/weapon/gun/smg/set_gun_config_values() ..() movement_onehanded_acc_penalty_mult = 4 + fa_max_scatter = SCATTER_AMOUNT_TIER_5 //------------------------------------------------------- //M39 SMG @@ -69,6 +71,7 @@ flags_gun_features = GUN_AUTO_EJECTOR|GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER starting_attachment_types = list(/obj/item/attachable/stock/smg/collapsible) map_specific_decoration = TRUE + start_automatic = TRUE /obj/item/weapon/gun/smg/m39/set_gun_attachment_offsets() attachable_offset = list("muzzle_x" = 30, "muzzle_y" = 20,"rail_x" = 14, "rail_y" = 22, "under_x" = 21, "under_y" = 16, "stock_x" = 24, "stock_y" = 15) @@ -85,6 +88,7 @@ scatter_unwielded = SCATTER_AMOUNT_TIER_4 damage_mult = BASE_BULLET_DAMAGE_MULT recoil_unwielded = RECOIL_AMOUNT_TIER_5 + fa_max_scatter = SCATTER_AMOUNT_TIER_10 + 0.5 /obj/item/weapon/gun/smg/m39/training @@ -270,6 +274,8 @@ scatter_unwielded = SCATTER_AMOUNT_TIER_4 damage_mult = BASE_BULLET_DAMAGE_MULT recoil_unwielded = RECOIL_AMOUNT_TIER_5 + fa_max_scatter = SCATTER_AMOUNT_TIER_9 + fa_scatter_peak = 1 // Seems a bit funny, but it works pretty well in the end /obj/item/weapon/gun/smg/ppsh/with_drum_mag current_mag = /obj/item/ammo_magazine/smg/ppsh/extended @@ -567,6 +573,7 @@ flags_gun_features = GUN_AUTO_EJECTOR|GUN_CAN_POINTBLANK gun_category = GUN_CATEGORY_SMG civilian_usable_override = TRUE + start_automatic = FALSE var/nailing_speed = 2 SECONDS //Time to apply a sheet for patching. Also haha name. Try to keep sync with soundbyte duration var/repair_sound = 'sound/weapons/nailgun_repair_long.ogg'