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

Private Member Functions

 PrepareSpellScript (spell_dk_raise_ally)
 
SpellCastResult CheckCast ()
 
void HandleDummy (SpellEffIndex)
 
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

◆ CheckCast()

SpellCastResult spell_dk_raise_ally::CheckCast ( )
inlineprivate
150 {
151 Player* unitTarget = GetHitPlayer();
152 if (!unitTarget)
154
155 if (unitTarget->IsAlive()) // not discovered attributeEx5?
157
158 return SPELL_CAST_OK;
159 }
@ SPELL_FAILED_TARGET_NOT_DEAD
Definition: SharedDefines.h:1068
@ SPELL_FAILED_BAD_TARGETS
Definition: SharedDefines.h:961
@ SPELL_CAST_OK
Definition: SharedDefines.h:1138
Definition: Player.h:1081
bool IsAlive() const
Definition: Unit.h:1654
Player * GetHitPlayer()
Definition: SpellScript.cpp:471

References SpellScript::GetHitPlayer(), Unit::IsAlive(), SPELL_CAST_OK, SPELL_FAILED_BAD_TARGETS, and SPELL_FAILED_TARGET_NOT_DEAD.

Referenced by Register().

◆ HandleDummy()

void spell_dk_raise_ally::HandleDummy ( SpellEffIndex  )
inlineprivate
162 {
163 if (Player* unitTarget = GetHitPlayer())
164 {
165 unitTarget->CastSpell(unitTarget, GetEffectValue(), true);
166 if (Unit* ghoul = unitTarget->GetCharm())
167 {
168 //health, mana, armor and resistance
169 PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(ghoul->GetEntry(), ghoul->GetLevel());
170 if (pInfo) // exist in DB
171 {
172 ghoul->SetCreateHealth(pInfo->health);
173 ghoul->SetModifierValue(UNIT_MOD_HEALTH, BASE_VALUE, pInfo->health);
174 ghoul->SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(pInfo->armor));
175 for (uint8 stat = 0; stat < MAX_STATS; ++stat)
176 ghoul->SetCreateStat(Stats(stat), float(pInfo->stats[stat]));
177 }
178
179 ghoul->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(ghoul->GetLevel() - (ghoul->GetLevel() / 4)));
180 ghoul->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(ghoul->GetLevel() + (ghoul->GetLevel() / 4)));
181
182 // Avoidance, Night of the Dead
183 if (Aura* aur = ghoul->AddAura(62137, ghoul))
184 if (AuraEffect* aurEff = GetCaster()->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_DEATHKNIGHT, 2718, 0))
185 if (aur->GetEffect(0))
186 aur->GetEffect(0)->SetAmount(-aurEff->GetSpellInfo()->Effects[EFFECT_2].CalcValue());
187
188 // Hit / Expertise scalling, warlock / hunter pets have this by default
189 ghoul->AddAura(SPELL_HUNTER_PET_SCALING_04, ghoul);
190
191 // DK Ghoul haste refresh
192 float val = (GetCaster()->m_modAttackSpeedPct[BASE_ATTACK] - 1.0f) * 100.0f;
193 ghoul->m_modAttackSpeedPct[BASE_ATTACK] = GetCaster()->m_modAttackSpeedPct[BASE_ATTACK];
194 ghoul->SetFloatValue(UNIT_FIELD_BASEATTACKTIME, 2000.0f);
195 ghoul->ApplyPercentModFloatValue(UNIT_FIELD_BASEATTACKTIME, val, true); // we want to reduce attack time
196
197 // Strength + Stamina
198 for (uint8 i = STAT_STRENGTH; i <= STAT_STAMINA; ++i)
199 {
200 Stats stat = Stats(i);
201 if (stat != STAT_STRENGTH && stat != STAT_STAMINA)
202 continue;
203
204 float value = 0.0f;
205 float mod = (stat == STAT_STAMINA ? 0.3f : 0.7f);
206
207 // Check just if owner has Ravenous Dead since it's effect is not an aura
209 if (aurEff)
210 {
211 SpellInfo const* spellInfo = aurEff->GetSpellInfo(); // Then get the SpellProto and add the dummy effect value
212 AddPct(mod, spellInfo->Effects[EFFECT_1].CalcValue()); // Ravenous Dead edits the original scale
213 }
214 // Glyph of the Ghoul
216 if (aurEff)
217 mod += CalculatePct(1.0f, aurEff->GetAmount()); // Glyph of the Ghoul adds a flat value to the scale mod
218
219 value = float(GetCaster()->GetStat(stat)) * mod;
220 value = ghoul->GetTotalStatValue(stat, value);
221 ghoul->SetStat(stat, int32(value));
222 ghoul->ApplyStatBuffMod(stat, value, true);
223 }
224
225 // Attack Power
226 ghoul->SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, 589 + ghoul->GetStat(STAT_STRENGTH) + ghoul->GetStat(STAT_AGILITY));
227 ghoul->SetInt32Value(UNIT_FIELD_ATTACK_POWER, (int32)ghoul->GetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE) * ghoul->GetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_PCT));
228 ghoul->SetInt32Value(UNIT_FIELD_ATTACK_POWER_MODS, (int32)ghoul->GetModifierValue(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE));
229 ghoul->SetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER, ghoul->GetModifierValue(UNIT_MOD_ATTACK_POWER, TOTAL_PCT) - 1.0f);
230
231 // Health
232 ghoul->SetModifierValue(UNIT_MOD_HEALTH, TOTAL_VALUE, (ghoul->GetStat(STAT_STAMINA) - ghoul->GetCreateStat(STAT_STAMINA)) * 10.0f);
233
234 // Power Energy
235 ghoul->SetModifierValue(UnitMods(UNIT_MOD_POWER_START + static_cast<uint8>(POWER_ENERGY)), BASE_VALUE, ghoul->GetCreatePowers(POWER_ENERGY));
236 ghoul->UpdateAllStats();
237 ghoul->SetFullHealth();
238
239 // Aura Immunities
241 ghoul->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MELEE_SLOW, true, SPELL_BLOCK_TYPE_POSITIVE);
242 ghoul->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_STAT, true, SPELL_BLOCK_TYPE_POSITIVE);
244 ghoul->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_ATTACK_POWER, true, SPELL_BLOCK_TYPE_POSITIVE);
246 }
247 }
248 }
T AddPct(T &base, U pct)
Definition: Util.h:67
T CalculatePct(T base, U pct)
Definition: Util.h:61
std::int32_t int32
Definition: Define.h:103
std::uint8_t uint8
Definition: Define.h:109
@ SPELL_DK_GLYPH_OF_THE_GHOUL
Definition: spell_dk.cpp:39
@ EFFECT_1
Definition: SharedDefines.h:32
@ EFFECT_0
Definition: SharedDefines.h:31
@ EFFECT_2
Definition: SharedDefines.h:33
#define MAX_STATS
Definition: SharedDefines.h:265
@ POWER_ENERGY
Definition: SharedDefines.h:272
@ IMMUNITY_STATE
Definition: SharedDefines.h:1395
@ SPELLFAMILY_DEATHKNIGHT
Definition: SharedDefines.h:3543
Stats
Definition: SharedDefines.h:257
@ STAT_AGILITY
Definition: SharedDefines.h:259
@ STAT_STRENGTH
Definition: SharedDefines.h:258
@ STAT_STAMINA
Definition: SharedDefines.h:260
#define sObjectMgr
Definition: ObjectMgr.h:1635
@ SPELL_BLOCK_TYPE_POSITIVE
Definition: SpellDefines.h:160
@ SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
Definition: SpellAuraDefines.h:200
@ SPELL_AURA_MOD_ATTACK_POWER
Definition: SpellAuraDefines.h:162
@ SPELL_AURA_MELEE_SLOW
Definition: SpellAuraDefines.h:256
@ SPELL_AURA_ADD_FLAT_MODIFIER
Definition: SpellAuraDefines.h:170
@ SPELL_AURA_MOD_STAT
Definition: SpellAuraDefines.h:92
@ SPELL_AURA_MOD_MELEE_RANGED_HASTE
Definition: SpellAuraDefines.h:255
@ SPELL_AURA_MOD_ATTACK_POWER_PCT
Definition: SpellAuraDefines.h:229
@ UNIT_FIELD_ATTACK_POWER_MODS
Definition: UpdateFields.h:163
@ UNIT_FIELD_ATTACK_POWER_MULTIPLIER
Definition: UpdateFields.h:164
@ UNIT_FIELD_ATTACK_POWER
Definition: UpdateFields.h:162
@ UNIT_FIELD_BASEATTACKTIME
Definition: UpdateFields.h:120
@ MINDAMAGE
Definition: Unit.h:135
@ MAXDAMAGE
Definition: Unit.h:136
UnitMods
Definition: Unit.h:142
@ UNIT_MOD_ARMOR
Definition: Unit.h:156
@ UNIT_MOD_ATTACK_POWER
Definition: Unit.h:163
@ UNIT_MOD_HEALTH
Definition: Unit.h:148
@ UNIT_MOD_POWER_START
Definition: Unit.h:174
@ BASE_ATTACK
Definition: Unit.h:209
@ BASE_VALUE
Definition: Unit.h:126
@ TOTAL_VALUE
Definition: Unit.h:128
@ TOTAL_PCT
Definition: Unit.h:129
@ BASE_PCT
Definition: Unit.h:127
@ SPELL_HUNTER_PET_SCALING_04
Definition: PetDefines.h:141
Definition: Unit.h:630
Unit * GetCharm() const
Definition: Unit.cpp:10671
float m_modAttackSpeedPct[3]
Definition: Unit.h:1953
AuraEffect * GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID=ObjectGuid::Empty) const
Definition: Unit.cpp:5494
Definition: ObjectMgr.h:528
uint32 health
Definition: ObjectMgr.h:535
std::array< uint32, MAX_STATS > stats
Definition: ObjectMgr.h:534
uint32 armor
Definition: ObjectMgr.h:537
Definition: SpellAuraEffects.h:39
SpellInfo const * GetSpellInfo() const
Definition: SpellAuraEffects.h:54
int32 GetAmount() const
Definition: SpellAuraEffects.h:64
Definition: SpellAuras.h:87
Definition: SpellInfo.h:316
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition: SpellInfo.h:393
int32 GetEffectValue() const
Definition: SpellScript.cpp:600
Unit * GetCaster()
Definition: SpellScript.cpp:401

References AddPct(), PetLevelInfo::armor, BASE_ATTACK, BASE_PCT, BASE_VALUE, CalculatePct(), EFFECT_0, EFFECT_1, EFFECT_2, SpellInfo::Effects, AuraEffect::GetAmount(), Unit::GetAuraEffect(), SpellScript::GetCaster(), Unit::GetCharm(), SpellScript::GetEffectValue(), SpellScript::GetHitPlayer(), AuraEffect::GetSpellInfo(), PetLevelInfo::health, IMMUNITY_STATE, Unit::m_modAttackSpeedPct, MAX_STATS, MAXDAMAGE, MINDAMAGE, POWER_ENERGY, sObjectMgr, SPELL_AURA_ADD_FLAT_MODIFIER, SPELL_AURA_MELEE_SLOW, SPELL_AURA_MOD_ATTACK_POWER, SPELL_AURA_MOD_ATTACK_POWER_PCT, SPELL_AURA_MOD_MELEE_RANGED_HASTE, SPELL_AURA_MOD_STAT, SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, SPELL_BLOCK_TYPE_POSITIVE, SPELL_DK_GLYPH_OF_THE_GHOUL, SPELL_HUNTER_PET_SCALING_04, SPELLFAMILY_DEATHKNIGHT, STAT_AGILITY, STAT_STAMINA, STAT_STRENGTH, PetLevelInfo::stats, TOTAL_PCT, TOTAL_VALUE, UNIT_FIELD_ATTACK_POWER, UNIT_FIELD_ATTACK_POWER_MODS, UNIT_FIELD_ATTACK_POWER_MULTIPLIER, UNIT_FIELD_BASEATTACKTIME, UNIT_MOD_ARMOR, UNIT_MOD_ATTACK_POWER, UNIT_MOD_HEALTH, and UNIT_MOD_POWER_START.

Referenced by Register().

◆ PrepareSpellScript()

spell_dk_raise_ally::PrepareSpellScript ( spell_dk_raise_ally  )
private

◆ Register()

void spell_dk_raise_ally::Register ( )
inlineoverrideprivatevirtual

Implements _SpellScript.

251 {
254 }
@ SPELL_EFFECT_DUMMY
Definition: SharedDefines.h:781
#define SpellCheckCastFn(F)
Definition: SpellScript.h:329
#define SpellEffectFn(F, I, N)
Definition: SpellScript.h:337
HookList< CheckCastHandler > OnCheckCast
Definition: SpellScript.h:328
HookList< EffectHandler > OnEffectHitTarget
Definition: SpellScript.h:336
SpellCastResult CheckCast()
Definition: spell_dk.cpp:149
void HandleDummy(SpellEffIndex)
Definition: spell_dk.cpp:161

References CheckCast(), EFFECT_0, HandleDummy(), SpellScript::OnCheckCast, SpellScript::OnEffectHitTarget, SPELL_EFFECT_DUMMY, SpellCheckCastFn, and SpellEffectFn.