Help with HUD ammo count/Look @ my WAD

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
mydoomdevelopment
Posts: 11
Joined: Mon Aug 31, 2020 2:14 am

Help with HUD ammo count/Look @ my WAD

Post by mydoomdevelopment »

This is my first wad so I'll post the full dec and I'd really appreciate any tips, This started out as a browning hipower but i think i'm gonna keep making additions. everything works how I want it to but I would like to add the ability to see the current ammo in mag count on my hud as well as the total ammo count along side it in the same box that it's already in, something like [10/150] 10 being ammo left in the mag and 150 being total ammo on my person. Also any ways to simplify would be great as well as suggestions for things to add. I'll post the wad too, please try it out and let me know what you think. All textures from scratch other than Doomguys OG hands. Most of the code is practically copied from old posts on this forum. I'm currently working on a reload animation and other improvements that i'll probably post here sometime soon. My Avatar is a frame of its fire animation.

https://www.dropbox.com/s/htg1bbwberpea ... o.wad?dl=0

Code: Select all

ACTOR doomguy: DoomPlayer 
{
	Player.Weaponslot 1, Fist, Chainsaw
	Player.Weaponslot 2, BRNPIS
	Player.Weaponslot 3, Shotgun, SuperShotgun
	Player.Weaponslot 4, Chaingun
	Player.Weaponslot 5, RocketLauncher
	Player.Weaponslot 6, PlasmaRifle
	Player.Weaponslot 7, BFG9000
	Player.StartItem "BRNPIS"
	Player.StartItem "Fist"
	Player.StartItem "9mmAmmo", 50
 }
 
ACTOR BRNPIS : Pistol Replaces Pistol 1971 
{
	Weapon.SelectionOrder 2000
	Weapon.AmmoUse 1
	Weapon.AmmoGive 200
	Weapon.AmmoType "9mmAmmo"
	Weapon.AmmoUse2 1
	Weapon.AmmoType2 "9mmAmmo"
	Weapon.AmmoGive2 200
	Weapon.SlotNumber 1
	AttackSound "weapon/BRNSHT"
	
	Inventory.PickupSound "weapon/BRNPKP"
	Inventory.PickupMessage "FUKYEAH"
	
	States 
	{
		Spawn:
		BRNP G -1
		Stop
		
		Select:
		BRNP A 1 A_Raise
		Loop
		
		Deselect:
		BRNP A 1 A_Lower
		Loop
		
		Ready:
		BRNP B 1 A_WeaponReady(WRF_ALLOWRELOAD)
		Loop
		
		Reload:
		BRNP A 1 A_TakeInventory("NewPistolLoaded", 12)
		BRNP A 1 Offset(0,35) A_PlayWeaponSound("weapons/shotgr")
		BRNP A 1 Offset(0,38)
		BRNP A 1 Offset(0,44)
		BRNP A 1 Offset(0,52)
		BRNP A 1 Offset(0,62)
		BRNP A 1 Offset(0,72)
		BRNP A 1 Offset(0,82)
		TNT1 A 8 A_TakeInventory("NewPistolLoaded", 12)
		BRNP A 1 Offset(0,82)
		BRNP A 1 Offset(0,72)
		BRNP A 1 Offset(0,62)
		BRNP A 1 Offset(0,52)
		BRNP A 1 Offset(0,44)
		BRNP A 1 Offset(0,38)
		BRNP A 1 Offset(0,35)
		BRNP A 1 Offset(0,32)
		Goto Ready
		
		
		Fire:
		BRNP A 0 A_JumpIfInventory("NewPistolLoaded", 12, "Reload")
		BRNP A 3 A_GiveInventory("NewPistolLoaded", 1)
		BRNP A 1 A_Firebullets (0,0, 1, 15, "BulletPuff", FBF_UseAmmo)
		BRNP A 3 Bright A_Gunflash 
		BRNP BC 3 Bright
		BRNP DE 4
		Goto Ready
		
		AltFire:
		BRNP A 3 A_JumpIfInventory("NewPistolLoaded", 12, "Reload")
		BRNP A 0 A_GiveInventory("NewPistolLoaded", 1)
		BRNP A 2 A_Firebullets (random(-3,2), random(-1,3), 1, 25, "BulletPuff", FBF_UseAmmo|FBF_NoRandom)
		BRNP A 2 Bright A_Gunflash
		BRNP BC 1 Bright
		BRNP DC 1
		BRNP A 0 A_JumpIfInventory("NewPistolLoaded", 12, "Reload")
		BRNP A 0 A_GiveInventory("NewPistolLoaded", 1)
		BRNP A 2 A_Firebullets (random(-1,1), random(-2,2), 1, 25, "BulletPuff", FBF_UseAmmo|FBF_NoRandom)
		BRNP A 2 Bright A_Gunflash
		BRNP BC 1 Bright
		BRNP DC 1
		BRNP A 0 A_JumpIfInventory("NewPistolLoaded", 12, "Reload")
		BRNP A 0 A_GiveInventory("NewPistolLoaded", 1)
		BRNP A 2 A_Firebullets (random(-4,2), random(-3,2), 1, 25, "BulletPuff", FBF_UseAmmo|FBF_NoRandom)
		BRNP A 1 Bright A_Gunflash
		BRNP BC 1 Bright
		BRNP DE 1
		Goto Ready
		
	Flash:
	BRNP F 0 A_Recoil (1)
	BRNP F 2 
	Stop	
	
	
	}
}
 ACTOR 9mmAmmo : Ammo replaces Clip
{
 Inventory.Amount 10 
 Inventory.MaxAmount 200
 Ammo.BackpackAmount 30 
 Ammo.BackpackMaxAmount 300
 Inventory.Icon "CLIPA0" 
 Inventory.PickupMessage "Picked up some 9mm ammo."
 States
 {
 Spawn:
  CLIP A -1
  Stop
 }
}

ACTOR NewPistolLoaded : Ammo
{
 Inventory.MaxAmount 12
 +IGNORESKILL
}
I'm sure this looks awful compared to what I could do with more than two days of Slade experience, but it couldn't be anymore fun to play to me :)
Attachments
BrownHiPo.wad
(235.94 KiB) Downloaded 16 times
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: Help with HUD ammo count/Look @ my WAD

Post by Jarewill »

You are trying to make the current ammo appear on the HUD, correct?
One possible solution is changing AmmoType1 to the "NewPistolLoaded" ammo.
This will make the ammo show on the HUD, but it will show as "0" when full.
Spoiler:
User avatar
mydoomdevelopment
Posts: 11
Joined: Mon Aug 31, 2020 2:14 am

Re: Help with HUD ammo count/Look @ my WAD

Post by mydoomdevelopment »

I messed around with this a little bit and after more than a little bit of fidgeting i've decided that my system is just going to have to make enough for me sense for now. Would there be any way to have my HUD display how much ammo is "in the mag" as my code is here?
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: Help with HUD ammo count/Look @ my WAD

Post by Jarewill »

The only thing that comes to mind with the current system is to use ACS with HudMessage:

Code: Select all

#library "ModName"
#include "zcommon.acs"

Script "AmmoType" ENTER
{
    While(true)
    {
        int am = 12 - CheckInventory("NewPistolLoaded"); //Define an integer that will show current ammo
        If(CheckWeapon("BRNPIS")){HudMessage(i:am; HUDMSG_PLAIN, 1, CR_RED, 0.9, 0.9, 0);} //Show current ammo on HUD, replace "0.9, 0.9" with proper position
        Else{HudMessage(s:""; HUDMSG_PLAIN, 1, CR_RED, 0.9, 0.9, 0);} //Also check if current weapon is "BRNPIS" to show the ammo
        Delay(1);
    }
} 
User avatar
mydoomdevelopment
Posts: 11
Joined: Mon Aug 31, 2020 2:14 am

Re: Help with HUD ammo count/Look @ my WAD

Post by mydoomdevelopment »

Thank you sm for helping so far. Earlier today i started learned a little ZScript and was able to better grasp what you were trying to have me do the first time. I understand now that the pistols magazine will draw from "Newpistolloaded" and i will reload as long as I have ammo in "9mmAmmo". I adapted your fix to my code and included it into the burst firemechanic as well and it all works great, I now fire until 9 rounds after i have reloaded, my gun stays up, and I'm able to run out of ammo. Here's a little of what is relevant.
Spoiler:
I'm off to bed, but in the morning sometime, i'll try out your HUD fix
Maybe my HUD solution lies in ZScript after all. It's a shame there aren't any video tutorials on beginning ZScript without any experience.
I'll just have to make those videos myself when i understand a little more I guess. I'm sure i'll be an expert in a week or two

EDIT: I've started converting to ZScript and have the gun in a working state but I need help making it replace the pistol again. I had troubles defining a new mandatory playerpawn.
Spoiler:
That's the whole of the zscript, I removed the MAPINFO entirely during troubleshooting
Post Reply

Return to “Scripting”