Unit *PlayerbotClassAI::FindMainAssistInRaid(Player *gPlayer) { if (!gPlayer) return NULL; Group *pGroup = gPlayer->GetGroup(); if (!pGroup) return NULL; uint64 pLeaderGuid = pGroup->GetLeaderGUID(); Unit *pPlayer = NULL; // Check if set in raid if (pGroup->isRaidGroup()) { QueryResult result = CharacterDatabase.PQuery("SELECT memberGuid FROM group_member WHERE memberFlags='%u' AND guid = '%u'",MEMBER_FLAG_MAINASSIST, pGroup->GetGUID()); if(result) { uint64 pGuid = MAKE_NEW_GUID(result->Fetch()->GetInt32(),0,HIGHGUID_PLAYER); pPlayer = sObjectMgr->GetPlayer(pGuid); if (pPlayer && pGroup->IsMember(pGuid) && pPlayer->isAlive()){ return pPlayer; } } } // default to main tank return FindMainTankInRaid(gPlayer); }
bool Battlefield::AddOrSetPlayerToCorrectBfGroup(Player* player) { if (!player->IsInWorld()) return false; if (player->GetGroup() && (player->GetGroup()->isBGGroup() || player->GetGroup()->isBFGroup())) { sLog->outMisc("Battlefield::AddOrSetPlayerToCorrectBfGroup - player is already in %s group!", (player->GetGroup()->isBGGroup() ? "BG" : "BF")); return false; } Group* group = GetFreeBfRaid(player->GetTeamId()); if (!group) { group = new Group; group->SetBattlefieldGroup(this); group->Create(player); sGroupMgr->AddGroup(group); m_Groups[player->GetTeamId()].insert(group->GetGUID()); } else if (group->IsMember(player->GetGUID())) { uint8 subgroup = group->GetMemberGroup(player->GetGUID()); player->SetBattlegroundOrBattlefieldRaid(group, subgroup); } else group->AddMember(player); return true; }
void WorldSession::HandleSetLootMethodOpcode(WorldPackets::Party::SetLootMethod& packet) { Group* group = GetPlayer()->GetGroup(); if (!group) return; /** error handling **/ if (!group->IsLeader(GetPlayer()->GetGUID())) return; if (packet.LootMethod > PERSONAL_LOOT) return; if (packet.LootThreshold < ITEM_QUALITY_UNCOMMON || packet.LootThreshold > ITEM_QUALITY_ARTIFACT) return; if (packet.LootMethod == MASTER_LOOT && !group->IsMember(packet.LootMasterGUID)) return; /********************/ // everything's fine, do it group->SetLootMethod(static_cast<LootMethod>(packet.LootMethod)); group->SetMasterLooterGuid(packet.LootMasterGUID); group->SetLootThreshold(static_cast<ItemQualities>(packet.LootThreshold)); group->SendUpdate(); }
void WorldSession::HandleGroupUninvite(uint64 guid, std::string name) { Group *group = GetPlayer()->GetGroup(); if(!group) return; Player *player = objmgr.GetPlayer(guid); /** error handling **/ if(!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID())) { SendPartyResult(PARTY_OP_LEAVE, "", PARTY_RESULT_YOU_NOT_LEADER); return; } if(!group->IsMember(guid) && (player && player->GetGroupInvite() != group)) { SendPartyResult(PARTY_OP_LEAVE, name, PARTY_RESULT_NOT_IN_YOUR_PARTY); return; } /********************/ // everything's fine, do it if(player && player->GetGroupInvite()) // uninvite invitee player->UninviteFromGroup(); else // uninvite member Player::RemoveFromGroup(group,guid); }
void WorldSession::HandlePartyUninviteOpcode(WorldPackets::Party::PartyUninvite& packet) { // can't uninvite yourself if (packet.TargetGUID == GetPlayer()->GetGUID()) { TC_LOG_ERROR("network", "WorldSession::HandleGroupUninviteGuidOpcode: leader %s (%s) tried to uninvite himself from the group.", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str()); return; } PartyResult res = GetPlayer()->CanUninviteFromGroup(packet.TargetGUID); if (res != ERR_PARTY_RESULT_OK) { SendPartyResult(PARTY_OP_UNINVITE, "", res); return; } Group* grp = GetPlayer()->GetGroup(); // grp is checked already above in CanUninviteFromGroup() ASSERT(grp); if (grp->IsMember(packet.TargetGUID)) { Player::RemoveFromGroup(grp, packet.TargetGUID, GROUP_REMOVEMETHOD_KICK, GetPlayer()->GetGUID(), packet.Reason.c_str()); return; } if (Player* player = grp->GetInvited(packet.TargetGUID)) { player->UninviteFromGroup(); return; } SendPartyResult(PARTY_OP_UNINVITE, "", ERR_TARGET_NOT_IN_GROUP_S); }
bool Battlefield::AddOrSetPlayerToCorrectBfGroup(Player* player) { if (!player->IsInWorld()) return false; if (Group* group = player->GetGroup()) group->RemoveMember(player->GetGUID()); Group* group = GetFreeBfRaid(player->GetTeamId()); if (!group) { group = new Group; group->SetBattlefieldGroup(this); group->Create(player); sGroupMgr->AddGroup(group); m_Groups[player->GetTeamId()].insert(group->GetGUID()); } else if (group->IsMember(player->GetGUID())) { uint8 subgroup = group->GetMemberGroup(player->GetGUID()); player->SetBattlegroundOrBattlefieldRaid(group, subgroup); } else group->AddMember(player); return true; }
void WorldSession::HandleLootMethodOpcode(WorldPacket& recvData) { TC_LOG_DEBUG("network", "WORLD: Received CMSG_LOOT_METHOD"); uint32 lootMethod; ObjectGuid lootMaster; uint32 lootThreshold; recvData >> lootMethod >> lootMaster >> lootThreshold; Group* group = GetPlayer()->GetGroup(); if (!group) return; /** error handling **/ if (!group->IsLeader(GetPlayer()->GetGUID())) return; if (lootMethod > NEED_BEFORE_GREED) return; if (lootThreshold < ITEM_QUALITY_UNCOMMON || lootThreshold > ITEM_QUALITY_ARTIFACT) return; if (lootMethod == MASTER_LOOT && !group->IsMember(lootMaster)) return; /********************/ // everything's fine, do it group->SetLootMethod((LootMethod)lootMethod); group->SetMasterLooterGuid(lootMaster); group->SetLootThreshold((ItemQualities)lootThreshold); group->SendUpdate(); }
void WorldSession::HandleLootMethodOpcode(WorldPacket& recvData) { ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_LOOT_METHOD"); uint32 lootMethod; uint64 lootMaster; uint32 lootThreshold; recvData >> lootMethod >> lootMaster >> lootThreshold; Group* group = GetPlayer()->GetGroup(); if (!group) return; /** error handling **/ // Xinef: Check if group is LFG if (!group->IsLeader(GetPlayer()->GetGUID()) || group->isLFGGroup()) return; if (lootMethod > NEED_BEFORE_GREED) return; if (lootThreshold < ITEM_QUALITY_UNCOMMON || lootThreshold > ITEM_QUALITY_ARTIFACT) return; if (lootMethod == MASTER_LOOT && !group->IsMember(lootMaster)) return; /********************/ // everything's fine, do it group->SetLootMethod((LootMethod)lootMethod); group->SetMasterLooterGuid(lootMaster); group->SetLootThreshold((ItemQualities)lootThreshold); group->SendUpdate(); }
void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recvData) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_UNINVITE_GUID"); #endif uint64 guid; std::string reason, name; recvData >> guid; recvData >> reason; //can't uninvite yourself if (guid == GetPlayer()->GetGUID()) { sLog->outError("WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); return; } // Xinef: name is properly filled in packets sObjectMgr->GetPlayerNameByGUID(guid, name); PartyResult res = GetPlayer()->CanUninviteFromGroup(); if (res != ERR_PARTY_RESULT_OK) { SendPartyResult(PARTY_OP_UNINVITE, name, res); return; } Group* grp = GetPlayer()->GetGroup(); if (!grp) return; // Xinef: do not allow to kick with empty reason, this will resend packet with given reason if (grp->isLFGGroup() && reason.empty()) { SendPartyResult(PARTY_OP_UNINVITE, name, ERR_VOTE_KICK_REASON_NEEDED); return; } if (grp->IsLeader(guid) && !grp->isLFGGroup()) { SendPartyResult(PARTY_OP_UNINVITE, name, ERR_NOT_LEADER); return; } if (grp->IsMember(guid)) { Player::RemoveFromGroup(grp, guid, GROUP_REMOVEMETHOD_KICK, GetPlayer()->GetGUID(), reason.c_str()); return; } if (Player* player = grp->GetInvited(guid)) { player->UninviteFromGroup(); return; } SendPartyResult(PARTY_OP_UNINVITE, name, ERR_TARGET_NOT_IN_GROUP_S); }
void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data) { ObjectGuid guid; std::string reason; recv_data >> guid; recv_data >> reason; // reason // can't uninvite yourself if (guid == GetPlayer()->GetObjectGuid()) { sLog.outError("WorldSession::HandleGroupUninviteGuidOpcode: leader %s tried to uninvite himself from the group.", GetPlayer()->GetGuidStr().c_str()); return; } Group* grp = GetPlayer()->GetGroup(); if(!grp) return; if (grp->IsMember(guid) && grp->isLFGGroup()) { sLFGMgr.InitBoot(GetPlayer(), guid, reason); return; } PartyResult res = GetPlayer()->CanUninviteFromGroup(); if (res != ERR_PARTY_RESULT_OK) { SendPartyResult(PARTY_OP_LEAVE, "", res); return; } if (grp->IsMember(guid)) { Player::RemoveFromGroup(grp, guid); return; } if (Player* plr = grp->GetInvited(guid)) { plr->UninviteFromGroup(); return; } SendPartyResult(PARTY_OP_LEAVE, "", ERR_TARGET_NOT_IN_GROUP_S); }
void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_UNINVITE_GUID"); uint64 guid; std::string reason; recv_data >> guid; recv_data >> reason; //can't uninvite yourself if (guid == GetPlayer()->GetGUID()) { sLog->outError("WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); return; } PartyResult res = GetPlayer()->CanUninviteFromGroup(); if (res != ERR_PARTY_RESULT_OK) { SendPartyResult(PARTY_OP_UNINVITE, "", res); return; } Group* grp = GetPlayer()->GetGroup(); if (!grp) return; if (grp->IsLeader(guid)) { SendPartyResult(PARTY_OP_UNINVITE, "", ERR_NOT_LEADER); return; } if (grp->IsMember(guid)) { Player::RemoveFromGroup(grp, guid, GROUP_REMOVEMETHOD_KICK, GetPlayer()->GetGUID(), reason.c_str()); //remove any npcbots it has //Creature *bot = GetPlayer()->GetBot(); //if(bot && bot->GetGUID() == guid) GetPlayer()->SetBotMustDie(); //check that player is not a playerbot Player *player = sObjectMgr->GetPlayer(guid); if(player && player->IsPlayerbot()) GetPlayer()->GetSession()->LogoutPlayerBot(guid, true); return; } if (Player* plr = grp->GetInvited(guid)) { plr->UninviteFromGroup(); return; } SendPartyResult(PARTY_OP_UNINVITE, "", ERR_TARGET_NOT_IN_GROUP_S); }
/** Function that checks if the player can be added to a raid group @param player to be added to raid */ bool Battlefield::CanAddPlayerToRaid(Player* player) { if (!player->IsInWorld()) return false; DEBUG_LOG("Battlefield: Adding player %s to raid", player->GetGuidStr().c_str()); if (Group* group = player->GetGroup()) { DEBUG_LOG("Battlefield: Player %s already has group %s, uninviting", player->GetGuidStr().c_str(), group->GetGuidStr().c_str()); group->RemoveMember(player->GetObjectGuid(), 0); } PvpTeamIndex teamIdx = GetTeamIndexByTeamId(player->GetTeam()); Group* group = GetFreeRaid(teamIdx); if (!group) { DEBUG_LOG("Battlefield: No free raid for %s!", player->GetGuidStr().c_str()); if (IsTeamFull(teamIdx)) { DEBUG_LOG("Battlefield: Battlefield is full! Can't add player %s!", player->GetGuidStr().c_str()); return false; } DEBUG_LOG("Battlefield: Trying to create new group for %s!", player->GetGuidStr().c_str()); group = new Group; group->SetBattlefieldGroup(this); if (group->Create(player->GetObjectGuid(), player->GetName())) DEBUG_LOG("Battlefield: Successfully created new group %s", group->GetGuidStr().c_str()); else sLog.outError("Battlefield: Failed to create group for player %s.", player->GetGuidStr().c_str()); m_battlefieldRaids[teamIdx].insert(group); } else if (group->IsMember(player->GetObjectGuid())) { DEBUG_LOG("Battlefield: Raid already has players %s, making some shit", player->GetGuidStr().c_str()); uint8 subgroup = group->GetMemberGroup(player->GetObjectGuid()); player->SetBattleRaid(group, subgroup); } else { if (IsTeamFull(teamIdx)) { DEBUG_LOG("Battlefield: Group %s found, but battlefield is full! Can't add player %s!", group->GetGuidStr().c_str(), player->GetGuidStr().c_str()); return false; } return group->AddMember(player->GetObjectGuid(), player->GetName()); } return true; }
void JustDied(Unit* killer) override { me->SetObjectScale(1.0f); _events.Reset(); if (Creature* legoso = me->FindNearestCreature(NPC_LEGOSO, SIZE_OF_GRIDS)) { Group* group = me->GetLootRecipientGroup(); if (killer->GetGUID() == legoso->GetGUID() || (group && group->IsMember(killer->GetGUID())) || killer->GetGUID() == legoso->AI()->GetGUID(DATA_EVENT_STARTER_GUID)) legoso->AI()->DoAction(ACTION_LEGOSO_SIRONAS_KILLED); } }
void WorldSession::HandleGroupUninviteOpcode(WorldPacket & recv_data) { std::string membername; recv_data >> membername; // player not found if (!normalizePlayerName(membername)) return; // can't uninvite yourself if (GetPlayer()->GetName() == membername) { sLog.outError("WorldSession::HandleGroupUninviteOpcode: leader %s tried to uninvite himself from the group.", GetPlayer()->GetGuidStr().c_str()); return; } Group* grp = GetPlayer()->GetGroup(); if (!grp) return; ObjectGuid guid = grp->GetMemberGuid(membername); if (grp->IsMember(guid) && grp->isLFGGroup()) { sLFGMgr.InitBoot(GetPlayer(), guid, ""); return; } PartyResult res = GetPlayer()->CanUninviteFromGroup(); if (res != ERR_PARTY_RESULT_OK) { SendPartyResult(PARTY_OP_LEAVE, "", res); return; } if (!guid.IsEmpty()) { Player::RemoveFromGroup(grp, guid); return; } if (Player* plr = grp->GetInvited(membername)) { plr->UninviteFromGroup(); return; } SendPartyResult(PARTY_OP_LEAVE, membername, ERR_TARGET_NOT_IN_GROUP_S); }
void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recvData) { TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_UNINVITE_GUID"); uint64 guid; std::string reason; recvData >> guid; recvData >> reason; //can't uninvite yourself if (guid == GetPlayer()->GetGUID()) { TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); return; } PartyResult res = GetPlayer()->CanUninviteFromGroup(); if (res != ERR_PARTY_RESULT_OK) { SendPartyResult(PARTY_OP_UNINVITE, "", res); return; } Group* grp = GetPlayer()->GetGroup(); if (!grp) return; if (grp->IsLeader(guid)) { SendPartyResult(PARTY_OP_UNINVITE, "", ERR_NOT_LEADER); return; } if (grp->IsMember(guid)) { Player::RemoveFromGroup(grp, guid, GROUP_REMOVEMETHOD_KICK, GetPlayer()->GetGUID(), reason.c_str()); return; } if (Player* player = grp->GetInvited(guid)) { player->UninviteFromGroup(); return; } SendPartyResult(PARTY_OP_UNINVITE, "", ERR_TARGET_NOT_IN_GROUP_S); }
void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data) { ObjectGuid guid; std::string reason; recv_data >> guid; recv_data >> reason; // reason // can't uninvite yourself if (guid == GetPlayer()->GetObjectGuid()) { ERROR_LOG("WorldSession::HandleGroupUninviteGuidOpcode: leader %s tried to uninvite himself from the group.", GetPlayer()->GetGuidStr().c_str()); return; } Group* grp = GetPlayer()->GetGroup(); if(!grp) return; PartyResult res = GetPlayer()->CanUninviteFromGroup(); if (res != ERR_PARTY_RESULT_OK) { SendPartyResult(PARTY_OP_UNINVITE, "", res); return; } if (grp->IsMember(guid)) { if (grp->GetLeaderGuid() == guid) return; Player::RemoveFromGroup(grp, guid); return; } if (Player* plr = grp->GetInvited(guid)) { if (grp->GetLeaderGuid() == plr->GetObjectGuid()) return; plr->UninviteFromGroup(); return; } SendPartyResult(PARTY_OP_UNINVITE, "", ERR_TARGET_NOT_IN_GROUP_S); }
void WorldSession::HandleLootMethodOpcode(WorldPacket & recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_LOOT_METHOD"); uint8 lootMethod; ObjectGuid lootMaster; uint32 lootThreshold; recvData >> lootMethod; recvData.read_skip<uint8>(); recvData >> lootThreshold; uint8 bitOrder[8] = { 3, 5, 0, 6, 2, 1, 7, 4 }; recvData.ReadBitInOrder(lootMaster, bitOrder); recvData.FlushBits(); uint8 byteOrder[8] = { 6, 0, 3, 5, 2, 7, 4, 1 }; recvData.ReadBytesSeq(lootMaster, byteOrder); Group* group = GetPlayer()->GetGroup(); if (!group) return; /** error handling **/ if (!group->IsLeader(GetPlayer()->GetGUID())) return; if (lootMethod > NEED_BEFORE_GREED) return; if (lootThreshold < ITEM_QUALITY_UNCOMMON || lootThreshold > ITEM_QUALITY_ARTIFACT) return; if (lootMethod == MASTER_LOOT && !group->IsMember(lootMaster)) return; /********************/ // everything's fine, do it group->SetLootMethod((LootMethod)lootMethod); group->SetLooterGuid(lootMaster); group->SetLootThreshold((ItemQualities)lootThreshold); group->SendUpdate(); }
void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data) { uint64 guid; std::string reason; recv_data >> guid; recv_data >> reason; //can't uninvite yourself if (guid == GetPlayer()->GetGUID()) { sLog.outError("WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); return; } PartyResult res = GetPlayer()->CanUninviteFromGroup(); if (res != ERR_PARTY_RESULT_OK) { SendPartyResult(PARTY_OP_UNINVITE, "", res); return; } Group* grp = GetPlayer()->GetGroup(); if (!grp) return; if (grp->IsMember(guid)) { if (grp->isLFGGroup()) sLFGMgr.InitBoot(grp, GUID_LOPART(GetPlayer()->GetGUID()), GUID_LOPART(guid), reason); else Player::RemoveFromGroup(grp, guid, GROUP_REMOVEMETHOD_KICK); return; } if (Player* plr = grp->GetInvited(guid)) { plr->UninviteFromGroup(); return; } SendPartyResult(PARTY_OP_UNINVITE, "", ERR_TARGET_NOT_IN_GROUP_S); }
void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recvData) { TC_LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_UNINVITE_GUID"); ObjectGuid guid; std::string reason; recvData >> guid; recvData >> reason; //can't uninvite yourself if (guid == GetPlayer()->GetGUID()) { TC_LOG_ERROR("network", "WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().GetCounter()); return; } PartyResult res = GetPlayer()->CanUninviteFromGroup(guid); if (res != ERR_PARTY_RESULT_OK) { SendPartyResult(PARTY_OP_UNINVITE, "", res); return; } Group* grp = GetPlayer()->GetGroup(); // grp is checked already above in CanUninviteFromGroup() ASSERT(grp); if (grp->IsMember(guid)) { Player::RemoveFromGroup(grp, guid, GROUP_REMOVEMETHOD_KICK, GetPlayer()->GetGUID(), reason.c_str()); return; } if (Player* player = grp->GetInvited(guid)) { player->UninviteFromGroup(); return; } SendPartyResult(PARTY_OP_UNINVITE, "", ERR_TARGET_NOT_IN_GROUP_S); }
void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data) { CHECK_PACKET_SIZE(recv_data,8); uint64 guid; recv_data >> guid; //can't uninvite yourself if(guid == GetPlayer()->GetGUID()) { sLog.outError("WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); return; } PartyResult res = GetPlayer()->CanUninviteFromGroup(); if(res != PARTY_RESULT_OK) { SendPartyResult(PARTY_OP_LEAVE, "", res); return; } Group* grp = GetPlayer()->GetGroup(); if(!grp) return; if(grp->IsMember(guid)) { Player::RemoveFromGroup(grp,guid); return; } if(Player* plr = grp->GetInvited(guid)) { plr->UninviteFromGroup(); return; } SendPartyResult(PARTY_OP_LEAVE, "", PARTY_RESULT_NOT_IN_YOUR_PARTY); }
// is Resource heavy, do not spam or use heavily in loop Unit *PlayerbotClassAI::FindMainTankInRaid(Player *gPlayer) { // check if original main tank is still alive. No point regetting main // tank b/c chances are slim that it will not get reset in the middle of a fight. // But if main tank dies, try to find next best canidate if (mainTank!=NULL && mainTank->isAlive()) { return mainTank; } if (!gPlayer) return NULL; Group *pGroup = gPlayer->GetGroup(); if (!pGroup) return NULL; uint64 pLeaderGuid = pGroup->GetLeaderGUID(); Unit *pPlayer = NULL; // Check if set in raid if (pGroup->isRaidGroup()) { QueryResult result = CharacterDatabase.PQuery("SELECT memberGuid FROM group_member WHERE memberFlags='%u' AND guid = '%u'",MEMBER_FLAG_MAINTANK, pGroup->GetGUID()); if(result) { uint64 pGuid = MAKE_NEW_GUID(result->Fetch()->GetInt32(),0,HIGHGUID_PLAYER); pPlayer = sObjectMgr->GetPlayer(pGuid); if (pPlayer && pGroup->IsMember(pGuid) && pPlayer->isAlive()){ mainTank = pPlayer; return pPlayer; } } } // if could not find tank try assuming // Assume the one with highest health is the main tank uint32 maxhpfound=0; std::list<Unit*> unitList; gPlayer->GetRaidMember(unitList,30); if (!unitList.empty()){ for (std::list<Unit*>::iterator itr = unitList.begin() ; itr!=unitList.end();++itr) { //Player *tPlayer = GetPlayerBot()->GetObjPlayer((*itr)->GetGUID()); Unit *tPlayer = sObjectMgr->GetPlayer((*itr)->GetGUID()); if (tPlayer == NULL) continue; if (tPlayer->isDead()) continue; if (GetPlayerBot()->GetAreaId() != tPlayer->GetAreaId()) continue; //if(tPlayer->GetGUID() == GetPlayerBot()->GetGUID()) continue; if (GetPlayerBot()->GetDistance(tPlayer) > 50) continue; if (tPlayer->GetMaxHealth() > maxhpfound) { maxhpfound = tPlayer->GetMaxHealth(); pPlayer=tPlayer; } // Also check pets if ( (tPlayer->getClass() == (uint8) CLASS_HUNTER || tPlayer->getClass() == (uint8) CLASS_WARLOCK) && IS_PET_GUID(tPlayer->GetPetGUID()) ) { Pet* tpet = ObjectAccessor::GetPet(*tPlayer, tPlayer->GetPetGUID()); if (!tpet || !tpet->IsInWorld() || !tpet->isDead()) continue; if (tpet->GetArmor() > tPlayer->GetArmor()) //Probably a tanking capable pet.. { if (tpet->GetMaxHealth() > maxhpfound) { maxhpfound = tpet->GetMaxHealth(); pPlayer=tpet; } else if (tPlayer->GetGUID() == pPlayer->GetGUID()) {pPlayer = tpet;} //set pet as tank instead of owner } } } } mainTank = pPlayer; return pPlayer; }
void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_UNINVITE_GUID"); ObjectGuid guid; std::string unkstring; recvData.read_skip<uint8>(); // unk 0x00 guid[6] = recvData.ReadBit(); guid[4] = recvData.ReadBit(); guid[3] = recvData.ReadBit(); guid[2] = recvData.ReadBit(); guid[0] = recvData.ReadBit(); guid[1] = recvData.ReadBit(); guid[7] = recvData.ReadBit(); guid[5] = recvData.ReadBit(); uint8 stringSize = recvData.ReadBits(8); unkstring = recvData.ReadString(stringSize); recvData.ReadByteSeq(guid[5]); recvData.ReadByteSeq(guid[6]); recvData.ReadByteSeq(guid[1]); recvData.ReadByteSeq(guid[4]); recvData.ReadByteSeq(guid[3]); recvData.ReadByteSeq(guid[2]); recvData.ReadByteSeq(guid[7]); recvData.ReadByteSeq(guid[0]); // Can't uninvite yourself if (guid == GetPlayer()->GetGUID()) { sLog->outError(LOG_FILTER_NETWORKIO, "WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); return; } PartyResult res = GetPlayer()->CanUninviteFromGroup(); if (res != ERR_PARTY_RESULT_OK) { SendPartyResult(PARTY_OP_UNINVITE, "", res); return; } Group* grp = GetPlayer()->GetGroup(); if (!grp) return; if (grp->IsLeader(guid)) { SendPartyResult(PARTY_OP_UNINVITE, "", ERR_NOT_LEADER); return; } if (grp->IsMember(guid)) { Player::RemoveFromGroup(grp, guid, GROUP_REMOVEMETHOD_KICK, GetPlayer()->GetGUID(), unkstring.c_str()); return; } if (Player* player = grp->GetInvited(guid)) { player->UninviteFromGroup(); return; } SendPartyResult(PARTY_OP_UNINVITE, "", ERR_TARGET_NOT_IN_GROUP_S); }
void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recvData) { TC_LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_UNINVITE_GUID"); ObjectGuid guid; recvData.read_skip<uint8>(); guid[6] = recvData.ReadBit(); guid[4] = recvData.ReadBit(); guid[3] = recvData.ReadBit(); guid[2] = recvData.ReadBit(); guid[0] = recvData.ReadBit(); guid[1] = recvData.ReadBit(); guid[7] = recvData.ReadBit(); guid[5] = recvData.ReadBit(); uint8 reasonLen = recvData.ReadBits(8); std::string reason = recvData.ReadString(reasonLen); recvData.ReadByteSeq(guid[5]); recvData.ReadByteSeq(guid[6]); recvData.ReadByteSeq(guid[1]); recvData.ReadByteSeq(guid[4]); recvData.ReadByteSeq(guid[3]); recvData.ReadByteSeq(guid[2]); recvData.ReadByteSeq(guid[7]); recvData.ReadByteSeq(guid[0]); //can't uninvite yourself if (guid == GetPlayer()->GetGUID()) { TC_LOG_ERROR("network", "WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow()); return; } PartyResult res = GetPlayer()->CanUninviteFromGroup(); if (res != ERR_PARTY_RESULT_OK) { SendPartyResult(PARTY_OP_UNINVITE, "", res); return; } Group* grp = GetPlayer()->GetGroup(); if (!grp) return; if (grp->IsLeader(guid)) { SendPartyResult(PARTY_OP_UNINVITE, "", ERR_NOT_LEADER); return; } if (grp->IsMember(guid)) { Player::RemoveFromGroup(grp, guid, GROUP_REMOVEMETHOD_KICK, GetPlayer()->GetGUID(), reason.c_str()); return; } if (Player* player = grp->GetInvited(guid)) { player->UninviteFromGroup(); return; } SendPartyResult(PARTY_OP_UNINVITE, "", ERR_TARGET_NOT_IN_GROUP_S); }