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
 
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 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
 
- 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
1005 {
1006 Unit* caster = GetCaster();
1007 if (!caster || !caster->ToPlayer()) // caster cant be null, but meh :p
1008 return;
1009
1011 {
1012 if (!handled)
1013 if (const WorldLocation* loc = GetExplTargetDest())
1014 {
1015 caster->CastSpell(loc->GetPositionX(), loc->GetPositionY(), loc->GetPositionZ(), SPELL_MISSED_TORCH, true);
1017 }
1018 return;
1019 }
1020
1021 ThrowNextTorch(caster);
1022 }
Player * ToPlayer()
Definition Object.h:202
WorldLocation const * GetExplTargetDest()
Definition SpellScript.cpp:416
SpellInfo const * GetSpellInfo()
Definition SpellScript.cpp:411
Unit * GetCaster()
Definition SpellScript.cpp:401
Definition Unit.h:620
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:1193
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:4965
Definition Position.h:255
void ThrowNextTorch(Unit *caster)
Definition midsummer.cpp:979
bool handled
Definition midsummer.cpp:976
@ SPELL_TORCH_COUNTER
Definition midsummer.cpp:949
@ SPELL_FLING_TORCH_DUMMY
Definition midsummer.cpp:947
@ SPELL_MISSED_TORCH
Definition midsummer.cpp:948

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
1025 {
1026 PreventHitDefaultEffect(effIndex);
1027 if (Player* target = GetHitPlayer())
1028 {
1029 if (target->GetGUID() != GetCaster()->GetGUID())
1030 return;
1031
1032 handled = true;
1033 if (Aura* aur = target->GetAura(SPELL_TORCH_COUNTER))
1034 {
1035 aur->ModStackAmount(1);
1036 uint8 count = 4;
1037 if (target->GetQuestStatus(target->GetTeamId() ? QUEST_MORE_TORCH_TOSS_H : QUEST_MORE_TORCH_TOSS_A) == QUEST_STATUS_INCOMPLETE) // More Torch Catching quests
1038 count = 10;
1039
1040 if (aur->GetStackAmount() >= count)
1041 {
1042 //target->CastSpell(target, 46711, true); // Set Flag: all torch returning quests are complete
1043 target->CastSpell(target, (target->GetTeamId() ? SPELL_TORCH_CATCH_SUCCESS_H : SPELL_TORCH_CATCH_SUCCESS_A), true); // Quest completion
1044 aur->SetDuration(1);
1045 return;
1046 }
1047 }
1048 else
1049 target->CastSpell(target, SPELL_TORCH_COUNTER, true);
1050
1052 }
1053 }
std::uint8_t uint8
Definition Define.h:109
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:103
Definition SpellAuras.h:87
Definition Player.h:1083
Player * GetHitPlayer()
Definition SpellScript.cpp:471
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Definition SpellScript.cpp:590
@ QUEST_MORE_TORCH_TOSS_H
Definition midsummer.cpp:956
@ SPELL_TORCH_CATCH_SUCCESS_H
Definition midsummer.cpp:952
@ SPELL_TORCH_CATCH_SUCCESS_A
Definition midsummer.cpp:951
@ QUEST_MORE_TORCH_TOSS_A
Definition midsummer.cpp:955

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.

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

1056 {
1059 {
1061 }
1062 }
@ EFFECT_0
Definition SharedDefines.h:31
@ SPELL_EFFECT_SCRIPT_EFFECT
Definition SharedDefines.h:855
#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:1024
void HandleFinish()
Definition midsummer.cpp:1004
@ SPELL_JUGGLE_TORCH
Definition midsummer.cpp:953

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
980 {
981 Creature* bunny = caster->FindNearestCreature(NPC_TORCH_TARGET, 100.0f);
982
983 if (!bunny)
984 return;
985
986 // targets are located on a circle with fixed radius around the target bunny
987 // first target is chosen randomly anywhere on the circle
988 // next target is chosen on the opposite half of the circle
989 // so a minimum flight duration of the torch is guaranteed
990 float angle = 0.0f;
992 angle = frand(-1.0f * M_PI, 1.0f * M_PI); // full circle
993 else
994 angle = frand(-0.5f * M_PI, 0.5f * M_PI); // half circle
995
996 Position pos = bunny->GetPosition();
997 pos.SetOrientation(caster->GetPosition().GetAbsoluteAngle(pos));
998 pos.RelocatePolarOffset(angle, 8.0f); // radius is sniffed value
999
1000 caster->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SPELL_FLING_TORCH, true);
1001 caster->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SPELL_TORCH_SHADOW, true);
1002 }
float frand(float min, float max)
Definition Random.cpp:57
Definition Creature.h:43
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:2441
@ NPC_TORCH_TARGET
Definition midsummer.cpp:944
@ SPELL_TORCH_SHADOW
Definition midsummer.cpp:950
@ SPELL_FLING_TORCH
Definition midsummer.cpp:946
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: