.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Half-Life 1 SDK (http://forums.bots-united.com/forumdisplay.php?f=33)
-   -   send debug to HUD text? (http://forums.bots-united.com/showthread.php?t=455)

Pierre-Marie Baty 22-01-2004 12:06

send debug to HUD text?
 
Hi guys

I noticed on some debug screenshots of some bots (especially JoeBot XP) that some of you were sending debug text to the HUD instead of the server console or the chat area.

Currently when I want to see debug messages in game about my bots I send them all to the chat area but when I want to send a lot of text all the stuff starts scrolling up and I can't see anything :(

What I saw on a JoeBot debug screenshot for example was quite amazing, there was a lot of text (with different colors), left/top aligned, some of it right aligned in the bottom of the screen, some of it centered, and every debug message had its location and was not overlapping another.

I am utterly jealous! How do you guys do that ?

I know how to send hudtextparms_t text to the HUD, but it's text that fades in and fades out, and I need to send it continuously if I want it to stay on the screen (and if I do that, it looks unclean). And although I can imagine how to split the screen coordinates into lines and coulumns I'm clueless on how to make it right-aligned or things like that.

Any hint ?

Austin 22-01-2004 19:21

Re: send debug to HUD text?
 
The csstats module to Amx mod displays three boxes of different colored text in different locations on the screen when you die. It looks nice and is very readable.

The csstats mm plugin source is small. I don't think it would take you long to find the code that does this!

http://sourceforge.net/projects/amxmod/

@$3.1415rin 22-01-2004 19:47

Re: send debug to HUD text?
 
it's just the normal hudparams_t stuff, like done in almost every bot to display welcome messages, birthday notifications, whatever :D

or are you referring to the picture below ? that's done with a new clientmessage - unfortunately only possible with hldm or any other open source mod :)

but I think you know that ... somehow I didnt get your point I think ...

http://joebot.bots-united.com/images...oebotxp005.jpg

Austin 22-01-2004 23:15

Re: send debug to HUD text?
 
This is what csstats does. Looks nice. You have the code.

http://Austinbots.com/dl/tmp/0001.jpg

Pierre-Marie Baty 22-01-2004 23:49

Re: send debug to HUD text?
 
Thanks Austin, I'll give it a look :)

@Joe: a new network message ? I didn't know that. Clever !
Anyway I knew the basics about the hudtextparms stuff, but I'd want to know, is all that hudtextparms text on your picture a text that appears continuously during the game (being updated if necessary) or just a fixed text that is sent on request, fades in, stays a few second and fades out like a dumb welcome message?

*EDIT*

I checked your plugin, Austin, and the AMX plugins are written in Small, and they call functions in the AMX API that are completely different from the HL engine functions or the metamod API. The source code is of no use for me :(

Joe, my dear Joe, my old friend Joe, may I dare to request to have a vvveryqik' look at the "normally closed" joebot XP source code that you use for displaying your stuff ? 9_9

@$3.1415rin 23-01-2004 16:38

Re: send debug to HUD text?
 
ah no pierre, that's totally secret code ...

Code:


void ShowInfo (void)
{
  //return;
 
  //cout << g_pGame->getMaxCurrentPlayer () << endl;
 
#ifndef _DEBUG
  if (!g_bShowProfile && !g_bShowWPStat)
  {
          return;
  }
#endif
 
  if (!IS_DEDICATED_SERVER ())
  {
          if (g_pGame->m_pListenserverEdict.getEntity ())
          {
                static float fNext = 0;
                static float fNextDiff = .2;
 
                if (fNext < g_pGame->getTime ())
                {
                        fNextDiff = .42f;
                        fNext = g_pGame->getTime () + .4f;
                        g_debuginfo = true;
                }
                else
                {
                        if (g_pGame->getTime () < 30 && fNext > 31)
                          fNext = 0;
 
                        g_debuginfo = false;
                        return;
                }
 
                edict_t *pInfo = 0;
                szDebugText[0] = 0;
 
                if (!g_bShowProfile && !g_bShowWPStat)
                {
#ifdef _DEBUG
                        float fMin = 10;
                        char szTemp[200];
 
                        sprintf (szTemp, "time: %.0f\n", g_pGame->getTime ());
                        strcat (szDebugText, szTemp);
                        sprintf (szTemp, "Players : %i\n", g_pGame->getMaxCurrentPlayer ());
                        strcat (szDebugText, szTemp);
                        sprintf (szTemp, "ASMP : %li %3li %li/%li\n",
                                        g_ASN_MPool.m_lCAlloc,
                                        g_ASN_MPool.m_lCAlloc - g_ASN_MPool.m_lCFree,
                                        g_ASN_MPool.m_lNextFree,
                                        g_ASN_MPool.m_lCMax);
                        strcat (szDebugText, szTemp);
                        sprintf (szTemp, "ASTM : #%li/%li\n",
                                        g_AStarTasks.getCurrentTotalTasks (),
                                        g_AStarTasks.getTotalTasks ());
                        strcat (szDebugText, szTemp);
 
                        pInfo = 0;
                        pInfo = UTIL_GetNearestPlayer (g_pGame->m_pListenserverEdict.getEntity (),
                                                                                  -1, fMin, true, true);
 
                        fMin = 100000;
 
                        if (!pInfo)
                        {
                          pInfo = UTIL_GetNearestPlayer (g_pGame->m_pListenserverEdict.getEntity (),
                                                                                          -1, fMin, true, false);
                        }
 
                        if (pInfo)
                        {
                          getInfo (szDebugText, pInfo);
                        }
#endif
                }
 
                else if (g_bShowProfile)
                {
                        strcpy (szDebugText, g_szProfileOutput);
                }
 
                else /*if (g_bShowWPStat)*/
                {
                        if (!g_pGame->m_pListenserverEdict.getEntity ())
                          return;
 
                        int iNWP = g_Map.m_Waypoints.getNearest (g_pGame->m_pListenserverEdict.getOrigin ());
 
                        if (iNWP == -1)
                          return;
 
                        char szTemp[80];
 
                        sprintf (szDebugText, "WPStat Info (%i/%i)\n\n",
                                        iNWP, g_Map.m_Waypoints.m_iNumWaypoints);
                        sprintf (szTemp, "iVWP : %i\n",
                                        g_Map.m_Waypoints[iNWP].m_iVisibleWaypoints);
                        strcat (szDebugText, szTemp);
                        sprintf (szTemp, "fAvDv : %.0f\n",
                                        g_Map.m_Waypoints[iNWP].m_fAvDistVWP);
                        strcat (szDebugText, szTemp);
 
                        sprintf (szTemp, "D/Dd : %li/%li\n",
                                        g_Map.m_Waypoints[iNWP].m_lTotalDamage,
                                        g_Map.m_Waypoints[iNWP].m_lTotalDamaged);
                        strcat (szDebugText, szTemp);
 
                        sprintf (szTemp, "traffic : %li\n",
                                        g_Map.m_Waypoints[iNWP].m_lTraffic);
                        strcat (szDebugText, szTemp);
 
                        g_pGame->drawBeam (g_pGame->m_pListenserverEdict.getEntity(),
                                                          g_pGame->m_pListenserverEdict.getOrigin (),
                                                          g_Map.m_Waypoints[iNWP].m_VOrigin,
                                                          2,
                                                          0,
                                                          Vector (255, 255, 255),
                                                          255,
                                                          0,
                                                          fNextDiff * 10);
 
                        if (!g_Map.m_Waypoints.m_bDisplay)
                          g_pGame->drawBeam (g_pGame->m_pListenserverEdict.getEntity (),
                                                                  g_Map.m_Waypoints[iNWP].m_VOrigin + Vector (0, 0, 20),
                                                                  g_Map.m_Waypoints[iNWP].m_VOrigin - Vector (0, 0, 20),
                                                                  10,
                                                                  0,
                                                                  Vector (255, 255, 255),
                                                                  127,
                                                                  0,
                                                                  fNextDiff * 10);
                }
 
                hudtextparms_t message_params;
 
                static float fLastTime = 0;
 
                if (!pInfo)
                        pInfo = g_pGame->m_pListenserverEdict.getEntity ();
 
                message_params.x = 0;
                message_params.y = 1;
                message_params.effect = 0;
                message_params.r1 = 0;
                message_params.g1 = 255;
                message_params.b1 = 255;
                message_params.a1 = 1;
                message_params.r2 = message_params.r1;
                message_params.g2 = message_params.g1;
                message_params.b2 = message_params.b1;
                message_params.a2 = 1;
                message_params.fadeinTime = 0.f;
                message_params.fadeoutTime = 0.f;
                message_params.holdTime = fNextDiff;
                message_params.fxTime = 0.f;
                message_params.channel = 1;
 
                fLastTime = g_pGame->getTime ();
 
                long lNL = UTIL_CountLines (szDebugText);
                lNL = 17 - lNL;
 
                for (; lNL > 0; lNL--)
                {
                        strcat (szDebugText, "\n");
                }
 
                szDebugText[400] = 0;
 
                UTIL_ShowText (g_pGame->m_pListenserverEdict.getEntity (), message_params, szDebugText);
          }
  }
}

( somehow it wont let me post tabs here ... and no spaces neither ... )

that is pretty similar to the code in old joebot, it looks like I just copied it ... cause it's not yet incorporated in my game class ...

and the client message idea was once again not mine, but killarunas ....

Rick 24-01-2004 19:07

Re: send debug to HUD text?
 
3 Attachment(s)
Hmm I just made something neat :)
I made a few classes so you can display text like the way you can do with cout. For example:
Code:

rcout << "Max speed: " << bots[NearestBotInd].f_max_speed << "\n";
To display the text in the right-down corner on your screen.

You can use it by adding(and adapting) the files in your project, then declare
something like this in a file like dll.cpp:
Code:

CBaseOutput cout;
CLeftOutput lcout;
CRightOutput rcout;
CMiddleOutput mcout;

and include bot_io in in a file which is 'included' much like util.h :)

Pierre-Marie Baty 24-01-2004 20:15

Re: send debug to HUD text?
 
sweet Rick, this is exactly what I need. You save me a lot of trouble, thanks a lot ! :)

...I will soon end up with more lines of credit than lines of code in this bot actually :D

Rick 24-01-2004 20:40

Re: send debug to HUD text?
 
No problem :)
I only never tested the coords with other resolutions then 1024*768. So you might have to change that.

[EDIT]
Seems i might forgot something to mention...
You should call the display() function each frame.
Like I do have in StartFrame:
Code:

cout.Display();
lcout.Display();
rcout.Display();
mcout.Display();

(*other_gFunctionTable.pfnStartFrame)();


wulf 21-02-2004 01:25

Re: send debug to HUD text?
 
Can anyone provide any reference, or just the info, on how x/y applies the HUD ?

e.g. where is (x,y) = (0.0, 0.0) located (top left corner? top right corner? center?)

What scale are the x, y stored in ( is it up to 1.0 for each, from -1.0 to 1.0, from 0.0 to 10,000.. ?)

How does different resolution affect above ?

Thanks in advance for any info !!


All times are GMT +2. The time now is 14:53.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.