Page 1 of 3
Ammo Indicator
Posted: 2013-07-19 17:42
by Mats391
Before anyone starts crying, i meant this only for weapons where you would be able to see and guess the amount of ammo left in real life. So consider this mostly for belt fed MGs.
So this is what i did:

Its meant to give rough idea how much is left inside the box. This example shows for a 100round belt.
And this is how i did it:
Code: Select all
hudBuilder.createSplitNode IngameHud AmmoIndicatorHud
hudBuilder.createPictureNode AmmoIndicatorHud AmmoIndicatorFrame 760 580 10 18
hudBuilder.setPictureNodeTexture Ingame\Weapons\Icons\Hud\AmmoIndicator\AmmoIndicatorFrame.dds
hudBuilder.setNodeRGBVariables PrimaryClipColorRed PrimaryClipColorGreen PrimaryClipColorBlue
hudBuilder.createCompassNode AmmoIndicatorHud AmmoIndicatorBar 3 761 581 8 16 1 0
hudBuilder.setCompassNodeTexture 1 Ingame\Weapons\Icons\Hud\AmmoIndicator\AmmoIndicatorBar.dds
hudBuilder.setCompassNodeTextureSize 808 16
hudBuilder.setCompassNodeBorder 0 0 0 -4220
hudBuilder.setCompassNodeValueVariable PrimaryAmmo
hudBuilder.setCompassNodeOffset 0
hudBuilder.setNodeRGBVariables PrimaryClipColorRed PrimaryClipColorGreen PrimaryClipColorBlue
The AmmoIndicatorFrame is just a 10x18 rectangle and this is the AmmoIndicatorBar:

This requires a new bar and a new compass for each amount of ammo per belt, but that could be easily be done by giving certain guiindexes to certain magazine sizes.
Also it took me quite some trial and error to figure out the corret number for "hudbuilder.setCompassNodeBorder" does anyone know what it really does?

Re: Ammo Indicator
Posted: 2013-07-19 18:57
by BloodyDeed
I like it.
I'll take a closer look tomorrow when I'm back on my PC again.
Posted: 2013-07-19 19:39
by Mineral
Looks awesome. And I'm guessing this is all clientside so shouldn't be an issue for server load. But I agree that its not needed on all weapons
Re: Ammo Indicator
Posted: 2013-07-19 20:34
by Wheres_my_chili
Dude, mats is kicking ***.
Re: Ammo Indicator
Posted: 2013-07-19 22:35
by Bluedrake42
for things like AR, this would be awesome.
HOWEVER. It would also be cool if this ONLY showed when you re-equip your weapon
That way you can check how much ammo is left, but you have to go through the deploy/arm animation first
This would kindof simulate taking out a mag and checking the ammo/weight
Re: Ammo Indicator
Posted: 2013-07-20 00:35
by Adalaxy
This on vehicles with HMGs?
Re: Ammo Indicator
Posted: 2013-07-20 07:38
by AfterDune
Not bad

.
Re: Ammo Indicator
Posted: 2013-07-20 07:58
by ExeTick
I think I ammo counter like this only works on tanks,IFVs,apcs and crows.
have it on a humvee with a 50cal or infantry would just ruin the game.
Re: Ammo Indicator
Posted: 2013-07-20 08:00
by Mats391
MineralWouter wrote:Looks awesome. And I'm guessing this is all clientside so shouldn't be an issue for server load. But I agree that its not needed on all weapons
yes, all client side. Its just a new compass with different variable.
This on vehicles with HMGs?
That was the plan
HOWEVER. It would also be cool if this ONLY showed when you re-equip your weapon
That way you can check how much ammo is left, but you have to go through the deploy/arm animation first
This would kindof simulate taking out a mag and checking the ammo/weight
I dont know if this is possible, but my guess is yes.
Dude, mats is kicking ***.
Not bad .
Thanks!
Re: Ammo Indicator
Posted: 2013-07-20 08:08
by Moszeusz6Pl
Interesting idea. Although doing it through compass bar would require a few quite large textures.
As for your question about hudbuilder.setCompassNodeBorder, it's used to define which part of texture isn't used. This is used, because some GF cards dont support textures which aren't a power of two, so your bar would cause crash on such computers, unless it would be added to menu atlas. So you would need to increase bar size to 1024x16. I think that negative border means, that there is still a texture of size 4220 to the right.
I also seems one more problem with using compass bar to do this. In situation one edge between one size of ammo and another, it can show both ammo sizes.
I like idea of adding something like that, but it will also drastically increase size of texture, that need to be on Atlas, because that ones will be use constantly as infantry. If we want to include it for all ammocounts we are using it would create few quite big textures to add, while I was trying to reduce it to minimum.
Maybe try doing it with a smaller texture?
You could also check if it could use barnode instead of compass one, if it would be possible, it would greatly reduce texture size, which is the main concern I'm worried right now.
Re: Ammo Indicator
Posted: 2013-07-20 09:37
by Mats391
[R-DEV]Moszeusz6Pl wrote:
Maybe try doing it with a smaller texture?
You could also check if it could use barnode instead of compass one, if it would be possible, it would greatly reduce texture size, which is the main concern I'm worried right now.
I checked barnodes and managed to get a similar effect with only a 8x16texture for the bar.
This is how it looks, i didnt check what ammocount belongs to which state. I only know that the last one is only when the magazine is completly empty:
And the code:
Code: Select all
hudBuilder.createSplitNode IngameHud AmmoIndicatorHud
hudBuilder.createPictureNode AmmoIndicatorHud AmmoIndicatorFrame 760 580 10 18
hudBuilder.setPictureNodeTexture Ingame\Weapons\Icons\Hud\AmmoIndicator\AmmoIndicatorFrame.dds
hudBuilder.setNodeRGBVariables PrimaryClipColorRed PrimaryClipColorGreen PrimaryClipColorBlue
hudBuilder.createBarNode AmmoIndicatorHud AmmoIndicatorBar 0 761 581 8 16
hudbuilder.setBarNodeTexture 1 Ingame\Weapons\Icons\Hud\AmmoIndicator\AmmoIndicatorBar2.dds
hudBuilder.setBarNodeTexture 0 Ingame/GeneralIcons/empty.tga
hudBuilder.setBarNodeSnap 3
hudBuilder.setBarNoderRound 1
hudBuilder.setBarNodeValueVariable PrimaryAmmo
hudBuilder.setNodeRGBVariables PrimaryClipColorRed PrimaryClipColorGreen PrimaryClipColorBlue
Re: Ammo Indicator
Posted: 2013-07-20 09:56
by Moszeusz6Pl
I was worried that PrimaryAmmo variable won't work with bar node, what a nice surprise.
Good job.
Re: Ammo Indicator
Posted: 2013-07-20 10:49
by Mats391
These are the ammo counts to the indicator states, tested with 100 magsize. Im not really happy with it
Edit:
With a little change it looks like this now:

I like that more

new code:
Code: Select all
hudBuilder.createBarNode AmmoIndicatorHud AmmoIndicatorBar 0 761 581 8 16
hudbuilder.setBarNodeTexture 1 Ingame\Weapons\Icons\Hud\AmmoIndicator\AmmoIndicatorBar2.dds
hudBuilder.setBarNodeTexture 0 Ingame/GeneralIcons/empty.tga
hudBuilder.setBarNodeSnap 3
hudBuilder.setBarNodeSnapDir 1
hudBuilder.setBarNodeValueVariable PrimaryAmmo
hudBuilder.setNodeRGBVariables PrimaryClipColorRed PrimaryClipColorGreen PrimaryClipColorBlue
reversed the snap direction and removed the BarNodeRound as it didnt do anything
Re: Ammo Indicator
Posted: 2013-07-20 11:22
by Moszeusz6Pl
I think it will be best, if it will be 0 ammo + 4 states, or 0ammo + 8states, so 5 or 9 in total. If you need to have one state for full or empty map, do it for empty, because it don't really matter if you have 100 or 85 bullets. Difference between 5 and 0 can be much greater.
Re: Ammo Indicator
Posted: 2013-07-20 11:34
by AfterDune
Not too many, as you then might as well reintroduce the bulletcount. If you ask me, it should be an indicator: full, half-full, (nearly) empty.
Re: Ammo Indicator
Posted: 2013-07-20 11:43
by rodrigoma
I agree with AD this is a nice addition if simplified to the minimum.
Re: Ammo Indicator
Posted: 2013-07-20 11:50
by Mats391
[R-DEV]AfterDune wrote:Not too many, as you then might as well reintroduce the bulletcount. If you ask me, it should be an indicator: full, half-full, (nearly) empty.
like this?

Re: Ammo Indicator
Posted: 2013-07-20 11:52
by AfterDune
Yeah, that would be nice.
Re: Ammo Indicator
Posted: 2013-07-20 11:59
by Rudd
could the near low and low one turn red or would that be too gamey?
Re: Ammo Indicator
Posted: 2013-07-20 12:13
by Moszeusz6Pl
Color is controlled by BF2 engine. You could have it controlled by some if statement, which is what I'm going to look into after 1.0.