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

Private Member Functions

 PrepareSpellScript (spell_herald_volzaj_insanity)
 
bool Load () override
 
void HandleDummyEffect (std::list< WorldObject * > &targets)
 
void HandleAfterCast ()
 
void Register () override
 

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 bool Validate (SpellInfo 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

◆ HandleAfterCast()

void spell_herald_volzaj_insanity::HandleAfterCast ( )
inlineprivate
363 {
365 }
@ DATA_SET_INSANITY_PHASE
Definition boss_herald_volazj.cpp:77
CreatureAI * AI() const
Definition Creature.h:145
Creature * ToCreature()
Definition Object.h:206
Unit * GetCaster()
Definition SpellScript.cpp:401
virtual void SetData(uint32, uint32)
Definition UnitAI.h:219

References Creature::AI(), DATA_SET_INSANITY_PHASE, SpellScript::GetCaster(), UnitAI::SetData(), and Object::ToCreature().

Referenced by Register().

◆ HandleDummyEffect()

void spell_herald_volzaj_insanity::HandleDummyEffect ( std::list< WorldObject * > &  targets)
inlineprivate
291 {
292 Unit* caster = GetCaster();
293 if (!caster)
294 {
295 targets.clear();
296 return;
297 }
298
299 if (!targets.empty())
300 {
301 targets.remove_if([this](WorldObject* targetObj) -> bool
302 {
303 return !targetObj || !targetObj->IsPlayer() || !GetCaster()->IsInCombatWith(targetObj->ToPlayer()) ||
304 targetObj->GetDistance(GetCaster()) >= (MAX_VISIBILITY_DISTANCE * 2);
305 });
306 }
307
308 if (targets.empty())
309 return;
310
311 // Start channel visual and set self as unnattackable
312 caster->ToCreature()->AI()->Talk(SAY_INSANITY);
313 caster->CastSpell(caster, SPELL_WHISPER_INSANITY, true);
314 caster->RemoveAllAuras();
315 caster->CastSpell(caster, INSANITY_VISUAL, true);
317 caster->SetControlled(true, UNIT_STATE_STUNNED);
318
319 // Handle phase effect
320 uint32 insanityCounter = 0;
321 std::list<WorldObject*>::const_iterator itr = targets.begin();
322 while (itr != targets.end() && insanityCounter < MAX_INSANITY_TARGETS)
323 {
324 WorldObject* targetObj = *itr;
325 if (!targetObj)
326 continue;
327
328 Player* plrTarget = targetObj->ToPlayer();
329 // This should never happen, spell has attribute SPELL_ATTR3_ONLY_TARGET_PLAYERS
330 if (!plrTarget)
331 continue;
332
333 // phase mask
334 plrTarget->CastSpell(plrTarget, InsanitySpells.at(insanityCounter), true);
335
336 // Summon clone
337 for (std::list<WorldObject*>::const_iterator itr2 = targets.begin(); itr2 != targets.end(); ++itr2)
338 {
339 // Should not make clone of current player target
340 Player* plrClone = *itr2 ? (*itr2)->ToPlayer() : nullptr;
341 if (!plrClone || plrClone == plrTarget || !plrClone->IsAlive())
342 continue;
343
344 if (Unit* summon = caster->SummonCreature(NPC_TWISTED_VISAGE, plrClone->GetPosition(), TEMPSUMMON_CORPSE_DESPAWN, 0))
345 {
346 plrClone->CastSpell(summon, SPELL_CLONE_PLAYER, true);
347
348 summon->AddThreat(plrTarget, 0.0f);
349 summon->SetInCombatWith(plrTarget);
350 plrTarget->SetInCombatWith(summon);
351 summon->SetPhaseMask(1 | (1 << (4 + insanityCounter)), true);
352 summon->SetUInt32Value(UNIT_FIELD_MINDAMAGE, plrClone->GetUInt32Value(UNIT_FIELD_MINDAMAGE));
353 summon->SetUInt32Value(UNIT_FIELD_MAXDAMAGE, plrClone->GetUInt32Value(UNIT_FIELD_MAXDAMAGE));
354 }
355 }
356
357 ++insanityCounter;
358 ++itr;
359 }
360 }
std::uint32_t uint32
Definition Define.h:107
#define MAX_VISIBILITY_DISTANCE
Definition ObjectDefines.h:30
@ TEMPSUMMON_CORPSE_DESPAWN
Definition Object.h:52
@ UNIT_STATE_STUNNED
Definition UnitDefines.h:173
@ UNIT_FLAG_NOT_SELECTABLE
Definition UnitDefines.h:279
@ UNIT_FIELD_MINDAMAGE
Definition UpdateFields.h:127
@ UNIT_FIELD_MAXDAMAGE
Definition UpdateFields.h:128
@ NPC_TWISTED_VISAGE
Definition boss_herald_volazj.cpp:73
@ MAX_INSANITY_TARGETS
Definition boss_herald_volazj.cpp:76
const std::array< uint32, MAX_INSANITY_TARGETS > InsanitySpells
Definition boss_herald_volazj.cpp:80
@ INSANITY_VISUAL
Definition boss_herald_volazj.cpp:35
@ SPELL_CLONE_PLAYER
Definition boss_herald_volazj.cpp:36
@ SPELL_WHISPER_INSANITY
Definition boss_herald_volazj.cpp:44
@ SAY_INSANITY
Definition boss_herald_volazj.cpp:55
void Talk(uint8 id, WorldObject const *whisperTarget=nullptr, Milliseconds delay=0ms)
Causes the creature to talk/say the text assigned to their entry in the creature_text database table.
Definition CreatureAI.cpp:53
bool IsPlayer() const
Definition Object.h:201
uint32 GetUInt32Value(uint16 index) const
Definition Object.cpp:294
Player * ToPlayer()
Definition Object.h:202
Definition Player.h:1071
Definition Unit.h:650
void SetInCombatWith(Unit *enemy, uint32 duration=0)
Definition Unit.cpp:13662
bool IsAlive() const
Definition Unit.h:1748
void SetControlled(bool apply, UnitState state, Unit *source=nullptr, bool isFear=false)
Definition Unit.cpp:18074
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:1194
void RemoveAllAuras()
Definition Unit.cpp:5387
void SetUnitFlag(UnitFlags flags)
UnitFlags available in UnitDefines.h.
Definition Unit.h:733
Definition Object.h:472
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0, SummonPropertiesEntry const *properties=nullptr, bool visibleBySummonerOnly=false) const
Definition Object.cpp:2359
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1278
void GetPosition(float &x, float &y) const
Definition Position.h:126

References Creature::AI(), Unit::CastSpell(), SpellScript::GetCaster(), WorldObject::GetDistance(), Position::GetPosition(), Object::GetUInt32Value(), INSANITY_VISUAL, InsanitySpells, Unit::IsAlive(), Object::IsPlayer(), MAX_INSANITY_TARGETS, MAX_VISIBILITY_DISTANCE, NPC_TWISTED_VISAGE, Unit::RemoveAllAuras(), SAY_INSANITY, Unit::SetControlled(), Unit::SetInCombatWith(), Unit::SetUnitFlag(), SPELL_CLONE_PLAYER, SPELL_WHISPER_INSANITY, WorldObject::SummonCreature(), CreatureAI::Talk(), TEMPSUMMON_CORPSE_DESPAWN, Object::ToCreature(), Object::ToPlayer(), UNIT_FIELD_MAXDAMAGE, UNIT_FIELD_MINDAMAGE, UNIT_FLAG_NOT_SELECTABLE, and UNIT_STATE_STUNNED.

Referenced by Register().

◆ Load()

bool spell_herald_volzaj_insanity::Load ( )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

288{ return GetCaster()->IsCreature(); }
bool IsCreature() const
Definition Object.h:205

References SpellScript::GetCaster(), and Object::IsCreature().

◆ PrepareSpellScript()

spell_herald_volzaj_insanity::PrepareSpellScript ( spell_herald_volzaj_insanity  )
private

◆ Register()

void spell_herald_volzaj_insanity::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

368 {
371 }
@ EFFECT_0
Definition SharedDefines.h:31
@ TARGET_UNIT_SRC_AREA_ENEMY
Definition SharedDefines.h:1431
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition SpellScript.h:354
#define SpellCastFn(F)
Definition SpellScript.h:324
HookList< CastHandler > AfterCast
Definition SpellScript.h:323
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
Definition SpellScript.h:353
void HandleDummyEffect(std::list< WorldObject * > &targets)
Definition boss_herald_volazj.cpp:290
void HandleAfterCast()
Definition boss_herald_volazj.cpp:362

References SpellScript::AfterCast, EFFECT_0, HandleAfterCast(), HandleDummyEffect(), SpellScript::OnObjectAreaTargetSelect, SpellCastFn, SpellObjectAreaTargetSelectFn, and TARGET_UNIT_SRC_AREA_ENEMY.


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