| RuneStorm https://www.runestorm.com/forums/ |
|
| Ammo Counters for BW Weapons. https://www.runestorm.com/forums/viewtopic.php?f=95&t=77295 |
Page 1 of 1 |
| Author: | CMGuy [ Wed Dec 14, 2011 10:12 am ] |
| Post subject: | Ammo Counters for BW Weapons. |
Blade Sword wanted to know about this so here goes... I managed to somehow add ammo counts for the weapons, mainly when I was was working on the Halo Weapons Pack(its on hold now). Anyway heres what can be done. NOTE: any other necessary Weapon-tick Coding like the M50's AI GL code shown in the example needs to go before the main Ammo Counter Code Code: class M55AssaultRifle extends BallisticWeapon; #exec OBJ LOAD FILE="..\Textures\Numbers.utx" (My Number Texture File) var() Material Number0; var() Material Number1; var() Material Number2; var() Material Number3; var() Material Number4; var() Material Number5; var() Material Number6; var() Material Number7; var() Material Number8; var() Material Number9; var() Material Number10; var() Material Number11; var() Material Number12; var() Material Number13; var() Material Number14; var() Material Number15; var() Material Number16; var() Material Number17; var() Material Number18; var() Material Number19; var() Material Number20; var() Material Number21; var() Material Number22; var() Material Number23; var() Material Number24; var() Material Number25; var() Material Number26; var() Material Number27; var() Material Number28; var() Material Number29; var() Material Number30; var() Material Number31; var() Material Number32; var() Material Number33; var() Material Number34; var() Material Number35; var() Material Number36; simulated event WeaponTick(float DT) { super.WeaponTick(DT); if (AIController(Instigator.Controller) != None && !IsGrenadeLoaded()&& AmmoAmount(1) > 0 && BotShouldReloadGrenade() && !IsReloadingGrenade()) LoadGrenade(); if (MagAmmo - BFireMode[0].ConsumedLoad == 36) { Skins[3]=Number36; } if (MagAmmo - BFireMode[0].ConsumedLoad == 35) { Skins[3]=Number35; } if (MagAmmo - BFireMode[0].ConsumedLoad == 34) { Skins[3]=Number34; } if (MagAmmo - BFireMode[0].ConsumedLoad == 33) { Skins[3]=Number33; } if (MagAmmo - BFireMode[0].ConsumedLoad == 32) { Skins[3]=Number32; } if (MagAmmo - BFireMode[0].ConsumedLoad == 31) { Skins[3]=Number31; } if (MagAmmo - BFireMode[0].ConsumedLoad == 30) { Skins[3]=Number30; } if (MagAmmo - BFireMode[0].ConsumedLoad == 29) { Skins[3]=Number29; } if (MagAmmo - BFireMode[0].ConsumedLoad == 28) { Skins[3]=Number28; } if (MagAmmo - BFireMode[0].ConsumedLoad == 27) { Skins[3]=Number27; } if (MagAmmo - BFireMode[0].ConsumedLoad == 26) { Skins[3]=Number26; } if (MagAmmo - BFireMode[0].ConsumedLoad == 25) { Skins[3]=Number25; } if (MagAmmo - BFireMode[0].ConsumedLoad == 24) { Skins[3]=Number24; } if (MagAmmo - BFireMode[0].ConsumedLoad == 23) { Skins[3]=Number23; } if (MagAmmo - BFireMode[0].ConsumedLoad == 22) { Skins[3]=Number22; } if (MagAmmo - BFireMode[0].ConsumedLoad == 21) { Skins[3]=Number21; } if (MagAmmo - BFireMode[0].ConsumedLoad == 20) { Skins[3]=Number20; } if (MagAmmo - BFireMode[0].ConsumedLoad == 19) { Skins[3]=Number19; } if (MagAmmo - BFireMode[0].ConsumedLoad == 18) { Skins[3]=Number18; } if (MagAmmo - BFireMode[0].ConsumedLoad == 17) { Skins[3]=Number17; } if (MagAmmo - BFireMode[0].ConsumedLoad == 16) { Skins[3]=Number16; } if (MagAmmo - BFireMode[0].ConsumedLoad == 15) { Skins[3]=Number15; } if (MagAmmo - BFireMode[0].ConsumedLoad == 14) { Skins[3]=Number14; } if (MagAmmo - BFireMode[0].ConsumedLoad == 13) { Skins[3]=Number13; } if (MagAmmo - BFireMode[0].ConsumedLoad == 12) { Skins[3]=Number12; } if (MagAmmo - BFireMode[0].ConsumedLoad == 11) { Skins[3]=Number11; } if (MagAmmo - BFireMode[0].ConsumedLoad == 10) { Skins[3]=Number10; } if (MagAmmo - BFireMode[0].ConsumedLoad == 9) { Skins[3]=Number9; } if (MagAmmo - BFireMode[0].ConsumedLoad == 8) { Skins[3]=Number8; } if (MagAmmo - BFireMode[0].ConsumedLoad == 7) { Skins[3]=Number7; } if (MagAmmo - BFireMode[0].ConsumedLoad == 6) { Skins[3]=Number6; } if (MagAmmo - BFireMode[0].ConsumedLoad == 5) { Skins[3]=Number5; } if (MagAmmo - BFireMode[0].ConsumedLoad == 4) { Skins[3]=Number4; } if (MagAmmo - BFireMode[0].ConsumedLoad == 3) { Skins[3]=Number3; } if (MagAmmo - BFireMode[0].ConsumedLoad == 2) { Skins[3]=Number2; } if (MagAmmo - BFireMode[0].ConsumedLoad == 1) { Skins[3]=Number1; } if (MagAmmo - BFireMode[0].ConsumedLoad == 0) { Skins[3]=Number0; } } defaultproperties { Number0=Combiner'Numbers.Final.00Final' Number1=Combiner'Numbers.Final.01Final' Number2=Combiner'Numbers.Final.02Final' Number3=Combiner'Numbers.Final.03Final' Number4=Combiner'Numbers.Final.04Final' Number5=Combiner'Numbers.Final.05Final' Number6=Combiner'Numbers.Final.06Final' Number7=Combiner'Numbers.Final.07Final' Number8=Combiner'Numbers.Final.08Final' Number9=Combiner'Numbers.Final.09Final' Number10=Combiner'Numbers.Final.10Final' Number11=Combiner'Numbers.Final.11Final' Number12=Combiner'Numbers.Final.12Final' Number13=Combiner'Numbers.Final.13Final' Number14=Combiner'Numbers.Final.14Final' Number15=Combiner'Numbers.Final.15Final' Number16=Combiner'Numbers.Final.16Final' Number17=Combiner'Numbers.Final.17Final' Number18=Combiner'Numbers.Final.18Final' Number19=Combiner'Numbers.Final.19Final' Number20=Combiner'Numbers.Final.20Final' Number21=Combiner'Numbers.Final.21Final' Number22=Combiner'Numbers.Final.22Final' Number23=Combiner'Numbers.Final.23Final' Number24=Combiner'Numbers.Final.24Final' Number25=Combiner'Numbers.Final.25Final' Number26=Combiner'Numbers.Final.26Final' Number27=Combiner'Numbers.Final.27Final' Number28=Combiner'Numbers.Final.28Final' Number29=Combiner'Numbers.Final.29Final' Number30=Combiner'Numbers.Final.30Final' Number31=Combiner'Numbers.Final.31Final' Number32=Combiner'Numbers.Final.32Final' Number33=Combiner'Numbers.Final.33Final' Number34=Combiner'Numbers.Final.34Final' Number35=Combiner'Numbers.Final.35Final' Number36=Combiner'Numbers.Final.36Final' } ![]() ![]() How it should look ingame. (Shots are for Demonstrations only, I don't plan on releasing anything right now.) This is not the most effective method IMO. Its gonna be a pain in the arse to make a Machine-gun that has a 200 ammo count then. However its the only one I was able to make and use with any success. I tried doing it like how YARM did it for their weapons but it was in vain. If someone can find a better and more efficient method, go ahead and post about it. |
|
| Author: | wantwon [ Wed Dec 14, 2011 11:15 am ] |
| Post subject: | Re: Ammo Counters for BW Weapons. |
That looks like a pain in the arse to code, but it works. I don't know much about coding in unreal engine so I can't help you here, nice work btw. |
|
| Author: | Blade sword [ Wed Dec 14, 2011 2:02 pm ] |
| Post subject: | Re: Ammo Counters for BW Weapons. |
I'm not expert coder but I think there is probably way to use individual digits, though I know why you told me there might be a problem with high counters. I watched the mars wars mod and the Yarm mod and the numbers were all single digits. They only need 10 numbers, (0,1,2,3,4,5,6,7,8,9) and they do the whole thing. Second what I understood I think you can summon textures with probably 30 summons for any counter (between 0 up to 999) and 20 if it doesn't exceed 99, but I wonder if the said texture can be placed in the right place too for my raygun for example there is no problem with because it uses individual screens, but for weapons with an uniform screen that might be a problem though that's looks great nonetheless |
|
| Author: | CMGuy [ Wed Dec 14, 2011 4:25 pm ] |
| Post subject: | Re: Ammo Counters for BW Weapons. |
Blade sword wrote: I'm not expert coder but I think there is probably way to use individual digits, though I know why you told me there might be a problem with high counters. I watched the mars wars mod and the Yarm mod and the numbers were all single digits. They only need 10 numbers, (0,1,2,3,4,5,6,7,8,9) and they do the whole thing. Second what I understood I think you can summon textures with probably 30 summons for any counter (between 0 up to 999) and 20 if it doesn't exceed 99, but I wonder if the said texture can be placed in the right place too for my raygun for example there is no problem with because it uses individual screens, but for weapons with an uniform screen that might be a problem though that's looks great nonetheless Yeah, I tried doing the single digits using their method using one of the BW weapons (I used both the scope and the weapon itself as a test for this) but it doesn't seem to work with the BW weapons sadly... So I tried something else. I did it for the whole materiel map instead and tested it on the M50's Cam Screen, but it also has its downsides like loading each number(weaker Processors are out) and having to make each texture for each number, but at the very least it works. And I made sure the textures are correlating to each other. At least there is someway of doing it rather than none at all. Still anything that is better than what I have would be great. |
|
| Author: | Captain Xavious [ Wed Dec 14, 2011 4:50 pm ] |
| Post subject: | Re: Ammo Counters for BW Weapons. |
Well, I think this could be useful, with some modifications to models in mind. Suppose there was a seperate texture in place for each digit, and you just replaced each texture with an appropriate number, using only 0-9. This could totally work. Only problem would be figuring out a simple formula to get the 10s and 1s values, though that probably wouldn't be too difficult. |
|
| Author: | CMGuy [ Wed Dec 14, 2011 4:53 pm ] |
| Post subject: | Re: Ammo Counters for BW Weapons. |
Captain Xavious wrote: Well, I think this could be useful, with some modifications to models in mind. Suppose there was a seperate texture in place for each digit, and you just replaced each texture with an appropriate number, using only 0-9. This could totally work. Only problem would be figuring out a simple formula to get the 10s and 1s values, though that probably wouldn't be too difficult. Yes, it could work, I don't know how to since I can't use YARM's method. But nevertheless I'll see what I can think of. If nothing else works though I'll stick to the one I've got.... better than nothing. |
|
| Author: | Sgt. Kelly [ Wed Dec 14, 2011 5:06 pm ] |
| Post subject: | Re: Ammo Counters for BW Weapons. |
Oh my, this is definitely the brute force method! I didn't consider this method because it would bloat texture file size by a lot, especially when put on a gun that can hold in excess of 50 bullets. When I get time I'm going to be looking at the HUD code to see if that can be modified for use on texture planes while still looking reasonable. |
|
| Author: | CMGuy [ Wed Dec 14, 2011 5:09 pm ] |
| Post subject: | Re: Ammo Counters for BW Weapons. |
Yes please do, anything better than my Monstrosity of a Code would be very much great... |
|
| Author: | Captain Xavious [ Wed Dec 14, 2011 5:18 pm ] |
| Post subject: | Re: Ammo Counters for BW Weapons. |
CMGuy wrote: Yes, it could work, I don't know how to since I can't use YARM's method. But nevertheless I'll see what I can think of. If nothing else works though I'll stick to the one I've got.... better than nothing. I worded it wrong, I mean you could probably apply a separate material/uv map/texture/miniature screen for each digit (so you got a couple squares floating in front of the main screen) and then set its texture to one appropriate for the value. Then you would simply need to define textures for 0-9, and apply that texture to the smaller digit screen for each place, so if you have 26 bullets, you would break it down to find out what the 10s place digit is (2) and apply it to mini screen #1, then find 8 and apply it to mini screen #2. |
|
| Author: | Black Eagle [ Fri Dec 16, 2011 8:40 am ] |
| Post subject: | Re: Ammo Counters for BW Weapons. |
That is quite a cumbersome method there!.... The best way is to take a single texture with the numbers 0-9 on it... Then you give the screen on your weapon a Scripted Texture... This scripted texture then allows you to render on it in the same way you do a HUD, with this you can draw any graphics you want on the weapon's screen(Scripted Texture), including a tile clipping method that takes the number texture and renders the correct numbers next to each other... You don't need to have a separate texture for each number, you just need to clip the part of the texture you want to render... Its the same way the weapon icons on the weapon selection bar work, and a bunch of other things... Scripted Textures can sometime be tricky, but many things use them, the M50's default camera screen for one, which renders a screenshot of another point in the world onto the gun's screen texture... |
|
| Author: | Sgt. Kelly [ Fri Dec 16, 2011 5:34 pm ] |
| Post subject: | Re: Ammo Counters for BW Weapons. |
Ooh, I didn't even think about scripted textures! That should be quite easy to do, since like you said, it's similar to the HUD stuff. I bet I could use a modulus to easily parse the numbers too. Gracias senor. |
|
| Author: | Black Eagle [ Sat Dec 17, 2011 2:56 am ] |
| Post subject: | Re: Ammo Counters for BW Weapons. |
No problema... I don't remember exactly what I did to create a number splitter, but its pretty easy, lets see... First thing you'll want is to create a 10 length static array of some variable that holds 4 floats or ints, otherwise you can create your own struct for this... The 4 values represent: X Clip Position, Y Clip Position, X Clip Size, Y Clip Size... These represent the different positions and sizes of the numbers on your texture. You can then easily use these values in the clipping process to correctly calculate the clipping regions... Then lastly you will need a means to calculate the current ammo count to return the correct clipping regions to use... This shouldn't be too hard, using some string functions will likely make it much easier... Once you've done these things, rendering it is a piece of cake, you simple render the correct numbers next to each other in the right order to correctly represent the current ammo count... |
|
| Author: | DarkCarnivour [ Sat Dec 17, 2011 8:34 am ] |
| Post subject: | Re: Ammo Counters for BW Weapons. |
Ouch! That's quite a brutal technique. I would do it pretty much the same way BE recommended, but instead of using an array of coords, just offset the starting coord depending on the digit. That'll work if your digit texture has the digits simply arrayed vertically or horizontally. To calculate the tens digit: Code: Tens = int(Ammo / 10); To calculate ones use: Code: Ones = Ammo % 10.0 or if UE2 doesn't have modulo (I don't remember if it did): Code: Ones = Ammo - (10 * int(Ammo / 10.0)) A nice simple, fun project this one, I remember it being fun to implement in The Crucible. P.S. Your screen looks pretty cool in the screenshots. |
|
| Author: | Black Eagle [ Sat Dec 17, 2011 9:31 am ] |
| Post subject: | Re: Ammo Counters for BW Weapons. |
This is true, if the digits are evenly spaced, you won't need an array of independent coords, you just multiply the position by the desired number... And as you can see the maths are really simple, I clearly was no thinking well when I mentioned strings to split up the amount!... |
|
| Author: | CMGuy [ Fri Jan 13, 2012 1:38 pm ] |
| Post subject: | Re: Ammo Counters for BW Weapons. |
I think I found a solution. I got some hints from you guys as well as around the UT community and this is what I came up with. Thanks for the tips! This one is for two separate Textures for the two digits. These are directly applied to the two separate textures... assuming they are both the same shape and size and are placed evenly. These two textures represent the two digits, one being the ones place, the other being on the tenths place. Code: var material DigitTexture[10]; *The digits* simulated event WeaponTick(float dt){ local int OnesPlace, TenthsPlace, ClipAmount, dir; super.weaponTick(dt); if(pawn(owner) == none) return; if(Instigator.IsFirstPerson()) { ClipAmount = (MagAmmo - BFireMode[0].ConsumedLoad); OnesPlace = ClipAmount%10; *Divide by ten and take the remainder. BASIC MATH.* TenthsPlace = (ClipAmount-OnesPlace)/10; *Subtract the remainder and divide by ten. BASIC MATH.* Skins[*Insert Skin Number Here*]=DigitTexture[OnesPlace]; Skins[*Insert Skin Number Here*]=DigitTexture[TenthsPlace]; } defaultproperties { DigitTexture(0)= DigitTexture(1)= DigitTexture(2)= DigitTexture(3)= DigitTexture(4)= DigitTexture(5)= *Insert your skins here as needed* DigitTexture(6)= DigitTexture(7)= DigitTexture(8)= DigitTexture(9)= } For Single Textures if you like. Code: var material DigitTexture[11]; *The Number needs to be at least one value higher than the max clip amount* simulated event WeaponTick(float dt) { local int NumberSlot, dir; super.WeaponTick(DT); if(pawn(owner) == none) return; if(Instigator.IsFirstPerson()) { NumberSlot = (MagAmmo - BFireMode[0].ConsumedLoad); Skins[*Insert your Number Here*]=DigitTexture[NumberSlot]; } } defaultproperties { DigitTexture(0)= DigitTexture(1)= DigitTexture(2)= DigitTexture(3)= DigitTexture(4)= DigitTexture(5)= *just insert your skins as usual* DigitTexture(6)= DigitTexture(7)= DigitTexture(8)= DigitTexture(9)= DigitTexture(10)= } They Should both work, as I tried these in-game. So Much better than my old junkie one thats for sure, but still, its great to have some feedback nevertheless. There is one problem though, trying to get more than two digits... then again, its just me lacking proper math skills.... Oh and DC, UE2 does have the modulo bit so I used the first method you posted. |
|
| Author: | Sgt. Kelly [ Mon Jan 23, 2012 8:17 pm ] |
| Post subject: | Re: Ammo Counters for BW Weapons. |
Well, after a little bit of experimenting I have succeeded in making the weapon screen on a gun green! DrawTile (float X, float Y, float XL, float YL, float U, float V, float UL, float VL, Material Material, Color Color) looks like the command I want, so the gun's calling: Tex.DrawTile(0,0,256,256,256,256,0,0,ScreenBase, MyFontColor); Either I have my ScreenBase somewhere outside my texture or the almighty MyFontColor is too strong for it. Let's see what I can do after some more experimenting. Edit: Great, it looks like non-optional Color completely overwrites whatever material you use. That is not useful at all. I guess we can all pretend the weapons have Blue Screens of Death or something. Edit 2: Nevermind, I had the texture hidden. |
|
| Page 1 of 1 | All times are UTC - 6 hours |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|