//================================================================================ //================================================================================ float CHuntEnemySchedule::GetDesire() const { if ( !GetMemory() || !GetLocomotion() ) return BOT_DESIRE_NONE; if ( !GetDecision()->CanHuntThreat() ) return BOT_DESIRE_NONE; CEntityMemory *memory = GetBot()->GetPrimaryThreat(); if ( memory == NULL ) return BOT_DESIRE_NONE; // We have no vision of the enemy if ( HasCondition( BCOND_ENEMY_LOST ) ) { // But we have a vision of his last position and we are close if ( HasCondition( BCOND_ENEMY_LAST_POSITION_VISIBLE ) && (HasCondition( BCOND_ENEMY_TOO_NEAR ) || HasCondition( BCOND_ENEMY_NEAR )) ) return BOT_DESIRE_NONE; return 0.65f; } // We do not have direct vision to the enemy (a person, window, etc.) if ( HasCondition( BCOND_ENEMY_OCCLUDED ) ) return 0.65f; // We do not have range of attack if ( HasCondition( BCOND_TOO_FAR_TO_ATTACK ) ) return 0.38f; return BOT_DESIRE_NONE; }
int main(int argc, char** argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); srand (time(NULL)); if (FLAGS_race_id.empty()) { FLAGS_race_id = random_race_id(); } std::cout << "Race id: " << FLAGS_race_id << std::endl; boost::filesystem::create_directories("bin/" + FLAGS_race_id); try { std::cout << "Host: " << FLAGS_host << ", port: " << FLAGS_port << ", name: " << FLAGS_bot << ", key:" << FLAGS_key << std::endl; std::unique_ptr<bots::RawBot> bot(new bots::RawBot(GetBot(FLAGS_bot_algorithm))); utils::Connection connection(FLAGS_host, FLAGS_port); run(&connection, bot.get(), FLAGS_bot, FLAGS_key); } catch (const std::exception& e) { std::cerr << "EXCEPTION!!!" << std::endl; std::cerr << e.what() << std::endl; return 2; } return 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)); } }
void BnxDriver::LoadBot(const IniFile::Section &clSection) { bool bEnabled = clSection.GetValue<bool>("enabled", true); if (!bEnabled) return; std::string strServer = clSection.GetValue<std::string>("server", ""); std::string strNickname = clSection.GetValue<std::string>("nickname", ""); if (strServer.empty() || strNickname.empty()) return; BnxBot *pclBot = GetBot(clSection.GetName()); if (pclBot == NULL) { pclBot = new BnxBot(); pclBot->SetProfileName(clSection.GetName()); m_vBots.push_back(pclBot); } std::string strPort = clSection.GetValue<std::string>("port", "6667"); std::string strUsername = clSection.GetValue<std::string>("username", "BnxBot"); std::string strRealName = clSection.GetValue<std::string>("realname", "BnxBot"); std::string strAccessList = clSection.GetValue<std::string>("accesslist", "access.lst"); std::string strShitList = clSection.GetValue<std::string>("shitlist", "shit.lst"); std::string strSeenList = clSection.GetValue<std::string>("seenlist", "seen.lst"); std::string strResponseRules = clSection.GetValue<std::string>("responserules", "response.txt"); std::string strHomeChannels = clSection.GetValue<std::string>("homechannels", ""); std::string strNickServ = clSection.GetValue<std::string>("nickserv", ""); std::string strNickServPassword = clSection.GetValue<std::string>("nickservpassword", ""); pclBot->SetServerAndPort(strServer, strPort); pclBot->SetNickServAndPassword(strNickServ, strNickServPassword); pclBot->SetNickname(strNickname); pclBot->SetUsername(strUsername); pclBot->SetRealName(strRealName); pclBot->LoadResponseRules(strResponseRules); pclBot->LoadAccessList(strAccessList); pclBot->LoadShitList(strShitList); pclBot->LoadSeenList(strSeenList); pclBot->SetLogFile(m_strLogFile); pclBot->SetHomeChannels(strHomeChannels); }
Bot *BotControl::GetHighestFragsBot (int team) { Bot *highFragBot = null; int bestIndex = 0; float bestScore = -1; // search bots in this team for (int i = 0; i < engine->GetMaxClients (); i++) { highFragBot = g_botManager->GetBot (i); if (highFragBot != null && IsAlive (highFragBot->GetEntity ()) && GetTeam (highFragBot->GetEntity ()) == team) { if (highFragBot->pev->frags > bestScore) { bestIndex = i; bestScore = highFragBot->pev->frags; } } } return GetBot (bestIndex); }
Bot *BotControl::GetBot (edict_t *ent) { // same as above, but using bot entity return GetBot (GetIndex (ent)); }