diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2018-02-26 22:37:06 -0300 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-09-04 22:52:31 +0200 |
| commit | 9fa95b4b57c1d843392d0c321cdabbc3a21e1d69 (patch) | |
| tree | fa9f20e55994895e44704b1956e24f18b6c6e05d /src/server/game | |
| parent | 8a4e1119ac21e2d1112d1717337597fe073e495f (diff) | |
Core/Spells: Fix periodic rolling adding bonuses twice
Calculation is now done in CalculateAmount
(cherry picked from commit 93eda20d5cf6eeb34e1aee1b81469ba6e8fa7f0c)
Diffstat (limited to 'src/server/game')
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 15 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 2 | ||||
| -rw-r--r-- | src/server/game/Miscellaneous/SharedDefines.h | 2 | ||||
| -rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 12 | ||||
| -rw-r--r-- | src/server/game/Spells/SpellInfo.h | 1 | ||||
| -rw-r--r-- | src/server/game/Spells/SpellMgr.cpp | 5 | ||||
| -rw-r--r-- | src/server/game/Spells/SpellMgr.h | 5 |
7 files changed, 18 insertions, 24 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index e03a84cc057..68ebc0d81dc 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -12219,21 +12219,6 @@ void Unit::OutDebugInfo() const TC_LOG_DEBUG("entities.unit", "On vehicle %u.", GetVehicleBase()->GetEntry()); } -uint32 Unit::GetRemainingPeriodicAmount(ObjectGuid caster, uint32 spellId, AuraType auraType, uint8 effectIndex) const -{ - uint32 amount = 0; - AuraEffectList const& periodicAuras = GetAuraEffectsByType(auraType); - for (AuraEffect const* aurEff : periodicAuras) - { - if (aurEff->GetCasterGUID() != caster || aurEff->GetId() != spellId || aurEff->GetEffIndex() != effectIndex || !aurEff->GetTotalTicks()) - continue; - amount += uint32((aurEff->GetAmount() * static_cast<int32>(aurEff->GetRemainingTicks())) / aurEff->GetTotalTicks()); - break; - } - - return amount; -} - void Unit::SendClearTarget() { WorldPackets::Combat::BreakTarget breakTarget; diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index a11aa499f41..3f7aa1a4308 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1664,8 +1664,6 @@ class TC_GAME_API Unit : public WorldObject static uint32 SpellCriticalDamageBonus(Unit const* caster, SpellInfo const* spellProto, uint32 damage, Unit* victim); static uint32 SpellCriticalHealingBonus(Unit const* caster, SpellInfo const* spellProto, uint32 damage, Unit* victim); - uint32 GetRemainingPeriodicAmount(ObjectGuid caster, uint32 spellId, AuraType auraType, uint8 effectIndex = 0) const; - void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply); virtual bool IsImmunedToSpell(SpellInfo const* spellInfo, WorldObject const* caster) const; uint32 GetSchoolImmunityMask() const; diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index 63733a8b220..a49d54a7a0f 100644 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -747,7 +747,7 @@ enum SpellAttr10 SPELL_ATTR10_HERB_GATHERING_MINING = 0x00000800, // 11 Only Herb Gathering and Mining SPELL_ATTR10_USE_SPELL_BASE_LEVEL_FOR_SCALING= 0x00001000, // 12 SPELL_ATTR10_RESET_COOLDOWN_ON_ENCOUNTER_END = 0x00002000, // 13 - SPELL_ATTR10_UNK14 = 0x00004000, // 14 + SPELL_ATTR10_ROLLING_PERIODIC = 0x00004000, // 14 Add remaining periodic damage to new aura when refreshed SPELL_ATTR10_UNK15 = 0x00008000, // 15 SPELL_ATTR10_UNK16 = 0x00010000, // 16 SPELL_ATTR10_CAN_DODGE_PARRY_WHILE_CASTING = 0x00020000, // 17 diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 740e885bd4b..7be6a7380bf 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -50,6 +50,7 @@ #include "WorldPacket.h" #include "WorldSession.h" #include <G3D/g3dmath.h> +#include <numeric> class Aura; // @@ -667,6 +668,17 @@ int32 AuraEffect::CalculateAmount(Unit* caster) break; } + if (GetSpellInfo()->HasAttribute(SPELL_ATTR10_ROLLING_PERIODIC)) + { + Unit::AuraEffectList const& periodicAuras = GetBase()->GetUnitOwner()->GetAuraEffectsByType(GetAuraType()); + amount = std::accumulate(std::begin(periodicAuras), std::end(periodicAuras), amount, [this](int32 val, AuraEffect const* aurEff) + { + if (aurEff->GetCasterGUID() == GetCasterGUID() && aurEff->GetId() == GetId() && aurEff->GetEffIndex() == GetEffIndex() && aurEff->GetTotalTicks() > 0) + val += aurEff->GetAmount() * static_cast<int32>(aurEff->GetRemainingTicks()) / static_cast<int32>(aurEff->GetTotalTicks()); + return val; + }); + } + GetBase()->CallScriptEffectCalcAmountHandlers(this, amount, m_canBeRecalculated); if (!GetSpellEffectInfo().EffectAttributes.HasFlag(SpellEffectAttributes::NoScaleWithStack)) amount *= GetBase()->GetStackAmount(); diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index a63d6b2985c..27571f997e9 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -196,6 +196,7 @@ enum SpellCustomAttributes SPELL_ATTR0_CU_DIRECT_DAMAGE = 0x00000100, SPELL_ATTR0_CU_CHARGE = 0x00000200, SPELL_ATTR0_CU_PICKPOCKET = 0x00000400, + SPELL_ATTR0_CU_DEPRECATED_ROLLING_PERIODIC = 0x00000800, // DO NOT REUSE SPELL_ATTR0_CU_DEPRECATED_NEGATIVE_EFF0 = 0x00001000, // DO NOT REUSE SPELL_ATTR0_CU_DEPRECATED_NEGATIVE_EFF1 = 0x00002000, // DO NOT REUSE SPELL_ATTR0_CU_DEPRECATED_NEGATIVE_EFF2 = 0x00004000, // DO NOT REUSE diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 472b052a56d..9a9bcdca436 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -638,10 +638,9 @@ bool SpellMgr::IsArenaAllowedEnchancment(uint32 ench_id) const return mEnchantCustomAttr[ench_id]; } -const std::vector<int32>* SpellMgr::GetSpellLinked(int32 spell_id) const +std::vector<int32> const* SpellMgr::GetSpellLinked(int32 spell_id) const { - SpellLinkedMap::const_iterator itr = mSpellLinkedMap.find(spell_id); - return itr != mSpellLinkedMap.end() ? &(itr->second) : nullptr; + return Trinity::Containers::MapGetValuePtr(mSpellLinkedMap, spell_id); } PetLevelupSpellSet const* SpellMgr::GetPetLevelupSpellList(uint32 petFamily) const diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index 174347fdd9e..df6ebba3a45 100644 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -579,10 +579,9 @@ struct PetDefaultSpellsEntry // < 0 for petspelldata id, > 0 for creature_id typedef std::map<int32, PetDefaultSpellsEntry> PetDefaultSpellsMap; -typedef std::vector<uint32> SpellCustomAttribute; typedef std::vector<bool> EnchantCustomAttribute; -typedef std::map<int32, std::vector<int32> > SpellLinkedMap; +typedef std::unordered_map<int32, std::vector<int32>> SpellLinkedMap; bool IsPrimaryProfessionSkill(uint32 skill); @@ -692,7 +691,7 @@ class TC_GAME_API SpellMgr SpellEnchantProcEntry const* GetSpellEnchantProcEvent(uint32 enchId) const; bool IsArenaAllowedEnchancment(uint32 ench_id) const; - const std::vector<int32> *GetSpellLinked(int32 spell_id) const; + std::vector<int32> const* GetSpellLinked(int32 spell_id) const; PetLevelupSpellSet const* GetPetLevelupSpellList(uint32 petFamily) const; PetDefaultSpellsEntry const* GetPetDefaultSpellsEntry(int32 id) const; |
