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

Private Member Functions

 PrepareAuraScript (spell_mc_play_dead_AuraScript)
 
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::spell_mc_play_dead_AuraScript::HandleEffectApply ( AuraEffect const *  ,
AuraEffectHandleModes   
)
inlineprivate
135 {
136 Creature* creatureTarget = GetTarget()->ToCreature();
137 if (!creatureTarget)
138 {
139 return;
140 }
141
142 creatureTarget->CastSpell(creatureTarget, SPELL_PLAY_DEAD_PACIFY, true);
143 creatureTarget->SetDynamicFlag(UNIT_DYNFLAG_DEAD);
144 creatureTarget->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH);
145 //creatureTarget->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
146 creatureTarget->SetReactState(REACT_PASSIVE);
147 creatureTarget->SetControlled(true, UNIT_STATE_ROOT);
148
149 creatureTarget->AttackStop();
150 }
@ UNIT_FLAG2_FEIGN_DEATH
Definition: Unit.h:488
@ REACT_PASSIVE
Definition: Unit.h:1023
@ UNIT_STATE_ROOT
Definition: Unit.h:335
@ SPELL_PLAY_DEAD_PACIFY
Definition: molten_core.cpp:37
@ UNIT_DYNFLAG_DEAD
Definition: SharedDefines.h:3098
Definition: Creature.h:46
void SetReactState(ReactStates st)
Definition: Creature.h:89
virtual void SetDynamicFlag(uint32 flag)
Definition: Object.h:117
Creature * ToCreature()
Definition: Object.h:197
void SetUnitFlag2(UnitFlags2 flags)
Definition: Unit.h:1487
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
bool AttackStop()
Definition: Unit.cpp:10368
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::spell_mc_play_dead_AuraScript::HandleEffectRemove ( AuraEffect const *  ,
AuraEffectHandleModes   
)
inlineprivate
153 {
154 Creature* creatureTarget = GetTarget()->ToCreature();
155 if (!creatureTarget)
156 {
157 return;
158 }
159
161 creatureTarget->RemoveDynamicFlag(UNIT_DYNFLAG_DEAD);
163 //creatureTarget->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
164 creatureTarget->SetControlled(false, UNIT_STATE_ROOT);
165 creatureTarget->SetReactState(REACT_AGGRESSIVE);
166
167 if (!creatureTarget->IsInCombat())
168 {
169 return;
170 }
171
172 bool shouldDie = true;
173 std::list<Creature*> hounds;
174 creatureTarget->GetCreaturesWithEntryInRange(hounds, 80.0f, NPC_CORE_HOUND);
175
176 // Perform lambda based check to find if there is any nearby
177 if (!hounds.empty())
178 {
179 // Alive hound been found within 80 yards -> cancel suicide
180 if (std::find_if(hounds.begin(), hounds.end(), [creatureTarget](Creature const* hound)
181 {
182 return creatureTarget != hound && creatureTarget->IsWithinLOSInMap(hound) && hound->IsAlive() && hound->IsInCombat() && !hound->HasAura(SPELL_PLAY_DEAD);
183 }) != hounds.end())
184 {
185 shouldDie = false;
186 }
187 }
188
189 if (!shouldDie)
190 {
191 if (CreatureAI* targetAI = creatureTarget->AI())
192 {
193 targetAI->DoCastSelf(SPELL_FIRE_NOVA_VISUAL, true);
194 targetAI->DoCastSelf(SPELL_FULL_HEALTH, true);
195 targetAI->Talk(EMOTE_IGNITE);
196 }
197 }
198 else
199 {
200 Unit::Kill(creatureTarget, creatureTarget);
201 creatureTarget->DespawnOrUnsummon(14000);
202 }
203 }
@ REACT_AGGRESSIVE
Definition: Unit.h:1025
@ SPELL_FULL_HEALTH
Definition: molten_core.cpp:35
@ SPELL_FIRE_NOVA_VISUAL
Definition: molten_core.cpp:36
@ EMOTE_IGNITE
Definition: molten_core.cpp:27
@ NPC_CORE_HOUND
Definition: molten_core.h:64
Definition: CreatureAI.h:70
void DespawnOrUnsummon(Milliseconds msTimeToDespawn, Seconds forcedRespawnTimer)
Definition: Creature.cpp:2108
CreatureAI * AI() const
Definition: Creature.h:135
virtual void RemoveDynamicFlag(uint32 flag)
Definition: Object.h:118
void GetCreaturesWithEntryInRange(std::list< Creature * > &creatureList, float radius, uint32 entry)
Definition: Object.cpp:3015
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:17862
void RemoveUnitFlag2(UnitFlags2 flags)
Definition: Unit.h:1488
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4835
bool IsInCombat() const
Definition: Unit.h:1688

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::spell_mc_play_dead_AuraScript::Load ( )
inlineoverrideprivatevirtual

Reimplemented from _SpellScript.

130 {
131 return GetCaster()->GetTypeId() == TYPEID_UNIT;
132 }
@ TYPEID_UNIT
Definition: ObjectGuid.h:37
TypeID GetTypeId() const
Definition: Object.h:121
Unit * GetCaster() const
Definition: SpellScript.cpp:1020

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

◆ PrepareAuraScript()

spell_mc_play_dead::spell_mc_play_dead_AuraScript::PrepareAuraScript ( spell_mc_play_dead_AuraScript  )
private

◆ Register()

void spell_mc_play_dead::spell_mc_play_dead_AuraScript::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

206 {
209 }
@ 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:30
HookList< EffectApplyHandler > AfterEffectRemove
Definition: SpellScript.h:753
HookList< EffectApplyHandler > AfterEffectApply
Definition: SpellScript.h:742
void HandleEffectApply(AuraEffect const *, AuraEffectHandleModes)
Definition: molten_core.cpp:134
void HandleEffectRemove(AuraEffect const *, AuraEffectHandleModes)
Definition: molten_core.cpp:152

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