diff options
author | Shauren <shauren.trinity@gmail.com> | 2019-12-03 00:40:04 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2019-12-03 00:40:04 +0100 |
commit | d02f3ca7cab196eb2b2b14410582aff009b04817 (patch) | |
tree | 9f73589223f35e262444e31a8e712f00aa0753a3 | |
parent | 459fe6109dd06c8f2255a944574538f1eab4454c (diff) |
Core/Items: Changed how azerite item bonuses are applied at login to avoid applying them twice
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 30 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 7 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/StatSystem.cpp | 2 |
3 files changed, 27 insertions, 12 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 36bc994a9d6..e09b82e172f 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -7925,20 +7925,18 @@ void Player::ApplyAzeritePowers(Item* item, bool apply) { // milestone powers for (uint32 azeriteItemMilestonePowerId : azeriteItem->m_azeriteItemData->UnlockedEssenceMilestones) - ApplyAzeriteItemMilestonePower(item, sAzeriteItemMilestonePowerStore.AssertEntry(azeriteItemMilestonePowerId), apply); + ApplyAzeriteItemMilestonePower(azeriteItem, sAzeriteItemMilestonePowerStore.AssertEntry(azeriteItemMilestonePowerId), apply); // essences if (UF::SelectedAzeriteEssences const* selectedEssences = azeriteItem->GetSelectedAzeriteEssences()) for (uint8 slot = 0; slot < MAX_AZERITE_ESSENCE_SLOT; ++slot) if (selectedEssences->AzeriteEssenceID[slot]) - ApplyAzeriteEssence(item, selectedEssences->AzeriteEssenceID[slot], azeriteItem->GetEssenceRank(selectedEssences->AzeriteEssenceID[slot]), + ApplyAzeriteEssence(azeriteItem, selectedEssences->AzeriteEssenceID[slot], azeriteItem->GetEssenceRank(selectedEssences->AzeriteEssenceID[slot]), AzeriteItemMilestoneType(sDB2Manager.GetAzeriteItemMilestonePower(slot)->Type) == AzeriteItemMilestoneType::MajorEssence, apply); - - return; } } -void Player::ApplyAzeriteItemMilestonePower(Item* item, AzeriteItemMilestonePowerEntry const* azeriteItemMilestonePower, bool apply) +void Player::ApplyAzeriteItemMilestonePower(AzeriteItem* item, AzeriteItemMilestonePowerEntry const* azeriteItemMilestonePower, bool apply) { AzeriteItemMilestoneType type = AzeriteItemMilestoneType(azeriteItemMilestonePower->Type); if (type == AzeriteItemMilestoneType::BonusStamina) @@ -7953,7 +7951,7 @@ void Player::ApplyAzeriteItemMilestonePower(Item* item, AzeriteItemMilestonePowe } } -void Player::ApplyAzeriteEssence(Item* item, uint32 azeriteEssenceId, uint32 rank, bool major, bool apply) +void Player::ApplyAzeriteEssence(AzeriteItem* item, uint32 azeriteEssenceId, uint32 rank, bool major, bool apply) { for (uint32 currentRank = 1; currentRank <= rank; ++currentRank) { @@ -7971,7 +7969,7 @@ void Player::ApplyAzeriteEssence(Item* item, uint32 azeriteEssenceId, uint32 ran } } -void Player::ApplyAzeriteEssencePower(Item* item, AzeriteEssencePowerEntry const* azeriteEssencePower, bool major, bool apply) +void Player::ApplyAzeriteEssencePower(AzeriteItem* item, AzeriteEssencePowerEntry const* azeriteEssencePower, bool major, bool apply) { if (SpellInfo const* powerSpell = sSpellMgr->GetSpellInfo(azeriteEssencePower->MinorPowerDescription)) { @@ -8308,7 +8306,6 @@ void Player::_RemoveAllItemMods() ApplyItemEquipSpell(m_items[i], false); ApplyEnchantment(m_items[i], false); - ApplyAzeritePowers(m_items[i], false); ApplyArtifactPowers(m_items[i], false); } } @@ -8361,7 +8358,6 @@ void Player::_ApplyAllItemMods() ApplyItemEquipSpell(m_items[i], true); ApplyArtifactPowers(m_items[i], true); - ApplyAzeritePowers(m_items[i], true); ApplyEnchantment(m_items[i], true); } } @@ -8383,6 +8379,20 @@ void Player::_ApplyAllLevelScaleItemMods(bool apply) } } +void Player::ApplyAllAzeriteItemMods(bool apply) +{ + for (uint8 i = 0; i < INVENTORY_SLOT_BAG_END; ++i) + { + if (m_items[i]) + { + if (!m_items[i]->IsAzeriteItem() || m_items[i]->IsBroken() || !CanUseAttackType(Player::GetAttackBySlot(i, m_items[i]->GetTemplate()->GetInventoryType()))) + continue; + + ApplyAzeritePowers(m_items[i], apply); + } + } +} + ObjectGuid Player::GetLootWorldObjectGUID(ObjectGuid const& lootObjectGuid) const { auto itr = m_AELootView.find(lootObjectGuid); @@ -18892,6 +18902,8 @@ void Player::_LoadInventory(PreparedQueryResult result, PreparedQueryResult arti } //if (IsAlive()) _ApplyAllItemMods(); + // Apply all azerite item mods, azerite empowered item mods will get applied through its spell script + ApplyAllAzeriteItemMods(true); } void Player::_LoadVoidStorage(PreparedQueryResult result) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 6a2592a0fe0..8d82f256ff8 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -2014,6 +2014,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> void _RemoveAllItemMods(); void _ApplyAllItemMods(); void _ApplyAllLevelScaleItemMods(bool apply); + void ApplyAllAzeriteItemMods(bool apply); void _ApplyItemBonuses(Item* item, uint8 slot, bool apply); void _ApplyWeaponDamage(uint8 slot, Item* item, bool apply); bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) const; @@ -2028,9 +2029,9 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> void ApplyArtifactPowers(Item* item, bool apply); void ApplyArtifactPowerRank(Item* artifact, ArtifactPowerRankEntry const* artifactPowerRank, bool apply); void ApplyAzeritePowers(Item* item, bool apply); - void ApplyAzeriteItemMilestonePower(Item* item, AzeriteItemMilestonePowerEntry const* azeriteItemMilestonePower, bool apply); - void ApplyAzeriteEssence(Item* item, uint32 azeriteEssenceId, uint32 rank, bool major, bool apply); - void ApplyAzeriteEssencePower(Item* item, AzeriteEssencePowerEntry const* azeriteEssencePower, bool major, bool apply); + void ApplyAzeriteItemMilestonePower(AzeriteItem* item, AzeriteItemMilestonePowerEntry const* azeriteItemMilestonePower, bool apply); + void ApplyAzeriteEssence(AzeriteItem* item, uint32 azeriteEssenceId, uint32 rank, bool major, bool apply); + void ApplyAzeriteEssencePower(AzeriteItem* item, AzeriteEssencePowerEntry const* azeriteEssencePower, bool major, bool apply); void CastItemCombatSpell(DamageInfo const& damageInfo); void CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemTemplate const* proto); diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index ce487186175..722ac413329 100644 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -789,6 +789,7 @@ void Player::_ApplyAllStatBonuses() _ApplyAllAuraStatMods(); _ApplyAllItemMods(); + ApplyAllAzeriteItemMods(true); SetCanModifyStats(true); @@ -799,6 +800,7 @@ void Player::_RemoveAllStatBonuses() { SetCanModifyStats(false); + ApplyAllAzeriteItemMods(false); _RemoveAllItemMods(); _RemoveAllAuraStatMods(); |