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
 
void ThrowNextTorch (Unit *caster)
 
void HandleFinish ()
 
void HandleScript (SpellEffIndex effIndex)
 
void Register () override
 

Private Attributes

bool handled
 

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
 
Unit * GetCaster ()
 
GameObject * GetGObjCaster ()
 
Unit * GetOriginalCaster ()
 
SpellInfo const * GetSpellInfo ()
 
SpellValue const * GetSpellValue ()
 
WorldLocation const * GetExplTargetDest ()
 
void SetExplTargetDest (WorldLocation &loc)
 
WorldObject * GetExplTargetWorldObject ()
 
Unit * GetExplTargetUnit ()
 
GameObject * GetExplTargetGObj ()
 
Item * GetExplTargetItem ()
 
Unit * GetHitUnit ()
 
Creature * GetHitCreature ()
 
Player * GetHitPlayer ()
 
Item * GetHitItem ()
 
GameObject * GetHitGObj ()
 
WorldLocation * GetHitDest ()
 
int32 GetHitDamage ()
 
void SetHitDamage (int32 damage)
 
void PreventHitDamage ()
 
int32 GetHitHeal ()
 
void SetHitHeal (int32 heal)
 
void PreventHitHeal ()
 
Spell * GetSpell ()
 
Aura * GetHitAura ()
 
void PreventHitAura ()
 
void PreventHitEffect (SpellEffIndex effIndex)
 
void PreventHitDefaultEffect (SpellEffIndex effIndex)
 
int32 GetEffectValue () const
 
void SetEffectValue (int32 value)
 
Item * GetCastItem ()
 
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 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< CastHandler > BeforeCast
 
HookList< CastHandler > OnCast
 
HookList< CastHandler > AfterCast
 
HookList< CheckCastHandler > OnCheckCast
 
HookList< EffectHandler > OnEffectLaunch
 
HookList< EffectHandler > OnEffectLaunchTarget
 
HookList< EffectHandler > OnEffectHit
 
HookList< EffectHandler > OnEffectHitTarget
 
HookList< BeforeHitHandler > BeforeHit
 
HookList< HitHandler > OnHit
 
HookList< HitHandler > AfterHit
 
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
 
HookList< ObjectTargetSelectHandler > OnObjectTargetSelect
 
HookList< DestinationTargetSelectHandler > OnDestinationTargetSelect
 
- Protected Attributes inherited from _SpellScript
uint8 m_currentScriptState
 
std::string const * m_scriptName
 
uint32 m_scriptSpellId
 

Detailed Description

Member Function Documentation

◆ HandleFinish()

void spell_midsummer_fling_torch::HandleFinish ( )
inlineprivate
1013 {
1014 Unit* caster = GetCaster();
1015 if (!caster || !caster->ToPlayer()) // caster cant be null, but meh :p
1016 return;
1017
1019 {
1020 if (!handled)
1021 if (WorldLocation const* loc = GetExplTargetDest())
1022 {
1023 caster->CastSpell(loc->GetPositionX(), loc->GetPositionY(), loc->GetPositionZ(), SPELL_MISSED_TORCH, true);
1025 }
1026 return;
1027 }
1028
1029 ThrowNextTorch(caster);
1030 }
Player * ToPlayer()
Definition Object.h:208
WorldLocation const * GetExplTargetDest()
Definition SpellScript.cpp:421
SpellInfo const * GetSpellInfo()
Definition SpellScript.cpp:416
Unit * GetCaster()
Definition SpellScript.cpp:401
Definition Unit.h:665
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:1372
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:4936
Definition Position.h:256
void ThrowNextTorch(Unit *caster)
Definition midsummer.cpp:987
bool handled
Definition midsummer.cpp:984
@ SPELL_TORCH_COUNTER
Definition midsummer.cpp:957
@ SPELL_FLING_TORCH_DUMMY
Definition midsummer.cpp:955
@ SPELL_MISSED_TORCH
Definition midsummer.cpp:956

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
1033 {
1034 PreventHitDefaultEffect(effIndex);
1035 if (Player* target = GetHitPlayer())
1036 {
1037 if (target->GetGUID() != GetCaster()->GetGUID())
1038 return;
1039
1040 handled = true;
1041 if (Aura* aur = target->GetAura(SPELL_TORCH_COUNTER))
1042 {
1043 aur->ModStackAmount(1);
1044 uint8 count = 4;
1045 if (target->GetQuestStatus(target->GetTeamId() ? QUEST_MORE_TORCH_TOSS_H : QUEST_MORE_TORCH_TOSS_A) == QUEST_STATUS_INCOMPLETE) // More Torch Catching quests
1046 count = 10;
1047
1048 if (aur->GetStackAmount() >= count)
1049 {
1050 //target->CastSpell(target, 46711, true); // Set Flag: all torch returning quests are complete
1051 target->CastSpell(target, (target->GetTeamId() ? SPELL_TORCH_CATCH_SUCCESS_H : SPELL_TORCH_CATCH_SUCCESS_A), true); // Quest completion
1052 aur->SetDuration(1);
1053 return;
1054 }
1055 }
1056 else
1057 target->CastSpell(target, SPELL_TORCH_COUNTER, true);
1058
1060 }
1061 }
std::uint8_t uint8
Definition Define.h:109
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:103
Definition SpellAuras.h:88
Definition Player.h:1086
Player * GetHitPlayer()
Definition SpellScript.cpp:476
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Definition SpellScript.cpp:595
@ QUEST_MORE_TORCH_TOSS_H
Definition midsummer.cpp:964
@ SPELL_TORCH_CATCH_SUCCESS_H
Definition midsummer.cpp:960
@ SPELL_TORCH_CATCH_SUCCESS_A
Definition midsummer.cpp:959
@ QUEST_MORE_TORCH_TOSS_A
Definition midsummer.cpp:963

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.

985{ 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.

1064 {
1067 {
1069 }
1070 }
@ EFFECT_0
Definition SharedDefines.h:31
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition SharedDefines.h:843
#define SpellEffectFn(F, I, N)
Definition SpellScript.h:337
#define SpellCastFn(F)
Definition SpellScript.h:324
HookList< CastHandler > AfterCast
Definition SpellScript.h:323
HookList< EffectHandler > OnEffectHitTarget
Definition SpellScript.h:336
uint32 m_scriptSpellId
Definition SpellScript.h:107
void HandleScript(SpellEffIndex effIndex)
Definition midsummer.cpp:1032
void HandleFinish()
Definition midsummer.cpp:1012
@ SPELL_JUGGLE_TORCH
Definition midsummer.cpp:961

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

◆ ThrowNextTorch()

void spell_midsummer_fling_torch::ThrowNextTorch ( Unit *  caster)
inlineprivate
988 {
989 Creature* bunny = caster->FindNearestCreature(NPC_TORCH_TARGET, 100.0f);
990
991 if (!bunny)
992 return;
993
994 // targets are located on a circle with fixed radius around the target bunny
995 // first target is chosen randomly anywhere on the circle
996 // next target is chosen on the opposite half of the circle
997 // so a minimum flight duration of the torch is guaranteed
998 float angle = 0.0f;
1000 angle = frand(-1.0f * M_PI, 1.0f * M_PI); // full circle
1001 else
1002 angle = frand(-0.5f * M_PI, 0.5f * M_PI); // half circle
1003
1004 Position pos = bunny->GetPosition();
1005 pos.SetOrientation(caster->GetPosition().GetAbsoluteAngle(pos));
1006 pos.RelocatePolarOffset(angle, 8.0f); // radius is sniffed value
1007
1008 caster->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SPELL_FLING_TORCH, true);
1009 caster->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SPELL_TORCH_SHADOW, true);
1010 }
float frand(float min, float max)
Definition Random.cpp:57
Definition Creature.h:47
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:2558
@ NPC_TORCH_TARGET
Definition midsummer.cpp:952
@ SPELL_TORCH_SHADOW
Definition midsummer.cpp:958
@ SPELL_FLING_TORCH
Definition midsummer.cpp:954
Definition Position.h:27
float GetPositionZ() const
Definition Position.h:123
void SetOrientation(float orientation)
Definition Position.h:116
float GetPositionX() const
Definition Position.h:121
void GetPosition(float &x, float &y) const
Definition Position.h:126
float GetPositionY() const
Definition Position.h:122
void RelocatePolarOffset(float angle, float dist, float z=0.0f)
Definition Position.cpp:34

References Unit::CastSpell(), WorldObject::FindNearestCreature(), frand(), Position::GetPosition(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), SpellScript::GetSpellInfo(), NPC_TORCH_TARGET, Position::RelocatePolarOffset(), Position::SetOrientation(), SPELL_FLING_TORCH, SPELL_FLING_TORCH_DUMMY, and SPELL_TORCH_SHADOW.

Referenced by HandleFinish(), and HandleScript().

◆ Validate()

bool spell_midsummer_fling_torch::Validate ( SpellInfo const *  )
inlineoverrideprivatevirtual

Member Data Documentation

◆ handled

bool spell_midsummer_fling_torch::handled
private

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


The documentation for this class was generated from the following file: