56 sLog.outDebug(
"Group::~Group: battleground group being deleted.");
59 else sLog.outError(
"Group::~Group: battleground group is not linked to the correct battleground.");
75 itr->second.save->RemoveGroup(
this);
114 CharacterDatabase.
PExecute(
"INSERT INTO groups(leaderGuid,mainTank,mainAssistant,lootMethod,looterGuid,lootThreshold,icon1,icon2,icon3,icon4,icon5,icon6,icon7,icon8,isRaid,difficulty,masterLooterGuid) " 115 "VALUES('%u','%u','%u','%u','%u','%u','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','%u','%u','%u')",
117 GUID_LOPART(
m_looterGuid),
uint32(
m_lootThreshold),
m_targetIcons[0],
m_targetIcons[1],
m_targetIcons[2],
m_targetIcons[3],
m_targetIcons[4],
m_targetIcons[5],
m_targetIcons[6],
m_targetIcons[7],
isRaidGroup(),
m_difficulty,
m_masterLooterGuid);
138 result =
CharacterDatabase.
PQuery(
"SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, masterLooterGuid FROM groups WHERE leaderGuid ='%u'",
GUID_LOPART(leaderGuid));
173 LoadMemberFromDB((*result)[0].GetUInt32(), (*result)[2].GetUInt8(), (*result)[1].GetBool());
175 while (result->NextRow());
193 member.
group = subgroup;
231 sScriptMgr.OnGroupPlayerInvited(
this, player);
257 (*itr)->SetGroupInvite(NULL);
266 if ((*itr)->GetGUID() == guid)
276 if ((*itr)->GetName() == name)
324 sScriptMgr.OnGroupPlayerRemoved(
this, player, method, kicker, reason);
329 player->GetSession()->SendPacket(&data);
333 if (
Group* group = player->GetGroup())
339 player->GetSession()->SendPacket(&data);
374 if (oldLeader && newLeader)
375 sScriptMgr.OnGroupLeaderChanged(
this, oldLeader, newLeader);
392 player =
sObjectMgr.GetPlayer(citr->guid,
true);
461 data <<
uint32(CountDown);
463 for (Roll::PlayerVote::const_iterator itr = r.
playerVote.begin(); itr != r.
playerVote.end(); ++itr)
477 data <<
uint64(SourceGuid);
479 data <<
uint64(TargetGuid);
483 data <<
uint8(RollNumber);
484 data <<
uint8(RollType);
487 for (Roll::PlayerVote::const_iterator itr = r.
playerVote.begin(); itr != r.
playerVote.end(); ++itr)
501 data <<
uint64(SourceGuid);
506 data <<
uint64(TargetGuid);
507 data <<
uint8(RollNumber);
508 data <<
uint8(RollType);
510 for (Roll::PlayerVote::const_iterator itr = r.
playerVote.begin(); itr != r.
playerVote.end(); ++itr)
525 data <<
uint32(NumberOfPlayers);
530 for (Roll::PlayerVote::const_iterator itr = r.
playerVote.begin(); itr != r.
playerVote.end(); ++itr)
564 std::vector<LootItem>::iterator i;
570 for (i = loot->
items.begin(); i != loot->
items.end(); ++i, ++itemSlot)
586 Roll* r =
new Roll(newitemGUID, *i);
591 Player* member = itr->GetSource();
594 if (i->AllowedForPlayer(member))
599 ++r->totalPlayersRolling;
605 r->itemSlot = itemSlot;
609 loot->
items[itemSlot].is_blocked =
true;
610 object->m_groupLootTimer = 60000;
616 i->is_underthreshold = 1;
627 for (std::vector<LootItem>::iterator i = loot->
items.begin(); i != loot->
items.end(); ++i, ++itemSlot)
635 Roll* r =
new Roll(newitemGUID, *i);
639 Player* playerToRoll = itr->GetSource();
640 if (!playerToRoll || !playerToRoll->
GetSession())
643 if (playerToRoll->
CanUseItem(item) && i->AllowedForPlayer(playerToRoll))
648 ++r->totalPlayersRolling;
653 if (r->totalPlayersRolling > 0)
656 r->itemSlot = itemSlot;
660 loot->
items[itemSlot].is_blocked =
true;
668 i->is_underthreshold = 1;
678 sLog.outDebug(
"Group::MasterLoot (SMSG_LOOT_MASTER_LIST, 330) player = [%s].", player->
GetName());
680 for (std::vector<LootItem>::iterator i = loot->
items.begin(); i != loot->
items.end(); ++i)
685 i->is_blocked = !i->is_underthreshold;
689 i->is_blocked = !i->is_underthreshold;
698 Player* looter = itr->GetSource();
709 data.put<
uint8>(0, real_count);
713 Player* looter = itr->GetSource();
721 Rolls::iterator rollI =
GetRoll(Guid);
722 if (rollI ==
RollId.end())
726 Roll::PlayerVote::iterator itr = roll->
playerVote.find(playerGUID);
790 for (Roll::PlayerVote::const_iterator itr = roll->
playerVote.begin(); itr != roll->
playerVote.end(); ++itr)
797 if (maxresul < randomN)
799 maxguid = itr->first;
834 Roll::PlayerVote::iterator itr;
841 SendLootRoll(0, itr->first, randomN, itr->second, *roll);
842 if (maxresul < randomN)
844 maxguid = itr->first;
908 Player* member = itr->GetSource();
909 if (!member || !member->
IsAlive())
917 if (!member_with_max_level || member_with_max_level->
getLevel() < member->
getLevel())
918 member_with_max_level = member;
923 if (victim->
getLevel() > gray_level && (!not_gray_member_with_max_level
925 not_gray_member_with_max_level = member;
954 player =
sObjectMgr.GetPlayer(citr->guid,
true);
969 data << (
uint8)(citr->group);
971 data <<
uint64(0x50000000FFFFFFFELL);
975 if (citr->guid == citr2->guid)
983 data << (
uint64)citr2->guid;
985 data << (
uint8)(onlineState);
986 data << (
uint8)(citr2->group);
1021 member = itr->GetSource();
1031 Player* pl = itr->GetSource();
1032 if (!pl || (ignore != 0 && pl->
GetGUID() == ignore) || (ignorePlayersInBGRaid && pl->
GetGroup() !=
this))
1035 if (pl->
GetSession() && (group == -1 || itr->getSubGroup() == group))
1044 Player* pl = itr->GetSource();
1059 data <<
uint64(citr->guid);
1072 bool groupFound =
false;
1086 return _addMember(guid, name, isAssistant, groupid);
1102 member.
group = group;
1139 CharacterDatabase.
PExecute(
"INSERT INTO group_member(leaderGuid,memberGuid,assistant,subgroup) VALUES('%u','%u','%u','%u')",
GUID_LOPART(
m_leaderGuid),
GUID_LOPART(member.
guid), ((member.
assistant == 1) ? 1 : 0), member.
group);
1205 "DELETE FROM group_instance WHERE leaderguid='%u' AND (permanent = 1 OR " 1206 "instance IN (SELECT instance FROM character_instance WHERE guid = '%u')" 1217 if (itr->second.perm)
1219 itr->second.save->RemoveGroup(
this);
1248 for (Rolls::iterator it =
RollId.begin(); it <
RollId.end(); ++it)
1251 Roll::PlayerVote::iterator itr2 = roll->
playerVote.find(guid);
1276 slot->group = group;
1291 slot->assistant = state;
1327 if (!member1 || !member2)
return false;
1328 if (member1->
GetGroup() !=
this || member2->
GetGroup() !=
this)
return false;
1401 Player* pNewLooter = NULL;
1407 pNewLooter = player;
1420 pNewLooter = player;
1428 if (oldLooterGUID != pNewLooter->
GetGUID())
1445 if (memberscount < MinPlayerCount)
1447 if (memberscount > MaxPlayerCount)
1463 Player* member = itr->GetSource();
1468 if (member->
GetTeam() != team)
1496 getTarget()->addLootValidatorRef(
this);
1506 Player* player = itr->GetSource();
1518 Player* pPlayer = itr->GetSource();
1557 bool isEmpty =
true;
1607 if (!mapEntry || !mapEntry->
IsDungeon())
1616 BoundInstancesMap::iterator itr =
m_boundInstances[difficulty].find(mapId);
1618 return &itr->second;
1636 if (permanent != bind.
perm || save != bind.
save)
1641 if (bind.
save != save)
1648 bind.
perm = permanent;
1658 BoundInstancesMap::iterator itr =
m_boundInstances[difficulty].find(mapid);
1663 itr->second.save->RemoveGroup(
this);
1676 if (!playerBind || !playerBind->
perm)
1694 if (
Pet* pet = pp->GetPet())
1702 DEBUG_LOG(
"-- Forced group value update for '%s'", pp->GetName());
void SetLooterGuid(const uint64 &guid)
uint8 GetSubGroup() const
bool _setAssistantFlag(const uint64 &guid, const bool &state)
void SetTargetIcon(uint8 id, uint64 guid)
bool SameSubGroup(uint64 guid1, const uint64 &guid2) const
MemberSlotList::iterator member_witerator
void _initRaidSubGroupsCounter()
MemberSlotList::const_iterator member_citerator
void GroupLoot(const uint64 &playerGUID, Loot *loot, WorldObject *object)
member_witerator _getMemberWSlot(uint64 Guid)
void SetGroupInvite(Group *group)
uint8 totalPlayersRolling
InstanceGroupBind * BindToInstance(InstanceSave *save, bool permanent, bool load=false)
DungeonDifficulty GetDifficulty()
void BroadcastReadyCheck(WorldPacket *packet)
QueryResult_AutoPtr PQuery(const char *format,...) ATTR_PRINTF(2
void SendLootRoll(const uint64 &SourceGuid, const uint64 &TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r)
GroupReference & GetGroupRef()
void BroadcastGroupUpdate(void)
void SetBgRaid(uint32 TeamID, Group *bg_raid)
void _homebindIfInstance(Player *player)
uint32 GetGroupUpdateFlag()
bool InBattlegroundQueueForBattlegroundQueueType(uint32 bgQueueType) const
void MasterLoot(const uint64 &playerGUID, Loot *loot, WorldObject *object)
uint8 * m_subGroupsCounts
void BroadcastPacket(WorldPacket *packet, bool ignorePlayersInBGRaid, int group=-1, uint64 ignore=0)
void SendLootAllPassed(uint32 NumberOfPlayers, const Roll &r)
uint32 GetGrayLevel(uint32 pl_level)
void SendDungeonDifficulty(bool IsInGroup)
bool _setMembersGroup(const uint64 &guid, const uint8 &group)
#define sLog
Log class singleton.
void ChangeLeader(const uint64 &guid)
bool CanJoinToBattleground() const
bool IsAssistant(uint64 guid) const
void ChangeMembersGroup(const uint64 &guid, const uint8 &group)
uint64 m_masterLooterGuid
void Initialize(uint16 opcode, size_t newres=200)
bool IsAtGroupRewardDistance(WorldObject const *pRewardSource) const
bool IsGameMaster() const
Item * StoreNewItem(ItemPosCountVec const &pos, uint32 item, bool update, int32 randomPropertyId=0)
void SetDifficulty(DungeonDifficulty difficulty)
void SendLootStartRoll(uint32 CountDown, const Roll &r)
DungeonDifficulty GetDifficulty()
void SendPacket(WorldPacket const *packet)
uint32 CanJoinBattlegroundQueue(uint32 bgTypeId, uint32 bgQueueType, uint32 MinPlayerCount, uint32 MaxPlayerCount, bool isRated, uint32 arenaSlot)
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
static MapManager & Instance()
member_citerator _getMemberCSlot(uint64 Guid) const
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
void NotifyItemRemoved(uint8 lootIndex)
float GetDistance2d(const WorldObject *obj) const
uint8 CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 item, uint32 count, uint32 *no_space_count=NULL) const
uint64 m_targetIcons[TARGETICONCOUNT]
void UpdatePlayerOutOfRange(Player *pPlayer)
void AddGroup(Group *group)
bool AddMember(const uint64 &guid, const char *name)
void BuildPartyMemberStatsChangedPacket(Player *player, WorldPacket *data)
void SendResetInstanceFailed(uint32 reason, uint32 MapId)
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true) const
void UpdateLooterGuid(WorldObject *object, bool ifneed=false)
MemberSlotList m_memberSlots
void SetOriginalGroup(Group *group, int8 subgroup=-1)
BoundInstancesMap m_boundInstances[TOTAL_DIFFICULTIES]
void CountRollVote(const uint64 &playerGUID, const uint64 &Guid, uint32 NumberOfPlayers, uint8 Choise)
void RemoveFromBattlegroundRaid()
void ResetInstances(uint8 method)
void setSubGroup(uint8 pSubGroup)
AttackerSet const & getAttackers() const
const bool & IsInWorld() const
bool IsLeader(const uint64 &guid) const
bool _removeMember(const uint64 &guid)
void targetObjectBuildLink() override
uint64 GetMasterLooterGuid() const
void SendLootRollWon(const uint64 &SourceGuid, const uint64 &TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r)
GroupFlagMask GetFlags(MemberSlot const &slot) const
bool _setMainAssistant(const uint64 &guid)
uint32 RemoveMember(const uint64 &guid, const RemoveMethod &method=GROUP_REMOVEMETHOD_DEFAULT, uint64 kicker=0, const char *reason=NULL)
void SendResetInstanceSuccess(uint32 MapId)
void SetBattlegroundRaid(Group *group, int8 subgroup=-1)
Rolls::iterator GetRoll(uint64 Guid)
void SetDifficulty(DungeonDifficulty dungeon_difficulty)
void NeedBeforeGreed(const uint64 &playerGUID, Loot *loot, WorldObject *object)
#define MAKE_NEW_GUID(l, e, h)
static Player * FindPlayer(uint64, bool force=false)
uint32 GetInstanceId() const
UNORDERED_MAP< uint32, InstanceGroupBind > BoundInstancesMap
void SendEquipError(uint8 msg, Item *pItem, Item *pItem2)
bool LoadGroupFromDB(const uint64 &leaderGuid, QueryResult_AutoPtr result=QueryResult_AutoPtr(NULL), bool loadMembers=true)
void SendTargetIconList(WorldSession *session)
PackedGuid const & GetPackGUID() const
void ScheduleDelayedOperation(uint32 operation)
InstancePlayerBind * GetBoundInstance(uint32 mapid, uint8 difficulty)
DungeonDifficulty GetDifficulty()
void SubGroupCounterDecrease(uint8 subgroup)
GroupReference * GetFirstMember()
bool IsInMap(const WorldObject *obj) const
bool PExecute(const char *format,...) ATTR_PRINTF(2
void SetGroup(Group *group, int8 subgroup=-1)
Map * FindMap(uint32 mapid, uint32 instanceId=0) const
uint32 RemoveInvite(Player *player)
void SendLooter(Creature *creature, Player *pLooter)
void UnbindInstance(uint32 mapid, uint8 difficulty, bool unload=false)
bool _setMainTank(const uint64 &guid)
GroupReference & GetOriginalGroupRef()
bool LoadMemberFromDB(uint32 guidLow, uint8 subgroup, bool assistant)
const char * GetName() const
std::vector< ItemPosCount > ItemPosCountVec
uint8 GetOriginalSubGroup() const
const uint64 & GetLeaderGUID() const
uint32 GetArenaTeamId(uint8 slot)
Group * GetOriginalGroup()
std::vector< LootItem > items
void Disband(bool hideDestroy=false)
ACE_Refcounted_Auto_Ptr< QueryResult, ACE_Null_Mutex > QueryResult_AutoPtr
bool Create(const uint64 &guid, const char *name)
DungeonDifficulty m_difficulty
uint32 GetMembersCount() const
void GetDataForXPAtKill(Unit const *victim, uint32 &count, uint32 &sum_level, Player *&member_with_max_level, Player *¬_gray_member_with_max_level)
bool HasFreeBattlegroundQueueId()
Player * GetInvited(const uint64 &guid) const
ItemQualities m_lootThreshold
bool hasOverThresholdItem() const
LootMethod GetLootMethod() const
void _setLeader(const uint64 &guid)
void _removeRolls(const uint64 &guid)
bool InCombatToInstance(uint32 instanceId)
void SetGroupUpdateFlag(uint32 flag)
void SubGroupCounterIncrease(uint8 subgroup)
WorldSession * GetSession() const
uint8 CanUseItem(Item *pItem, bool not_loading=true) const
InstanceGroupBind * GetBoundInstance(Player *player)
DatabaseType CharacterDatabase
Accessor to the character database.
bool _addMember(const uint64 &guid, const char *name, bool isAssistant=false)
bool AddLeaderInvite(Player *player)
bool RemoveGroup(Group *group)
uint32 GetBattlegroundQueueIdFromLevel() const
static void ConvertInstancesToGroup(Player *player, Group *group=NULL, uint64 player_guid=0)
void CountTheRoll(Rolls::iterator roll, uint32 NumberOfPlayers)
void ResetInstances(uint8 method, Player *SendMsgTo)
bool AddInvite(Player *player, bool leader)
const uint64 GetLooterGuid() const
float GetSightRange(const WorldObject *target=NULL) const
std::vector< LootItem > quest_items
Group * GetBgRaid(uint32 TeamID) const
BoundInstancesMap & GetBoundInstances(DungeonDifficulty difficulty)
uint32 urand(uint32 min, uint32 max)