Beispiel #1
0
void CServer::BotCreate(struct bot_profile_s *profile)
{
   edict_t *BotEnt = CreateFakeClient(profile->name);

   if (!FNullEnt(BotEnt)) {
      char *infobuffer = GET_INFOBUFFER(BotEnt);
      int clientIndex = ENTINDEX(BotEnt);

      CBaseBot *pBot = NewBotInstance();
      pBot->pev = &BotEnt->v;
      pBot->m_pProfile = profile;

      if (!IsTeamplay()) {
         SET_CLIENT_KEY_VALUE(clientIndex, infobuffer, "model", profile->skin);

         // use random colors
         SET_CLIENT_KEY_VALUE(clientIndex, infobuffer, "topcolor", va("%d", RandomLong(0, 255)));
         SET_CLIENT_KEY_VALUE(clientIndex, infobuffer, "bottomcolor", va("%d", RandomLong(0, 255)));
      }

      AddBot(pBot);

      pBot->m_pProfile->is_used = true;
   }
}
Beispiel #2
0
int ModSynch( void )
{
	SET_SEGV_LOCATION();
	statbot = AddBot( &statbotinfo );
	if( !statbot )
		return NS_FAILURE;
	/* Timer to save the database */
	AddTimer( TIMER_TYPE_INTERVAL, SaveStatsTimer, "SaveStatsTimer", DBSAVETIME, NULL );
	/* Timer to output html */
	if( StatServ.html )
	{
		AddTimer( TIMER_TYPE_INTERVAL, HTMLOutputTimer, "HTMLOutputTimer", StatServ.htmltime, NULL );
		/* Initial output at load */
		HTMLOutput();
	}
	/* Timer to reset timeslice stats */
	AddTimer( TIMER_TYPE_DAILY, ResetStatisticsTimer, "ResetStatisticsTimer", 0, NULL );
	/* Timer to average stats */
	AddTimer( TIMER_TYPE_INTERVAL, AverageStatisticsTimer, "AverageStatisticsTimer", TS_ONE_HOUR, NULL );
	/* Initial average at load */
	AverageStatistics();
	/* Timer to delete old channels */
	AddTimer( TIMER_TYPE_INTERVAL, DelOldChanTimer, "DelOldChanTimer", TS_ONE_HOUR, NULL );
	return NS_SUCCESS;
}
Beispiel #3
0
void CCubeTool::OnAddObj ()
{
if (!GetMine ())
	return;
CDSegment *seg = m_mine->CurrSeg ();
if (IsBotMaker (seg))
	AddBot ();
else if (IsEquipMaker (seg))
	AddEquip ();
}
Beispiel #4
0
int ModSynch( void )
{
	/* Introduce a bot onto the network saving the bot handle */
	template_bot = AddBot( &template_bot_info );
	if( !template_bot ) 
	{
		return NS_FAILURE;
	}
	return NS_SUCCESS;
}
Beispiel #5
0
void BotControl::FillServer (int selection, int personality, int skill, int numToAdd)
{
   // this function fill server with bots, with specified team & personality

   if (GetBotsNum () >= engine->GetMaxClients () - GetHumansNum ())
      return;

   if (selection == 1 || selection == 2)
   {
      CVAR_SET_STRING ("mp_limitteams", "0");
      CVAR_SET_STRING ("mp_autoteambalance", "0");
   }
   else
      selection = 5;

   char teamDescs[6][12] =
   {
      "",
      {"Terrorists"},
      {"CTs"},
      "",
      "",
      {"Random"},
   };

   int toAdd = numToAdd == -1 ? engine->GetMaxClients () - (GetHumansNum () + GetBotsNum ()) : numToAdd;

   for (int i = 0; i <= toAdd; i++)
   {
      // since we got constant skill from menu (since creation process call automatic), we need to manually
      // randomize skill here, on given skill there.
      int randomizedSkill = 0;

      if (skill >= 0 && skill <= 20)
         randomizedSkill = engine->RandomInt (0, 20);
      else if (skill >= 20 && skill <= 40)
         randomizedSkill = engine->RandomInt (20, 40);
      else if (skill >= 40 && skill <= 60)
         randomizedSkill = engine->RandomInt (40, 60);
      else if (skill >= 60 && skill <= 80)
         randomizedSkill = engine->RandomInt (60, 80);
      else if (skill >= 80 && skill <= 99)
         randomizedSkill = engine->RandomInt (80, 99);
      else if (skill == 100)
         randomizedSkill = skill;

      AddBot ("", randomizedSkill, personality, selection, -1);
   }

   yb_quota.SetInt (toAdd);
   CenterPrint ("Fill Server with %s bots...", &teamDescs[selection][0]);
}
Beispiel #6
0
//-------------------------------- LoadMap ------------------------------------
//
//  sets up the game environment from map file
//-----------------------------------------------------------------------------
bool Raven_Game::LoadMap(const std::string& filename)
{  
  //clear any current bots and projectiles
  Clear();
  
  //out with the old
  delete m_pMap;
  delete m_pGraveMarkers;
  delete m_pPathManager;

  //in with the new
  m_pGraveMarkers = new GraveMarkers(script->GetDouble("GraveLifetime"));
  m_pPathManager = new PathManager<Raven_PathPlanner>(script->GetInt("MaxSearchCyclesPerUpdateStep"));
  m_pMap = new Raven_Map();

  //make sure the entity manager is reset
  EntityMgr->Reset();


  //load the new map data
  if (m_pMap->LoadMap(filename))
  { 
	  int NumBots = script->GetInt("NumBots");
	  for (int i = 1; i <= NumBots; i++) // unconventional loop. Lua array are
										 // not zero-indexed.
	  {
		  std::string botClassName = script->GetStringFromArray("BotNames", i);
			if (botClassName == "")
			{
				debug_con << "Invalid lua table: BotNames" << "";
			} else
			{
				AddBot(botClassName);
			}
	  }
  
    return true;
  }

  return false;
}