mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 03:02:54 +00:00
Makes Projectile Ammo HUD code work!
Now to just get all the boolets to have `hud_state`s set. D:
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
// Begin TGMC Ammo HUD Port
|
||||
/obj/screen/ammo
|
||||
name = "ammo"
|
||||
icon = 'icons/mob/ammoHUD.dmi'
|
||||
icon = 'icons/mob/screen_ammo.dmi'
|
||||
icon_state = "ammo"
|
||||
screen_loc = ui_ammo_hud1
|
||||
var/warned = FALSE
|
||||
@@ -74,7 +74,7 @@
|
||||
|
||||
overlays.Cut()
|
||||
|
||||
var/empty = image('icons/mob/ammoHUD.dmi', src, "[hud_state_empty]")
|
||||
var/empty = image('icons/mob/screen_ammo.dmi', src, "[hud_state_empty]")
|
||||
|
||||
if(rounds == 0)
|
||||
if(warned)
|
||||
@@ -91,21 +91,21 @@
|
||||
overlays += empty
|
||||
else
|
||||
warned = FALSE
|
||||
overlays += image('icons/mob/ammoHUD.dmi', src, "[hud_state]")
|
||||
overlays += image('icons/mob/screen_ammo.dmi', src, "[hud_state]")
|
||||
|
||||
rounds = num2text(rounds)
|
||||
//Handle the amount of rounds
|
||||
switch(length(rounds))
|
||||
if(1)
|
||||
overlays += image('icons/mob/ammoHUD.dmi', src, "o[rounds[1]]")
|
||||
overlays += image('icons/mob/screen_ammo.dmi', src, "o[rounds[1]]")
|
||||
if(2)
|
||||
overlays += image('icons/mob/ammoHUD.dmi', src, "o[rounds[2]]")
|
||||
overlays += image('icons/mob/ammoHUD.dmi', src, "t[rounds[1]]")
|
||||
overlays += image('icons/mob/screen_ammo.dmi', src, "o[rounds[2]]")
|
||||
overlays += image('icons/mob/screen_ammo.dmi', src, "t[rounds[1]]")
|
||||
if(3)
|
||||
overlays += image('icons/mob/ammoHUD.dmi', src, "o[rounds[3]]")
|
||||
overlays += image('icons/mob/ammoHUD.dmi', src, "t[rounds[2]]")
|
||||
overlays += image('icons/mob/ammoHUD.dmi', src, "h[rounds[1]]")
|
||||
overlays += image('icons/mob/screen_ammo.dmi', src, "o[rounds[3]]")
|
||||
overlays += image('icons/mob/screen_ammo.dmi', src, "t[rounds[2]]")
|
||||
overlays += image('icons/mob/screen_ammo.dmi', src, "h[rounds[1]]")
|
||||
else //"0" is still length 1 so this means it's over 999
|
||||
overlays += image('icons/mob/ammoHUD.dmi', src, "o9")
|
||||
overlays += image('icons/mob/ammoHUD.dmi', src, "t9")
|
||||
overlays += image('icons/mob/ammoHUD.dmi', src, "h9")
|
||||
overlays += image('icons/mob/screen_ammo.dmi', src, "o9")
|
||||
overlays += image('icons/mob/screen_ammo.dmi', src, "t9")
|
||||
overlays += image('icons/mob/screen_ammo.dmi', src, "h9")
|
||||
@@ -98,6 +98,10 @@
|
||||
|
||||
if(handle_casings != HOLD_CASINGS)
|
||||
chambered = null
|
||||
|
||||
var/mob/living/M = loc // CHOMPEdit: TGMC Ammo HUD
|
||||
if(istype(M)) // CHOMPEdit: TGMC Ammo HUD
|
||||
M?.hud_used.update_ammo_hud(M, src)
|
||||
|
||||
|
||||
//Attempts to load A into src, depending on the type of thing being loaded and the load_method
|
||||
@@ -117,6 +121,7 @@
|
||||
AM.loc = src
|
||||
ammo_magazine = AM
|
||||
user.visible_message("[user] inserts [AM] into [src].", "<span class='notice'>You insert [AM] into [src].</span>")
|
||||
user.hud_used.update_ammo_hud(user, src)
|
||||
playsound(src, 'sound/weapons/flipblade.ogg', 50, 1)
|
||||
if(SPEEDLOADER)
|
||||
if(loaded.len >= max_shells)
|
||||
@@ -131,8 +136,10 @@
|
||||
loaded += C
|
||||
AM.stored_ammo -= C //should probably go inside an ammo_magazine proc, but I guess less proc calls this way...
|
||||
count++
|
||||
user.hud_used.update_ammo_hud(user, src)
|
||||
if(count)
|
||||
user.visible_message("[user] reloads [src].", "<span class='notice'>You load [count] round\s into [src].</span>")
|
||||
user.hud_used.update_ammo_hud(user, src)
|
||||
playsound(src, 'sound/weapons/empty.ogg', 50, 1)
|
||||
AM.update_icon()
|
||||
else if(istype(A, /obj/item/ammo_casing))
|
||||
@@ -168,6 +175,7 @@
|
||||
sleep(1 SECOND)
|
||||
|
||||
update_icon()
|
||||
user.hud_used.update_ammo_hud(user, src)
|
||||
|
||||
//attempts to unload src. If allow_dump is set to 0, the speedloader unloading method will be disabled
|
||||
/obj/item/weapon/gun/projectile/proc/unload_ammo(mob/user, var/allow_dump=1)
|
||||
@@ -177,6 +185,7 @@
|
||||
playsound(src, 'sound/weapons/empty.ogg', 50, 1)
|
||||
ammo_magazine.update_icon()
|
||||
ammo_magazine = null
|
||||
user.hud_used.update_ammo_hud(user, src)
|
||||
else if(loaded.len)
|
||||
//presumably, if it can be speed-loaded, it can be speed-unloaded.
|
||||
if(allow_dump && (load_method & SPEEDLOADER))
|
||||
@@ -195,6 +204,7 @@
|
||||
user.put_in_hands(C)
|
||||
user.visible_message("[user] removes \a [C] from [src].", "<span class='notice'>You remove \a [C] from [src].</span>")
|
||||
playsound(src, 'sound/weapons/empty.ogg', 50, 1)
|
||||
user.hud_used.update_ammo_hud(user, src)
|
||||
else
|
||||
to_chat(user, "<span class='warning'>[src] is empty.</span>")
|
||||
update_icon()
|
||||
@@ -256,3 +266,53 @@
|
||||
|
||||
unload_ammo(usr)
|
||||
*/
|
||||
|
||||
// TGMC Ammo HUD Insertion
|
||||
/obj/item/weapon/gun/projectile/has_ammo_counter()
|
||||
return TRUE
|
||||
|
||||
/obj/item/weapon/gun/projectile/get_ammo_type()
|
||||
if(load_method == MAGAZINE)
|
||||
if(chambered) // Do we have a round 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?
|
||||
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?
|
||||
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?
|
||||
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
|
||||
else
|
||||
return list("unknown", "unknown") // Safety, this shouldn't happen, but just in case
|
||||
else
|
||||
return list("unknown", "unknown") // Failsafe if we somehow fail both methods
|
||||
|
||||
/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
|
||||
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
|
||||
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
|
||||
return loaded.len
|
||||
else // Completely unloaded, nothing in chamber or ammo, or code failed???
|
||||
return 0
|
||||
else
|
||||
CRASH("/obj/item/weapon/gun/projectile/get_ammo_count() was called from [src] but did not have a valid load_method set! Load_method set was [load_method].")
|
||||
|
||||
@@ -1,29 +1,6 @@
|
||||
/*
|
||||
* 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"
|
||||
@@ -75,12 +52,14 @@
|
||||
else
|
||||
chambered.loc = get_turf(src) // Eject casing
|
||||
chambered = null
|
||||
user.hud_used.update_ammo_hud(user, src) // TGMC Ammo HUD Port
|
||||
|
||||
// Load next shell
|
||||
if(loaded.len)
|
||||
var/obj/item/ammo_casing/AC = loaded[1] // Load next casing.
|
||||
loaded -= AC // Remove casing from loaded list.
|
||||
chambered = AC
|
||||
user.hud_used.update_ammo_hud(user, src) // TGMC Ammo HUD Port
|
||||
|
||||
if(pump_animation) // This affects all bolt action and shotguns.
|
||||
flick("[pump_animation]", src) // This plays any pumping
|
||||
@@ -212,6 +191,7 @@
|
||||
burst = 2
|
||||
user.visible_message("<span class='danger'>The shotgun goes off!</span>", "<span class='danger'>The shotgun goes off in your face!</span>")
|
||||
Fire_userless(user)
|
||||
user.hud_used.update_ammo_hud(user, src) // TGMC Ammo HUD Port
|
||||
burst = burstsetting
|
||||
return
|
||||
if(do_after(user, 30)) // SHIT IS STEALTHY EYYYYY
|
||||
|
||||
@@ -106,6 +106,7 @@
|
||||
playsound(src, sound_ejectchamber, 50, 0)
|
||||
user.visible_message("<span class='notice'>[user] pulls back \the [bolt_name] before releasing it[close_open_ejected] causing it to slide forward again[casing_chambered].</span>", \
|
||||
"<span class='notice'>You pull back \the [bolt_name] before releasing it[close_open_ejected] causing it to slide forward again[casing_chambered].</span>")
|
||||
user.hud_used.update_ammo_hud(user, src)
|
||||
else if(opened)
|
||||
playsound(src, sound_eject, 50, 0)
|
||||
if(locked)
|
||||
@@ -135,6 +136,7 @@
|
||||
else
|
||||
user.visible_message("<span class='notice'>[user] closes \the [bolt_name][casing_chambered].</span>", \
|
||||
"<span class='notice'>You close \the [bolt_name][casing_chambered].</span>")
|
||||
user.hud_used.update_ammo_hud(user, src)
|
||||
|
||||
/obj/item/weapon/gun/projectile/proc/bolt_toggle(var/manual)
|
||||
if(!bolt_open)
|
||||
@@ -298,6 +300,7 @@
|
||||
chamber_bullet()
|
||||
bolt_toggle()
|
||||
playsound(src, 'sound/weapons/flipblade.ogg', 50, 1)
|
||||
user.hud_used.update_ammo_hud(user, src)
|
||||
if(SPEEDLOADER)
|
||||
if(only_open_load && !bolt_open)
|
||||
to_chat(user, "<span_class='warning'>[src] must have its bolt open to be loaded!</span>")
|
||||
@@ -317,6 +320,7 @@
|
||||
if(count)
|
||||
user.visible_message("[user] reloads [src].", "<span class='notice'>You load [count] round\s into [src].</span>")
|
||||
playsound(src, 'sound/weapons/empty.ogg', 50, 1)
|
||||
user.hud_used.update_ammo_hud(user, src)
|
||||
AM.update_icon()
|
||||
else if(istype(A, /obj/item/ammo_casing))
|
||||
var/obj/item/ammo_casing/C = A
|
||||
@@ -330,6 +334,7 @@
|
||||
if(do_after(user,5))
|
||||
user.visible_message("<span class='notice'>[user] slides \the [C] into the [src]'s chamber.</span>","<span class='notice'>You slide \the [C] into the [src]'s chamber.</span>")
|
||||
chambered = C
|
||||
user.hud_used.update_ammo_hud(user, src)
|
||||
else
|
||||
return
|
||||
else if(!(CHECK_BITFIELD(auto_loading_type,LOCK_OPEN_EMPTY) || (CHECK_BITFIELD(auto_loading_type,LOCK_MANUAL_LOCK))))
|
||||
@@ -337,6 +342,7 @@
|
||||
user.visible_message("<span class='notice'>[user] holds open \the [src]'s [bolt_name] and slides [C] into the chamber before letting the bolt close again.</span>","<span class='notice'>You slide \the [C] into the [src]'s chamber.</span>")
|
||||
|
||||
chambered = C
|
||||
user.hud_used.update_ammo_hud(user, src)
|
||||
else
|
||||
return
|
||||
else
|
||||
@@ -366,6 +372,7 @@
|
||||
loaded.Insert(1, C) //add to the head of the list
|
||||
user.visible_message("[user] inserts \a [C] into [src].", "<span class='notice'>You insert \a [C] into [src].</span>")
|
||||
playsound(src, 'sound/weapons/empty.ogg', 50, 1)
|
||||
user.hud_used.update_ammo_hud(user, src)
|
||||
|
||||
else if(istype(A, /obj/item/weapon/storage))
|
||||
var/obj/item/weapon/storage/storage = A
|
||||
@@ -379,6 +386,7 @@
|
||||
continue
|
||||
|
||||
load_ammo(ammo, user)
|
||||
user.hud_used.update_ammo_hud(user, src)
|
||||
|
||||
if(loaded.len >= max_shells)
|
||||
to_chat(user, "<span class='warning'>[src] is full.</span>")
|
||||
|
||||
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Reference in New Issue
Block a user