[READY] Adds ability to add bayonets to weapons - Only enabled on kinetic accelerators - refactors gunlight/bayonet sprites to ballistics too (#1191)
This commit is contained in:
committed by
kevinz000
parent
833c0c549c
commit
e9d00c2aff
@@ -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, "<span class='notice'>You click [S] into place on [src].</span>")
|
||||
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, "<span class='notice'>You unscrew the seclite from [src].</span>")
|
||||
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, "<span class='notice'>You click \the [S] into place on \the [src].</span>")
|
||||
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, "<span class='notice'>You attach \the [K] to the front of ]the [src].</span>")
|
||||
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, "<span class='notice'>You unscrew the seclite from \the [src].</span>")
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user