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

Private Member Functions

 PrepareAuraScript (spell_mc_play_dead_aura)
 
bool Validate (SpellInfo const *) override
 
bool Load () override
 
void HandleEffectApply (AuraEffect const *, AuraEffectHandleModes)
 
void HandleEffectRemove (AuraEffect const *, AuraEffectHandleModes)
 
void Register () override
 

Additional Inherited Members

- Public Member Functions inherited from AuraScript
 AuraScript ()
 
bool _Validate (SpellInfo const *entry) override
 
bool _Load (Aura *aura)
 
void _PrepareScriptCall (AuraScriptHookType hookType, AuraApplication const *aurApp=nullptr)
 
void _FinishScriptCall ()
 
bool _IsDefaultActionPrevented ()
 
void PreventDefaultAction ()
 
SpellInfo const * GetSpellInfo () const
 
uint32 GetId () const
 
ObjectGuid GetCasterGUID () const
 
UnitGetCaster () const
 
WorldObjectGetOwner () const
 
UnitGetUnitOwner () const
 
DynamicObjectGetDynobjOwner () const
 
void Remove (uint32 removeMode=0)
 
AuraGetAura () const
 
AuraObjectType GetType () const
 
int32 GetDuration () const
 
void SetDuration (int32 duration, bool withMods=false)
 
void RefreshDuration ()
 
time_t GetApplyTime () const
 
int32 GetMaxDuration () const
 
void SetMaxDuration (int32 duration)
 
int32 CalcMaxDuration () const
 
bool IsExpired () const
 
bool IsPermanent () const
 
uint8 GetCharges () const
 
void SetCharges (uint8 charges)
 
uint8 CalcMaxCharges () const
 
bool ModCharges (int8 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
bool DropCharge (AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
uint8 GetStackAmount () const
 
void SetStackAmount (uint8 num)
 
bool ModStackAmount (int32 num, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
 
bool IsPassive () const
 
bool IsDeathPersistent () const
 
bool HasEffect (uint8 effIndex) const
 
AuraEffectGetEffect (uint8 effIndex) const
 
bool HasEffectType (AuraType type) const
 
UnitGetTarget () const
 
AuraApplication const * GetTargetApplication () const
 
- 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 AuraScript
HookList< CheckAreaTargetHandlerDoCheckAreaTarget
 
HookList< AuraDispelHandlerOnDispel
 
HookList< AuraDispelHandlerAfterDispel
 
HookList< EffectApplyHandlerOnEffectApply
 
HookList< EffectApplyHandlerAfterEffectApply
 
HookList< EffectApplyHandlerOnEffectRemove
 
HookList< EffectApplyHandlerAfterEffectRemove
 
HookList< EffectPeriodicHandlerOnEffectPeriodic
 
HookList< EffectUpdatePeriodicHandlerOnEffectUpdatePeriodic
 
HookList< EffectCalcAmountHandlerDoEffectCalcAmount
 
HookList< EffectCalcPeriodicHandlerDoEffectCalcPeriodic
 
HookList< EffectCalcSpellModHandlerDoEffectCalcSpellMod
 
HookList< EffectAbsorbHandlerOnEffectAbsorb
 
HookList< EffectAbsorbHandlerAfterEffectAbsorb
 
HookList< EffectManaShieldHandlerOnEffectManaShield
 
HookList< EffectManaShieldHandlerAfterEffectManaShield
 
HookList< EffectSplitHandlerOnEffectSplit
 
HookList< CheckProcHandlerDoCheckProc
 
HookList< AfterCheckProcHandlerDoAfterCheckProc
 
HookList< AuraProcHandlerDoPrepareProc
 
HookList< AuraProcHandlerOnProc
 
HookList< AuraProcHandlerAfterProc
 
HookList< EffectProcHandlerOnEffectProc
 
HookList< EffectProcHandlerAfterEffectProc
 
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

◆ HandleEffectApply()

void spell_mc_play_dead_aura::HandleEffectApply ( AuraEffect const *  ,
AuraEffectHandleModes   
)
inlineprivate
136 {
137 Creature* creatureTarget = GetTarget()->ToCreature();
138 if (!creatureTarget)
139 {
140 return;
141 }
142
143 creatureTarget->CastSpell(creatureTarget, SPELL_PLAY_DEAD_PACIFY, true);
144 creatureTarget->SetDynamicFlag(UNIT_DYNFLAG_DEAD);
145 creatureTarget->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
146 //creatureTarget->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
147 creatureTarget->SetReactState(REACT_PASSIVE);
148 creatureTarget->SetControlled(true, UNIT_STATE_ROOT);
149
150 creatureTarget->AttackStop();
151 }
@ REACT_PASSIVE
Definition: Unit.h:548
@ UNIT_FLAG2_FEIGN_DEATH
Definition: UnitDefines.h:268
@ UNIT_STATE_ROOT
Definition: UnitDefines.h:159
@ SPELL_PLAY_DEAD_PACIFY
Definition: molten_core.cpp:38
@ UNIT_DYNFLAG_DEAD
Definition: SharedDefines.h:3126
Definition: Creature.h:46
void SetReactState(ReactStates state)
A creature can have 3 ReactStates : Agressive, Passive, Neutral.
Definition: Creature.h:97
virtual void SetDynamicFlag(uint32 flag)
Definition: Object.h:120
Creature * ToCreature()
Definition: Object.h:202
void SetUnitFlag2(UnitFlags2 flags)
Definition: Unit.h:689
void SetControlled(bool apply, UnitState state, Unit *source=nullptr, bool isFear=false)
Definition: Unit.cpp:17990
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:1168
bool AttackStop()
Force the unit to stop attacking. This will clear UNIT_STATE_MELEE_ATTACKING, Interrupt current spell...
Definition: Unit.cpp:10365
Unit * GetTarget() const
Definition: SpellScript.cpp:1165

References Unit::AttackStop(), Unit::CastSpell(), AuraScript::GetTarget(), REACT_PASSIVE, Unit::SetControlled(), Object::SetDynamicFlag(), Creature::SetReactState(), Unit::SetUnitFlag2(), SPELL_PLAY_DEAD_PACIFY, Object::ToCreature(), UNIT_DYNFLAG_DEAD, UNIT_FLAG2_FEIGN_DEATH, and UNIT_STATE_ROOT.

Referenced by Register().

◆ HandleEffectRemove()

void spell_mc_play_dead_aura::HandleEffectRemove ( AuraEffect const *  ,
AuraEffectHandleModes   
)
inlineprivate
154 {
155 Creature* creatureTarget = GetTarget()->ToCreature();
156 if (!creatureTarget)
157 {
158 return;
159 }
160
162 creatureTarget->RemoveDynamicFlag(UNIT_DYNFLAG_DEAD);
164 //creatureTarget->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
165 creatureTarget->SetControlled(false, UNIT_STATE_ROOT);
166 creatureTarget->SetReactState(REACT_AGGRESSIVE);
167
168 if (!creatureTarget->IsInCombat())
169 {
170 return;
171 }
172
173 bool shouldDie = true;
174 std::list<Creature*> hounds;
175 creatureTarget->GetCreaturesWithEntryInRange(hounds, 80.0f, NPC_CORE_HOUND);
176
177 // Perform lambda based check to find if there is any nearby
178 if (!hounds.empty())
179 {
180 // Alive hound been found within 80 yards -> cancel suicide
181 if (std::find_if(hounds.begin(), hounds.end(), [creatureTarget](Creature const* hound)
182 {
183 return creatureTarget != hound && creatureTarget->IsWithinLOSInMap(hound) && hound->IsAlive() && hound->IsInCombat() && !hound->HasAura(SPELL_PLAY_DEAD);
184 }) != hounds.end())
185 {
186 shouldDie = false;
187 }
188 }
189
190 if (!shouldDie)
191 {
192 if (CreatureAI* targetAI = creatureTarget->AI())
193 {
194 targetAI->DoCastSelf(SPELL_FIRE_NOVA_VISUAL, true);
195 targetAI->DoCastSelf(SPELL_FULL_HEALTH, true);
196 targetAI->Talk(EMOTE_IGNITE);
197 }
198 }
199 else
200 {
201 Unit::Kill(creatureTarget, creatureTarget);
202 creatureTarget->DespawnOrUnsummon(14000);
203 }
204 }
@ REACT_AGGRESSIVE
Definition: Unit.h:550
@ SPELL_FULL_HEALTH
Definition: molten_core.cpp:36
@ SPELL_FIRE_NOVA_VISUAL
Definition: molten_core.cpp:37
@ EMOTE_IGNITE
Definition: molten_core.cpp:28
@ NPC_CORE_HOUND
Definition: molten_core.h:63
Definition: CreatureAI.h:71
void DespawnOrUnsummon(Milliseconds msTimeToDespawn, Seconds forcedRespawnTimer)
Definition: Creature.cpp:2173
CreatureAI * AI() const
Definition: Creature.h:143
virtual void RemoveDynamicFlag(uint32 flag)
Definition: Object.h:121
void GetCreaturesWithEntryInRange(std::list< Creature * > &creatureList, float radius, uint32 entry)
Definition: Object.cpp:3084
static void Kill(Unit *killer, Unit *victim, bool durabilityLoss=true, WeaponAttackType attackType=BASE_ATTACK, SpellInfo const *spellProto=nullptr, Spell const *spell=nullptr)
Definition: Unit.cpp:17658
void RemoveUnitFlag2(UnitFlags2 flags)
Definition: Unit.h:690
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4891
bool IsInCombat() const
Definition: Unit.h:820

References Creature::AI(), Creature::DespawnOrUnsummon(), EMOTE_IGNITE, WorldObject::GetCreaturesWithEntryInRange(), AuraScript::GetTarget(), Unit::IsInCombat(), Unit::Kill(), NPC_CORE_HOUND, REACT_AGGRESSIVE, Unit::RemoveAurasDueToSpell(), Object::RemoveDynamicFlag(), Unit::RemoveUnitFlag2(), Unit::SetControlled(), Creature::SetReactState(), SPELL_FIRE_NOVA_VISUAL, SPELL_FULL_HEALTH, SPELL_PLAY_DEAD_PACIFY, Object::ToCreature(), UNIT_DYNFLAG_DEAD, UNIT_FLAG2_FEIGN_DEATH, and UNIT_STATE_ROOT.

Referenced by Register().

◆ Load()

bool spell_mc_play_dead_aura::Load ( )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

131 {
132 return GetCaster()->IsCreature();
133 }
bool IsCreature() const
Definition: Object.h:201
Unit * GetCaster() const
Definition: SpellScript.cpp:1020

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

◆ PrepareAuraScript()

spell_mc_play_dead_aura::PrepareAuraScript ( spell_mc_play_dead_aura  )
private

◆ Register()

void spell_mc_play_dead_aura::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

207 {
210 }
@ SPELL_AURA_FEIGN_DEATH
Definition: SpellAuraDefines.h:129
@ AURA_EFFECT_HANDLE_REAL
Definition: SpellAuraDefines.h:42
#define AuraEffectApplyFn(F, I, N, M)
Definition: SpellScript.h:743
@ EFFECT_0
Definition: SharedDefines.h:31
HookList< EffectApplyHandler > AfterEffectRemove
Definition: SpellScript.h:753
HookList< EffectApplyHandler > AfterEffectApply
Definition: SpellScript.h:742
void HandleEffectRemove(AuraEffect const *, AuraEffectHandleModes)
Definition: molten_core.cpp:153
void HandleEffectApply(AuraEffect const *, AuraEffectHandleModes)
Definition: molten_core.cpp:135

References AuraScript::AfterEffectApply, AuraScript::AfterEffectRemove, AURA_EFFECT_HANDLE_REAL, AuraEffectApplyFn, EFFECT_0, HandleEffectApply(), HandleEffectRemove(), and SPELL_AURA_FEIGN_DEATH.

◆ Validate()

bool spell_mc_play_dead_aura::Validate ( SpellInfo const *  )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

126 {
128 }
@ SPELL_PLAY_DEAD
Definition: molten_core.cpp:35
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Definition: SpellScript.h:125

References SPELL_PLAY_DEAD, SPELL_PLAY_DEAD_PACIFY, and _SpellScript::ValidateSpellInfo().