TrinityCore
hallows_end.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "ScriptMgr.h"
19#include "Containers.h"
20#include "CreatureAIImpl.h"
21#include "Player.h"
22#include "ScriptedCreature.h"
23#include "SpellAuraEffects.h"
24#include "SpellScript.h"
25
27{
28 SPELL_HALLOWS_END_CANDY_ORANGE_GIANT = 24924, // Effect 1: Apply Aura: Mod Size, Value: 30%
29 SPELL_HALLOWS_END_CANDY_SKELETON = 24925, // Effect 1: Apply Aura: Change Model (Skeleton). Effect 2: Apply Aura: Underwater Breathing
30 SPELL_HALLOWS_END_CANDY_PIRATE = 24926, // Effect 1: Apply Aura: Increase Swim Speed, Value: 50%
31 SPELL_HALLOWS_END_CANDY_GHOST = 24927, // Effect 1: Apply Aura: Levitate / Hover. Effect 2: Apply Aura: Slow Fall, Effect 3: Apply Aura: Water Walking
32 SPELL_HALLOWS_END_CANDY_FEMALE_DEFIAS_PIRATE = 44742, // Effect 1: Apply Aura: Change Model (Defias Pirate, Female). Effect 2: Increase Swim Speed, Value: 50%
33 SPELL_HALLOWS_END_CANDY_MALE_DEFIAS_PIRATE = 44743 // Effect 1: Apply Aura: Change Model (Defias Pirate, Male). Effect 2: Increase Swim Speed, Value: 50%
34};
35
36std::array<uint32, 4> const CandysSpells =
37{
42};
43
45{
51};
52
54{
57};
58
59// 24930 - Hallow's End Candy
61{
62 bool Validate(SpellInfo const* /*spellInfo*/) override
63 {
65 }
66
67 void HandleDummy(SpellEffIndex /*effIndex*/)
68 {
70 }
71
72 void Register() override
73 {
75 }
76};
77
78// 24926 - Hallow's End Candy
80{
81 bool Validate(SpellInfo const* /*spellInfo*/) override
82 {
83 return ValidateSpellInfo(
84 {
87 });
88 }
89
90 void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
91 {
93 GetTarget()->CastSpell(GetTarget(), spell, true);
94 }
95
96 void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
97 {
100 }
101
102 void Register() override
103 {
106 }
107};
108
110{
121};
122
123// 24750 - Trick
125{
126 bool Validate(SpellInfo const* /*spell*/) override
127 {
128 return ValidateSpellInfo(
129 {
140 });
141 }
142
143 void HandleScript(SpellEffIndex /*effIndex*/)
144 {
145 Unit* caster = GetCaster();
146 if (Player* target = GetHitPlayer())
147 {
148 uint8 gender = target->GetNativeGender();
149 uint32 spellId = SPELL_TRICK_BUFF;
150 switch (urand(0, 5))
151 {
152 case 1:
154 break;
155 case 2:
157 break;
158 case 3:
160 break;
161 case 4:
163 break;
164 case 5:
165 spellId = SPELL_SKELETON_COSTUME;
166 break;
167 default:
168 break;
169 }
170
171 caster->CastSpell(target, spellId, true);
172 }
173 }
174
175 void Register() override
176 {
178 }
179};
180
182{
183 SPELL_TRICK = 24714,
184 SPELL_TREAT = 24715,
188 SPELL_UPSET_TUMMY = 42966
190
191// 24751 - Trick or Treat
193{
194 bool Validate(SpellInfo const* /*spell*/) override
195 {
197 }
198
199 void HandleScript(SpellEffIndex /*effIndex*/)
200 {
201 Unit* caster = GetCaster();
202 if (Player* target = GetHitPlayer())
203 {
204 caster->CastSpell(target, roll_chance_i(50) ? SPELL_TRICK : SPELL_TREAT, true);
205 caster->CastSpell(target, SPELL_TRICKED_OR_TREATED, true);
206 }
207 }
208
209 void Register() override
210 {
212 }
213};
214
215// 44436 - Tricky Treat
217{
218 bool Validate(SpellInfo const* /*spell*/) override
219 {
220 return ValidateSpellInfo(
221 {
225 });
226 }
227
228 void HandleScript(SpellEffIndex /*effIndex*/)
229 {
230 Unit* caster = GetCaster();
232 caster->CastSpell(caster, SPELL_UPSET_TUMMY, true);
233 }
234
235 void Register() override
236 {
238 }
239};
240
242{
252
253// 24717, 24718, 24719, 24720, 24724, 24733, 24737, 24741
255{
256 bool Validate(SpellInfo const* /*spellEntry*/) override
257 {
258 return ValidateSpellInfo(
259 {
268 });
269 }
270
272 {
273 Unit* caster = GetCaster();
274 Unit* target = GetHitUnit();
275
276 uint32 spellId = 0;
277 uint8 gender = target->GetNativeGender();
278
279 switch (GetSpellInfo()->Id)
280 {
283 break;
286 break;
289 break;
292 break;
295 break;
296 default:
297 return;
298 }
299 caster->CastSpell(target, spellId, true);
300 }
301
302 void Register() override
303 {
305 }
306};
307
308// 97135 - Children's Costume Aura
310{
311 static constexpr std::array<uint32, 5> ChildrensCustomeSpells =
312 {
318 };
319
320 bool Validate(SpellInfo const* /*spellInfo*/) override
321 {
323 }
324
326 {
328 }
329
330 void HandlePeriodic(AuraEffect const* aurEff)
331 {
332 for (uint32 spell : ChildrensCustomeSpells)
333 GetTarget()->RemoveAura(spell);
334
336 }
337
338 void Register() override
339 {
342 }
343};
344
345// 191547 - Powder Blast
347{
348 bool Validate(SpellInfo const* /*spellInfo*/) override
349 {
351 }
352
353 void HandleProc(AuraEffect* /*aurEff*/, ProcEventInfo& eventInfo)
354 {
357 }
358
359 void Register() override
360 {
362 }
363};
364
366{
375}
First const & RAND(First const &first, Second const &second, Rest const &... rest)
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
bool roll_chance_i(int chance)
Definition: Random.h:59
#define RegisterSpellScript(spell_script)
Definition: ScriptMgr.h:1369
SpellEffIndex
Definition: SharedDefines.h:29
@ EFFECT_0
Definition: SharedDefines.h:30
@ GENDER_FEMALE
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_PROC_TRIGGER_SPELL
@ SPELL_AURA_MOD_INCREASE_SWIM_SPEED
@ SPELL_AURA_PERIODIC_DUMMY
#define AuraEffectProcFn(F, I, N)
Definition: SpellScript.h:2160
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:842
#define AuraEffectPeriodicFn(F, I, N)
Definition: SpellScript.h:2046
#define AuraEffectApplyFn(F, I, N, M)
Definition: SpellScript.h:2029
#define SpellHitFn(F)
Definition: SpellScript.h:854
#define AuraEffectRemoveFn(F, I, N, M)
Definition: SpellScript.h:2040
HookList< EffectApplyHandler > AfterEffectRemove
Definition: SpellScript.h:2039
HookList< EffectPeriodicHandler > OnEffectPeriodic
Definition: SpellScript.h:2045
HookList< EffectApplyHandler > AfterEffectApply
Definition: SpellScript.h:2028
Unit * GetTarget() const
HookList< EffectProcHandler > OnEffectProc
Definition: SpellScript.h:2155
Unit * GetProcTarget() const
Definition: Unit.h:495
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:162
Player * GetHitPlayer() const
Unit * GetCaster() const
HookList< HitHandler > AfterHit
Definition: SpellScript.h:852
HookList< EffectHandler > OnEffectHit
Definition: SpellScript.h:839
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:840
SpellInfo const * GetSpellInfo() const
Definition: Unit.h:627
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3685
virtual Gender GetNativeGender() const
Definition: Unit.h:757
uint32 GetAuraCount(uint32 spellId) const
Definition: Unit.cpp:4648
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4664
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3831
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2896
void HandleApply(AuraEffect const *, AuraEffectHandleModes)
Definition: hallows_end.cpp:90
void HandleRemove(AuraEffect const *, AuraEffectHandleModes)
Definition: hallows_end.cpp:96
bool Validate(SpellInfo const *) override
Definition: hallows_end.cpp:81
void Register() override
Definition: hallows_end.cpp:72
bool Validate(SpellInfo const *) override
Definition: hallows_end.cpp:62
void HandleDummy(SpellEffIndex)
Definition: hallows_end.cpp:67
bool Validate(SpellInfo const *) override
void HandleScript(SpellEffIndex)
void Register() override
bool Validate(SpellInfo const *) override
void HandleScript(SpellEffIndex)
void HandleScript(SpellEffIndex)
bool Validate(SpellInfo const *) override
void Register() override
bool Validate(SpellInfo const *) override
void HandleAfterApply(AuraEffect const *aurEff, AuraEffectHandleModes)
static constexpr std::array< uint32, 5 > ChildrensCustomeSpells
void HandlePeriodic(AuraEffect const *aurEff)
bool Validate(SpellInfo const *) override
void HandleProc(AuraEffect *, ProcEventInfo &eventInfo)
bool Validate(SpellInfo const *) override
TrickSpells
@ SPELL_SKELETON_COSTUME
@ SPELL_LEPER_GNOME_COSTUME_MALE
@ SPELL_NINJA_COSTUME_MALE
@ SPELL_TRICK_BUFF
@ SPELL_NINJA_COSTUME_FEMALE
@ SPELL_GHOST_COSTUME_FEMALE
@ SPELL_PIRATE_COSTUME_MALE
@ SPELL_PIRATE_COSTUME_FEMALE
@ SPELL_LEPER_GNOME_COSTUME_FEMALE
@ SPELL_GHOST_COSTUME_MALE
HallowsEndChildrensCustomeSpells
Definition: hallows_end.cpp:45
@ SPELL_HALLOWS_END_SCARY_PUMPKIN_MASK
Definition: hallows_end.cpp:48
@ SPELL_HALLOWS_END_FANCY_TOP_HAT
Definition: hallows_end.cpp:50
@ SPELL_HALLOWS_END_SCARY_TIKI_MASK
Definition: hallows_end.cpp:46
@ SPELL_HALLOWS_END_SCARY_WITCH_HAT
Definition: hallows_end.cpp:47
@ SPELL_HALLOWS_END_SCARY_TIKI_MASK_2
Definition: hallows_end.cpp:49
HallowendData
@ SPELL_HALLOWED_WAND_NINJA
@ SPELL_HALLOWED_WAND_WISP
@ SPELL_HALLOWED_WAND_SKELETON
@ SPELL_HALLOWED_WAND_BAT
@ SPELL_HALLOWED_WAND_LEPER_GNOME
@ SPELL_HALLOWED_WAND_RANDOM
@ SPELL_HALLOWED_WAND_GHOST
@ SPELL_HALLOWED_WAND_PIRATE
HallowsEndMiscSpells
Definition: hallows_end.cpp:54
@ SPELL_HALLOWS_END_DUMMY_NUKE
Definition: hallows_end.cpp:55
@ SPELL_HALLOWS_END_DREAD_FERTILIZER
Definition: hallows_end.cpp:56
void AddSC_event_hallows_end()
HallowEndCandysSpells
Definition: hallows_end.cpp:27
@ SPELL_HALLOWS_END_CANDY_ORANGE_GIANT
Definition: hallows_end.cpp:28
@ SPELL_HALLOWS_END_CANDY_GHOST
Definition: hallows_end.cpp:31
@ SPELL_HALLOWS_END_CANDY_SKELETON
Definition: hallows_end.cpp:29
@ SPELL_HALLOWS_END_CANDY_MALE_DEFIAS_PIRATE
Definition: hallows_end.cpp:33
@ SPELL_HALLOWS_END_CANDY_PIRATE
Definition: hallows_end.cpp:30
@ SPELL_HALLOWS_END_CANDY_FEMALE_DEFIAS_PIRATE
Definition: hallows_end.cpp:32
TrickOrTreatSpells
@ SPELL_UPSET_TUMMY
@ SPELL_TRICKED_OR_TREATED
@ SPELL_TREAT
@ SPELL_TRICKY_TREAT_TRIGGER
@ SPELL_TRICK
@ SPELL_TRICKY_TREAT_SPEED
std::array< uint32, 4 > const CandysSpells
Definition: hallows_end.cpp:36
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition: Containers.h:109