Jamming Tweaks (#8261)

Tweaked how gunjamming works. You now have to spam the Z button, or keep clicking the gun sprite if you don't have hotkeys, to unjam it.
    Added sounds to jamming and unjamming guns.
This commit is contained in:
Geeves
2020-02-22 21:52:37 +02:00
committed by GitHub
parent c0ff0d90d6
commit e6d6e0dfb6
2 changed files with 32 additions and 32 deletions

View File

@@ -28,7 +28,8 @@
var/auto_eject = 0 //if the magazine should automatically eject itself when empty.
var/auto_eject_sound = null
var/is_jammed = 0 //Whether this gun is jammed
var/jam_num = 0 //Whether this gun is jammed and how many self-uses until it's unjammed
var/unjam_cooldown = 0 //Gives the unjammer some time after spamming unjam to not eject their mag
var/jam_chance = 0 //Chance it jams on fire
//TODO generalize ammo icon states for guns
@@ -46,8 +47,8 @@
update_icon()
/obj/item/gun/projectile/consume_next_projectile()
if(is_jammed)
return 0
if(jam_num)
return FALSE
//get the next casing
if(loaded.len)
chambered = loaded[1] //load next casing.
@@ -74,12 +75,13 @@
/obj/item/gun/projectile/special_check(var/mob/user)
if(!..())
return 0
if(!is_jammed && jam_chance)
return FALSE
if(!jam_num && jam_chance && getAmmo())
if(prob(jam_chance))
playsound(src.loc, 'sound/items/trayhit2.ogg', 50, 1)
to_chat(user, "<span class='danger'>\The [src] jams!</span>")
is_jammed = 1
return 1
jam_num = rand(2, 5) // gotta attackself two to five times to unjam
return TRUE
/obj/item/gun/projectile/proc/process_chambered()
if (!chambered) return
@@ -195,28 +197,31 @@
to_chat(user, "<span class='warning'>[src] is empty.</span>")
update_icon()
/obj/item/gun/projectile/attackby(var/obj/item/A as obj, mob/user as mob)
/obj/item/gun/projectile/attackby(obj/item/A, mob/user)
..()
load_ammo(A, user)
/obj/item/gun/projectile/attack_self(mob/user as mob)
if(is_jammed)
to_chat(user, "<span class='notice'>\The [user] unjams \the [src]!</span>")
if(do_after(user, 5))
playsound(src.loc, 'sound/weapons/empty.ogg', 100, 1)
is_jammed = 0
/obj/item/gun/projectile/attack_self(mob/user)
if(jam_num)
playsound(src.loc, 'sound/weapons/empty.ogg', 50, 1)
jam_num--
if(!jam_num)
visible_message(span("danger", "\The [user] unjams \the [src]!"))
playsound(src.loc, 'sound/items/glowstick.ogg', 100, 1)
unjam_cooldown = world.time
else if(unjam_cooldown + 2 SECONDS > world.time)
return
else if(firemodes.len > 1)
..()
else
unload_ammo(user)
/obj/item/gun/projectile/attack_hand(mob/user as mob)
/obj/item/gun/projectile/attack_hand(mob/user)
if(user.get_inactive_hand() == src)
unload_ammo(user, allow_dump=0)
else
return ..()
/obj/item/gun/projectile/afterattack(atom/A, mob/living/user)
..()
if(auto_eject && ammo_magazine && ammo_magazine.stored_ammo && !ammo_magazine.stored_ammo.len)
@@ -235,7 +240,7 @@
..(user)
if(get_dist(src, user) > 1)
return
if(is_jammed)
if(jam_num)
to_chat(user, "<span class='warning'>It looks jammed.</span>")
if(ammo_magazine)
to_chat(user, "It has \a [ammo_magazine] loaded.")
@@ -251,15 +256,3 @@
if(chambered)
bullets += 1
return bullets
/* Unneeded -- so far.
//in case the weapon has firemodes and can't unload using attack_hand()
/obj/item/gun/projectile/verb/unload_gun()
set name = "Unload Ammo"
set category = "Object"
set src in usr
if(usr.stat || usr.restrained()) return
unload_ammo(usr)
*/

View File

@@ -0,0 +1,7 @@
author: Geeves
delete-after: True
changes:
- tweak: "Tweaked how gunjamming works. You now have to spam the Z button, or keep clicking the gun sprite if you don't have hotkeys, to unjam it."
- rscadd: "Added sounds to jamming and unjamming guns."