forked from TrinityCore/TrinityCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspell_pet.cpp
More file actions
1744 lines (1489 loc) · 68.6 KB
/
spell_pet.cpp
File metadata and controls
1744 lines (1489 loc) · 68.6 KB
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
/*
* Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/>
*
* 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_DEATHKNIGHT and SPELLFAMILY_GENERIC spells used by deathknight players.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_dk_".
*/
#include "ScriptMgr.h"
#include "SpellScript.h"
#include "SpellAuraEffects.h"
#include "Unit.h"
#include "Player.h"
#include "Pet.h"
enum HunterPetCalculate
{
SPELL_TAMED_PET_PASSIVE_06 = 19591,
SPELL_TAMED_PET_PASSIVE_07 = 20784,
SPELL_TAMED_PET_PASSIVE_08 = 34666,
SPELL_TAMED_PET_PASSIVE_09 = 34667,
SPELL_TAMED_PET_PASSIVE_10 = 34675,
SPELL_HUNTER_PET_SCALING_01 = 34902,
SPELL_HUNTER_PET_SCALING_02 = 34903,
SPELL_HUNTER_PET_SCALING_03 = 34904,
SPELL_HUNTER_PET_SCALING_04 = 61017,
SPELL_HUNTER_ANIMAL_HANDLER = 34453,
};
enum WarlockPetCalculate
{
SPELL_PET_PASSIVE_CRIT = 35695,
SPELL_PET_PASSIVE_DAMAGE_TAKEN = 35697,
SPELL_WARLOCK_PET_SCALING_01 = 34947,
SPELL_WARLOCK_PET_SCALING_02 = 34956,
SPELL_WARLOCK_PET_SCALING_03 = 34957,
SPELL_WARLOCK_PET_SCALING_04 = 34958,
SPELL_WARLOCK_PET_SCALING_05 = 61013,
ENTRY_FELGUARD = 17252,
ENTRY_VOIDWALKER = 1860,
ENTRY_FELHUNTER = 417,
ENTRY_SUCCUBUS = 1863,
ENTRY_IMP = 416,
SPELL_WARLOCK_GLYPH_OF_VOIDWALKER = 56247,
};
enum DKPetCalculate
{
SPELL_DEATH_KNIGHT_RUNE_WEAPON_02 = 51906,
SPELL_DEATH_KNIGHT_PET_SCALING_01 = 54566,
SPELL_DEATH_KNIGHT_PET_SCALING_02 = 51996,
SPELL_DEATH_KNIGHT_PET_SCALING_03 = 61697,
SPELL_NIGHT_OF_THE_DEAD = 55620,
ENTRY_ARMY_OF_THE_DEAD_GHOUL = 24207,
SPELL_DEATH_KNIGHT_GLYPH_OF_GHOUL = 58686,
};
enum ShamanPetCalculate
{
SPELL_FERAL_SPIRIT_PET_UNK_01 = 35674,
SPELL_FERAL_SPIRIT_PET_UNK_02 = 35675,
SPELL_FERAL_SPIRIT_PET_UNK_03 = 35676,
SPELL_FERAL_SPIRIT_PET_SCALING_04 = 61783,
};
enum MiscPetCalculate
{
SPELL_MAGE_PET_PASSIVE_ELEMENTAL = 44559,
SPELL_PET_HEALTH_SCALING = 61679,
SPELL_PET_UNK_01 = 67561,
SPELL_PET_UNK_02 = 67557,
};
class spell_gen_pet_calculate : public SpellScriptLoader
{
public:
spell_gen_pet_calculate() : SpellScriptLoader("spell_gen_pet_calculate") { }
class spell_gen_pet_calculate_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_pet_calculate_AuraScript);
bool Load()
{
if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER)
return false;
return true;
}
void CalculateAmountCritSpell(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
{
// For others recalculate it from:
float CritSpell = 0.0f;
// Crit from Intellect
CritSpell += owner->GetSpellCritFromIntellect();
// Increase crit from SPELL_AURA_MOD_SPELL_CRIT_CHANCE
CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_CRIT_CHANCE);
// Increase crit from SPELL_AURA_MOD_CRIT_PCT
CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT);
// Increase crit spell from spell crit ratings
CritSpell += owner->GetRatingBonusValue(CR_CRIT_SPELL);
amount += int32(CritSpell);
}
}
void CalculateAmountCritMelee(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
{
// For others recalculate it from:
float CritMelee = 0.0f;
// Crit from Agility
CritMelee += owner->GetMeleeCritFromAgility();
// Increase crit from SPELL_AURA_MOD_WEAPON_CRIT_PERCENT
CritMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_WEAPON_CRIT_PERCENT);
// Increase crit from SPELL_AURA_MOD_CRIT_PCT
CritMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT);
// Increase crit melee from melee crit ratings
CritMelee += owner->GetRatingBonusValue(CR_CRIT_MELEE);
amount += int32(CritMelee);
}
}
void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
{
// For others recalculate it from:
float HitMelee = 0.0f;
// Increase hit from SPELL_AURA_MOD_HIT_CHANCE
HitMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_HIT_CHANCE);
// Increase hit melee from meele hit ratings
HitMelee += owner->GetRatingBonusValue(CR_HIT_MELEE);
amount += int32(HitMelee);
}
}
void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
{
// For others recalculate it from:
float HitSpell = 0.0f;
// Increase hit from SPELL_AURA_MOD_SPELL_HIT_CHANCE
HitSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE);
// Increase hit spell from spell hit ratings
HitSpell += owner->GetRatingBonusValue(CR_HIT_SPELL);
amount += int32(HitSpell);
}
}
void CalculateAmountExpertise(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
{
// For others recalculate it from:
float Expertise = 0.0f;
// Increase hit from SPELL_AURA_MOD_EXPERTISE
Expertise += owner->GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE);
// Increase Expertise from Expertise ratings
Expertise += owner->GetRatingBonusValue(CR_EXPERTISE);
amount += int32(Expertise);
}
}
void Register()
{
switch (m_scriptSpellId)
{
case SPELL_TAMED_PET_PASSIVE_06:
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountCritMelee, EFFECT_0, SPELL_AURA_MOD_WEAPON_CRIT_PERCENT);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountCritSpell, EFFECT_1, SPELL_AURA_MOD_SPELL_CRIT_CHANCE);
break;
case SPELL_PET_PASSIVE_CRIT:
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountCritSpell, EFFECT_0, SPELL_AURA_MOD_SPELL_CRIT_CHANCE);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountCritMelee, EFFECT_1, SPELL_AURA_MOD_WEAPON_CRIT_PERCENT);
break;
case SPELL_WARLOCK_PET_SCALING_05:
case SPELL_HUNTER_PET_SCALING_04:
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountMeleeHit, EFFECT_0, SPELL_AURA_MOD_HIT_CHANCE);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountSpellHit, EFFECT_1, SPELL_AURA_MOD_SPELL_HIT_CHANCE);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountExpertise, EFFECT_2, SPELL_AURA_MOD_EXPERTISE);
break;
case SPELL_DEATH_KNIGHT_PET_SCALING_03:
// case SPELL_SHAMAN_PET_HIT:
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountMeleeHit, EFFECT_0, SPELL_AURA_MOD_HIT_CHANCE);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_pet_calculate_AuraScript::CalculateAmountSpellHit, EFFECT_1, SPELL_AURA_MOD_SPELL_HIT_CHANCE);
break;
default:
break;
}
}
};
AuraScript* GetAuraScript() const
{
return new spell_gen_pet_calculate_AuraScript();
}
};
class spell_warl_pet_scaling_01 : public SpellScriptLoader
{
public:
spell_warl_pet_scaling_01() : SpellScriptLoader("spell_warl_pet_scaling_01") { }
class spell_warl_pet_scaling_01_AuraScript : public AuraScript
{
PrepareAuraScript(spell_warl_pet_scaling_01_AuraScript);
bool Load()
{
if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER)
return false;
_tempBonus = 0;
return true;
}
void CalculateStaminaAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* pet = GetUnitOwner())
if (pet->isPet())
if (Unit* owner = pet->ToPet()->GetOwner())
{
float ownerBonus = CalculatePct(owner->GetStat(STAT_STAMINA), 75);
amount += ownerBonus;
}
}
void ApplyEffect(AuraEffect const* /* aurEff */, AuraEffectHandleModes /*mode*/)
{
if (Unit* pet = GetUnitOwner())
if (_tempBonus)
{
PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(pet->GetEntry(), pet->getLevel());
uint32 healthMod = 0;
uint32 baseHealth = pInfo->health;
switch (pet->GetEntry())
{
case ENTRY_IMP:
healthMod = uint32(_tempBonus * 8.4f);
break;
case ENTRY_FELGUARD:
case ENTRY_VOIDWALKER:
healthMod = _tempBonus * 11;
break;
case ENTRY_SUCCUBUS:
healthMod = uint32(_tempBonus * 9.1f);
break;
case ENTRY_FELHUNTER:
healthMod = uint32(_tempBonus * 9.5f);
break;
default:
healthMod = 0;
break;
}
if (healthMod)
pet->ToPet()->SetCreateHealth(baseHealth + healthMod);
}
}
void RemoveEffect(AuraEffect const* /* aurEff */, AuraEffectHandleModes /*mode*/)
{
if (Unit* pet = GetUnitOwner())
if (pet->isPet())
{
PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(pet->GetEntry(), pet->getLevel());
pet->ToPet()->SetCreateHealth(pInfo->health);
}
}
void CalculateAttackPowerAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* pet = GetUnitOwner())
if (pet->isPet())
if (Unit* owner = pet->ToPet()->GetOwner())
{
int32 fire = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FIRE);
int32 shadow = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_SHADOW);
int32 maximum = (fire > shadow) ? fire : shadow;
if (maximum < 0)
maximum = 0;
float bonusAP = maximum * 0.57f;
amount += bonusAP;
// Glyph of felguard
if (pet->GetEntry() == ENTRY_FELGUARD)
{
if (AuraEffect* /* aurEff */ect = owner->GetAuraEffect(56246, EFFECT_0))
{
float base_attPower = pet->GetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE) * pet->GetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_PCT);
amount += CalculatePct(amount+base_attPower, /* aurEff */ect->GetAmount());
}
}
}
}
void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* pet = GetUnitOwner())
if (pet->isPet())
if (Unit* owner = pet->ToPet()->GetOwner())
{
//the damage bonus used for pets is either fire or shadow damage, whatever is higher
int32 fire = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FIRE);
int32 shadow = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_SHADOW);
int32 maximum = (fire > shadow) ? fire : shadow;
float bonusDamage = 0.0f;
if (maximum > 0)
bonusDamage = maximum * 0.15f;
amount += bonusDamage;
}
}
void Register()
{
OnEffectRemove += AuraEffectRemoveFn(spell_warl_pet_scaling_01_AuraScript::RemoveEffect, EFFECT_0, SPELL_AURA_MOD_STAT, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK);
AfterEffectApply += AuraEffectApplyFn(spell_warl_pet_scaling_01_AuraScript::ApplyEffect, EFFECT_0, SPELL_AURA_MOD_STAT, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_01_AuraScript::CalculateStaminaAmount, EFFECT_0, SPELL_AURA_MOD_STAT);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_01_AuraScript::CalculateAttackPowerAmount, EFFECT_1, SPELL_AURA_MOD_ATTACK_POWER);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_01_AuraScript::CalculateDamageDoneAmount, EFFECT_2, SPELL_AURA_MOD_DAMAGE_DONE);
}
private:
uint32 _tempBonus;
};
AuraScript* GetAuraScript() const
{
return new spell_warl_pet_scaling_01_AuraScript();
}
};
class spell_warl_pet_scaling_02 : public SpellScriptLoader
{
public:
spell_warl_pet_scaling_02() : SpellScriptLoader("spell_warl_pet_scaling_02") { }
class spell_warl_pet_scaling_02_AuraScript : public AuraScript
{
PrepareAuraScript(spell_warl_pet_scaling_02_AuraScript);
bool Load()
{
if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER)
return false;
_tempBonus = 0;
return true;
}
void CalculateIntellectAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* pet = GetUnitOwner())
if (pet->isPet())
if (Unit* owner = pet->ToPet()->GetOwner())
{
float ownerBonus = 0.0f;
ownerBonus = CalculatePct(owner->GetStat(STAT_INTELLECT), 30);
amount += ownerBonus;
_tempBonus = ownerBonus;
}
}
void ApplyEffect(AuraEffect const* /* aurEff */, AuraEffectHandleModes /*mode*/)
{
if (Unit* pet = GetUnitOwner())
if (_tempBonus)
{
PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(pet->GetEntry(), pet->getLevel());
uint32 manaMod = 0;
uint32 baseMana = pInfo->mana;
switch (pet->GetEntry())
{
case ENTRY_IMP:
manaMod = uint32(_tempBonus * 4.9f);
break;
case ENTRY_VOIDWALKER:
case ENTRY_SUCCUBUS:
case ENTRY_FELHUNTER:
case ENTRY_FELGUARD:
manaMod = uint32(_tempBonus * 11.5f);
break;
default:
manaMod = 0;
break;
}
if (manaMod)
pet->ToPet()->SetCreateMana(baseMana + manaMod);
}
}
void RemoveEffect(AuraEffect const* /* aurEff */, AuraEffectHandleModes /*mode*/)
{
if (Unit* pet = GetUnitOwner())
if (pet->isPet())
{
PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(pet->GetEntry(), pet->getLevel());
pet->ToPet()->SetCreateMana(pInfo->mana);
}
}
void CalculateArmorAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* pet = GetUnitOwner())
if (pet->isPet())
if (Unit* owner = pet->ToPet()->GetOwner())
{
float ownerBonus = 0.0f;
ownerBonus = CalculatePct(owner->GetArmor(), 35);
amount += ownerBonus;
}
}
void CalculateFireResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* pet = GetUnitOwner())
if (pet->isPet())
if (Unit* owner = pet->ToPet()->GetOwner())
{
float ownerBonus = 0.0f;
ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_FIRE), 40);
amount += ownerBonus;
}
}
void Register()
{
OnEffectRemove += AuraEffectRemoveFn(spell_warl_pet_scaling_02_AuraScript::RemoveEffect, EFFECT_0, SPELL_AURA_MOD_STAT, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK);
AfterEffectApply += AuraEffectApplyFn(spell_warl_pet_scaling_02_AuraScript::ApplyEffect, EFFECT_0, SPELL_AURA_MOD_STAT, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_02_AuraScript::CalculateIntellectAmount, EFFECT_0, SPELL_AURA_MOD_STAT);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_02_AuraScript::CalculateArmorAmount, EFFECT_1, SPELL_AURA_MOD_RESISTANCE);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_02_AuraScript::CalculateFireResistanceAmount, EFFECT_2, SPELL_AURA_MOD_RESISTANCE);
}
private:
uint32 _tempBonus;
};
AuraScript* GetAuraScript() const
{
return new spell_warl_pet_scaling_02_AuraScript();
}
};
class spell_warl_pet_scaling_03 : public SpellScriptLoader
{
public:
spell_warl_pet_scaling_03() : SpellScriptLoader("spell_warl_pet_scaling_03") { }
class spell_warl_pet_scaling_03_AuraScript : public AuraScript
{
PrepareAuraScript(spell_warl_pet_scaling_03_AuraScript);
bool Load()
{
if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER)
return false;
return true;
}
void CalculateFrostResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* pet = GetUnitOwner())
if (pet->isPet())
if (Unit* owner = pet->ToPet()->GetOwner())
{
float ownerBonus = 0.0f;
ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_FROST), 40);
amount += ownerBonus;
}
}
void CalculateArcaneResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* pet = GetUnitOwner())
if (pet->isPet())
if (Unit* owner = pet->ToPet()->GetOwner())
{
float ownerBonus = 0.0f;
ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_ARCANE), 40);
amount += ownerBonus;
}
}
void CalculateNatureResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* pet = GetUnitOwner())
if (pet->isPet())
if (Unit* owner = pet->ToPet()->GetOwner())
{
float ownerBonus = 0.0f;
ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_NATURE), 40);
amount += ownerBonus;
}
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_03_AuraScript::CalculateFrostResistanceAmount, EFFECT_0, SPELL_AURA_MOD_RESISTANCE);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_03_AuraScript::CalculateArcaneResistanceAmount, EFFECT_1, SPELL_AURA_MOD_RESISTANCE);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_03_AuraScript::CalculateNatureResistanceAmount, EFFECT_2, SPELL_AURA_MOD_RESISTANCE);
}
};
AuraScript* GetAuraScript() const
{
return new spell_warl_pet_scaling_03_AuraScript();
}
};
class spell_warl_pet_scaling_04 : public SpellScriptLoader
{
public:
spell_warl_pet_scaling_04() : SpellScriptLoader("spell_warl_pet_scaling_04") { }
class spell_warl_pet_scaling_04_AuraScript : public AuraScript
{
PrepareAuraScript(spell_warl_pet_scaling_04_AuraScript);
bool Load()
{
if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER)
return false;
return true;
}
void CalculateShadowResistanceAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* pet = GetUnitOwner())
if (pet->isPet())
if (Unit* owner = pet->ToPet()->GetOwner())
{
float ownerBonus = 0.0f;
ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_SHADOW), 40);
amount += ownerBonus;
}
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_04_AuraScript::CalculateShadowResistanceAmount, EFFECT_0, SPELL_AURA_MOD_RESISTANCE);
}
};
AuraScript* GetAuraScript() const
{
return new spell_warl_pet_scaling_04_AuraScript();
}
};
class spell_warl_pet_scaling_05 : public SpellScriptLoader
{
public:
spell_warl_pet_scaling_05() : SpellScriptLoader("spell_warl_pet_scaling_05") { }
class spell_warl_pet_scaling_05_AuraScript : public AuraScript
{
PrepareAuraScript(spell_warl_pet_scaling_05_AuraScript);
bool Load()
{
if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER)
return false;
return true;
}
void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
{
// For others recalculate it from:
float HitMelee = 0.0f;
// Increase hit from SPELL_AURA_MOD_SPELL_HIT_CHANCE
HitMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE);
// Increase hit spell from spell hit ratings
HitMelee += owner->GetRatingBonusValue(CR_HIT_SPELL);
amount += int32(HitMelee);
}
}
void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
{
// For others recalculate it from:
float HitSpell = 0.0f;
// Increase hit from SPELL_AURA_MOD_SPELL_HIT_CHANCE
HitSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE);
// Increase hit spell from spell hit ratings
HitSpell += owner->GetRatingBonusValue(CR_HIT_SPELL);
amount += int32(HitSpell);
}
}
void CalculateAmountExpertise(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
{
// For others recalculate it from:
float Expertise = 0.0f;
// Increase hit from SPELL_AURA_MOD_SPELL_HIT_CHANCE
Expertise += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE);
// Increase hit spell from spell hit ratings
Expertise += owner->GetRatingBonusValue(CR_HIT_SPELL);
amount += int32(Expertise);
}
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_05_AuraScript::CalculateAmountMeleeHit, EFFECT_0, SPELL_AURA_MOD_HIT_CHANCE);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_05_AuraScript::CalculateAmountSpellHit, EFFECT_1, SPELL_AURA_MOD_SPELL_HIT_CHANCE);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_scaling_05_AuraScript::CalculateAmountExpertise, EFFECT_2, SPELL_AURA_MOD_EXPERTISE);
}
};
AuraScript* GetAuraScript() const
{
return new spell_warl_pet_scaling_05_AuraScript();
}
};
class spell_warl_pet_passive : public SpellScriptLoader
{
public:
spell_warl_pet_passive() : SpellScriptLoader("spell_warl_pet_passive") { }
class spell_warl_pet_passive_AuraScript : public AuraScript
{
PrepareAuraScript(spell_warl_pet_passive_AuraScript);
bool Load()
{
if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER)
return false;
return true;
}
void CalculateAmountCritSpell(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
{
// For others recalculate it from:
float CritSpell = 0.0f;
// Crit from Intellect
CritSpell += owner->GetSpellCritFromIntellect();
// Increase crit from SPELL_AURA_MOD_SPELL_CRIT_CHANCE
CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_CRIT_CHANCE);
// Increase crit from SPELL_AURA_MOD_CRIT_PCT
CritSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT);
// Increase crit spell from spell crit ratings
CritSpell += owner->GetRatingBonusValue(CR_CRIT_SPELL);
if (AuraApplication* improvedDemonicTacticsApp = owner->GetAuraApplicationOfRankedSpell(54347))
if (Aura* improvedDemonicTactics = improvedDemonicTacticsApp->GetBase())
if (AuraEffect* improvedDemonicTacticsEffect = improvedDemonicTactics->GetEffect(EFFECT_0))
amount += CalculatePct(CritSpell, improvedDemonicTacticsEffect->GetAmount());
}
}
void CalculateAmountCritMelee(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
{
// For others recalculate it from:
float CritMelee = 0.0f;
// Crit from Agility
CritMelee += owner->GetMeleeCritFromAgility();
// Increase crit from SPELL_AURA_MOD_WEAPON_CRIT_PERCENT
CritMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_WEAPON_CRIT_PERCENT);
// Increase crit from SPELL_AURA_MOD_CRIT_PCT
CritMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_PCT);
// Increase crit melee from melee crit ratings
CritMelee += owner->GetRatingBonusValue(CR_CRIT_MELEE);
if (AuraApplication* improvedDemonicTacticsApp = owner->GetAuraApplicationOfRankedSpell(54347))
if (Aura* improvedDemonicTactics = improvedDemonicTacticsApp->GetBase())
if (AuraEffect* improvedDemonicTacticsEffect = improvedDemonicTactics->GetEffect(EFFECT_0))
amount += CalculatePct(CritMelee, improvedDemonicTacticsEffect->GetAmount());
}
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_passive_AuraScript::CalculateAmountCritSpell, EFFECT_0, SPELL_AURA_MOD_SPELL_CRIT_CHANCE);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_passive_AuraScript::CalculateAmountCritMelee, EFFECT_1, SPELL_AURA_MOD_WEAPON_CRIT_PERCENT);
}
};
AuraScript* GetAuraScript() const
{
return new spell_warl_pet_passive_AuraScript();
}
};
// this doesnt actually fit in here
class spell_warl_pet_passive_damage_done : public SpellScriptLoader
{
public:
spell_warl_pet_passive_damage_done() : SpellScriptLoader("spell_warl_pet_passive_damage_done") { }
class spell_warl_pet_passive_damage_done_AuraScript : public AuraScript
{
PrepareAuraScript(spell_warl_pet_passive_damage_done_AuraScript);
bool Load()
{
if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER)
return false;
return true;
}
void CalculateAmountDamageDone(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (!GetCaster() || !GetCaster()->GetOwner())
return;
if (GetCaster()->GetOwner()->ToPlayer())
{
switch (GetCaster()->GetEntry())
{
case ENTRY_VOIDWALKER:
amount += -16;
break;
case ENTRY_FELHUNTER:
amount += -20;
break;
case ENTRY_SUCCUBUS:
case ENTRY_FELGUARD:
amount += 5;
break;
}
}
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_passive_damage_done_AuraScript::CalculateAmountDamageDone, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_passive_damage_done_AuraScript::CalculateAmountDamageDone, EFFECT_1, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
}
};
AuraScript* GetAuraScript() const
{
return new spell_warl_pet_passive_damage_done_AuraScript();
}
};
class spell_warl_pet_passive_voidwalker : public SpellScriptLoader
{
public:
spell_warl_pet_passive_voidwalker() : SpellScriptLoader("spell_warl_pet_passive_voidwalker") { }
class spell_warl_pet_passive_voidwalker_AuraScript : public AuraScript
{
PrepareAuraScript(spell_warl_pet_passive_voidwalker_AuraScript);
bool Load()
{
if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER)
return false;
return true;
}
void CalculateAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* pet = GetUnitOwner())
if (pet->isPet())
if (Unit* owner = pet->ToPet()->GetOwner())
if (AuraEffect* /* aurEff */ect = owner->GetAuraEffect(SPELL_WARLOCK_GLYPH_OF_VOIDWALKER, EFFECT_0))
amount += /* aurEff */ect->GetAmount();
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_warl_pet_passive_voidwalker_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE);
}
};
AuraScript* GetAuraScript() const
{
return new spell_warl_pet_passive_voidwalker_AuraScript();
}
};
class spell_sha_pet_scaling_04 : public SpellScriptLoader
{
public:
spell_sha_pet_scaling_04() : SpellScriptLoader("spell_sha_pet_scaling_04") { }
class spell_sha_pet_scaling_04_AuraScript : public AuraScript
{
PrepareAuraScript(spell_sha_pet_scaling_04_AuraScript);
bool Load()
{
if (!GetCaster() || !GetCaster()->GetOwner() || GetCaster()->GetOwner()->GetTypeId() != TYPEID_PLAYER)
return false;
return true;
}
void CalculateAmountMeleeHit(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
{
// For others recalculate it from:
float HitMelee = 0.0f;
// Increase hit from SPELL_AURA_MOD_HIT_CHANCE
HitMelee += owner->GetTotalAuraModifier(SPELL_AURA_MOD_HIT_CHANCE);
// Increase hit melee from meele hit ratings
HitMelee += owner->GetRatingBonusValue(CR_HIT_MELEE);
amount += int32(HitMelee);
}
}
void CalculateAmountSpellHit(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Player* owner = GetCaster()->GetOwner()->ToPlayer())
{
// For others recalculate it from:
float HitSpell = 0.0f;
// Increase hit from SPELL_AURA_MOD_SPELL_HIT_CHANCE
HitSpell += owner->GetTotalAuraModifier(SPELL_AURA_MOD_SPELL_HIT_CHANCE);
// Increase hit spell from spell hit ratings
HitSpell += owner->GetRatingBonusValue(CR_HIT_SPELL);
amount += int32(HitSpell);
}
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_sha_pet_scaling_04_AuraScript::CalculateAmountMeleeHit, EFFECT_0, SPELL_AURA_MOD_HIT_CHANCE);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_sha_pet_scaling_04_AuraScript::CalculateAmountSpellHit, EFFECT_1, SPELL_AURA_MOD_SPELL_HIT_CHANCE);
}
};
AuraScript* GetAuraScript() const
{
return new spell_sha_pet_scaling_04_AuraScript();
}
};
class spell_hun_pet_scaling_01 : public SpellScriptLoader
{
public:
spell_hun_pet_scaling_01() : SpellScriptLoader("spell_hun_pet_scaling_01") { }
class spell_hun_pet_scaling_01_AuraScript : public AuraScript
{
PrepareAuraScript(spell_hun_pet_scaling_01_AuraScript);
void CalculateStaminaAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* pet = GetUnitOwner())
if (pet->isPet())
if (Unit* owner = pet->ToPet()->GetOwner())
{
float mod = 0.45f;
float ownerBonus = 0.0f;
PetSpellMap::const_iterator itr = (pet->ToPet()->m_spells.find(62758)); // Wild Hunt rank 1
if (itr == pet->ToPet()->m_spells.end())
itr = pet->ToPet()->m_spells.find(62762); // Wild Hunt rank 2
if (itr != pet->ToPet()->m_spells.end()) // If pet has Wild Hunt
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); // Then get the SpellProto and add the dummy effect value
AddPct(mod, spellInfo->Effects[EFFECT_0].CalcValue());
}
ownerBonus = owner->GetStat(STAT_STAMINA)*mod;
amount += ownerBonus;
}
}
void ApplyEffect(AuraEffect const* /* aurEff */, AuraEffectHandleModes /*mode*/)
{
if (Unit* pet = GetUnitOwner())
if (_tempHealth)
pet->SetHealth(_tempHealth);
}
void RemoveEffect(AuraEffect const* /* aurEff */, AuraEffectHandleModes /*mode*/)
{
if (Unit* pet = GetUnitOwner())
_tempHealth = pet->GetHealth();
}
void CalculateAttackPowerAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* pet = GetUnitOwner())
{
if (!pet->isPet())
return;
Unit* owner = pet->ToPet()->GetOwner();
if (!owner)
return;
float mod = 1.0f; //Hunter contribution modifier
float bonusAP = 0.0f;
PetSpellMap::const_iterator itr = (pet->ToPet()->m_spells.find(62758)); // Wild Hunt rank 1
if (itr == pet->ToPet()->m_spells.end())
itr = pet->ToPet()->m_spells.find(62762); // Wild Hunt rank 2
if (itr != pet->ToPet()->m_spells.end()) // If pet has Wild Hunt
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); // Then get the SpellProto and add the dummy effect value
mod += CalculatePct(1.0f, spellInfo->Effects[EFFECT_1].CalcValue());
}
bonusAP = owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.22f * mod;
amount += bonusAP;
}
}
void CalculateDamageDoneAmount(AuraEffect const* /* aurEff */, int32& amount, bool& /*canBeRecalculated*/)
{
if (Unit* pet = GetUnitOwner())
{
if (!pet->isPet())
return;
Unit* owner = pet->ToPet()->GetOwner();
if (!owner)
return;
float mod = 1.0f; //Hunter contribution modifier
float bonusDamage = 0.0f;
PetSpellMap::const_iterator itr = (pet->ToPet()->m_spells.find(62758)); // Wild Hunt rank 1
if (itr == pet->ToPet()->m_spells.end())
itr = pet->ToPet()->m_spells.find(62762); // Wild Hunt rank 2
if (itr != pet->ToPet()->m_spells.end()) // If pet has Wild Hunt
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); // Then get the SpellProto and add the dummy effect value
mod += CalculatePct(1.0f, spellInfo->Effects[EFFECT_1].CalcValue());
}
bonusDamage = owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.1287f * mod;
amount += bonusDamage;
}
}
void Register()
{
OnEffectRemove += AuraEffectRemoveFn(spell_hun_pet_scaling_01_AuraScript::RemoveEffect, EFFECT_0, SPELL_AURA_MOD_STAT, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK);
AfterEffectApply += AuraEffectApplyFn(spell_hun_pet_scaling_01_AuraScript::ApplyEffect, EFFECT_0, SPELL_AURA_MOD_STAT, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_01_AuraScript::CalculateStaminaAmount, EFFECT_0, SPELL_AURA_MOD_STAT);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_01_AuraScript::CalculateAttackPowerAmount, EFFECT_1, SPELL_AURA_MOD_ATTACK_POWER);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_hun_pet_scaling_01_AuraScript::CalculateDamageDoneAmount, EFFECT_2, SPELL_AURA_MOD_DAMAGE_DONE);
}
private:
uint32 _tempHealth;
};
AuraScript* GetAuraScript() const
{
return new spell_hun_pet_scaling_01_AuraScript();
}
};