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
432 {
434 }
@ DATA_SET_INSANITY_PHASE
Definition: boss_herald_volazj.cpp:77
virtual void SetData(uint32, uint32)
Definition: UnitAI.h:203
CreatureAI * AI() const
Definition: Creature.h:135
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
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->GetTypeId() != TYPEID_PLAYER || !targetObj->ToPlayer()->IsInCombatWith(GetCaster()) ||
365 targetObj->GetDistance(GetCaster()) >= (MAX_VISIBILITY_DISTANCE * 2);
366 });
367 }
368
369 if (targets.empty())
370 {
371 return;
372 }
373
374 // Start channel visual and set self as unnattackable
375 caster->ToCreature()->AI()->Talk(SAY_INSANITY);
376 caster->CastSpell(caster, SPELL_WHISPER_INSANITY, true);
377 caster->RemoveAllAuras();
378 caster->CastSpell(caster, INSANITY_VISUAL, true);
380 caster->SetControlled(true, UNIT_STATE_STUNNED);
381
382 // Handle phase effect
383 uint32 insanityCounter = 0;
384 std::list<WorldObject*>::const_iterator itr = targets.begin();
385 while (itr != targets.end() && insanityCounter < MAX_INSANITY_TARGETS)
386 {
387 WorldObject* targetObj = *itr;
388 if (!targetObj)
389 {
390 continue;
391 }
392
393 Player* plrTarget = targetObj->ToPlayer();
394 // This should never happen, spell has attribute SPELL_ATTR3_ONLY_TARGET_PLAYERS
395 if (!plrTarget)
396 {
397 continue;
398 }
399
400 // phase mask
401 plrTarget->CastSpell(plrTarget, InsanitySpells.at(insanityCounter), true);
402
403 // Summon clone
404 for (std::list<WorldObject*>::const_iterator itr2 = targets.begin(); itr2 != targets.end(); ++itr2)
405 {
406 // Should not make clone of current player target
407 Player const* plrClone = *itr2 ? (*itr2)->ToPlayer() : nullptr;
408 if (!plrClone || plrClone == plrTarget)
409 {
410 continue;
411 }
412
413 if (Unit* summon = caster->SummonCreature(NPC_TWISTED_VISAGE, plrClone->GetPosition(), TEMPSUMMON_CORPSE_DESPAWN, 0))
414 {
415 summon->AddThreat(plrTarget, 0.0f);
416 summon->SetInCombatWith(plrTarget);
417 plrTarget->SetInCombatWith(summon);
418
419 plrTarget->CastSpell(summon, SPELL_CLONE_PLAYER, true);
420 summon->SetPhaseMask(1 | (1 << (4 + insanityCounter)), true);
421 summon->SetUInt32Value(UNIT_FIELD_MINDAMAGE, plrClone->GetUInt32Value(UNIT_FIELD_MINDAMAGE));
422 summon->SetUInt32Value(UNIT_FIELD_MAXDAMAGE, plrClone->GetUInt32Value(UNIT_FIELD_MAXDAMAGE));
423 }
424 }
425
426 ++insanityCounter;
427 ++itr;
428 }
429 }
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: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:34
@ 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
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:2318
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1245
void GetPosition(float &x, float &y) const
Definition: Position.h:122
Definition: Player.h:1046
Definition: Unit.h:1290
void AddThreat(Unit *victim, float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=nullptr)
Definition: Unit.cpp:14548
void SetInCombatWith(Unit *enemy, uint32 duration=0)
Definition: Unit.cpp:13492
bool IsInCombatWith(Unit const *who) const
Definition: Unit.cpp:21205
void SetControlled(bool apply, UnitState state, Unit *source=nullptr, bool isFear=false)
Definition: Unit.cpp:18192
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:5239
void SetUnitFlag(UnitFlags flags)
Definition: Unit.h:1481

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.

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

437 {
440 }
#define SpellObjectAreaTargetSelectFn(F, I, N)
Definition: SpellScript.h:354
#define SpellCastFn(F)
Definition: SpellScript.h:324
@ EFFECT_0
Definition: SharedDefines.h:30
@ TARGET_UNIT_SRC_AREA_ENEMY
Definition: SharedDefines.h:1392
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:431

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