.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > SDK Programming discussions > Half-Life 1 SDK
Half-Life 1 SDK For developments focused around Half-Life (and its mods) Half-Life

Reply
 
Thread Tools
send debug to HUD text?
Old
  (#1)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default send debug to HUD text? - 22-01-2004

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 ?



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: send debug to HUD text?
Old
  (#2)
Austin
Moderator
 
Austin's Avatar
 
Status: Offline
Posts: 403
Join Date: Nov 2003
Default Re: send debug to HUD text? - 22-01-2004

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/
  
Reply With Quote
Re: send debug to HUD text?
Old
  (#3)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: send debug to HUD text? - 22-01-2004

it's just the normal hudparams_t stuff, like done in almost every bot to display welcome messages, birthday notifications, whatever

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 ...



  
Reply With Quote
Re: send debug to HUD text?
Old
  (#4)
Austin
Moderator
 
Austin's Avatar
 
Status: Offline
Posts: 403
Join Date: Nov 2003
Default Re: send debug to HUD text? - 23-01-2004

This is what csstats does. Looks nice. You have the code.

  
Reply With Quote
Re: send debug to HUD text?
Old
  (#5)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: send debug to HUD text? - 23-01-2004

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



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."

Last edited by Pierre-Marie Baty; 23-01-2004 at 04:40..
  
Reply With Quote
Re: send debug to HUD text?
Old
  (#6)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: send debug to HUD text? - 23-01-2004

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 ....



Last edited by Pierre-Marie Baty; 23-01-2004 at 18:56.. Reason: Formatted Joe's code to split the 3 million characters lines in something more readable...
  
Reply With Quote
Re: send debug to HUD text?
Old
  (#7)
Rick
Council Member
 
Rick's Avatar
 
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default Re: send debug to HUD text? - 24-01-2004

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
Attached Thumbnails
Click image for larger version

Name:	debugtext2.jpg
Views:	396
Size:	90.5 KB
ID:	48  
Attached Files
File Type: cpp bot_io.cpp (1.4 KB, 412 views)
File Type: h bot_io.h (2.0 KB, 390 views)
  
Reply With Quote
Re: send debug to HUD text?
Old
  (#8)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: send debug to HUD text? - 24-01-2004

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



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: send debug to HUD text?
Old
  (#9)
Rick
Council Member
 
Rick's Avatar
 
Status: Offline
Posts: 690
Join Date: Dec 2003
Location: Holland
Default Re: send debug to HUD text? - 24-01-2004

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)();

Last edited by Rick; 24-01-2004 at 22:55..
  
Reply With Quote
Re: send debug to HUD text?
Old
  (#10)
wulf
Guest
 
Status:
Posts: n/a
Default Re: send debug to HUD text? - 21-02-2004

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 !!
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com