[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.
This commit is contained in:
Alex King 2023-04-05 10:30:13 -04:00 committed by GitHub
parent 82762c3f5a
commit 1bafe0b6b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1473,7 +1473,7 @@ bool Mob::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool
SetTarget(other); 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 ( if (
(IsCasting() && GetClass() != BARD && !IsFromSpell) (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 //Check that we can attack before we calc heading and face our target
if (!IsAttackAllowed(other)) { if (!IsAttackAllowed(other)) {
if (GetOwnerID()) if (GetOwnerID()) {
SayString(NOT_LEGAL_TARGET); SayString(NOT_LEGAL_TARGET);
if (other) { }
if (other->IsClient())
if (other->IsClient()) {
other->CastToClient()->RemoveXTarget(this, false); other->CastToClient()->RemoveXTarget(this, false);
}
RemoveFromHateList(other); RemoveFromHateList(other);
LogCombat("I am not allowed to attack [{}]", other->GetName()); LogCombat("I am not allowed to attack [{}]", other->GetName());
}
return false; return false;
} }
@ -2131,6 +2133,7 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool
my_hit.skill = static_cast<EQ::skills::SkillType>(GetPrimSkill()); my_hit.skill = static_cast<EQ::skills::SkillType>(GetPrimSkill());
OffHandAtk(false); OffHandAtk(false);
} }
if (Hand == EQ::invslot::slotSecondary) { if (Hand == EQ::invslot::slotSecondary) {
my_hit.skill = static_cast<EQ::skills::SkillType>(GetSecSkill()); my_hit.skill = static_cast<EQ::skills::SkillType>(GetSecSkill());
OffHandAtk(true); OffHandAtk(true);
@ -2138,10 +2141,11 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool
//figure out what weapon they are using, if any //figure out what weapon they are using, if any
const EQ::ItemData *weapon = nullptr; const EQ::ItemData *weapon = nullptr;
if (Hand == EQ::invslot::slotPrimary && equipment[EQ::invslot::slotPrimary] > 0) if (Hand == EQ::invslot::slotPrimary && equipment[EQ::invslot::slotPrimary] > 0) {
weapon = database.GetItem(equipment[EQ::invslot::slotPrimary]); 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]); weapon = database.GetItem(equipment[EQ::invslot::slotSecondary]);
}
//We dont factor much from the weapon into the attack. //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 //Just the skill type so it doesn't look silly using punching animations and stuff while wielding weapons
@ -2194,6 +2198,7 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool
if (!mob) { if (!mob) {
continue; continue;
} }
if (mob->IsNPC() && mob->CastToNPC()->IsGuard()) { if (mob->IsNPC() && mob->CastToNPC()->IsGuard()) {
float distance = Distance(other->GetPosition(), mob->GetPosition()); float distance = Distance(other->GetPosition(), mob->GetPosition());
if ((mob->CheckLosFN(other) || mob->CheckLosFN(this)) && distance <= 70) { if ((mob->CheckLosFN(other) || mob->CheckLosFN(this)) && distance <= 70) {
@ -2910,7 +2915,6 @@ void Mob::AddToHateList(Mob* other, int64 hate /*= 0*/, int64 damage /*= 0*/, bo
Mob* targetmob = GetTarget(); Mob* targetmob = GetTarget();
bool on_hatelist = CheckAggro(other); bool on_hatelist = CheckAggro(other);
if (other) {
AddRampage(other); AddRampage(other);
if (on_hatelist) { // odd reason, if you're not on the hate list, subtlety etc don't apply! if (on_hatelist) { // odd reason, if you're not on the hate list, subtlety etc don't apply!
// Spell Casting Subtlety etc // Spell Casting Subtlety etc
@ -2923,7 +2927,6 @@ void Mob::AddToHateList(Mob* other, int64 hate /*= 0*/, int64 damage /*= 0*/, bo
else { else {
hate += 100; // 100 bonus initial aggro hate += 100; // 100 bonus initial aggro
} }
}
// Pet that is /pet hold on will not add to their hate list if they're not engaged // Pet that is /pet hold on will not add to their hate list if they're not engaged
// Pet that is /pet hold on and /pet focus on will not add others to their hate list // Pet that is /pet hold on and /pet focus on will not add others to their hate list