Skip to content

Commit

Permalink
automatic guns real????
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoe2013 committed Jul 26, 2023
1 parent dd643a8 commit 4db773c
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion code/__DEFINES/conflict.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions code/datums/components/autofire/autofire.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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()
4 changes: 3 additions & 1 deletion code/modules/projectiles/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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


/**
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions code/modules/projectiles/gun_attachables.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]."))
Expand Down
2 changes: 2 additions & 0 deletions code/modules/projectiles/guns/energy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
..()
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions code/modules/projectiles/guns/flamer/flamer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
. = ..()
Expand Down
2 changes: 2 additions & 0 deletions code/modules/projectiles/guns/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
. = ..()
Expand Down Expand Up @@ -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.


Expand Down
1 change: 1 addition & 0 deletions code/modules/projectiles/guns/pistols.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 12 additions & 2 deletions code/modules/projectiles/guns/rifles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
. = ..()
Expand All @@ -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()
..()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
. = ..()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -719,6 +727,7 @@
)

flags_gun_features = GUN_AUTO_EJECTOR|GUN_CAN_POINTBLANK
start_automatic = TRUE



Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions code/modules/projectiles/guns/shotguns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
. = ..()
Expand Down
1 change: 1 addition & 0 deletions code/modules/projectiles/guns/smartgun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...)
Expand Down
7 changes: 7 additions & 0 deletions code/modules/projectiles/guns/smgs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
. = ..()
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'

Expand Down

0 comments on commit 4db773c

Please sign in to comment.