aboutsummaryrefslogtreecommitdiff
path: root/src/game/Item.cpp
diff options
context:
space:
mode:
authorMachiavelli <none@none>2009-06-09 21:56:56 +0200
committerMachiavelli <none@none>2009-06-09 21:56:56 +0200
commit1afdfd91066805cac42e4d73fcac78591c139c89 (patch)
treefdeb525bd9bd8dd84351dea70e0c8766a04a101d /src/game/Item.cpp
parent41baf8b0d34dba1bd579831fe77bcc785f857f9b (diff)
parentc5232138f870a8a4e5a59ecb3e0a3228373f58e2 (diff)
Merge
--HG-- branch : trunk
Diffstat (limited to 'src/game/Item.cpp')
-rw-r--r--src/game/Item.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/game/Item.cpp b/src/game/Item.cpp
index 36ddcd16828..06268f2fef7 100644
--- a/src/game/Item.cpp
+++ b/src/game/Item.cpp
@@ -776,6 +776,23 @@ bool Item::IsFitToSpellRequirements(SpellEntry const* spellInfo) const
return true;
}
+bool Item::IsTargetValidForItemUse(Unit* pUnitTarget)
+{
+ ItemRequiredTargetMapBounds bounds = objmgr.GetItemRequiredTargetMapBounds(GetProto()->ItemId);
+
+ if (bounds.first == bounds.second)
+ return true;
+
+ if (!pUnitTarget)
+ return false;
+
+ for(ItemRequiredTargetMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
+ if(itr->second.IsFitToRequirements(pUnitTarget))
+ return true;
+
+ return false;
+}
+
void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges)
{
// Better lost small time at check in comparison lost time at item save to DB.
@@ -982,3 +999,16 @@ bool Item::IsBindedNotWith( Player const* player ) const
return objmgr.GetPlayerAccountIdByGUID(GetOwnerGUID()) != player->GetSession()->GetAccountId();
}
}
+
+bool ItemRequiredTarget::IsFitToRequirements( Unit* pUnitTarget ) const
+{
+ switch(m_uiType)
+ {
+ case ITEM_TARGET_TYPE_CREATURE:
+ return pUnitTarget->isAlive();
+ case ITEM_TARGET_TYPE_DEAD:
+ return !pUnitTarget->isAlive();
+ default:
+ return false;
+ }
+}