From b2e02687e2db50d869dd7e91f495f12b97eedfa2 Mon Sep 17 00:00:00 2001 From: ShizCalev Date: Sun, 19 Aug 2018 20:03:51 -0400 Subject: [PATCH] Fix guns not checking if the knife can bayonet (#39783) --- code/modules/projectiles/gun.dm | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 21e7f6eab55..d42895c6e82 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -334,22 +334,21 @@ if(loc == user) alight.Grant(user) else if(istype(I, /obj/item/kitchen/knife)) - if(!can_bayonet) - return ..() var/obj/item/kitchen/knife/K = I - if(!bayonet) - if(!user.transferItemToLoc(I, src)) - return - to_chat(user, "You attach \the [K] to the front of \the [src].") - bayonet = K - var/state = "bayonet" //Generic state. - if(bayonet.icon_state in icon_states('icons/obj/guns/bayonets.dmi')) //Snowflake state? - state = bayonet.icon_state - var/icon/bayonet_icons = 'icons/obj/guns/bayonets.dmi' - knife_overlay = mutable_appearance(bayonet_icons, state) - knife_overlay.pixel_x = knife_x_offset - knife_overlay.pixel_y = knife_y_offset - add_overlay(knife_overlay, TRUE) + if(!can_bayonet || !K.bayonet || bayonet) //ensure the gun has an attachment point available, and that the knife is compatible with it. + return ..() + if(!user.transferItemToLoc(I, src)) + return + to_chat(user, "You attach \the [K] to the front of \the [src].") + bayonet = K + var/state = "bayonet" //Generic state. + if(bayonet.icon_state in icon_states('icons/obj/guns/bayonets.dmi')) //Snowflake state? + state = bayonet.icon_state + var/icon/bayonet_icons = 'icons/obj/guns/bayonets.dmi' + knife_overlay = mutable_appearance(bayonet_icons, state) + knife_overlay.pixel_x = knife_x_offset + knife_overlay.pixel_y = knife_y_offset + add_overlay(knife_overlay, TRUE) else if(istype(I, /obj/item/screwdriver)) if(gun_light) var/obj/item/flashlight/seclite/S = gun_light