Forum

What do you guys think ?

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

What do you guys think ?

Postby frag.machine » Mon Mar 07, 2011 1:33 am

I am working on that HUD scripting support, and it's quite functional ATM. However, I must say I am not happy with the results. Why, you may ask ?

Well, when I started it, I was aiming for something simple to implement and use even in vanilla GLQuake. But if you think about it for a while, you'll see that the actual problem is more complex than looks at first.

Example: the health inidicator from the original sbar. If your health drops below 25 points, it uses the red digits, otherwise, the normal ones. How to implement this with a simple to use hud script language ? I have something that works more or less like this:
Code: Select all
hud if $health < 25 goto use_red_digits
hud font 2
hud print 20 20 $health
hud break
hud label use_red_digits
hud font 3
hud print 20 20 $health
hud break


Where $health is the client's health, font 2 and font 3 are the regular 12x12 number and its red version, respectively.

This is a simple problem, however what if we wanted to draw, let's say, a graphic colored bar ? Things will get more complicated, and soon I found myself implementing a full featured client side script language, with conditionals, loops and vars. And even with all this added complexity, I always can think in something that would be cool to implement but would require more programming capability. I am not happy with this approach. I want something SIMPLE.

The alternative to that is to delegate all flux control to the server, using QuakeC to spam stuffcmd() when required. That would turn the problem above in something like:

Code: Select all
void () updateHUDHealth =
{
    if (self.health < 25)
    {
      stuffcmd ("hud font 3\n");
    }
    else
    {
      stuffcmd ("hud font 2\n");
    }

    stuffcmd ("hud print 20 20 ");
    stuffcmd (ftos (self.health));
    stuffcmd ("\n");
};


The problem with that is obviously the judicious use of stuffcmd() to interact with the HUD. I already can see some people shuddering with the idea. :D

So, what do you guys think about this ? Should I keep working in this client side scripting language, or should only implement a bare bones console command and delegate all control to server side QuakeC ?
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby Baker » Mon Mar 07, 2011 3:41 am

Frag.machine, here is my thought ... I think your HUD scripting should live in a hudinfo.txt file or some such thing and be disattached from QuakeC kind of like effectsinfo.txt. I mean map or a progs.dat lives in a gamedir folder.

And I think your HUD scripting could quickly create a boom in people wanting to make their own HUDs or do experimentation. It need not be as complex as sbar.c. Anything is more than what we got now and CSQC is a bit steep of a challenge at the moment IMHO for beginners.

I could easily imagine running some contests with your new HUD scripting or the PSP guys playing around with it.

Anyway, my 2 cents ... right, wrong or even way off base.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby Mexicouger » Mon Mar 07, 2011 3:52 am

I'd rather do it the hard way and Manually code the HUD in sbar.c. Not very hard to do.
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby dreadlorde » Mon Mar 07, 2011 4:09 am

goto in hud scripting language? :p

Just hard code it.
Ken Thompson wrote:One of my most productive days was throwing away 1000 lines of code.

Get off my lawn!
User avatar
dreadlorde
 
Posts: 268
Joined: Tue Nov 24, 2009 2:20 am

Postby mankrip » Mon Mar 07, 2011 7:48 am

If you want to make it simple to use, strip any unecessary complexity out of it. This includes the red digits, the animations in the HUD icons, and so on.

And don't make a scripting language, make a definition language that reads values for stuff like "display this icon at that position when this variable has that value". Example:

Code: Select all
icon shotgun
{
file "gfx.wad"
image "shotty"
x_position 30
y_position 180
variable self.items
condition &
value IT_SHOTGUN
}

icon pause
{
file "gfx/pause.lmp"
x_position center
y_position top
variable cl_paused
condition is
value true
}

icon intermission
{
file "gfx/inter.lmp"
x_position center
y_position top
variable sv_intermission
condition is
value true
}

hud ingame
{
icon shotgun
}

hud intermission
{
icon intermission
}

hud pause
{
icon pause
hud ingame
}
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
User avatar
mankrip
 
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am

Postby gnounc » Mon Mar 07, 2011 8:10 am

hud css lol.
I'd like to see that, I've wanted to do hud work but have never bothered. I think if hud css existed I'd jump at it.
User avatar
gnounc
 
Posts: 424
Joined: Mon Apr 06, 2009 6:26 am

Postby frag.machine » Mon Mar 07, 2011 12:18 pm

@Baker: I see your point: better have something not so flexible than nothing.

@mk: I liked the idea; gives some flexibility at the same time doesn't become a full interpreter.

I'll think a bit more about, you guys surely helped. Thanks to all.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby mh » Mon Mar 07, 2011 1:16 pm

Mexicouger wrote:I'd rather do it the hard way and Manually code the HUD in sbar.c. Not very hard to do.

True enough, but not very flexible for mods either. You just have to look at the mess that is the Hipnotic and Rogue (especially Hipnotic) code to know that. Staying with sbar.c basically means that every mod that wants to use a slightly different HUD layout, or add/remove elements, needs an engine update. Best of luck co-ordinating that across all engines.

I guess it's OK if what you're working on is a specific mod that uses a specific engine. When it's not OK is when you're working on a mod that you want to run on all (or as many as possible) engines, or an engine that you want to run all (or as many as possible) mods. Sometimes you just got to look outside of your own personal immediate needs.

Aside from anything else code like this has no business being in an engine (the same goes for menu.c, r_part.c and good chunks of cl_tent.c, by the way).

It's a shame that CSQC is so complex and over-engineered. If it was possible to cut it down to the bare bones - i.e. a basic client-side scripting language that just ran some code, as opposed to this monster that interacts with entities and protocols and does a hostile takeover of so much of the engine, then we would have had widespread uptake of it by now and none of this would be necessary.

The fact that it's heavily documented from the mod-makers perspective, but not even remotely documented at all from the engine coder's perspective doesn't help matters either.

Anyway, I like the idea of a HUD CSS language. It seems a good compromise between flexibility and simplicity, and it would be a good idea to start bashing out requirements.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby TimeServ » Tue Mar 08, 2011 11:37 pm

mh wrote:It's a shame that CSQC is so complex and over-engineered. If it was possible to cut it down to the bare bones - i.e. a basic client-side scripting language that just ran some code, as opposed to this monster that interacts with entities and protocols and does a hostile takeover of so much of the engine, then we would have had widespread uptake of it by now and none of this would be necessary.


For something that does client-side coding in sync with how Quake works entities I think the heavy engine modding is just unavoidable. On the other hand I'd think most QC modders just want a few temporary effects and a HUD change up. For temporary effects I think CSQC isn't so bad for the QC itself but for a HUD you have to redo the whole positioning and formatting digits which sucks. You don't gain any enhancements for HUDs that engines may provide either unless it's reimplemented in the QC.

I have to say though I don't think of CSS as something simple... but now that I think if it maybe something like that could be used as a MenuQC alternative as well.
TimeServ
 
Posts: 38
Joined: Wed Jun 08, 2005 4:02 pm

Postby Spike » Wed Mar 09, 2011 2:21 am

Q2 has a scripted sbar. move x,y; pic foo, etc. its a bit limited in what it can do, and it depends upon precache_pic type stuff from the gamecode in order to function, but it gets the job done.

regarding csqc, one of the design features is that you can use it to draw models and stuff for the hud if you so choose. What you gain in simplicity you loose in versitility. I agree there could be a few more helper builtins, just as there could be a helper qc lib, but 200 builtins instead of ~50 extras hinders any sort of efforts for compatibility.
is the theory anyway.
if the engine were a little cleaner, a 'hostile takeover' would be somewhat less 'hostile'. I mean, if you don't want to add all the various hooks and protocol adaptations and entity handling then you don't have to. but if you don't, what the heck is the use of any of it?
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby leileilol » Wed Mar 09, 2011 2:25 am

And here's the Q3TA example (okay, so i lied, it's OATA). It builds this hud. It always assumes a virtual 640x480 screen space. (and in DP CSQC, doing huds is quite annoying as you also have to throw in conditions for a 16:10/16:9 aspect or it'll crop your sbar off)

RTCWMP does the same approach, but they hardcode the timer and the compass in cgame
i should not be here
leileilol
 
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Postby Mexicouger » Wed Mar 09, 2011 3:34 am

While we are on the Subject of HUD coding, how hard would it be to create a bulitin that Draws an image? I just feel that it wouldn't be that hard to do, But could be wrong.

Just an idea
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby mh » Wed Mar 09, 2011 10:12 am

Mexicouger wrote:While we are on the Subject of HUD coding, how hard would it be to create a bulitin that Draws an image? I just feel that it wouldn't be that hard to do, But could be wrong.

Just an idea

QC builtins run on the server but images are drawn on the client, so so you need to define some protocol changes for it and work on the basis that latency is gonna be unavoidable (even SP games have some latency in Quake).
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby Spike » Wed Mar 09, 2011 12:33 pm

telejano has some builtins to add/remove pics on the client (relative to some part of the screen). Doesn't support animations, so each change/tweek/etc requires a call in ssqc.
You can't do UIs with it, but huds can work. Assuming you force the user's viewsize to 120 to get rid of the engine's default hud (required if you want something that could potentially work with multiple engines via the same extension). Its somewhat painful to then implement every single hud element and number change, etc.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby mh » Wed Mar 09, 2011 12:43 pm

There's also Nehahra's ShowLMP thing, but that's ghastly and is really only intended for simple icons (like a skull onscreen when you die).
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Next

Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest