1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
|
/*
* Copyright (C)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Scripts for spells with SPELLFAMILY_PRIEST and SPELLFAMILY_GENERIC spells used by priest players.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_pri_".
*/
#include "Player.h"
#include "ScriptMgr.h"
#include "SpellScript.h"
#include "SpellAuraEffects.h"
#include "GridNotifiers.h"
enum PriestSpells
{
SPELL_PRIEST_DIVINE_AEGIS = 47753,
SPELL_PRIEST_EMPOWERED_RENEW = 63544,
SPELL_PRIEST_GLYPH_OF_CIRCLE_OF_HEALING = 55675,
SPELL_PRIEST_GLYPH_OF_LIGHTWELL = 55673,
SPELL_PRIEST_GLYPH_OF_PRAYER_OF_HEALING_HEAL = 56161,
SPELL_PRIEST_GUARDIAN_SPIRIT_HEAL = 48153,
SPELL_PRIEST_ITEM_EFFICIENCY = 37595,
SPELL_PRIEST_MANA_LEECH_PROC = 34650,
SPELL_PRIEST_PENANCE_R1 = 47540,
SPELL_PRIEST_PENANCE_R1_DAMAGE = 47758,
SPELL_PRIEST_PENANCE_R1_HEAL = 47757,
SPELL_PRIEST_REFLECTIVE_SHIELD_TRIGGERED = 33619,
SPELL_PRIEST_REFLECTIVE_SHIELD_R1 = 33201,
SPELL_PRIEST_SHADOW_WORD_DEATH = 32409,
SPELL_PRIEST_T9_HEALING_2P = 67201,
SPELL_PRIEST_VAMPIRIC_TOUCH_DISPEL = 64085,
SPELL_GENERIC_ARENA_DAMPENING = 74410,
SPELL_GENERIC_BATTLEGROUND_DAMPENING = 74411
};
enum PriestSpellIcons
{
PRIEST_ICON_ID_BORROWED_TIME = 2899,
PRIEST_ICON_ID_EMPOWERED_RENEW_TALENT = 3021,
PRIEST_ICON_ID_PAIN_AND_SUFFERING = 2874,
};
// Ours
class spell_pri_shadowfiend_scaling : public SpellScriptLoader
{
public:
spell_pri_shadowfiend_scaling() : SpellScriptLoader("spell_pri_shadowfiend_scaling") { }
class spell_pri_shadowfiend_scaling_AuraScript : public AuraScript
{
PrepareAuraScript(spell_pri_shadowfiend_scaling_AuraScript);
void CalculateResistanceAmount(AuraEffect const* aurEff, int32 & amount, bool & /*canBeRecalculated*/)
{
// xinef: shadowfiend inherits 40% of resistance from owner and 35% of armor (guessed)
if (Unit* owner = GetUnitOwner()->GetOwner())
{
SpellSchoolMask schoolMask = SpellSchoolMask(aurEff->GetSpellInfo()->Effects[aurEff->GetEffIndex()].MiscValue);
int32 modifier = schoolMask == SPELL_SCHOOL_MASK_NORMAL ? 35 : 40;
amount = CalculatePct(std::max<int32>(0, owner->GetResistance(schoolMask)), modifier);
}
}
void CalculateStatAmount(AuraEffect const* aurEff, int32 & amount, bool & /*canBeRecalculated*/)
{
// xinef: shadowfiend inherits 30% of intellect / stamina (guessed)
if (Unit* owner = GetUnitOwner()->GetOwner())
{
Stats stat = Stats(aurEff->GetSpellInfo()->Effects[aurEff->GetEffIndex()].MiscValue);
amount = CalculatePct(std::max<int32>(0, owner->GetStat(stat)), 30);
}
}
void CalculateAPAmount(AuraEffect const* aurEff, int32 & amount, bool & /*canBeRecalculated*/)
{
// xinef: shadowfiend inherits 333% of SP as AP - 35.7% of damage increase per hit
if (Unit* owner = GetUnitOwner()->GetOwner())
{
int32 shadow = owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW);
amount = CalculatePct(std::max<int32>(0, shadow), 300); // xinef: deacrased to 300, including 15% from self buff
}
}
void CalculateSPAmount(AuraEffect const* aurEff, int32 & amount, bool & /*canBeRecalculated*/)
{
// xinef: shadowfiend inherits 30% of SP
if (Unit* owner = GetUnitOwner()->GetOwner())
{
int32 shadow = owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW);
amount = CalculatePct(std::max<int32>(0, shadow), 30);
// xinef: Update appropriate player field
if (owner->GetTypeId() == TYPEID_PLAYER)
owner->SetUInt32Value(PLAYER_PET_SPELL_POWER, (uint32)amount);
}
}
void HandleEffectApply(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{
GetUnitOwner()->ApplySpellImmune(0, IMMUNITY_STATE, aurEff->GetAuraType(), true, SPELL_BLOCK_TYPE_POSITIVE);
if (aurEff->GetAuraType() == SPELL_AURA_MOD_ATTACK_POWER)
GetUnitOwner()->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_ATTACK_POWER_PCT, true, SPELL_BLOCK_TYPE_POSITIVE);
else if (aurEff->GetAuraType() == SPELL_AURA_MOD_STAT)
GetUnitOwner()->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, true, SPELL_BLOCK_TYPE_POSITIVE);
}
void Register()
{
if (m_scriptSpellId != 35661)
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pri_shadowfiend_scaling_AuraScript::CalculateResistanceAmount, EFFECT_ALL, SPELL_AURA_MOD_RESISTANCE);
if (m_scriptSpellId == 35661 || m_scriptSpellId == 35662)
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pri_shadowfiend_scaling_AuraScript::CalculateStatAmount, EFFECT_ALL, SPELL_AURA_MOD_STAT);
if (m_scriptSpellId == 35661)
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pri_shadowfiend_scaling_AuraScript::CalculateAPAmount, EFFECT_ALL, SPELL_AURA_MOD_ATTACK_POWER);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pri_shadowfiend_scaling_AuraScript::CalculateSPAmount, EFFECT_ALL, SPELL_AURA_MOD_DAMAGE_DONE);
}
OnEffectApply += AuraEffectApplyFn(spell_pri_shadowfiend_scaling_AuraScript::HandleEffectApply, EFFECT_ALL, SPELL_AURA_ANY, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const
{
return new spell_pri_shadowfiend_scaling_AuraScript();
}
};
// Theirs
// -34861 - Circle of Healing
class spell_pri_circle_of_healing : public SpellScriptLoader
{
public:
spell_pri_circle_of_healing() : SpellScriptLoader("spell_pri_circle_of_healing") { }
class spell_pri_circle_of_healing_SpellScript : public SpellScript
{
PrepareSpellScript(spell_pri_circle_of_healing_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/)
{
if (!sSpellMgr->GetSpellInfo(SPELL_PRIEST_GLYPH_OF_CIRCLE_OF_HEALING))
return false;
return true;
}
void FilterTargets(std::list<WorldObject*>& targets)
{
targets.remove_if(Trinity::RaidCheck(GetCaster(), false));
uint32 const maxTargets = GetCaster()->HasAura(SPELL_PRIEST_GLYPH_OF_CIRCLE_OF_HEALING) ? 6 : 5; // Glyph of Circle of Healing
if (targets.size() > maxTargets)
{
targets.sort(Trinity::HealthPctOrderPred());
targets.resize(maxTargets);
}
}
void Register()
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_pri_circle_of_healing_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ALLY);
}
};
SpellScript* GetSpellScript() const
{
return new spell_pri_circle_of_healing_SpellScript();
}
};
// -47509 - Divine Aegis
class spell_pri_divine_aegis : public SpellScriptLoader
{
public:
spell_pri_divine_aegis() : SpellScriptLoader("spell_pri_divine_aegis") { }
class spell_pri_divine_aegis_AuraScript : public AuraScript
{
PrepareAuraScript(spell_pri_divine_aegis_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/)
{
if (!sSpellMgr->GetSpellInfo(SPELL_PRIEST_DIVINE_AEGIS))
return false;
return true;
}
bool CheckProc(ProcEventInfo& eventInfo)
{
return eventInfo.GetProcTarget();
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
int32 absorb = CalculatePct(int32(eventInfo.GetHealInfo()->GetHeal()), aurEff->GetAmount());
// Multiple effects stack, so let's try to find this aura.
if (AuraEffect const* aegis = eventInfo.GetProcTarget()->GetAuraEffect(SPELL_PRIEST_DIVINE_AEGIS, EFFECT_0))
absorb += aegis->GetAmount();
absorb = std::min(absorb, eventInfo.GetProcTarget()->getLevel() * 125);
GetTarget()->CastCustomSpell(SPELL_PRIEST_DIVINE_AEGIS, SPELLVALUE_BASE_POINT0, absorb, eventInfo.GetProcTarget(), true, NULL, aurEff);
}
void Register()
{
DoCheckProc += AuraCheckProcFn(spell_pri_divine_aegis_AuraScript::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_pri_divine_aegis_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const
{
return new spell_pri_divine_aegis_AuraScript();
}
};
// 64844 - Divine Hymn
class spell_pri_divine_hymn : public SpellScriptLoader
{
public:
spell_pri_divine_hymn() : SpellScriptLoader("spell_pri_divine_hymn") { }
class spell_pri_divine_hymn_SpellScript : public SpellScript
{
PrepareSpellScript(spell_pri_divine_hymn_SpellScript);
void FilterTargets(std::list<WorldObject*>& targets)
{
targets.remove_if(Trinity::RaidCheck(GetCaster(), false));
uint32 const maxTargets = 3;
if (targets.size() > maxTargets)
{
targets.sort(Trinity::HealthPctOrderPred());
targets.resize(maxTargets);
}
}
void Register()
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_pri_divine_hymn_SpellScript::FilterTargets, EFFECT_ALL, TARGET_UNIT_SRC_AREA_ALLY);
}
};
SpellScript* GetSpellScript() const
{
return new spell_pri_divine_hymn_SpellScript();
}
};
// 55680 - Glyph of Prayer of Healing
class spell_pri_glyph_of_prayer_of_healing : public SpellScriptLoader
{
public:
spell_pri_glyph_of_prayer_of_healing() : SpellScriptLoader("spell_pri_glyph_of_prayer_of_healing") { }
class spell_pri_glyph_of_prayer_of_healing_AuraScript : public AuraScript
{
PrepareAuraScript(spell_pri_glyph_of_prayer_of_healing_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/)
{
if (!sSpellMgr->GetSpellInfo(SPELL_PRIEST_GLYPH_OF_PRAYER_OF_HEALING_HEAL))
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(SPELL_PRIEST_GLYPH_OF_PRAYER_OF_HEALING_HEAL);
int32 heal = int32(CalculatePct(int32(eventInfo.GetHealInfo()->GetHeal()), aurEff->GetAmount()) / triggeredSpellInfo->GetMaxTicks());
GetTarget()->CastCustomSpell(SPELL_PRIEST_GLYPH_OF_PRAYER_OF_HEALING_HEAL, SPELLVALUE_BASE_POINT0, heal, eventInfo.GetProcTarget(), true, NULL, aurEff);
}
void Register()
{
OnEffectProc += AuraEffectProcFn(spell_pri_glyph_of_prayer_of_healing_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const
{
return new spell_pri_glyph_of_prayer_of_healing_AuraScript();
}
};
// 47788 - Guardian Spirit
class spell_pri_guardian_spirit : public SpellScriptLoader
{
public:
spell_pri_guardian_spirit() : SpellScriptLoader("spell_pri_guardian_spirit") { }
class spell_pri_guardian_spirit_AuraScript : public AuraScript
{
PrepareAuraScript(spell_pri_guardian_spirit_AuraScript);
uint32 healPct;
bool Validate(SpellInfo const* /*spellInfo*/)
{
if (!sSpellMgr->GetSpellInfo(SPELL_PRIEST_GUARDIAN_SPIRIT_HEAL))
return false;
return true;
}
bool Load()
{
healPct = GetSpellInfo()->Effects[EFFECT_1].CalcValue();
return true;
}
void CalculateAmount(AuraEffect const* /*aurEff*/, int32 & amount, bool & /*canBeRecalculated*/)
{
// Set absorbtion amount to unlimited
amount = -1;
}
void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
{
Unit* target = GetTarget();
if (dmgInfo.GetDamage() < target->GetHealth())
return;
int32 healAmount = int32(target->CountPctFromMaxHealth(healPct));
// remove the aura now, we don't want 40% healing bonus
Remove(AURA_REMOVE_BY_ENEMY_SPELL);
target->CastCustomSpell(target, SPELL_PRIEST_GUARDIAN_SPIRIT_HEAL, &healAmount, NULL, NULL, true);
absorbAmount = dmgInfo.GetDamage();
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pri_guardian_spirit_AuraScript::CalculateAmount, EFFECT_1, SPELL_AURA_SCHOOL_ABSORB);
OnEffectAbsorb += AuraEffectAbsorbFn(spell_pri_guardian_spirit_AuraScript::Absorb, EFFECT_1);
}
};
AuraScript* GetAuraScript() const
{
return new spell_pri_guardian_spirit_AuraScript();
}
};
// 64904 - Hymn of Hope
class spell_pri_hymn_of_hope : public SpellScriptLoader
{
public:
spell_pri_hymn_of_hope() : SpellScriptLoader("spell_pri_hymn_of_hope") { }
class spell_pri_hymn_of_hope_SpellScript : public SpellScript
{
PrepareSpellScript(spell_pri_hymn_of_hope_SpellScript);
void FilterTargets(std::list<WorldObject*>& targets)
{
targets.remove_if(Trinity::PowerCheck(POWER_MANA, false));
targets.remove_if(Trinity::RaidCheck(GetCaster(), false));
uint32 const maxTargets = 3;
if (targets.size() > maxTargets)
{
targets.sort(Trinity::PowerPctOrderPred(POWER_MANA));
targets.resize(maxTargets);
}
}
void Register()
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_pri_hymn_of_hope_SpellScript::FilterTargets, EFFECT_ALL, TARGET_UNIT_SRC_AREA_ALLY);
}
};
SpellScript* GetSpellScript() const
{
return new spell_pri_hymn_of_hope_SpellScript();
}
};
// 37594 - Greater Heal Refund
class spell_pri_item_greater_heal_refund : public SpellScriptLoader
{
public:
spell_pri_item_greater_heal_refund() : SpellScriptLoader("spell_pri_item_greater_heal_refund") { }
class spell_pri_item_greater_heal_refund_AuraScript : public AuraScript
{
PrepareAuraScript(spell_pri_item_greater_heal_refund_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/)
{
if (!sSpellMgr->GetSpellInfo(SPELL_PRIEST_ITEM_EFFICIENCY))
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
{
PreventDefaultAction();
GetTarget()->CastSpell(GetTarget(), SPELL_PRIEST_ITEM_EFFICIENCY, true, NULL, aurEff);
}
void Register()
{
OnEffectProc += AuraEffectProcFn(spell_pri_item_greater_heal_refund_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
}
};
AuraScript* GetAuraScript() const
{
return new spell_pri_item_greater_heal_refund_AuraScript();
}
};
// -7001 - Lightwell Renew
class spell_pri_lightwell_renew : public SpellScriptLoader
{
public:
spell_pri_lightwell_renew() : SpellScriptLoader("spell_pri_lightwell_renew") { }
class spell_pri_lightwell_renew_AuraScript : public AuraScript
{
PrepareAuraScript(spell_pri_lightwell_renew_AuraScript);
void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* caster = GetCaster())
{
// Bonus from Glyph of Lightwell
if (AuraEffect* modHealing = caster->GetAuraEffect(SPELL_PRIEST_GLYPH_OF_LIGHTWELL, EFFECT_0))
AddPct(amount, modHealing->GetAmount());
}
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pri_lightwell_renew_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_PERIODIC_HEAL);
}
};
AuraScript* GetAuraScript() const
{
return new spell_pri_lightwell_renew_AuraScript();
}
};
// 8129 - Mana Burn
class spell_pri_mana_burn : public SpellScriptLoader
{
public:
spell_pri_mana_burn() : SpellScriptLoader("spell_pri_mana_burn") { }
class spell_pri_mana_burn_SpellScript : public SpellScript
{
PrepareSpellScript(spell_pri_mana_burn_SpellScript);
void HandleAfterHit()
{
if (Unit* unitTarget = GetHitUnit())
unitTarget->RemoveAurasWithMechanic((1 << MECHANIC_FEAR) | (1 << MECHANIC_POLYMORPH));
}
void Register()
{
AfterHit += SpellHitFn(spell_pri_mana_burn_SpellScript::HandleAfterHit);
}
};
SpellScript* GetSpellScript() const
{
return new spell_pri_mana_burn_SpellScript;
}
};
// 28305 - Mana Leech (Passive) (Priest Pet Aura)
class spell_pri_mana_leech : public SpellScriptLoader
{
public:
spell_pri_mana_leech() : SpellScriptLoader("spell_pri_mana_leech") { }
class spell_pri_mana_leech_AuraScript : public AuraScript
{
PrepareAuraScript(spell_pri_mana_leech_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/)
{
if (!sSpellMgr->GetSpellInfo(SPELL_PRIEST_MANA_LEECH_PROC))
return false;
return true;
}
bool Load()
{
_procTarget = NULL;
return true;
}
bool CheckProc(ProcEventInfo& /*eventInfo*/)
{
_procTarget = GetTarget()->GetOwner();
return _procTarget;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
{
PreventDefaultAction();
GetTarget()->CastSpell(_procTarget, SPELL_PRIEST_MANA_LEECH_PROC, true, NULL, aurEff);
}
void Register()
{
DoCheckProc += AuraCheckProcFn(spell_pri_mana_leech_AuraScript::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_pri_mana_leech_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
private:
Unit* _procTarget;
};
AuraScript* GetAuraScript() const
{
return new spell_pri_mana_leech_AuraScript();
}
};
// -49821 - Mind Sear
class spell_pri_mind_sear : public SpellScriptLoader
{
public:
spell_pri_mind_sear() : SpellScriptLoader("spell_pri_mind_sear") { }
class spell_pri_mind_sear_SpellScript : public SpellScript
{
PrepareSpellScript(spell_pri_mind_sear_SpellScript);
void FilterTargets(std::list<WorldObject*>& unitList)
{
unitList.remove_if(Trinity::ObjectGUIDCheck(GetCaster()->GetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT), true));
}
void Register()
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_pri_mind_sear_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ENEMY);
}
};
SpellScript* GetSpellScript() const
{
return new spell_pri_mind_sear_SpellScript();
}
};
// 47948 - Pain and Suffering (Proc)
class spell_pri_pain_and_suffering_proc : public SpellScriptLoader
{
public:
spell_pri_pain_and_suffering_proc() : SpellScriptLoader("spell_pri_pain_and_suffering_proc") { }
class spell_pri_pain_and_suffering_proc_SpellScript : public SpellScript
{
PrepareSpellScript(spell_pri_pain_and_suffering_proc_SpellScript);
void HandleEffectScriptEffect(SpellEffIndex /*effIndex*/)
{
// Refresh Shadow Word: Pain on target
if (Unit* unitTarget = GetHitUnit())
if (AuraEffect* aur = unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, 0x8000, 0, 0, GetCaster()->GetGUID()))
{
aur->GetBase()->RefreshTimersWithMods();
aur->ChangeAmount(aur->CalculateAmount(aur->GetCaster()), false);
}
}
void Register()
{
OnEffectHitTarget += SpellEffectFn(spell_pri_pain_and_suffering_proc_SpellScript::HandleEffectScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const
{
return new spell_pri_pain_and_suffering_proc_SpellScript;
}
};
// -47540 - Penance
class spell_pri_penance : public SpellScriptLoader
{
public:
spell_pri_penance() : SpellScriptLoader("spell_pri_penance") { }
class spell_pri_penance_SpellScript : public SpellScript
{
PrepareSpellScript(spell_pri_penance_SpellScript);
bool Load()
{
return GetCaster()->GetTypeId() == TYPEID_PLAYER;
}
bool Validate(SpellInfo const* spellInfo)
{
SpellInfo const* firstRankSpellInfo = sSpellMgr->GetSpellInfo(SPELL_PRIEST_PENANCE_R1);
if (!firstRankSpellInfo)
return false;
// can't use other spell than this penance due to spell_ranks dependency
if (!spellInfo->IsRankOf(firstRankSpellInfo))
return false;
uint8 rank = spellInfo->GetRank();
if (!sSpellMgr->GetSpellWithRank(SPELL_PRIEST_PENANCE_R1_DAMAGE, rank, true))
return false;
if (!sSpellMgr->GetSpellWithRank(SPELL_PRIEST_PENANCE_R1_HEAL, rank, true))
return false;
return true;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
if (Unit* unitTarget = GetHitUnit())
{
if (!unitTarget->IsAlive())
return;
uint8 rank = GetSpellInfo()->GetRank();
if (caster->IsFriendlyTo(unitTarget))
caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(SPELL_PRIEST_PENANCE_R1_HEAL, rank), false);
else
caster->CastSpell(unitTarget, sSpellMgr->GetSpellWithRank(SPELL_PRIEST_PENANCE_R1_DAMAGE, rank), false);
}
}
SpellCastResult CheckCast()
{
Unit* caster = GetCaster();
if (Unit* target = GetExplTargetUnit())
{
if (!caster->IsFriendlyTo(target))
{
if (!caster->IsValidAttackTarget(target))
return SPELL_FAILED_BAD_TARGETS;
if (!caster->isInFront(target))
return SPELL_FAILED_UNIT_NOT_INFRONT;
}
}
else
return SPELL_FAILED_BAD_TARGETS;
return SPELL_CAST_OK;
}
void Register()
{
OnEffectHitTarget += SpellEffectFn(spell_pri_penance_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
OnCheckCast += SpellCheckCastFn(spell_pri_penance_SpellScript::CheckCast);
}
};
SpellScript* GetSpellScript() const
{
return new spell_pri_penance_SpellScript;
}
};
// -17 - Power Word: Shield
class spell_pri_power_word_shield : public SpellScriptLoader
{
public:
spell_pri_power_word_shield() : SpellScriptLoader("spell_pri_power_word_shield") { }
static int32 CalculateSpellAmount(Unit* caster, int32 amount, const SpellInfo* spellInfo, const AuraEffect* aurEff)
{
// +80.68% from sp bonus
float bonus = 0.8068f;
// Borrowed Time
if (AuraEffect const* borrowedTime = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, PRIEST_ICON_ID_BORROWED_TIME, EFFECT_1))
bonus += CalculatePct(1.0f, borrowedTime->GetAmount());
bonus *= caster->SpellBaseHealingBonusDone(spellInfo->GetSchoolMask());
// Improved PW: Shield: its weird having a SPELLMOD_ALL_EFFECTS here but its blizzards doing :)
// Improved PW: Shield is only applied at the spell healing bonus because it was already applied to the base value in CalculateSpellDamage
bonus = caster->ApplyEffectModifiers(spellInfo, aurEff->GetEffIndex(), bonus);
bonus *= caster->CalculateLevelPenalty(spellInfo);
amount += int32(bonus);
// Twin Disciplines
if (AuraEffect const* twinDisciplines = caster->GetAuraEffect(SPELL_AURA_ADD_PCT_MODIFIER, SPELLFAMILY_PRIEST, 0x400000, 0, 0, caster->GetGUID()))
AddPct(amount, twinDisciplines->GetAmount());
// Focused Power, xinef: apply positive modifier only
if (int32 healModifier = caster->GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HEALING_DONE_PERCENT))
AddPct(amount, healModifier);
// Arena - Dampening
if (AuraEffect const* dampening = caster->GetAuraEffect(SPELL_GENERIC_ARENA_DAMPENING, EFFECT_0))
AddPct(amount, dampening->GetAmount());
// Battleground - Dampening
else if (AuraEffect const* dampening = caster->GetAuraEffect(SPELL_GENERIC_BATTLEGROUND_DAMPENING, EFFECT_0))
AddPct(amount, dampening->GetAmount());
return amount;
}
class spell_pri_power_word_shield_AuraScript : public AuraScript
{
PrepareAuraScript(spell_pri_power_word_shield_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/)
{
if (!sSpellMgr->GetSpellInfo(SPELL_PRIEST_REFLECTIVE_SHIELD_TRIGGERED))
return false;
if (!sSpellMgr->GetSpellInfo(SPELL_PRIEST_REFLECTIVE_SHIELD_R1))
return false;
return true;
}
void CalculateAmount(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated)
{
canBeRecalculated = false;
if (Unit* caster = GetCaster())
amount = CalculateSpellAmount(caster, amount, GetSpellInfo(), aurEff);
}
void ReflectDamage(AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount)
{
Unit* target = GetTarget();
if (dmgInfo.GetAttacker() == target)
return;
if (Unit* owner = GetUnitOwner())
if (AuraEffect* talentAurEff = owner->GetAuraEffectOfRankedSpell(SPELL_PRIEST_REFLECTIVE_SHIELD_R1, EFFECT_0))
{
int32 bp = CalculatePct(absorbAmount, talentAurEff->GetAmount());
// xinef: prevents infinite loop!
if (!dmgInfo.GetSpellInfo() || dmgInfo.GetSpellInfo()->Id != SPELL_PRIEST_REFLECTIVE_SHIELD_TRIGGERED)
target->CastCustomSpell(dmgInfo.GetAttacker(), SPELL_PRIEST_REFLECTIVE_SHIELD_TRIGGERED, &bp, NULL, NULL, true, NULL, aurEff);
}
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pri_power_word_shield_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB);
AfterEffectAbsorb += AuraEffectAbsorbFn(spell_pri_power_word_shield_AuraScript::ReflectDamage, EFFECT_0);
}
};
AuraScript* GetAuraScript() const
{
return new spell_pri_power_word_shield_AuraScript();
}
class spell_pri_power_word_shield_SpellScript : public SpellScript
{
PrepareSpellScript(spell_pri_power_word_shield_SpellScript);
SpellCastResult CheckCast()
{
Unit* caster = GetCaster();
Unit* target = GetExplTargetUnit();
if (!target)
return SPELL_FAILED_BAD_TARGETS;
if (AuraEffect* aurEff = target->GetAuraEffect(SPELL_AURA_SCHOOL_ABSORB, (SpellFamilyNames)GetSpellInfo()->SpellFamilyName, GetSpellInfo()->SpellIconID, EFFECT_0))
{
int32 newAmount = GetSpellInfo()->Effects[EFFECT_0].CalcValue(caster, NULL, NULL);
newAmount = CalculateSpellAmount(caster, newAmount, GetSpellInfo(), aurEff);
if (aurEff->GetAmount() > newAmount)
return SPELL_FAILED_AURA_BOUNCED;
}
return SPELL_CAST_OK;
}
void Register()
{
OnCheckCast += SpellCheckCastFn(spell_pri_power_word_shield_SpellScript::CheckCast);
}
};
SpellScript* GetSpellScript() const
{
return new spell_pri_power_word_shield_SpellScript;
}
};
// 33110 - Prayer of Mending Heal
class spell_pri_prayer_of_mending_heal : public SpellScriptLoader
{
public:
spell_pri_prayer_of_mending_heal() : SpellScriptLoader("spell_pri_prayer_of_mending_heal") { }
class spell_pri_prayer_of_mending_heal_SpellScript : public SpellScript
{
PrepareSpellScript(spell_pri_prayer_of_mending_heal_SpellScript);
void HandleHeal(SpellEffIndex /*effIndex*/)
{
if (Unit* caster = GetOriginalCaster())
{
if (AuraEffect* aurEff = caster->GetAuraEffect(SPELL_PRIEST_T9_HEALING_2P, EFFECT_0))
{
int32 heal = GetHitHeal();
AddPct(heal, aurEff->GetAmount());
SetHitHeal(heal);
}
}
}
void Register()
{
OnEffectHitTarget += SpellEffectFn(spell_pri_prayer_of_mending_heal_SpellScript::HandleHeal, EFFECT_0, SPELL_EFFECT_HEAL);
}
};
SpellScript* GetSpellScript() const
{
return new spell_pri_prayer_of_mending_heal_SpellScript();
}
};
// -139 - Renew
class spell_pri_renew : public SpellScriptLoader
{
public:
spell_pri_renew() : SpellScriptLoader("spell_pri_renew") { }
class spell_pri_renew_AuraScript : public AuraScript
{
PrepareAuraScript(spell_pri_renew_AuraScript);
bool Load()
{
return GetCaster() && GetCaster()->GetTypeId() == TYPEID_PLAYER;
}
void HandleApplyEffect(AuraEffect const* aurEff, AuraEffectHandleModes /*mode*/)
{
if (Unit* caster = GetCaster())
{
// Empowered Renew
if (AuraEffect const* empoweredRenewAurEff = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, PRIEST_ICON_ID_EMPOWERED_RENEW_TALENT, EFFECT_1))
{
uint32 heal = GetEffect(EFFECT_0)->GetAmount();
heal = GetTarget()->SpellHealingBonusTaken(caster, GetSpellInfo(), heal, DOT);
int32 basepoints0 = empoweredRenewAurEff->GetAmount() * GetEffect(EFFECT_0)->GetTotalTicks() * int32(heal) / 100;
caster->CastCustomSpell(GetTarget(), SPELL_PRIEST_EMPOWERED_RENEW, &basepoints0, NULL, NULL, true, NULL, aurEff);
}
}
}
void Register()
{
OnEffectApply += AuraEffectApplyFn(spell_pri_renew_AuraScript::HandleApplyEffect, EFFECT_0, SPELL_AURA_PERIODIC_HEAL, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
}
};
AuraScript* GetAuraScript() const
{
return new spell_pri_renew_AuraScript();
}
};
// -32379 - Shadow Word Death
class spell_pri_shadow_word_death : public SpellScriptLoader
{
public:
spell_pri_shadow_word_death() : SpellScriptLoader("spell_pri_shadow_word_death") { }
class spell_pri_shadow_word_death_SpellScript : public SpellScript
{
PrepareSpellScript(spell_pri_shadow_word_death_SpellScript);
void HandleDamage()
{
int32 damage = GetHitDamage();
// Pain and Suffering reduces damage
if (AuraEffect* aurEff = GetCaster()->GetDummyAuraEffect(SPELLFAMILY_PRIEST, PRIEST_ICON_ID_PAIN_AND_SUFFERING, EFFECT_1))
AddPct(damage, aurEff->GetAmount());
GetCaster()->CastCustomSpell(GetCaster(), SPELL_PRIEST_SHADOW_WORD_DEATH, &damage, 0, 0, true);
}
void Register()
{
OnHit += SpellHitFn(spell_pri_shadow_word_death_SpellScript::HandleDamage);
}
};
SpellScript* GetSpellScript() const
{
return new spell_pri_shadow_word_death_SpellScript();
}
};
// -34914 - Vampiric Touch
class spell_pri_vampiric_touch : public SpellScriptLoader
{
public:
spell_pri_vampiric_touch() : SpellScriptLoader("spell_pri_vampiric_touch") { }
class spell_pri_vampiric_touch_AuraScript : public AuraScript
{
PrepareAuraScript(spell_pri_vampiric_touch_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/)
{
if (!sSpellMgr->GetSpellInfo(SPELL_PRIEST_VAMPIRIC_TOUCH_DISPEL))
return false;
return true;
}
void HandleDispel(DispelInfo* /*dispelInfo*/)
{
if (Unit* caster = GetCaster())
if (Unit* target = GetUnitOwner())
if (AuraEffect const* aurEff = GetEffect(EFFECT_1))
{
int32 damage = aurEff->GetBaseAmount();
damage = aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue(caster, &damage, NULL) * 8;
// backfire damage
caster->CastCustomSpell(target, SPELL_PRIEST_VAMPIRIC_TOUCH_DISPEL, &damage, NULL, NULL, true, NULL, aurEff);
}
}
bool CheckProc(ProcEventInfo& eventInfo)
{
return eventInfo.GetActionTarget() && eventInfo.GetActionTarget()->IsAlive() && GetOwner()->GetGUID() == eventInfo.GetActionTarget()->GetGUID();
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
eventInfo.GetActor()->CastSpell(eventInfo.GetActor(), 57669, true, NULL, aurEff);
}
void Register()
{
AfterDispel += AuraDispelFn(spell_pri_vampiric_touch_AuraScript::HandleDispel);
DoCheckProc += AuraCheckProcFn(spell_pri_vampiric_touch_AuraScript::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_pri_vampiric_touch_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const
{
return new spell_pri_vampiric_touch_AuraScript();
}
};
void AddSC_priest_spell_scripts()
{
// Ours
new spell_pri_shadowfiend_scaling();
// Theirs
new spell_pri_circle_of_healing();
new spell_pri_divine_aegis();
new spell_pri_divine_hymn();
new spell_pri_glyph_of_prayer_of_healing();
new spell_pri_guardian_spirit();
new spell_pri_hymn_of_hope();
new spell_pri_item_greater_heal_refund();
new spell_pri_lightwell_renew();
new spell_pri_mana_burn();
new spell_pri_mana_leech();
new spell_pri_mind_sear();
new spell_pri_pain_and_suffering_proc();
new spell_pri_penance();
new spell_pri_power_word_shield();
new spell_pri_prayer_of_mending_heal();
new spell_pri_renew();
new spell_pri_shadow_word_death();
new spell_pri_vampiric_touch();
}
|