View Single Post
Re: Joining a team in CS 1.6
Old
  (#4)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,618
Join Date: Jul 2004
Location: Bulgaria
Default Re: Joining a team in CS 1.6 - 07-06-2015

Hello again,

I guess that it is bug in the function BotClient_CS_HLTV. The state variable there although static it will never be incremented to 1 so the new round will never be detected...
However I don't think the fix would be simple, because every other bot projects that I know use it as global variable and reset it in MessageBegin/End in order to always have correct count.

Good luck.

P.S. Actually a fix would be to increment the value each time the function enters and to put it back to zero when reaches 1. However this might not be enough, because I don't know how much states the HLTV message can have. But you can try to debug it.

To be more exact, do it like this:
Code:
void BotClient_CS_HLTV(void *p, int bot_index)
{
   static int state = 0;   // current state machine state
   static int players;
   int index;

   if (state == 0)
   {
      state++;
      players = *(int *) p;
   }
   else if (state == 1)
   {
      // new round in CS 1.6
      state = 0;
      if ((players == 0) && (*(int *) p == 0))
      {
         for (index = 0; index < 32; index++)
         {
            if (bots[index].is_used)
               BotSpawnInit (&bots[index]); // reset bots for new round
         }
      }
   }
   else
   {
      state++;
   }
}
Sorry, had posted the code with mistake.
  
Reply With Quote