Core/GameObjects: Chests will now remain locked for players who left the group if loot from that boss is stored in it (note: this is just an implementation of locking the chest, they still need to be linked to a boss - not yet implemented)
This commit is contained in:
@@ -55,6 +55,8 @@ GameObject::GameObject() : WorldObject(false), m_model(NULL), m_goValue(new Game
|
|||||||
m_DBTableGuid = 0;
|
m_DBTableGuid = 0;
|
||||||
m_rotation = 0;
|
m_rotation = 0;
|
||||||
|
|
||||||
|
m_lootRecipient = 0;
|
||||||
|
m_lootRecipientGroup = 0;
|
||||||
m_groupLootTimer = 0;
|
m_groupLootTimer = 0;
|
||||||
lootingGroupLowGUID = 0;
|
lootingGroupLowGUID = 0;
|
||||||
|
|
||||||
@@ -1968,3 +1970,57 @@ void GameObject::UpdateModel()
|
|||||||
if (m_model)
|
if (m_model)
|
||||||
GetMap()->Insert(*m_model);
|
GetMap()->Insert(*m_model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player* GameObject::GetLootRecipient() const
|
||||||
|
{
|
||||||
|
if (!m_lootRecipient)
|
||||||
|
return NULL;
|
||||||
|
return ObjectAccessor::FindPlayer(m_lootRecipient);
|
||||||
|
}
|
||||||
|
|
||||||
|
Group* GameObject::GetLootRecipientGroup() const
|
||||||
|
{
|
||||||
|
if (!m_lootRecipientGroup)
|
||||||
|
return NULL;
|
||||||
|
return sGroupMgr->GetGroupByGUID(m_lootRecipientGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameObject::SetLootRecipient(Unit* unit)
|
||||||
|
{
|
||||||
|
// set the player whose group should receive the right
|
||||||
|
// to loot the creature after it dies
|
||||||
|
// should be set to NULL after the loot disappears
|
||||||
|
|
||||||
|
if (!unit)
|
||||||
|
{
|
||||||
|
m_lootRecipient = 0;
|
||||||
|
m_lootRecipientGroup = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unit->GetTypeId() != TYPEID_PLAYER && !unit->IsVehicle())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself();
|
||||||
|
if (!player) // normal creature, no player involved
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_lootRecipient = player->GetGUID();
|
||||||
|
if (Group* group = player->GetGroup())
|
||||||
|
m_lootRecipientGroup = group->GetLowGUID();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GameObject::IsLootAllowedFor(Player const* player) const
|
||||||
|
{
|
||||||
|
if (!m_lootRecipient && !m_lootRecipientGroup)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (player->GetGUID() == m_lootRecipient)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
Group const* playerGroup = player->GetGroup();
|
||||||
|
if (!playerGroup || playerGroup != GetLootRecipientGroup()) // if we dont have a group we arent the recipient
|
||||||
|
return false; // if go doesnt have group bound it means it was solo killed by someone else
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -745,6 +745,11 @@ class GameObject : public WorldObject, public GridObject<GameObject>
|
|||||||
|
|
||||||
Loot loot;
|
Loot loot;
|
||||||
|
|
||||||
|
Player* GetLootRecipient() const;
|
||||||
|
Group* GetLootRecipientGroup() const;
|
||||||
|
void SetLootRecipient(Unit* unit);
|
||||||
|
bool IsLootAllowedFor(Player const* player) const;
|
||||||
|
bool HasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; }
|
||||||
uint32 m_groupLootTimer; // (msecs)timer used for group loot
|
uint32 m_groupLootTimer; // (msecs)timer used for group loot
|
||||||
uint32 lootingGroupLowGUID; // used to find group which is looting
|
uint32 lootingGroupLowGUID; // used to find group which is looting
|
||||||
|
|
||||||
@@ -821,6 +826,8 @@ class GameObject : public WorldObject, public GridObject<GameObject>
|
|||||||
|
|
||||||
uint64 m_rotation;
|
uint64 m_rotation;
|
||||||
|
|
||||||
|
uint64 m_lootRecipient;
|
||||||
|
uint32 m_lootRecipientGroup;
|
||||||
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
|
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
|
||||||
private:
|
private:
|
||||||
void RemoveFromOwner();
|
void RemoveFromOwner();
|
||||||
|
|||||||
@@ -486,6 +486,10 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask*
|
|||||||
}
|
}
|
||||||
updateMask->SetBit(GAMEOBJECT_DYNAMIC);
|
updateMask->SetBit(GAMEOBJECT_DYNAMIC);
|
||||||
updateMask->SetBit(GAMEOBJECT_BYTES_1);
|
updateMask->SetBit(GAMEOBJECT_BYTES_1);
|
||||||
|
|
||||||
|
if (ToGameObject()->GetGoType() == GAMEOBJECT_TYPE_CHEST && ToGameObject()->GetGOInfo()->chest.groupLootRules &&
|
||||||
|
ToGameObject()->HasLootRecipient())
|
||||||
|
updateMask->SetBit(GAMEOBJECT_FLAGS);
|
||||||
}
|
}
|
||||||
else if (isType(TYPEMASK_UNIT))
|
else if (isType(TYPEMASK_UNIT))
|
||||||
{
|
{
|
||||||
@@ -709,6 +713,15 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask*
|
|||||||
*data << uint16(-1);
|
*data << uint16(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (index == GAMEOBJECT_FLAGS)
|
||||||
|
{
|
||||||
|
uint32 flags = m_uint32Values[index];
|
||||||
|
if (ToGameObject()->GetGoType() == GAMEOBJECT_TYPE_CHEST)
|
||||||
|
if (ToGameObject()->GetGOInfo()->chest.groupLootRules && !ToGameObject()->IsLootAllowedFor(target))
|
||||||
|
flags |= GO_FLAG_LOCKED | GO_FLAG_NOT_SELECTABLE;
|
||||||
|
|
||||||
|
*data << flags;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
*data << m_uint32Values[index]; // other cases
|
*data << m_uint32Values[index]; // other cases
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user