PDA

View Full Version : HUDMutators... Whose HUD is this?


Shiit
15th Nov 2001, 12:14 PM
I have need to modify a HUD with a mutator, but I stumbled upon a problem. The only variable passed to the PostRender function is the canvas you get to draw on, and I need to know which player it belongs to. Is there any way to find out?
Also, I need to remove the weapons bar+ammo icon from the HUD for all players (even in a Net-game). Is this possible?

Captain Kewl
15th Nov 2001, 01:00 PM
Canvas.Owner?

Shiit
15th Nov 2001, 01:08 PM
I hadn't even thought of that, but it doesn't work. Canvas is not a subclass of Actor, so it doesn't have an Owner variable. :(

BTW, I just realized that it probably won't be necessary to use the mutators Postrender() function, as I might be able to use the weapon's. I'll see into it.

(EDIT) Cool, it works! Thanks for your time anyway :)

usaar33
15th Nov 2001, 07:10 PM
canvas.viewport.actor
is valid.

Brood_of_Evil
15th Nov 2001, 09:18 PM
It's funny because until yesterday I had the same problem. I needed a reference to a Pawn object in the same function, to compare it with the instigator of a projectile..anyways, what I did was do an foreach AllActors iteration, the look for each pawn's inventory looking for the weapon that is supposed to spawn such projectile, if they had the weapon, then I would compare it the weapon instigator was the same as the owner of the weapon...it worked well for me, but until now I didn't knew there was a reference for an actor object in canvas...I do know there is such a variable in ChallengeHUD, but this was not the case. Anyways it's always good to learn new things.

Brood_of_Evil
15th Nov 2001, 11:00 PM
Btw, is it really possible to implement PostRender in anything other than a HUD class or a mutator, I'm using it inside a mutator, but I want to implement it in a projectile class. If it's possible, how can I receive post render calls within this class?

Shiit
16th Nov 2001, 01:25 PM
Lots of classes have a postrender function, but I don't know if you can just add one. It might be worth a try to just add a "simulated event PostRender(canvas C)" to the class, but I don't know if it'll work. If that doesn't work you'll have to make a workaround to have the weapon that fires the projectiles call it once for each projectile. (That's only a bit more complicated than what the Redeemer does with the red readouts to the left in remote-control-mode)

usaar33
16th Nov 2001, 08:11 PM
postrender is called on the playerpawn and console.
The playerpawn calls it on the HUD.
The HUD (if certain conditions are met) will call postrender() on the owner's weapon and any hudmutators.
The console will render uwindows if needed.

Lemoni
18th Nov 2001, 05:10 AM
the ammo count bar on the icons?
how do i make it verticle instead of horizental?

Brood_of_Evil
18th Nov 2001, 05:13 AM
I think you would have to alter the texture, flip it 90 degrees or something, then you would have to remake the whole canvas, unless there's a way to rotate textures in the canvas or hud classes

Lemoni
18th Nov 2001, 05:18 AM
i was thinking of redrawing the icons so the band when vert but i dont know how to get the code to work the band

Shiit
18th Nov 2001, 01:39 PM
Check out this function:
native(466) final function DrawTile( texture Tex, float XL, float YL, float U, float V, float UL, float VL );
In here, Tex is the graphic that has the bar, XL and YL are the size on-screen, U and V are the top-left coördinates of the tile you want to draw (on Tex, that is) and UL and VL is the size of the tile on Tex.
So, if you made a 256*256 texture that has the vertical bar in the top left corner, you'd want to do this:

DrawTile( Texture'Somepackage.Sometexture', 8, 128*(Length of bar), 0,0, 8, 128 );

I hope that clears things up.

Lemoni
19th Nov 2001, 12:27 PM
cool i think thanks
its that from a script ,if so what script

Shiit
19th Nov 2001, 03:17 PM
I found the function description in the Canvas class (<--subclass of Object). The example was just something logical I thought up, but you can find lots of similar code in the ChallengeHUD class. I'm currently using a PC that I don't use for Uscripting, so I can't really give you the exact location of good example code.

Lemoni
21st Nov 2001, 12:17 PM
Originally posted by Shiit
I found the function description in the Canvas class (<--subclass of Object). The example was just something logical I thought up, but you can find lots of similar code in the ChallengeHUD class. I'm currently using a PC that I don't use for Uscripting, so I can't really give you the exact location of good example code.
cool if any one interested hears the bit in challange hud class
// Draw Ammo bar
Canvas.CurX = WeaponX;
Canvas.CurY = BaseY + 52 * WeapScale;
Canvas.DrawColor = BaseColor;
AmmoScale = FClamp(88.0 * WeapScale * WeaponSlot[i].AmmoType.AmmoAmount/WeaponSlot[i].AmmoType.MaxAmmo, 0, 88);
Canvas.DrawTile(Texture'BotPack.HudElements1', AmmoScale, 8 * WeapScale,64,64,128.0,8.0);
}
}
}
}

Silver_Ibex
21st Nov 2001, 01:56 PM
Nothing fancy :D
Just code for two bar graphs, one on the right side of the screen and one on the left, nothing else.

Left hand side bar graph needs to be red, will represent characters health from 0 to 199.

Right side bar graph needs to be blue and will be set to a new character attribute “Energy” it also needs to be able to display a 0 to 199 value.

Thought I would ask here, as it seems similar to what you are talking about.

Shiit
21st Nov 2001, 03:51 PM
That's very easy. You should be able to figure it out yourself by looking at the ChallengeHUD (I did, and it took me only a few minutes). Create a subclass of the good ol' ChallengeHUD and put a new PostRender. Just don't forget to call Super.Postrender!
If you want I might be able to write a short tutorial on info bars (it'd be my first! yay!), but not today, it's getting kinda late.

Silver_Ibex
21st Nov 2001, 04:55 PM
Yes a tutorial is always a good thing :cool: especially for those like me who are not yet well versed in U-script.

I will try to get around to modifying the HUD for myself with the above info, though right now I’m unsuccessfully messing with the Relic mutator classes.

Shiit
22nd Nov 2001, 02:09 PM
I finished the tutorial and sent it to Chimeric. I hope it'll be up sometime soon.