Skip to content

Commit

Permalink
Adds in unholstering delay + slowdown (#10034)
Browse files Browse the repository at this point in the history
* Fire rate crosshair

* Update mouse_control.dm

* KA Fixes

* Boop

* Makes non guns have no equip time

* Buffs the sketchkin

* Pocket pistol has no equip time

* Removes the crosshair from normal gun fire, reduces slowdown amount
  • Loading branch information
PowerfulBacon authored Oct 26, 2023
1 parent 1360108 commit cc5a0a1
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 14 deletions.
2 changes: 2 additions & 0 deletions code/__DEFINES/movespeed_modification.dm
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,5 @@
#define MOVESPEED_ID_SMOKE "SMOKE"

#define MOVESPEED_ID_HOLOPARA_FRENZY "HOLOPARA_FRENZY"

#define MOVESPEED_ID_GUN_EQUIP "GUN_EQUIP"
1 change: 1 addition & 0 deletions code/modules/antagonists/changeling/powers/mutations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@
throw_range = 0
throw_speed = 0
requires_wielding = FALSE
equip_time = 0

/obj/item/gun/magic/tentacle/Initialize(mapload, silent)
. = ..()
Expand Down
1 change: 1 addition & 0 deletions code/modules/antagonists/cult/cult_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
60 changes: 46 additions & 14 deletions code/modules/projectiles/gun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions code/modules/projectiles/guns/ballistic/pistol.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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."
Expand Down
1 change: 1 addition & 0 deletions code/modules/projectiles/guns/energy/stun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions code/modules/projectiles/guns/magic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions code/modules/projectiles/guns/misc/medbeam.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cc5a0a1

Please sign in to comment.