From 1bafe0b6b36ae64171d3fbd9b5b5c54f00c9c1a7 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Wed, 5 Apr 2023 10:30:13 -0400 Subject: [PATCH] [Cleanup] other is always defined in these cases in attack.cpp (#3217) # Notes - `other` is always defined since we check it prior to checking here. --- zone/attack.cpp | 103 +++++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 50 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index 6a2110389..ba2d490be 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -1473,7 +1473,7 @@ bool Mob::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool SetTarget(other); } - LogCombatDetail("Attacking [{}] with hand [{}] [{}]", other ? other->GetName() : "nullptr", Hand, bRiposte ? "this is a riposte" : ""); + LogCombatDetail("Attacking [{}] with hand [{}] [{}]", other->GetName(), Hand, bRiposte ? "this is a riposte" : ""); if ( (IsCasting() && GetClass() != BARD && !IsFromSpell) @@ -2110,14 +2110,16 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool //Check that we can attack before we calc heading and face our target if (!IsAttackAllowed(other)) { - if (GetOwnerID()) + if (GetOwnerID()) { SayString(NOT_LEGAL_TARGET); - if (other) { - if (other->IsClient()) - other->CastToClient()->RemoveXTarget(this, false); - RemoveFromHateList(other); - LogCombat("I am not allowed to attack [{}]", other->GetName()); } + + if (other->IsClient()) { + other->CastToClient()->RemoveXTarget(this, false); + } + + RemoveFromHateList(other); + LogCombat("I am not allowed to attack [{}]", other->GetName()); return false; } @@ -2131,17 +2133,19 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool my_hit.skill = static_cast(GetPrimSkill()); OffHandAtk(false); } + if (Hand == EQ::invslot::slotSecondary) { my_hit.skill = static_cast(GetSecSkill()); OffHandAtk(true); } //figure out what weapon they are using, if any - const EQ::ItemData* weapon = nullptr; - if (Hand == EQ::invslot::slotPrimary && equipment[EQ::invslot::slotPrimary] > 0) + const EQ::ItemData *weapon = nullptr; + if (Hand == EQ::invslot::slotPrimary && equipment[EQ::invslot::slotPrimary] > 0) { weapon = database.GetItem(equipment[EQ::invslot::slotPrimary]); - else if (equipment[EQ::invslot::slotSecondary]) + } else if (equipment[EQ::invslot::slotSecondary]) { weapon = database.GetItem(equipment[EQ::invslot::slotSecondary]); + } //We dont factor much from the weapon into the attack. //Just the skill type so it doesn't look silly using punching animations and stuff while wielding weapons @@ -2154,34 +2158,34 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool } switch (weapon->ItemType) { - case EQ::item::ItemType1HSlash: - my_hit.skill = EQ::skills::Skill1HSlashing; - break; - case EQ::item::ItemType2HSlash: - my_hit.skill = EQ::skills::Skill2HSlashing; - break; - case EQ::item::ItemType1HPiercing: - my_hit.skill = EQ::skills::Skill1HPiercing; - break; - case EQ::item::ItemType2HPiercing: - my_hit.skill = EQ::skills::Skill2HPiercing; - break; - case EQ::item::ItemType1HBlunt: - my_hit.skill = EQ::skills::Skill1HBlunt; - break; - case EQ::item::ItemType2HBlunt: - my_hit.skill = EQ::skills::Skill2HBlunt; - break; - case EQ::item::ItemTypeBow: - my_hit.skill = EQ::skills::SkillArchery; - break; - case EQ::item::ItemTypeLargeThrowing: - case EQ::item::ItemTypeSmallThrowing: - my_hit.skill = EQ::skills::SkillThrowing; - break; - default: - my_hit.skill = EQ::skills::SkillHandtoHand; - break; + case EQ::item::ItemType1HSlash: + my_hit.skill = EQ::skills::Skill1HSlashing; + break; + case EQ::item::ItemType2HSlash: + my_hit.skill = EQ::skills::Skill2HSlashing; + break; + case EQ::item::ItemType1HPiercing: + my_hit.skill = EQ::skills::Skill1HPiercing; + break; + case EQ::item::ItemType2HPiercing: + my_hit.skill = EQ::skills::Skill2HPiercing; + break; + case EQ::item::ItemType1HBlunt: + my_hit.skill = EQ::skills::Skill1HBlunt; + break; + case EQ::item::ItemType2HBlunt: + my_hit.skill = EQ::skills::Skill2HBlunt; + break; + case EQ::item::ItemTypeBow: + my_hit.skill = EQ::skills::SkillArchery; + break; + case EQ::item::ItemTypeLargeThrowing: + case EQ::item::ItemTypeSmallThrowing: + my_hit.skill = EQ::skills::SkillThrowing; + break; + default: + my_hit.skill = EQ::skills::SkillHandtoHand; + break; } } @@ -2194,6 +2198,7 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool if (!mob) { continue; } + if (mob->IsNPC() && mob->CastToNPC()->IsGuard()) { float distance = Distance(other->GetPosition(), mob->GetPosition()); if ((mob->CheckLosFN(other) || mob->CheckLosFN(this)) && distance <= 70) { @@ -2910,19 +2915,17 @@ void Mob::AddToHateList(Mob* other, int64 hate /*= 0*/, int64 damage /*= 0*/, bo Mob* targetmob = GetTarget(); bool on_hatelist = CheckAggro(other); - if (other) { - AddRampage(other); - if (on_hatelist) { // odd reason, if you're not on the hate list, subtlety etc don't apply! - // Spell Casting Subtlety etc - int64 hatemod = 100 + other->spellbonuses.hatemod + other->itembonuses.hatemod + other->aabonuses.hatemod; + AddRampage(other); + if (on_hatelist) { // odd reason, if you're not on the hate list, subtlety etc don't apply! + // Spell Casting Subtlety etc + int64 hatemod = 100 + other->spellbonuses.hatemod + other->itembonuses.hatemod + other->aabonuses.hatemod; - if (hatemod < 1) - hatemod = 1; - hate = ((hate * (hatemod)) / 100); - } - else { - hate += 100; // 100 bonus initial aggro - } + if (hatemod < 1) + hatemod = 1; + hate = ((hate * (hatemod)) / 100); + } + else { + hate += 100; // 100 bonus initial aggro } // Pet that is /pet hold on will not add to their hate list if they're not engaged