Sbar_DrawFace question
Sbar_DrawFace question
Hi!
I have edited my HUD in darkplaces, all works fine except the little animation for the gfx/face!
It only changes to face1, face2, face3, face4, face5, it misses the face_p1, face_p2, face_p3, face_p4, face_p5 when i get hit!
Maybe someone can help, would be great
Here is what i got:
health = GetStat_FLOAT_TRUNCATED(STAT_HEALTH);
if (health < 0)
health = 0;
if (health >= 100)
f = 4;
else
f = floor(health / 20);
Sbar_DrawPic('-208 24 0', strcat("gfx/face", ftos(5 - f)), ALPHA_FULL, 1);
I have edited my HUD in darkplaces, all works fine except the little animation for the gfx/face!
It only changes to face1, face2, face3, face4, face5, it misses the face_p1, face_p2, face_p3, face_p4, face_p5 when i get hit!
Maybe someone can help, would be great
Here is what i got:
health = GetStat_FLOAT_TRUNCATED(STAT_HEALTH);
if (health < 0)
health = 0;
if (health >= 100)
f = 4;
else
f = floor(health / 20);
Sbar_DrawPic('-208 24 0', strcat("gfx/face", ftos(5 - f)), ALPHA_FULL, 1);
Re: Sbar_DrawFace question
dp has dmg_take, dmg_save, dmg_origin globals in its csqc.
if take or save is set, make a note of the time and if it happened within the last second or so, insert an extra _p into the drawpic image name.
if take or save is set, make a note of the time and if it happened within the last second or so, insert an extra _p into the drawpic image name.
Re: Sbar_DrawFace question
thanks for your help but im a newbie.
how can i set this dmg_values and where to put them?
its annoying i know, sorry!
how can i set this dmg_values and where to put them?
its annoying i know, sorry!
-
- Posts: 14
- Joined: Sun Oct 19, 2014 2:37 am
Re: Sbar_DrawFace question
This is just an example poorly written but you can clean it up:
dmg_take is the global value Spike mentioned. Hope this helps.
Code: Select all
// Global
float dmg_take;
float dmg_save;
float dmg_origin;
float PainTime;
// Put this or something similar in your HUD display function.
// Local
string Icon
Health = getstati(STAT_HEALTH);
if(dmg_take)
PainTime = time + 0.3;
if(Health < 20)
{
if(PainTime > time)
Icon = "gfx/face_p5";
else
Icon = "gfx/face5";
}
else if(Health < 40)
{
if(PainTime > time)
Icon = "gfx/face_p4";
else
Icon = "gfx/face4";
}
else if(Health < 60)
{
if(PainTime > time)
Icon = "gfx/face_p3";
else
Icon = "gfx/face3";
}
else if(Health < 80)
{
if(PainTime > time)
strIcon = "gfx/face_p2";
else
strIcon = "gfx/face2";
}
else
{
if(PainTime > time)
Icon = "gfx/face_p1";
else
Icon = "gfx/face1";
}
Sbar_DrawPic('-208 24 0', Icon, ALPHA_FULL, 1);
Re: Sbar_DrawFace question
*YOU* don't. The engine sets them.smd wrote:how can i set this dmg_values
Somewhere in your csqc's defs, define them as:
Code: Select all
float dmg_take, dmg_save; //engine-set
float dmg_time; //qc-set
Code: Select all
if (dmg_take || dmg_save)
dmg_time = time + 0.1;
Code: Select all
Sbar_DrawPic('-208 24 0', strcat("gfx/face", (dmg_time > time)?"_p":"", ftos(5 - f)), ALPHA_FULL, 1);
Code: Select all
Sbar_DrawPic('-208 24 0', strcat("gfx/face", (dmg_time > time)?"_p":"", ftos(5 - floor(bound(0, GetStat_FLOAT_TRUNCATED(STAT_HEALTH)/20, 4)))), ALPHA_FULL, 1);
Re: Sbar_DrawFace question
thank you very much both of you guys!
it works great now!
nice
it works great now!
nice
-
- Posts: 1395
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
Re: Sbar_DrawFace question
Wow.Didn't know that. Is it the same for FTEQW? Does FTE set them too?Spike wrote:*YOU* don't. The engine sets them.
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Re: Sbar_DrawFace question
no. they are fields in ssqc and thus I refuse to make them non-fields in csqc as it would force inconsistancies.
I'll add a CSQC_Parse_Damage as compensation, allowing you to emulate it (or easily inhibit it).
I'll add a CSQC_Parse_Damage as compensation, allowing you to emulate it (or easily inhibit it).
-
- Posts: 1395
- Joined: Tue Feb 24, 2009 4:39 pm
- Location: Italy
Re: Sbar_DrawFace question
yeah, imo what FTEQW really needs is documentation: a solid documentation that explains in details all the CSQC_ builtin fuctions, one by one. I'm trying to do it by myself but I'm too noob to do the task all on my own. Because, for what I understood, the power of CSQC_ builtins is that you can use them as class-parented methods in Object-Oriented languages. If you let them unchanged, the default method will be applied. If you modify it, you'll ovveride default method. Which it's awesome, imo, but maybe that'd need a little documentation more
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Re: Sbar_DrawFace question
That code works great Primallove, thank you.