Ammo Indicator

Making or wanting help making your own asset? Check in here
User avatar
Mats391
PR:BF2 Lead Developer
Posts: 7643
Joined: 2010-08-06 18:06

Ammo Indicator

Post 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:
Image
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:
Image
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? :)
Image

Mineral: TIL that Wire-guided missiles actually use wire
BloodyDeed
Retired PR Developer
Posts: 4452
Joined: 2008-05-07 17:43

Re: Ammo Indicator

Post by BloodyDeed »

I like it.
I'll take a closer look tomorrow when I'm back on my PC again.
Image
User avatar
Mineral
Retired PR Developer
Posts: 8534
Joined: 2012-01-02 12:37
Location: Belgium

Post 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
Image
Wheres_my_chili
Posts: 240
Joined: 2011-07-31 23:35

Re: Ammo Indicator

Post by Wheres_my_chili »

Dude, mats is kicking ***.
Bluedrake42
Posts: 1933
Joined: 2009-07-23 17:52

Re: Ammo Indicator

Post 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
Adalaxy
Posts: 103
Joined: 2013-03-05 00:09

Re: Ammo Indicator

Post by Adalaxy »

This on vehicles with HMGs?
soundcloud.com/adalaxy
AfterDune
Retired PR Developer
Posts: 17094
Joined: 2007-02-08 07:19

Re: Ammo Indicator

Post by AfterDune »

Not bad :) .
Image
ExeTick
Posts: 855
Joined: 2011-01-13 22:50

Re: Ammo Indicator

Post 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.
Image

Image
User avatar
Mats391
PR:BF2 Lead Developer
Posts: 7643
Joined: 2010-08-06 18:06

Re: Ammo Indicator

Post 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!
Image

Mineral: TIL that Wire-guided missiles actually use wire
Moszeusz6Pl
Retired PR Developer
Posts: 939
Joined: 2010-06-24 13:41

Re: Ammo Indicator

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

Image
User avatar
Mats391
PR:BF2 Lead Developer
Posts: 7643
Joined: 2010-08-06 18:06

Re: Ammo Indicator

Post 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:
Image

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
Image

Mineral: TIL that Wire-guided missiles actually use wire
Moszeusz6Pl
Retired PR Developer
Posts: 939
Joined: 2010-06-24 13:41

Re: Ammo Indicator

Post by Moszeusz6Pl »

I was worried that PrimaryAmmo variable won't work with bar node, what a nice surprise.
Good job.

Image
User avatar
Mats391
PR:BF2 Lead Developer
Posts: 7643
Joined: 2010-08-06 18:06

Re: Ammo Indicator

Post by Mats391 »

These are the ammo counts to the indicator states, tested with 100 magsize. Im not really happy with it :(
Image

Edit:
With a little change it looks like this now:
Image
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
Last edited by Mats391 on 2013-07-20 11:05, edited 1 time in total.
Image

Mineral: TIL that Wire-guided missiles actually use wire
Moszeusz6Pl
Retired PR Developer
Posts: 939
Joined: 2010-06-24 13:41

Re: Ammo Indicator

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

Image
AfterDune
Retired PR Developer
Posts: 17094
Joined: 2007-02-08 07:19

Re: Ammo Indicator

Post 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.
Image
rodrigoma
Posts: 1537
Joined: 2012-03-22 21:21

Re: Ammo Indicator

Post by rodrigoma »

I agree with AD this is a nice addition if simplified to the minimum.
User avatar
Mats391
PR:BF2 Lead Developer
Posts: 7643
Joined: 2010-08-06 18:06

Re: Ammo Indicator

Post 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?
Image
Image

Mineral: TIL that Wire-guided missiles actually use wire
AfterDune
Retired PR Developer
Posts: 17094
Joined: 2007-02-08 07:19

Re: Ammo Indicator

Post by AfterDune »

Yeah, that would be nice.
Image
Rudd
Retired PR Developer
Posts: 21225
Joined: 2007-08-15 14:32

Re: Ammo Indicator

Post by Rudd »

could the near low and low one turn red or would that be too gamey?
Image
Moszeusz6Pl
Retired PR Developer
Posts: 939
Joined: 2010-06-24 13:41

Re: Ammo Indicator

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

Image
Post Reply

Return to “PR:BF2 Community Modding”