[Crash] Fix crash in Mob::CommonDamage when attacker was null (#2872)

This commit is contained in:
Aeadoin 2023-02-13 00:53:29 -05:00 committed by GitHub
parent ca0e85b4bc
commit 24de1d948a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3930,6 +3930,7 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
parse->HasQuestSub(CastToNPC()->GetNPCTypeID(), EVENT_DAMAGE_GIVEN)
) ||
(
attacker &&
attacker->IsNPC() &&
parse->HasQuestSub(attacker->CastToNPC()->GetNPCTypeID(), EVENT_DAMAGE_GIVEN)
)
@ -3941,6 +3942,7 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
parse->HasQuestSub(CastToNPC()->GetNPCTypeID(), EVENT_DAMAGE_TAKEN)
) ||
(
attacker &&
attacker->IsNPC() &&
parse->HasQuestSub(attacker->CastToNPC()->GetNPCTypeID(), EVENT_DAMAGE_TAKEN)
)
@ -4070,7 +4072,7 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
bool is_immune_to_frontal_stun = false;
if (IsBot() || IsClient() || IsMerc()) {
if (IsOfClientBotMerc()) {
if (
IsPlayerClass(GetClass()) &&
RuleI(Combat, FrontalStunImmunityClasses) & GetPlayerClassBit(GetClass())
@ -4206,10 +4208,11 @@ void Mob::CommonDamage(Mob* attacker, int64 &damage, const uint16 spell_id, cons
(IsClient() || zone->random.Roll(RuleI(Combat, MeleePushChance)))) {
a->force = EQ::skills::GetSkillMeleePushForce(skill_used);
if (IsNPC()) {
if (attacker->IsNPC())
if (attacker && attacker->IsNPC()) {
a->force = 0.0f; // 2013 change that disabled NPC vs NPC push
else
} else {
a->force *= 0.10f; // force against NPCs is divided by 10 I guess? ex bash is 0.3, parsed 0.03 against an NPC
}
if (ForcedMovement == 0 && a->force != 0.0f && position_update_melee_push_timer.Check()) {
m_Delta.x += a->force * g_Math.FastSin(a->hit_heading);
m_Delta.y += a->force * g_Math.FastCos(a->hit_heading);