diff options
| author | Shauren <shauren.trinity@gmail.com> | 2023-06-17 16:29:59 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2023-06-17 16:29:59 +0200 |
| commit | 0fb8765a6638fd947b59fce44d5c31251d0cdadd (patch) | |
| tree | 0414c93f15f760f755b559edb654be3c9865eb1d /src/server/scripts | |
| parent | a97cdfc8f5dedc4be1998f0b1667b519fb1ce33b (diff) | |
Core/Items: Item bonus generation improvements
* Pass ItemContext to item creation wherever possible
* Support scaling item levels with m+ keystone levels (not used currently)
* Fixed item link validation when client sends it as default uninitialized bonus list with context only
* Support scaling items depending on current active season (seasons not implemented)
* Implemented content tuning redirection
Diffstat (limited to 'src/server/scripts')
| -rw-r--r-- | src/server/scripts/Commands/cs_misc.cpp | 28 | ||||
| -rw-r--r-- | src/server/scripts/Spells/spell_monk.cpp | 2 |
2 files changed, 17 insertions, 13 deletions
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 14cba07953b..efaf039149a 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -30,6 +30,7 @@ #include "IpAddress.h" #include "IPLocation.h" #include "Item.h" +#include "ItemBonusMgr.h" #include "Language.h" #include "MiscPackets.h" #include "MMapFactory.h" @@ -1227,16 +1228,16 @@ public: // semicolon separated bonuslist ids (parse them after all arguments are extracted by strtok!) if (bonuses) for (std::string_view token : Trinity::Tokenize(bonuses, ';', false)) - if (Optional<int32> bonusListId = Trinity::StringTo<int32>(token)) + if (Optional<int32> bonusListId = Trinity::StringTo<int32>(token); bonusListId && *bonusListId) bonusListIDs.push_back(*bonusListId); ItemContext itemContext = ItemContext::NONE; if (context) { itemContext = ItemContext(Trinity::StringTo<uint8>(context).value_or(0)); - if (itemContext != ItemContext::NONE && itemContext < ItemContext::Max) + if (itemContext < ItemContext::Max) { - std::set<uint32> contextBonuses = sDB2Manager.GetDefaultItemBonusTree(itemId, itemContext); + std::vector<int32> contextBonuses = ItemBonusMgr::GetBonusListsForItem(itemId, itemContext); bonusListIDs.insert(bonusListIDs.begin(), contextBonuses.begin(), contextBonuses.end()); } } @@ -1297,7 +1298,8 @@ public: return false; } - Item* item = playerTarget->StoreNewItem(dest, itemId, true, GenerateItemRandomBonusListId(itemId), GuidSet(), itemContext, bonusListIDs); + Item* item = playerTarget->StoreNewItem(dest, itemId, true, GenerateItemRandomBonusListId(itemId), GuidSet(), itemContext, + bonusListIDs.empty() ? nullptr : &bonusListIDs); // remove binding (let GM give it to another player later) if (player == playerTarget) @@ -1392,16 +1394,16 @@ public: // semicolon separated bonuslist ids (parse them after all arguments are extracted by strtok!) if (bonuses) for (std::string_view token : Trinity::Tokenize(bonuses, ';', false)) - if (Optional<int32> bonusListId = Trinity::StringTo<int32>(token)) + if (Optional<int32> bonusListId = Trinity::StringTo<int32>(token); bonusListId && *bonusListId) bonusListIDs.push_back(*bonusListId); ItemContext itemContext = ItemContext::NONE; if (context) { itemContext = ItemContext(Trinity::StringTo<uint8>(context).value_or(0)); - if (itemContext != ItemContext::NONE && itemContext < ItemContext::Max) + if (itemContext < ItemContext::Max) { - std::set<uint32> contextBonuses = sDB2Manager.GetDefaultItemBonusTree(itemId, itemContext); + std::vector<int32> contextBonuses = ItemBonusMgr::GetBonusListsForItem(itemId, itemContext); bonusListIDs.insert(bonusListIDs.begin(), contextBonuses.begin(), contextBonuses.end()); } } @@ -1457,7 +1459,8 @@ public: return false; } - Item* item = playerTarget->StoreNewItem(dest, itemId, true, GenerateItemRandomBonusListId(itemId), GuidSet(), itemContext, bonusListIDs); + Item* item = playerTarget->StoreNewItem(dest, itemId, true, GenerateItemRandomBonusListId(itemId), GuidSet(), itemContext, + bonusListIDs.empty() ? nullptr : &bonusListIDs); // remove binding (let GM give it to another player later) if (player == playerTarget) @@ -1493,7 +1496,7 @@ public: // semicolon separated bonuslist ids (parse them after all arguments are extracted by strtok!) if (bonuses) for (std::string_view token : Trinity::Tokenize(*bonuses, ';', false)) - if (Optional<int32> bonusListId = Trinity::StringTo<int32>(token)) + if (Optional<int32> bonusListId = Trinity::StringTo<int32>(token); bonusListId && *bonusListId) bonusListIDs.push_back(*bonusListId); ItemContext itemContext = ItemContext::NONE; @@ -1518,13 +1521,14 @@ public: if (msg == EQUIP_ERR_OK) { std::vector<int32> bonusListIDsForItem = bonusListIDs; // copy, bonuses for each depending on context might be different for each item - if (itemContext != ItemContext::NONE && itemContext < ItemContext::Max) + if (itemContext < ItemContext::Max) { - std::set<uint32> contextBonuses = sDB2Manager.GetDefaultItemBonusTree(itemTemplatePair.first, itemContext); + std::vector<int32> contextBonuses = ItemBonusMgr::GetBonusListsForItem(itemTemplatePair.first, itemContext); bonusListIDsForItem.insert(bonusListIDsForItem.begin(), contextBonuses.begin(), contextBonuses.end()); } - Item* item = playerTarget->StoreNewItem(dest, itemTemplatePair.first, true, {}, GuidSet(), itemContext, bonusListIDsForItem); + Item* item = playerTarget->StoreNewItem(dest, itemTemplatePair.first, true, {}, GuidSet(), itemContext, + bonusListIDsForItem.empty() ? nullptr : &bonusListIDsForItem); // remove binding (let GM give it to another player later) if (player == playerTarget) diff --git a/src/server/scripts/Spells/spell_monk.cpp b/src/server/scripts/Spells/spell_monk.cpp index f74034b8d21..d5846f9b16d 100644 --- a/src/server/scripts/Spells/spell_monk.cpp +++ b/src/server/scripts/Spells/spell_monk.cpp @@ -341,7 +341,7 @@ class spell_monk_stagger : public AuraScript Unit* target = GetTarget(); float agility = target->GetStat(STAT_AGILITY); float base = CalculatePct(agility, float(effect->GetAmount())); - float K = sDB2Manager.EvaluateExpectedStat(ExpectedStatType::ArmorConstant, target->GetLevel(), -2, 0, Classes(target->GetClass())); + float K = sDB2Manager.EvaluateExpectedStat(ExpectedStatType::ArmorConstant, target->GetLevel(), -2, 0, Classes(target->GetClass()), 0); float newAmount = (base / (base + K)); newAmount *= multiplier; |
