TrinityCore
Loading...
Searching...
No Matches
midsummer.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 "CreatureAIImpl.h"
20#include "Player.h"
21#include "SpellAuraEffects.h"
22#include "SpellScript.h"
23
36
37// 45724 - Braziers Hit!
69
70// 46074 - Remove Torches
91
92// 45716 - Torch Tossing Training
93// 46630 - Torch Tossing Practice
122
123// 45907 - Torch Target Picker
125{
126 bool Validate(SpellInfo const* /*spellInfo*/) override
127 {
129 }
130
131 void HandleScript(SpellEffIndex /*effIndex*/)
132 {
133 Unit* target = GetHitUnit();
134 target->CastSpell(target, SPELL_TARGET_INDICATOR_COSMETIC, true);
135 target->CastSpell(target, SPELL_TARGET_INDICATOR, true);
136 }
137
142};
143
144// 46054 - Torch Toss (land)
146{
147 bool Validate(SpellInfo const* /*spellInfo*/) override
148 {
150 }
151
152 void HandleScript(SpellEffIndex /*effIndex*/)
153 {
155 }
156
161};
162
173
174// 29705, 29726, 29727 - Test Ribbon Pole Channel
176{
177 bool Validate(SpellInfo const* /*spellInfo*/) override
178 {
179 return ValidateSpellInfo(
180 {
185 });
186 }
187
192
193 void PeriodicTick(AuraEffect const* /*aurEff*/)
194 {
195 Unit* target = GetTarget();
196 target->CastSpell(target, SPELL_RIBBON_POLE_PERIODIC_VISUAL, true);
197
198 if (Aura* aur = target->GetAura(SPELL_RIBBON_DANCE))
199 {
200 aur->SetMaxDuration(std::min(3600000, aur->GetMaxDuration() + 180000));
201 aur->RefreshDuration();
202
203 if (aur->GetMaxDuration() == 3600000 && target->HasAura(SPELL_HAS_FULL_MIDSUMMER_SET))
204 target->CastSpell(target, SPELL_BURNING_HOT_POLE_DANCE, true);
205 }
206 else
207 target->CastSpell(target, SPELL_RIBBON_DANCE, true);
208 }
209
215};
216
217// 45406 - Holiday - Midsummer, Ribbon Pole Periodic Visual
242
261
262// 45819 - Throw Torch
264{
273
274 void HandleDummy(SpellEffIndex /*effIndex*/)
275 {
276 if (!GetExplTargetDest())
277 return;
278
279 WorldLocation spellDest = *GetExplTargetDest();
280 float distance = GetCaster()->GetExactDist2d(spellDest.GetPositionX(), spellDest.GetPositionY());
281
282 uint32 torchSpellID = 0;
283 uint32 torchShadowSpellID = 0;
284
285 if (distance <= 1.5f)
286 {
287 torchSpellID = SPELL_JUGGLE_TORCH_SELF;
288 torchShadowSpellID = SPELL_JUGGLE_TORCH_SHADOW_SELF;
289 spellDest = GetCaster()->GetWorldLocation();
290 }
291 else if (distance <= 10.0f)
292 {
293 torchSpellID = SPELL_JUGGLE_TORCH_SLOW;
294 torchShadowSpellID = SPELL_JUGGLE_TORCH_SHADOW_SLOW;
295 }
296 else if (distance <= 20.0f)
297 {
298 torchSpellID = SPELL_JUGGLE_TORCH_MEDIUM;
299 torchShadowSpellID = SPELL_JUGGLE_TORCH_SHADOW_MEDIUM;
300 }
301 else
302 {
303 torchSpellID = SPELL_JUGGLE_TORCH_FAST;
304 torchShadowSpellID = SPELL_JUGGLE_TORCH_SHADOW_FAST;
305 }
306
307 GetCaster()->CastSpell(spellDest, torchSpellID);
308 GetCaster()->CastSpell(spellDest, torchShadowSpellID);
309 }
310
315};
316
317// 45644 - Juggle Torch (Catch)
319{
320 bool Validate(SpellInfo const* /*spellInfo*/) override
321 {
323 }
324
325 void HandleDummy(SpellEffIndex /*effIndex*/)
326 {
327 Player* player = GetHitPlayer();
328 if (!player)
329 return;
330
332 player->CastSpell(player, SPELL_GIVE_TORCH);
333 }
334
339};
340
351
352// 46747 - Fling torch
354{
355 bool Validate(SpellInfo const* /*spellInfo*/) override
356 {
358 }
359
360 void HandleDummy(SpellEffIndex /*effIndex*/)
361 {
362 Position dest = GetCaster()->GetFirstCollisionPosition(30.0f, rand_norm() * static_cast<float>(2 * M_PI));
365 }
366
371};
372
373// 45669 - Fling Torch
375{
376 bool Validate(SpellInfo const* /*spellInfo*/) override
377 {
379 }
380
382 {
383 if (Position const* pos = GetHitDest())
384 {
385 if (GetCaster()->GetExactDist2d(pos) > 3.0f)
386 {
387 PreventHitEffect(effIndex);
390 }
391 }
392 }
393
398};
399
400// 45671 - Juggle Torch (Catch, Quest)
402{
413
415 {
416 Player* player = GetHitPlayer();
417 if (!player)
418 return;
419
420 if (!GetExplTargetDest())
421 return;
422
423 // Only the caster can catch the torch
424 if (player->GetGUID() != GetCaster()->GetGUID())
425 return;
426
427 uint8 requiredCatches = 0;
428 // Number of required catches depends on quest - 4 for the normal quest, 10 for the daily version
430 requiredCatches = 3;
432 requiredCatches = 9;
433
434 // Used quest item without being on quest - do nothing
435 if (requiredCatches == 0)
436 return;
437
438 if (player->GetAuraCount(SPELL_TORCHES_CAUGHT) >= requiredCatches)
439 {
443 }
444 else
445 {
446 Position dest = player->GetFirstCollisionPosition(15.0f, rand_norm() * static_cast<float>(2 * M_PI));
447 player->CastSpell(player, SPELL_TORCHES_CAUGHT);
448 player->CastSpell(dest, SPELL_FLING_TORCH_TRIGGERED, true);
449 player->CastSpell(dest, SPELL_FLING_TORCH_SHADOW);
450 }
451 }
452
457};
458
459// 45676 - Juggle Torch (Quest, Missed)
461{
462 void FilterTargets(std::list<WorldObject*>& targets)
463 {
464 // This spell only hits the caster
465 targets.remove_if([this](WorldObject* obj)
466 {
467 return obj->GetGUID() != GetCaster()->GetGUID();
468 });
469 }
470
476};
477
489
490// 29126 - Cleansing Flames
491// 29137 - Cleansing Flames
492// 29135 - Cleansing Flames
493// 29136 - Cleansing Flames
494// 29138 - Cleansing Flames
495// 29139 - Cleansing Flames
496// 46672 - Cleansing Flames
497// 46671 - Cleansing Flames
499{
500 bool Validate(SpellInfo const* /*spellInfo*/) override
501 {
503 }
504
505 void HandleDummy(SpellEffIndex /*effIndex*/)
506 {
508 }
509
514
516
517public:
518 explicit spell_midsummer_cleansing_flames(CleansingFlames triggeredSpell) : _triggeredSpell(triggeredSpell) { }
519};
520
527
528// 45458 - Holiday - Midsummer, Stamp Out Bonfire, Quest Complete
546
547// 45443 - Stamp Out Bonfire, Event
549{
550 bool Validate(SpellInfo const* /*spellInfo*/) override
551 {
553 }
554
555 void HandleScript(SpellEffIndex /*effIndex*/)
556 {
557 Unit* caster = GetCaster();
558 caster->CastSpell(caster, SPELL_STAMP_OUT_BONFIRE_ART_KIT, true);
559 caster->CastSpell(caster, SPELL_STAMP_OUT_BONFIRE_DUMMY, true);
560 }
561
566};
567
569{
593}
#define M_PI
Definition Common.h:118
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
@ QUEST_STATUS_REWARDED
Definition QuestDef.h:149
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:146
float rand_norm()
Definition Random.cpp:76
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
#define RegisterSpellScriptWithArgs(spell_script, script_name,...)
Definition ScriptMgr.h:1382
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ EFFECT_2
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_EFFECT_TRIGGER_MISSILE
@ TARGET_UNIT_DEST_AREA_ENTRY
@ ALLIANCE
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAPPLY
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
@ SPELL_AURA_DETECT_AMORE
@ SPELL_AURA_PERIODIC_DUMMY
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
#define AuraEffectRemoveFn(F, I, N, M)
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectPeriodicHandler > OnEffectPeriodic
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetTarget() const
uint8 GetStackAmount() const
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition Player.cpp:15929
Team GetTeam() const
Definition Player.h:2406
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
WorldLocation * GetHitDest() const
Player * GetHitPlayer() const
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHit
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
void PreventHitEffect(SpellEffIndex effIndex)
WorldLocation const * GetExplTargetDest() const
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition Unit.h:647
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3846
uint32 GetAuraCount(uint32 spellId) const
Definition Unit.cpp:4806
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4718
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4822
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3992
constexpr WorldLocation GetWorldLocation() const
Definition Position.h:211
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
Position GetFirstCollisionPosition(float dist, float angle)
Definition Object.cpp:2767
bool Validate(SpellInfo const *) override
Definition midsummer.cpp:40
void HandleEffectApply(AuraEffect const *, AuraEffectHandleModes)
Definition midsummer.cpp:52
spell_midsummer_cleansing_flames(CleansingFlames triggeredSpell)
void HandleDummy(SpellEffIndex)
bool Validate(SpellInfo const *) override
void HandleScriptEffect(SpellEffIndex)
bool Validate(SpellInfo const *) override
void FilterTargets(std::list< WorldObject * > &targets)
void HandleTriggerMissile(SpellEffIndex effIndex)
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *) override
void HandleDummy(SpellEffIndex)
void HandleDummy(SpellEffIndex)
bool Validate(SpellInfo const *) override
void HandleDummy(SpellEffIndex)
Definition midsummer.cpp:78
bool Validate(SpellInfo const *) override
Definition midsummer.cpp:73
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *) override
void AfterApply(AuraEffect const *, AuraEffectHandleModes)
void PeriodicTick(AuraEffect const *)
bool Validate(SpellInfo const *) override
void HandleRemove(AuraEffect const *, AuraEffectHandleModes)
void HandleDummy(SpellEffIndex)
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *) override
bool Validate(SpellInfo const *) override
void HandleScript(SpellEffIndex)
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
bool Validate(SpellInfo const *) override
Definition midsummer.cpp:96
void AfterApply(AuraEffect const *, AuraEffectHandleModes)
TorchSpells
Definition midsummer.cpp:25
@ SPELL_TORCH_TOSSING_TRAINING_SUCCESS_2
Definition midsummer.cpp:29
@ SPELL_TARGET_INDICATOR
Definition midsummer.cpp:32
@ SPELL_BRAZIERS_HIT
Definition midsummer.cpp:33
@ SPELL_TARGET_INDICATOR_COSMETIC
Definition midsummer.cpp:31
@ SPELL_REMOVE_TORCHES
Definition midsummer.cpp:30
@ SPELL_TORCH_TOSSING_TRAINING
Definition midsummer.cpp:26
@ SPELL_TORCH_TOSSING_TRAINING_SUCCESS_1
Definition midsummer.cpp:28
@ SPELL_TARGET_DETECT_INVISIBILITY
Definition midsummer.cpp:34
@ SPELL_TORCH_TOSSING_PRACTICE
Definition midsummer.cpp:27
FlingTorch
@ SPELL_TORCHES_CAUGHT
@ SPELL_JUGGLE_TORCH_MISSED
@ SPELL_TORCH_CATCHING_SUCCESS_ALLIANCE
@ SPELL_FLING_TORCH_SHADOW
@ SPELL_TORCH_CATCHING_REMOVE_TORCHES
@ SPELL_TORCH_CATCHING_SUCCESS_HORDE
@ SPELL_FLING_TORCH_TRIGGERED
StampOutBonfire
@ SPELL_STAMP_OUT_BONFIRE_DUMMY
@ SPELL_STAMP_OUT_BONFIRE_ART_KIT
@ SPELL_STAMP_OUT_BONFIRE_EVENT
void AddSC_event_midsummer()
RibbonPoleData
@ SPELL_TEST_RIBBON_POLE_2
@ SPELL_RIBBON_POLE_PERIODIC_VISUAL
@ SPELL_BURNING_HOT_POLE_DANCE
@ SPELL_HAS_FULL_MIDSUMMER_SET
@ SPELL_RIBBON_DANCE
@ SPELL_TEST_RIBBON_POLE_1
@ SPELL_TEST_RIBBON_POLE_3
JugglingTorch
@ SPELL_JUGGLE_TORCH_SHADOW_SLOW
@ QUEST_MORE_TORCH_CATCHING_A
@ QUEST_TORCH_CATCHING_A
@ QUEST_TORCH_CATCHING_H
@ SPELL_JUGGLE_TORCH_SELF
@ SPELL_GIVE_TORCH
@ SPELL_JUGGLE_TORCH_SHADOW_FAST
@ SPELL_JUGGLE_TORCH_SLOW
@ SPELL_JUGGLE_TORCH_SHADOW_MEDIUM
@ SPELL_JUGGLE_TORCH_SHADOW_SELF
@ QUEST_MORE_TORCH_CATCHING_H
@ SPELL_JUGGLE_TORCH_FAST
@ SPELL_JUGGLE_TORCH_MEDIUM
CleansingFlames
@ SPELL_CREATE_FLAME_OF_DARNASSUS
@ SPELL_CREATE_FLAME_OF_THE_EXODAR
@ SPELL_CREATE_FLAME_OF_IRONFORGE
@ SPELL_CREATE_FLAME_OF_STORMWIND
@ SPELL_CREATE_FLAME_OF_THE_UNDERCITY
@ SPELL_CREATE_FLAME_OF_ORGRIMMAR
@ SPELL_CREATE_FLAME_OF_THUNDER_BLUFF
@ SPELL_CREATE_FLAME_OF_SILVERMOON
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
float GetExactDist2d(const float x, const float y) const
Definition Position.h:117