PDA

View Full Version : Post your funny code comments!


stefanhendriks
08-01-2004, 21:10
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:


// Tub says: BIG BUG BAD! :)



// @ 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... :D )


// 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! :D

Pierre-Marie Baty
08-01-2004, 21:46
funny thing when you're two coders on the same project and the only way you communicate is through code comments :D

// 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
}


BotWalkPath (pBot); // walk the path, Neo.

^^ hinting Stefan on this one ;)

// 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 =)


// 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 ?


// 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)
}
}


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

// else segment is neither horizontal nor vertical, but just bent (grr)
else
{
// we have to compute the bastard's equation.


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

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


pBot->bot_goal |= BOT_GOAL_PLANTBOMB; // bot's goal is to blow stuff up, haha!

and I kept the best one for the end

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

:D

stefanhendriks
08-01-2004, 22:36
rofl @ pierre, and yeah, i remember Neo ;)


float f_update_weapon_time; // Aargh


in experimental (commented out now) code to make bots jump:

// we are going to fall
// JUMP baby



// 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?
}

@$3.1415rin
08-01-2004, 23:25
// should the bot pause for a while here? ( looks kind of intelligent )







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,pEd ict),0);

}

}







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





the original birthday code :D



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 :D )



//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 :)





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

.....







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 :D