Esempio n. 1
0
void BotControl::ListBots (void)
{
   // this function list's bots currently playing on the server

   ServerPrintNoTag ("%-3.5s %-9.13s %-17.18s %-3.4s %-3.4s %-3.4s", "index", "name", "personality", "team", "skill", "frags");

   for (int i = 0; i < engine->GetMaxClients (); i++)
   {
      edict_t *player = INDEXENT (i);

      // is this player slot valid
      if (IsValidBot (player) != null && GetBot (player) != null)
         ServerPrintNoTag ("[%-3.1d] %-9.13s %-17.18s %-3.4s %-3.1d %-3.1d", i, STRING (player->v.netname), GetBot (player)->m_personality == PERSONALITY_RUSHER ? "rusher" : GetBot (player)->m_personality == PERSONALITY_NORMAL ? "normal" : "careful", GetTeam (player) != 0 ? "CT" : "T", GetBot (player)->m_skill, static_cast <int> (player->v.frags));
   }
}
Esempio n. 2
0
void BotControl::Think (void)
{
   // this function calls think () function for all available at call moment bots, and
   // try to catch internal error if such shit occurs

   float thinkFps = yb_thinkfps.GetFloat ();

   // check ranges
   if (thinkFps <= 0.0f || thinkFps > 40.0f)
   {
      thinkFps = 22.0f;

      AddLogEntry (true, LOG_ERROR, "Value of yb_thinkfps should be greater than zero and lower than 40.");
      yb_thinkfps.SetFloat (thinkFps);
   }
   thinkFps = (1.0f / thinkFps) * 0.88f;

   for (int i = 0; i < engine->GetMaxClients (); i++)
   {
      if (m_bots[i] != null)
      {
         if (m_bots[i]->m_thinkTimer <= engine->GetTime ())
         {
            // use these try-catch blocks to prevent server crashes when error occurs
#if !defined (NDEBUG) && !defined (_DEBUG)
            try
            {
               m_bots[i]->Think ();
            }
            catch (...)
            {
               // error occurred. kick off all bots and then print a warning message
               RemoveAll ();

               ServerPrintNoTag ("**** INTERNAL BOT ERROR! PLEASE SHUTDOWN AND RESTART YOUR SERVER! ****");
            }
#else
            m_bots[i]->Think ();
#endif
            m_bots[i]->m_thinkTimer = engine->GetTime () + thinkFps;
         }
      }
   }
}
Esempio n. 3
0
void BotControl::Think (void)
{
	
   // this function calls think () function for all available at call moment bots, and
   // try to catch internal error if such shit occurs

   for (int i = 0; i < engine->GetMaxClients (); i++)
   {
      if (m_bots[i] != null)
      {
         if (m_bots[i]->m_thinkTimer <= engine->GetTime ())
         {
            // use these try-catch blocks to prevent server crashes when error occurs
#if !defined (NDEBUG) && !defined (_DEBUG)
            try
            {
               m_bots[i]->Think ();
            }
            catch (...)
            {
               // error occurred. kick off all bots and then print a warning message
               RemoveAll ();

               ServerPrintNoTag ("**** INTERNAL BOT ERROR! PLEASE SHUTDOWN AND RESTART YOUR SERVER! ****");
            }
#else
            m_bots[i]->Think ();
#endif
            //m_bots[i]->m_thinkTimer = engine->GetTime () + thinkFps;
            if (IsDedicatedServer ())
            	m_bots[i]->m_thinkTimer = engine->GetTime () + (1.0f / (CVAR_GET_FLOAT("fps_max")/2)) * 0.88f;
            else
            	m_bots[i]->m_thinkTimer = engine->GetTime ();
         }
      }
   }
   
}