void BotControl::MaintainBotQuota (void) { // this function keeps number of bots up to date, and don't allow to maintain bot creation // while creation process in process. if (!m_creationTab.IsEmpty () && m_maintainTime < engine->GetTime ()) { CreateItem last = m_creationTab.Pop (); int resultOfCall = CreateBot (last.name, last.skill, last.personality, last.team, last.member); // check the result of creation if (resultOfCall == 0) { m_creationTab.RemoveAll (); // something wrong with waypoints, reset tab of creation yb_quota.SetInt (0); // reset quota } else if (resultOfCall == 2) { m_creationTab.RemoveAll (); // maximum players reached, so set quota to maximum players yb_quota.SetInt (GetBotsNum ()); } m_maintainTime = engine->GetTime () + 0.2f; } // now keep bot number up to date if (m_maintainTime < engine->GetTime ()) { int botNumber = GetBotsNum (); int humanNumber = GetHumansNum (); if (botNumber > yb_quota.GetInt ()) RemoveRandom (); if (yb_autovacate.GetBool ()) { if (botNumber < yb_quota.GetInt () && botNumber < engine->GetMaxClients () - 1) AddRandom (); if (humanNumber >= engine->GetMaxClients ()) RemoveRandom (); } else { if (botNumber < yb_quota.GetInt () && botNumber < engine->GetMaxClients ()) AddRandom (); } int botQuota = yb_autovacate.GetBool () ? (engine->GetMaxClients () - 1 - (humanNumber + 1)) : engine->GetMaxClients (); // check valid range of quota if (yb_quota.GetInt () > botQuota) yb_quota.SetInt (botQuota); else if (yb_quota.GetInt () < 0) yb_quota.SetInt (0); m_maintainTime = engine->GetTime () + 0.25f; } }
void BotControl::RemoveAll (void) { // this function drops all bot clients from server (this function removes only yapb's)`q CenterPrint ("Bots are removed from server."); for (int i = 0; i < engine->GetMaxClients (); i++) { if (m_bots[i] != null) // is this slot used? m_bots[i]->Kick (); } m_creationTab.RemoveAll (); // reset cvars yb_quota.SetInt (0); yb_autovacate.SetInt (0); }
void Bot::Kick (void) { // this function kick off one bot from the server. ServerCommand ("kick #%d", GETPLAYERUSERID (GetEntity ())); CenterPrint ("Bot '%s' kicked", STRING (pev->netname)); // balances quota if (g_botManager->GetBotsNum () - 1 < yb_quota.GetInt ()) yb_quota.SetInt (g_botManager->GetBotsNum () - 1); }
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]); }
void BotControl::AddBot (const String &name, const String &skill, const String &personality, const String &team, const String &member) { // this function is same as the function above, but accept as parameters string instead of integers CreateItem queueID; const String &any = "*"; queueID.name = (name.IsEmpty () || (name == any)) ? String ("\0") : name; queueID.skill = (skill.IsEmpty () || (skill == any)) ? -1 : (int)skill; queueID.team = (team.IsEmpty () || (team == any)) ? -1 : (int)team; queueID.member = (member.IsEmpty () || (member == any)) ? -1 : (int)member; queueID.personality = (personality.IsEmpty () || (personality == any)) ? -1 : (int)personality; m_creationTab.Push (queueID); // keep quota number up to date if (GetBotsNum () + 1 > yb_quota.GetInt ()) yb_quota.SetInt (GetBotsNum () + 1); }
void BotControl::AddBot (const String &name, int skill, int personality, int team, int member) { // this function putting bot creation process to queue to prevent engine crashes CreateItem queueID; // fill the holder queueID.name = name; queueID.skill = skill; queueID.personality = personality; queueID.team = team; queueID.member = member; // put to queue m_creationTab.Push (queueID); // keep quota number up to date if (GetBotsNum () + 1 > yb_quota.GetInt ()) yb_quota.SetInt (GetBotsNum () + 1); }
void RoundInit (void) { // this is called at the start of each round g_roundEnded = false; // SyPB Pro P.35 - Game Mode Setting if (GetGameMod() == 0) { // check team economics g_botManager->CheckTeamEconomics(TEAM_TERRORIST); g_botManager->CheckTeamEconomics(TEAM_COUNTER); } for (int i = 0; i < engine->GetMaxClients (); i++) { if (g_botManager->GetBot (i)) g_botManager->GetBot (i)->NewRound (); g_radioSelect[i] = 0; } g_waypoint->SetBombPosition (true); g_waypoint->ClearGoalScore (); // SyPB Pro P.38 - Zombie Mode Human Camp g_waypoint->InitTypes(1); g_bombSayString = false; g_timeBombPlanted = 0.0f; g_timeNextBombUpdate = 0.0f; g_leaderChoosen[TEAM_COUNTER] = false; g_leaderChoosen[TEAM_TERRORIST] = false; g_lastRadioTime[0] = 0.0f; g_lastRadioTime[1] = 0.0f; g_botsCanPause = false; g_entityIdAPI.RemoveAll(); g_entityTeamAPI.RemoveAll(); g_entityActionAPI.RemoveAll(); // SyPB Pro P.15 char *Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/plugins-dmkd.ini", GetModName()); if (TryFileOpen(Plugin_INI)) { if (CVAR_GET_FLOAT("HsK_Deathmatch_Plugin_load_SyPB") == 1) sypb_gamemod.SetInt(1); else sypb_gamemod.SetInt(0); } // SyPB Pro P.35 - ZP5.0 Fixed char *zpGameVersion[] = { "plugins-zplague", // ZP4.3 "plugins-zp50_ammopacks", // ZP5.0 "plugins-zp50_money" //ZP5.0 }; for (int i = 0; i < 3; i++) { Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/%s.ini", GetModName(), zpGameVersion[i]); if (TryFileOpen(Plugin_INI)) { float delayTime = CVAR_GET_FLOAT("zp_delay") + 2.0f; if (i != 0) delayTime = CVAR_GET_FLOAT("zp_gamemode_delay") + 0.2f; if (delayTime > 0) { sypb_gamemod.SetInt(2); sypb_walkallow.SetInt(0); //g_DelayTimer = engine->GetTime() + delayTime + 6.0f; // SyPB Pro P.34 - ZP TIME FIXED g_DelayTimer = engine->GetTime() + delayTime;// +1.99f; break; } } } // SyPB Pro P.11 Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/zombiehell.cfg", GetModName()); if (TryFileOpen(Plugin_INI) && CVAR_GET_FLOAT("zh_zombie_maxslots") > 0) { sypb_gamemod.SetInt(4); sypb_walkallow.SetInt(0); extern ConVar sypb_quota; sypb_quota.SetInt(static_cast <int> (CVAR_GET_FLOAT("zh_zombie_maxslots"))); } // SyPB Pro P.29 - Support CSBTE Final Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/bte_player.ini", GetModName()); if (TryFileOpen(Plugin_INI)) { const int Const_GameModes = 13; int bteGameModAi[Const_GameModes] = { 0, 0, 1, 3, 0, 2, 2, 2, 2, 4, 2, 3, 2 };//1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13 char *bteGameINI[Const_GameModes] = { "plugins-none", //1 "plugins-td", //2 "plugins-dm", //3 "plugins-dr", //4 "plugins-gd", //5 "plugins-ghost",//6 "plugins-zb1", //7 "plugins-zb3", //8 "plugins-zb4", //9 "plugins-ze", //10 "plugins-zse", //11 "plugins-npc", //12 "plugins-zb5" //13 }; for (int i = 0; i < Const_GameModes; i++) { if (TryFileOpen(FormatBuffer("%s/addons/amxmodx/configs/%s.ini", GetModName(), bteGameINI[i]))) { //sypb_gamemod.SetInt(bteGameModAi[i]); if (bteGameModAi[i] == 2 && i != 5) { sypb_walkallow.SetInt(0); g_DelayTimer = engine->GetTime() + 20.0f + CVAR_GET_FLOAT("mp_freezetime"); } ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]); ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]); ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]); if (i == 3 || i == 9) { ServerPrint("***** SyPB not support the mode now :( *****"); ServerPrint("***** SyPB not support the mode now :( *****"); ServerPrint("***** SyPB not support the mode now :( *****"); ServerPrint("***** SyPB not support the mode now :( *****"); ServerPrint("***** SyPB not support the mode now :( *****"); sypb_gamemod.SetInt(10); } else sypb_gamemod.SetInt(bteGameModAi[i]); // SyPB Pro P.36 - bte support g_gameVersion = CSVER_CZERO; break; } } } // SyPB Pro P.38 - Base Change if (GetGameMod() != 0) g_mapType |= MAP_DE; // SyPB Pro P.35 - Game Mode Setting if (GetGameMod () == 0) g_exp.UpdateGlobalKnowledge (); // update experience data on round start // calculate the round mid/end in world time g_timeRoundStart = engine->GetTime () + engine->GetFreezeTime (); g_timeRoundMid = g_timeRoundStart + engine->GetRoundTime () * 60 / 2; g_timeRoundEnd = g_timeRoundStart + engine->GetRoundTime () * 60; }
void RoundInit (void) { // this is called at the start of each round g_roundEnded = false; // check team economics g_botManager->CheckTeamEconomics (TEAM_TERRORIST); g_botManager->CheckTeamEconomics (TEAM_COUNTER); for (int i = 0; i < engine->GetMaxClients (); i++) { if (g_botManager->GetBot (i)) g_botManager->GetBot (i)->NewRound (); g_radioSelect[i] = 0; } g_waypoint->SetBombPosition (true); g_waypoint->ClearGoalScore (); g_bombSayString = false; g_timeBombPlanted = 0.0f; g_timeNextBombUpdate = 0.0f; g_leaderChoosen[TEAM_COUNTER] = false; g_leaderChoosen[TEAM_TERRORIST] = false; g_lastRadioTime[0] = 0.0f; g_lastRadioTime[1] = 0.0f; g_botsCanPause = false; // SyPB Pro P.15 char *Plugin_INI = FormatBuffer ("%s/addons/amxmodx/configs/plugins-dmkd.ini", GetModName ()); if (TryFileOpen(Plugin_INI)) { if (CVAR_GET_FLOAT("HsK_Deathmatch_Plugin_load_SyPB") == 1) sypb_gamemod.SetInt (1); else sypb_gamemod.SetInt (0); } // SyPB Pro P.2 // SyPB Pro P.15 Plugin_INI = FormatBuffer ("%s/addons/amxmodx/configs/plugins-zplague.ini", GetModName ()); if (TryFileOpen(Plugin_INI)) // Getting GameMod { float delayTime = (CVAR_GET_FLOAT("zp_delay") >0) ? CVAR_GET_FLOAT("zp_delay") : CVAR_GET_FLOAT("zp_gamemode_delay"); if (delayTime > 0) { sypb_gamemod.SetInt (2); sypb_walkallow.SetInt (0); g_DelayTimer = engine->GetTime () + delayTime + (CVAR_GET_FLOAT("mp_freezetime") / 2); } } // SyPB Pro P.11 Plugin_INI = FormatBuffer ("%s/addons/amxmodx/configs/zombiehell.cfg", GetModName ()); if (TryFileOpen(Plugin_INI) && CVAR_GET_FLOAT("zh_zombie_maxslots") > 0) { sypb_gamemod.SetInt (4); sypb_walkallow.SetInt (0); extern ConVar sypb_quota; sypb_quota.SetInt (static_cast <int> (CVAR_GET_FLOAT("zh_zombie_maxslots"))); } // SyPB Pro P.14 Plugin_INI = FormatBuffer ("%s/addons/amxmodx/configs/bte_wpn.ini", GetModName ()); if (TryFileOpen(Plugin_INI)) // This is CS:BTE { Plugin_INI = FormatBuffer ("%s/addons/amxmodx/configs/plugins-ze.ini", GetModName ()); if ((g_mapType & MAP_ZE) && TryFileOpen(Plugin_INI)) { sypb_gamemod.SetInt (99); sypb_walkallow.SetInt (0); g_DelayTimer = engine->GetTime () + 24.0f; } Plugin_INI = FormatBuffer ("%s/addons/amxmodx/configs/plugins-zb1.ini", GetModName ()); if (TryFileOpen(Plugin_INI)) { sypb_gamemod.SetInt (2); sypb_walkallow.SetInt (0); } } g_exp.UpdateGlobalKnowledge (); // update experience data on round start // calculate the round mid/end in world time g_timeRoundStart = engine->GetTime () + engine->GetFreezeTime (); g_timeRoundMid = g_timeRoundStart + engine->GetRoundTime () * 60 / 2; g_timeRoundEnd = g_timeRoundStart + engine->GetRoundTime () * 60; }
void RoundInit (void) { // this is called at the start of each round g_roundEnded = false; // check team economics g_botManager->CheckTeamEconomics (TEAM_TERRORIST); g_botManager->CheckTeamEconomics (TEAM_COUNTER); for (int i = 0; i < engine->GetMaxClients (); i++) { if (g_botManager->GetBot (i)) g_botManager->GetBot (i)->NewRound (); g_radioSelect[i] = 0; } g_waypoint->SetBombPosition (true); g_waypoint->ClearGoalScore (); g_bombSayString = false; g_timeBombPlanted = 0.0f; g_timeNextBombUpdate = 0.0f; g_leaderChoosen[TEAM_COUNTER] = false; g_leaderChoosen[TEAM_TERRORIST] = false; g_lastRadioTime[0] = 0.0f; g_lastRadioTime[1] = 0.0f; g_botsCanPause = false; // SyPB Pro P.15 char *Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/plugins-dmkd.ini", GetModName()); if (TryFileOpen(Plugin_INI)) { if (CVAR_GET_FLOAT("HsK_Deathmatch_Plugin_load_SyPB") == 1) sypb_gamemod.SetInt(1); else sypb_gamemod.SetInt(0); } // SyPB Pro P.2 // SyPB Pro P.15 Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/plugins-zplague.ini", GetModName()); if (TryFileOpen(Plugin_INI)) // Getting GameMod { float delayTime = (CVAR_GET_FLOAT("zp_delay") >0) ? CVAR_GET_FLOAT("zp_delay") : CVAR_GET_FLOAT("zp_gamemode_delay"); if (delayTime > 0) { sypb_gamemod.SetInt(2); sypb_walkallow.SetInt(0); g_DelayTimer = engine->GetTime() + delayTime + (CVAR_GET_FLOAT("mp_freezetime") / 2); } } // SyPB Pro P.11 Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/zombiehell.cfg", GetModName()); if (TryFileOpen(Plugin_INI) && CVAR_GET_FLOAT("zh_zombie_maxslots") > 0) { sypb_gamemod.SetInt(4); sypb_walkallow.SetInt(0); extern ConVar sypb_quota; sypb_quota.SetInt(static_cast <int> (CVAR_GET_FLOAT("zh_zombie_maxslots"))); } // SyPB Pro P.29 - Support CSBTE Final Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/bte_player.ini", GetModName()); if (TryFileOpen(Plugin_INI)) { const int Const_GameModes = 12; int bteGameModAi[Const_GameModes] = { 0, 0, 1, 3, 0, 2, 2, 2, 2, 4, 2, 3 };//n, t, d, d, g, g, z, z, z, z, z, n char *bteGameINI[Const_GameModes] = { "plugins-none", "plugins-td", "plugins-dm", "plugins-dr", "plugins-gd", "plugins-ghost", "plugins-zb1", "plugins-zb3", "plugins-zb4", "plugins-ze", "plugins-zse", "plugins-npc" }; for (int i = 0; i < Const_GameModes; i++) { if (TryFileOpen(FormatBuffer("%s/addons/amxmodx/configs/%s.ini", GetModName(), bteGameINI[i]))) { sypb_gamemod.SetInt(bteGameModAi[i]); if (bteGameModAi[i] == 2 && i != 5) { sypb_walkallow.SetInt(0); g_DelayTimer = engine->GetTime() + 20.0f; } ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]); ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]); ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]); if (i == 3 || i == 9 || i == 10) { ServerPrint("***** SyPB not support the mode now :( *****"); ServerPrint("***** SyPB not support the mode now :( *****"); ServerPrint("***** SyPB not support the mode now :( *****"); ServerPrint("***** SyPB not support the mode now :( *****"); ServerPrint("***** SyPB not support the mode now :( *****"); } break; } } } // SyPB Pro P.25 - Zombie Ai if (GetGameMod() == 2 || GetGameMod() == 4) g_mapType |= MAP_DE; g_exp.UpdateGlobalKnowledge (); // update experience data on round start // calculate the round mid/end in world time g_timeRoundStart = engine->GetTime () + engine->GetFreezeTime (); g_timeRoundMid = g_timeRoundStart + engine->GetRoundTime () * 60 / 2; g_timeRoundEnd = g_timeRoundStart + engine->GetRoundTime () * 60; }