diff --git a/aurorastation.dme b/aurorastation.dme index 4de2d8b29f9..14c6ba21715 100644 --- a/aurorastation.dme +++ b/aurorastation.dme @@ -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" diff --git a/code/datums/uplink/devices and tools.dm b/code/datums/uplink/devices and tools.dm index 58a8dff035e..848344b95e3 100644 --- a/code/datums/uplink/devices and tools.dm +++ b/code/datums/uplink/devices and tools.dm @@ -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." \ No newline at end of file + 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 \ No newline at end of file diff --git a/code/modules/projectiles/ammo_display.dm b/code/modules/projectiles/ammo_display.dm new file mode 100644 index 00000000000..810ff843314 --- /dev/null +++ b/code/modules/projectiles/ammo_display.dm @@ -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 \ No newline at end of file diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 298a754dc07..273740c5719 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -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 diff --git a/code/modules/projectiles/guns/energy/crank.dm b/code/modules/projectiles/guns/energy/crank.dm index 26b4280fb19..e73dd30cdfc 100644 --- a/code/modules/projectiles/guns/energy/crank.dm +++ b/code/modules/projectiles/guns/energy/crank.dm @@ -44,6 +44,7 @@ if(do_after(user,20)) to_chat(user, "You finish charging \the [src].") power_supply.give(charge_cost) + update_maptext() update_icon() is_charging = FALSE else diff --git a/code/modules/projectiles/guns/projectile.dm b/code/modules/projectiles/guns/projectile.dm index 7368fb77eed..a3685ecc104 100644 --- a/code/modules/projectiles/guns/projectile.dm +++ b/code/modules/projectiles/guns/projectile.dm @@ -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 diff --git a/html/changelogs/geeves-ammo_display.yml b/html/changelogs/geeves-ammo_display.yml new file mode 100644 index 00000000000..f4f06327a57 --- /dev/null +++ b/html/changelogs/geeves-ammo_display.yml @@ -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." \ No newline at end of file diff --git a/icons/obj/weapons.dmi b/icons/obj/weapons.dmi index 64f886dfc7b..f1f5f34f971 100644 Binary files a/icons/obj/weapons.dmi and b/icons/obj/weapons.dmi differ