-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Expand file tree
/
Copy pathspell_generic.cpp
More file actions
5925 lines (5142 loc) · 196 KB
/
Copy pathspell_generic.cpp
File metadata and controls
5925 lines (5142 loc) · 196 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
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* 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 "AreaTrigger.h"
#include "AreaTriggerAI.h"
#include "Battleground.h"
#include "BattlePetMgr.h"
#include "CellImpl.h"
#include "CommonPredicates.h"
#include "Containers.h"
#include "CreatureAI.h"
#include "DB2Stores.h"
#include "GameTime.h"
#include "GridNotifiersImpl.h"
#include "Item.h"
#include "Log.h"
#include "MapUtils.h"
#include "MotionMaster.h"
#include "NPCPackets.h"
#include "ObjectMgr.h"
#include "Pet.h"
#include "PhasingHandler.h"
#include "ReputationMgr.h"
#include "PathGenerator.h"
#include "SkillDiscovery.h"
#include "SpellAuraEffects.h"
#include "SpellHistory.h"
#include "SpellMgr.h"
#include "SpellPackets.h"
#include "SpellScript.h"
#include "Vehicle.h"
#include "WorldStateMgr.h"
class spell_gen_absorb0_hitlimit1 : public AuraScript
{
uint32 limit = 0;
bool Load() override
{
// Max absorb stored in 1 dummy effect
limit = GetSpellInfo()->GetEffect(EFFECT_1).CalcValueAsInt();
return true;
}
void Absorb(AuraEffect* /*aurEff*/, DamageInfo& /*dmgInfo*/, uint32& absorbAmount)
{
absorbAmount = std::min(limit, absorbAmount);
}
void Register() override
{
OnEffectAbsorb += AuraEffectAbsorbFn(spell_gen_absorb0_hitlimit1::Absorb, EFFECT_0);
}
};
// 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 AuraScript
{
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo(
{
SPELL_GEN_ADAPTIVE_WARDING_FIRE,
SPELL_GEN_ADAPTIVE_WARDING_NATURE,
SPELL_GEN_ADAPTIVE_WARDING_FROST,
SPELL_GEN_ADAPTIVE_WARDING_SHADOW,
SPELL_GEN_ADAPTIVE_WARDING_ARCANE
});
}
bool CheckProc(ProcEventInfo& eventInfo)
{
if (!eventInfo.GetSpellInfo())
return false;
// find Mage Armor
if (!GetTarget()->GetAuraEffect(SPELL_AURA_MOD_MANA_REGEN_INTERRUPT, SPELLFAMILY_MAGE, flag128(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* 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, aurEff);
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_gen_adaptive_warding::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_gen_adaptive_warding::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
class spell_gen_allow_cast_from_item_only : public 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::CheckRequirement);
}
};
enum AnimalBloodPoolSpell
{
SPELL_ANIMAL_BLOOD = 46221,
SPELL_SPAWN_BLOOD_POOL = 63471
};
// 46221 - Animal Blood
class spell_gen_animal_blood : public AuraScript
{
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_SPAWN_BLOOD_POOL });
}
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())
owner->CastSpell(owner, SPELL_SPAWN_BLOOD_POOL, true);
}
void Register() override
{
AfterEffectApply += AuraEffectRemoveFn(spell_gen_animal_blood::OnApply, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
AfterEffectRemove += AuraEffectRemoveFn(spell_gen_animal_blood::OnRemove, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
}
};
// 63471 - Spawn Blood Pool
class spell_spawn_blood_pool : public SpellScript
{
void SetDest(SpellDestination& dest)
{
Unit* caster = GetCaster();
Position summonPos = caster->GetPosition();
LiquidData liquidStatus;
if (caster->GetMap()->GetLiquidStatus(caster->GetPhaseShift(), caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ(), {}, &liquidStatus, caster->GetCollisionHeight()))
summonPos.m_positionZ = liquidStatus.level;
dest.Relocate(summonPos);
}
void Register() override
{
OnDestinationTargetSelect += SpellDestinationTargetSelectFn(spell_spawn_blood_pool::SetDest, EFFECT_0, TARGET_DEST_CASTER);
}
};
// 430 Drink
// 431 Drink
// 432 Drink
// 1133 Drink
// 1135 Drink
// 1137 Drink
// 10250 Drink
// 22734 Drink
// 27089 Drink
// 34291 Drink
// 43182 Drink
// 43183 Drink
// 46755 Drink
// 49472 Drink Coffee
// 57073 Drink
// 61830 Drink
// 72623 Drink
class spell_gen_arena_drink : public AuraScript
{
bool Load() override
{
return GetCaster() && GetCaster()->GetTypeId() == TYPEID_PLAYER;
}
bool Validate(SpellInfo const* spellInfo) override
{
if (!ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) || !spellInfo->GetEffect(EFFECT_0).IsAura(SPELL_AURA_MOD_POWER_REGEN))
{
TC_LOG_ERROR("spells", "Aura {} structure has been changed - first aura is no longer SPELL_AURA_MOD_POWER_REGEN", GetId());
return false;
}
return true;
}
void CalcPeriodic(AuraEffect const* /*aurEff*/, bool& isPeriodic, int32& /*amplitude*/)
{
// Get SPELL_AURA_MOD_POWER_REGEN aura from spell
AuraEffect* regen = GetAura()->GetEffect(EFFECT_0);
if (!regen)
return;
// default case - not in arena
if (!GetCaster()->ToPlayer()->InArena())
isPeriodic = false;
}
void CalcAmount(AuraEffect const* /*aurEff*/, SpellEffectValue& amount, bool& /*canBeRecalculated*/)
{
AuraEffect* regen = GetAura()->GetEffect(EFFECT_0);
if (!regen)
return;
// default case - not in arena
if (!GetCaster()->ToPlayer()->InArena())
regen->ChangeAmount(amount);
}
void UpdatePeriodic(AuraEffect* aurEff)
{
AuraEffect* regen = GetAura()->GetEffect(EFFECT_0);
if (!regen)
return;
// **********************************************
// This feature used only in arenas
// **********************************************
// Here need increase mana regen per tick (6 second rule)
// on 0 tick - 0 (handled in 2 second)
// on 1 tick - 166% (handled in 4 second)
// on 2 tick - 133% (handled in 6 second)
// Apply bonus for 1 - 4 tick
switch (aurEff->GetTickNumber())
{
case 1: // 0%
regen->ChangeAmount(0);
break;
case 2: // 166%
regen->ChangeAmount(aurEff->GetAmount() * 5 / 3);
break;
case 3: // 133%
regen->ChangeAmount(aurEff->GetAmount() * 4 / 3);
break;
default: // 100% - normal regen
regen->ChangeAmount(aurEff->GetAmount());
// No need to update after 4th tick
aurEff->SetPeriodic(false);
break;
}
}
void Register() override
{
DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_gen_arena_drink::CalcPeriodic, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_gen_arena_drink::CalcAmount, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY);
OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_gen_arena_drink::UpdatePeriodic, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY);
}
};
// 28313 - Aura of Fear
class spell_gen_aura_of_fear : public AuraScript
{
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellEffect({ { spellInfo->Id, EFFECT_0 } }) && ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
}
void PeriodicTick(AuraEffect const* aurEff)
{
PreventDefaultAction();
if (!roll_chance(GetSpellInfo()->ProcChance))
return;
GetTarget()->CastSpell(nullptr, aurEff->GetSpellEffectInfo().TriggerSpell, true);
}
void Register() override
{
OnEffectPeriodic += AuraEffectPeriodicFn(spell_gen_aura_of_fear::PeriodicTick, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
}
};
class spell_gen_av_drekthar_presence : public 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::CheckAreaTarget);
}
};
enum GenericBandage
{
SPELL_RECENTLY_BANDAGED = 11196
};
class spell_gen_bandage : public SpellScript
{
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_RECENTLY_BANDAGED });
}
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::CheckCast);
AfterHit += SpellHitFn(spell_gen_bandage::HandleScript);
}
};
// 193970 - Mercenary Shapeshift
class spell_gen_battleground_mercenary_shapeshift : public AuraScript
{
inline static std::unordered_map<Races, std::array<uint32, 2>> const RaceDisplayIds =
{
{ RACE_HUMAN, { 55239, 55238 } },
{ RACE_ORC, { 55257, 55256 } },
{ RACE_DWARF, { 55241, 55240 } },
{ RACE_NIGHTELF, { 55243, 55242 } },
{ RACE_UNDEAD_PLAYER, { 55259, 55258 } },
{ RACE_TAUREN, { 55261, 55260 } },
{ RACE_GNOME, { 55245, 55244 } },
{ RACE_TROLL, { 55263, 55262 } },
{ RACE_GOBLIN, { 55267, 57244 } },
{ RACE_BLOODELF, { 55265, 55264 } },
{ RACE_DRAENEI, { 55247, 55246 } },
{ RACE_WORGEN, { 55255, 55254 } },
{ RACE_PANDAREN_NEUTRAL, { 55253, 55252 } }, // not verified, might be swapped with RACE_PANDAREN_HORDE
{ RACE_PANDAREN_ALLIANCE, { 55249, 55248 } },
{ RACE_PANDAREN_HORDE, { 55251, 55250 } },
{ RACE_NIGHTBORNE, { 82375, 82376 } },
{ RACE_HIGHMOUNTAIN_TAUREN, { 82377, 82378 } },
{ RACE_VOID_ELF, { 82371, 82372 } },
{ RACE_LIGHTFORGED_DRAENEI, { 82373, 82374 } },
{ RACE_ZANDALARI_TROLL, { 88417, 88416 } },
{ RACE_KUL_TIRAN, { 88414, 88413 } },
{ RACE_DARK_IRON_DWARF, { 88409, 88408 } },
{ RACE_VULPERA, { 94999, 95001 } },
{ RACE_MAGHAR_ORC, { 88420, 88410 } },
{ RACE_MECHAGNOME, { 94998, 95000 } },
{ RACE_DRACTHYR_ALLIANCE, { 112794, 112793 } },
{ RACE_DRACTHYR_HORDE, { 112796, 112795 } },
{ RACE_EARTHEN_DWARF_HORDE, { 118113, 118114 } },
{ RACE_EARTHEN_DWARF_ALLIANCE, { 118111, 118112 } },
{ RACE_HARANIR_ALLIANCE, { 140501, 140500 } },
{ RACE_HARANIR_HORDE, { 140503, 140502 } },
};
inline static std::vector<uint32> RacialSkills;
static Races GetReplacementRace(Races nativeRace, Classes playerClass)
{
if (CharBaseInfoEntry const* charBaseInfo = DB2Manager::GetCharBaseInfo(nativeRace, playerClass))
if (sObjectMgr->GetPlayerInfo(charBaseInfo->OtherFactionRaceID, playerClass))
return Races(charBaseInfo->OtherFactionRaceID);
return RACE_NONE;
}
static uint32 GetDisplayIdForRace(Races race, Gender gender)
{
if (std::array<uint32, 2> const* displayIds = Trinity::Containers::MapGetValuePtr(RaceDisplayIds, race))
return (*displayIds)[gender];
return 0;
}
bool Validate(SpellInfo const* /*spellInfo*/) override
{
for (auto const& [race, displayIds] : RaceDisplayIds)
{
if (!sChrRacesStore.LookupEntry(race))
return false;
for (uint32 displayId : displayIds)
if (!sCreatureDisplayInfoStore.LookupEntry(displayId))
return false;
}
RacialSkills.clear();
for (SkillLineEntry const* skillLine : sSkillLineStore)
if (skillLine->GetFlags().HasFlag(SkillLineFlags::RacialForThePurposeOfTemporaryRaceChange))
RacialSkills.push_back(skillLine->ID);
return true;
}
void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes mode) const
{
Unit* owner = GetUnitOwner();
Races otherFactionRace = GetReplacementRace(Races(owner->GetRace()), Classes(owner->GetClass()));
if (otherFactionRace == RACE_NONE)
return;
if (uint32 displayId = GetDisplayIdForRace(otherFactionRace, owner->GetNativeGender()))
owner->SetDisplayId(displayId);
if (mode & AURA_EFFECT_HANDLE_REAL)
UpdateRacials(Races(owner->GetRace()), otherFactionRace);
}
void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) const
{
Unit* owner = GetUnitOwner();
Races otherFactionRace = GetReplacementRace(Races(owner->GetRace()), Classes(owner->GetClass()));
if (otherFactionRace == RACE_NONE)
return;
UpdateRacials(otherFactionRace, Races(owner->GetRace()));
}
void UpdateRacials(Races oldRace, Races newRace) const
{
Player* player = GetUnitOwner()->ToPlayer();
if (!player)
return;
for (uint32 racialSkillId : RacialSkills)
{
if (sDB2Manager.GetSkillRaceClassInfo(racialSkillId, oldRace, player->GetClass()))
if (std::vector<SkillLineAbilityEntry const*> const* skillLineAbilities = sDB2Manager.GetSkillLineAbilitiesBySkill(racialSkillId))
for (SkillLineAbilityEntry const* ability : *skillLineAbilities)
player->RemoveSpell(ability->Spell, false, false);
if (sDB2Manager.GetSkillRaceClassInfo(racialSkillId, newRace, player->GetClass()))
player->LearnSkillRewardedSpells(racialSkillId, player->GetMaxSkillValueForLevel(), newRace);
}
}
void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_gen_battleground_mercenary_shapeshift::HandleApply, EFFECT_0, SPELL_AURA_TRANSFORM, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK);
AfterEffectRemove += AuraEffectApplyFn(spell_gen_battleground_mercenary_shapeshift::HandleRemove, EFFECT_0, SPELL_AURA_TRANSFORM, AURA_EFFECT_HANDLE_REAL);
}
};
// Blood Reserve - 64568
enum BloodReserve
{
SPELL_GEN_BLOOD_RESERVE_AURA = 64568,
SPELL_GEN_BLOOD_RESERVE_HEAL = 64569
};
class spell_gen_blood_reserve : public AuraScript
{
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_GEN_BLOOD_RESERVE_HEAL });
}
bool CheckProc(ProcEventInfo& eventInfo)
{
if (Unit* caster = eventInfo.GetActionTarget())
if (caster->HealthBelowPct(35))
return true;
return false;
}
void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActionTarget();
CastSpellExtraArgs args(aurEff);
args.AddSpellBP0(aurEff->GetAmount());
caster->CastSpell(caster, SPELL_GEN_BLOOD_RESERVE_HEAL, args);
caster->RemoveAura(SPELL_GEN_BLOOD_RESERVE_AURA);
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_gen_blood_reserve::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_gen_blood_reserve::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
}
};
enum Bonked
{
SPELL_BONKED = 62991,
SPELL_FOAM_SWORD_DEFEAT = 62994,
SPELL_ON_GUARD = 62972
};
class spell_gen_bonked : public 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::HandleScript, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
/* 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 SpellScript
{
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ 62552, 62719, 64100, 66482 });
}
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())
{
if (aura->GetId() == 62552 || aura->GetId() == 62719 || aura->GetId() == 64100 || aura->GetId() == 66482)
{
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::HandleScriptEffect, EFFECT_FIRST_FOUND, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
// 48750 - Burning Depths Necrolyte Image
class spell_gen_burning_depths_necrolyte_image : public AuraScript
{
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellEffect({ { spellInfo->Id, EFFECT_2 } })
&& ValidateSpellInfo({ static_cast<uint32>(spellInfo->GetEffect(EFFECT_2).CalcValueAsInt()) });
}
void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
if (Unit* caster = GetCaster())
caster->CastSpell(GetTarget(), uint32(GetEffectInfo(EFFECT_2).CalcValueAsInt()));
}
void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
GetTarget()->RemoveAurasDueToSpell(uint32(GetEffectInfo(EFFECT_2).CalcValueAsInt()), GetCasterGUID());
}
void Register() override
{
AfterEffectApply += AuraEffectApplyFn(spell_gen_burning_depths_necrolyte_image::HandleApply, EFFECT_0, SPELL_AURA_TRANSFORM, AURA_EFFECT_HANDLE_REAL);
AfterEffectRemove += AuraEffectRemoveFn(spell_gen_burning_depths_necrolyte_image::HandleRemove, EFFECT_0, SPELL_AURA_TRANSFORM, AURA_EFFECT_HANDLE_REAL);
}
};
class spell_gen_cancel_aura : public SpellScript
{
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) });
}
void HandleScript(SpellEffIndex /*effIndex*/)
{
GetHitUnit()->RemoveAurasDueToSpell(uint32(GetEffectValueAsInt()));
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_gen_cancel_aura::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
class spell_gen_cast_caster_to_target : public SpellScript
{
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) });
}
void HandleScript(SpellEffIndex /*effIndex*/)
{
GetCaster()->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt()));
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_gen_cast_caster_to_target::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
class spell_gen_cast_target_to_target : public SpellScript
{
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ uint32(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt()) });
}
void HandleScript(SpellEffIndex /*effIndex*/)
{
GetHitUnit()->CastSpell(GetHitUnit(), uint32(GetEffectValueAsInt()));
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_gen_cast_target_to_target::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
enum CannibalizeSpells
{
SPELL_CANNIBALIZE_TRIGGERED = 20578
};
class spell_gen_cannibalize : public SpellScript
{
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_CANNIBALIZE_TRIGGERED });
}
SpellCastResult CheckIfCorpseNear()
{
Unit* caster = GetCaster();
float max_range = GetSpellInfo()->GetMaxRange(false);
WorldObject* result = nullptr;
// search for nearby enemy corpse in range
Trinity::AnyDeadUnitSpellTargetInRangeCheck check(caster, max_range, GetSpellInfo(), TARGET_CHECK_ENEMY, TARGET_OBJECT_TYPE_CORPSE_ENEMY);
Trinity::WorldObjectSearcher<Trinity::AnyDeadUnitSpellTargetInRangeCheck> searcher(caster, result, check);
Cell::VisitWorldObjects(caster, searcher, max_range);
if (!result)
Cell::VisitGridObjects(caster, searcher, max_range);
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::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
OnCheckCast += SpellCheckCastFn(spell_gen_cannibalize::CheckIfCorpseNear);
}
};
// 66020 Chains of Ice
class spell_gen_chains_of_ice : public AuraScript
{
void UpdatePeriodic(AuraEffect* aurEff)
{
// Get 0 effect aura
AuraEffect* slow = GetAura()->GetEffect(EFFECT_0);
if (!slow)
return;
SpellEffectValue newAmount = std::min(slow->GetAmount() + aurEff->GetAmount(), 0.0);
slow->ChangeAmount(newAmount);
}
void Register() override
{
OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_gen_chains_of_ice::UpdatePeriodic, EFFECT_1, SPELL_AURA_PERIODIC_DUMMY);
}
};
// 28471 - ClearAll
class spell_clear_all : public SpellScript
{
void HandleScript(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
caster->RemoveAllAurasOnDeath();
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_clear_all::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
enum Clone
{
SPELL_NIGHTMARE_FIGMENT_MIRROR_IMAGE = 57528
};
class spell_gen_clone : public SpellScript
{
void HandleScriptEffect(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValueAsInt()), true);
}
void Register() override
{
if (m_scriptSpellId == SPELL_NIGHTMARE_FIGMENT_MIRROR_IMAGE)
{
OnEffectHitTarget += SpellEffectFn(spell_gen_clone::HandleScriptEffect, EFFECT_1, SPELL_EFFECT_DUMMY);
OnEffectHitTarget += SpellEffectFn(spell_gen_clone::HandleScriptEffect, EFFECT_2, SPELL_EFFECT_DUMMY);
}
else
{
OnEffectHitTarget += SpellEffectFn(spell_gen_clone::HandleScriptEffect, EFFECT_1, SPELL_EFFECT_SCRIPT_EFFECT);
OnEffectHitTarget += SpellEffectFn(spell_gen_clone::HandleScriptEffect, EFFECT_2, SPELL_EFFECT_SCRIPT_EFFECT);
}
}
};
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 SpellScript
{
void HandleScriptEffect(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
GetHitUnit()->CastSpell(GetCaster(), uint32(GetEffectValueAsInt()), true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_gen_clone_weapon::HandleScriptEffect, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
class spell_gen_clone_weapon_aura : public AuraScript
{
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo(
{
SPELL_COPY_WEAPON_AURA,
SPELL_COPY_WEAPON_2_AURA,
SPELL_COPY_WEAPON_3_AURA,
SPELL_COPY_OFFHAND_AURA,
SPELL_COPY_OFFHAND_2_AURA,
SPELL_COPY_RANGED_AURA
});
}
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->GetVirtualItemId(0);
if (Player* player = caster->ToPlayer())
{
if (Item* mainItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND))
target->SetVirtualItem(0, mainItem->GetEntry());
}
else
target->SetVirtualItem(0, caster->GetVirtualItemId(0));
break;
}
case SPELL_COPY_OFFHAND_AURA:
case SPELL_COPY_OFFHAND_2_AURA:
{
prevItem = target->GetVirtualItemId(1);
if (Player* player = caster->ToPlayer())
{
if (Item* offItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND))
target->SetVirtualItem(1, offItem->GetEntry());
}
else
target->SetVirtualItem(1, caster->GetVirtualItemId(1));
break;
}
case SPELL_COPY_RANGED_AURA:
{
prevItem = target->GetVirtualItemId(2);
if (Player* player = caster->ToPlayer())
{
if (Item* rangedItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND))
target->SetVirtualItem(2, rangedItem->GetEntry());
}
else
target->SetVirtualItem(2, caster->GetVirtualItemId(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: