.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Half-Life and HL1 Mods (http://forums.bots-united.com/forumdisplay.php?f=22)
-   -   Let's kill the bots (http://forums.bots-united.com/showthread.php?t=5581)

The_Hard_Mission_Guy 05-08-2006 19:26

Re: Let's kill the bots
 
OK Fasten Seat Belts:
PHP Code:

void StartFramevoid ){
if((
gpGlobals->time 3) && (gpGlobals->time 3.1)) ClientPutInServer(bots[0].pEdict); //Init the Game
 
if(gpGlobals->time 3){
if(
fabs(gpGlobals->time) > 1){
if((
current->pEdict->v.origin g).Length() < 50){
g_engfuncs.pfnServerPrint("I'm too Slow , Kill me!\n");
ClientKill(current->pEdict);
}
current->pEdict->v.origin
gpGlobals->time
}
}
if(
current->pEdict->v.deadflag != DEAD_NO){
botnumber++;
if(
botnumber >= 7){
botnumber 0;
}
ClientPutInServer(bots[botnumber].pEdict);
current = &bots[botnumber];
}
 
BotThink(current);
 
(*
other_gFunctionTable.pfnStartFrame)();


So this is the main Code .....what is very important to say is that the phrase ("I'm too Slow , Kill me!\n" gets printed out exactly when it should but the ClientKill() beneath gets totally ignored....
Can you see something I've overseen?

P.S also very important to note is that I'm having only one bot running at the same time (as you can see) the next bot gets called after the previous dies....

The Storm 05-08-2006 19:31

Re: Let's kill the bots
 
From where you got the data for the pointer current->pEdict ?

The_Hard_Mission_Guy 05-08-2006 19:33

Re: Let's kill the bots
 
Initialized in ServerActivate()

The Storm 05-08-2006 19:39

Re: Let's kill the bots
 
Are you using array to get it in ClientConnect() ? Because if new bot join the pointer will be overwrited ?

The_Hard_Mission_Guy 05-08-2006 19:43

Re: Let's kill the bots
 
Yep! I'm using an array of a struct called bot_t which holds pEdict.
also I omited ClientPutInServer() from BotCreate() so that they are spawned in StartFrame()

The Storm 05-08-2006 19:50

Re: Let's kill the bots
 
ServerActivate() is not good to get bot edicts, you can't get the bots edicts at all from it, ClientPutInServer() is not usefull because you must call it for each bot, this function is not called auto when you create the bot with the engine. I suggest to do the edicts update and checks in start frame, and to spawn the bots in their own BotThink() function.
put that in the begining of start frame:
Code:

for (int iPlayerIndex = 1; iPlayerIndex <= gpGlobals->maxClients; iPlayerIndex++)
    {
      edict_t *pPlayer = INDEXENT(iPlayerIndex);
      int iStoreIndex = iPlayerIndex - 1;
      if (!FNullEnt(pPlayer) && !pPlayer->free && (pPlayer->v.flags & (FL_CLIENT | FL_FAKECLIENT)))
      {
          bots[iStoreIndex].pEdict = pPlayer;
          bots[iStoreIndex].bIsUsed = TRUE;
      }
      else
      {
          bots[iStoreIndex].bIsUsed = FALSE;
          bots[iStoreIndex].pEdict = NULL;
      }
  }

bot_t bots[32]; - make this global.

The_Hard_Mission_Guy 05-08-2006 19:59

Re: Let's kill the bots
 
Hmmmmm , OK I'll re-check the rest of of my code ..

but how do you explain the fact that , when I replace ClienKill() with ClientPutInserver() in the above Code that the Bot gets successfully respawned ?

The_Hard_Mission_Guy 05-08-2006 20:18

Re: Let's kill the bots
 
Assuming that current->pEdict points to an invalid Entity or to another player , how is it possible that this same "invalid" pointer is fed to pfnPlayerMove() and results in the bot jumping , moving , shooting around successfully ?

The Storm 05-08-2006 20:43

Re: Let's kill the bots
 
ClientPutInServer() must be called only one time for each bot. Now you have all the bot edicts sotred in bots[32] loop this array and do the job.

The_Hard_Mission_Guy 05-08-2006 23:31

Re: Let's kill the bots
 
You didn't answer my last question!


All times are GMT +2. The time now is 23:16.

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