TrinityCore
Loading...
Searching...
No Matches
spell_azerite.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "ScriptMgr.h"
19#include "AzeritePackets.h"
20#include "Containers.h"
21#include "Player.h"
22#include "Spell.h"
23#include "SpellAuraEffects.h"
24#include "SpellInfo.h"
25#include "SpellMgr.h"
26#include "SpellScript.h"
27
29{
30 bool Validate(SpellInfo const* spellInfo) override
31 {
32 return ValidateSpellEffect({ { spellInfo->Id, EFFECT_1 } }) && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_1).TriggerSpell });
33 }
34
35 void CalculateAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated)
36 {
37 if (Unit* caster = GetCaster())
38 {
39 amount = 0;
40 canBeRecalculated = false;
41 for (auto const& [_, aurApp] : Trinity::Containers::MapEqualRange(caster->GetAppliedAuras(), GetEffectInfo(EFFECT_1).TriggerSpell))
42 if (aurApp->HasEffect(EFFECT_0))
43 amount += aurApp->GetBase()->GetEffect(EFFECT_0)->GetAmount();
44 }
45 }
46
51};
52
53// 270658 - Azerite Fortification
55{
56 bool CheckProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
57 {
58 Spell const* procSpell = eventInfo.GetProcSpell();
59 if (!procSpell)
60 return false;
61
62 return procSpell->GetSpellInfo()->HasAura(SPELL_AURA_MOD_STUN)
66 }
67
72};
73
79
80// 271548 - Strength in Numbers
102
108
109// 271843 - Blessed Portents
111{
112 bool Validate(SpellInfo const* /*spellInfo*/) override
113 {
115 }
116
117 void CheckProc(AuraEffect* /*aurEff*/, DamageInfo& dmgInfo, uint32& /*absorbAmount*/)
118 {
119 if (GetTarget()->HealthBelowPctDamaged(50, dmgInfo.GetDamage()))
120 {
121 if (Unit* caster = GetCaster())
122 if (AuraEffect const* trait = caster->GetAuraEffect(SPELL_BLESSED_PORTENTS_TRAIT, EFFECT_0, caster->GetGUID()))
124 .AddSpellMod(SPELLVALUE_BASE_POINT0, trait->GetAmount()));
125 }
126 else
128 }
129
134};
135
140
141// 272260 - Concentrated Mending
143{
144 bool Validate(SpellInfo const* /*spellInfo*/) override
145 {
147 }
148
150 {
151 if (Unit const* caster = GetCaster())
152 if (AuraEffect const* trait = caster->GetAuraEffect(SPELL_CONCENTRATED_MENDING_TRAIT, EFFECT_0, caster->GetGUID()))
153 aurEff->ChangeAmount(trait->GetAmount() * aurEff->GetTickNumber());
154 }
155
160};
161
169
170// 272276 - Bracing Chill
172{
177
178 bool CheckHealCaster(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
179 {
180 return GetCasterGUID() == eventInfo.GetActor()->GetGUID();
181 }
182
183 void HandleProc(AuraEffect* /*aurEff*/, ProcEventInfo& procInfo)
184 {
185 Unit* caster = procInfo.GetActor();
186 if (!caster)
187 return;
188
189 if (AuraEffect const* trait = caster->GetAuraEffect(SPELL_BRACING_CHILL_TRAIT, EFFECT_0, caster->GetGUID()))
191 CastSpellExtraArgs(TRIGGERED_FULL_MASK).AddSpellMod(SPELLVALUE_BASE_POINT0, trait->GetAmount()));
192
193 if (GetStackAmount() > 1)
196
197 Remove();
198 }
199
205};
206
207// 272436 - Bracing Chill
209{
210 void FilterTarget(std::list<WorldObject*>& targets)
211 {
212 if (targets.empty())
213 return;
214
215 std::list<WorldObject*> copy = targets;
217 {
218 return target->IsUnit() && !target->ToUnit()->HasAura(SPELL_BRACING_CHILL, GetCaster()->GetGUID());
219 }, 1);
220
221 if (!copy.empty())
222 {
223 // found a preferred target, use that
224 targets.swap(copy);
225 return;
226 }
227
229 targets.clear();
230 targets.push_back(target);
231 }
232
238
244};
245
246// 272837 - Trample the Weak
248{
249 bool CheckHealthPct(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
250 {
251 return eventInfo.GetActor()->GetHealthPct() > eventInfo.GetActionTarget()->GetHealthPct();
252 }
253
258};
259
260// 272892 - Wracking Brilliance
262{
263 enum
264 {
266 };
267
268 bool Validate(SpellInfo const* /*spellInfo*/) override
269 {
271 }
272
273 bool CheckProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
274 {
275 SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
276 if (!spellInfo)
277 return false;
278
279 if (spellInfo->Id != SPELL_AGONY_SOUL_SHARD_GAIN)
280 return false;
281
282 _canTrigger = !_canTrigger; // every other soul shard gain
283 return _canTrigger;
284 }
285
290
291 bool _canTrigger = true;
292};
293
298
299// 275514 - Orbital Precision
301{
302 bool Validate(SpellInfo const* /*spellInfo*/) override
303 {
305 }
306
307 bool CheckFrozenOrbActive(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
308 {
309 return eventInfo.GetActor()->GetAreaTrigger(SPELL_MAGE_FROZEN_ORB) != nullptr;
310 }
311
316};
317
322
323// 277966 - Blur of Talons
325{
326 bool Validate(SpellInfo const* /*spellInfo*/) override
327 {
329 }
330
331 bool CheckCoordinatedAssaultActive(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
332 {
333 return eventInfo.GetActor()->HasAura(SPELL_HUNTER_COORDINATED_ASSAULT, eventInfo.GetActor()->GetGUID());
334 }
335
340};
341
342// 278519 - Divine Right
355
356// 280409 - Blood Rite
358{
359 void HandleProc(AuraEffect* /*aurEff*/, ProcEventInfo& /*procInfo*/)
360 {
362 }
363
368};
369
370// 281843 - Tradewinds
372{
373 enum
374 {
376 };
377
378 bool Validate(SpellInfo const* /*spellInfo*/) override
379 {
381 }
382
383 void HandleRemove(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
384 {
385 if (AuraEffect const* trait = GetTarget()->GetAuraEffect(GetEffectInfo(EFFECT_1).TriggerSpell, EFFECT_1))
387 CastSpellExtraArgs(aurEff).AddSpellMod(SPELLVALUE_BASE_POINT0, trait->GetAmount()));
388 }
389
394};
395
396// 287379 - Bastion of Might
398{
399 enum
400 {
402 };
403
404 bool Validate(SpellInfo const* /*spellInfo*/) override
405 {
407 }
408
413
418};
419
420// 287650 - Echoing Blades
453
454// 287653 - Echoing Blades
456{
457 enum
458 {
460 };
461
462 bool Validate(SpellInfo const* /*spellInfo*/) override
463 {
465 }
466
467 void CalculateDamage(SpellEffectInfo const& /*spellEffectInfo*/, Unit const* /*victim*/, int32& damage, int32& /*flatMod*/, float& /*pctMod*/) const
468 {
469 if (AuraEffect const* trait = GetCaster()->GetAuraEffect(SPELL_ECHOING_BLADES_TRAIT, EFFECT_2))
470 damage = trait->GetAmountAsInt() * 2;
471 }
472
473 void ForceCritical(Unit const* /*victim*/, float& critChance)
474 {
475 critChance = 100.0f;
476 }
477
483};
484
485// 288882 - Hour of Reaping
487{
488 enum
489 {
490 SPELL_DH_SOUL_BARRIER = 263648
491 };
492
493 bool Validate(SpellInfo const* /*spellInfo*/) override
494 {
496 }
497
498 bool CheckProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/)
499 {
501 }
502
503 void TriggerSoulBarrier(AuraEffect* aurEff, ProcEventInfo& /*procInfo*/)
504 {
506 }
507
513};
514
515// 304086 - Azerite Fortification
517{
518 bool CheckProc(AuraEffect const* /*aurEff*/, ProcEventInfo& eventInfo)
519 {
520 Spell const* procSpell = eventInfo.GetProcSpell();
521 if (!procSpell)
522 return false;
523
524 return procSpell->GetSpellInfo()->HasAura(SPELL_AURA_MOD_STUN)
526 }
527
532};
533
534// 305723 - Strife (Azerite Essence)
536{
537 bool CheckProc(ProcEventInfo& eventInfo)
538 {
539 if (eventInfo.GetHitMask() & (PROC_HIT_INTERRUPT | PROC_HIT_DISPEL))
540 return true;
541
542 Spell const* procSpell = eventInfo.GetProcSpell();
543 if (!procSpell)
544 return false;
545
546 bool isCrowdControl = procSpell->GetSpellInfo()->HasAura(SPELL_AURA_MOD_CONFUSE)
554
555 if (!isCrowdControl)
556 return false;
557
558 return eventInfo.GetActionTarget()->HasAura([&](Aura const* aura) { return aura->GetCastId() == procSpell->m_castId; });
559 }
560
565};
566
567// 277253 - Heart of Azeroth
569{
570 void SetEquippedFlag(AuraEffect const* /*effect*/, AuraEffectHandleModes /*mode*/)
571 {
572 SetState(true);
573 }
574
575 void ClearEquippedFlag(AuraEffect const* /*effect*/, AuraEffectHandleModes /*mode*/)
576 {
577 SetState(false);
578 }
579
580 void SetState(bool equipped) const
581 {
582 if (Player* target = GetTarget()->ToPlayer())
583 {
584 target->ApplyAllAzeriteEmpoweredItemMods(equipped);
585
587 statusChanged.IsHeartEquipped = equipped;
588 target->SendDirectMessage(statusChanged.Write());
589 }
590 }
591
597};
598
599// 315176 - Grasping Tendrils
601{
602 bool Load() override
603 {
604 return GetUnitOwner()->IsPlayer();
605 }
606
607 void CalcAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& canBeRecalculated)
608 {
609 Player* player = GetUnitOwner()->ToPlayer();
610 amount = std::clamp(10.0f + player->GetRatingBonusValue(CR_CORRUPTION) - player->GetRatingBonusValue(CR_CORRUPTION_RESISTANCE), 0.0f, 99.0f);
611 canBeRecalculated = false;
612 }
613
618};
619
int64_t int64
Definition Define.h:149
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ EFFECT_2
@ TARGET_UNIT_DEST_AREA_ALLY
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_KNOCK_BACK
@ AURA_STATE_WOUNDED_20_PERCENT
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_PROC_TRIGGER_SPELL
@ SPELL_AURA_MOD_FEAR
@ SPELL_AURA_MOD_ROOT_2
@ SPELL_AURA_MOD_RATING
@ SPELL_AURA_PERIODIC_HEAL
@ SPELL_AURA_DUMMY
@ SPELL_AURA_MOD_STUN_DISABLE_GRAVITY
@ SPELL_AURA_MOD_PACIFY
@ SPELL_AURA_MOD_SILENCE
@ SPELL_AURA_MOD_ROOT
@ SPELL_AURA_MOD_PACIFY_SILENCE
@ SPELL_AURA_MOD_DECREASE_SPEED
@ SPELL_AURA_MOD_CONFUSE
@ SPELL_AURA_MOD_STUN
@ SPELLVALUE_AURA_STACK
double SpellEffectValue
This is a double instead of float to be able to store full range of int32.
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
@ SPELLVALUE_BASE_POINT0
@ PROC_HIT_DISPEL
Definition SpellMgr.h:249
@ PROC_HIT_INTERRUPT
Definition SpellMgr.h:247
#define AuraProcFn(F)
#define SpellOnCalcCritChanceFn(F)
#define AuraEffectProcFn(F, I, N)
#define SpellEffectFn(F, I, N)
#define AuraEffectCalcAmountFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraCheckEffectProcFn(F, I, N)
#define AuraEffectUpdatePeriodicFn(F, I, N)
#define SpellCalcDamageFn(F)
#define AuraEffectAbsorbFn(F, I)
#define AuraEffectApplyFn(F, I, N, M)
#define AuraCheckProcFn(F)
#define SpellHitFn(F)
#define AuraEffectRemoveFn(F, I, N, M)
@ CR_CORRUPTION
Definition Unit.h:328
@ CR_CORRUPTION_RESISTANCE
Definition Unit.h:329
void ChangeAmount(SpellEffectValue newAmount, bool mark=true, bool onStackOrReapply=false, AuraEffect const *triggeredBy=nullptr)
uint32 GetTickNumber() const
void SetAmount(SpellEffectValue amount)
SpellEffectValue GetAmount() const
void RecalculateAmount(AuraEffect const *triggeredBy=nullptr)
void PreventDefaultAction()
HookList< EffectApplyHandler > AfterEffectRemove
HookList< CheckEffectProcHandler > DoCheckEffectProc
HookList< EffectProcHandler > AfterEffectProc
HookList< EffectCalcAmountHandler > DoEffectCalcAmount
Unit * GetCaster() const
HookList< EffectUpdatePeriodicHandler > OnEffectUpdatePeriodic
SpellEffectInfo const & GetEffectInfo(SpellEffIndex effIndex) const
AuraEffect * GetEffect(uint8 effIndex) const
HookList< EffectAbsorbHandler > OnEffectAbsorb
Aura * GetAura() const
Unit * GetTarget() const
ObjectGuid GetCasterGUID() const
void RefreshDuration()
HookList< CheckProcHandler > DoCheckProc
HookList< EffectApplyHandler > OnEffectRemove
Unit * GetUnitOwner() const
HookList< AuraProcHandler > DoPrepareProc
uint8 GetStackAmount() const
HookList< EffectApplyHandler > OnEffectApply
ObjectGuid GetCastId() const
Definition SpellAuras.h:186
uint32 CalcMaxStackAmount() const
bool IsUnit() const
Definition BaseEntity.h:171
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
bool IsPlayer() const
Definition BaseEntity.h:173
uint32 GetDamage() const
Definition Unit.h:452
Player * ToPlayer()
Definition Object.h:126
Unit * ToUnit()
Definition Object.h:116
float GetRatingBonusValue(CombatRating cr) const
Definition Player.cpp:5240
Unit * GetActionTarget() const
Definition Unit.h:500
Spell const * GetProcSpell() const
Definition Unit.h:514
ProcFlagsHit GetHitMask() const
Definition Unit.h:506
SpellInfo const * GetSpellInfo() const
Definition Unit.cpp:281
Unit * GetProcTarget() const
Definition Unit.h:501
Unit * GetActor() const
Definition Unit.h:499
bool HasEffect(SpellEffectName effect) const
uint32 const Id
Definition SpellInfo.h:328
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition SpellInfo.h:588
bool HasAura(AuraType aura) const
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
static bool ValidateSpellEffect(std::initializer_list< std::pair< uint32, SpellEffIndex > > effects)
HookList< DamageAndHealingCalcHandler > CalcDamage
Unit * GetCaster() const
HookList< HitHandler > AfterHit
int64 GetUnitTargetCountForEffect(SpellEffIndex effect) const
Unit * GetHitUnit() const
SpellValue const * GetSpellValue() const
HookList< EffectHandler > OnEffectHitTarget
Spell * GetSpell() const
HookList< OnCalcCritChanceHandler > OnCalcCritChance
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition Spell.h:277
SpellInfo const * GetSpellInfo() const
Definition Spell.h:702
ObjectGuid m_castId
Definition Spell.h:604
Definition Unit.h:635
float GetHealthPct() const
Definition Unit.h:796
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition Unit.cpp:4604
bool HasAuraState(AuraStateType flag, SpellInfo const *spellProto=nullptr, Unit const *Caster=nullptr) const
Definition Unit.cpp:6146
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4804
AreaTrigger * GetAreaTrigger(uint32 spellId) const
Definition Unit.cpp:5469
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
bool Validate(SpellInfo const *spellInfo) override
void CalculateAmount(AuraEffect const *, SpellEffectValue &amount, bool &canBeRecalculated)
bool CheckProc(AuraEffect const *, ProcEventInfo &eventInfo)
bool Validate(SpellInfo const *) override
void CheckProc(AuraEffect *, DamageInfo &dmgInfo, uint32 &)
bool Validate(SpellInfo const *) override
void HandleProc(AuraEffect *, ProcEventInfo &)
void Register() override
bool Validate(SpellInfo const *) override
bool CheckCoordinatedAssaultActive(AuraEffect const *, ProcEventInfo &eventInfo)
bool Validate(SpellInfo const *) override
bool CheckHealCaster(AuraEffect const *, ProcEventInfo &eventInfo)
void HandleProc(AuraEffect *, ProcEventInfo &procInfo)
void FilterTarget(std::list< WorldObject * > &targets)
bool Validate(SpellInfo const *) override
void RecalculateHealAmount(AuraEffect *aurEff)
bool CheckProc(ProcEventInfo &eventInfo)
bool CheckProc(AuraEffect const *, ProcEventInfo &eventInfo)
void CalcAmount(AuraEffect const *, SpellEffectValue &amount, bool &canBeRecalculated)
bool CheckHealthPct(AuraEffect const *, ProcEventInfo &eventInfo)
bool Validate(SpellInfo const *) override
void ForceCritical(Unit const *, float &critChance)
void CalculateDamage(SpellEffectInfo const &, Unit const *, int32 &damage, int32 &, float &) const
void PrepareProc(ProcEventInfo &eventInfo)
bool CheckFanOfKnivesCounter(AuraEffect const *aurEff, ProcEventInfo &)
void ReduceCounter(AuraEffect *aurEff, ProcEventInfo &)
void SetState(bool equipped) const
void SetEquippedFlag(AuraEffect const *, AuraEffectHandleModes)
void ClearEquippedFlag(AuraEffect const *, AuraEffectHandleModes)
bool CheckProc(AuraEffect const *, ProcEventInfo &)
bool Validate(SpellInfo const *) override
void TriggerSoulBarrier(AuraEffect *aurEff, ProcEventInfo &)
bool CheckFrozenOrbActive(AuraEffect const *, ProcEventInfo &eventInfo)
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *) override
void Register() override
void HandleRemove(AuraEffect const *aurEff, AuraEffectHandleModes)
bool Validate(SpellInfo const *) override
bool CheckHealthPct(AuraEffect const *, ProcEventInfo &eventInfo)
bool CheckProc(AuraEffect const *, ProcEventInfo &eventInfo)
bool Validate(SpellInfo const *) override
auto MapEqualRange(M &map, typename M::key_type const &key)
auto SelectRandomContainerElement(C const &container) -> std::add_const_t< decltype(*std::ranges::begin(container))> &
Definition Containers.h:110
void RandomResize(C &container, std::size_t requestedSize)
Definition Containers.h:67
BracingChill
@ SPELL_BRACING_CHILL
@ SPELL_BRACING_CHILL_SEARCH_JUMP_TARGET
@ SPELL_BRACING_CHILL_TRAIT
@ SPELL_BRACING_CHILL_HEAL
BlessedPortents
@ SPELL_BLESSED_PORTENTS_TRAIT
@ SPELL_BLESSED_PORTENTS_HEAL
ConcentratedMending
@ SPELL_CONCENTRATED_MENDING_TRAIT
void AddSC_azerite_item_spell_scripts()
OrbitalPrecision
@ SPELL_MAGE_FROZEN_ORB
StrengthInNumbers
@ SPELL_STRENGTH_IN_NUMBERS_BUFF
@ SPELL_STRENGTH_IN_NUMBERS_TRAIT
BlurOfTalons
@ SPELL_HUNTER_COORDINATED_ASSAULT
CastSpellExtraArgs & AddSpellMod(SpellValueMod mod, int32 val)