diff options
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/game/Spells/Spell.cpp | 72 | ||||
| -rw-r--r-- | src/server/game/Spells/Spell.h | 1 | ||||
| -rw-r--r-- | src/server/scripts/Spells/spell_generic.cpp | 67 | 
3 files changed, 84 insertions, 56 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 0450fa7fb6c..50e41fe2ff7 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -611,7 +611,6 @@ m_spellValue(new SpellValue(caster->GetMap()->GetDifficultyID(), m_spellInfo))      m_castId = ObjectGuid::Create<HighGuid::Cast>(SPELL_CAST_SOURCE_NORMAL, m_caster->GetMapId(), m_spellInfo->Id, m_caster->GetMap()->GenerateLowGuid<HighGuid::Cast>());      memset(m_misc.Raw.Data, 0, sizeof(m_misc.Raw.Data));      m_SpellVisual = caster->GetCastSpellXSpellVisualId(m_spellInfo); -    m_preCastSpell = 0;      m_triggeredByAuraSpell  = NULL;      m_spellAura = NULL; @@ -2785,15 +2784,6 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA  void Spell::DoTriggersOnSpellHit(Unit* unit, uint32 effMask)  { -    // Apply additional spell effects to target -    /// @todo move this code to scripts -    if (m_preCastSpell) -    { -        if (sSpellMgr->GetSpellInfo(m_preCastSpell)) -            // Blizz seems to just apply aura without bothering to cast -            m_caster->AddAura(m_preCastSpell, unit); -    } -      // handle SPELL_AURA_ADD_TARGET_TRIGGER auras      // this is executed after spell proc spells on target hit      // spells are triggered for each hit spell target @@ -2805,7 +2795,7 @@ void Spell::DoTriggersOnSpellHit(Unit* unit, uint32 effMask)          {              if (CanExecuteTriggersOnHit(effMask, i->triggeredByAura) && roll_chance_i(i->chance))              { -                m_caster->CastSpell(unit, i->triggeredSpell, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_TARGET_CHECK)); +                m_caster->CastSpell(unit, i->triggeredSpell, TRIGGERED_FULL_MASK);                  TC_LOG_DEBUG("spells", "Spell %d triggered spell %d by SPELL_AURA_ADD_TARGET_TRIGGER aura", m_spellInfo->Id, i->triggeredSpell->Id);                  // SPELL_AURA_ADD_TARGET_TRIGGER auras shouldn't trigger auras without duration @@ -7518,56 +7508,28 @@ bool Spell::CanExecuteTriggersOnHit(uint32 effMask, SpellInfo const* triggeredBy  void Spell::PrepareTriggersExecutedOnHit()  { -    /// @todo move this to scripts -    if (m_spellInfo->SpellFamilyName) -    { -        SpellInfo const* excludeCasterSpellInfo = sSpellMgr->GetSpellInfo(m_spellInfo->ExcludeCasterAuraSpell); -        if (excludeCasterSpellInfo && !excludeCasterSpellInfo->IsPositive()) -            m_preCastSpell = m_spellInfo->ExcludeCasterAuraSpell; -        SpellInfo const* excludeTargetSpellInfo = sSpellMgr->GetSpellInfo(m_spellInfo->ExcludeTargetAuraSpell); -        if (excludeTargetSpellInfo && !excludeTargetSpellInfo->IsPositive()) -            m_preCastSpell = m_spellInfo->ExcludeTargetAuraSpell; -    } - -    /// @todo move this to scripts -    switch (m_spellInfo->SpellFamilyName) -    { -        case SPELLFAMILY_MAGE: -        { -             // Permafrost -             if (m_spellInfo->SpellFamilyFlags[1] & 0x00001000 ||  m_spellInfo->SpellFamilyFlags[0] & 0x00100220) -                 m_preCastSpell = 68391; -             break; -        } -    } -      // handle SPELL_AURA_ADD_TARGET_TRIGGER auras:      // save auras which were present on spell caster on cast, to prevent triggered auras from affecting caster      // and to correctly calculate proc chance when combopoints are present      Unit::AuraEffectList const& targetTriggers = m_caster->GetAuraEffectsByType(SPELL_AURA_ADD_TARGET_TRIGGER); -    for (Unit::AuraEffectList::const_iterator i = targetTriggers.begin(); i != targetTriggers.end(); ++i) +    for (AuraEffect const* aurEff : targetTriggers)      { -        if (!(*i)->IsAffectingSpell(m_spellInfo)) +        if (!aurEff->IsAffectingSpell(m_spellInfo))              continue; -        SpellInfo const* auraSpellInfo = (*i)->GetSpellInfo(); -        uint32 auraSpellIdx = (*i)->GetEffIndex(); -        // todo 6.x -        if (SpellEffectInfo const* auraEffect = auraSpellInfo->GetEffect(m_caster->GetMap()->GetDifficultyID(), auraSpellIdx)) -        { -            if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(auraEffect->TriggerSpell)) -            { -                // calculate the chance using spell base amount, because aura amount is not updated on combo-points change -                // this possibly needs fixing -                int32 auraBaseAmount = (*i)->GetBaseAmount(); -                // proc chance is stored in effect amount -                int32 chance = m_caster->CalculateSpellDamage(NULL, auraSpellInfo, auraSpellIdx, &auraBaseAmount); -                // build trigger and add to the list -                HitTriggerSpell spellTriggerInfo; -                spellTriggerInfo.triggeredSpell = spellInfo; -                spellTriggerInfo.triggeredByAura = auraSpellInfo; -                spellTriggerInfo.chance = chance * (*i)->GetBase()->GetStackAmount(); -                m_hitTriggerSpells.push_back(spellTriggerInfo); -            } + +        if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(aurEff->GetSpellEffectInfo()->TriggerSpell)) +        { +            // calculate the chance using spell base amount, because aura amount is not updated on combo-points change +            // this possibly needs fixing +            int32 auraBaseAmount = aurEff->GetBaseAmount(); +            // proc chance is stored in effect amount +            int32 chance = m_caster->CalculateSpellDamage(nullptr, aurEff->GetSpellInfo(), aurEff->GetEffIndex(), &auraBaseAmount); +            // build trigger and add to the list +            HitTriggerSpell spellTriggerInfo; +            spellTriggerInfo.triggeredSpell = spellInfo; +            spellTriggerInfo.triggeredByAura = aurEff->GetSpellInfo(); +            spellTriggerInfo.chance = chance * aurEff->GetBase()->GetStackAmount(); +            m_hitTriggerSpells.push_back(spellTriggerInfo);          }      }  } diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 20b29dd982b..a344f4deb84 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -625,7 +625,6 @@ class TC_GAME_API Spell              } Raw;          } m_misc;          uint32 m_SpellVisual; -        uint32 m_preCastSpell;          SpellCastTargets m_targets;          int8 m_comboPointGain;          SpellCustomErrors m_customError; diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index ab5fe968716..f1360c7fc8f 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -3371,6 +3371,71 @@ class spell_gen_tournament_pennant : public SpellScriptLoader          }  }; +class spell_gen_trigger_exclude_caster_aura_spell : public SpellScriptLoader +{ +    public: +        spell_gen_trigger_exclude_caster_aura_spell() : SpellScriptLoader("spell_gen_trigger_exclude_caster_aura_spell") { } + +        class spell_gen_trigger_exclude_caster_aura_spell_SpellScript : public SpellScript +        { +            PrepareSpellScript(spell_gen_trigger_exclude_caster_aura_spell_SpellScript); + +            bool Validate(SpellInfo const* spellInfo) override +            { +                return ValidateSpellInfo({ spellInfo->ExcludeCasterAuraSpell }); +            } + +            void HandleTrigger() +            { +                // Blizz seems to just apply aura without bothering to cast +                GetCaster()->AddAura(GetSpellInfo()->ExcludeCasterAuraSpell, GetCaster()); +            } + +            void Register() override +            { +                AfterCast += SpellCastFn(spell_gen_trigger_exclude_caster_aura_spell_SpellScript::HandleTrigger); +            } +        }; + +        SpellScript* GetSpellScript() const override +        { +            return new spell_gen_trigger_exclude_caster_aura_spell_SpellScript(); +        } +}; + +class spell_gen_trigger_exclude_target_aura_spell : public SpellScriptLoader +{ +    public: +        spell_gen_trigger_exclude_target_aura_spell() : SpellScriptLoader("spell_gen_trigger_exclude_target_aura_spell") { } + +        class spell_gen_trigger_exclude_target_aura_spell_SpellScript : public SpellScript +        { +            PrepareSpellScript(spell_gen_trigger_exclude_target_aura_spell_SpellScript); + +            bool Validate(SpellInfo const* spellInfo) override +            { +                return ValidateSpellInfo({ spellInfo->ExcludeTargetAuraSpell }); +            } + +            void HandleTrigger() +            { +                if (Unit* target = GetHitUnit()) +                    // Blizz seems to just apply aura without bothering to cast +                    GetCaster()->AddAura(GetSpellInfo()->ExcludeTargetAuraSpell, target); +            } + +            void Register() override +            { +                AfterHit += SpellHitFn(spell_gen_trigger_exclude_target_aura_spell_SpellScript::HandleTrigger); +            } +        }; + +        SpellScript* GetSpellScript() const override +        { +            return new spell_gen_trigger_exclude_target_aura_spell_SpellScript(); +        } +}; +  enum PvPTrinketTriggeredSpells  {      SPELL_WILL_OF_THE_FORSAKEN_COOLDOWN_TRIGGER         = 72752, @@ -4629,6 +4694,8 @@ void AddSC_generic_spell_scripts()      new spell_gen_throw_shield();      new spell_gen_tournament_duel();      new spell_gen_tournament_pennant(); +    new spell_gen_trigger_exclude_caster_aura_spell(); +    new spell_gen_trigger_exclude_target_aura_spell();      new spell_pvp_trinket_wotf_shared_cd<SPELL_WILL_OF_THE_FORSAKEN_COOLDOWN_TRIGGER>("spell_pvp_trinket_shared_cd");      new spell_pvp_trinket_wotf_shared_cd<SPELL_WILL_OF_THE_FORSAKEN_COOLDOWN_TRIGGER_WOTF>("spell_wotf_shared_cd");      new spell_gen_turkey_marker();  | 
