/
spell_item.cpp
2802 lines (2373 loc) · 99.6 KB
/
spell_item.cpp
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-2016 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 spells used by items.
* Ordered alphabetically using scriptname.
* Scriptnames of files in this file should be prefixed with "spell_item_".
*/
#include "Player.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "SpellAuraEffects.h"
#include "SpellHistory.h"
#include "SkillDiscovery.h"
#include "Battleground.h"
#include "DBCStores.h"
// Generic script for handling item dummy effects which trigger another spell.
class spell_item_trigger_spell : public SpellScriptLoader
{
private:
uint32 _triggeredSpellId;
public:
spell_item_trigger_spell(const char* name, uint32 triggeredSpellId) : SpellScriptLoader(name), _triggeredSpellId(triggeredSpellId) { }
class spell_item_trigger_spell_SpellScript : public SpellScript
{
PrepareSpellScript(spell_item_trigger_spell_SpellScript);
private:
uint32 _triggeredSpellId;
public:
spell_item_trigger_spell_SpellScript(uint32 triggeredSpellId) : SpellScript(), _triggeredSpellId(triggeredSpellId) { }
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(_triggeredSpellId))
return false;
return true;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
if (Item* item = GetCastItem())
caster->CastSpell(caster, _triggeredSpellId, true, item);
}
void Register() override
{
OnEffectHit += SpellEffectFn(spell_item_trigger_spell_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_item_trigger_spell_SpellScript(_triggeredSpellId);
}
};
enum AegisOfPreservation
{
SPELL_AEGIS_HEAL = 23781
};
// 23780 - Aegis of Preservation
class spell_item_aegis_of_preservation : public SpellScriptLoader
{
public:
spell_item_aegis_of_preservation() : SpellScriptLoader("spell_item_aegis_of_preservation") { }
class spell_item_aegis_of_preservation_AuraScript : public AuraScript
{
PrepareAuraScript(spell_item_aegis_of_preservation_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_AEGIS_HEAL))
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
{
PreventDefaultAction();
GetTarget()->CastSpell(GetTarget(), SPELL_AEGIS_HEAL, true, NULL, aurEff);
}
void Register() override
{
OnEffectProc += AuraEffectProcFn(spell_item_aegis_of_preservation_AuraScript::HandleProc, EFFECT_1, SPELL_AURA_PROC_TRIGGER_SPELL);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_item_aegis_of_preservation_AuraScript();
}
};
// 26400 - Arcane Shroud
class spell_item_arcane_shroud : public SpellScriptLoader
{
public:
spell_item_arcane_shroud() : SpellScriptLoader("spell_item_arcane_shroud") { }
class spell_item_arcane_shroud_AuraScript : public AuraScript
{
PrepareAuraScript(spell_item_arcane_shroud_AuraScript);
void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
{
int32 diff = GetUnitOwner()->getLevel() - 60;
if (diff > 0)
amount += 2 * diff;
}
void Register() override
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_item_arcane_shroud_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_MOD_THREAT);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_item_arcane_shroud_AuraScript();
}
};
// 64411 - Blessing of Ancient Kings (Val'anyr, Hammer of Ancient Kings)
enum BlessingOfAncientKings
{
SPELL_PROTECTION_OF_ANCIENT_KINGS = 64413
};
class spell_item_blessing_of_ancient_kings : public SpellScriptLoader
{
public:
spell_item_blessing_of_ancient_kings() : SpellScriptLoader("spell_item_blessing_of_ancient_kings") { }
class spell_item_blessing_of_ancient_kings_AuraScript : public AuraScript
{
PrepareAuraScript(spell_item_blessing_of_ancient_kings_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_PROTECTION_OF_ANCIENT_KINGS))
return false;
return true;
}
bool CheckProc(ProcEventInfo& eventInfo)
{
return eventInfo.GetProcTarget() != nullptr;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
int32 absorb = int32(CalculatePct(eventInfo.GetHealInfo()->GetHeal(), 15.0f));
if (AuraEffect* protEff = eventInfo.GetProcTarget()->GetAuraEffect(SPELL_PROTECTION_OF_ANCIENT_KINGS, 0, eventInfo.GetActor()->GetGUID()))
{
// The shield can grow to a maximum size of 20,000 damage absorbtion
protEff->SetAmount(std::min<int32>(protEff->GetAmount() + absorb, 20000));
// Refresh and return to prevent replacing the aura
protEff->GetBase()->RefreshDuration();
}
else
GetTarget()->CastCustomSpell(SPELL_PROTECTION_OF_ANCIENT_KINGS, SPELLVALUE_BASE_POINT0, absorb, eventInfo.GetProcTarget(), true, NULL, aurEff);
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_item_blessing_of_ancient_kings_AuraScript::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_item_blessing_of_ancient_kings_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_item_blessing_of_ancient_kings_AuraScript();
}
};
// 47770 - Roll Dice
class spell_item_decahedral_dwarven_dice : public SpellScriptLoader
{
public:
spell_item_decahedral_dwarven_dice() : SpellScriptLoader("spell_item_decahedral_dwarven_dice") { }
class spell_item_decahedral_dwarven_dice_SpellScript : public SpellScript
{
PrepareSpellScript(spell_item_decahedral_dwarven_dice_SpellScript);
enum
{
TEXT_DECAHEDRAL_DWARVEN_DICE = 26147
};
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sBroadcastTextStore.LookupEntry(TEXT_DECAHEDRAL_DWARVEN_DICE))
return false;
return true;
}
bool Load() override
{
return GetCaster()->GetTypeId() == TYPEID_PLAYER;
}
void HandleScript(SpellEffIndex /*effIndex*/)
{
GetCaster()->TextEmote(TEXT_DECAHEDRAL_DWARVEN_DICE, GetHitUnit());
static uint32 const minimum = 1;
static uint32 const maximum = 100;
GetCaster()->ToPlayer()->DoRandomRoll(minimum, maximum);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_item_decahedral_dwarven_dice_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_item_decahedral_dwarven_dice_SpellScript();
}
};
// 8342 - Defibrillate (Goblin Jumper Cables) have 33% chance on success
// 22999 - Defibrillate (Goblin Jumper Cables XL) have 50% chance on success
// 54732 - Defibrillate (Gnomish Army Knife) have 67% chance on success
enum Defibrillate
{
SPELL_GOBLIN_JUMPER_CABLES_FAIL = 8338,
SPELL_GOBLIN_JUMPER_CABLES_XL_FAIL = 23055
};
class spell_item_defibrillate : public SpellScriptLoader
{
public:
spell_item_defibrillate(char const* name, uint8 chance, uint32 failSpell = 0) : SpellScriptLoader(name), _chance(chance), _failSpell(failSpell) { }
class spell_item_defibrillate_SpellScript : public SpellScript
{
PrepareSpellScript(spell_item_defibrillate_SpellScript);
public:
spell_item_defibrillate_SpellScript(uint8 chance, uint32 failSpell) : SpellScript(), _chance(chance), _failSpell(failSpell) { }
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (_failSpell && !sSpellMgr->GetSpellInfo(_failSpell))
return false;
return true;
}
void HandleScript(SpellEffIndex effIndex)
{
if (roll_chance_i(_chance))
{
PreventHitDefaultEffect(effIndex);
if (_failSpell)
GetCaster()->CastSpell(GetCaster(), _failSpell, true, GetCastItem());
}
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_item_defibrillate_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_RESURRECT);
}
private:
uint8 _chance;
uint32 _failSpell;
};
SpellScript* GetSpellScript() const override
{
return new spell_item_defibrillate_SpellScript(_chance, _failSpell);
}
private:
uint8 _chance;
uint32 _failSpell;
};
enum DesperateDefense
{
SPELL_DESPERATE_RAGE = 33898
};
// 33896 - Desperate Defense
class spell_item_desperate_defense : public SpellScriptLoader
{
public:
spell_item_desperate_defense() : SpellScriptLoader("spell_item_desperate_defense") { }
class spell_item_desperate_defense_AuraScript : public AuraScript
{
PrepareAuraScript(spell_item_desperate_defense_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_DESPERATE_RAGE))
return false;
return true;
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
{
PreventDefaultAction();
GetTarget()->CastSpell(GetTarget(), SPELL_DESPERATE_RAGE, true, NULL, aurEff);
}
void Register() override
{
OnEffectProc += AuraEffectProcFn(spell_item_desperate_defense_AuraScript::HandleProc, EFFECT_2, SPELL_AURA_PROC_TRIGGER_SPELL);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_item_desperate_defense_AuraScript();
}
};
// http://www.wowhead.com/item=6522 Deviate Fish
// 8063 Deviate Fish
enum DeviateFishSpells
{
SPELL_SLEEPY = 8064,
SPELL_INVIGORATE = 8065,
SPELL_SHRINK = 8066,
SPELL_PARTY_TIME = 8067,
SPELL_HEALTHY_SPIRIT = 8068,
};
class spell_item_deviate_fish : public SpellScriptLoader
{
public:
spell_item_deviate_fish() : SpellScriptLoader("spell_item_deviate_fish") { }
class spell_item_deviate_fish_SpellScript : public SpellScript
{
PrepareSpellScript(spell_item_deviate_fish_SpellScript);
bool Load() override
{
return GetCaster()->GetTypeId() == TYPEID_PLAYER;
}
bool Validate(SpellInfo const* /*spellInfo*/) override
{
for (uint32 spellId = SPELL_SLEEPY; spellId <= SPELL_HEALTHY_SPIRIT; ++spellId)
if (!sSpellMgr->GetSpellInfo(spellId))
return false;
return true;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
uint32 spellId = urand(SPELL_SLEEPY, SPELL_HEALTHY_SPIRIT);
caster->CastSpell(caster, spellId, true, NULL);
}
void Register() override
{
OnEffectHit += SpellEffectFn(spell_item_deviate_fish_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_item_deviate_fish_SpellScript();
}
};
// 71610, 71641 - Echoes of Light (Althor's Abacus)
class spell_item_echoes_of_light : public SpellScriptLoader
{
public:
spell_item_echoes_of_light() : SpellScriptLoader("spell_item_echoes_of_light") { }
class spell_item_echoes_of_light_SpellScript : public SpellScript
{
PrepareSpellScript(spell_item_echoes_of_light_SpellScript);
void FilterTargets(std::list<WorldObject*>& targets)
{
if (targets.size() < 2)
return;
targets.sort(Trinity::HealthPctOrderPred());
WorldObject* target = targets.front();
targets.clear();
targets.push_back(target);
}
void Register() override
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_item_echoes_of_light_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_DEST_AREA_ALLY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_item_echoes_of_light_SpellScript();
}
};
// 7434 - Fate Rune of Unsurpassed Vigor
enum FateRuneOfUnsurpassedVigor
{
SPELL_UNSURPASSED_VIGOR = 25733
};
class spell_item_fate_rune_of_unsurpassed_vigor : public SpellScriptLoader
{
public:
spell_item_fate_rune_of_unsurpassed_vigor() : SpellScriptLoader("spell_item_fate_rune_of_unsurpassed_vigor") { }
class spell_item_fate_rune_of_unsurpassed_vigor_AuraScript : public AuraScript
{
PrepareAuraScript(spell_item_fate_rune_of_unsurpassed_vigor_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_UNSURPASSED_VIGOR))
return false;
return true;
}
void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/)
{
GetTarget()->CastSpell(GetTarget(), SPELL_UNSURPASSED_VIGOR, true);
}
void Register() override
{
OnEffectProc += AuraEffectProcFn(spell_item_fate_rune_of_unsurpassed_vigor_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_item_fate_rune_of_unsurpassed_vigor_AuraScript();
}
};
// http://www.wowhead.com/item=47499 Flask of the North
// 67019 Flask of the North
enum FlaskOfTheNorthSpells
{
SPELL_FLASK_OF_THE_NORTH_SP = 67016,
SPELL_FLASK_OF_THE_NORTH_AP = 67017,
SPELL_FLASK_OF_THE_NORTH_STR = 67018,
};
class spell_item_flask_of_the_north : public SpellScriptLoader
{
public:
spell_item_flask_of_the_north() : SpellScriptLoader("spell_item_flask_of_the_north") { }
class spell_item_flask_of_the_north_SpellScript : public SpellScript
{
PrepareSpellScript(spell_item_flask_of_the_north_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_FLASK_OF_THE_NORTH_SP) || !sSpellMgr->GetSpellInfo(SPELL_FLASK_OF_THE_NORTH_AP) || !sSpellMgr->GetSpellInfo(SPELL_FLASK_OF_THE_NORTH_STR))
return false;
return true;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
std::vector<uint32> possibleSpells;
switch (caster->getClass())
{
case CLASS_WARLOCK:
case CLASS_MAGE:
case CLASS_PRIEST:
possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_SP);
break;
case CLASS_DEATH_KNIGHT:
case CLASS_WARRIOR:
possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_STR);
break;
case CLASS_ROGUE:
case CLASS_HUNTER:
possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_AP);
break;
case CLASS_DRUID:
case CLASS_PALADIN:
possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_SP);
possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_STR);
break;
case CLASS_SHAMAN:
possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_SP);
possibleSpells.push_back(SPELL_FLASK_OF_THE_NORTH_AP);
break;
}
if (possibleSpells.empty())
{
TC_LOG_WARN("spells", "Missing spells for class %u in script spell_item_flask_of_the_north", caster->getClass());
return;
}
caster->CastSpell(caster, possibleSpells[urand(0, (possibleSpells.size() - 1))], true, NULL);
}
void Register() override
{
OnEffectHit += SpellEffectFn(spell_item_flask_of_the_north_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_item_flask_of_the_north_SpellScript();
}
};
// http://www.wowhead.com/item=10645 Gnomish Death Ray
// 13280 Gnomish Death Ray
enum GnomishDeathRay
{
SPELL_GNOMISH_DEATH_RAY_SELF = 13493,
SPELL_GNOMISH_DEATH_RAY_TARGET = 13279,
};
class spell_item_gnomish_death_ray : public SpellScriptLoader
{
public:
spell_item_gnomish_death_ray() : SpellScriptLoader("spell_item_gnomish_death_ray") { }
class spell_item_gnomish_death_ray_SpellScript : public SpellScript
{
PrepareSpellScript(spell_item_gnomish_death_ray_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_GNOMISH_DEATH_RAY_SELF) || !sSpellMgr->GetSpellInfo(SPELL_GNOMISH_DEATH_RAY_TARGET))
return false;
return true;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
if (Unit* target = GetHitUnit())
{
if (urand(0, 99) < 15)
caster->CastSpell(caster, SPELL_GNOMISH_DEATH_RAY_SELF, true, NULL); // failure
else
caster->CastSpell(target, SPELL_GNOMISH_DEATH_RAY_TARGET, true, NULL);
}
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_item_gnomish_death_ray_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_item_gnomish_death_ray_SpellScript();
}
};
// http://www.wowhead.com/item=27388 Mr. Pinchy
// 33060 Make a Wish
enum MakeAWish
{
SPELL_MR_PINCHYS_BLESSING = 33053,
SPELL_SUMMON_MIGHTY_MR_PINCHY = 33057,
SPELL_SUMMON_FURIOUS_MR_PINCHY = 33059,
SPELL_TINY_MAGICAL_CRAWDAD = 33062,
SPELL_MR_PINCHYS_GIFT = 33064,
};
class spell_item_make_a_wish : public SpellScriptLoader
{
public:
spell_item_make_a_wish() : SpellScriptLoader("spell_item_make_a_wish") { }
class spell_item_make_a_wish_SpellScript : public SpellScript
{
PrepareSpellScript(spell_item_make_a_wish_SpellScript);
bool Load() override
{
return GetCaster()->GetTypeId() == TYPEID_PLAYER;
}
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_MR_PINCHYS_BLESSING) || !sSpellMgr->GetSpellInfo(SPELL_SUMMON_MIGHTY_MR_PINCHY) || !sSpellMgr->GetSpellInfo(SPELL_SUMMON_FURIOUS_MR_PINCHY) || !sSpellMgr->GetSpellInfo(SPELL_TINY_MAGICAL_CRAWDAD) || !sSpellMgr->GetSpellInfo(SPELL_MR_PINCHYS_GIFT))
return false;
return true;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
uint32 spellId = SPELL_MR_PINCHYS_GIFT;
switch (urand(1, 5))
{
case 1: spellId = SPELL_MR_PINCHYS_BLESSING; break;
case 2: spellId = SPELL_SUMMON_MIGHTY_MR_PINCHY; break;
case 3: spellId = SPELL_SUMMON_FURIOUS_MR_PINCHY; break;
case 4: spellId = SPELL_TINY_MAGICAL_CRAWDAD; break;
}
caster->CastSpell(caster, spellId, true, NULL);
}
void Register() override
{
OnEffectHit += SpellEffectFn(spell_item_make_a_wish_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_item_make_a_wish_SpellScript();
}
};
// http://www.wowhead.com/item=32686 Mingo's Fortune Giblets
// 40802 Mingo's Fortune Generator
class spell_item_mingos_fortune_generator : public SpellScriptLoader
{
public:
spell_item_mingos_fortune_generator() : SpellScriptLoader("spell_item_mingos_fortune_generator") { }
class spell_item_mingos_fortune_generator_SpellScript : public SpellScript
{
PrepareSpellScript(spell_item_mingos_fortune_generator_SpellScript);
void HandleDummy(SpellEffIndex effIndex)
{
// Selecting one from Bloodstained Fortune item
uint32 newitemid;
switch (urand(1, 20))
{
case 1: newitemid = 32688; break;
case 2: newitemid = 32689; break;
case 3: newitemid = 32690; break;
case 4: newitemid = 32691; break;
case 5: newitemid = 32692; break;
case 6: newitemid = 32693; break;
case 7: newitemid = 32700; break;
case 8: newitemid = 32701; break;
case 9: newitemid = 32702; break;
case 10: newitemid = 32703; break;
case 11: newitemid = 32704; break;
case 12: newitemid = 32705; break;
case 13: newitemid = 32706; break;
case 14: newitemid = 32707; break;
case 15: newitemid = 32708; break;
case 16: newitemid = 32709; break;
case 17: newitemid = 32710; break;
case 18: newitemid = 32711; break;
case 19: newitemid = 32712; break;
case 20: newitemid = 32713; break;
default:
return;
}
CreateItem(effIndex, newitemid);
}
void Register() override
{
OnEffectHit += SpellEffectFn(spell_item_mingos_fortune_generator_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_item_mingos_fortune_generator_SpellScript();
}
};
// 71875, 71877 - Item - Black Bruise: Necrotic Touch Proc
enum NecroticTouch
{
SPELL_ITEM_NECROTIC_TOUCH_PROC = 71879
};
class spell_item_necrotic_touch : public SpellScriptLoader
{
public:
spell_item_necrotic_touch() : SpellScriptLoader("spell_item_necrotic_touch") { }
class spell_item_necrotic_touch_AuraScript : public AuraScript
{
PrepareAuraScript(spell_item_necrotic_touch_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_ITEM_NECROTIC_TOUCH_PROC))
return false;
return true;
}
bool CheckProc(ProcEventInfo& eventInfo)
{
return eventInfo.GetProcTarget() && eventInfo.GetProcTarget()->IsAlive();
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
int32 bp = CalculatePct(int32(eventInfo.GetDamageInfo()->GetDamage()), aurEff->GetAmount());
GetTarget()->CastCustomSpell(SPELL_ITEM_NECROTIC_TOUCH_PROC, SPELLVALUE_BASE_POINT0, bp, eventInfo.GetProcTarget(), true, NULL, aurEff);
}
void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_item_necrotic_touch_AuraScript::CheckProc);
OnEffectProc += AuraEffectProcFn(spell_item_necrotic_touch_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY);
}
};
AuraScript* GetAuraScript() const override
{
return new spell_item_necrotic_touch_AuraScript();
}
};
// http://www.wowhead.com/item=10720 Gnomish Net-o-Matic Projector
// 13120 Net-o-Matic
enum NetOMaticSpells
{
SPELL_NET_O_MATIC_TRIGGERED1 = 16566,
SPELL_NET_O_MATIC_TRIGGERED2 = 13119,
SPELL_NET_O_MATIC_TRIGGERED3 = 13099,
};
class spell_item_net_o_matic : public SpellScriptLoader
{
public:
spell_item_net_o_matic() : SpellScriptLoader("spell_item_net_o_matic") { }
class spell_item_net_o_matic_SpellScript : public SpellScript
{
PrepareSpellScript(spell_item_net_o_matic_SpellScript);
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_NET_O_MATIC_TRIGGERED1) || !sSpellMgr->GetSpellInfo(SPELL_NET_O_MATIC_TRIGGERED2) || !sSpellMgr->GetSpellInfo(SPELL_NET_O_MATIC_TRIGGERED3))
return false;
return true;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
if (Unit* target = GetHitUnit())
{
uint32 spellId = SPELL_NET_O_MATIC_TRIGGERED3;
uint32 roll = urand(0, 99);
if (roll < 2) // 2% for 30 sec self root (off-like chance unknown)
spellId = SPELL_NET_O_MATIC_TRIGGERED1;
else if (roll < 4) // 2% for 20 sec root, charge to target (off-like chance unknown)
spellId = SPELL_NET_O_MATIC_TRIGGERED2;
GetCaster()->CastSpell(target, spellId, true, NULL);
}
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_item_net_o_matic_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_item_net_o_matic_SpellScript();
}
};
// http://www.wowhead.com/item=8529 Noggenfogger Elixir
// 16589 Noggenfogger Elixir
enum NoggenfoggerElixirSpells
{
SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED1 = 16595,
SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED2 = 16593,
SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED3 = 16591,
};
class spell_item_noggenfogger_elixir : public SpellScriptLoader
{
public:
spell_item_noggenfogger_elixir() : SpellScriptLoader("spell_item_noggenfogger_elixir") { }
class spell_item_noggenfogger_elixir_SpellScript : public SpellScript
{
PrepareSpellScript(spell_item_noggenfogger_elixir_SpellScript);
bool Load() override
{
return GetCaster()->GetTypeId() == TYPEID_PLAYER;
}
bool Validate(SpellInfo const* /*spellInfo*/) override
{
if (!sSpellMgr->GetSpellInfo(SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED1) || !sSpellMgr->GetSpellInfo(SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED2) || !sSpellMgr->GetSpellInfo(SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED3))
return false;
return true;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
uint32 spellId = SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED3;
switch (urand(1, 3))
{
case 1: spellId = SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED1; break;
case 2: spellId = SPELL_NOGGENFOGGER_ELIXIR_TRIGGERED2; break;
}
caster->CastSpell(caster, spellId, true, NULL);
}
void Register() override
{
OnEffectHit += SpellEffectFn(spell_item_noggenfogger_elixir_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_item_noggenfogger_elixir_SpellScript();
}
};
// 17512 - Piccolo of the Flaming Fire
class spell_item_piccolo_of_the_flaming_fire : public SpellScriptLoader
{
public:
spell_item_piccolo_of_the_flaming_fire() : SpellScriptLoader("spell_item_piccolo_of_the_flaming_fire") { }
class spell_item_piccolo_of_the_flaming_fire_SpellScript : public SpellScript
{
PrepareSpellScript(spell_item_piccolo_of_the_flaming_fire_SpellScript);
void HandleScript(SpellEffIndex effIndex)
{
PreventHitDefaultEffect(effIndex);
if (Player* target = GetHitPlayer())
target->HandleEmoteCommand(EMOTE_STATE_DANCE);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_item_piccolo_of_the_flaming_fire_SpellScript::HandleScript, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_item_piccolo_of_the_flaming_fire_SpellScript();
}
};
// http://www.wowhead.com/item=6657 Savory Deviate Delight
// 8213 Savory Deviate Delight
enum SavoryDeviateDelight
{
SPELL_FLIP_OUT_MALE = 8219,
SPELL_FLIP_OUT_FEMALE = 8220,
SPELL_YAAARRRR_MALE = 8221,
SPELL_YAAARRRR_FEMALE = 8222,
};
class spell_item_savory_deviate_delight : public SpellScriptLoader
{
public:
spell_item_savory_deviate_delight() : SpellScriptLoader("spell_item_savory_deviate_delight") { }
class spell_item_savory_deviate_delight_SpellScript : public SpellScript
{
PrepareSpellScript(spell_item_savory_deviate_delight_SpellScript);
bool Load() override
{
return GetCaster()->GetTypeId() == TYPEID_PLAYER;
}
bool Validate(SpellInfo const* /*spellInfo*/) override
{
for (uint32 spellId = SPELL_FLIP_OUT_MALE; spellId <= SPELL_YAAARRRR_FEMALE; ++spellId)
if (!sSpellMgr->GetSpellInfo(spellId))
return false;
return true;
}
void HandleDummy(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
uint32 spellId = 0;
switch (urand(1, 2))
{
// Flip Out - ninja
case 1: spellId = (caster->getGender() == GENDER_MALE ? SPELL_FLIP_OUT_MALE : SPELL_FLIP_OUT_FEMALE); break;
// Yaaarrrr - pirate
case 2: spellId = (caster->getGender() == GENDER_MALE ? SPELL_YAAARRRR_MALE : SPELL_YAAARRRR_FEMALE); break;
}
caster->CastSpell(caster, spellId, true, NULL);
}
void Register() override
{
OnEffectHit += SpellEffectFn(spell_item_savory_deviate_delight_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
SpellScript* GetSpellScript() const override
{
return new spell_item_savory_deviate_delight_SpellScript();
}
};
// 48129 - Scroll of Recall
// 60320 - Scroll of Recall II
// 60321 - Scroll of Recall III
enum ScrollOfRecall
{
SPELL_SCROLL_OF_RECALL_I = 48129,
SPELL_SCROLL_OF_RECALL_II = 60320,
SPELL_SCROLL_OF_RECALL_III = 60321,
SPELL_LOST = 60444,
SPELL_SCROLL_OF_RECALL_FAIL_ALLIANCE_1 = 60323,
SPELL_SCROLL_OF_RECALL_FAIL_HORDE_1 = 60328,
};
class spell_item_scroll_of_recall : public SpellScriptLoader
{
public:
spell_item_scroll_of_recall() : SpellScriptLoader("spell_item_scroll_of_recall") { }
class spell_item_scroll_of_recall_SpellScript : public SpellScript
{
PrepareSpellScript(spell_item_scroll_of_recall_SpellScript);
bool Load() override
{
return GetCaster()->GetTypeId() == TYPEID_PLAYER;
}
void HandleScript(SpellEffIndex effIndex)
{
Unit* caster = GetCaster();
uint8 maxSafeLevel = 0;
switch (GetSpellInfo()->Id)
{
case SPELL_SCROLL_OF_RECALL_I: // Scroll of Recall
maxSafeLevel = 40;
break;
case SPELL_SCROLL_OF_RECALL_II: // Scroll of Recall II
maxSafeLevel = 70;
break;
case SPELL_SCROLL_OF_RECALL_III: // Scroll of Recal III
maxSafeLevel = 80;
break;
default:
break;
}