fix(Core/Spells): possible crashes within class spells (#9168)

This commit is contained in:
Nefertumm
2021-11-21 11:41:51 -03:00
committed by GitHub
parent 92b3617f63
commit 61c7488698
9 changed files with 66 additions and 25 deletions

View File

@@ -444,7 +444,7 @@ class spell_dk_improved_blood_presence_proc : public AuraScript
bool CheckProc(ProcEventInfo& eventInfo)
{
return eventInfo.GetDamageInfo()->GetDamage();
return eventInfo.GetDamageInfo() && eventInfo.GetDamageInfo()->GetDamage();
}
void Register() override
@@ -461,7 +461,7 @@ class spell_dk_wandering_plague_aura : public AuraScript
bool CheckProc(ProcEventInfo& eventInfo)
{
const SpellInfo* spellInfo = eventInfo.GetSpellInfo();
if (!spellInfo || !eventInfo.GetActionTarget() || !eventInfo.GetDamageInfo())
if (!spellInfo || !eventInfo.GetActionTarget() || !eventInfo.GetDamageInfo() || !eventInfo.GetActor())
return false;
if (!roll_chance_f(eventInfo.GetActor()->GetUnitCriticalChance(BASE_ATTACK, eventInfo.GetActionTarget())))
@@ -548,7 +548,7 @@ class spell_dk_blood_caked_blade : public AuraScript
bool CheckProc(ProcEventInfo& eventInfo)
{
return eventInfo.GetActionTarget() && eventInfo.GetActionTarget()->IsAlive();
return eventInfo.GetActionTarget() && eventInfo.GetActionTarget()->IsAlive() && eventInfo.GetActor();
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)

View File

@@ -601,6 +601,12 @@ class spell_dru_living_seed : public AuraScript
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
PreventDefaultAction();
if (!eventInfo.GetHealInfo() || !eventInfo.GetProcTarget())
{
return;
}
int32 amount = CalculatePct(eventInfo.GetHealInfo()->GetHeal(), aurEff->GetAmount());
GetTarget()->CastCustomSpell(SPELL_DRUID_LIVING_SEED_PROC, SPELLVALUE_BASE_POINT0, amount, eventInfo.GetProcTarget(), true, nullptr, aurEff);
}

View File

@@ -743,11 +743,16 @@ class spell_gen_proc_once_per_cast : public AuraScript
bool CheckProc(ProcEventInfo& eventInfo)
{
if (Player* player = eventInfo.GetActor()->ToPlayer())
if (eventInfo.GetActor())
{
if (player->m_spellModTakingSpell == _spellPointer)
return false;
_spellPointer = player->m_spellModTakingSpell;
if (Player* player = eventInfo.GetActor()->ToPlayer())
{
if (player->m_spellModTakingSpell == _spellPointer)
{
return false;
}
_spellPointer = player->m_spellModTakingSpell;
}
}
return true;
}

View File

@@ -706,12 +706,17 @@ class spell_hun_sniper_training : public AuraScript
PreventDefaultAction();
if (aurEff->GetAmount() <= 0)
{
Unit* caster = GetCaster();
uint32 spellId = SPELL_HUNTER_SNIPER_TRAINING_BUFF_R1 + GetId() - SPELL_HUNTER_SNIPER_TRAINING_R1;
if (Unit* target = GetTarget())
if (!GetCaster() || !GetTarget())
{
SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(spellId);
Unit* triggerCaster = triggeredSpellInfo->NeedsToBeTriggeredByCaster(GetSpellInfo()) ? caster : target;
return;
}
Unit* target = GetTarget();
uint32 spellId = SPELL_HUNTER_SNIPER_TRAINING_BUFF_R1 + GetId() - SPELL_HUNTER_SNIPER_TRAINING_R1;
if (SpellInfo const* triggeredSpellInfo = sSpellMgr->GetSpellInfo(spellId))
{
Unit* triggerCaster = triggeredSpellInfo->NeedsToBeTriggeredByCaster(GetSpellInfo()) ? GetCaster() : target;
triggerCaster->CastSpell(target, triggeredSpellInfo, true, 0, aurEff);
}
}
@@ -1119,7 +1124,7 @@ class spell_hun_lock_and_load : public AuraScript
bool CheckTrapProc(ProcEventInfo& eventInfo)
{
SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
if (!spellInfo)
if (!spellInfo || !eventInfo.GetActor())
{
return false;
}

View File

@@ -156,6 +156,11 @@ class spell_mage_molten_armor : public AuraScript
if (!spellInfo || (eventInfo.GetTypeMask() & PROC_FLAG_TAKEN_MELEE_AUTO_ATTACK))
return true;
if (!eventInfo.GetActionTarget())
{
return false;
}
// Xinef: Molten Shields talent
if (AuraEffect* aurEff = eventInfo.GetActionTarget()->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_MAGE, 16, EFFECT_0))
return roll_chance_i(aurEff->GetSpellInfo()->GetRank() * 50);
@@ -803,7 +808,7 @@ class spell_mage_master_of_elements : public AuraScript
bool CheckProc(ProcEventInfo& eventInfo)
{
_spellInfo = eventInfo.GetSpellInfo();
if (!_spellInfo)
if (!_spellInfo || !eventInfo.GetActor() || !eventInfo.GetActionTarget())
{
return false;
}

View File

@@ -94,6 +94,11 @@ class spell_pal_seal_of_command_aura : public AuraScript
bool CheckProc(ProcEventInfo& eventInfo)
{
if (!eventInfo.GetActor() || !eventInfo.GetActionTarget())
{
return false;
}
if (const SpellInfo* procSpell = eventInfo.GetSpellInfo())
{
if (procSpell->SpellIconID == 3025) // Righteous Vengeance, should not proc SoC
@@ -117,12 +122,10 @@ class spell_pal_seal_of_command_aura : public AuraScript
}
}
if (Unit* target = eventInfo.GetActionTarget())
Unit* target = eventInfo.GetActionTarget();
if (target->IsAlive())
{
if (target->IsAlive())
{
eventInfo.GetActor()->CastCustomSpell(aurEff->GetSpellInfo()->Effects[EFFECT_0].TriggerSpell, SPELLVALUE_MAX_TARGETS, targets, target, false, nullptr, aurEff);
}
eventInfo.GetActor()->CastCustomSpell(aurEff->GetSpellInfo()->Effects[EFFECT_0].TriggerSpell, SPELLVALUE_MAX_TARGETS, targets, target, false, nullptr, aurEff);
}
}

View File

@@ -658,6 +658,11 @@ class spell_sha_earthliving_weapon : public AuraScript
{
auto chance = 20;
Unit* caster = eventInfo.GetActor();
if (!caster || !eventInfo.GetProcTarget())
{
return false;
}
if (AuraEffect const* aurEff = caster->GetAuraEffectOfRankedSpell(SPELL_SHAMAN_BLESSING_OF_THE_ETERNALS_R1, EFFECT_1, caster->GetGUID()))
{
if (eventInfo.GetProcTarget()->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT))

View File

@@ -1142,12 +1142,14 @@ class spell_warl_drain_soul : public AuraScript
{
PreventDefaultAction();
Unit* caster = eventInfo.GetActor();
// Improved Drain Soul.
if (Aura const* impDrainSoul = caster->GetAuraOfRankedSpell(SPELL_WARLOCK_IMPROVED_DRAIN_SOUL_R1, caster->GetGUID()))
if (Unit* caster = eventInfo.GetActor())
{
int32 amount = CalculatePct(caster->GetMaxPower(POWER_MANA), impDrainSoul->GetSpellInfo()->Effects[EFFECT_2].CalcValue());
caster->CastCustomSpell(SPELL_WARLOCK_IMPROVED_DRAIN_SOUL_PROC, SPELLVALUE_BASE_POINT0, amount, caster, true, nullptr, aurEff, caster->GetGUID());
// Improved Drain Soul.
if (Aura const* impDrainSoul = caster->GetAuraOfRankedSpell(SPELL_WARLOCK_IMPROVED_DRAIN_SOUL_R1, caster->GetGUID()))
{
int32 amount = CalculatePct(caster->GetMaxPower(POWER_MANA), impDrainSoul->GetSpellInfo()->Effects[EFFECT_2].CalcValue());
caster->CastCustomSpell(SPELL_WARLOCK_IMPROVED_DRAIN_SOUL_PROC, SPELLVALUE_BASE_POINT0, amount, caster, true, nullptr, aurEff, caster->GetGUID());
}
}
}

View File

@@ -150,7 +150,7 @@ class spell_warr_improved_spell_reflection : public AuraScript
bool CheckProc(ProcEventInfo& eventInfo)
{
return eventInfo.GetSpellInfo() && eventInfo.GetSpellInfo()->Id == SPELL_WARRIOR_SPELL_REFLECTION;
return eventInfo.GetSpellInfo() && eventInfo.GetActor() && eventInfo.GetSpellInfo()->Id == SPELL_WARRIOR_SPELL_REFLECTION;
}
void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
@@ -623,6 +623,11 @@ class spell_warr_sweeping_strikes : public AuraScript
bool CheckProc(ProcEventInfo& eventInfo)
{
if (!eventInfo.GetActor() || eventInfo.GetProcTarget())
{
return false;
}
_procTarget = eventInfo.GetActor()->SelectNearbyNoTotemTarget(eventInfo.GetProcTarget());
DamageInfo* damageInfo = eventInfo.GetDamageInfo();
@@ -801,6 +806,11 @@ class spell_warr_retaliation : public AuraScript
bool CheckProc(ProcEventInfo& eventInfo)
{
if (!eventInfo.GetActor() || !eventInfo.GetProcTarget())
{
return false;
}
// check attack comes not from behind and warrior is not stunned
return GetTarget()->isInFront(eventInfo.GetActor(), M_PI) && !GetTarget()->HasUnitState(UNIT_STATE_STUNNED);
}