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
1075 {
1076 Unit* caster = GetCaster();
1077 if (!caster || !caster->ToPlayer()) // caster cant be null, but meh :p
1078 return;
1079
1081 {
1082 if (!handled)
1083 if (const WorldLocation* loc = GetExplTargetDest())
1084 {
1085 caster->CastSpell(loc->GetPositionX(), loc->GetPositionY(), loc->GetPositionZ(), SPELL_MISSED_TORCH, true);
1087 }
1088 return;
1089 }
1090
1091 ThrowNextTorch(caster);
1092 }
Player * ToPlayer()
Definition Object.h:201
WorldLocation const * GetExplTargetDest()
Definition SpellScript.cpp:416
SpellInfo const * GetSpellInfo()
Definition SpellScript.cpp:411
Unit * GetCaster()
Definition SpellScript.cpp:401
Definition Unit.h:636
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:1178
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:4941
Definition Position.h:255
void ThrowNextTorch(Unit *caster)
Definition midsummer.cpp:1049
bool handled
Definition midsummer.cpp:1046
@ SPELL_TORCH_COUNTER
Definition midsummer.cpp:1019
@ SPELL_FLING_TORCH_DUMMY
Definition midsummer.cpp:1017
@ SPELL_MISSED_TORCH
Definition midsummer.cpp:1018

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

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.

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

1126 {
1129 {
1131 }
1132 }
@ 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:1094
void HandleFinish()
Definition midsummer.cpp:1074
@ SPELL_JUGGLE_TORCH
Definition midsummer.cpp:1023

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

1034 {
1035 return ValidateSpellInfo(
1036 {
1043 });
1044 }
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: