diff --git a/code/_onclick/hud/screen_objects_ch.dm b/code/_onclick/hud/screen_objects_ch.dm
index 07886a4546..2a0cf6f3e7 100644
--- a/code/_onclick/hud/screen_objects_ch.dm
+++ b/code/_onclick/hud/screen_objects_ch.dm
@@ -38,13 +38,17 @@
var/warned = FALSE
var/static/list/ammo_screen_loc_list = list(ui_ammo_hud1, ui_ammo_hud2, ui_ammo_hud3 ,ui_ammo_hud4)
-/obj/screen/ammo/proc/add_hud(var/mob/living/user)
+/obj/screen/ammo/proc/add_hud(var/mob/living/user, var/obj/item/weapon/gun/G)
+
if(!user?.client)
return
+
+ // var/obj/item/weapon/gun/G = user.get_active_hand()
+
+ if(!G)
+ CRASH("/obj/screen/ammo/proc/add_hud() has been called from [src] without the required param of G")
- var/obj/item/weapon/gun/G = user.get_active_hand()
-
- if(!G || !G.has_ammo_counter() || !G.hud_enabled)
+ if(!G.has_ammo_counter())
return
user.client.screen += src
@@ -52,13 +56,13 @@
/obj/screen/ammo/proc/remove_hud(var/mob/living/user)
user?.client?.screen -= src
-/obj/screen/ammo/proc/update_hud(var/mob/living/user)
+/obj/screen/ammo/proc/update_hud(var/mob/living/user, var/obj/item/weapon/gun/G)
if(!user?.client?.screen.Find(src))
return
- var/obj/item/weapon/gun/G = user.get_active_hand()
+ // var/obj/item/weapon/gun/G = user.get_active_hand()
- if(!G || !istype(G) || !G.has_ammo_counter() || !G.hud_enabled || !G.get_ammo_type() || isnull(G.get_ammo_count()))
+ if(!G || !istype(G) || !G.has_ammo_counter() || !G.get_ammo_type() || isnull(G.get_ammo_count()))
remove_hud()
return
diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm
index 217f206381..4b56821d01 100644
--- a/code/modules/projectiles/gun.dm
+++ b/code/modules/projectiles/gun.dm
@@ -451,6 +451,9 @@
to_chat(nerd, "You're so tiny that the pull of the trigger causes you to drop the gun!")
//YAWNEDIT: Knockdown code end
+
+ // CHOMPEdit: TGMC Ammo HUD insertion:
+ user.hud_used.update_ammo_hud(user, src)
// Similar to the above proc, but does not require a user, which is ideal for things like turrets.
/obj/item/weapon/gun/proc/Fire_userless(atom/target)
@@ -543,6 +546,7 @@
/obj/item/weapon/gun/proc/handle_click_empty(mob/user)
if (user)
user.visible_message("*click click*", "*click*")
+ user.hud_used.update_ammo_hud(user, src)
else
src.visible_message("*click click*")
playsound(src, 'sound/weapons/empty.ogg', 100, 1)
@@ -774,6 +778,7 @@
var/datum/firemode/new_mode = firemodes[sel_mode]
new_mode.apply_to(src)
to_chat(user, "\The [src] is now set to [new_mode.name].")
+ user.hud_used.update_ammo_hud(user, src) // CHOMPEdit: TGMC Ammo HUD
return new_mode
diff --git a/code/modules/projectiles/gun_ch.dm b/code/modules/projectiles/gun_ch.dm
index 58e2fd9483..61e657ae58 100644
--- a/code/modules/projectiles/gun_ch.dm
+++ b/code/modules/projectiles/gun_ch.dm
@@ -1,2 +1,28 @@
/obj/item/weapon/gun
- var/holy = 0 //For Divinely blessed guns
\ No newline at end of file
+ var/holy = 0 //For Divinely blessed guns
+
+/* TGMC Ammo HUD Port Begin */
+/obj/item/weapon/gun
+ var/hud_enabled = TRUE
+
+/obj/item/weapon/gun/proc/has_ammo_counter()
+ return FALSE
+
+/obj/item/weapon/gun/proc/get_ammo_type()
+ return FALSE
+
+/obj/item/weapon/gun/proc/get_ammo_count()
+ return FALSE
+
+/obj/item/weapon/gun/equipped(mob/living/user, slot) // When a gun is equipped to your hands, we'll add the HUD to the user. Pending porting over TGMC guncode where wielding is far more sensible.
+ if(slot == slot_l_hand || slot == slot_r_hand)
+ user.hud_used.add_ammo_hud(user, src)
+ else
+ user.hud_used.remove_ammo_hud(user, src)
+
+ return ..()
+
+/obj/item/weapon/gun/dropped(mob/living/user) // Ditto as above, we remove the HUD. Pending porting TGMC code to clean up this fucking nightmare of spaghetti.
+ user.hud_used.remove_ammo_hud(user, src)
+
+ ..()
\ No newline at end of file
diff --git a/code/modules/projectiles/guns/energy.dm b/code/modules/projectiles/guns/energy.dm
index b869a7c6b5..c9e418e5c4 100644
--- a/code/modules/projectiles/guns/energy.dm
+++ b/code/modules/projectiles/guns/energy.dm
@@ -92,6 +92,9 @@
power_supply.give(rechargeamt) //... to recharge 1/5th the battery
update_icon()
+ var/mob/living/M = loc // CHOMPEdit: TGMC Ammo HUD
+ if(istype(M)) // CHOMPEdit: TGMC Ammo HUD
+ M?.hud_used.update_ammo_hud(M, src) // CHOMPEdit: TGMC Ammo HUD
else
charge_tick = 0
return 1
@@ -132,6 +135,7 @@
playsound(src, 'sound/weapons/flipblade.ogg', 50, 1)
update_icon()
update_held_icon()
+ user.hud_used.update_ammo_hud(user, src) // CHOMPEdit: TGMC Ammo HUD
else
to_chat(user, "This cell is not fitted for [src].")
return
@@ -148,6 +152,7 @@
playsound(src, 'sound/weapons/empty.ogg', 50, 1)
update_icon()
update_held_icon()
+ user.hud_used.update_ammo_hud(user, src) // CHOMPEdit: TGMC Ammo HUD
else
to_chat(user, "[src] does not have a power cell.")
@@ -235,3 +240,20 @@
results += ..()
return results
+
+// CHOMPEDIT: TGMC AMMO HUD PORT Start
+/obj/item/weapon/gun/energy/has_ammo_counter()
+ return TRUE
+
+/obj/item/weapon/gun/energy/get_ammo_type()
+ if(!projectile_type)
+ return list("unknown", "unknown")
+ else
+ var/obj/item/projectile/P = projectile_type
+ return list(initial(P.hud_state), initial(P.hud_state_empty))
+
+/obj/item/weapon/gun/energy/get_ammo_count()
+ if(!power_supply)
+ return 0
+ else
+ return FLOOR(power_supply.charge / max(charge_cost, 1), 1)
\ No newline at end of file
diff --git a/code/modules/projectiles/guns/projectile/shotgun.dm b/code/modules/projectiles/guns/projectile/shotgun.dm
index 7a00e2b92e..3771e5810a 100644
--- a/code/modules/projectiles/guns/projectile/shotgun.dm
+++ b/code/modules/projectiles/guns/projectile/shotgun.dm
@@ -1,6 +1,30 @@
/*
* Shotgun
*/
+// TGMC Ammo HUD Insertion
+/obj/item/weapon/gun/projectile/shotgun/has_ammo_counter()
+ return TRUE
+
+/obj/item/weapon/gun/projectile/shotgun/get_ammo_type()
+ if(load_method == MAGAZINE)
+ if(!ammo_magazine)
+
+ else if(load_method == SINGLE_CASING|SPEEDLOADER && loaded.len)
+
+ else
+ return list("unknown", "unknown")
+
+/obj/item/weapon/gun/projectile/shotgun/get_ammo_count()
+ if(load_method == MAGAZINE)
+ if(!ammo_magazine)
+ return chambered ? 1 : 0
+ else
+ return chambered ? (ammo_magazine.stored_ammo + 1) : ammo_magazine.stored_ammo
+ else if(load_method == SINGLE_CASING|SPEEDLOADER)
+ if(chambered)
+ else
+
+
/obj/item/weapon/gun/projectile/shotgun/pump
name = "shotgun"
// desc = "The mass-produced MarsTech Meteor 29 shotgun is a favourite of police and security forces on many worlds. Uses 12g rounds." //CHOMP Disable
diff --git a/code/modules/projectiles/projectile/beams.dm b/code/modules/projectiles/projectile/beams.dm
index 7cc79d8d15..4635684f25 100644
--- a/code/modules/projectiles/projectile/beams.dm
+++ b/code/modules/projectiles/projectile/beams.dm
@@ -20,6 +20,9 @@
muzzle_type = /obj/effect/projectile/muzzle/laser
tracer_type = /obj/effect/projectile/tracer/laser
impact_type = /obj/effect/projectile/impact/laser
+
+ hud_state = "laser"
+ hud_state_empty = "battery_empty"
/obj/item/projectile/beam/practice
name = "laser"
@@ -229,6 +232,8 @@
muzzle_type = /obj/effect/projectile/muzzle/stun
tracer_type = /obj/effect/projectile/tracer/stun
impact_type = /obj/effect/projectile/impact/stun
+
+ hud_state = "taser" // TGMC Ammo HUD port
/obj/item/projectile/beam/stun/weak
name = "weak stun beam"
diff --git a/code/modules/projectiles/projectile/bullets.dm b/code/modules/projectiles/projectile/bullets.dm
index a1d09e76f1..2c2e0c12da 100644
--- a/code/modules/projectiles/projectile/bullets.dm
+++ b/code/modules/projectiles/projectile/bullets.dm
@@ -70,30 +70,38 @@
/obj/item/projectile/bullet/pistol // 9mm pistols and most SMGs. Sacrifice power for capacity.
fire_sound = 'sound/weapons/gunshot2.ogg'
damage = 20
+ hud_state = "pistol" // CHOMPEdit: Putting these here for easier upstream porting.
+ hud_state_empty = "pistol_empty" // CHOMPEdit: Putting these here for easier upstream porting.
/obj/item/projectile/bullet/pistol/ap
damage = 15
armor_penetration = 30
+ hud_state = "pistol_light_ap" // CHOMPEdit: Putting these here for easier upstream porting.
/obj/item/projectile/bullet/pistol/hp
damage = 25
armor_penetration = -50
+ hud_state = "pistol_ap" // CHOMPEdit: Putting these here for easier upstream porting.
/obj/item/projectile/bullet/pistol/medium // .45 (and maybe .40 if it ever gets added) caliber security pistols. Balance between capacity and power.
fire_sound = 'sound/weapons/gunshot3.ogg' // Snappier sound.
damage = 25
+ hud_state = "pistol" // CHOMPEdit: Putting these here for easier upstream porting.
/obj/item/projectile/bullet/pistol/medium/ap
damage = 20
armor_penetration = 15
+ hud_state = "pistol_light_ap" // CHOMPEdit: Putting these here for easier upstream porting.
/obj/item/projectile/bullet/pistol/medium/hp
damage = 30
armor_penetration = -50
+ hud_state = "pistol_ap" // CHOMPEdit: Putting these here for easier upstream porting.
/obj/item/projectile/bullet/pistol/strong // .357 and .44 caliber stuff. High power pistols like the Mateba or Desert Eagle. Sacrifice capacity for power.
fire_sound = 'sound/weapons/gunshot4.ogg'
damage = 60
+ hud_state = "pistol_heavy"
/obj/item/projectile/bullet/pistol/rubber/strong // "Rubber" bullets for high power pistols.
fire_sound = 'sound/weapons/gunshot3.ogg' // Rubber shots have less powder, but these still have more punch than normal rubber shot.
diff --git a/code/modules/projectiles/projectile_ch.dm b/code/modules/projectiles/projectile_ch.dm
index a2af0b08be..649673c772 100644
--- a/code/modules/projectiles/projectile_ch.dm
+++ b/code/modules/projectiles/projectile_ch.dm
@@ -1,6 +1,8 @@
/obj/item/projectile
/// If this projectile is holy. Silver bullets, etc. Currently no effects.
var/holy = 0
+ var/hud_state = "unknown" // TGMC Ammo HUD Port
+ var/hud_state_empty = "unknown" // TGMC Ammo HUD Port
/obj/item/projectile/bullet/pellet/shotgun/silver
name = "shrapnel"