diff --git a/code/__DEFINES/autofire.dm b/code/__DEFINES/autofire.dm new file mode 100644 index 000000000000..934cdcd7dc79 --- /dev/null +++ b/code/__DEFINES/autofire.dm @@ -0,0 +1,4 @@ +// Controls how many buckets should be kept, each representing a tick. Max is ten seconds, to have better perf. +#define AUTOFIRE_BUCKET_LEN (world.fps * 10) +/// Helper for getting the correct bucket +#define AUTOFIRE_BUCKET_POS(next_fire) (((round((next_fire - SSautomatedfire.head_offset) / world.tick_lag) + 1) % AUTOFIRE_BUCKET_LEN) || AUTOFIRE_BUCKET_LEN) diff --git a/code/__DEFINES/conflict.dm b/code/__DEFINES/conflict.dm index 141d69c69b11..a33aaca153ee 100644 --- a/code/__DEFINES/conflict.dm +++ b/code/__DEFINES/conflict.dm @@ -54,30 +54,24 @@ #define GUN_TRIGGER_SAFETY (1<<1) #define GUN_UNUSUAL_DESIGN (1<<2) #define GUN_SILENCED (1<<3) -#define GUN_AUTOMATIC (1<<4) ///If checking for ammo with current.mag you have to check it against numerical values, as booleans will not trigger. -#define GUN_INTERNAL_MAG (1<<5) -#define GUN_AUTO_EJECTOR (1<<6) -#define GUN_AMMO_COUNTER (1<<7) -#define GUN_BURST_ON (1<<8) -#define GUN_BURST_FIRING (1<<9) -#define GUN_FLASHLIGHT_ON (1<<10) -#define GUN_WY_RESTRICTED (1<<11) -#define GUN_SPECIALIST (1<<12) -#define GUN_WIELDED_FIRING_ONLY (1<<13) -#define GUN_HAS_FULL_AUTO (1<<14) -#define GUN_FULL_AUTO_ON (1<<15) +#define GUN_INTERNAL_MAG (1<<4) +#define GUN_AUTO_EJECTOR (1<<5) +#define GUN_AMMO_COUNTER (1<<6) +#define GUN_BURST_FIRING (1<<7) +#define GUN_FLASHLIGHT_ON (1<<8) +#define GUN_WY_RESTRICTED (1<<9) +#define GUN_SPECIALIST (1<<10) +#define GUN_WIELDED_FIRING_ONLY (1<<11) /// removes unwielded accuracy and scatter penalties (not recoil) -#define GUN_ONE_HAND_WIELDED (1<<16) -#define GUN_ANTIQUE (1<<17) +#define GUN_ONE_HAND_WIELDED (1<<12) +#define GUN_ANTIQUE (1<<13) /// Whether the gun has been fired by its current user (reset upon `dropped()`) -#define GUN_RECOIL_BUILDUP (1<<18) +#define GUN_RECOIL_BUILDUP (1<<14) /// support weapon, bipod will grant IFF -#define GUN_SUPPORT_PLATFORM (1<<19) -#define GUN_BURST_ONLY (1<<20) -#define GUN_FULL_AUTO_ONLY (1<<21) +#define GUN_SUPPORT_PLATFORM (1<<15) /// No gun description, only base desc -#define GUN_NO_DESCRIPTION (1<<22) +#define GUN_NO_DESCRIPTION (1<<16) // NOTE: Don't add flags past 1<<23, it'll break things due to BYOND limitations. You can usually use a Component instead. #define USES_STREAKS (1<<0) diff --git a/code/__DEFINES/dcs/signals/atom/mob/signals_mob.dm b/code/__DEFINES/dcs/signals/atom/mob/signals_mob.dm index 347623798b74..323e0ee6966c 100644 --- a/code/__DEFINES/dcs/signals/atom/mob/signals_mob.dm +++ b/code/__DEFINES/dcs/signals/atom/mob/signals_mob.dm @@ -110,3 +110,9 @@ #define COMSIG_MOB_STAT_SET_DEAD "mob_stat_set_dead" #define COMSIG_GHOST_MOVED "ghost_moved" + +#define COMSIG_MOB_MOUSEDOWN "mob_mousedown" //from /client/MouseDown(): (atom/object, turf/location, control, params) +#define COMSIG_MOB_MOUSEUP "mob_mouseup" //from /client/MouseUp(): (atom/object, turf/location, control, params) +#define COMSIG_MOB_MOUSEDRAG "mob_mousedrag" //from /client/MouseDrag(): (atom/src_object, atom/over_object, turf/src_location, turf/over_location, src_control, over_control, params) + #define COMSIG_MOB_CLICK_CANCELED (1<<0) + #define COMSIG_MOB_CLICK_HANDLED (1<<1) diff --git a/code/__DEFINES/dcs/signals/atom/signals_item.dm b/code/__DEFINES/dcs/signals/atom/signals_item.dm index 9c2f3b92ba05..138e88d21746 100644 --- a/code/__DEFINES/dcs/signals/atom/signals_item.dm +++ b/code/__DEFINES/dcs/signals/atom/signals_item.dm @@ -38,3 +38,19 @@ #define COMSIG_ITEM_ZOOM "item_zoom" /// from /obj/item/proc/unzoom() : (mob/user) #define COMSIG_ITEM_UNZOOM "item_unzoom" + +//Signals for automatic fire at component +#define COMSIG_AUTOMATIC_SHOOTER_START_SHOOTING_AT "start_shooting_at" +#define COMSIG_AUTOMATIC_SHOOTER_STOP_SHOOTING_AT "stop_shooting_at" +#define COMSIG_AUTOMATIC_SHOOTER_SHOOT "shoot" + +//Signals for gun auto fire component +#define COMSIG_GET_BURST_FIRE "get_burst_fire" + #define BURST_FIRING (1<<0) + +#define COMSIG_GUN_FIRE "gun_fire" +#define COMSIG_GUN_STOP_FIRE "gun_stop_fire" +#define COMSIG_GUN_FIRE_MODE_TOGGLE "gun_fire_mode_toggle" +#define COMSIG_GUN_AUTOFIREDELAY_MODIFIED "gun_autofiredelay_modified" +#define COMSIG_GUN_BURST_SHOTS_TO_FIRE_MODIFIED "gun_burst_shots_to_fire_modified" +#define COMSIG_GUN_BURST_SHOT_DELAY_MODIFIED "gun_burst_shot_delay_modified" diff --git a/code/__DEFINES/guns.dm b/code/__DEFINES/guns.dm index a89d98805e73..b29f7c7439f2 100644 --- a/code/__DEFINES/guns.dm +++ b/code/__DEFINES/guns.dm @@ -37,3 +37,11 @@ #define REVOLVER_TIP_COLOR_INCENDIARY AMMO_BAND_COLOR_INCENDIARY #define REVOLVER_TIP_COLOR_PENETRATING AMMO_BAND_COLOR_PENETRATING #define REVOLVER_TIP_COLOR_TOXIN AMMO_BAND_COLOR_TOXIN + +#define GUN_FIREMODE_SEMIAUTO "semi-auto fire mode" +#define GUN_FIREMODE_BURSTFIRE "burst-fire mode" +#define GUN_FIREMODE_AUTOMATIC "automatic fire mode" + +//autofire component fire callback return flags +#define AUTOFIRE_CONTINUE (1<<0) +#define AUTOFIRE_SUCCESS (1<<1) diff --git a/code/__DEFINES/subsystems.dm b/code/__DEFINES/subsystems.dm index 662bcb458c55..3a25d865fb60 100644 --- a/code/__DEFINES/subsystems.dm +++ b/code/__DEFINES/subsystems.dm @@ -173,6 +173,7 @@ #define SS_PRIORITY_INPUT 1000 #define SS_PRIORITY_TIMER 700 +#define SS_PRIORITY_AUTOFIRE 450 #define SS_PRIORITY_SOUND 250 #define SS_PRIORITY_TICKER 200 #define SS_PRIORITY_NIGHTMARE 180 diff --git a/code/_globalvars/bitfields.dm b/code/_globalvars/bitfields.dm index 121d1e305e43..f2213b8efffe 100644 --- a/code/_globalvars/bitfields.dm +++ b/code/_globalvars/bitfields.dm @@ -109,24 +109,18 @@ DEFINE_BITFIELD(flags_gun_features, list( "GUN_TRIGGER_SAFETY" = GUN_TRIGGER_SAFETY, "GUN_UNUSUAL_DESIGN" = GUN_UNUSUAL_DESIGN, "GUN_SILENCED" = GUN_SILENCED, - "GUN_AUTOMATIC" = GUN_AUTOMATIC, "GUN_INTERNAL_MAG" = GUN_INTERNAL_MAG, "GUN_AUTO_EJECTOR" = GUN_AUTO_EJECTOR, "GUN_AMMO_COUNTER" = GUN_AMMO_COUNTER, - "GUN_BURST_ON" = GUN_BURST_ON, "GUN_BURST_FIRING" = GUN_BURST_FIRING, "GUN_FLASHLIGHT_ON" = GUN_FLASHLIGHT_ON, "GUN_WY_RESTRICTED" = GUN_WY_RESTRICTED, "GUN_SPECIALIST" = GUN_SPECIALIST, "GUN_WIELDED_FIRING_ONLY" = GUN_WIELDED_FIRING_ONLY, - "GUN_HAS_FULL_AUTO" = GUN_HAS_FULL_AUTO, - "GUN_FULL_AUTO_ON" = GUN_FULL_AUTO_ON, "GUN_ONE_HAND_WIELDED" = GUN_ONE_HAND_WIELDED, "GUN_ANTIQUE" = GUN_ANTIQUE, "GUN_RECOIL_BUILDUP" = GUN_RECOIL_BUILDUP, "GUN_SUPPORT_PLATFORM" = GUN_SUPPORT_PLATFORM, - "GUN_BURST_ONLY" = GUN_BURST_ONLY, - "GUN_FULL_AUTO_ONLY" = GUN_FULL_AUTO_ONLY, )) DEFINE_BITFIELD(flags_magazine, list( diff --git a/code/_onclick/click_hold.dm b/code/_onclick/click_hold.dm index c68beb52fc9e..f65dd33c2eea 100644 --- a/code/_onclick/click_hold.dm +++ b/code/_onclick/click_hold.dm @@ -30,6 +30,9 @@ mouse_trace_history = null LAZYADD(mouse_trace_history, A) + if(SEND_SIGNAL(mob, COMSIG_MOB_MOUSEDOWN, A, T, skin_ctl, params) & COMSIG_MOB_CLICK_CANCELED) + return + var/list/mods = params2list(params) if(mods["left"]) SEND_SIGNAL(src, COMSIG_CLIENT_LMB_DOWN, A, mods) @@ -62,6 +65,9 @@ params += ";click_catcher=1" holding_click = FALSE + if(SEND_SIGNAL(mob, COMSIG_MOB_MOUSEUP, A, T, skin_ctl, params) & COMSIG_MOB_CLICK_CANCELED) + return + var/list/mods = params2list(params) if(mods["left"]) SEND_SIGNAL(src, COMSIG_CLIENT_LMB_UP, A, params) @@ -75,6 +81,9 @@ if(click_catcher_click) params += ";click_catcher=1" + if(SEND_SIGNAL(mob, COMSIG_MOB_MOUSEDRAG, src_obj, over_obj, src_loc, over_loc, src_ctl, over_ctl, params) & COMSIG_MOB_CLICK_CANCELED) + return + var/list/mods = params2list(params) if(mods["left"]) SEND_SIGNAL(src, COMSIG_CLIENT_LMB_DRAG, src_obj, over_obj, params) diff --git a/code/controllers/subsystem/autofire.dm b/code/controllers/subsystem/autofire.dm new file mode 100644 index 000000000000..3d3abbd2669f --- /dev/null +++ b/code/controllers/subsystem/autofire.dm @@ -0,0 +1,85 @@ +/** + * # Autofire Subsystem + * + * Maintains a timer-like system to handle autofiring. Much of this code is modeled + * after or adapted from TGMC's runechat subsytem. + * + * Note that this has the same structure for storing and queueing shooter component as the timer subsystem does + * for handling timers: the bucket_list is a list of autofire component, each of which are the head + * of a linked list. Any given index in bucket_list could be null, representing an empty bucket. + * + * Doesn't support any event scheduled for more than 100 ticks in the future, as it has no secondary queue by design + */ +SUBSYSTEM_DEF(automatedfire) + name = "Automated fire" + flags = SS_TICKER | SS_NO_INIT + wait = 1 + priority = SS_PRIORITY_AUTOFIRE + + /// world.time of the first entry in the bucket list, effectively the 'start time' of the current buckets + var/head_offset = 0 + /// Index of the first non-empty bucket + var/practical_offset = 1 + ///How many buckets for every frame of world.fps + var/bucket_resolution = 0 + /// How many shooter are in the buckets + var/shooter_count = 0 + /// List of buckets, each bucket holds every shooter that has to shoot this byond tick + var/list/bucket_list = list() + /// Reference to the next shooter before we clean shooter.next + var/datum/component/automatedfire/next_shooter + +/datum/controller/subsystem/automatedfire/PreInit() + bucket_list.len = AUTOFIRE_BUCKET_LEN + head_offset = world.time + bucket_resolution = world.tick_lag + +/datum/controller/subsystem/automatedfire/stat_entry(msg = "ActShooters: [shooter_count]") + return ..() + +/datum/controller/subsystem/automatedfire/fire(resumed = FALSE) + // Check for when we need to loop the buckets, this occurs when + // the head_offset is approaching AUTOFIRE_BUCKET_LEN ticks in the past + if (practical_offset > AUTOFIRE_BUCKET_LEN) + head_offset += TICKS2DS(AUTOFIRE_BUCKET_LEN) + practical_offset = 1 + resumed = FALSE + + // Check for when we have to reset buckets, typically from auto-reset + if ((length(bucket_list) != AUTOFIRE_BUCKET_LEN) || (world.tick_lag != bucket_resolution)) + reset_buckets() + bucket_list = src.bucket_list + resumed = FALSE + + // Store a reference to the 'working' shooter so that we can resume if the MC + // has us stop mid-way through processing + var/static/datum/component/automatedfire/shooter + if (!resumed) + shooter = null + + // Iterate through each bucket starting from the practical offset + while (practical_offset <= AUTOFIRE_BUCKET_LEN && head_offset + ((practical_offset - 1) * world.tick_lag) <= world.time) + if(!shooter) + shooter = bucket_list[practical_offset] + bucket_list[practical_offset] = null + + while (shooter) + next_shooter = shooter.next + INVOKE_ASYNC(shooter, TYPE_PROC_REF(/datum/component/automatedfire, process_shot)) + + SSautomatedfire.shooter_count-- + shooter = next_shooter + if (MC_TICK_CHECK) + return + + // Move to the next bucket + practical_offset++ + +/datum/controller/subsystem/automatedfire/Recover() + bucket_list |= SSautomatedfire.bucket_list + +///In the event of a change of world.tick_lag, we refresh the size of the bucket and the bucket resolution +/datum/controller/subsystem/automatedfire/proc/reset_buckets() + bucket_list.len = AUTOFIRE_BUCKET_LEN + head_offset = world.time + bucket_resolution = world.tick_lag diff --git a/code/datums/components/autofire/_automated_fire.dm b/code/datums/components/autofire/_automated_fire.dm new file mode 100644 index 000000000000..9abd6a152199 --- /dev/null +++ b/code/datums/components/autofire/_automated_fire.dm @@ -0,0 +1,49 @@ +/datum/component/automatedfire + ///The owner of this component + var/atom/shooter + /// Contains the scheduled fire time, used for scheduling EOL + var/next_fire + /// Contains the reference to the next component in the bucket, used by autofire subsystem + var/datum/component/automatedfire/next + /// Contains the reference to the previous component in the bucket, used by autofire subsystem + var/datum/component/automatedfire/prev + + +/// schedule the shooter into the system, inserting it into the next fire queue +/datum/component/automatedfire/proc/schedule_shot() + //We move to another bucket, so we clean the reference from the former linked list + next = null + prev = null + var/list/bucket_list = SSautomatedfire.bucket_list + + // Ensure the next_fire time is properly bound to avoid missing a scheduled event + next_fire = max(CEILING(next_fire, world.tick_lag), world.time + world.tick_lag) + + // Get bucket position and a local reference to the datum var, it's faster to access this way + var/bucket_pos = AUTOFIRE_BUCKET_POS(next_fire) + + // Get the bucket head for that bucket, increment the bucket count + var/datum/component/automatedfire/bucket_head = bucket_list[bucket_pos] + SSautomatedfire.shooter_count++ + + // If there is no existing head of this bucket, we can set this shooter to be that head + if (!bucket_head) + bucket_list[bucket_pos] = src + return + + // Otherwise it's a simple insertion into the double-linked list + if (bucket_head.next) + next = bucket_head.next + next.prev = src + + bucket_head.next = src + prev = bucket_head + + //Something went wrong, probably a lag spike or something. To prevent infinite loops, we reschedule it to a another next fire + if(prev == src) + next_fire += 1 + schedule_shot() + +///Handle the firing of the autofire component +/datum/component/automatedfire/proc/process_shot() + return diff --git a/code/datums/components/autofire/autofire.dm b/code/datums/components/autofire/autofire.dm new file mode 100644 index 000000000000..bd83895da4d1 --- /dev/null +++ b/code/datums/components/autofire/autofire.dm @@ -0,0 +1,131 @@ +/datum/component/automatedfire/autofire + ///The current fire mode of the shooter + var/fire_mode + ///Delay between two shots when in full auto + var/auto_fire_shot_delay + ///Delay between two burst shots + var/burstfire_shot_delay + ///How many bullets are fired in burst mode + var/burst_shots_to_fire + ///Count the shots fired when bursting + var/shots_fired = 0 + ///If the shooter is currently shooting + var/shooting = FALSE + ///If TRUE, the shooter will reset its references at the end of the burst + var/have_to_reset_at_burst_end = FALSE + ///If we are in a burst + var/bursting = FALSE + ///Callback to set bursting mode on the parent + var/datum/callback/callback_bursting + ///Callback to ask the parent to reset its firing vars + var/datum/callback/callback_reset_fire + ///Callback to ask the parent to fire + var/datum/callback/callback_fire + +/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) + . = ..() + + RegisterSignal(parent, COMSIG_GUN_FIRE_MODE_TOGGLE, PROC_REF(modify_fire_mode)) + RegisterSignal(parent, COMSIG_GUN_AUTOFIREDELAY_MODIFIED, PROC_REF(modify_fire_shot_delay)) + RegisterSignal(parent, COMSIG_GUN_BURST_SHOTS_TO_FIRE_MODIFIED, PROC_REF(modify_burst_shots_to_fire)) + RegisterSignal(parent, COMSIG_GUN_BURST_SHOT_DELAY_MODIFIED, PROC_REF(modify_burstfire_shot_delay)) + RegisterSignal(parent, COMSIG_GUN_FIRE, PROC_REF(initiate_shot)) + RegisterSignal(parent, COMSIG_GUN_STOP_FIRE, PROC_REF(stop_firing)) + + auto_fire_shot_delay = _auto_fire_shot_delay + burstfire_shot_delay = _burstfire_shot_delay + burst_shots_to_fire = _burst_shots_to_fire + fire_mode = _fire_mode + callback_bursting = _callback_bursting + callback_reset_fire = _callback_reset_fire + callback_fire = _callback_fire + +/datum/component/automatedfire/autofire/Destroy(force, silent) + QDEL_NULL(callback_fire) + QDEL_NULL(callback_reset_fire) + QDEL_NULL(callback_bursting) + return ..() + +///Setter for fire mode +/datum/component/automatedfire/autofire/proc/modify_fire_mode(datum/source, _fire_mode) + SIGNAL_HANDLER + fire_mode = _fire_mode + +///Setter for auto fire shot delay +/datum/component/automatedfire/autofire/proc/modify_fire_shot_delay(datum/source, _auto_fire_shot_delay) + SIGNAL_HANDLER + auto_fire_shot_delay = _auto_fire_shot_delay + +///Setter for the number of shot in a burst +/datum/component/automatedfire/autofire/proc/modify_burst_shots_to_fire(datum/source, _burst_shots_to_fire) + SIGNAL_HANDLER + burst_shots_to_fire = _burst_shots_to_fire + +///Setter for burst shot delay +/datum/component/automatedfire/autofire/proc/modify_burstfire_shot_delay(datum/source, _burstfire_shot_delay) + SIGNAL_HANDLER + burstfire_shot_delay = _burstfire_shot_delay + +///Insert the component in the bucket system if it was not in already +/datum/component/automatedfire/autofire/proc/initiate_shot() + SIGNAL_HANDLER + if(shooting)//if we are already shooting, it means the shooter is still on cooldown + if(bursting) //something went wrong due to lag + hard_reset() + return + shooting = TRUE + process_shot() + +///Remove the component from the bucket system if it was in +/datum/component/automatedfire/autofire/proc/stop_firing() + SIGNAL_HANDLER + if(!shooting) + return + ///We are burst firing, we can't clean the state now. We will do it when the burst is over + if(bursting) + have_to_reset_at_burst_end = TRUE + return + shooting = FALSE + shots_fired = 0 + +///Hard reset the autofire, happens when the shooter fall/is thrown, at the end of a burst or when it runs out of ammunition +/datum/component/automatedfire/autofire/proc/hard_reset() + callback_reset_fire.Invoke() //resets the gun + shots_fired = 0 + have_to_reset_at_burst_end = FALSE + if(bursting) + bursting = FALSE + callback_bursting.Invoke(FALSE) + shooting = FALSE + + +///Ask the shooter to fire and schedule the next shot if need +/datum/component/automatedfire/autofire/process_shot() + if(!shooting) + return + if(next_fire > world.time)//This mean duplication somewhere, we abort now + return + if(!(callback_fire.Invoke() & AUTOFIRE_CONTINUE))//reset fire if we want to stop + hard_reset() + return + switch(fire_mode) + if(GUN_FIREMODE_BURSTFIRE) + shots_fired++ + if(shots_fired == burst_shots_to_fire) + callback_bursting.Invoke(FALSE) + bursting = FALSE + stop_firing() + if(have_to_reset_at_burst_end)//We failed to reset because we were bursting, we do it now + callback_reset_fire.Invoke() + have_to_reset_at_burst_end = FALSE + return + callback_bursting.Invoke(TRUE) + bursting = TRUE + next_fire = world.time + burstfire_shot_delay + if(GUN_FIREMODE_AUTOMATIC) + var/obj/item/weapon/gun/parent_gun = parent + parent_gun.fa_firing = TRUE + next_fire = world.time + auto_fire_shot_delay + if(GUN_FIREMODE_SEMIAUTO) + return + schedule_shot() diff --git a/code/modules/cm_tech/implements/medical_czsp.dm b/code/modules/cm_tech/implements/medical_czsp.dm index ccfd59ce7cbc..e0b00ebf5afd 100644 --- a/code/modules/cm_tech/implements/medical_czsp.dm +++ b/code/modules/cm_tech/implements/medical_czsp.dm @@ -186,21 +186,21 @@ /obj/item/weapon/gun/pill/Fire(atom/target, mob/living/user, params, reflex, dual_wield) if(!able_to_fire(user)) - return + return NONE if(!current_mag.current_rounds) click_empty(user) - return + return NONE if(!istype(current_mag, /obj/item/ammo_magazine/internal/pillgun)) - return + return NONE var/obj/item/ammo_magazine/internal/pillgun/internal_mag = current_mag var/obj/item/reagent_container/pill/pill_to_use = LAZYACCESS(internal_mag.pills, 1) if(QDELETED(pill_to_use)) click_empty(user) - return + return NONE var/obj/item/projectile/pill/P = new /obj/item/projectile/pill(src, user, src) P.generate_bullet(GLOB.ammo_list[/datum/ammo/pill], 0, 0) @@ -211,6 +211,7 @@ playsound(user.loc, 'sound/items/syringeproj.ogg', 50, 1) P.fire_at(target, user, src) + return AUTOFIRE_CONTINUE /datum/ammo/pill name = "syringe" diff --git a/code/modules/projectiles/full_auto.dm b/code/modules/projectiles/full_auto.dm deleted file mode 100644 index ad3e037b68e6..000000000000 --- a/code/modules/projectiles/full_auto.dm +++ /dev/null @@ -1,129 +0,0 @@ -/obj/item/weapon/gun/proc/full_auto_start(client/source, atom/A, params) - SIGNAL_HANDLER - if(!ismob(loc) || !A) - return - var/mob/user = loc - - // No FA with mods - if(params["shift"] || params["ctrl"] || params["alt"]) - return - - // No shooting the 4th wall - if(istype(A, /atom/movable/screen)) - return - - // No FA on attachables - if(active_attachable) - return - - if(user.get_active_hand() != src) - return - - if(user.throw_mode) - return - - // Don't open fire on adjacent targets. Let normal attack code handle this - if(A.Adjacent(user) && user.a_intent != INTENT_HARM) - return - - if(user.client?.prefs?.toggle_prefs & TOGGLE_HELP_INTENT_SAFETY && (user.a_intent == INTENT_HELP)) - if(world.time % 3) // Limits how often this message pops up, saw this somewhere else and thought it was clever - to_chat(user, SPAN_NOTICE("You consider shooting at [A], but do not follow through.")) - return - - fa_firing = TRUE - fa_shots = 0 - fa_target = A - fa_params = params - - // Ward off spamclickin fellas - if(world.time < last_fired + fa_delay) - if(world.time % 3) // Limits how often this message pops up, saw this somewhere else and it's fucking stupid - to_chat(user, SPAN_WARNING("[src] is not ready to fire again!")) - return - - // Kick off the full-auto - INVOKE_ASYNC(src, PROC_REF(repeat_fire), user) - -/obj/item/weapon/gun/proc/full_auto_stop(client/source, atom/A, params) - SIGNAL_HANDLER - fa_target = null - fa_params = null - -/obj/item/weapon/gun/proc/full_auto_new_target(client/source, atom/start, atom/hovered, params) - SIGNAL_HANDLER - if(!ismob(loc)) - return - var/mob/user = loc - - if(istype(hovered, /atom/movable/screen)) - return - - if(get_turf(hovered) == get_turf(user)) - return - - fa_target = hovered - fa_params = params2list(params) - -/obj/item/weapon/gun/proc/repeat_fire(mob/user) - if(!fa_target) - return - - // fun is ended - if(active_attachable) - return - - // fun's over - if(!in_chamber && !current_mag) - click_empty(user) - return - - // fun's also over - if(!user.canmove || user.stat || user.is_mob_restrained() || !user.loc || !isturf(user.loc)) - return - - // you abandoned the f u n - if(user.get_active_hand() != src || loc != user) - return - - if(user.throw_mode) - return - - user.face_atom(fa_target) - Fire(fa_target, user, fa_params) - - addtimer(CALLBACK(src, PROC_REF(repeat_fire), user), fa_delay) - -// Make sure we're not trying to start full auto when the gun isn't even held by anyone -/obj/item/weapon/gun/dropped(mob/user) - ..() - - if(!user.client) - return - - UnregisterSignal(user.client, list( - COMSIG_CLIENT_LMB_DOWN, - COMSIG_CLIENT_LMB_UP, - COMSIG_CLIENT_LMB_DRAG, - )) - -// Also make sure it's registered when held in any hand and full-auto is on -/obj/item/weapon/gun/equipped(mob/user, slot) - ..() - - if(!user.client) - return - - // If it was equipped to anything but the hands, make sure we're not registered - if(slot != WEAR_R_HAND && slot != WEAR_L_HAND) - UnregisterSignal(user.client, list( - COMSIG_CLIENT_LMB_DOWN, - COMSIG_CLIENT_LMB_UP, - COMSIG_CLIENT_LMB_DRAG, - )) - return - - if(flags_gun_features & GUN_FULL_AUTO_ON) - RegisterSignal(user.client, COMSIG_CLIENT_LMB_DOWN, PROC_REF(full_auto_start)) - RegisterSignal(user.client, COMSIG_CLIENT_LMB_UP, PROC_REF(full_auto_stop)) - RegisterSignal(user.client, COMSIG_CLIENT_LMB_DRAG, PROC_REF(full_auto_new_target)) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 263f5b07cca4..b11cc1d30997 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -132,14 +132,12 @@ var/fa_max_scatter = 5 ///The delay when firing full-auto var/fa_delay = 2.5 - ///The atom we're shooting at while full-autoing - var/atom/fa_target = null ///Click parameters to use when firing full-auto var/fa_params = null //Targeting. ///List of who yer targeting. - var/tmp/list/mob/living/target + //var/tmp/list/mob/living/target ///Used to fire faster at more than one person. var/tmp/mob/living/last_moved_mob var/tmp/lock_time = -100 @@ -223,6 +221,17 @@ // Set to TRUE or FALSE, it overrides the is_civilian_usable check with its value. Does nothing if null. var/civilian_usable_override = null + ///Current selected firemode of the gun. + var/gun_firemode = GUN_FIREMODE_SEMIAUTO + ///List of allowed firemodes. + var/list/gun_firemode_list = list(GUN_FIREMODE_SEMIAUTO) + ///How many bullets the gun fired while bursting/auto firing + var/shots_fired = 0 + /// Currently selected target to fire at + var/atom/target + /// Current user (holding) of the gun + var/mob/gun_user + /** * An assoc list where the keys are fire delay group string defines @@ -253,7 +262,8 @@ else current_mag = new current_mag(src, spawn_empty? 1:0) replace_ammo(null, current_mag) - else ammo = GLOB.ammo_list[ammo] //If they don't have a mag, they fire off their own thing. + else + ammo = GLOB.ammo_list[ammo] //If they don't have a mag, they fire off their own thing. set_gun_attachment_offsets() set_gun_config_values() @@ -265,6 +275,8 @@ if(auto_retrieval_slot) 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, fa_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))) //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 @@ -288,8 +300,8 @@ attachments = null attachable_overlays = null QDEL_NULL(active_attachable) - fa_target = null GLOB.gun_list -= src + set_gun_user(null) . = ..() /* @@ -471,6 +483,10 @@ for(var/obj/O in contents) O.emp_act(severity) +/* +Note: pickup and dropped on weapons must have both the ..() to update zoom AND twohanded, +As sniper rifles have both and weapon mods can change them as well. ..() deals with zoom only. +*/ /obj/item/weapon/gun/equipped(mob/user, slot) if(flags_item & NODROP) return @@ -480,8 +496,31 @@ pull_time += 3 guaranteed_delay_time = world.time + WEAPON_GUARANTEED_DELAY + var/delay_left = (last_fired + fire_delay + additional_fire_group_delay) - world.time + if(fire_delay_group && delay_left > 0) + for(var/group in fire_delay_group) + LAZYSET(user.fire_delay_next_fire, group, world.time + delay_left) + + if(slot in list(WEAR_L_HAND, WEAR_R_HAND)) + set_gun_user(user) + else + set_gun_user(null) + return ..() +/obj/item/weapon/gun/dropped(mob/user) + . = ..() + + disconnect_light_from_mob(user) + + var/delay_left = (last_fired + fire_delay + additional_fire_group_delay) - world.time + if(fire_delay_group && delay_left > 0) + for(var/group in fire_delay_group) + LAZYSET(user.fire_delay_next_fire, group, world.time + delay_left) + + unwield(user) + set_gun_user(null) + /obj/item/weapon/gun/update_icon() if(overlays) overlays.Cut() @@ -675,8 +714,8 @@ data["penetration_max"] = ARMOR_PENETRATION_TIER_10 data["punch_max"] = 5 data["glob_armourbreak"] = GLOB.xeno_general.armor_ignore_integrity - data["automatic"] = flags_gun_features & GUN_HAS_FULL_AUTO - data["auto_only"] = flags_gun_features & GUN_FULL_AUTO_ONLY + data["automatic"] = (GUN_FIREMODE_AUTOMATIC in gun_firemode_list) + data["auto_only"] = ((length(gun_firemode_list) == 1) && (GUN_FIREMODE_AUTOMATIC in gun_firemode_list)) return data @@ -724,14 +763,14 @@ else wield_time -= 2*user.skills.get_skill_level(SKILL_FIREARMS) - if(flags_gun_features & GUN_FULL_AUTO_ON) - ADD_TRAIT(user, TRAIT_OVERRIDE_CLICKDRAG, TRAIT_SOURCE_WEAPON) + //if(flags_gun_features & GUN_FULL_AUTO_ON) //Zonenote: look into + // ADD_TRAIT(user, TRAIT_OVERRIDE_CLICKDRAG, TRAIT_SOURCE_WEAPON) return 1 /obj/item/weapon/gun/unwield(mob/user) . = ..() - REMOVE_TRAIT(user, TRAIT_OVERRIDE_CLICKDRAG, TRAIT_SOURCE_WEAPON) + //REMOVE_TRAIT(user, TRAIT_OVERRIDE_CLICKDRAG, TRAIT_SOURCE_WEAPON) if(.) slowdown = initial(slowdown) @@ -915,6 +954,9 @@ User can be passed as null, (a gun reloading itself for instance), so we need to to_chat(user, SPAN_HIGHDANGER("Help intent safety is on! Switch to another intent to fire your weapon.")) click_empty(user) return FALSE + else if((gun_firemode == GUN_FIREMODE_BURSTFIRE) && burst_amount > 1) + SEND_SIGNAL(src, COMSIG_GUN_FIRE) + return TRUE else Fire(A,user,params) //Otherwise, fire normally. return TRUE @@ -1056,16 +1098,16 @@ and you're good to go. // \\ //---------------------------------------------------------- -/obj/item/weapon/gun/proc/Fire(atom/target, mob/living/user, params, reflex = 0, dual_wield) - set waitfor = 0 +/obj/item/weapon/gun/proc/Fire(atom/target, mob/living/user, params, reflex = FALSE, dual_wield) + set waitfor = FALSE if(!able_to_fire(user) || !target) - return + return NONE var/turf/curloc = get_turf(user) //In case the target or we are expired. var/turf/targloc = get_turf(target) if(!targloc || !curloc) - return //Something has gone wrong... + return NONE //Something has gone wrong... var/atom/original_target = target //This is for burst mode, in case the target changes per scatter chance in between fired bullets. /* @@ -1087,14 +1129,14 @@ and you're good to go. else active_attachable.fire_attachment(target, src, user) //Fire it. active_attachable.last_fired = world.time - return + return NONE //If there's more to the attachment, it will be processed farther down, through in_chamber and regular bullet act. /* This is where burst is established for the proceeding section. Which just means the proc loops around that many times. If burst = 1, you must null it if you ever RETURN during the for() cycle. If for whatever reason burst is left on while the gun is not firing, it will break a lot of stuff. BREAK is fine, as it will null it. */ - else if((flags_gun_features & GUN_BURST_ON) && burst_amount > 1) + else if((gun_firemode == GUN_FIREMODE_BURSTFIRE) && burst_amount > 1) //Zonenote: move to component? bullets_to_fire = burst_amount flags_gun_features |= GUN_BURST_FIRING if(PB_burst_bullets_fired) //Has a burst been carried over from a PB? @@ -1115,7 +1157,7 @@ and you're good to go. akimbo.Fire(target,user,params, 0, TRUE) var/bullets_fired - for(bullets_fired = 1 to bullets_to_fire) + for(bullets_fired = 1 to 1) if(loc != user || (flags_gun_features & GUN_WIELDED_FIRING_ONLY && !(flags_item & WIELDED))) break //If you drop it while bursting, for example. @@ -1176,7 +1218,7 @@ and you're good to go. flags_gun_features &= ~GUN_BURST_FIRING in_chamber = null click_empty(user) - return + return NONE if(targloc != curloc) simulate_recoil(dual_wield, user, target) @@ -1195,8 +1237,7 @@ and you're good to go. SEND_SIGNAL(user, COMSIG_MOB_FIRED_GUN, src) . = TRUE - if(flags_gun_features & GUN_FULL_AUTO_ON) - fa_shots++ + shots_fired++ else // This happens in very rare circumstances when you're moving a lot while burst firing, so I'm going to toss it up to guns jamming. clear_jam(projectile_to_fire,user) @@ -1211,12 +1252,13 @@ and you're good to go. click_empty(user) break //Nothing else to do here, time to cancel out. - if(bullets_fired < bullets_to_fire) // We still have some bullets to fire. - extra_delay = fire_delay * 0.5 - sleep(burst_delay) + //if(bullets_fired < bullets_to_fire) // We still have some bullets to fire. + // extra_delay = fire_delay * 0.5 + // sleep(burst_delay) flags_gun_features &= ~GUN_BURST_FIRING // We always want to turn off bursting when we're done, mainly for when we break early mid-burstfire. display_ammo(user) + return AUTOFIRE_CONTINUE #define EXECUTION_CHECK (attacked_mob.stat == UNCONSCIOUS || attacked_mob.is_mob_restrained()) && ((user.a_intent == INTENT_GRAB)||(user.a_intent == INTENT_DISARM)) @@ -1335,7 +1377,7 @@ and you're good to go. var/bullets_to_fire = 1 - if(!check_for_attachment_fire && (flags_gun_features & GUN_BURST_ON) && burst_amount > 1) + if(!check_for_attachment_fire && (gun_firemode == GUN_FIREMODE_BURSTFIRE) && burst_amount > 1) bullets_to_fire = burst_amount flags_gun_features |= GUN_BURST_FIRING @@ -1470,7 +1512,7 @@ not all weapons use normal magazines etc. load_into_chamber() itself is designed */ if(flags_gun_features & GUN_BURST_FIRING) - return + return TRUE //ZONENOTE if(world.time < guaranteed_delay_time) return if((world.time < wield_time || world.time < pull_time) && (delay_style & WEAPON_DELAY_NO_FIRE > 0)) @@ -1626,7 +1668,7 @@ not all weapons use normal magazines etc. load_into_chamber() itself is designed var/fire_angle = Get_Angle(curloc, targloc) var/total_scatter_angle = projectile_to_fire.scatter - if(flags_gun_features & GUN_BURST_ON && bullets_fired > 1)//Much higher scatter on burst. Each additional bullet adds scatter + if((gun_firemode == GUN_FIREMODE_BURSTFIRE) && (bullets_fired > 1))//Much higher scatter on burst. Each additional bullet adds scatter var/bullet_amt_scat = min(bullets_fired-1, SCATTER_AMOUNT_TIER_6)//capped so we don't penalize large bursts too much. if(flags_item & WIELDED) total_scatter_angle += max(0, bullet_amt_scat * burst_scatter_mult) @@ -1635,7 +1677,7 @@ not all weapons use normal magazines etc. load_into_chamber() itself is designed // Full auto fucks your scatter up big time // Note that full auto uses burst scatter multipliers - if(flags_gun_features & GUN_FULL_AUTO_ON) + if(gun_firemode == GUN_FIREMODE_AUTOMATIC) // The longer you fire full-auto, the worse the scatter gets var/bullet_amt_scat = min((fa_shots/fa_scatter_peak) * fa_max_scatter, fa_max_scatter) if(flags_item & WIELDED) @@ -1730,3 +1772,112 @@ not all weapons use normal magazines etc. load_into_chamber() itself is designed xeno.animation_attack_on(src) xeno.visible_message(SPAN_XENOWARNING("\The [xeno] slashes the lights on \the [src]!"), SPAN_XENONOTICE("You slash the lights on \the [src]!")) return XENO_ATTACK_ACTION + +/// Setter proc to toggle burst firing +/obj/item/weapon/gun/proc/set_bursting() + flags_gun_features ^= GUN_BURST_FIRING + +///Clean all references +/obj/item/weapon/gun/proc/reset_fire() + shots_fired = 0//Let's clean everything + set_target(null) + fa_firing = FALSE + //gun_user?.client?.mouse_pointer_icon = initial(gun_user.client.mouse_pointer_icon) + +/// setter for fire_delay +/obj/item/weapon/gun/proc/modify_fire_delay(value) + fire_delay += value + SEND_SIGNAL(src, COMSIG_GUN_AUTOFIREDELAY_MODIFIED, fire_delay) + +/// setter for burst_amount +/obj/item/weapon/gun/proc/modify_burst_amount(value, mob/user) + burst_amount += value + SEND_SIGNAL(src, COMSIG_GUN_BURST_SHOTS_TO_FIRE_MODIFIED, burst_amount) + + if(burst_amount < 2) + if(GUN_FIREMODE_BURSTFIRE in gun_firemode_list) + remove_firemode(GUN_FIREMODE_BURSTFIRE, user) + else + if(!(GUN_FIREMODE_BURSTFIRE in gun_firemode_list)) + add_firemode(GUN_FIREMODE_BURSTFIRE, user) + +/// Setter for burst_delay +/obj/item/weapon/gun/proc/modify_burst_delay(value, mob/user) + burst_delay += value + SEND_SIGNAL(src, COMSIG_GUN_BURST_SHOT_DELAY_MODIFIED, burst_delay) + +///Set the target and take care of hard delete +/obj/item/weapon/gun/proc/set_target(atom/object) + active_attachable?.set_target(object) + if(object == target || object == loc) + return + if(target) + UnregisterSignal(target, COMSIG_PARENT_QDELETING) + target = object + if(target) + RegisterSignal(target, COMSIG_PARENT_QDELETING, PROC_REF(clean_target)) + +///Set the target to its turf, so we keep shooting even when it was qdeled +/obj/item/weapon/gun/proc/clean_target() + SIGNAL_HANDLER + active_attachable?.clean_target() + target = get_turf(target) + +/obj/item/weapon/gun/proc/stop_fire() + SIGNAL_HANDLER + gun_user?.client?.mouse_pointer_icon = initial(gun_user.client.mouse_pointer_icon) + if(flags_gun_features & GUN_BURST_FIRING) + reset_fire() + SEND_SIGNAL(src, COMSIG_GUN_STOP_FIRE) + +/obj/item/weapon/gun/proc/set_gun_user(mob/to_set) + if(to_set == gun_user) + return + if(gun_user) + UnregisterSignal(gun_user, list(COMSIG_MOB_MOUSEUP, COMSIG_MOB_MOUSEDOWN, COMSIG_MOB_MOUSEDRAG)) + + gun_user = to_set + RegisterSignal(gun_user, COMSIG_MOB_MOUSEDOWN, PROC_REF(start_fire)) + RegisterSignal(gun_user, COMSIG_MOB_MOUSEDRAG, PROC_REF(change_target)) + RegisterSignal(gun_user, COMSIG_MOB_MOUSEUP, PROC_REF(stop_fire)) + +///Update the target if you draged your mouse +/obj/item/weapon/gun/proc/change_target(datum/source, atom/src_object, atom/over_object, turf/src_location, turf/over_location, src_control, over_control, params) + SIGNAL_HANDLER + set_target(get_turf_on_clickcatcher(over_object, gun_user, params)) + gun_user?.face_atom(target) + +///Check if the gun can fire and add it to bucket auto_fire system if needed, or just fire the gun if not +/obj/item/weapon/gun/proc/start_fire(datum/source, atom/object, turf/location, control, params, bypass_checks = FALSE) + SIGNAL_HANDLER + + var/list/modifiers = params2list(params) + if(modifiers["shift"] || modifiers["middle"] || modifiers["right"]) + return + + //if(gun_on_cooldown(gun_user)) + // return + if(!bypass_checks) + if(gun_user.hand && !isgun(gun_user.l_hand) || !gun_user.hand && !isgun(gun_user.r_hand)) // If the object in our active hand is not a gun, abort + return + if(gun_user.throw_mode) + return + if(gun_user.Adjacent(object)) //Dealt with by attack code + return + if(QDELETED(object)) + return + set_target(get_turf_on_clickcatcher(object, gun_user, params)) + if(gun_firemode == GUN_FIREMODE_SEMIAUTO) + Fire(object, gun_user, modifiers) + reset_fire() + return + SEND_SIGNAL(src, COMSIG_GUN_FIRE) + +/// Wrapper proc for the autofire subsystem to ensure the important args aren't null +/obj/item/weapon/gun/proc/fire_wrapper(atom/target, mob/living/user, params, reflex = FALSE, dual_wield) + SHOULD_NOT_OVERRIDE(TRUE) + if(!target) + target = src.target + if(!user) + user = src.gun_user + return Fire(target, user, params, reflex, dual_wield) diff --git a/code/modules/projectiles/gun_attachables.dm b/code/modules/projectiles/gun_attachables.dm index 0baf6f527d4b..f39abb0d5674 100644 --- a/code/modules/projectiles/gun_attachables.dm +++ b/code/modules/projectiles/gun_attachables.dm @@ -131,8 +131,7 @@ Defined in conflicts.dm of the #defines folder. G.attachments[slot] = src G.recalculate_attachment_bonuses() - if(G.burst_amount <= 1) - G.flags_gun_features &= ~GUN_BURST_ON //Remove burst if they can no longer use it. + G.setup_firemodes() G.update_force_list() //This updates the gun to use proper force verbs. var/mob/living/living @@ -1926,18 +1925,34 @@ Defined in conflicts.dm of the #defines folder. /// An assoc list in the format list(/datum/element/bullet_trait_to_give = list(...args)) /// that will be given to the projectiles of the attached gun var/list/list/traits_to_give_attached + /// Current target we're firing at + var/mob/target -/obj/item/attachable/attached_gun/New() //Let's make sure if something needs an ammo type, it spawns with one. - ..() +/obj/item/attachable/attached_gun/Initialize(mapload, ...) //Let's make sure if something needs an ammo type, it spawns with one. + . = ..() if(ammo) ammo = GLOB.ammo_list[ammo] /obj/item/attachable/attached_gun/Destroy() ammo = null - . = ..() - + target = null + return ..() +/// setter for target +/obj/item/attachable/attached_gun/proc/set_target(atom/object) + if(object == target) + return + if(target) + UnregisterSignal(target, COMSIG_PARENT_QDELETING) + target = object + if(target) + RegisterSignal(target, COMSIG_PARENT_QDELETING, PROC_REF(clean_target)) + +///Set the target to its turf, so we keep shooting even when it was qdeled +/obj/item/attachable/attached_gun/proc/clean_target() + SIGNAL_HANDLER + target = get_turf(target) /obj/item/attachable/attached_gun/activate_attachment(obj/item/weapon/gun/G, mob/living/user, turn_off) if(G.active_attachable == src) diff --git a/code/modules/projectiles/gun_helpers.dm b/code/modules/projectiles/gun_helpers.dm index d8ea29cd92f8..d8bc7aa84efb 100644 --- a/code/modules/projectiles/gun_helpers.dm +++ b/code/modules/projectiles/gun_helpers.dm @@ -136,29 +136,6 @@ DEFINES in setup.dm, referenced here. else ..() -/* -Note: pickup and dropped on weapons must have both the ..() to update zoom AND twohanded, -As sniper rifles have both and weapon mods can change them as well. ..() deals with zoom only. -*/ -/obj/item/weapon/gun/dropped(mob/user) - . = ..() - - disconnect_light_from_mob(user) - - var/delay_left = (last_fired + fire_delay + additional_fire_group_delay) - world.time - if(fire_delay_group && delay_left > 0) - for(var/group in fire_delay_group) - LAZYSET(user.fire_delay_next_fire, group, world.time + delay_left) - - unwield(user) - -/obj/item/weapon/gun/equipped(mob/user, slot) - . = ..() - - var/delay_left = (last_fired + fire_delay + additional_fire_group_delay) - world.time - if(fire_delay_group && delay_left > 0) - for(var/group in fire_delay_group) - LAZYSET(user.fire_delay_next_fire, group, world.time + delay_left) /// This function disconnects the luminosity from the mob and back to the gun /obj/item/weapon/gun/proc/disconnect_light_from_mob(mob/bearer) @@ -681,7 +658,7 @@ As sniper rifles have both and weapon mods can change them as well. ..() deals w playsound(src, 'sound/handling/attachment_remove.ogg', 15, 1, 4) update_icon() -/obj/item/weapon/gun/proc/toggle_burst(mob/user) +/*/obj/item/weapon/gun/proc/toggle_burst(mob/user) //Burst of 1 doesn't mean anything. The weapon will only fire once regardless. //Just a good safety to have all weapons that can equip a scope with 1 burst_amount. if(burst_amount < 2 && !(flags_gun_features & GUN_HAS_FULL_AUTO)) @@ -741,12 +718,91 @@ As sniper rifles have both and weapon mods can change them as well. ..() deals w flags_gun_features ^= GUN_BURST_ON - to_chat(user, SPAN_NOTICE("[icon2html(src, user)] You [flags_gun_features & GUN_BURST_ON ? "enable" : "disable"] [src]'s burst fire mode.")) + to_chat(user, SPAN_NOTICE("[icon2html(src, user)] You [flags_gun_features & GUN_BURST_ON ? "enable" : "disable"] [src]'s burst fire mode."))*/ + +/obj/item/weapon/gun/proc/do_toggle_firemode(datum/source, datum/keybinding, new_firemode) + SIGNAL_HANDLER + if(flags_gun_features & GUN_BURST_FIRING)//can't toggle mid burst + return + + if(!length(gun_firemode_list)) + CRASH("[src] called do_toggle_firemode() with an empty gun_firemode_list") + + if(length(gun_firemode_list) == 1) + return + + if(new_firemode) + if(!(new_firemode in gun_firemode_list)) + CRASH("[src] called do_toggle_firemode() with [new_firemode] new_firemode, not on gun_firemode_list") + gun_firemode = new_firemode + else + var/mode_index = gun_firemode_list.Find(gun_firemode) + if(++mode_index <= length(gun_firemode_list)) + gun_firemode = gun_firemode_list[mode_index] + else + gun_firemode = gun_firemode_list[1] + + if(ishuman(source)) + to_chat(source, SPAN_NOTICE("[icon2html(src, source)] You switch to [gun_firemode].")) + //playsound(src, 'sound/weapons/guns/interact/selector.ogg', 15, 1) + SEND_SIGNAL(src, COMSIG_GUN_FIRE_MODE_TOGGLE, gun_firemode) + +/obj/item/weapon/gun/proc/add_firemode(added_firemode, mob/user) + gun_firemode_list += added_firemode + + switch(length(gun_firemode_list)) + if(0) + CRASH("add_firemode called with a resulting gun_firemode_list length of [length(gun_firemode_list)].") + if(1) //No need to toggle anything if there's a single firemode. + return + if(2) + /*LAZYADD(actions_types, /datum/action/item_action/firemode) + var/datum/action/new_action = new /datum/action/item_action/firemode(src) + if(user) + var/mob/living/living_user = user + if((src == living_user.l_hand || src == living_user.r_hand) && !CHECK_BITFIELD(flags_item, IS_DEPLOYED)) + new_action.give_action(living_user)*/ + else //The action should already be there by now. + return + +/obj/item/weapon/gun/proc/remove_firemode(removed_firemode, mob/user) + switch(length(gun_firemode_list)) + if(0, 1) + CRASH("remove_firemode called with gun_firemode_list length [length(gun_firemode_list)].") + /*if(2) + LAZYREMOVE(actions_types, /datum/action/item_action/firemode) + var/datum/action/old_action = locate(/datum/action/item_action/firemode) in actions + if(user) + var/mob/living/living_user = user + if((src == living_user.l_hand || src == living_user.r_hand) && !CHECK_BITFIELD(flags_item, IS_DEPLOYED)) + old_action.remove_action(living_user) + qdel(old_action)*/ + + gun_firemode_list -= removed_firemode + + if(gun_firemode == removed_firemode) + gun_firemode = gun_firemode_list[1] + do_toggle_firemode(user, gun_firemode) + +/obj/item/weapon/gun/proc/setup_firemodes() + if(burst_amount > 1 && !(GUN_FIREMODE_BURSTFIRE in gun_firemode_list)) + gun_firemode_list += GUN_FIREMODE_BURSTFIRE + + switch(length(gun_firemode_list)) + if(0) + CRASH("[src] called setup_firemodes() with an empty gun_firemode_list") + else + gun_firemode = gun_firemode_list[1] + /*var/datum/action/new_action = new /datum/action/item_action/firemode(src) + if(isliving(loc)) + var/mob/living/living_user = loc + if(src == living_user.l_hand || src == living_user.r_hand) + new_action.give_action(living_user)*/ /obj/item/weapon/gun/verb/use_toggle_burst() set category = "Weapons" - set name = "Toggle Burst Fire Mode" - set desc = "Toggle on or off your weapon burst mode, if it has one. Greatly reduces accuracy." + set name = "Toggle Firemode" + set desc = "Cycles through your gun's firemodes. Automatic modes greatly reduce accuracy." set src = usr.contents var/obj/item/weapon/gun/active_firearm = get_active_firearm(usr) @@ -754,7 +810,7 @@ As sniper rifles have both and weapon mods can change them as well. ..() deals w return src = active_firearm - toggle_burst(usr) + do_toggle_firemode(usr) /obj/item/weapon/gun/verb/empty_mag() set category = "Weapons" @@ -960,3 +1016,12 @@ As sniper rifles have both and weapon mods can change them as well. ..() deals w return TRUE return FALSE + +///Helper proc that processes a clicked target, if the target is not black tiles, it will not change it. If they are it will return the turf of the black tiles. It will return null if the object is a screen object other than black tiles. +/proc/get_turf_on_clickcatcher(atom/target, mob/user, params) + var/list/modifiers = params2list(params) + if(!istype(target, /atom/movable/screen)) + return target + if(!istype(target, /atom/movable/screen/click_catcher)) + return null + return params2turf(modifiers["screen-loc"], get_turf(user), user.client) diff --git a/code/modules/projectiles/guns/energy.dm b/code/modules/projectiles/guns/energy.dm index 12f1976e186e..8ba8e0875e8f 100644 --- a/code/modules/projectiles/guns/energy.dm +++ b/code/modules/projectiles/guns/energy.dm @@ -90,6 +90,7 @@ to_firer = "[round((cell.charge / charge_cost), 1)] / [max_shots] SHOTS REMAINING" user.visible_message(SPAN_DANGER("[user] fires \the [src]!"), SPAN_DANGER("[to_firer]"), message_flags = CHAT_TYPE_WEAPON_USE) + return AUTOFIRE_CONTINUE /obj/item/weapon/gun/energy/reload_into_chamber() update_icon() diff --git a/code/modules/projectiles/guns/flamer/flamer.dm b/code/modules/projectiles/guns/flamer/flamer.dm index c5a0c8ee2f8c..be08ebdd537a 100644 --- a/code/modules/projectiles/guns/flamer/flamer.dm +++ b/code/modules/projectiles/guns/flamer/flamer.dm @@ -92,7 +92,7 @@ . = ..() if(.) if(!current_mag || !current_mag.current_rounds) - return + return NONE /obj/item/weapon/gun/flamer/proc/get_fire_sound() var/list/fire_sounds = list( @@ -102,15 +102,15 @@ return pick(fire_sounds) /obj/item/weapon/gun/flamer/Fire(atom/target, mob/living/user, params, reflex) - set waitfor = 0 + set waitfor = FALSE if(!able_to_fire(user)) - return + return NONE var/turf/curloc = get_turf(user) //In case the target or we are expired. var/turf/targloc = get_turf(target) if (!targloc || !curloc) - return //Something has gone wrong... + return NONE //Something has gone wrong... if(active_attachable && active_attachable.flags_attach_features & ATTACH_WEAPON) //Attachment activated and is a weapon. if(active_attachable.flags_attach_features & ATTACH_PROJECTILE) @@ -120,23 +120,26 @@ to_chat(user, SPAN_WARNING("[active_attachable] is empty!")) to_chat(user, SPAN_NOTICE("You disable [active_attachable].")) active_attachable.activate_attachment(src, null, TRUE) + return AUTOFIRE_CONTINUE else active_attachable.fire_attachment(target, src, user) //Fire it. active_attachable.last_fired = world.time - return + return AUTOFIRE_CONTINUE if(flags_gun_features & GUN_TRIGGER_SAFETY) to_chat(user, SPAN_WARNING("\The [src] isn't lit!")) - return + return NONE if(!current_mag) - return + return NONE if(current_mag.current_rounds <= 0) click_empty(user) else user.track_shot(initial(name)) unleash_flame(target, user) + return AUTOFIRE_CONTINUE + return NONE /obj/item/weapon/gun/flamer/reload(mob/user, obj/item/ammo_magazine/magazine) if(!magazine || !istype(magazine)) @@ -321,7 +324,7 @@ unload(user, drop_override = TRUE) current_mag = fuelpack.active_fuel update_icon() - ..() + return ..() /obj/item/weapon/gun/flamer/M240T/reload(mob/user, obj/item/ammo_magazine/magazine) @@ -360,6 +363,11 @@ return TRUE return FALSE +/obj/item/weapon/gun/flamer/M240T/auto // With NEW advances in science, we've learned how to drain a pyro's tank in 6 seconds, or your money back! + name = "\improper M240-T2 incinerator unit" + 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." + gun_firemode_list = list(GUN_FIREMODE_AUTOMATIC) + GLOBAL_LIST_EMPTY(flamer_particles) /particles/flamer_fire icon = 'icons/effects/particles/fire.dmi' diff --git a/code/modules/projectiles/guns/lever_action.dm b/code/modules/projectiles/guns/lever_action.dm index 259c6170ae48..b0a4c12b0f95 100644 --- a/code/modules/projectiles/guns/lever_action.dm +++ b/code/modules/projectiles/guns/lever_action.dm @@ -493,7 +493,7 @@ their unique feature is that a direct hit will buff your damage and firerate /obj/item/weapon/gun/lever_action/xm88/Fire(atom/target, mob/living/user, params, reflex, dual_wield) if(!able_to_fire(user) || !target) //checks here since we don't want to fuck up applying the increase - return + return NONE if(floating_penetration && in_chamber) //has to go before actual firing var/obj/item/projectile/P = in_chamber switch(floating_penetration) diff --git a/code/modules/projectiles/guns/misc.dm b/code/modules/projectiles/guns/misc.dm index 4a84f99d7c62..4d7c8f737bf5 100644 --- a/code/modules/projectiles/guns/misc.dm +++ b/code/modules/projectiles/guns/misc.dm @@ -13,8 +13,9 @@ current_mag = /obj/item/ammo_magazine/minigun w_class = SIZE_HUGE force = 20 - flags_gun_features = GUN_AUTO_EJECTOR|GUN_WIELDED_FIRING_ONLY|GUN_AMMO_COUNTER|GUN_RECOIL_BUILDUP|GUN_HAS_FULL_AUTO|GUN_CAN_POINTBLANK + flags_gun_features = GUN_AUTO_EJECTOR|GUN_WIELDED_FIRING_ONLY|GUN_AMMO_COUNTER|GUN_RECOIL_BUILDUP|GUN_CAN_POINTBLANK gun_category = GUN_CATEGORY_HEAVY + gun_firemode_list = list(GUN_FIREMODE_AUTOMATIC) /obj/item/weapon/gun/minigun/Initialize(mapload, spawn_empty) . = ..() @@ -45,7 +46,7 @@ /obj/item/weapon/gun/minigun/upp name = "\improper GSh-7.62 rotary machine gun" desc = "A gas-operated rotary machine gun used by UPP heavies. Its enormous volume of fire and ammunition capacity allows the suppression of large concentrations of enemy forces. Heavy weapons training is required control its recoil." - flags_gun_features = GUN_AUTO_EJECTOR|GUN_SPECIALIST|GUN_WIELDED_FIRING_ONLY|GUN_AMMO_COUNTER|GUN_RECOIL_BUILDUP|GUN_HAS_FULL_AUTO|GUN_CAN_POINTBLANK + flags_gun_features = GUN_AUTO_EJECTOR|GUN_SPECIALIST|GUN_WIELDED_FIRING_ONLY|GUN_AMMO_COUNTER|GUN_RECOIL_BUILDUP|GUN_CAN_POINTBLANK /obj/item/weapon/gun/minigun/upp/able_to_fire(mob/living/user) . = ..() @@ -72,7 +73,7 @@ current_mag = /obj/item/ammo_magazine/m60 w_class = SIZE_LARGE force = 25 - flags_gun_features = GUN_WIELDED_FIRING_ONLY|GUN_HAS_FULL_AUTO|GUN_FULL_AUTO_ON|GUN_FULL_AUTO_ONLY|GUN_CAN_POINTBLANK + flags_gun_features = GUN_WIELDED_FIRING_ONLY|GUN_CAN_POINTBLANK gun_category = GUN_CATEGORY_HEAVY attachable_allowed = list( /obj/item/attachable/m60barrel, @@ -82,6 +83,7 @@ /obj/item/attachable/m60barrel, /obj/item/attachable/bipod/m60, ) + gun_firemode_list = list(GUN_FIREMODE_AUTOMATIC) 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 e7e20526b31f..404a0ecb44d2 100644 --- a/code/modules/projectiles/guns/pistols.dm +++ b/code/modules/projectiles/guns/pistols.dm @@ -161,6 +161,7 @@ icon_state = "b92fs" item_state = "b92fs" current_mag = /obj/item/ammo_magazine/pistol/b92fs + gun_firemode_list = list(GUN_FIREMODE_SEMIAUTO, GUN_FIREMODE_BURSTFIRE) /obj/item/weapon/gun/pistol/b92fs/Initialize(mapload, spawn_empty) . = ..() @@ -171,7 +172,7 @@ BFA.flags_attach_features &= ~ATTACH_REMOVABLE BFA.Attach(src) update_attachable(BFA.slot) - flags_gun_features |= GUN_BURST_ON + //flags_gun_features |= GUN_BURST_ON //Zonenote /obj/item/weapon/gun/pistol/b92fs/set_gun_attachment_offsets() attachable_offset = list("muzzle_x" = 28, "muzzle_y" = 20,"rail_x" = 10, "rail_y" = 22, "under_x" = 21, "under_y" = 17, "stock_x" = 21, "stock_y" = 17) @@ -462,8 +463,8 @@ if(!manually_slided) click_empty() to_chat(user, SPAN_DANGER("\The [src] makes a clicking noise! You need to manually rack the slide after loading in a new magazine!")) - return - ..() + return NONE + return ..() /obj/item/weapon/gun/pistol/highpower/unique_action(mob/user) if(!manually_slided) @@ -739,7 +740,7 @@ It is a modified Beretta 93R, and can fire three-round burst or single fire. Whe fire_sound = 'sound/weapons/gun_skorpion.ogg' current_mag = /obj/item/ammo_magazine/pistol/skorpion - flags_gun_features = GUN_AUTO_EJECTOR|GUN_CAN_POINTBLANK|GUN_ONE_HAND_WIELDED|GUN_HAS_FULL_AUTO|GUN_FULL_AUTO_ON|GUN_FULL_AUTO_ONLY + flags_gun_features = GUN_AUTO_EJECTOR|GUN_CAN_POINTBLANK|GUN_ONE_HAND_WIELDED attachable_allowed = list( /obj/item/attachable/reddot, //Rail /obj/item/attachable/reflex, @@ -750,7 +751,8 @@ It is a modified Beretta 93R, and can fire three-round burst or single fire. Whe /obj/item/attachable/heavy_barrel, /obj/item/attachable/lasersight, //Underbarrel /obj/item/attachable/burstfire_assembly, - ) + ) + gun_firemode_list = list(GUN_FIREMODE_AUTOMATIC) /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/revolvers.dm b/code/modules/projectiles/guns/revolvers.dm index 3553ae880d7d..a9a9f0a20931 100644 --- a/code/modules/projectiles/guns/revolvers.dm +++ b/code/modules/projectiles/guns/revolvers.dm @@ -699,7 +699,7 @@ /obj/item/weapon/gun/revolver/cmb/Fire(atom/target, mob/living/user, params, reflex = 0, dual_wield) playsound('sound/weapons/gun_cmb_bass.ogg') // badass shooting bass - . = ..() + return ..() /obj/item/weapon/gun/revolver/cmb/set_gun_attachment_offsets() attachable_offset = list("muzzle_x" = 29, "muzzle_y" = 22,"rail_x" = 11, "rail_y" = 25, "under_x" = 20, "under_y" = 18, "stock_x" = 20, "stock_y" = 18) diff --git a/code/modules/projectiles/guns/rifles.dm b/code/modules/projectiles/guns/rifles.dm index ab2602204f72..a93018721eb5 100644 --- a/code/modules/projectiles/guns/rifles.dm +++ b/code/modules/projectiles/guns/rifles.dm @@ -137,7 +137,7 @@ /obj/item/attachable/scope/mini/nsg23, ) - flags_gun_features = GUN_AUTO_EJECTOR|GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER|GUN_BURST_ON|GUN_BURST_ONLY|GUN_WY_RESTRICTED + flags_gun_features = GUN_AUTO_EJECTOR|GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER|GUN_WY_RESTRICTED random_spawn_muzzle = list( /obj/item/attachable/suppressor, @@ -148,6 +148,7 @@ /obj/item/attachable/scope/mini/nsg23, /obj/item/attachable/attached_gun/flamer/advanced, ) + gun_firemode_list = list(GUN_FIREMODE_BURSTFIRE) /obj/item/weapon/gun/rifle/nsg23/Initialize(mapload, spawn_empty) . = ..() @@ -182,7 +183,7 @@ starting_attachment_types = list() //starts with the stock anyways due to handle_starting_attachment() /obj/item/weapon/gun/rifle/nsg23/no_lock - flags_gun_features = GUN_AUTO_EJECTOR|GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER|GUN_BURST_ON|GUN_BURST_ONLY + flags_gun_features = GUN_AUTO_EJECTOR|GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER starting_attachment_types = list( /obj/item/attachable/scope/mini/nsg23, /obj/item/attachable/attached_gun/flamer,//non-op flamer for normal spawns @@ -291,7 +292,7 @@ indestructible = TRUE current_mag = /obj/item/ammo_magazine/rifle/xm40/heap - flags_gun_features = GUN_AUTO_EJECTOR|GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER|GUN_BURST_ON + flags_gun_features = GUN_AUTO_EJECTOR|GUN_CAN_POINTBLANK|GUN_AMMO_COUNTER aim_slowdown = SLOWDOWN_ADS_QUICK wield_delay = WIELD_DELAY_FAST map_specific_decoration = FALSE @@ -324,6 +325,7 @@ ) random_spawn_chance = 0 + gun_firemode_list = list(GUN_FIREMODE_SEMIAUTO, GUN_FIREMODE_BURSTFIRE) /obj/item/weapon/gun/rifle/m41a/elite/xm40/handle_starting_attachment() ..() @@ -630,7 +632,7 @@ fire_delay += FIRE_DELAY_TIER_10 burst_amount -= BURST_AMOUNT_TIER_6 - flags_gun_features &= ~GUN_BURST_ON //Gun loses some combat ability in return for IFF, as well as burst fire mode + //flags_gun_features &= ~GUN_BURST_ON //Gun loses some combat ability in return for IFF, as well as burst fire mode //Zonenote /obj/item/weapon/gun/rifle/m46c/proc/name_after_co(mob/living/carbon/human/H) diff --git a/code/modules/projectiles/guns/shotguns.dm b/code/modules/projectiles/guns/shotguns.dm index d844498c2c02..5a883975e7e6 100644 --- a/code/modules/projectiles/guns/shotguns.dm +++ b/code/modules/projectiles/guns/shotguns.dm @@ -324,9 +324,10 @@ can cause issues with ammo types getting mixed up during the burst. current_mag = /obj/item/ammo_magazine/internal/shotgun/buckshot flags_equip_slot = SLOT_WAIST|SLOT_BACK - flags_gun_features = GUN_CAN_POINTBLANK|GUN_INTERNAL_MAG|GUN_HAS_FULL_AUTO|GUN_FULL_AUTO_ON + flags_gun_features = GUN_CAN_POINTBLANK|GUN_INTERNAL_MAG fa_delay = FIRE_DELAY_TIER_6 auto_retrieval_slot = WEAR_J_STORE + gun_firemode_list = list(GUN_FIREMODE_SEMIAUTO, GUN_FIREMODE_AUTOMATIC) /obj/item/weapon/gun/shotgun/combat/marsoc/Initialize(mapload, spawn_empty) . = ..() @@ -935,9 +936,9 @@ can cause issues with ammo types getting mixed up during the burst. /obj/item/weapon/gun/shotgun/double/twobore/Fire(atom/target, mob/living/carbon/human/user, params, reflex = 0, dual_wield) //Using this instead of apply_bullet_effects() as RPG does so I get more granular angles than just user direction. var/prefire_rounds = current_mag.current_rounds //How many rounds do we have before we fire? - ..() + . = ..() if(current_mag.current_rounds == prefire_rounds) //We didn't fire a shot. - return + return NONE var/target_angle = Get_Compass_Dir(user, target) //More precise than get_dir(). fired_shots++ twobore_recoil(user, target_angle) @@ -1220,7 +1221,7 @@ can cause issues with ammo types getting mixed up during the burst. playsound(src, 'sound/machines/switch.ogg', 15, TRUE) return TRUE -/obj/item/weapon/gun/shotgun/pump/dual_tube/toggle_burst() +/obj/item/weapon/gun/shotgun/pump/dual_tube/set_bursting() var/obj/item/weapon/gun/shotgun/pump/dual_tube/shotgun = get_active_firearm(usr) if(shotgun == src) swap_tube(usr) diff --git a/code/modules/projectiles/guns/smartgun.dm b/code/modules/projectiles/guns/smartgun.dm index c73d9c0f6423..2dd6ceecef21 100644 --- a/code/modules/projectiles/guns/smartgun.dm +++ b/code/modules/projectiles/guns/smartgun.dm @@ -59,10 +59,11 @@ /obj/item/attachable/flashlight, ) - flags_gun_features = GUN_SPECIALIST|GUN_WIELDED_FIRING_ONLY|GUN_HAS_FULL_AUTO|GUN_FULL_AUTO_ON|GUN_FULL_AUTO_ONLY + flags_gun_features = GUN_SPECIALIST|GUN_WIELDED_FIRING_ONLY gun_category = GUN_CATEGORY_HEAVY starting_attachment_types = list(/obj/item/attachable/smartbarrel) auto_retrieval_slot = WEAR_J_STORE + gun_firemode_list = list(GUN_FIREMODE_AUTOMATIC) /obj/item/weapon/gun/smartgun/Initialize(mapload, ...) @@ -86,8 +87,6 @@ /obj/item/weapon/gun/smartgun/set_gun_config_values() ..() fire_delay = FIRE_DELAY_TIER_10 - burst_amount = BURST_AMOUNT_TIER_3 - burst_delay = FIRE_DELAY_TIER_9 fa_delay = FIRE_DELAY_TIER_SG fa_scatter_peak = FULL_AUTO_SCATTER_PEAK_TIER_8 fa_max_scatter = SCATTER_AMOUNT_TIER_9 @@ -101,7 +100,6 @@ else scatter = SCATTER_AMOUNT_TIER_6 recoil = RECOIL_AMOUNT_TIER_3 - burst_scatter_mult = SCATTER_AMOUNT_TIER_8 damage_mult = BASE_BULLET_DAMAGE_MULT /obj/item/weapon/gun/smartgun/set_bullet_traits() @@ -364,15 +362,13 @@ /obj/item/weapon/gun/smartgun/Fire(atom/target, mob/living/user, params, reflex = 0, dual_wield) if(!requires_battery) - ..() - return + return ..() if(battery) if(!requires_power) - ..() - return + return ..() if(drain_battery()) - ..() + return ..() /obj/item/weapon/gun/smartgun/proc/drain_battery(override_drain) @@ -530,7 +526,7 @@ else if(unconscious_targets.len) . = pick(unconscious_targets) -/obj/item/weapon/gun/smartgun/proc/process_shot(mob/living/user, warned) +/obj/item/weapon/gun/smartgun/proc/process_shot(mob/living/user, warned) //ZONENOTE: WHUH set waitfor = 0 @@ -672,7 +668,7 @@ ammo = /obj/item/ammo_magazine/smartgun/dirty ammo_primary = /datum/ammo/bullet/smartgun/dirty//Toggled ammo type ammo_secondary = /datum/ammo/bullet/smartgun/dirty/armor_piercing///Toggled ammo type - flags_gun_features = GUN_WY_RESTRICTED|GUN_SPECIALIST|GUN_WIELDED_FIRING_ONLY|GUN_HAS_FULL_AUTO|GUN_FULL_AUTO_ON|GUN_FULL_AUTO_ONLY + flags_gun_features = GUN_WY_RESTRICTED|GUN_SPECIALIST|GUN_WIELDED_FIRING_ONLY /obj/item/weapon/gun/smartgun/dirty/Initialize(mapload, ...) . = ..() diff --git a/code/modules/projectiles/guns/smgs.dm b/code/modules/projectiles/guns/smgs.dm index 0c3e7f42fe72..7b5ce4a10e5d 100644 --- a/code/modules/projectiles/guns/smgs.dm +++ b/code/modules/projectiles/guns/smgs.dm @@ -283,15 +283,15 @@ playsound(src, 'sound/weapons/handling/gun_jam_click.ogg', 35, TRUE) to_chat(user, SPAN_WARNING("Your gun is jammed! Mash Unique-Action to unjam it!")) balloon_alert(user, "*jammed*") - return + return NONE else if(prob(ppsh_mag?.jam_chance)) jammed = TRUE playsound(src, 'sound/weapons/handling/gun_jam_initial_click.ogg', 50, FALSE) user.visible_message(SPAN_DANGER("[src] makes a noticeable clicking noise!"), SPAN_HIGHDANGER("\The [src] suddenly jams and refuses to fire! Mash Unique-Action to unjam it.")) balloon_alert(user, "*jammed*") - return + return NONE else - . = ..() + return ..() /obj/item/weapon/gun/smg/ppsh/unique_action(mob/user) if(jammed) @@ -444,15 +444,15 @@ playsound(src, 'sound/weapons/handling/gun_jam_click.ogg', 35, TRUE) to_chat(user, SPAN_WARNING("Your gun is jammed! Mash Unique-Action to unjam it!")) balloon_alert(user, "*jammed*") - return + return NONE else if(prob(uzi_mag.jam_chance)) jammed = TRUE playsound(src, 'sound/weapons/handling/gun_jam_initial_click.ogg', 35, TRUE) user.visible_message(SPAN_DANGER("[src] makes a noticeable clicking noise!"), SPAN_HIGHDANGER("\The [src] suddenly jams and refuses to fire! Mash Unique-Action to unjam it.")) balloon_alert(user, "*jammed*") - return + return NONE else - . = ..() + return ..() /obj/item/weapon/gun/smg/uzi/unique_action(mob/user) if(jammed) diff --git a/code/modules/projectiles/guns/souto.dm b/code/modules/projectiles/guns/souto.dm index fbc1a39124b8..8d7a1b2550a4 100644 --- a/code/modules/projectiles/guns/souto.dm +++ b/code/modules/projectiles/guns/souto.dm @@ -27,14 +27,14 @@ to_chat(user, "You must equip the specialized Backpack Souto Vending Machine to use the Souto Slinger Supremo!") click_empty(user) unlink_soutopack() - return + return NONE if(soutopack) if(!current_mag) current_mag = soutopack.internal_mag // Check we're actually firing the right fuel tank if(current_mag != soutopack.internal_mag) current_mag = soutopack.internal_mag - ..() + return ..() /obj/item/weapon/gun/souto/reload(mob/user, obj/item/ammo_magazine/magazine) to_chat(user, SPAN_WARNING("The [src] feed system cannot be reloaded manually.")) diff --git a/code/modules/projectiles/guns/specialist.dm b/code/modules/projectiles/guns/specialist.dm index be1bf5068a54..ec1a3a68e352 100644 --- a/code/modules/projectiles/guns/specialist.dm +++ b/code/modules/projectiles/guns/specialist.dm @@ -267,7 +267,7 @@ if(toggling_action) toggling_action.update_button_icon() -/obj/item/weapon/gun/rifle/sniper/toggle_burst(mob/user) +/obj/item/weapon/gun/rifle/sniper/set_bursting(mob/user) if(has_aimed_shot) toggle_laser(user) else diff --git a/colonialmarines.dme b/colonialmarines.dme index 204c144c8916..f4aa55673519 100644 --- a/colonialmarines.dme +++ b/colonialmarines.dme @@ -33,6 +33,7 @@ #include "code\__DEFINES\admin.dm" #include "code\__DEFINES\ARES.dm" #include "code\__DEFINES\atmospherics.dm" +#include "code\__DEFINES\autofire.dm" #include "code\__DEFINES\autolathe.dm" #include "code\__DEFINES\blood.dm" #include "code\__DEFINES\bsql.config.dm" @@ -227,6 +228,7 @@ #include "code\controllers\subsystem\admin.dm" #include "code\controllers\subsystem\assets.dm" #include "code\controllers\subsystem\atoms.dm" +#include "code\controllers\subsystem\autofire.dm" #include "code\controllers\subsystem\cellauto.dm" #include "code\controllers\subsystem\chat.dm" #include "code\controllers\subsystem\communications.dm" @@ -370,6 +372,8 @@ #include "code\datums\components\speed_modifier.dm" #include "code\datums\components\toxin_buildup.dm" #include "code\datums\components\weed_damage_reduction.dm" +#include "code\datums\components\autofire\_automated_fire.dm" +#include "code\datums\components\autofire\autofire.dm" #include "code\datums\components\xeno\shield_slash.dm" #include "code\datums\construction\construction_template.dm" #include "code\datums\construction\xenomorph\construction_template_xenomorph.dm" @@ -2047,7 +2051,6 @@ #include "code\modules\power\turbine.dm" #include "code\modules\projectiles\ammo_datums.dm" #include "code\modules\projectiles\ammunition.dm" -#include "code\modules\projectiles\full_auto.dm" #include "code\modules\projectiles\gun.dm" #include "code\modules\projectiles\gun_attachables.dm" #include "code\modules\projectiles\gun_helpers.dm"