Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
spell_holiday.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6/*
7 * Spells used in holidays/game events that do not fit any other category.
8 * Ordered alphabetically using scriptname.
9 * Scriptnames in this file should be prefixed with "spell_#holidayname_".
10 */
11
12#include "Player.h"
13#include "ScriptMgr.h"
14#include "ScriptedCreature.h"
15#include "SpellScript.h"
16#include "SpellAuraEffects.h"
17#include "GridNotifiers.h"
18#include "GridNotifiersImpl.h"
19#include "CellImpl.h"
20
21// 45102 Romantic Picnic
23{
24 SPELL_BASKET_CHECK = 45119, // Holiday - Valentine - Romantic Picnic Near Basket Check
25 SPELL_MEAL_PERIODIC = 45103, // Holiday - Valentine - Romantic Picnic Meal Periodic - effect dummy
26 SPELL_MEAL_EAT_VISUAL = 45120, // Holiday - Valentine - Romantic Picnic Meal Eat Visual
27 //SPELL_MEAL_PARTICLE = 45114, // Holiday - Valentine - Romantic Picnic Meal Particle - unused
28 SPELL_DRINK_VISUAL = 45121, // Holiday - Valentine - Romantic Picnic Drink Visual
29 SPELL_ROMANTIC_PICNIC_ACHIEV = 45123, // Romantic Picnic periodic = 5000
30};
31
33{
34public:
35 spell_love_is_in_the_air_romantic_picnic() : SpellScriptLoader("spell_love_is_in_the_air_romantic_picnic") { }
36
38 {
40
41 void OnApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
42 {
43 Unit* target = GetTarget();
45 target->CastSpell(target, SPELL_MEAL_PERIODIC, false);
46 }
47
48 void OnPeriodic(AuraEffect const* /*aurEff*/)
49 {
50 // Every 5 seconds
51 Unit* target = GetTarget();
52 Unit* caster = GetCaster();
53
54 // If our player is no longer sit, remove all auras
55 if (target->getStandState() != UNIT_STAND_STATE_SIT)
56 {
58 target->RemoveAura(GetAura());
59 return;
60 }
61
62 target->CastSpell(target, SPELL_BASKET_CHECK, false); // unknown use, it targets Romantic Basket
64
65 bool foundSomeone = false;
66 // For nearby players, check if they have the same aura. If so, cast Romantic Picnic (45123)
67 // required by achievement and "hearts" visual
68 std::list<Player*> playerList;
71 target->VisitNearbyWorldObject(INTERACTION_DISTANCE * 2, searcher);
72 for (std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
73 {
74 if ((*itr) != target && (*itr)->HasAura(GetId())) // && (*itr)->getStandState() == UNIT_STAND_STATE_SIT)
75 {
76 if (caster)
77 {
78 caster->CastSpell(*itr, SPELL_ROMANTIC_PICNIC_ACHIEV, true);
79 caster->CastSpell(target, SPELL_ROMANTIC_PICNIC_ACHIEV, true);
80 }
81 foundSomeone = true;
82 // break;
83 }
84 }
85
86 if (!foundSomeone && target->HasAura(SPELL_ROMANTIC_PICNIC_ACHIEV))
88 }
89
95 };
96
101};
102
103// 24750 Trick
117
119{
120public:
121 spell_hallow_end_trick() : SpellScriptLoader("spell_hallow_end_trick") { }
122
124 {
126
127 bool Validate(SpellInfo const* /*spell*/) OVERRIDE
128 {
131 || !sSpellMgr->GetSpellInfo(SPELL_SKELETON_COSTUME) || !sSpellMgr->GetSpellInfo(SPELL_GHOST_COSTUME_MALE) || !sSpellMgr->GetSpellInfo(SPELL_GHOST_COSTUME_FEMALE) || !sSpellMgr->GetSpellInfo(SPELL_TRICK_BUFF))
132 return false;
133 return true;
134 }
135
136 void HandleScript(SpellEffIndex /*effIndex*/)
137 {
138 Unit* caster = GetCaster();
139 if (Player* target = GetHitPlayer())
140 {
141 uint8 gender = target->getGender();
142 uint32 spellId = SPELL_TRICK_BUFF;
143 switch (std::rand() % 5)
144 {
145 case 1:
147 break;
148 case 2:
150 break;
151 case 3:
153 break;
154 case 4:
156 break;
157 case 5:
158 spellId = SPELL_SKELETON_COSTUME;
159 break;
160 default:
161 break;
162 }
163
164 caster->CastSpell(target, spellId, true);
165 }
166 }
167
172 };
173
178};
179
180// 24751 Trick or Treat
190
192{
193public:
194 spell_hallow_end_trick_or_treat() : SpellScriptLoader("spell_hallow_end_trick_or_treat") { }
195
197 {
199
200 bool Validate(SpellInfo const* /*spell*/) OVERRIDE
201 {
202 if (!sSpellMgr->GetSpellInfo(SPELL_TRICK) || !sSpellMgr->GetSpellInfo(SPELL_TREAT) || !sSpellMgr->GetSpellInfo(SPELL_TRICKED_OR_TREATED))
203 return false;
204 return true;
205 }
206
207 void HandleScript(SpellEffIndex /*effIndex*/)
208 {
209 Unit* caster = GetCaster();
210 if (Player* target = GetHitPlayer())
211 {
212 caster->CastSpell(target, roll_chance_i(50) ? SPELL_TRICK : SPELL_TREAT, true);
213 caster->CastSpell(target, SPELL_TRICKED_OR_TREATED, true);
214 }
215 }
216
221 };
222
227};
228
230{
231public:
232 spell_hallow_end_tricky_treat() : SpellScriptLoader("spell_hallow_end_tricky_treat") { }
233
235 {
237
238 bool Validate(SpellInfo const* /*spell*/) OVERRIDE
239 {
240 if (!sSpellMgr->GetSpellInfo(SPELL_TRICKY_TREAT_SPEED))
241 return false;
242 if (!sSpellMgr->GetSpellInfo(SPELL_TRICKY_TREAT_TRIGGER))
243 return false;
244 if (!sSpellMgr->GetSpellInfo(SPELL_UPSET_TUMMY))
245 return false;
246 return true;
247 }
248
249 void HandleScript(SpellEffIndex /*effIndex*/)
250 {
251 Unit* caster = GetCaster();
253 caster->CastSpell(caster, SPELL_UPSET_TUMMY, true);
254 }
255
260 };
261
266};
267
274
276{
277public:
278 spell_winter_veil_mistletoe() : SpellScriptLoader("spell_winter_veil_mistletoe") { }
279
281 {
283
284 bool Validate(SpellInfo const* /*spell*/) OVERRIDE
285 {
286 if (!sSpellMgr->GetSpellInfo(SPELL_CREATE_MISTLETOE) ||
287 !sSpellMgr->GetSpellInfo(SPELL_CREATE_HOLLY) ||
288 !sSpellMgr->GetSpellInfo(SPELL_CREATE_SNOWFLAKES))
289 return false;
290 return true;
291 }
292
293 void HandleScript(SpellEffIndex /*effIndex*/)
294 {
295 if (Player* target = GetHitPlayer())
296 {
298 GetCaster()->CastSpell(target, spellId, true);
299 }
300 }
301
306 };
307
312};
313
314// 26275 - PX-238 Winter Wondervolt TRAP
322
324{
325public:
326 spell_winter_veil_px_238_winter_wondervolt() : SpellScriptLoader("spell_winter_veil_px_238_winter_wondervolt") { }
327
329 {
331
332 bool Validate(SpellInfo const* /*spellInfo*/) OVERRIDE
333 {
338 return false;
339 return true;
340 }
341
343 {
344 PreventHitDefaultEffect(effIndex);
345
346 uint32 const spells[4] =
347 {
352 };
353
354 if (Unit* target = GetHitUnit())
355 {
356 for (uint8 i = 0; i < 4; ++i)
357 if (target->HasAura(spells[i]))
358 return;
359
360 target->CastSpell(target, spells[std::rand() % 3], true);
361 }
362 }
363
368 };
369
374};
375
377{
378 // Love is in the Air
380 // Hallow's End
384 // Winter Veil
387}
const T & RAND(const T &v1, const T &v2)
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
#define INTERACTION_DISTANCE
Definition Object.h:21
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_AURA_PERIODIC_DUMMY
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
#define sSpellMgr
Definition SpellMgr.h:744
#define SpellEffectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
@ UNIT_STAND_STATE_SIT
Definition Unit.h:163
bool roll_chance_i(int chance)
Definition Util.h:89
HookList< EffectPeriodicHandler > OnEffectPeriodic
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetCaster() const
Aura * GetAura() const
Unit * GetTarget() const
uint32 GetId() const
Player * GetHitPlayer()
void PreventHitDefaultEffect(SpellEffIndex effIndex)
HookList< EffectHandler > OnEffectHitTarget
Unit * GetHitUnit()
Unit * GetCaster()
SpellScriptLoader(const char *name)
Definition Unit.h:1367
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
bool HasAura(uint32 spellId, uint64 casterGUID=0, uint64 itemCasterGUID=0, uint32 reqEffMask=0) const
uint32 GetAuraCount(uint32 spellId) const
uint8 getStandState() const
Definition Unit.h:1724
void SetStandState(uint8 state)
Definition Unit.cpp:5902
void VisitNearbyWorldObject(float const &radius, NOTIFIER &notifier) const
Definition Object.h:784
PrepareSpellScript(spell_hallow_end_trick_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
SpellScript * GetSpellScript() const OVERRIDE
SpellScript * GetSpellScript() const OVERRIDE
AuraScript * GetAuraScript() const OVERRIDE
PrepareSpellScript(spell_winter_veil_mistletoe_SpellScript)
SpellScript * GetSpellScript() const OVERRIDE
SpellScript * GetSpellScript() 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
PX238WinterWondervolt
@ SPELL_PX_238_WINTER_WONDERVOLT_TRANSFORM_1
@ SPELL_PX_238_WINTER_WONDERVOLT_TRANSFORM_2
@ SPELL_PX_238_WINTER_WONDERVOLT_TRANSFORM_3
@ SPELL_PX_238_WINTER_WONDERVOLT_TRANSFORM_4
SpellsPicnic
@ SPELL_BASKET_CHECK
@ SPELL_ROMANTIC_PICNIC_ACHIEV
@ SPELL_MEAL_PERIODIC
@ SPELL_DRINK_VISUAL
@ SPELL_MEAL_EAT_VISUAL
Mistletoe
@ SPELL_CREATE_HOLLY
@ SPELL_CREATE_SNOWFLAKES
@ SPELL_CREATE_MISTLETOE
TrickOrTreatSpells
@ SPELL_UPSET_TUMMY
@ SPELL_TRICKED_OR_TREATED
@ SPELL_TREAT
@ SPELL_TRICKY_TREAT_TRIGGER
@ SPELL_TRICK
@ SPELL_TRICKY_TREAT_SPEED
void AddSC_holiday_spell_scripts()