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
424 {
426 }
@ DATA_SET_INSANITY_PHASE
Definition boss_herald_volazj.cpp:77
CreatureAI * AI() const
Definition Creature.h:141
Creature * ToCreature()
Definition Object.h:205
Unit * GetCaster()
Definition SpellScript.cpp:401
virtual void SetData(uint32, uint32)
Definition UnitAI.h:214

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
352 {
353 Unit* caster = GetCaster();
354 if (!caster)
355 {
356 targets.clear();
357 return;
358 }
359
360 if (!targets.empty())
361 {
362 targets.remove_if([this](WorldObject* targetObj) -> bool
363 {
364 return !targetObj || !targetObj->IsPlayer() || !GetCaster()->IsInCombatWith(targetObj->ToPlayer()) ||
365 targetObj->GetDistance(GetCaster()) >= (MAX_VISIBILITY_DISTANCE * 2);
366 });
367 }
368
369 if (targets.empty())
370 return;
371
372 // Start channel visual and set self as unnattackable
373 caster->ToCreature()->AI()->Talk(SAY_INSANITY);
374 caster->CastSpell(caster, SPELL_WHISPER_INSANITY, true);
375 caster->RemoveAllAuras();
376 caster->CastSpell(caster, INSANITY_VISUAL, true);
378 caster->SetControlled(true, UNIT_STATE_STUNNED);
379
380 // Handle phase effect
381 uint32 insanityCounter = 0;
382 std::list<WorldObject*>::const_iterator itr = targets.begin();
383 while (itr != targets.end() && insanityCounter < MAX_INSANITY_TARGETS)
384 {
385 WorldObject* targetObj = *itr;
386 if (!targetObj)
387 continue;
388
389 Player* plrTarget = targetObj->ToPlayer();
390 // This should never happen, spell has attribute SPELL_ATTR3_ONLY_TARGET_PLAYERS
391 if (!plrTarget)
392 continue;
393
394 // phase mask
395 plrTarget->CastSpell(plrTarget, InsanitySpells.at(insanityCounter), true);
396
397 // Summon clone
398 for (std::list<WorldObject*>::const_iterator itr2 = targets.begin(); itr2 != targets.end(); ++itr2)
399 {
400 // Should not make clone of current player target
401 Player* plrClone = *itr2 ? (*itr2)->ToPlayer() : nullptr;
402 if (!plrClone || plrClone == plrTarget || !plrClone->IsAlive())
403 continue;
404
405 if (Unit* summon = caster->SummonCreature(NPC_TWISTED_VISAGE, plrClone->GetPosition(), TEMPSUMMON_CORPSE_DESPAWN, 0))
406 {
407 plrClone->CastSpell(summon, SPELL_CLONE_PLAYER, true);
408
409 summon->AddThreat(plrTarget, 0.0f);
410 summon->SetInCombatWith(plrTarget);
411 plrTarget->SetInCombatWith(summon);
412 summon->SetPhaseMask(1 | (1 << (4 + insanityCounter)), true);
413 summon->SetUInt32Value(UNIT_FIELD_MINDAMAGE, plrClone->GetUInt32Value(UNIT_FIELD_MINDAMAGE));
414 summon->SetUInt32Value(UNIT_FIELD_MAXDAMAGE, plrClone->GetUInt32Value(UNIT_FIELD_MAXDAMAGE));
415 }
416 }
417
418 ++insanityCounter;
419 ++itr;
420 }
421 }
std::uint32_t uint32
Definition Define.h:107
#define MAX_VISIBILITY_DISTANCE
Definition ObjectDefines.h:31
@ TEMPSUMMON_CORPSE_DESPAWN
Definition Object.h:50
@ UNIT_STATE_STUNNED
Definition UnitDefines.h:173
@ UNIT_FLAG_NOT_SELECTABLE
Definition UnitDefines.h:275
@ 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:87
@ 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=0s)
Causes the creature to talk/say the text assigned to their entry in the creature_text database table.
Definition CreatureAI.cpp:50
bool IsPlayer() const
Definition Object.h:200
uint32 GetUInt32Value(uint16 index) const
Definition Object.cpp:305
Player * ToPlayer()
Definition Object.h:201
Definition Player.h:1081
Definition Unit.h:636
void SetInCombatWith(Unit *enemy, uint32 duration=0)
Definition Unit.cpp:13626
bool IsAlive() const
Definition Unit.h:1707
void SetControlled(bool apply, UnitState state, Unit *source=nullptr, bool isFear=false)
Definition Unit.cpp:18086
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 RemoveAllAuras()
Definition Unit.cpp:5351
void SetUnitFlag(UnitFlags flags)
UnitFlags available in UnitDefines.h.
Definition Unit.h:719
Definition Object.h:410
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:2368
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1256
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.

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

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.

429 {
432 }
@ EFFECT_0
Definition SharedDefines.h:31
@ TARGET_UNIT_SRC_AREA_ENEMY
Definition SharedDefines.h:1420
#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:351
void HandleAfterCast()
Definition boss_herald_volazj.cpp:423

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: