Core/Groups: Need restrictions in need before greed loot method should apply only to LFG dungeons

This commit is contained in:
Shauren
2012-01-14 18:42:23 +01:00
parent f4075f0f94
commit 894c27af52
4 changed files with 44 additions and 23 deletions
+19 -1
View File
@@ -11811,8 +11811,26 @@ InventoryResult Player::CanUseItem(ItemTemplate const* proto) const
return EQUIP_ERR_ITEM_NOT_FOUND;
}
InventoryResult Player::CanRollForItem(ItemTemplate const* proto) const
InventoryResult Player::CanRollForItemInLFG(ItemTemplate const* proto, WorldObject const* lootedObject) const
{
LfgDungeonSet const& dungeons = sLFGMgr->GetSelectedDungeons(GetGUID());
if (dungeons.empty())
return EQUIP_ERR_OK; // not using LFG
if (!GetGroup() || !GetGroup()->isLFGGroup())
return EQUIP_ERR_OK; // not in LFG group
// check if looted object is inside the lfg dungeon
bool lootedObjectInDungeon = false;
Map const* map = lootedObject->GetMap();
if (uint32 dungeonId = sLFGMgr->GetDungeon(GetGroup()->GetGUID(), true))
if (LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(dungeonId))
if (dungeon->map == map->GetId() && dungeon->difficulty == map->GetDifficulty())
lootedObjectInDungeon = true;
if (!lootedObjectInDungeon)
return EQUIP_ERR_OK;
if (!proto)
return EQUIP_ERR_ITEM_NOT_FOUND;
// Used by group, function NeedBeforeGreed, to know if a prototype can be used by a player
+1 -1
View File
@@ -1277,7 +1277,7 @@ class Player : public Unit, public GridObject<Player>
bool HasItemTotemCategory(uint32 TotemCategory) const;
InventoryResult CanUseItem(ItemTemplate const* pItem) const;
InventoryResult CanUseAmmo(uint32 item) const;
InventoryResult CanRollForItem(ItemTemplate const* item) const;
InventoryResult CanRollForItemInLFG(ItemTemplate const* item, WorldObject const* lootedObject) const;
Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId = 0);
Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId, AllowedLooterSet &allowedLooters);
Item* StoreItem(ItemPosCountVec const& pos, Item* pItem, bool update);
+15 -12
View File
@@ -740,24 +740,24 @@ void Group::SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll &r)
}
}
void Group::SendLootStartRollToPlayer(uint32 CountDown, uint32 mapid, Player* p, bool NeedBlocked, const Roll &r)
void Group::SendLootStartRollToPlayer(uint32 countDown, uint32 mapId, Player* p, bool canNeed, Roll const& r)
{
if (!p || !p->GetSession())
return;
WorldPacket data(SMSG_LOOT_START_ROLL, (8 + 4 + 4 + 4 + 4 + 4 + 4 + 1 ));
data << uint64(r.itemGUID); // guid of rolled item
data << uint32(mapid); // 3.3.3 mapid
data << uint32(mapId); // 3.3.3 mapid
data << uint32(r.totalPlayersRolling); // maybe the number of players rolling for it???
data << uint32(r.itemid); // the itemEntryId for the item that shall be rolled for
data << uint32(r.itemRandomSuffix); // randomSuffix
data << uint32(r.itemRandomPropId); // item random property ID
data << uint32(r.itemCount); // items in stack
data << uint32(CountDown); // the countdown time to choose "need" or "greed"
uint8 VoteMask = r.rollVoteMask;
if (NeedBlocked)
VoteMask &= ~ROLL_FLAG_TYPE_NEED;
data << uint8(VoteMask); // roll type mask
data << uint32(countDown); // the countdown time to choose "need" or "greed"
uint8 voteMask = r.rollVoteMask;
if (!canNeed)
voteMask &= ~ROLL_FLAG_TYPE_NEED;
data << uint8(voteMask); // roll type mask
p->GetSession()->SendPacket(&data);
}
@@ -944,7 +944,7 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject)
{
ItemTemplate const* item;
uint8 itemSlot = 0;
for (std::vector<LootItem>::iterator i=loot->items.begin(); i != loot->items.end(); ++i, ++itemSlot)
for (std::vector<LootItem>::iterator i = loot->items.begin(); i != loot->items.end(); ++i, ++itemSlot)
{
if (i->freeforall)
continue;
@@ -991,7 +991,7 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject)
loot->items[itemSlot].is_blocked = true;
//Broadcast Pass and Send Rollstart
for (Roll::PlayerVote::const_iterator itr=r->playerVote.begin(); itr != r->playerVote.end(); ++itr)
for (Roll::PlayerVote::const_iterator itr = r->playerVote.begin(); itr != r->playerVote.end(); ++itr)
{
Player* p = ObjectAccessor::FindPlayer(itr->first);
if (!p || !p->GetSession())
@@ -999,10 +999,8 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject)
if (itr->second == PASS)
SendLootRoll(newitemGUID, p->GetGUID(), 128, ROLL_PASS, *r);
if (p->CanRollForItem(item) == EQUIP_ERR_OK)
SendLootStartRollToPlayer(60000, lootedObject->GetMapId(), p, false, *r);
else
SendLootStartRollToPlayer(60000, lootedObject->GetMapId(), p, true, *r);
SendLootStartRollToPlayer(60000, lootedObject->GetMapId(), p, p->CanRollForItemInLFG(item, lootedObject) == EQUIP_ERR_OK, *r);
}
RollId.push_back(r);
@@ -1012,6 +1010,11 @@ void Group::NeedBeforeGreed(Loot* loot, WorldObject* lootedObject)
creature->m_groupLootTimer = 60000;
creature->lootingGroupLowGUID = GetLowGUID();
}
else if (GameObject* go = lootedObject->ToGameObject())
{
go->m_groupLootTimer = 60000;
go->lootingGroupLowGUID = GetLowGUID();
}
}
else
delete r;
+1 -1
View File
@@ -273,7 +273,7 @@ class Group
bool isRollLootActive() const;
void SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll &r);
void SendLootStartRollToPlayer(uint32 CountDown, uint32 mapid, Player* p, bool NeedBlocked, const Roll &r);
void SendLootStartRollToPlayer(uint32 countDown, uint32 mapId, Player* p, bool canNeed, Roll const& r);
void SendLootRoll(uint64 SourceGuid, uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r);
void SendLootRollWon(uint64 SourceGuid, uint64 TargetGuid, uint8 RollNumber, uint8 RollType, const Roll &r);
void SendLootAllPassed(uint32 NumberOfPlayers, const Roll &r);