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
34
35// 45724 - Braziers Hit!
37{
48
49 void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
50 {
51 Player* player = GetTarget()->ToPlayer();
52 if (!player)
53 return;
54
56 {
57 if (player->GetTeam() == ALLIANCE)
59 else if (player->GetTeam() == HORDE)
61 Remove();
62 }
63 }
64
69};
70
71// 45907 - Torch Target Picker
73{
74 bool Validate(SpellInfo const* /*spellInfo*/) override
75 {
77 }
78
79 void HandleScript(SpellEffIndex /*effIndex*/)
80 {
81 Unit* target = GetHitUnit();
82 target->CastSpell(target, SPELL_TARGET_INDICATOR_COSMETIC, true);
83 target->CastSpell(target, SPELL_TARGET_INDICATOR, true);
84 }
85
90};
91
92// 46054 - Torch Toss (land)
94{
95 bool Validate(SpellInfo const* /*spellInfo*/) override
96 {
98 }
99
100 void HandleScript(SpellEffIndex /*effIndex*/)
101 {
103 }
104
109};
110
121
122// 29705, 29726, 29727 - Test Ribbon Pole Channel
124{
125 bool Validate(SpellInfo const* /*spellInfo*/) override
126 {
127 return ValidateSpellInfo(
128 {
133 });
134 }
135
140
141 void PeriodicTick(AuraEffect const* /*aurEff*/)
142 {
143 Unit* target = GetTarget();
144 target->CastSpell(target, SPELL_RIBBON_POLE_PERIODIC_VISUAL, true);
145
146 if (Aura* aur = target->GetAura(SPELL_RIBBON_DANCE))
147 {
148 aur->SetMaxDuration(std::min(3600000, aur->GetMaxDuration() + 180000));
149 aur->RefreshDuration();
150
151 if (aur->GetMaxDuration() == 3600000 && target->HasAura(SPELL_HAS_FULL_MIDSUMMER_SET))
152 target->CastSpell(target, SPELL_BURNING_HOT_POLE_DANCE, true);
153 }
154 else
155 target->CastSpell(target, SPELL_RIBBON_DANCE, true);
156 }
157
163};
164
165// 45406 - Holiday - Midsummer, Ribbon Pole Periodic Visual
190
209
210// 45819 - Throw Torch
212{
221
222 void HandleDummy(SpellEffIndex /*effIndex*/)
223 {
224 if (!GetExplTargetDest())
225 return;
226
227 WorldLocation spellDest = *GetExplTargetDest();
228 float distance = GetCaster()->GetExactDist2d(spellDest.GetPositionX(), spellDest.GetPositionY());
229
230 uint32 torchSpellID = 0;
231 uint32 torchShadowSpellID = 0;
232
233 if (distance <= 1.5f)
234 {
235 torchSpellID = SPELL_JUGGLE_TORCH_SELF;
236 torchShadowSpellID = SPELL_JUGGLE_TORCH_SHADOW_SELF;
237 spellDest = GetCaster()->GetWorldLocation();
238 }
239 else if (distance <= 10.0f)
240 {
241 torchSpellID = SPELL_JUGGLE_TORCH_SLOW;
242 torchShadowSpellID = SPELL_JUGGLE_TORCH_SHADOW_SLOW;
243 }
244 else if (distance <= 20.0f)
245 {
246 torchSpellID = SPELL_JUGGLE_TORCH_MEDIUM;
247 torchShadowSpellID = SPELL_JUGGLE_TORCH_SHADOW_MEDIUM;
248 }
249 else
250 {
251 torchSpellID = SPELL_JUGGLE_TORCH_FAST;
252 torchShadowSpellID = SPELL_JUGGLE_TORCH_SHADOW_FAST;
253 }
254
255 GetCaster()->CastSpell(spellDest, torchSpellID);
256 GetCaster()->CastSpell(spellDest, torchShadowSpellID);
257 }
258
263};
264
265// 45644 - Juggle Torch (Catch)
267{
268 bool Validate(SpellInfo const* /*spellInfo*/) override
269 {
271 }
272
273 void HandleDummy(SpellEffIndex /*effIndex*/)
274 {
275 Player* player = GetHitPlayer();
276 if (!player)
277 return;
278
280 player->CastSpell(player, SPELL_GIVE_TORCH);
281 }
282
287};
288
299
300// 46747 - Fling torch
302{
303 bool Validate(SpellInfo const* /*spellInfo*/) override
304 {
306 }
307
308 void HandleDummy(SpellEffIndex /*effIndex*/)
309 {
310 Position dest = GetCaster()->GetFirstCollisionPosition(30.0f, rand_norm() * static_cast<float>(2 * M_PI));
313 }
314
319};
320
321// 45669 - Fling Torch
323{
324 bool Validate(SpellInfo const* /*spellInfo*/) override
325 {
327 }
328
330 {
331 if (Position const* pos = GetHitDest())
332 {
333 if (GetCaster()->GetExactDist2d(pos) > 3.0f)
334 {
335 PreventHitEffect(effIndex);
338 }
339 }
340 }
341
346};
347
348// 45671 - Juggle Torch (Catch, Quest)
350{
361
363 {
364 Player* player = GetHitPlayer();
365 if (!player)
366 return;
367
368 if (!GetExplTargetDest())
369 return;
370
371 // Only the caster can catch the torch
372 if (player->GetGUID() != GetCaster()->GetGUID())
373 return;
374
375 uint8 requiredCatches = 0;
376 // Number of required catches depends on quest - 4 for the normal quest, 10 for the daily version
378 requiredCatches = 3;
380 requiredCatches = 9;
381
382 // Used quest item without being on quest - do nothing
383 if (requiredCatches == 0)
384 return;
385
386 if (player->GetAuraCount(SPELL_TORCHES_CAUGHT) >= requiredCatches)
387 {
391 }
392 else
393 {
394 Position dest = player->GetFirstCollisionPosition(15.0f, rand_norm() * static_cast<float>(2 * M_PI));
395 player->CastSpell(player, SPELL_TORCHES_CAUGHT);
396 player->CastSpell(dest, SPELL_FLING_TORCH_TRIGGERED, true);
397 player->CastSpell(dest, SPELL_FLING_TORCH_SHADOW);
398 }
399 }
400
405};
406
407// 45676 - Juggle Torch (Quest, Missed)
409{
410 void FilterTargets(std::list<WorldObject*>& targets)
411 {
412 // This spell only hits the caster
413 targets.remove_if([this](WorldObject* obj)
414 {
415 return obj->GetGUID() != GetCaster()->GetGUID();
416 });
417 }
418
424};
425
#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:153
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:150
float rand_norm()
Definition Random.cpp:75
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ EFFECT_2
@ TARGET_UNIT_DEST_AREA_ENTRY
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_EFFECT_TRIGGER_MISSILE
@ ALLIANCE
@ HORDE
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAPPLY
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
@ 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
Player * ToPlayer()
Definition Object.h:126
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition Player.cpp:15962
Team GetTeam() const
Definition Player.h:2423
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:635
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3828
uint32 GetAuraCount(uint32 spellId) const
Definition Unit.cpp:4788
Aura * GetAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4700
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition Unit.cpp:4804
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
constexpr WorldLocation GetWorldLocation() const
Definition Position.h:211
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
Position GetFirstCollisionPosition(float dist, float angle)
Definition Object.cpp:2762
bool Validate(SpellInfo const *) override
Definition midsummer.cpp:38
void HandleEffectApply(AuraEffect const *, AuraEffectHandleModes)
Definition midsummer.cpp:49
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
bool Validate(SpellInfo const *) override
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
Definition midsummer.cpp:74
bool Validate(SpellInfo const *) override
Definition midsummer.cpp:95
void HandleScript(SpellEffIndex)
TorchSpells
Definition midsummer.cpp:25
@ SPELL_TARGET_INDICATOR
Definition midsummer.cpp:31
@ SPELL_BRAZIERS_HIT
Definition midsummer.cpp:32
@ SPELL_TARGET_INDICATOR_COSMETIC
Definition midsummer.cpp:30
@ SPELL_TORCH_TOSSING_TRAINING_SUCCESS_ALLIANCE
Definition midsummer.cpp:28
@ SPELL_TORCH_TOSSING_TRAINING
Definition midsummer.cpp:26
@ SPELL_TORCH_TOSSING_TRAINING_SUCCESS_HORDE
Definition midsummer.cpp:29
@ 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
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
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