diff options
| author | Roc13x <roc13x@gmail.com> | 2018-04-18 16:41:23 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2018-04-18 18:41:23 +0300 |
| commit | cd5a704fc1629d5f606535b3756195fb311b5ef2 (patch) | |
| tree | 9c547af43db7b5c20156ffc2a9034cbb4ff9e850 /src/server/game/Entities/Player | |
| parent | 3ee4c58176e85d461d9f9fd8dacd11a216a57783 (diff) | |
Core/Items: Implemented ItemLimitCategoryCondition.db2 (#21835)
Diffstat (limited to 'src/server/game/Entities/Player')
| -rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 29 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/Player.h | 2 |
2 files changed, 26 insertions, 5 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index ae12ddc303d..27db6496e84 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -10190,11 +10190,12 @@ InventoryResult Player::CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item if (limitEntry->Flags == ITEM_LIMIT_CATEGORY_MODE_HAVE) { + uint8 limitQuantity = GetItemLimitCategoryQuantity(limitEntry); uint32 curcount = GetItemCountWithLimitCategory(pProto->GetItemLimitCategory(), pItem); - if (curcount + count > uint32(limitEntry->Quantity)) + if (curcount + count > uint32(limitQuantity)) { if (no_space_count) - *no_space_count = count + curcount - limitEntry->Quantity; + *no_space_count = count + curcount - limitQuantity; if (offendingItemId) *offendingItemId = pProto->GetId(); return EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_COUNT_EXCEEDED_IS; @@ -25979,14 +25980,15 @@ InventoryResult Player::CanEquipUniqueItem(ItemTemplate const* itemProto, uint8 return EQUIP_ERR_NOT_EQUIPPABLE; // NOTE: limitEntry->mode not checked because if item have have-limit then it applied and to equip case + uint8 limitQuantity = GetItemLimitCategoryQuantity(limitEntry); - if (limit_count > limitEntry->Quantity) + if (limit_count > limitQuantity) return EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED_IS; // there is an equip limit on this item - if (HasItemWithLimitCategoryEquipped(itemProto->GetItemLimitCategory(), limitEntry->Quantity - limit_count + 1, except_slot)) + if (HasItemWithLimitCategoryEquipped(itemProto->GetItemLimitCategory(), limitQuantity - limit_count + 1, except_slot)) return EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED_IS; - else if (HasGemWithLimitCategoryEquipped(itemProto->GetItemLimitCategory(), limitEntry->Quantity - limit_count + 1, except_slot)) + else if (HasGemWithLimitCategoryEquipped(itemProto->GetItemLimitCategory(), limitQuantity - limit_count + 1, except_slot)) return EQUIP_ERR_ITEM_MAX_COUNT_EQUIPPED_SOCKETED; } @@ -28291,3 +28293,20 @@ void Player::UpdateItemLevelAreaBasedScaling() } // @todo other types of power scaling such as timewalking } + +uint8 Player::GetItemLimitCategoryQuantity(ItemLimitCategoryEntry const* limitEntry) const +{ + uint8 limit = limitEntry->Quantity; + + if (std::vector<ItemLimitCategoryConditionEntry const*> const* limitConditions = sDB2Manager.GetItemLimitCategoryConditions(limitEntry->ID)) + { + for (ItemLimitCategoryConditionEntry const* limitCondition : *limitConditions) + { + PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(limitCondition->PlayerConditionID); + if (!playerCondition || ConditionMgr::IsPlayerMeetingCondition(this, playerCondition)) + limit += limitCondition->AddQuantity; + } + } + + return limit; +} diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index ebe275a0f0a..7c161440207 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -47,6 +47,7 @@ struct CreatureTemplate; struct CurrencyTypesEntry; struct FactionEntry; struct ItemExtendedCostEntry; +struct ItemLimitCategoryEntry; struct ItemSetEffect; struct ItemTemplate; struct Loot; @@ -2223,6 +2224,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> void SendMovieStart(uint32 movieId); uint32 DoRandomRoll(uint32 minimum, uint32 maximum); + uint8 GetItemLimitCategoryQuantity(ItemLimitCategoryEntry const* limitEntry) const; void UpdateItemLevelAreaBasedScaling(); void ActivatePvpItemLevels(bool activate) { _usePvpItemLevels = activate; } |
