Core/Spells: Restored totem category check

Revert "Core/Totems: In cata totem items are no longer needed"

This reverts commit 45e0cae7be
This commit is contained in:
Shauren
2015-02-21 16:58:09 +01:00
parent d2396fb897
commit ea9eccae85
5 changed files with 51 additions and 2 deletions
+1 -1
View File
@@ -828,7 +828,7 @@ uint32 GetExpansionForLevel(uint32 level)
return CURRENT_EXPANSION;
}
bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId)
bool IsTotemCategoryCompatibleWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId)
{
if (requiredTotemCategoryId == 0)
return true;
+1 -1
View File
@@ -61,7 +61,7 @@ uint32 GetExpansionForLevel(uint32 level);
ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId);
bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId);
bool IsTotemCategoryCompatibleWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId);
void Zone2MapCoordinates(float &x, float &y, uint32 zone);
void Map2ZoneCoordinates(float &x, float &y, uint32 zone);
@@ -631,6 +631,7 @@ struct ItemTemplate
uint32 GetArea() const { return ExtendedData->Area; }
uint32 GetMap() const { return ExtendedData->Map; }
uint32 GetBagFamily() const { return ExtendedData->BagFamily; }
uint32 GetTotemCategory() const { return ExtendedData->TotemCategory; }
SocketColor GetSocketColor(uint32 index) const { ASSERT(index < MAX_ITEM_PROTO_SOCKETS); return SocketColor(ExtendedData->SocketColor[index]); }
uint32 GetSocketBonus() const { return ExtendedData->SocketBonus; }
uint32 GetGemProperties() const { return ExtendedData->GemProperties; }
@@ -10211,6 +10211,34 @@ InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& des
return CanStoreItem(bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL);
}
bool Player::HasItemTotemCategory(uint32 TotemCategory) const
{
Item* item;
for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i)
{
item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, i);
if (item && IsTotemCategoryCompatibleWith(item->GetTemplate()->GetTotemCategory(), TotemCategory))
return true;
}
Bag* bag;
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
{
bag = GetBagByPos(i);
if (bag)
{
for (uint32 j = 0; j < bag->GetBagSize(); ++j)
{
item = GetUseableItemByPos(i, j);
if (item && IsTotemCategoryCompatibleWith(item->GetTemplate()->GetTotemCategory(), TotemCategory))
return true;
}
}
}
return false;
}
InventoryResult Player::CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec &dest, ItemTemplate const* pProto, uint32& count, bool swap, Item* pSrcItem) const
{
Item* pItem2 = GetItemByPos(bag, slot);
+20
View File
@@ -6146,8 +6146,28 @@ SpellCastResult Spell::CheckItems()
else
totems -= 1;
}
if (totems != 0)
return SPELL_FAILED_TOTEMS;
// Check items for TotemCategory (items presence in inventory)
uint32 totemCategory = 2;
for (uint8 i = 0; i < 2; ++i)
{
if (m_spellInfo->TotemCategory[i] != 0)
{
if (player->HasItemTotemCategory(m_spellInfo->TotemCategory[i]))
{
totemCategory -= 1;
continue;
}
}
else
totemCategory -= 1;
}
if (totemCategory != 0)
return SPELL_FAILED_TOTEM_CATEGORY;
}
// special checks for spell effects