aboutsummaryrefslogtreecommitdiff
path: root/src/game/Creature.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/Creature.cpp')
-rw-r--r--src/game/Creature.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 9b4332a579f..8404702f748 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -973,8 +973,7 @@ void Creature::SetLootRecipient(Unit *unit)
if (!unit)
{
m_lootRecipient = 0;
- RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
- RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED);
+ RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE|UNIT_DYNFLAG_TAPPED);
return;
}
@@ -986,6 +985,27 @@ void Creature::SetLootRecipient(Unit *unit)
SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED);
}
+// return true if this creature is tapped by the player or by a member of his group.
+bool Creature::isTappedBy(Player *player) const
+{
+ if (player->GetGUID() == m_lootRecipient)
+ return true;
+
+ Player* recipient = GetLootRecipient();
+ if (!recipient)
+ return false; // recipient exist but is offline. can't check any further.
+
+ Group* recipientGroup = recipient->GetGroup();
+ if (!recipientGroup)
+ return (player == recipient);
+
+ Group* playerGroup = player->GetGroup();
+ if (!playerGroup || playerGroup != recipientGroup)
+ return false;
+
+ return true;
+}
+
void Creature::SaveToDB()
{
// this should only be used when the creature has already been loaded