.:: 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 ::. > YappA > Offtopic
Offtopic Just anything. You have time to waste ? Prove it !!!

Reply
 
Thread Tools
Post your funny code comments!
Old
  (#1)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Post your funny code comments! - 08-01-2004

Did you ever read those funny SDK comments that botman had filtered out? Lets share some code comments you find funny , found in your code, other code, etc.

An example of funny code in the time i was working on RB AI PR #2 and #3 with Tub:

Code:
// Tub says: BIG BUG BAD! :)
Code:
// @ TUB -> I do it my way :)
 // @ STEFAN -> the complicated way? :)
 // I can do this faster:
 // @ TUB -> Ok ok ok, you're right, you don't mind if i code now the
 // bots handling the task ok? :)
some pretty recent code (already read by pierre when he converted it to metamod... )

Code:
 // suggested code by pierre and fixed by botman because pierre is to lazy
	// to deliver proper code at once :P :) (j/k pierre)
show yours!


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: Post your funny code comments!
Old
  (#2)
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: Post your funny code comments! - 08-01-2004

funny thing when you're two coders on the same project and the only way you communicate is through code comments
Code:
   // is the bot controlled by the player ? (for debugging)
   if (pPlayer->Bot.is_controlled)
   {
	  BotIsBewitched (pPlayer); // OMG, this is witchery !
	  return; // let the player steer this bot
   }
Code:
	  BotWalkPath (pBot); // walk the path, Neo.
^^ hinting Stefan on this one
Code:
   // is our bot's goal to reach a rescue zone ?
   if (pBot->bot_goal & BOT_GOAL_REACHSAFETYZONE)
   {
	  // bot already knows where the site to reach is (v_goal), so first off it needs to get
	  // there, and then... uhhh... well... well then, he has won =)
Code:
	  // is bot NOT finding a path yet NOR walking it ?
	  if ((pBot->bot_task != BOT_TASK_FINDPATH) && (pBot->bot_task != BOT_TASK_WALKPATH))
	  {
		 // grmbl, this lazy bot is doing nothing. Is it far from the site ?
Code:
   // else do we want to kick one bot ?
   else if (strcmp (pcmd, "kick") == 0)
   {
	  // cycle through all bot slots and kick the first we find
	  for (bot_index = 0; bot_index < RACC_MAX_CLIENTS; bot_index++)
		 if (IsValidPlayer (&players[bot_index]) && players[bot_index].is_racc_bot)
		 {
			sprintf (server_cmd, "kick \"%s\"\n", players[bot_index].connection_name); // build the kick command string
			SERVER_COMMAND (server_cmd); // boot the bot out
			server.bot_check_time = *server.time + 0.5; // delay a while before checking the bot counts
			break; // stop looping (don't kick the whole population, you idiot)
		 }
   }
Code:
   // else does the bot want to laugh at a dead enemy ?
   else if (pPlayer->Bot.BotChat.bot_saytext == BOT_SAYTEXT_LAUGH)
   {
	  pPlayer->Bot.BotChat.bot_saytext = 0;
	  if (&players[pPlayer->Bot.victim_index] == pPlayer)
		 return; // don't laugh at self, eh...
the one belows come from a complicated function Cheeseh helped me to work out
Code:
	  // else segment is neither horizontal nor vertical, but just bent (grr)
	  else
	  {
		 // we have to compute the bastard's equation.
Code:
void pfnClientPrintf (edict_t *pEdict, PRINT_TYPE ptype, const char *szMsg)
{
   // this function prints the text message string pointed to by szMsg by the client side of
   // the client entity pointed to by pEntity, in a manner depending of ptype (print_console,
   // print_center or print_chat). Be certain never to try to feed a bot with this function,
   // as it will crash your server. Why would you, anyway ? bots have no client DLL as far as
   // we know, right ? But since stupidity rules this world, we do a preventive check :)
   if ((pEdict->v.flags & FL_FAKECLIENT) || players[ENTINDEX (pEdict) - 1].is_racc_bot)
	  return; // disallow client printings for bots
   (*g_engfuncs.pfnClientPrintf) (pEdict, ptype, szMsg);
}
here's a snippet of a long comment in pfnClientCommand()
Code:
   // make the server crash. Since hordes of uncautious, not to say stupid, programmers don't
   // even imagine some players on their servers could be bots, this check is performed less than
   // sometimes actually by their side, that's why we strongly recommend to check it here too. In
Code:
				  pBot->bot_goal |= BOT_GOAL_PLANTBOMB; // bot's goal is to blow stuff up, haha!
and I kept the best one for the end
Code:
bool IsMyBirthday (void)
{
   // hahaha :D big grin to @$3.1415rin for the idea !!!
 time_t now = time (NULL);
 tm *tm_now = localtime (&now);
 
   // is it my birthday ?
 if ((tm_now->tm_mon == 1) && (tm_now->tm_mday == 28))
  return (TRUE); // w00t, today is 28 february, it's my birthday ! :D
   // bah crap
   return (FALSE);
}



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: Post your funny code comments!
Old
  (#3)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: Post your funny code comments! - 08-01-2004

rofl @ pierre, and yeah, i remember Neo

Code:
   float f_update_weapon_time; // Aargh
in experimental (commented out now) code to make bots jump:
Code:
   // we are going to fall
   // JUMP baby
Code:
	  // VIP: When we found an enemy, we have a problem.
	  if (vip)
	  {
		// We do not forget our enemy, but we will try to get the heck out of here.
		// TODO TODO TODO: code something here?
	  }


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: Post your funny code comments!
Old
  (#4)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: Post your funny code comments! - 08-01-2004

Code:
// should the bot pause for a while here? ( looks kind of intelligent )


Code:
else if(i_BorA == 2){ // Bot is bored, so he behaves in a social way and wants to meet teammates ;)

if(!Task.Important()){

Task.AddTask(BT_ROAMTEAM,gpGlobals->time + 60.0,0,GetRandomPlayerWO(pEdict,bot_teamnm,1,0,pEdict),0);

}

}


Code:
// Bot is bored, so why not throw a flashbang at the base ?


the original birthday code

Code:
bool MyBirthday(void){

time_t now = time(NULL);

tm *tm_now = localtime(&now);


if(tm_now->tm_mon == 6

&&tm_now->tm_mday==8){ // 8.7.

g_lAge = tm_now->tm_year - 82;

return true;

}

return false;

}


a leftover from debugging ( only for german speaking ppl )

Code:
//FakeClientCommand(pEdict,"say","muh die kuh",0);


and the best code I once forgot to comment and then it took me some time get know what it meant ( well, joebot is a nightmare, I try to make things better in joebot xp



Code:
CBitField BFNearEnemy(g_Map.m_Waypoints.m_iNumWaypoints),

BFNotNearBot(g_Map.m_Waypoints.m_iNumWaypoints),

BFVis(g_Map.m_Waypoints.m_iNumWaypoints);

CBitField::bf_iterator iter;

// look if we can see some of the nearby waypoints to the enemy

g_Map.m_Waypoints.setDistanceMask(&BFNearEnemy,1,350,p->m_VOrigin);

// dont take the waypoints which are less than 200 units away

g_Map.m_Waypoints.setDistanceMask(&BFNotNearBot,-1,200,m_pBot->m_pPlayer->getOrigin());

// take only visible waypoints from here

g_Map.m_Waypoints.setVisibleMask(&BFVis,m_pBot->m_pPlayer->m_iNearestWP);

BFNearEnemy &= BFNotNearBot; // everything that's far enough from me

BFNearEnemy &= BFVis; // everything that's near to the enemy and visible to us

long lShootAt = BFNearEnemy.getSet();

.....


Code:
m_pBot->m_pAction->attackO(1); // press the attack button for just a second

m_pBot->m_pAction->slowDownO(1,0); // stay where you are ! ( for a second at least )


maybe I find really funny stuff tomorrow, gotta write a test tomorrow, so I guess it's better to sleep now



Last edited by @$3.1415rin; 08-01-2004 at 23:27..
  
Reply With Quote
Reply


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

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