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 void Register ()=0
 
virtual bool Validate (SpellInfo const *)
 
virtual bool Load ()
 
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
 
virtual bool _Validate (SpellInfo const *entry)
 
- 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
433 {
435 }
@ DATA_SET_INSANITY_PHASE
Definition: boss_herald_volazj.cpp:78
virtual void SetData(uint32, uint32)
Definition: UnitAI.h:203
CreatureAI * AI() const
Definition: Creature.h:136
Creature * ToCreature()
Definition: Object.h:197
Unit * GetCaster()
Definition: SpellScript.cpp:401

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
353 {
354 Unit* caster = GetCaster();
355 if (!caster)
356 {
357 targets.clear();
358 return;
359 }
360
361 if (!targets.empty())
362 {
363 targets.remove_if([this](WorldObject* targetObj) -> bool
364 {
365 return !targetObj || targetObj->GetTypeId() != TYPEID_PLAYER || !targetObj->ToPlayer()->IsInCombatWith(GetCaster()) ||
366 targetObj->GetDistance(GetCaster()) >= (MAX_VISIBILITY_DISTANCE * 2);
367 });
368 }
369
370 if (targets.empty())
371 {
372 return;
373 }
374
375 // Start channel visual and set self as unnattackable
376 caster->ToCreature()->AI()->Talk(SAY_INSANITY);
377 caster->CastSpell(caster, SPELL_WHISPER_INSANITY, true);
378 caster->RemoveAllAuras();
379 caster->CastSpell(caster, INSANITY_VISUAL, true);
381 caster->SetControlled(true, UNIT_STATE_STUNNED);
382
383 // Handle phase effect
384 uint32 insanityCounter = 0;
385 std::list<WorldObject*>::const_iterator itr = targets.begin();
386 while (itr != targets.end() && insanityCounter < MAX_INSANITY_TARGETS)
387 {
388 WorldObject* targetObj = *itr;
389 if (!targetObj)
390 {
391 continue;
392 }
393
394 Player* plrTarget = targetObj->ToPlayer();
395 // This should never happen, spell has attribute SPELL_ATTR3_ONLY_TARGET_PLAYERS
396 if (!plrTarget)
397 {
398 continue;
399 }
400
401 // phase mask
402 plrTarget->CastSpell(plrTarget, InsanitySpells.at(insanityCounter), true);
403
404 // Summon clone
405 for (std::list<WorldObject*>::const_iterator itr2 = targets.begin(); itr2 != targets.end(); ++itr2)
406 {
407 // Should not make clone of current player target
408 Player const* plrClone = *itr2 ? (*itr2)->ToPlayer() : nullptr;
409 if (!plrClone || plrClone == plrTarget)
410 {
411 continue;
412 }
413
414 if (Unit* summon = caster->SummonCreature(NPC_TWISTED_VISAGE, plrClone->GetPosition(), TEMPSUMMON_CORPSE_DESPAWN, 0))
415 {
416 summon->AddThreat(plrTarget, 0.0f);
417 summon->SetInCombatWith(plrTarget);
418 plrTarget->SetInCombatWith(summon);
419
420 plrTarget->CastSpell(summon, SPELL_CLONE_PLAYER, true);
421 summon->SetPhaseMask(1 | (1 << (4 + insanityCounter)), true);
422 summon->SetUInt32Value(UNIT_FIELD_MINDAMAGE, plrClone->GetUInt32Value(UNIT_FIELD_MINDAMAGE));
423 summon->SetUInt32Value(UNIT_FIELD_MAXDAMAGE, plrClone->GetUInt32Value(UNIT_FIELD_MAXDAMAGE));
424 }
425 }
426
427 ++insanityCounter;
428 ++itr;
429 }
430 }
std::uint32_t uint32
Definition: Define.h:108
@ TEMPSUMMON_CORPSE_DESPAWN
Definition: Object.h:46
#define MAX_VISIBILITY_DISTANCE
Definition: ObjectDefines.h:31
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
@ UNIT_FIELD_MINDAMAGE
Definition: UpdateFields.h:127
@ UNIT_FIELD_MAXDAMAGE
Definition: UpdateFields.h:128
@ UNIT_STATE_STUNNED
Definition: Unit.h:328
@ UNIT_FLAG_NOT_SELECTABLE
Definition: Unit.h:473
@ NPC_TWISTED_VISAGE
Definition: boss_herald_volazj.cpp:74
@ MAX_INSANITY_TARGETS
Definition: boss_herald_volazj.cpp:77
const std::array< uint32, MAX_INSANITY_TARGETS > InsanitySpells
Definition: boss_herald_volazj.cpp:88
@ INSANITY_VISUAL
Definition: boss_herald_volazj.cpp:35
@ SPELL_CLONE_PLAYER
Definition: boss_herald_volazj.cpp:37
@ SPELL_WHISPER_INSANITY
Definition: boss_herald_volazj.cpp:45
@ SAY_INSANITY
Definition: boss_herald_volazj.cpp:56
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:49
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:305
Player * ToPlayer()
Definition: Object.h:195
TypeID GetTypeId() const
Definition: Object.h:121
Definition: Object.h:393
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:2343
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1245
void GetPosition(float &x, float &y) const
Definition: Position.h:122
Definition: Player.h:1056
Definition: Unit.h:1302
void AddThreat(Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=nullptr)
Definition: Unit.cpp:14639
void SetInCombatWith(Unit *enemy, uint32 duration=0)
Definition: Unit.cpp:13575
bool IsInCombatWith(Unit const *who) const
Definition: Unit.cpp:21319
void SetControlled(bool apply, UnitState state, Unit *source=nullptr, bool isFear=false)
Definition: Unit.cpp:18288
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:1169
void RemoveAllAuras()
Definition: Unit.cpp:5259
void SetUnitFlag(UnitFlags flags)
Definition: Unit.h:1495

References Unit::AddThreat(), Creature::AI(), Unit::CastSpell(), SpellScript::GetCaster(), WorldObject::GetDistance(), Position::GetPosition(), Object::GetTypeId(), Object::GetUInt32Value(), INSANITY_VISUAL, InsanitySpells, Unit::IsInCombatWith(), 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(), TYPEID_PLAYER, 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.

350{ return GetCaster()->GetTypeId() == TYPEID_UNIT; }
@ TYPEID_UNIT
Definition: ObjectGuid.h:37

References SpellScript::GetCaster(), Object::GetTypeId(), and TYPEID_UNIT.

◆ PrepareSpellScript()

spell_herald_volzaj_insanity::PrepareSpellScript ( spell_herald_volzaj_insanity  )
private

◆ Register()

void spell_herald_volzaj_insanity::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

438 {
441 }
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition: SpellScript.h:354
#define SpellCastFn(F)
Definition: SpellScript.h:324
@ EFFECT_0
Definition: SharedDefines.h:31
@ TARGET_UNIT_SRC_AREA_ENEMY
Definition: SharedDefines.h:1420
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:352
void HandleAfterCast()
Definition: boss_herald_volazj.cpp:432

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