Implement auto pass on loot.

Fixes issue #1684.

--HG--
branch : trunk
This commit is contained in:
Trazom62
2010-04-17 18:55:17 +02:00
parent cc2db574f1
commit fbe4539e23
4 changed files with 62 additions and 10 deletions

View File

@@ -489,7 +489,7 @@ void Group::SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll &r)
if (!p || !p->GetSession())
continue;
if (itr->second != NOT_VALID)
if (itr->second == NOT_EMITED_YET)
p->GetSession()->SendPacket(&data);
}
}
@@ -505,7 +505,7 @@ void Group::SendLootRoll(const uint64& SourceGuid, const uint64& TargetGuid, uin
data << uint32(r.itemRandomPropId); // Item random property ID
data << uint8(RollNumber); // 0: "Need for: [item name]" > 127: "you passed on: [item name]" Roll number
data << uint8(RollType); // 0: "Need for: [item name]" 0: "You have selected need for [item name] 1: need roll 2: greed roll
data << uint8(0); // auto pass on loot
data << uint8(0); // auto pass on NeedBeforeGreed loot because player cannot use the object
for (Roll::PlayerVote::const_iterator itr=r.playerVote.begin(); itr != r.playerVote.end(); ++itr)
{
@@ -612,8 +612,18 @@ void Group::GroupLoot(Loot *loot, WorldObject* pLootedObject)
{
if (member->IsWithinDistInMap(pLootedObject,sWorld.getConfig(CONFIG_GROUP_XP_DISTANCE),false))
{
r->playerVote[member->GetGUID()] = NOT_EMITED_YET;
r->totalPlayersRolling++;
if (member->GetPassOnGroupLoot())
{
r->playerVote[member->GetGUID()] = PASS;
r->totalPass++;
// can't broadcast the pass now. need to wait until all rolling players are known.
}
else
{
r->playerVote[member->GetGUID()] = NOT_EMITED_YET;
}
}
}
}
@@ -625,6 +635,20 @@ void Group::GroupLoot(Loot *loot, WorldObject* pLootedObject)
loot->items[itemSlot].is_blocked = true;
// If there is any "auto pass", broadcast the pass now.
if (r->totalPass)
{
for (Roll::PlayerVote::const_iterator itr=r->playerVote.begin(); itr != r->playerVote.end(); ++itr)
{
Player *p = objmgr.GetPlayer(itr->first);
if (!p || !p->GetSession())
continue;
if (itr->second == PASS)
SendLootRoll(newitemGUID, p->GetGUID(), 128, ROLL_PASS, *r);
}
}
SendLootStartRoll(60000, pLootedObject->GetMapId(), *r);
RollId.push_back(r);
@@ -677,8 +701,18 @@ void Group::NeedBeforeGreed(Loot *loot, WorldObject* pLootedObject)
{
if (playerToRoll->IsWithinDistInMap(pLootedObject,sWorld.getConfig(CONFIG_GROUP_XP_DISTANCE),false))
{
r->playerVote[playerToRoll->GetGUID()] = NOT_EMITED_YET;
r->totalPlayersRolling++;
if (playerToRoll->GetPassOnGroupLoot())
{
r->playerVote[playerToRoll->GetGUID()] = PASS;
r->totalPass++;
// can't broadcast the pass now. need to wait until all rolling players are known.
}
else
{
r->playerVote[playerToRoll->GetGUID()] = NOT_EMITED_YET;
}
}
}
}
@@ -690,6 +724,20 @@ void Group::NeedBeforeGreed(Loot *loot, WorldObject* pLootedObject)
loot->items[itemSlot].is_blocked = true;
// If there is any "auto pass", broadcast the pass now.
if (r->totalPass)
{
for (Roll::PlayerVote::const_iterator itr=r->playerVote.begin(); itr != r->playerVote.end(); ++itr)
{
Player *p = objmgr.GetPlayer(itr->first);
if (!p || !p->GetSession())
continue;
if (itr->second == PASS)
SendLootRoll(newitemGUID, p->GetGUID(), 128, ROLL_PASS, *r);
}
}
SendLootStartRoll(60000, pLootedObject->GetMapId(), *r);
RollId.push_back(r);

View File

@@ -914,17 +914,16 @@ void WorldSession::HandleOptOutOfLootOpcode(WorldPacket & recv_data)
{
sLog.outDebug("WORLD: Received CMSG_OPT_OUT_OF_LOOT");
uint32 unkn;
recv_data >> unkn;
uint32 passOnLoot;
recv_data >> passOnLoot; // 1 always pass, 0 do not pass
// ignore if player not loaded
if (!GetPlayer()) // needed because STATUS_AUTHED
{
if (unkn != 0)
sLog.outError("CMSG_GROUP_PASS_ON_LOOT value<>0 for not-loaded character!");
if (passOnLoot != 0)
sLog.outError("CMSG_OPT_OUT_OF_LOOT value<>0 for not-loaded character!");
return;
}
if (unkn != 0)
sLog.outError("CMSG_GROUP_PASS_ON_LOOT: activation not implemented!");
GetPlayer()->SetPassOnGroupLoot(passOnLoot);
}

View File

@@ -337,6 +337,7 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
SetGroupInvite(NULL);
m_groupUpdateMask = 0;
m_auraRaidUpdateMask = 0;
m_bPassOnGroupLoot = false;
duel = NULL;

View File

@@ -2290,6 +2290,9 @@ class Player : public Unit, public GridObject<Player>
uint8 GetOriginalSubGroup() const { return m_originalGroup.getSubGroup(); }
void SetOriginalGroup(Group *group, int8 subgroup = -1);
void SetPassOnGroupLoot(bool bPassOnGroupLoot) { m_bPassOnGroupLoot = bPassOnGroupLoot; }
bool GetPassOnGroupLoot() const { return m_bPassOnGroupLoot; }
MapReference &GetMapRef() { return m_mapRef; }
// Set map to player and add reference
@@ -2563,6 +2566,7 @@ class Player : public Unit, public GridObject<Player>
Group *m_groupInvite;
uint32 m_groupUpdateMask;
uint64 m_auraRaidUpdateMask;
bool m_bPassOnGroupLoot;
// last used pet number (for BG's)
uint32 m_lastpetnumber;