void BotManager::simBots() { for (BotList::iterator i = bot_list.begin(); i != bot_list.end(); i++) { (*i)->processEvents(); } }
bool BotManager::isBot(Uint16 playerid) { for (BotList::iterator i = bot_list.begin(); i != bot_list.end(); i++) { if ( (*i)->botPlayerId == playerid ) { return true; } } return false; }
void BotManager::removeBot(Uint16 playerid) { for (BotList::iterator i = bot_list.begin(); i != bot_list.end(); ++i) { if ( (*i)->botPlayerId == playerid ) { delete (*i); bot_list.erase(i); break; } } }
static bool HandleNpcBotLookupCommand(ChatHandler* handler, const char* args) { //this is just a modified '.lookup creature' command if (!*args) { handler->SendSysMessage(".npcbot lookup #class"); handler->SendSysMessage("Looks up npcbots by #class, and returns all matches with their creature ID's."); handler->PSendSysMessage("BOT_CLASS_WARRIOR = %u", uint32(BOT_CLASS_WARRIOR)); handler->PSendSysMessage("BOT_CLASS_PALADIN = %u", uint32(BOT_CLASS_PALADIN)); handler->PSendSysMessage("BOT_CLASS_HUNTER = %u", uint32(BOT_CLASS_HUNTER)); handler->PSendSysMessage("BOT_CLASS_ROGUE = %u", uint32(BOT_CLASS_ROGUE)); handler->PSendSysMessage("BOT_CLASS_PRIEST = %u", uint32(BOT_CLASS_PRIEST)); handler->PSendSysMessage("BOT_CLASS_DEATH_KNIGHT = %u", uint32(BOT_CLASS_DEATH_KNIGHT)); handler->PSendSysMessage("BOT_CLASS_SHAMAN = %u", uint32(BOT_CLASS_SHAMAN)); handler->PSendSysMessage("BOT_CLASS_MAGE = %u", uint32(BOT_CLASS_MAGE)); handler->PSendSysMessage("BOT_CLASS_WARLOCK = %u", uint32(BOT_CLASS_WARLOCK)); handler->PSendSysMessage("BOT_CLASS_DRUID = %u", uint32(BOT_CLASS_DRUID)); handler->PSendSysMessage("BOT_CLASS_BM = %u", uint32(BOT_CLASS_BM)); handler->SetSentErrorMessage(true); return false; } char* classstr = strtok((char*)args, " "); uint8 botclass = BOT_CLASS_NONE; if (classstr) botclass = (uint8)atoi(classstr); if (botclass == BOT_CLASS_NONE || botclass >= BOT_CLASS_END) { handler->PSendSysMessage("Unknown bot class %u", uint32(botclass)); handler->SetSentErrorMessage(true); return false; } handler->PSendSysMessage("Looking for bots of class %u...", uint32(botclass)); uint8 localeIndex = handler->GetSessionDbLocaleIndex(); CreatureTemplateContainer const* ctc = sObjectMgr->GetCreatureTemplates(); typedef std::list<BotPair> BotList; BotList botlist; for (CreatureTemplateContainer::const_iterator itr = ctc->begin(); itr != ctc->end(); ++itr) { uint32 id = itr->second.Entry; if (id < BOT_ENTRY_BEGIN || id > BOT_ENTRY_END) continue; uint32 trainer_class = itr->second.trainer_class; if (trainer_class != botclass) continue; if (CreatureLocale const* creatureLocale = sObjectMgr->GetCreatureLocale(id)) { if (creatureLocale->Name.size() > localeIndex && !creatureLocale->Name[localeIndex].empty()) { botlist.push_back(BotPair(id, creatureLocale->Name[localeIndex])); continue; } } std::string name = itr->second.Name; if (name.empty()) continue; botlist.push_back(BotPair(id, name)); } if (botlist.empty()) { handler->SendSysMessage(LANG_COMMAND_NOCREATUREFOUND); handler->SetSentErrorMessage(true); return false; } botlist.sort(&script_bot_commands::sortbots); for (BotList::const_iterator itr = botlist.begin(); itr != botlist.end(); ++itr) { uint32 id = itr->first; char const* name = itr->second.c_str(); handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name); } return true; }