Progress Commit 2 - Energy Gun HUD works, starting Projectiles

Saving progress to resume later.
This commit is contained in:
Rykka
2022-04-03 21:51:07 -06:00
parent 3b5c753b7b
commit 85e69ffba4
8 changed files with 104 additions and 8 deletions

View File

@@ -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

View File

@@ -451,6 +451,9 @@
to_chat(nerd, "<span class='danger'>You're so tiny that the pull of the trigger causes you to drop the gun!</span>")
//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*", "<span class='danger'>*click*</span>")
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, "<span class='notice'>\The [src] is now set to [new_mode.name].</span>")
user.hud_used.update_ammo_hud(user, src) // CHOMPEdit: TGMC Ammo HUD
return new_mode

View File

@@ -1,2 +1,28 @@
/obj/item/weapon/gun
var/holy = 0 //For Divinely blessed guns
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)
..()

View File

@@ -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, "<span class='notice'>This cell is not fitted for [src].</span>")
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, "<span class='notice'>[src] does not have a power cell.</span>")
@@ -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)

View File

@@ -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

View File

@@ -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"

View File

@@ -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.

View File

@@ -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"