diff --git a/code/__DEFINES/movespeed_modification.dm b/code/__DEFINES/movespeed_modification.dm index f238f7cca71c6..015066d2439fd 100644 --- a/code/__DEFINES/movespeed_modification.dm +++ b/code/__DEFINES/movespeed_modification.dm @@ -101,3 +101,5 @@ #define MOVESPEED_ID_SMOKE "SMOKE" #define MOVESPEED_ID_HOLOPARA_FRENZY "HOLOPARA_FRENZY" + +#define MOVESPEED_ID_GUN_EQUIP "GUN_EQUIP" diff --git a/code/modules/antagonists/changeling/powers/mutations.dm b/code/modules/antagonists/changeling/powers/mutations.dm index c974b8aa2194e..980063a0f2dc0 100644 --- a/code/modules/antagonists/changeling/powers/mutations.dm +++ b/code/modules/antagonists/changeling/powers/mutations.dm @@ -229,6 +229,7 @@ throw_range = 0 throw_speed = 0 requires_wielding = FALSE + equip_time = 0 /obj/item/gun/magic/tentacle/Initialize(mapload, silent) . = ..() diff --git a/code/modules/antagonists/cult/cult_items.dm b/code/modules/antagonists/cult/cult_items.dm index ddd669818fc8d..17418e5b8d719 100644 --- a/code/modules/antagonists/cult/cult_items.dm +++ b/code/modules/antagonists/cult/cult_items.dm @@ -757,6 +757,7 @@ Striking a noncultist, however, will tear their flesh."} mag_type = /obj/item/ammo_box/magazine/internal/boltaction/enchanted/arcane_barrage/blood fire_sound = 'sound/magic/wand_teleport.ogg' weapon_weight = WEAPON_LIGHT + equip_time = 0 /obj/item/ammo_box/magazine/internal/boltaction/enchanted/arcane_barrage/blood ammo_type = /obj/item/ammo_casing/magic/arcane_barrage/blood diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 943fd27dd9e76..f44849b8b2a5b 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -90,6 +90,14 @@ var/pb_knockback = 0 var/ranged_cooldown = 0 + // Equipping + /// The slowdown applied to mobs upon a gun being equipped + var/equip_slowdown = 0.5 + /// The time it takes for a gun to count as equipped, null to get a precalculated value + var/equip_time = null + /// The timer ID of our equipping action + VAR_PRIVATE/equip_timer_id + /obj/item/gun/Initialize(mapload) . = ..() if(pin) @@ -102,6 +110,11 @@ if(!canMouseDown) //Some things like beam rifles override this. canMouseDown = automatic //Nsv13 / Bee change. build_zooming() + if (isnull(equip_time)) + // Light guns: 1.5 second equip time + // Medium guns: 2 second equip time + // Heavy guns: 2.5 second equip time + equip_time = weapon_weight * 5 + 10 if(isnull(spread_unwielded)) spread_unwielded = weapon_weight * 20 + 20 if(requires_wielding) @@ -178,6 +191,39 @@ . = ..() if(zoomed && user.get_active_held_item() != src) zoom(user, user.dir, FALSE) //we can only stay zoomed in if it's in our hands //yeah and we only unzoom if we're actually zoomed using the gun!! + if (slot == ITEM_SLOT_HANDS) + ranged_cooldown = max(world.time + equip_time, ranged_cooldown) + user.client?.give_cooldown_cursor(ranged_cooldown - world.time) + equip_timer_id = addtimer(CALLBACK(src, PROC_REF(clear_gun_equip_slowdown), user), equip_time, TIMER_STOPPABLE) + user.add_movespeed_modifier(MOVESPEED_ID_GUN_EQUIP, multiplicative_slowdown = equip_slowdown, movetypes = GROUND) + else + clear_gun_equip_slowdown(user) + if (equip_timer_id) + deltimer(equip_timer_id) + equip_timer_id = null + +/obj/item/gun/pickup(mob/user) + ..() + if(azoom) + azoom.Grant(user) + +/obj/item/gun/dropped(mob/user) + ..() + if(azoom) + azoom.Remove(user) + if(zoomed) + zoom(user, user.dir) + update_icon() + user.client?.clear_cooldown_cursor() + clear_gun_equip_slowdown(user) + if (equip_timer_id) + deltimer(equip_timer_id) + equip_timer_id = null + +/obj/item/gun/proc/clear_gun_equip_slowdown(mob/living/user) + slowdown = initial(slowdown) + user.remove_movespeed_modifier(MOVESPEED_ID_GUN_EQUIP) + equip_timer_id = null //called after the gun has successfully fired its chambered ammo. /obj/item/gun/proc/process_chamber() @@ -655,20 +701,6 @@ update_icon() update_action_buttons() -/obj/item/gun/pickup(mob/user) - ..() - if(azoom) - azoom.Grant(user) - -/obj/item/gun/dropped(mob/user) - ..() - if(azoom) - azoom.Remove(user) - if(zoomed) - zoom(user, user.dir) - update_icon() - user.client?.clear_cooldown_cursor() - /obj/item/gun/proc/handle_suicide(mob/living/carbon/human/user, mob/living/carbon/human/target, params, bypass_timer) if(!ishuman(user) || !ishuman(target)) return diff --git a/code/modules/projectiles/guns/ballistic/pistol.dm b/code/modules/projectiles/guns/ballistic/pistol.dm index 4869eeaff4872..ea19e1bea8634 100644 --- a/code/modules/projectiles/guns/ballistic/pistol.dm +++ b/code/modules/projectiles/guns/ballistic/pistol.dm @@ -16,6 +16,7 @@ fire_rate = 3 automatic = 0 weapon_weight = WEAPON_LIGHT + equip_time = 1 SECONDS /obj/item/gun/ballistic/automatic/pistol/no_mag spawnwithmagazine = FALSE @@ -48,6 +49,7 @@ spread_unwielded = 30 //Manually set unwielded spread to 30; Equivelant weight to 0.5 (Stechkin has weight 1) wild_spread = TRUE wild_factor = 0.70 //Minimum spread is 70% of spread value + equip_time = 0 /obj/item/gun/ballistic/automatic/pistol/der38/twelveshooter //For debugging only, or meme shit name = "palm pistol devastator" @@ -73,6 +75,7 @@ mag_type = /obj/item/ammo_box/magazine/m50 can_suppress = FALSE mag_display = TRUE + equip_time = 2 SECONDS /obj/item/gun/ballistic/automatic/pistol/deagle/gold desc = "A gold plated Desert Eagle folded over a million times by superior martian gunsmiths. Uses .50 AE ammo." diff --git a/code/modules/projectiles/guns/energy/stun.dm b/code/modules/projectiles/guns/energy/stun.dm index 6cddac9147b03..b16d26bfb6e63 100644 --- a/code/modules/projectiles/guns/energy/stun.dm +++ b/code/modules/projectiles/guns/energy/stun.dm @@ -42,6 +42,7 @@ can_flashlight = TRUE flight_x_offset = 15 flight_y_offset = 10 + equip_time = 2 SECONDS /obj/item/gun/energy/disabler/cyborg name = "cyborg disabler" diff --git a/code/modules/projectiles/guns/magic.dm b/code/modules/projectiles/guns/magic.dm index 0a8f988dde6c5..d64cace153faf 100644 --- a/code/modules/projectiles/guns/magic.dm +++ b/code/modules/projectiles/guns/magic.dm @@ -21,6 +21,7 @@ trigger_guard = TRIGGER_GUARD_ALLOW_ALL // Has no trigger at all, uses magic instead pin = /obj/item/firing_pin/magic requires_wielding = FALSE //Magic has no recoil, just hold with 1 hand + equip_time = 0 lefthand_file = 'icons/mob/inhands/items_lefthand.dmi' //not really a gun and some toys use these inhands righthand_file = 'icons/mob/inhands/items_righthand.dmi' diff --git a/code/modules/projectiles/guns/misc/medbeam.dm b/code/modules/projectiles/guns/misc/medbeam.dm index e0642646f7137..9e5643c66f7a5 100644 --- a/code/modules/projectiles/guns/misc/medbeam.dm +++ b/code/modules/projectiles/guns/misc/medbeam.dm @@ -6,6 +6,7 @@ item_state = "chronogun" w_class = WEIGHT_CLASS_NORMAL requires_wielding = FALSE + equip_time = 0 var/mob/living/current_target var/last_check = 0