forked from TrinityCore/TrinityCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspell_generic.cpp
More file actions
4117 lines (3534 loc) · 152 KB
/
spell_generic.cpp
File metadata and controls
4117 lines (3534 loc) · 152 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-2014 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_GENERIC which cannot be included in AI script file
* of creature using it or can't be bound to any player class.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_gen_"
*/
#include "ScriptMgr.h"
#include "Battleground.h"
#include "Cell.h"
#include "CellImpl.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "Group.h"
#include "InstanceScript.h"
#include "LFGMgr.h"
#include "Pet.h"
#include "ReputationMgr.h"
#include "SkillDiscovery.h"
#include "SpellScript.h"
#include "SpellAuraEffects.h"
#include "Vehicle.h"
class spell_gen_absorb0_hitlimit1 : public SpellScriptLoader
{
public:
spell_gen_absorb0_hitlimit1() : SpellScriptLoader("spell_gen_absorb0_hitlimit1") { }
class spell_gen_absorb0_hitlimit1_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_absorb0_hitlimit1_AuraScript);
public:
spell_gen_absorb0_hitlimit1_AuraScript()
{
limit = 0;
}
private:
uint32 limit;
bool Load() override
{
// Max absorb stored in 1 dummy effect
limit = GetSpellInfo()->Effects[EFFECT_1].CalcValue();
return true;
}
void Absorb(AuraEffect* /*aurEff*/, DamageInfo& /*dmgInfo*/, uint32& absorbAmount)
{
absorbAmount = std::min(limit, absorbAmount);
}
void Register() override
{
OnEffectAbsorb += AuraEffectAbsorbFn(spell_gen_absorb0_hitlimit1_AuraScript::Absorb, EFFECT_0);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_gen_absorb0_hitlimit1_AuraScript();
}
};
// 28764 - Adaptive Warding (Frostfire Regalia Set)
enum AdaptiveWarding
{
SPELL_GEN_ADAPTIVE_WARDING_FIRE = 28765,
SPELL_GEN_ADAPTIVE_WARDING_NATURE = 28768,
SPELL_GEN_ADAPTIVE_WARDING_FROST = 28766,
SPELL_GEN_ADAPTIVE_WARDING_SHADOW = 28769,
SPELL_GEN_ADAPTIVE_WARDING_ARCANE = 28770
};
class spell_gen_adaptive_warding : public SpellScriptLoader
{
public:
spell_gen_adaptive_warding() : SpellScriptLoader("spell_gen_adaptive_warding") { }
class spell_gen_adaptive_warding_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_adaptive_warding_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_GEN_ADAPTIVE_WARDING_FIRE) ||
!sSpellMgr->GetSpellInfo(SPELL_GEN_ADAPTIVE_WARDING_NATURE) ||
!sSpellMgr->GetSpellInfo(SPELL_GEN_ADAPTIVE_WARDING_FROST) ||
!sSpellMgr->GetSpellInfo(SPELL_GEN_ADAPTIVE_WARDING_SHADOW) ||
!sSpellMgr->GetSpellInfo(SPELL_GEN_ADAPTIVE_WARDING_ARCANE))
return false;
return true;
}
bool CheckProc(ProcEventInfo& eventInfo)
{
if (eventInfo.GetDamageInfo()->GetSpellInfo()) // eventInfo.GetSpellInfo()
return false;
// find Mage Armor
if (!GetTarget()->GetAuraEffect(SPELL_AURA_MOD_MANA_REGEN_INTERRUPT, SPELLFAMILY_MAGE, 0x10000000, 0x0, 0x0))
return false;
switch (GetFirstSchoolInMask(eventInfo.GetSchoolMask()))
{
case SPELL_SCHOOL_NORMAL:
case SPELL_SCHOOL_HOLY:
return false;
default:
break;
}
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
uint32 spellId = 0;
switch (GetFirstSchoolInMask(eventInfo.GetSchoolMask()))
{
case SPELL_SCHOOL_FIRE:
spellId = SPELL_GEN_ADAPTIVE_WARDING_FIRE;
break;
case SPELL_SCHOOL_NATURE:
spellId = SPELL_GEN_ADAPTIVE_WARDING_NATURE;
break;
case SPELL_SCHOOL_FROST:
spellId = SPELL_GEN_ADAPTIVE_WARDING_FROST;
break;
case SPELL_SCHOOL_SHADOW:
spellId = SPELL_GEN_ADAPTIVE_WARDING_SHADOW;
break;
case SPELL_SCHOOL_ARCANE:
spellId = SPELL_GEN_ADAPTIVE_WARDING_ARCANE;
break;
default:
return;
}
GetTarget()->CastSpell(GetTarget(), spellId, true, NULL, aurEff);
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_gen_adaptive_warding_AuraScript::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_gen_adaptive_warding_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_gen_adaptive_warding_AuraScript();
}
};
enum AlchemistStone
{
ALECHEMIST_STONE_HEAL = 21399,
ALECHEMIST_STONE_MANA = 21400,
};
// 17619 - Alchemist Stone
class spell_gen_alchemist_stone : public SpellScriptLoader
{
public:
spell_gen_alchemist_stone() : SpellScriptLoader("spell_gen_alchemist_stone") { }
class spell_gen_alchemist_stone_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_alchemist_stone_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(ALECHEMIST_STONE_HEAL) ||
!sSpellMgr->GetSpellInfo(ALECHEMIST_STONE_MANA))
return false;
return true;
}
bool CheckProc(ProcEventInfo& eventInfo)
{
return eventInfo.GetDamageInfo()->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_POTION;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
uint32 spellId = 0;
int32 bp = int32(eventInfo.GetDamageInfo()->GetDamage() * 0.4f);
if (eventInfo.GetDamageInfo()->GetSpellInfo()->HasEffect(SPELL_EFFECT_HEAL))
spellId = ALECHEMIST_STONE_HEAL;
else if (eventInfo.GetDamageInfo()->GetSpellInfo()->HasEffect(SPELL_EFFECT_ENERGIZE))
spellId = ALECHEMIST_STONE_MANA;
if (!spellId)
return;
GetTarget()->CastCustomSpell(spellId, SPELLVALUE_BASE_POINT0, bp, GetTarget(), true, NULL, aurEff);
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_gen_alchemist_stone_AuraScript::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_gen_alchemist_stone_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_gen_alchemist_stone_AuraScript();
}
};
class spell_gen_allow_cast_from_item_only : public SpellScriptLoader
{
public:
spell_gen_allow_cast_from_item_only() : SpellScriptLoader("spell_gen_allow_cast_from_item_only") { }
class spell_gen_allow_cast_from_item_only_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_allow_cast_from_item_only_SpellScript);
SpellCastResult CheckRequirement()
{
if (!GetCastItem())
return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW;
return SPELL_CAST_OK;
}
void Register() override
{
OnCheckCast += SpellCheckCastFn(spell_gen_allow_cast_from_item_only_SpellScript::CheckRequirement);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_gen_allow_cast_from_item_only_SpellScript();
}
};
enum AnimalBloodPoolSpell
{
SPELL_ANIMAL_BLOOD = 46221,
SPELL_SPAWN_BLOOD_POOL = 63471
};
class spell_gen_animal_blood : public SpellScriptLoader
{
public:
spell_gen_animal_blood() : SpellScriptLoader("spell_gen_animal_blood") { }
class spell_gen_animal_blood_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_animal_blood_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_SPAWN_BLOOD_POOL))
return false;
return true;
}
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
// Remove all auras with spell id 46221, except the one currently being applied
while (Aura* aur = GetUnitOwner()->GetOwnedAura(SPELL_ANIMAL_BLOOD, ObjectGuid::Empty, ObjectGuid::Empty, 0, GetAura()))
GetUnitOwner()->RemoveOwnedAura(aur);
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* owner = GetUnitOwner())
if (owner->IsInWater())
owner->CastSpell(owner, SPELL_SPAWN_BLOOD_POOL, true);
}
void Register() override
{
AfterEffectApply += AuraEffectRemoveFn(spell_gen_animal_blood_AuraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
AfterEffectRemove += AuraEffectRemoveFn(spell_gen_animal_blood_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_gen_animal_blood_AuraScript();
}
};
// 41337 Aura of Anger
class spell_gen_aura_of_anger : public SpellScriptLoader
{
public:
spell_gen_aura_of_anger() : SpellScriptLoader("spell_gen_aura_of_anger") { }
class spell_gen_aura_of_anger_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_aura_of_anger_AuraScript);
void HandleEffectPeriodicUpdate(AuraEffect* aurEff)
{
if (AuraEffect* aurEff1 = aurEff->GetBase()->GetEffect(EFFECT_1))
aurEff1->ChangeAmount(aurEff1->GetAmount() + 5);
aurEff->SetAmount(100 * aurEff->GetTickNumber());
}
void Register() override
{
OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_gen_aura_of_anger_AuraScript::HandleEffectPeriodicUpdate, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_gen_aura_of_anger_AuraScript();
}
};
enum ServiceUniform
{
// Spells
SPELL_SERVICE_UNIFORM = 71450,
// Models
MODEL_GOBLIN_MALE = 31002,
MODEL_GOBLIN_FEMALE = 31003
};
class spell_gen_aura_service_uniform : public SpellScriptLoader
{
public:
spell_gen_aura_service_uniform() : SpellScriptLoader("spell_gen_aura_service_uniform") { }
class spell_gen_aura_service_uniform_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_aura_service_uniform_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_SERVICE_UNIFORM))
return false;
return true;
}
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
// Apply model goblin
Unit* target = GetTarget();
if (target->GetTypeId() == TYPEID_PLAYER)
{
if (target->getGender() == GENDER_MALE)
target->SetDisplayId(MODEL_GOBLIN_MALE);
else
target->SetDisplayId(MODEL_GOBLIN_FEMALE);
}
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
if (target->GetTypeId() == TYPEID_PLAYER)
target->RestoreDisplayId();
}
void Register() override
{
AfterEffectApply += AuraEffectRemoveFn(spell_gen_aura_service_uniform_AuraScript::OnApply, EFFECT_0, SPELL_AURA_TRANSFORM, AURA_EFFECT_HANDLE_REAL);
AfterEffectRemove += AuraEffectRemoveFn(spell_gen_aura_service_uniform_AuraScript::OnRemove, EFFECT_0, SPELL_AURA_TRANSFORM, AURA_EFFECT_HANDLE_REAL);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_gen_aura_service_uniform_AuraScript();
}
};
class spell_gen_av_drekthar_presence : public SpellScriptLoader
{
public:
spell_gen_av_drekthar_presence() : SpellScriptLoader("spell_gen_av_drekthar_presence") { }
class spell_gen_av_drekthar_presence_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_av_drekthar_presence_AuraScript);
bool CheckAreaTarget(Unit* target)
{
switch (target->GetEntry())
{
// alliance
case 14762: // Dun Baldar North Marshal
case 14763: // Dun Baldar South Marshal
case 14764: // Icewing Marshal
case 14765: // Stonehearth Marshal
case 11948: // Vandar Stormspike
// horde
case 14772: // East Frostwolf Warmaster
case 14776: // Tower Point Warmaster
case 14773: // Iceblood Warmaster
case 14777: // West Frostwolf Warmaster
case 11946: // Drek'thar
return true;
default:
return false;
}
}
void Register() override
{
DoCheckAreaTarget += AuraCheckAreaTargetFn(spell_gen_av_drekthar_presence_AuraScript::CheckAreaTarget);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_gen_av_drekthar_presence_AuraScript();
}
};
enum GenericBandage
{
SPELL_RECENTLY_BANDAGED = 11196
};
class spell_gen_bandage : public SpellScriptLoader
{
public:
spell_gen_bandage() : SpellScriptLoader("spell_gen_bandage") { }
class spell_gen_bandage_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_bandage_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_RECENTLY_BANDAGED))
return false;
return true;
}
SpellCastResult CheckCast()
{
if (Unit* target = GetExplTargetUnit())
{
if (target->HasAura(SPELL_RECENTLY_BANDAGED))
return SPELL_FAILED_TARGET_AURASTATE;
}
return SPELL_CAST_OK;
}
void HandleScript()
{
if (Unit* target = GetHitUnit())
GetCaster()->CastSpell(target, SPELL_RECENTLY_BANDAGED, true);
}
void Register() override
{
OnCheckCast += SpellCheckCastFn(spell_gen_bandage_SpellScript::CheckCast);
AfterHit += SpellHitFn(spell_gen_bandage_SpellScript::HandleScript);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_gen_bandage_SpellScript();
}
};
enum Bonked
{
SPELL_BONKED = 62991,
SPELL_FOAM_SWORD_DEFEAT = 62994,
SPELL_ON_GUARD = 62972
};
class spell_gen_bonked : public SpellScriptLoader
{
public:
spell_gen_bonked() : SpellScriptLoader("spell_gen_bonked") { }
class spell_gen_bonked_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_bonked_SpellScript);
void HandleScript(SpellEffIndex /*effIndex*/)
{
if (Player* target = GetHitPlayer())
{
Aura const* aura = GetHitAura();
if (!(aura && aura->GetStackAmount() == 3))
return;
target->CastSpell(target, SPELL_FOAM_SWORD_DEFEAT, true);
target->RemoveAurasDueToSpell(SPELL_BONKED);
if (Aura const* auraOnGuard = target->GetAura(SPELL_ON_GUARD))
{
if (Item* item = target->GetItemByGuid(auraOnGuard->GetCastItemGUID()))
target->DestroyItemCount(item->GetEntry(), 1, true);
}
}
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_gen_bonked_SpellScript::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_gen_bonked_SpellScript();
}
};
/* DOCUMENTATION: Break-Shield spells
Break-Shield spells can be classified in three groups:
- Spells on vehicle bar used by players:
+ EFFECT_0: SCRIPT_EFFECT
+ EFFECT_1: NONE
+ EFFECT_2: NONE
- Spells cast by players triggered by script:
+ EFFECT_0: SCHOOL_DAMAGE
+ EFFECT_1: SCRIPT_EFFECT
+ EFFECT_2: FORCE_CAST
- Spells cast by NPCs on players:
+ EFFECT_0: SCHOOL_DAMAGE
+ EFFECT_1: SCRIPT_EFFECT
+ EFFECT_2: NONE
In the following script we handle the SCRIPT_EFFECT for effIndex EFFECT_0 and EFFECT_1.
- When handling EFFECT_0 we're in the "Spells on vehicle bar used by players" case
and we'll trigger "Spells cast by players triggered by script"
- When handling EFFECT_1 we're in the "Spells cast by players triggered by script"
or "Spells cast by NPCs on players" so we'll search for the first defend layer and drop it.
*/
enum BreakShieldSpells
{
SPELL_BREAK_SHIELD_DAMAGE_2K = 62626,
SPELL_BREAK_SHIELD_DAMAGE_10K = 64590,
SPELL_BREAK_SHIELD_TRIGGER_FACTION_MOUNTS = 62575, // Also on ToC5 mounts
SPELL_BREAK_SHIELD_TRIGGER_CAMPAING_WARHORSE = 64595,
SPELL_BREAK_SHIELD_TRIGGER_UNK = 66480
};
class spell_gen_break_shield: public SpellScriptLoader
{
public:
spell_gen_break_shield(const char* name) : SpellScriptLoader(name) { }
class spell_gen_break_shield_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_break_shield_SpellScript);
void HandleScriptEffect(SpellEffIndex effIndex)
{
Unit* target = GetHitUnit();
switch (effIndex)
{
case EFFECT_0: // On spells wich trigger the damaging spell (and also the visual)
{
uint32 spellId;
switch (GetSpellInfo()->Id)
{
case SPELL_BREAK_SHIELD_TRIGGER_UNK:
case SPELL_BREAK_SHIELD_TRIGGER_CAMPAING_WARHORSE:
spellId = SPELL_BREAK_SHIELD_DAMAGE_10K;
break;
case SPELL_BREAK_SHIELD_TRIGGER_FACTION_MOUNTS:
spellId = SPELL_BREAK_SHIELD_DAMAGE_2K;
break;
default:
return;
}
if (Unit* rider = GetCaster()->GetCharmer())
rider->CastSpell(target, spellId, false);
else
GetCaster()->CastSpell(target, spellId, false);
break;
}
case EFFECT_1: // On damaging spells, for removing a defend layer
{
Unit::AuraApplicationMap const& auras = target->GetAppliedAuras();
for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
{
if (Aura* aura = itr->second->GetBase())
{
SpellInfo const* auraInfo = aura->GetSpellInfo();
if (auraInfo && auraInfo->SpellIconID == 2007 && aura->HasEffectType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN))
{
aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL);
// Remove dummys from rider (Necessary for updating visual shields)
if (Unit* rider = target->GetCharmer())
if (Aura* defend = rider->GetAura(aura->GetId()))
defend->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL);
break;
}
}
}
break;
}
default:
break;
}
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_gen_break_shield_SpellScript::HandleScriptEffect, EFFECT_FIRST_FOUND, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_gen_break_shield_SpellScript();
}
};
// 46394 Brutallus Burn
class spell_gen_burn_brutallus : public SpellScriptLoader
{
public:
spell_gen_burn_brutallus() : SpellScriptLoader("spell_gen_burn_brutallus") { }
class spell_gen_burn_brutallus_AuraScript : public AuraScript
{
PrepareAuraScript(spell_gen_burn_brutallus_AuraScript);
void HandleEffectPeriodicUpdate(AuraEffect* aurEff)
{
if (aurEff->GetTickNumber() % 11 == 0)
aurEff->SetAmount(aurEff->GetAmount() * 2);
}
void Register() override
{
OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_gen_burn_brutallus_AuraScript::HandleEffectPeriodicUpdate, EFFECT_0, SPELL_AURA_PERIODIC_DAMAGE);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_gen_burn_brutallus_AuraScript();
}
};
enum CannibalizeSpells
{
SPELL_CANNIBALIZE_TRIGGERED = 20578
};
class spell_gen_cannibalize : public SpellScriptLoader
{
public:
spell_gen_cannibalize() : SpellScriptLoader("spell_gen_cannibalize") { }
class spell_gen_cannibalize_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_cannibalize_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_CANNIBALIZE_TRIGGERED))
return false;
return true;
}
SpellCastResult CheckIfCorpseNear()
{
Unit* caster = GetCaster();
float max_range = GetSpellInfo()->GetMaxRange(false);
WorldObject* result = NULL;
// search for nearby enemy corpse in range
Trinity::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_CHECK_ENEMY);
Trinity::WorldObjectSearcher<Trinity::AnyDeadUnitSpellTargetInRangeCheck> searcher(caster, result, check);
caster->GetMap()->VisitFirstFound(caster->m_positionX, caster->m_positionY, max_range, searcher);
if (!result)
return SPELL_FAILED_NO_EDIBLE_CORPSES;
return SPELL_CAST_OK;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
GetCaster()->CastSpell(GetCaster(), SPELL_CANNIBALIZE_TRIGGERED, false);
}
void Register() override
{
OnEffectHit += SpellEffectFn(spell_gen_cannibalize_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
OnCheckCast += SpellCheckCastFn(spell_gen_cannibalize_SpellScript::CheckIfCorpseNear);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_gen_cannibalize_SpellScript();
}
};
enum ChaosBlast
{
SPELL_CHAOS_BLAST = 37675
};
class spell_gen_chaos_blast : public SpellScriptLoader
{
public:
spell_gen_chaos_blast() : SpellScriptLoader("spell_gen_chaos_blast") { }
class spell_gen_chaos_blast_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_chaos_blast_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_CHAOS_BLAST))
return false;
return true;
}
void HandleDummy(SpellEffIndex /* effIndex */)
{
int32 basepoints0 = 100;
Unit* caster = GetCaster();
if (Unit* target = GetHitUnit())
caster->CastCustomSpell(target, SPELL_CHAOS_BLAST, &basepoints0, NULL, NULL, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_gen_chaos_blast_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_gen_chaos_blast_SpellScript();
}
};
enum Clone
{
SPELL_NIGHTMARE_FIGMENT_MIRROR_IMAGE = 57528
};
class spell_gen_clone : public SpellScriptLoader
{
public:
spell_gen_clone() : SpellScriptLoader("spell_gen_clone") { }
class spell_gen_clone_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_clone_SpellScript);
void HandleScriptEffect(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true);
}
void Register() override
{
if (m_scriptSpellId == SPELL_NIGHTMARE_FIGMENT_MIRROR_IMAGE)
{
OnEffectHitTarget += SpellEffectFn(spell_gen_clone_SpellScript::HandleScriptEffect, EFFECT_1, SPELL_EFFECT_DUMMY);
OnEffectHitTarget += SpellEffectFn(spell_gen_clone_SpellScript::HandleScriptEffect, EFFECT_2, SPELL_EFFECT_DUMMY);
}
else
{
OnEffectHitTarget += SpellEffectFn(spell_gen_clone_SpellScript::HandleScriptEffect, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
OnEffectHitTarget += SpellEffectFn(spell_gen_clone_SpellScript::HandleScriptEffect, EFFECT_2, SPELL_EFFECT_SCRIPT_EFFECT);
}
}
};
SpellScript* GetSpellScript() const override
{
return new spell_gen_clone_SpellScript();
}
};
enum CloneWeaponSpells
{
SPELL_COPY_WEAPON_AURA = 41054,
SPELL_COPY_WEAPON_2_AURA = 63418,
SPELL_COPY_WEAPON_3_AURA = 69893,
SPELL_COPY_OFFHAND_AURA = 45205,
SPELL_COPY_OFFHAND_2_AURA = 69896,
SPELL_COPY_RANGED_AURA = 57594
};
class spell_gen_clone_weapon : public SpellScriptLoader
{
public:
spell_gen_clone_weapon() : SpellScriptLoader("spell_gen_clone_weapon") { }
class spell_gen_clone_weapon_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_clone_weapon_SpellScript);
void HandleScriptEffect(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValue()), true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_gen_clone_weapon_SpellScript::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_gen_clone_weapon_SpellScript();
}
};
class spell_gen_clone_weapon_aura : public SpellScriptLoader
{
public:
spell_gen_clone_weapon_aura() : SpellScriptLoader("spell_gen_clone_weapon_aura") { }
class spell_gen_clone_weapon_auraScript : public AuraScript
{
PrepareAuraScript(spell_gen_clone_weapon_auraScript);
public:
spell_gen_clone_weapon_auraScript()
{
prevItem = 0;
}
private:
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_AURA) ||
!sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_2_AURA) ||
!sSpellMgr->GetSpellInfo(SPELL_COPY_WEAPON_3_AURA) ||
!sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND_AURA) ||
!sSpellMgr->GetSpellInfo(SPELL_COPY_OFFHAND_2_AURA) ||
!sSpellMgr->GetSpellInfo(SPELL_COPY_RANGED_AURA))
return false;
return true;
}
void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* caster = GetCaster();
Unit* target = GetTarget();
if (!caster)
return;
switch (GetSpellInfo()->Id)
{
case SPELL_COPY_WEAPON_AURA:
case SPELL_COPY_WEAPON_2_AURA:
case SPELL_COPY_WEAPON_3_AURA:
{
prevItem = target->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID);
if (Player* player = caster->ToPlayer())
{
if (Item* mainItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND))
target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, mainItem->GetEntry());
}
else
target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID));
break;
}
case SPELL_COPY_OFFHAND_AURA:
case SPELL_COPY_OFFHAND_2_AURA:
{
prevItem = target->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID) + 1;
if (Player* player = caster->ToPlayer())
{
if (Item* offItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND))
target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, offItem->GetEntry());
}
else
target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1));
break;
}
case SPELL_COPY_RANGED_AURA:
{
prevItem = target->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID) + 2;
if (Player* player = caster->ToPlayer())
{
if (Item* rangedItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED))
target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, rangedItem->GetEntry());
}
else
target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2));
break;
}
default:
break;
}
}
void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
Unit* target = GetTarget();
switch (GetSpellInfo()->Id)
{
case SPELL_COPY_WEAPON_AURA:
case SPELL_COPY_WEAPON_2_AURA:
case SPELL_COPY_WEAPON_3_AURA:
target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, prevItem);
break;
case SPELL_COPY_OFFHAND_AURA:
case SPELL_COPY_OFFHAND_2_AURA:
target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, prevItem);
break;
case SPELL_COPY_RANGED_AURA:
target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, prevItem);
break;
default:
break;
}
}
void Register() override
{
OnEffectApply += AuraEffectApplyFn(spell_gen_clone_weapon_auraScript::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
OnEffectRemove += AuraEffectRemoveFn(spell_gen_clone_weapon_auraScript::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
}
private:
uint32 prevItem;
};
AuraScript* GetAuraScript() const override
{
return new spell_gen_clone_weapon_auraScript();
}
};
class spell_gen_count_pct_from_max_hp : public SpellScriptLoader
{
public:
spell_gen_count_pct_from_max_hp(char const* name, int32 damagePct = 0) : SpellScriptLoader(name), _damagePct(damagePct) { }
class spell_gen_count_pct_from_max_hp_SpellScript : public SpellScript
{
PrepareSpellScript(spell_gen_count_pct_from_max_hp_SpellScript);
public:
spell_gen_count_pct_from_max_hp_SpellScript(int32 damagePct) : SpellScript(), _damagePct(damagePct) { }
void RecalculateDamage()
{
if (!_damagePct)
_damagePct = GetHitDamage();
SetHitDamage(GetHitUnit()->CountPctFromMaxHealth(_damagePct));
}
void Register() override
{
OnHit += SpellHitFn(spell_gen_count_pct_from_max_hp_SpellScript::RecalculateDamage);
}
private:
int32 _damagePct;
};