Holographic Ammo Display (#9250)

Added a holographic ammo display, that provides the number of bullets left as a number next to the sprite.
    Added the HAD to the devices and tools uplink, as well as to cargo under Zavodskoi.
    Fixes a bug with gunshot residue when certain gloves are worn.
This commit is contained in:
Geeves
2020-07-20 19:55:00 +02:00
committed by GitHub
parent bcc2d8c0e9
commit 592d2cc708
8 changed files with 68 additions and 6 deletions
+1
View File
@@ -2296,6 +2296,7 @@
#include "code\modules\power\tesla\coil.dm"
#include "code\modules\power\tesla\energy_ball.dm"
#include "code\modules\power\tesla\generator.dm"
#include "code\modules\projectiles\ammo_display.dm"
#include "code\modules\projectiles\ammunition.dm"
#include "code\modules\projectiles\gun.dm"
#include "code\modules\projectiles\pins.dm"
+6 -1
View File
@@ -189,4 +189,9 @@
name = "Electropack"
item_cost = 6
path = /obj/item/device/radio/electropack
desc = "A backpack wired with electrodes. Sync up with a signaller, attach to an unwilling host and pulse the signal to shock them."
desc = "A backpack wired with electrodes. Sync up with a signaller, attach to an unwilling host and pulse the signal to shock them."
/datum/uplink_item/item/tools/ammo_display
name = "Holographic Ammo Display"
item_cost = 2
path = /obj/item/ammo_display
+7
View File
@@ -0,0 +1,7 @@
/obj/item/ammo_display
name = "holographic ammo display"
desc = "A device that can be attached to most firearms, providing a holographic display of the remaining ammunition to the user."
icon = 'icons/obj/weapons.dmi'
icon_state = "ammo_display"
origin_tech = list(TECH_BLUESPACE = 3, TECH_MATERIAL = 4, TECH_DATA = 4)
w_class = ITEMSIZE_SMALL
+44 -4
View File
@@ -80,6 +80,8 @@
var/cyborg_maptext_override
var/displays_maptext = FALSE
var/can_ammo_display = TRUE
var/obj/item/ammo_display
maptext_x = 22
maptext_y = 2
@@ -732,12 +734,18 @@
return ..()
/obj/item/gun/throw_at()
..()
update_maptext()
/obj/item/gun/on_give()
update_maptext()
/obj/item/gun/dropped(mob/living/user)
..()
queue_icon_update()
//Unwields the item when dropped, deletes the offhand
if(displays_maptext)
maptext = ""
update_maptext()
if(is_wieldable)
if(user)
var/obj/item/offhand/O = user.get_inactive_hand()
@@ -748,7 +756,7 @@
/obj/item/gun/pickup(mob/user)
..()
queue_icon_update()
update_maptext()
addtimer(CALLBACK(src, .proc/update_maptext), 1)
if(is_wieldable)
unwield()
@@ -820,7 +828,6 @@
return
/obj/item/gun/attackby(var/obj/item/I, var/mob/user)
if(istype(I, /obj/item/material/knife/bayonet))
if(!can_bayonet)
return ..()
@@ -833,12 +840,40 @@
bayonet = I
to_chat(user, SPAN_NOTICE("You attach \the [I] to the front of \the [src]."))
update_icon()
return
if(istype(I, /obj/item/ammo_display))
if(!can_ammo_display)
to_chat(user, SPAN_WARNING("\The [I] cannot attach to \the [src]."))
return
if(ammo_display)
to_chat(user, SPAN_WARNING("\The [src] already has a holographic ammo display."))
return
if(displays_maptext)
to_chat(user, SPAN_WARNING("\The [src] is already displaying its ammo count."))
return
user.drop_from_inventory(I, src)
ammo_display = I
displays_maptext = TRUE
to_chat(user, SPAN_NOTICE("You attach \the [I] to \the [src]."))
return
if(I.iscrowbar() && bayonet)
to_chat(user, SPAN_NOTICE("You detach \the [bayonet] from \the [src]."))
bayonet.forceMove(get_turf(src))
user.put_in_hands(bayonet)
bayonet = null
update_icon()
return
if(I.iswrench() && ammo_display)
to_chat(user, SPAN_NOTICE("You wrench the ammo display loose from \the [src]."))
ammo_display.forceMove(get_turf(src))
user.put_in_hands(ammo_display)
ammo_display = null
displays_maptext = FALSE
maptext = ""
return
if(pin && I.isscrewdriver())
visible_message(SPAN_WARNING("\The [user] begins to try and pry out \the [src]'s firing pin!"))
@@ -846,6 +881,7 @@
if(pin.durable || prob(50))
visible_message(SPAN_NOTICE("\The [user] pops \the [pin] out of \the [src]!"))
pin.forceMove(get_turf(src))
user.put_in_hands(pin)
pin = null//clear it out.
else
user.visible_message(
@@ -854,6 +890,7 @@
"You hear a metallic crack.")
qdel(pin)
pin = null
return
return ..()
/obj/item/gun/proc/get_ammo()
@@ -865,6 +902,9 @@
/obj/item/gun/proc/update_maptext()
if(displays_maptext)
if(!ismob(loc) && !ismob(loc.loc))
maptext = ""
return
if(get_ammo() > 9)
maptext_x = 18
else
@@ -44,6 +44,7 @@
if(do_after(user,20))
to_chat(user, "<span class='notice'>You finish charging \the [src].</span>")
power_supply.give(charge_cost)
update_maptext()
update_icon()
is_charging = FALSE
else
+1 -1
View File
@@ -94,7 +94,7 @@
if(chambered.leaves_residue)
var/mob/living/carbon/human/H = loc
if(istype(H))
if(!H.gloves)
if(!istype(H.gloves, /obj/item/clothing))
H.gunshot_residue = chambered.caliber
else
var/obj/item/clothing/G = H.gloves
+8
View File
@@ -0,0 +1,8 @@
author: Code by Geeves, Sprite by Kyres
delete-after: True
changes:
- rscadd: "Added a holographic ammo display, that provides the number of bullets left as a number next to the sprite."
- rscadd: "Added the HAD to the devices and tools uplink, as well as to cargo under Zavodskoi."
- bugfix: "Fixes a bug with gunshot residue when certain gloves are worn."
Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB