void SendRemovePlayerBot(Player *player, Creature *creature, uint32 action) { int8 x = action - GOSSIP_ACTION_INFO_DEF - 1; if (x == 0) { SendRemovePlayerBotAll(player, creature); return; } WorldSession *session = player->GetSession(); for(PlayerBotMap::const_iterator itr = session->GetPlayerBotsBegin(); itr != session->GetPlayerBotsEnd(); ++itr) { if(x == 1 && itr->second && itr->second->GetGroup()) { Player *m_bot = itr->second; Group *m_group = m_bot->GetGroup(); //removing bot from group if(m_group->IsMember(m_bot->GetGUID())) { //deleting bot from group if(m_group->RemoveMember(m_bot->GetGUID(), GROUP_REMOVEMETHOD_DEFAULT) < 1) // 99 means I'm a bot { //no one left in group so deleting group delete m_group; //sObjectMgr.RemoveGroup(m_group); } } session->LogoutPlayerBot(m_bot->GetGUID(), true); break; } --x; } player->CLOSE_GOSSIP_MENU(); } //end SendRemovePlayerBot
void SendRemovePlayerBotMenu(Player *player, Creature *creature, uint32 action) { player->PlayerTalkClass->ClearMenus(); player->ADD_GOSSIP_ITEM(9, "REMOVE ALL", 6005, GOSSIP_ACTION_INFO_DEF + 1); uint8 x = 2; WorldSession *session = player->GetSession(); for(PlayerBotMap::const_iterator itr = session->GetPlayerBotsBegin(); itr != session->GetPlayerBotsEnd(); ++itr) { Player *bot = itr->second; player->ADD_GOSSIP_ITEM(9, bot->GetName(), 6005, GOSSIP_ACTION_INFO_DEF + x); ++x; } player->SEND_GOSSIP_MENU(907, creature->GetGUID()); } //end SendRemovePlayerBotMenu
bool OnGossipHello(Player *player, Creature *creature) { WorldSession *session = player->GetSession(); uint8 count = 0; for(PlayerBotMap::const_iterator itr = session->GetPlayerBotsBegin(); itr != session->GetPlayerBotsEnd(); ++itr) { if(count == 0) player->ADD_GOSSIP_ITEM(0, "Abandon Your Player?", 6004, GOSSIP_ACTION_INFO_DEF + 100); ++count; } if(player->HaveBot()) { player->ADD_GOSSIP_ITEM(0, "Abandon Your Minion?", 6001, GOSSIP_ACTION_INFO_DEF + 101); } else player->ADD_GOSSIP_ITEM(0, "Recruit a Minion", 6006, GOSSIP_ACTION_INFO_DEF + 2); if(count < player->GetMaxPlayerBot()) player->ADD_GOSSIP_ITEM(0, "Recruit a Player", 6002, GOSSIP_ACTION_INFO_DEF + 1); player->PlayerTalkClass->SendGossipMenu(907, creature->GetGUID()); return true; }