PDA

View Full Version : Shader + Text/value



Earliboy
10th April 2013, 13:36
Hello,
i don't wanna waste hudelems so i want to use a shader + an value


self.healthbar_cross = newClientHudElem(self);
self.healthbar_cross setShader("gfx/hud/hud@health_cross.tga", 10, 10);
self.healthbar_cross.alignX = "right";
self.healthbar_cross.alignY = "top";
self.healthbar_cross.sort = 9001;
self.healthbar_cross.x = x - 20;
self.healthbar_cross.y = y2 - 15;

I want to add self.healthbar_cross setValue(self.preHealth);
But if i do that, the shader doesnt shows anymore.

Any ideas? Or is it just not possible?
And no, i don't want to use another hudelem cause the elem limit for players (thats just useless :/ )

IzNoGoD
10th April 2013, 14:57
Either:

.label + settext/setvalue

OR

setshader

Nothing else.

Create another hud for the text.

Tally
10th April 2013, 15:44
Hello,
i don't wanna waste hudelems so i want to use a shader + an value


self.healthbar_cross = newClientHudElem(self);
self.healthbar_cross setShader("gfx/hud/hud@health_cross.tga", 10, 10);
self.healthbar_cross.alignX = "right";
self.healthbar_cross.alignY = "top";
self.healthbar_cross.sort = 9001;
self.healthbar_cross.x = x - 20;
self.healthbar_cross.y = y2 - 15;

I want to add self.healthbar_cross setValue(self.preHealth);
But if i do that, the shader doesnt shows anymore.

Any ideas? Or is it just not possible?
And no, i don't want to use another hudelem cause the elem limit for players (thats just useless :/ )

There is no point writing a health bar hud element as their is a stock one. It was never eneabled because Infinity Ward decided to abandon the old COD1 health system and go with the regeneration health system instead. The only thing you have to do with a health bar is:

1. Decide where it is going to go;
2. Set the client cvars so that it will show.

1. To determine where the health bar will go, look in ui_mp/hud.menu and search for "health bar". You will find this:


// HEALTH BAR
menuDef
{
name "Health"
fullScreen MENU_FALSE
visible MENU_TRUE
rect -152 -20 0 0 HORIZONTAL_ALIGN_RIGHT VERTICAL_ALIGN_BOTTOM

itemDef
{
name "healthbarback"
rect 13 0 130 12
forecolor 1.0 1.0 1.0 1.0
background "gfx/hud/hud@health_back.tga"
ownerdraw CG_PLAYER_BAR_HEALTH_BACK
visible MENU_TRUE
decoration
}
itemDef
{
name "healthbar"
rect 14 1 128 10
forecolor 0.7 0.4 0.0 1.0
background "gfx/hud/hud@health_bar.tga"
ownerdraw CG_PLAYER_BAR_HEALTH
visible MENU_TRUE
decoration
}
itemDef
{
name "healthbarcross"
rect 0 0 12 12
forecolor 1.0 1.0 1.0 1.0
background "gfx/hud/hud@health_cross.tga"
ownerdraw CG_PLAYER_BAR_HEALTH_BACK
visible MENU_TRUE
decoration
}
}


Those are the stock settings. I changed them in my Demon mod to these:


// HEALTH BAR
menuDef
{
name "Health"
fullScreen MENU_FALSE
visible MENU_TRUE
rect 45 448 640 40
itemDef
{
name "healthbarback"
rect 557.5 12 90 7
forecolor 1.0 1.0 1.0 1.0
background "gfx/hud/hud@health_back.tga"
ownerdraw CG_PLAYER_BAR_HEALTH_BACK
visible MENU_TRUE
decoration
dvartest "scr_demon_hardcore"
showDvar { "0" }
}
itemDef
{
name "healthbar"
rect 558.5 13 88 5
forecolor 0.7 0.4 0.0 1.0
background "gfx/hud/hud@health_bar.tga"
ownerdraw CG_PLAYER_BAR_HEALTH
visible MENU_TRUE
decoration
dvartest "scr_demon_hardcore"
showDvar { "0" }
}
itemDef
{
name "healthbarcross"
rect 545 11 10 10
forecolor 1.0 1.0 1.0 1.0
background "gfx/hud/hud@health_cross.tga"
ownerdraw CG_PLAYER_BAR_HEALTH_BACK
visible MENU_TRUE
decoration
dvartest "scr_demon_hardcore"
showDvar { "0" }
}
}


This places the health bar here:

http://imageshack.us/a/img811/7900/shot0003ml.jpg

(lower right-hand corner in green).

2. To enable the health bar, just set 2 cvars on the client:


self setClientCvar( "cg_drawhealth", "1" );
self setClientCvar( "hud_fade_healthbar", "0" );

That's all you have to do. Believe me - the stock health bar is far superior to anything you can script because it glows and pluses when the player is damaged in a way that would be difficult to script.

Earliboy
10th April 2013, 17:26
Well, my healthbar is working good and fine. I just wanted to change the value of health to the cross shader so u can see your actually health as value.
I allready done that but i use another extra hudelem for that.

But thanks for your answers.

Tally
10th April 2013, 17:37
Well, my healthbar is working good and fine. I just wanted to change the value of health to the cross shader so u can see your actually health as value.
I allready done that but i use another extra hudelem for that.

But thanks for your answers.

Before I learnt there was a stock healthbar I too wrote one. It too worked good and fine. Only problem is, it 1) takes up valuable client assets (there is a limit on hud elements and it is not a good idea to use one when you don't need to), and 2) the stock one works better than "good and fine".

Your choice, but I always believe there is no point in re-inventing the wheel unless you really have to.

Earliboy
11th April 2013, 09:59
Ye i could use that one, but i don't want the healthbar at the bottom of the screen, its just too small it nobody cares about it.
I wanted it like this.

(The problem was the Cross + the value on the top of the bar). Now i used shader + new hudelem
215