mirror of
https://github.com/mangosfour/server.git
synced 2025-12-17 16:37:00 +00:00
[11878] Add group looting rules for gameobjects (chests)
Patch based on original work by Wowka321 Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
parent
16b244373a
commit
461be74c3a
7 changed files with 209 additions and 26 deletions
|
|
@ -585,7 +585,7 @@ void Group::SendLootAllPassed(Roll const& r)
|
|||
}
|
||||
}
|
||||
|
||||
void Group::GroupLoot(Creature *creature, Loot *loot)
|
||||
void Group::GroupLoot(WorldObject* pSource, Loot* loot)
|
||||
{
|
||||
uint32 maxEnchantingSkill = GetMaxSkillValueForGroup(SKILL_ENCHANTING);
|
||||
|
||||
|
|
@ -601,13 +601,13 @@ void Group::GroupLoot(Creature *creature, Loot *loot)
|
|||
|
||||
//roll for over-threshold item if it's one-player loot
|
||||
if (itemProto->Quality >= uint32(m_lootThreshold) && !lootItem.freeforall)
|
||||
StartLootRool(creature, GROUP_LOOT, loot, itemSlot, maxEnchantingSkill);
|
||||
StartLootRool(pSource, GROUP_LOOT, loot, itemSlot, maxEnchantingSkill);
|
||||
else
|
||||
lootItem.is_underthreshold = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void Group::NeedBeforeGreed(Creature *creature, Loot *loot)
|
||||
void Group::NeedBeforeGreed(WorldObject* pSource, Loot* loot)
|
||||
{
|
||||
uint32 maxEnchantingSkill = GetMaxSkillValueForGroup(SKILL_ENCHANTING);
|
||||
|
||||
|
|
@ -623,13 +623,13 @@ void Group::NeedBeforeGreed(Creature *creature, Loot *loot)
|
|||
|
||||
//only roll for one-player items, not for ones everyone can get
|
||||
if (itemProto->Quality >= uint32(m_lootThreshold) && !lootItem.freeforall)
|
||||
StartLootRool(creature, NEED_BEFORE_GREED, loot, itemSlot, maxEnchantingSkill);
|
||||
StartLootRool(pSource, NEED_BEFORE_GREED, loot, itemSlot, maxEnchantingSkill);
|
||||
else
|
||||
lootItem.is_underthreshold = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void Group::MasterLoot(Creature *creature, Loot* loot)
|
||||
void Group::MasterLoot(WorldObject* pSource, Loot* loot)
|
||||
{
|
||||
for (LootItemList::iterator i=loot->items.begin(); i != loot->items.end(); ++i)
|
||||
{
|
||||
|
|
@ -651,7 +651,7 @@ void Group::MasterLoot(Creature *creature, Loot* loot)
|
|||
if (!looter->IsInWorld())
|
||||
continue;
|
||||
|
||||
if (looter->IsWithinDist(creature, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false))
|
||||
if (looter->IsWithinDist(pSource, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false))
|
||||
{
|
||||
data << looter->GetObjectGuid();
|
||||
++real_count;
|
||||
|
|
@ -663,7 +663,7 @@ void Group::MasterLoot(Creature *creature, Loot* loot)
|
|||
for(GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
Player *looter = itr->getSource();
|
||||
if (looter->IsWithinDist(creature, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false))
|
||||
if (looter->IsWithinDist(pSource, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false))
|
||||
looter->GetSession()->SendPacket(&data);
|
||||
}
|
||||
}
|
||||
|
|
@ -743,7 +743,7 @@ bool Group::CountRollVote(ObjectGuid const& playerGUID, Rolls::iterator& rollI,
|
|||
return false;
|
||||
}
|
||||
|
||||
void Group::StartLootRool(Creature* lootTarget, LootMethod method, Loot* loot, uint8 itemSlot, uint32 maxEnchantingSkill)
|
||||
void Group::StartLootRool(WorldObject* lootTarget, LootMethod method, Loot* loot, uint8 itemSlot, uint32 maxEnchantingSkill)
|
||||
{
|
||||
if (itemSlot >= loot->items.size())
|
||||
return;
|
||||
|
|
@ -778,11 +778,15 @@ void Group::StartLootRool(Creature* lootTarget, LootMethod method, Loot* loot, u
|
|||
r->playerVote.begin()->second = ROLL_NEED;
|
||||
else
|
||||
{
|
||||
// Only GO-group looting and NPC-group looting possible
|
||||
MANGOS_ASSERT(lootTarget->isType(TYPEMASK_CREATURE_OR_GAMEOBJECT));
|
||||
|
||||
r->CalculateCommonVoteMask(maxEnchantingSkill); // dependent from item and possible skill
|
||||
|
||||
SendLootStartRoll(LOOT_ROLL_TIMEOUT, lootTarget->GetMapId(), *r);
|
||||
loot->items[itemSlot].is_blocked = true;
|
||||
lootTarget->StartGroupLoot(this,LOOT_ROLL_TIMEOUT);
|
||||
|
||||
lootTarget->StartGroupLoot(this, LOOT_ROLL_TIMEOUT);
|
||||
}
|
||||
|
||||
RollId.push_back(r);
|
||||
|
|
@ -1488,7 +1492,7 @@ uint32 Group::GetMaxSkillValueForGroup( SkillType skill )
|
|||
return maxvalue;
|
||||
}
|
||||
|
||||
void Group::UpdateLooterGuid( Creature* creature, bool ifneed )
|
||||
void Group::UpdateLooterGuid(WorldObject* pSource, bool ifneed)
|
||||
{
|
||||
switch (GetLootMethod())
|
||||
{
|
||||
|
|
@ -1508,7 +1512,7 @@ void Group::UpdateLooterGuid( Creature* creature, bool ifneed )
|
|||
{
|
||||
// not update if only update if need and ok
|
||||
Player* looter = ObjectAccessor::FindPlayer(guid_itr->guid);
|
||||
if (looter && looter->IsWithinDist(creature, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false))
|
||||
if (looter && looter->IsWithinDist(pSource, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false))
|
||||
return;
|
||||
}
|
||||
++guid_itr;
|
||||
|
|
@ -1521,16 +1525,16 @@ void Group::UpdateLooterGuid( Creature* creature, bool ifneed )
|
|||
{
|
||||
if (Player* pl = ObjectAccessor::FindPlayer(itr->guid))
|
||||
{
|
||||
if (pl->IsWithinDist(creature, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false))
|
||||
if (pl->IsWithinDist(pSource, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false))
|
||||
{
|
||||
bool refresh = pl->GetLootGuid() == creature->GetObjectGuid();
|
||||
bool refresh = pl->GetLootGuid() == pSource->GetObjectGuid();
|
||||
|
||||
//if(refresh) // update loot for new looter
|
||||
// pl->GetSession()->DoLootRelease(pl->GetLootGUID());
|
||||
SetLooterGuid(pl->GetObjectGuid());
|
||||
SendUpdate();
|
||||
if (refresh) // update loot for new looter
|
||||
pl->SendLoot(creature->GetObjectGuid(), LOOT_CORPSE);
|
||||
pl->SendLoot(pSource->GetObjectGuid(), LOOT_CORPSE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -1542,16 +1546,16 @@ void Group::UpdateLooterGuid( Creature* creature, bool ifneed )
|
|||
{
|
||||
if (Player* pl = ObjectAccessor::FindPlayer(itr->guid))
|
||||
{
|
||||
if (pl->IsWithinDist(creature, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false))
|
||||
if (pl->IsWithinDist(pSource, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false))
|
||||
{
|
||||
bool refresh = pl->GetLootGuid() == creature->GetObjectGuid();
|
||||
bool refresh = pl->GetLootGuid() == pSource->GetObjectGuid();
|
||||
|
||||
//if(refresh) // update loot for new looter
|
||||
// pl->GetSession()->DoLootRelease(pl->GetLootGUID());
|
||||
SetLooterGuid(pl->GetObjectGuid());
|
||||
SendUpdate();
|
||||
if (refresh) // update loot for new looter
|
||||
pl->SendLoot(creature->GetObjectGuid(), LOOT_CORPSE);
|
||||
pl->SendLoot(pSource->GetObjectGuid(), LOOT_CORPSE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue