AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
spell_midsummer_fling_torch Class Reference
Inheritance diagram for spell_midsummer_fling_torch:
SpellScript _SpellScript

Private Member Functions

 PrepareSpellScript (spell_midsummer_fling_torch)
 
bool Validate (SpellInfo const *) override
 
bool Load () override
 
SpellCastResult CheckCast ()
 
void ThrowNextTorch (Unit *caster)
 
void HandleFinish ()
 
void HandleScript (SpellEffIndex effIndex)
 
void Register () override
 

Private Attributes

bool handled
 
std::list< Creature * > _crList
 

Additional Inherited Members

- Public Member Functions inherited from SpellScript
bool _Validate (SpellInfo const *entry) override
 
bool _Load (Spell *spell)
 
void _InitHit ()
 
bool _IsEffectPrevented (SpellEffIndex effIndex)
 
bool _IsDefaultEffectPrevented (SpellEffIndex effIndex)
 
void _PrepareScriptCall (SpellScriptHookType hookType)
 
void _FinishScriptCall ()
 
bool IsInCheckCastHook () const
 
bool IsInTargetHook () const
 
bool IsInHitPhase () const
 
bool IsInEffectHook () const
 
UnitGetCaster ()
 
UnitGetOriginalCaster ()
 
SpellInfo const * GetSpellInfo ()
 
SpellValue const * GetSpellValue ()
 
WorldLocation const * GetExplTargetDest ()
 
void SetExplTargetDest (WorldLocation &loc)
 
WorldObjectGetExplTargetWorldObject ()
 
UnitGetExplTargetUnit ()
 
GameObjectGetExplTargetGObj ()
 
ItemGetExplTargetItem ()
 
UnitGetHitUnit ()
 
CreatureGetHitCreature ()
 
PlayerGetHitPlayer ()
 
ItemGetHitItem ()
 
GameObjectGetHitGObj ()
 
WorldLocationGetHitDest ()
 
int32 GetHitDamage ()
 
void SetHitDamage (int32 damage)
 
void PreventHitDamage ()
 
int32 GetHitHeal ()
 
void SetHitHeal (int32 heal)
 
void PreventHitHeal ()
 
SpellGetSpell ()
 
AuraGetHitAura ()
 
void PreventHitAura ()
 
void PreventHitEffect (SpellEffIndex effIndex)
 
void PreventHitDefaultEffect (SpellEffIndex effIndex)
 
int32 GetEffectValue () const
 
void SetEffectValue (int32 value)
 
ItemGetCastItem ()
 
void CreateItem (uint32 effIndex, uint32 itemId)
 
SpellInfo const * GetTriggeringSpell ()
 
void FinishCast (SpellCastResult result)
 
void Cancel ()
 
void SetCustomCastResultMessage (SpellCustomErrors result)
 
- Public Member Functions inherited from _SpellScript
 _SpellScript ()
 
virtual ~_SpellScript ()
 
virtual void _Register ()
 
virtual void _Unload ()
 
virtual void _Init (std::string const *scriptname, uint32 spellId)
 
std::string const * _GetScriptName () const
 
virtual void Register ()=0
 
virtual bool Validate (SpellInfo const *)
 
virtual bool Load ()
 
virtual void Unload ()
 
- Static Public Member Functions inherited from _SpellScript
static bool ValidateSpellInfo (std::initializer_list< uint32 > spellIds)
 
template<class T >
static bool ValidateSpellInfo (T const &spellIds)
 
- Public Attributes inherited from SpellScript
HookList< CastHandlerBeforeCast
 
HookList< CastHandlerOnCast
 
HookList< CastHandlerAfterCast
 
HookList< CheckCastHandlerOnCheckCast
 
HookList< EffectHandlerOnEffectLaunch
 
HookList< EffectHandlerOnEffectLaunchTarget
 
HookList< EffectHandlerOnEffectHit
 
HookList< EffectHandlerOnEffectHitTarget
 
HookList< BeforeHitHandlerBeforeHit
 
HookList< HitHandlerOnHit
 
HookList< HitHandlerAfterHit
 
HookList< ObjectAreaTargetSelectHandlerOnObjectAreaTargetSelect
 
HookList< ObjectTargetSelectHandlerOnObjectTargetSelect
 
HookList< DestinationTargetSelectHandlerOnDestinationTargetSelect
 
virtual bool _Validate (SpellInfo const *entry)
 
- Protected Attributes inherited from _SpellScript
uint8 m_currentScriptState
 
std::string const * m_scriptName
 
uint32 m_scriptSpellId
 

Detailed Description

Member Function Documentation

◆ CheckCast()

SpellCastResult spell_midsummer_fling_torch::CheckCast ( )
inlineprivate
668 {
670 if (_crList.empty())
671 {
673 }
674
675 return SPELL_CAST_OK;
676 }
@ NPC_TORCH_TARGET
Definition: midsummer.cpp:632
@ SPELL_FAILED_NOT_HERE
Definition: SharedDefines.h:1009
@ SPELL_CAST_OK
Definition: SharedDefines.h:1138
void GetCreaturesWithEntryInRange(std::list< Creature * > &creatureList, float radius, uint32 entry)
Definition: Object.cpp:3040
Unit * GetCaster()
Definition: SpellScript.cpp:401
std::list< Creature * > _crList
Definition: midsummer.cpp:769

References _crList, SpellScript::GetCaster(), WorldObject::GetCreaturesWithEntryInRange(), NPC_TORCH_TARGET, SPELL_CAST_OK, and SPELL_FAILED_NOT_HERE.

Referenced by Register().

◆ HandleFinish()

void spell_midsummer_fling_torch::HandleFinish ( )
inlineprivate
708 {
709 Unit* caster = GetCaster();
710 if (!caster || !caster->ToPlayer()) // caster cant be null, but meh :p
711 return;
712
714 {
715 if (!handled)
716 if (const WorldLocation* loc = GetExplTargetDest())
717 {
718 caster->CastSpell(loc->GetPositionX(), loc->GetPositionY(), loc->GetPositionZ(), SPELL_MISSED_TORCH, true);
720 }
721 return;
722 }
723
724 ThrowNextTorch(caster);
725 }
@ SPELL_TORCH_COUNTER
Definition: midsummer.cpp:637
@ SPELL_FLING_TORCH_DUMMY
Definition: midsummer.cpp:635
@ SPELL_MISSED_TORCH
Definition: midsummer.cpp:636
Player * ToPlayer()
Definition: Object.h:195
Definition: Position.h:251
Definition: Unit.h:1302
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1169
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4855
WorldLocation const * GetExplTargetDest()
Definition: SpellScript.cpp:416
SpellInfo const * GetSpellInfo()
Definition: SpellScript.cpp:411
void ThrowNextTorch(Unit *caster)
Definition: midsummer.cpp:678
bool handled
Definition: midsummer.cpp:664

References Unit::CastSpell(), SpellScript::GetCaster(), SpellScript::GetExplTargetDest(), SpellScript::GetSpellInfo(), handled, Unit::RemoveAurasDueToSpell(), SPELL_FLING_TORCH_DUMMY, SPELL_MISSED_TORCH, SPELL_TORCH_COUNTER, ThrowNextTorch(), and Object::ToPlayer().

Referenced by Register().

◆ HandleScript()

void spell_midsummer_fling_torch::HandleScript ( SpellEffIndex  effIndex)
inlineprivate
728 {
729 PreventHitDefaultEffect(effIndex);
730 if (Player* target = GetHitPlayer())
731 {
732 if (target->GetGUID() != GetCaster()->GetGUID())
733 return;
734
735 handled = true;
736 if (Aura* aur = target->GetAura(SPELL_TORCH_COUNTER))
737 {
738 aur->ModStackAmount(1);
739 uint8 count = 4;
740 if (target->GetQuestStatus(target->GetTeamId() ? QUEST_MORE_TORCH_TOSS_H : QUEST_MORE_TORCH_TOSS_A) == QUEST_STATUS_INCOMPLETE) // More Torch Catching quests
741 count = 10;
742
743 if (aur->GetStackAmount() >= count)
744 {
745 //target->CastSpell(target, 46711, true); // Set Flag: all torch returning quests are complete
746 target->CastSpell(target, (target->GetTeamId() ? SPELL_TORCH_CATCH_SUCCESS_H : SPELL_TORCH_CATCH_SUCCESS_A), true); // Quest completion
747 aur->SetDuration(1);
748 return;
749 }
750 }
751 else
752 target->CastSpell(target, SPELL_TORCH_COUNTER, true);
753
755 }
756 }
std::uint8_t uint8
Definition: Define.h:110
@ QUEST_STATUS_INCOMPLETE
Definition: QuestDef.h:103
@ QUEST_MORE_TORCH_TOSS_H
Definition: midsummer.cpp:644
@ SPELL_TORCH_CATCH_SUCCESS_H
Definition: midsummer.cpp:640
@ SPELL_TORCH_CATCH_SUCCESS_A
Definition: midsummer.cpp:639
@ QUEST_MORE_TORCH_TOSS_A
Definition: midsummer.cpp:643
Definition: Player.h:1056
Definition: SpellAuras.h:87
Player * GetHitPlayer()
Definition: SpellScript.cpp:471
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Definition: SpellScript.cpp:590

References SpellScript::GetCaster(), SpellScript::GetHitPlayer(), handled, SpellScript::PreventHitDefaultEffect(), QUEST_MORE_TORCH_TOSS_A, QUEST_MORE_TORCH_TOSS_H, QUEST_STATUS_INCOMPLETE, SPELL_TORCH_CATCH_SUCCESS_A, SPELL_TORCH_CATCH_SUCCESS_H, SPELL_TORCH_COUNTER, and ThrowNextTorch().

Referenced by Register().

◆ Load()

bool spell_midsummer_fling_torch::Load ( )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

665{ handled = false; return true; }

References handled.

◆ PrepareSpellScript()

spell_midsummer_fling_torch::PrepareSpellScript ( spell_midsummer_fling_torch  )
private

◆ Register()

void spell_midsummer_fling_torch::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

759 {
763 {
765 }
766 }
#define SpellCheckCastFn(F)
Definition: SpellScript.h:329
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:337
#define SpellCastFn(F)
Definition: SpellScript.h:324
@ SPELL_JUGGLE_TORCH
Definition: midsummer.cpp:641
@ EFFECT_0
Definition: SharedDefines.h:31
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition: SharedDefines.h:855
uint32 m_scriptSpellId
Definition: SpellScript.h:107
HookList< CastHandler > AfterCast
Definition: SpellScript.h:323
HookList< CheckCastHandler > OnCheckCast
Definition: SpellScript.h:328
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:336
void HandleScript(SpellEffIndex effIndex)
Definition: midsummer.cpp:727
void HandleFinish()
Definition: midsummer.cpp:707
SpellCastResult CheckCast()
Definition: midsummer.cpp:667

References SpellScript::AfterCast, CheckCast(), EFFECT_0, HandleFinish(), HandleScript(), _SpellScript::m_scriptSpellId, SpellScript::OnCheckCast, SpellScript::OnEffectHitTarget, SPELL_EFFECT_SCRIPT_EFFECT, SPELL_JUGGLE_TORCH, SpellCastFn, SpellCheckCastFn, and SpellEffectFn.

◆ ThrowNextTorch()

void spell_midsummer_fling_torch::ThrowNextTorch ( Unit caster)
inlineprivate
679 {
680 uint8 rand = urand(0, _crList.size() - 1);
681 Position pos;
682 pos.Relocate(0.0f, 0.0f, 0.0f);
683 for (std::list<Creature*>::const_iterator itr = _crList.begin(); itr != _crList.end(); ++itr, --rand)
684 {
685 if (caster->GetDistance(*itr) < 5)
686 {
687 if (!rand)
688 rand++;
689 continue;
690 }
691
692 if (!rand)
693 {
694 pos.Relocate(*itr);
695 break;
696 }
697 }
698
699 // we have any pos
700 if (pos.GetPositionX())
701 {
702 caster->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SPELL_FLING_TORCH, true);
703 caster->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SPELL_TORCH_SHADOW, true);
704 }
705 }
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:44
@ SPELL_TORCH_SHADOW
Definition: midsummer.cpp:638
@ SPELL_FLING_TORCH
Definition: midsummer.cpp:634
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1245
Definition: Position.h:28
float GetPositionZ() const
Definition: Position.h:119
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
void Relocate(float x, float y)
Definition: Position.h:73

References _crList, Unit::CastSpell(), WorldObject::GetDistance(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Position::Relocate(), SPELL_FLING_TORCH, SPELL_TORCH_SHADOW, and urand().

Referenced by HandleFinish(), and HandleScript().

◆ Validate()

bool spell_midsummer_fling_torch::Validate ( SpellInfo const *  )
inlineoverrideprivatevirtual

Member Data Documentation

◆ _crList

std::list<Creature*> spell_midsummer_fling_torch::_crList
private

Referenced by CheckCast(), and ThrowNextTorch().

◆ handled

bool spell_midsummer_fling_torch::handled
private

Referenced by HandleFinish(), HandleScript(), and Load().