diff --git a/code/game/objects/items/weapons/kitchen.dm b/code/game/objects/items/weapons/kitchen.dm
index 54a41b2214..e11e36bbb6 100644
--- a/code/game/objects/items/weapons/kitchen.dm
+++ b/code/game/objects/items/weapons/kitchen.dm
@@ -65,6 +65,7 @@
attack_verb = list("slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut")
sharpness = IS_SHARP_ACCURATE
armor = list(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0, fire = 50, acid = 50)
+ var/bayonet = FALSE //Can this be attached to a gun?
/obj/item/weapon/kitchen/knife/attack(mob/living/carbon/M, mob/living/carbon/user)
if(user.zone_selected == "eyes")
@@ -107,7 +108,7 @@
throwforce = 20
origin_tech = "materials=3;combat=4"
attack_verb = list("slashed", "stabbed", "sliced", "torn", "ripped", "cut")
-
+ bayonet = TRUE
/obj/item/weapon/kitchen/knife/combat/survival
name = "survival knife"
@@ -115,6 +116,7 @@
desc = "A hunting grade survival knife."
force = 15
throwforce = 15
+ bayonet = TRUE
/obj/item/weapon/kitchen/knife/combat/bone
name = "bone dagger"
diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm
index 6fb4e6276f..04761befdc 100644
--- a/code/modules/projectiles/gun.dm
+++ b/code/modules/projectiles/gun.dm
@@ -43,8 +43,11 @@
var/obj/item/device/firing_pin/pin = /obj/item/device/firing_pin //standard firing pin for most guns
- var/obj/item/device/flashlight/gun_light = null
+ var/obj/item/device/flashlight/gun_light
var/can_flashlight = 0
+ var/obj/item/weapon/kitchen/knife/bayonet
+ var/can_bayonet = FALSE
+ var/datum/action/item_action/toggle_gunlight/alight
var/list/upgrades = list()
@@ -52,6 +55,8 @@
var/ammo_y_offset = 0
var/flight_x_offset = 0
var/flight_y_offset = 0
+ var/knife_x_offset = 0
+ var/knife_y_offset = 0
//Zooming
var/zoomable = FALSE //whether the gun generates a Zoom action on creation
@@ -65,8 +70,7 @@
if(pin)
pin = new pin(src)
if(gun_light)
- verbs += /obj/item/weapon/gun/proc/toggle_gunlight
- new /datum/action/item_action/toggle_gunlight(src)
+ alight = new /datum/action/item_action/toggle_gunlight(src)
build_zooming()
@@ -268,52 +272,88 @@
SSblackbox.add_details("gun_fired","[src.type]")
return 1
+/obj/item/weapon/gun/update_icon()
+ ..()
+ cut_overlays()
+ if(gun_light && can_flashlight)
+ var/state = "flight[gun_light.on? "_on":""]" //Generic state.
+ if(gun_light.icon_state in icon_states('icons/obj/guns/flashlights.dmi')) //Snowflake state?
+ state = gun_light.icon_state
+ var/mutable_appearance/flashlight_overlay = mutable_appearance('icons/obj/guns/flashlights.dmi', state)
+ flashlight_overlay.pixel_x = flight_x_offset
+ flashlight_overlay.pixel_y = flight_y_offset
+ add_overlay(flashlight_overlay)
+ if(bayonet && can_bayonet)
+ var/state = "bayonet" //Generic state.
+ if(bayonet.icon_state in icon_states('icons/obj/guns/bayonets.dmi')) //Snowflake state?
+ state = bayonet.icon_state
+ var/mutable_appearance/knife_overlay = mutable_appearance('icons/obj/guns/bayonets.dmi', state)
+ knife_overlay.pixel_x = knife_x_offset
+ knife_overlay.pixel_y = knife_y_offset
+ add_overlay(knife_overlay)
+
/obj/item/weapon/gun/attack(mob/M as mob, mob/user)
if(user.a_intent == INTENT_HARM) //Flogging
- ..()
- else
- return
+ if(bayonet)
+ bayonet.attack(M, user)
+ return
+ return ..()
+
+/obj/item/weapon/gun/attack_obj(obj/O, mob/user)
+ if(user.a_intent == INTENT_HARM)
+ if(bayonet)
+ bayonet.attack_obj(O, user)
+ return
+ return ..()
/obj/item/weapon/gun/attackby(obj/item/I, mob/user, params)
- if(can_flashlight)
- if(istype(I, /obj/item/device/flashlight/seclite))
- var/obj/item/device/flashlight/seclite/S = I
- if(!gun_light)
- if(!user.transferItemToLoc(I, src))
- return
- to_chat(user, "You click [S] into place on [src].")
- if(S.on)
- set_light(0)
- gun_light = S
- update_icon()
- update_gunlight(user)
- verbs += /obj/item/weapon/gun/proc/toggle_gunlight
- var/datum/action/A = new /datum/action/item_action/toggle_gunlight(src)
- if(loc == user)
- A.Grant(user)
-
- if(istype(I, /obj/item/weapon/screwdriver))
- if(gun_light)
- for(var/obj/item/device/flashlight/seclite/S in src)
- to_chat(user, "You unscrew the seclite from [src].")
- gun_light = null
- S.forceMove(get_turf(user))
- update_gunlight(user)
- S.update_brightness(user)
- update_icon()
- verbs -= /obj/item/weapon/gun/proc/toggle_gunlight
- for(var/datum/action/item_action/toggle_gunlight/TGL in actions)
- qdel(TGL)
+ if(user.a_intent == INTENT_HARM)
+ return ..()
+ else if(istype(I, /obj/item/device/flashlight/seclite))
+ if(!can_flashlight)
+ return ..()
+ var/obj/item/device/flashlight/seclite/S = I
+ if(!gun_light)
+ if(!user.transferItemToLoc(I, src))
+ return
+ to_chat(user, "You click \the [S] into place on \the [src].")
+ if(S.on)
+ set_light(0)
+ gun_light = S
+ update_icon()
+ update_gunlight(user)
+ alight = new /datum/action/item_action/toggle_gunlight(src)
+ if(loc == user)
+ alight.Grant(user)
+ else if(istype(I, /obj/item/weapon/kitchen/knife))
+ if(!can_bayonet)
+ return ..()
+ var/obj/item/weapon/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
+ update_icon()
+ else if(istype(I, /obj/item/weapon/screwdriver))
+ if(gun_light)
+ var/obj/item/device/flashlight/seclite/S = gun_light
+ to_chat(user, "You unscrew the seclite from \the [src].")
+ gun_light = null
+ S.forceMove(get_turf(user))
+ update_gunlight(user)
+ S.update_brightness(user)
+ update_icon()
+ QDEL_NULL(alight)
+ if(bayonet)
+ var/obj/item/weapon/kitchen/knife/K = bayonet
+ K.forceMove(get_turf(user))
+ bayonet = null
+ update_icon()
else
- ..()
-
-
+ return ..()
/obj/item/weapon/gun/proc/toggle_gunlight()
- set name = "Toggle Gunlight"
- set category = "Object"
- set desc = "Click to toggle your weapon's attached flashlight."
-
if(!gun_light)
return
@@ -343,12 +383,16 @@
..()
if(azoom)
azoom.Grant(user)
+ if(alight)
+ alight.Grant(user)
/obj/item/weapon/gun/dropped(mob/user)
..()
zoom(user,FALSE)
if(azoom)
azoom.Remove(user)
+ if(alight)
+ alight.Remove(user)
/obj/item/weapon/gun/AltClick(mob/user)
@@ -370,9 +414,6 @@
to_chat(M, "Your gun is now skinned as [choice]. Say hello to your new friend.")
update_icon()
-
-
-
/obj/item/weapon/gun/proc/handle_suicide(mob/living/carbon/human/user, mob/living/carbon/human/target, params)
if(!ishuman(user) || !ishuman(target))
return
diff --git a/code/modules/projectiles/guns/energy.dm b/code/modules/projectiles/guns/energy.dm
index b022941f78..f8d0911011 100644
--- a/code/modules/projectiles/guns/energy.dm
+++ b/code/modules/projectiles/guns/energy.dm
@@ -10,6 +10,7 @@
var/list/ammo_type = list(/obj/item/ammo_casing/energy)
var/select = 1 //The state of the select fire switch. Determines from the ammo_type list what kind of shot is fired next.
var/can_charge = 1 //Can it be charged in a recharger?
+ var/automatic_charge_overlays = TRUE //Do we handle overlays with base update_icon()?
var/charge_sections = 4
ammo_x_offset = 2
var/shaded_charge = 0 //if this gun uses a stateful charge bar for more detail
@@ -116,7 +117,9 @@
return
/obj/item/weapon/gun/energy/update_icon()
- cut_overlays()
+ ..()
+ if(!automatic_charge_overlays)
+ return
var/ratio = Ceiling((power_supply.charge / power_supply.maxcharge) * charge_sections)
var/obj/item/ammo_casing/energy/shot = ammo_type[select]
var/iconState = "[icon_state]_charge"
@@ -138,14 +141,6 @@
add_overlay(charge_overlay)
else
add_overlay("[icon_state]_charge[ratio]")
- if(gun_light && can_flashlight)
- var/iconF = "flight"
- if(gun_light.on)
- iconF = "flight_on"
- var/mutable_appearance/flashlight_overlay = mutable_appearance(icon, iconF)
- flashlight_overlay.pixel_x = flight_x_offset
- flashlight_overlay.pixel_y = flight_y_offset
- add_overlay(flashlight_overlay)
if(itemState)
itemState += "[ratio]"
item_state = itemState
diff --git a/code/modules/projectiles/guns/energy/kinetic_accelerator.dm b/code/modules/projectiles/guns/energy/kinetic_accelerator.dm
index e8d48373da..1799a33cbb 100644
--- a/code/modules/projectiles/guns/energy/kinetic_accelerator.dm
+++ b/code/modules/projectiles/guns/energy/kinetic_accelerator.dm
@@ -16,6 +16,9 @@
var/holds_charge = FALSE
var/unique_frequency = FALSE // modified by KA modkits
var/overheat = FALSE
+ can_bayonet = TRUE
+ knife_x_offset = 15
+ knife_y_offset = 13
var/max_mod_capacity = 100
var/list/modkits = list()
@@ -129,19 +132,11 @@
overheat = FALSE
/obj/item/weapon/gun/energy/kinetic_accelerator/update_icon()
- cut_overlays()
+ ..()
+
if(empty_state && !can_shoot())
add_overlay(empty_state)
- if(gun_light && can_flashlight)
- var/iconF = "flight"
- if(gun_light.on)
- iconF = "flight_on"
- var/mutable_appearance/flashlight_overlay = mutable_appearance(icon, iconF)
- flashlight_overlay.pixel_x = flight_x_offset
- flashlight_overlay.pixel_y = flight_y_offset
- add_overlay(flashlight_overlay)
-
//Casing
/obj/item/ammo_casing/energy/kinetic
projectile_type = /obj/item/projectile/kinetic
diff --git a/icons/obj/guns/bayonets.dmi b/icons/obj/guns/bayonets.dmi
new file mode 100644
index 0000000000..176005b7d7
Binary files /dev/null and b/icons/obj/guns/bayonets.dmi differ
diff --git a/icons/obj/guns/flashlights.dmi b/icons/obj/guns/flashlights.dmi
new file mode 100644
index 0000000000..a651cea313
Binary files /dev/null and b/icons/obj/guns/flashlights.dmi differ