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
1072 {
1073 Unit* caster = GetCaster();
1074 if (!caster || !caster->ToPlayer()) // caster cant be null, but meh :p
1075 return;
1076
1078 {
1079 if (!handled)
1080 if (const WorldLocation* loc = GetExplTargetDest())
1081 {
1082 caster->CastSpell(loc->GetPositionX(), loc->GetPositionY(), loc->GetPositionZ(), SPELL_MISSED_TORCH, true);
1084 }
1085 return;
1086 }
1087
1088 ThrowNextTorch(caster);
1089 }
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:1179
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:4942
Definition Position.h:255
void ThrowNextTorch(Unit *caster)
Definition midsummer.cpp:1046
bool handled
Definition midsummer.cpp:1043
@ SPELL_TORCH_COUNTER
Definition midsummer.cpp:1016
@ SPELL_FLING_TORCH_DUMMY
Definition midsummer.cpp:1014
@ SPELL_MISSED_TORCH
Definition midsummer.cpp:1015

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
1092 {
1093 PreventHitDefaultEffect(effIndex);
1094 if (Player* target = GetHitPlayer())
1095 {
1096 if (target->GetGUID() != GetCaster()->GetGUID())
1097 return;
1098
1099 handled = true;
1100 if (Aura* aur = target->GetAura(SPELL_TORCH_COUNTER))
1101 {
1102 aur->ModStackAmount(1);
1103 uint8 count = 4;
1104 if (target->GetQuestStatus(target->GetTeamId() ? QUEST_MORE_TORCH_TOSS_H : QUEST_MORE_TORCH_TOSS_A) == QUEST_STATUS_INCOMPLETE) // More Torch Catching quests
1105 count = 10;
1106
1107 if (aur->GetStackAmount() >= count)
1108 {
1109 //target->CastSpell(target, 46711, true); // Set Flag: all torch returning quests are complete
1110 target->CastSpell(target, (target->GetTeamId() ? SPELL_TORCH_CATCH_SUCCESS_H : SPELL_TORCH_CATCH_SUCCESS_A), true); // Quest completion
1111 aur->SetDuration(1);
1112 return;
1113 }
1114 }
1115 else
1116 target->CastSpell(target, SPELL_TORCH_COUNTER, true);
1117
1119 }
1120 }
std::uint8_t uint8
Definition Define.h:109
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:103
Definition SpellAuras.h:87
Definition Player.h:1082
Player * GetHitPlayer()
Definition SpellScript.cpp:471
void PreventHitDefaultEffect(SpellEffIndex effIndex)
Definition SpellScript.cpp:590
@ QUEST_MORE_TORCH_TOSS_H
Definition midsummer.cpp:1023
@ SPELL_TORCH_CATCH_SUCCESS_H
Definition midsummer.cpp:1019
@ SPELL_TORCH_CATCH_SUCCESS_A
Definition midsummer.cpp:1018
@ QUEST_MORE_TORCH_TOSS_A
Definition midsummer.cpp:1022

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.

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

1123 {
1126 {
1128 }
1129 }
@ 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:1091
void HandleFinish()
Definition midsummer.cpp:1071
@ SPELL_JUGGLE_TORCH
Definition midsummer.cpp:1020

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
1047 {
1048 Creature* bunny = caster->FindNearestCreature(NPC_TORCH_TARGET, 100.0f);
1049
1050 if (!bunny)
1051 return;
1052
1053 // targets are located on a circle with fixed radius around the target bunny
1054 // first target is chosen randomly anywhere on the circle
1055 // next target is chosen on the opposite half of the circle
1056 // so a minimum flight duration of the torch is guaranteed
1057 float angle = 0.0f;
1059 angle = frand(-1.0f * M_PI, 1.0f * M_PI); // full circle
1060 else
1061 angle = frand(-0.5f * M_PI, 0.5f * M_PI); // half circle
1062
1063 Position pos = bunny->GetPosition();
1064 pos.SetOrientation(caster->GetPosition().GetAbsoluteAngle(pos));
1065 pos.RelocatePolarOffset(angle, 8.0f); // radius is sniffed value
1066
1067 caster->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SPELL_FLING_TORCH, true);
1068 caster->CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SPELL_TORCH_SHADOW, true);
1069 }
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:2459
@ NPC_TORCH_TARGET
Definition midsummer.cpp:1011
@ SPELL_TORCH_SHADOW
Definition midsummer.cpp:1017
@ SPELL_FLING_TORCH
Definition midsummer.cpp:1013
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

Reimplemented from _SpellScript.

1031 {
1032 return ValidateSpellInfo(
1033 {
1040 });
1041 }
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition SpellScript.h:125

References SPELL_FLING_TORCH, SPELL_MISSED_TORCH, SPELL_TORCH_CATCH_SUCCESS_A, SPELL_TORCH_CATCH_SUCCESS_H, SPELL_TORCH_COUNTER, SPELL_TORCH_SHADOW, and _SpellScript::ValidateSpellInfo().

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: