Fixes issues with HUDs not updating

Forces updates upon cycling the next round.
Fixes Chambered casings still counting for ammo despite having no associated projectile. Because for ~realism~ the casing has a BB var that determines if we currently have a bullet available to fire.
Adds rocket states for our ONE measly rocket launcher.
Phasers will now update their ammunition count on every single pump.
This commit is contained in:
Rykka
2022-04-06 00:15:36 -06:00
parent 7cedcee7bc
commit f84c9d720f
3 changed files with 21 additions and 12 deletions

View File

@@ -184,11 +184,13 @@
if(!do_after(user, 10, src))
break
playsound(src,'sound/items/change_drill.ogg',25,1)
user.hud_used.update_ammo_hud(user, src)
if(power_supply.give(phase_power) < phase_power)
break
recharging = 0
update_icon()
user.hud_used.update_ammo_hud(user, src) // Update one last time once we're finished!
/obj/item/weapon/gun/energy/locked/frontier/update_icon()
if(recharging)

View File

@@ -54,6 +54,10 @@
chambered = ammo_magazine.stored_ammo[ammo_magazine.stored_ammo.len]
if(handle_casings != HOLD_CASINGS)
ammo_magazine.stored_ammo -= chambered
var/mob/living/M = loc // CHOMPEdit: TGMC Ammo HUD
if(istype(M)) // CHOMPEdit: TGMC Ammo HUD
M?.hud_used.update_ammo_hud(M, src)
if (chambered)
return chambered.BB
@@ -273,22 +277,22 @@
/obj/item/weapon/gun/projectile/get_ammo_type()
if(load_method == MAGAZINE)
if(chambered) // Do we have a round chambered
if(chambered) // Do we have an ammo casing chambered
var/obj/item/ammo_casing/A = chambered
var/obj/item/projectile/P = A.projectile_type
return list(initial(P.hud_state), initial(P.hud_state_empty))
else if(loaded.len && ammo_magazine && ammo_magazine.stored_ammo) // Are we loaded, have a mag, and have ammo in the mag?
else if(ammo_magazine && ammo_magazine.stored_ammo) // Are we loaded, have a mag, and have ammo in the mag?
var/obj/item/ammo_casing/A = ammo_magazine.stored_ammo[1]
var/obj/item/projectile/P = A.projectile_type
return list(initial(P.hud_state), initial(P.hud_state_empty))
else
return list("unknown", "unknown") // Safety, this shouldn't happen, but just in case
else if(load_method == SINGLE_CASING|SPEEDLOADER)
if(chambered) // Do we have a round loaded in the chamber?
if(chambered) // Do we have an ammo casing loaded in the chamber?
var/obj/item/ammo_casing/A = chambered
var/obj/item/projectile/P = A.projectile_type
return list(initial(P.hud_state), initial(P.hud_state_empty)) // Return the casing's ammo hud state
else if(!chambered && loaded.len) // Else, is the gun loaded, but no rounds in chamber currently?
else if(!chambered && loaded.len) // Else, is the gun loaded, but no ammo casings in chamber currently?
var/obj/item/ammo_casing/A = loaded[1]
var/obj/item/projectile/P = A.projectile_type
return list(initial(P.hud_state), initial(P.hud_state_empty)) // Return the ammunition in mag's hud_state
@@ -299,18 +303,18 @@
/obj/item/weapon/gun/projectile/get_ammo_count()
if(load_method == MAGAZINE)
if(!ammo_magazine) // No magazine? Return if we have a round chambered or not
return chambered ? 1 : 0
if(!ammo_magazine) // No magazine? Return if we have a round chambered or not. BB is the var for the round inside the casing.
return chambered.BB ? 1 : 0
else if(ammo_magazine) // If we have a magazine loaded, check if chambered and return either the magazine + chambered or the loaded amount
return chambered ? (ammo_magazine.stored_ammo.len + 1) : ammo_magazine.stored_ammo.len
return chambered.BB ? (ammo_magazine.stored_ammo.len + 1) : ammo_magazine.stored_ammo.len
else // Completely unloaded or code failure.
return 0
else if(load_method == SINGLE_CASING|SPEEDLOADER)
if(chambered && !loaded.len) // Chambered, but nothing in the magazine/internal ammo
return chambered ? 1: 0
else if(chambered && loaded.len) // Chambered + has ammo
return loaded.len + (chambered ? 1 : 0)
else if(loaded.len) // Has ammo, no round chambered
if(chambered.BB && !loaded.len) // Chambered and has a round in the casing, but nothing in the magazine/internal ammo. BB is the var for the round inside the casing.
return chambered.BB ? 1: 0
else if(chambered.BB && loaded.len) // Chambered casing + round + has ammo. BB is the var for the round inside the casing.
return loaded.len + (chambered.BB ? 1 : 0)
else if(loaded.len) // Has ammo, no round chambered (but might have a casing still in the breech). BB is the var for the round inside the casing.
return loaded.len
else // Completely unloaded, nothing in chamber or ammo, or code failed???
return 0

View File

@@ -7,6 +7,8 @@
icon_state = "missile"
damage = 30 //Meaty whack. *Chuckles*
does_spin = 0
hud_state = "rocket_he"
hud_state_empty = "rocket_empty"
/obj/item/projectile/bullet/srmrocket/on_hit(atom/target, blocked=0)
if(!isliving(target)) //if the target isn't alive, so is a wall or something
@@ -24,6 +26,7 @@
/obj/item/projectile/bullet/srmrocket/weak //Used in the jury rigged one.
damage = 10
hud_state = "rocket_he"
/obj/item/projectile/bullet/srmrocket/weak/on_hit(atom/target, blocked=0)
explosion(target, 0, 0, 2, 4)//No need to have a question.