aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2012-01-14 18:42:23 +0100
committerShauren <shauren.trinity@gmail.com>2012-01-14 18:42:23 +0100
commit894c27af520eb550764d4cacd2b43e87fd100597 (patch)
tree48df44f5a28e6b253d427e64f5a9babf4cef5ff6 /src
parentf4075f0f945c842fe2b1a08ea4a7fa253e8e2e53 (diff)
Core/Groups: Need restrictions in need before greed loot method should apply only to LFG dungeons
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/Entities/Player/Player.cpp26
-rwxr-xr-xsrc/server/game/Entities/Player/Player.h2
-rwxr-xr-xsrc/server/game/Groups/Group.cpp37
-rwxr-xr-xsrc/server/game/Groups/Group.h2
4 files changed, 44 insertions, 23 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 6a4b729e58a..bed3c0cb1a7 100755
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -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
@@ -11866,12 +11884,12 @@ InventoryResult Player::CanRollForItem(ItemTemplate const* proto) const
}
else if (proto->SubClass != ITEM_SUBCLASS_ARMOR_MAIL)
return EQUIP_ERR_CANT_DO_RIGHT_NOW;
- }
-
+ }
+
if (_class == CLASS_ROGUE || _class == CLASS_DRUID)
if (proto->SubClass != ITEM_SUBCLASS_ARMOR_LEATHER)
return EQUIP_ERR_CANT_DO_RIGHT_NOW;
-
+
if (_class == CLASS_MAGE || _class == CLASS_PRIEST || _class == CLASS_WARLOCK)
if (proto->SubClass != ITEM_SUBCLASS_ARMOR_CLOTH)
return EQUIP_ERR_CANT_DO_RIGHT_NOW;
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 2b8ea7bbdc8..7a455590506 100755
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -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);
diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp
index b2fb59ea993..19bc1ab7dea 100755
--- a/src/server/game/Groups/Group.cpp
+++ b/src/server/game/Groups/Group.cpp
@@ -190,7 +190,7 @@ void Group::LoadGroupFromDB(Field* fields)
m_raidDifficulty = RAID_DIFFICULTY_10MAN_NORMAL;
else
m_raidDifficulty = Difficulty(r_diff);
-
+
if (m_groupType & GROUPTYPE_LFG)
sLFGMgr->_LoadFromDB(fields, GetGUID());
}
@@ -547,7 +547,7 @@ bool Group::RemoveMember(uint64 guid, const RemoveMethod &method /*= GROUP_REMOV
}
SendUpdate();
-
+
if (isLFGGroup() && GetMembersCount() == 1)
{
Player* Leader = ObjectAccessor::FindPlayer(GetLeaderGUID());
@@ -700,7 +700,7 @@ void Group::Disband(bool hideDestroy /* = false */)
CharacterDatabase.CommitTransaction(trans);
ResetInstances(INSTANCE_RESET_GROUP_DISBAND, false, NULL);
ResetInstances(INSTANCE_RESET_GROUP_DISBAND, true, NULL);
-
+
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA);
stmt->setUInt32(0, m_dbStoreId);
CharacterDatabase.Execute(stmt);
@@ -740,25 +740,25 @@ 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;
diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h
index caa49125100..03f946cd3b6 100755
--- a/src/server/game/Groups/Group.h
+++ b/src/server/game/Groups/Group.h
@@ -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);