Skip to content

Commit

Permalink
NPCBots: Fix expertise not being applied to melee abilities
Browse files Browse the repository at this point in the history
  • Loading branch information
trickerer committed Oct 21, 2024
1 parent 0f27085 commit 0d4207c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/server/game/AI/NpcBots/bot_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2208,9 +2208,10 @@ void bot_ai::_listAuras(Player const* player, Unit const* unit) const
botstring << "\n" << LocalizedNpcText(player, BOT_TEXT_REGEN_MP_CAST) << ": " << float((_botclass == BOT_CLASS_SPHYNX ? -1.f : 1.f) * me->GetFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER) * sWorld->getRate(RATE_POWER_MANA) * 5.0f);
botstring << "\n" << LocalizedNpcText(player, BOT_TEXT_REGEN_MP_NOCAST) << ": " << float((_botclass == BOT_CLASS_SPHYNX ? -1.f : 1.f) * me->GetFloatValue(UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER) * sWorld->getRate(RATE_POWER_MANA) * 5.0f);
}
int32 bot_expertise = expertise + me->GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE);
botstring << "\n" << LocalizedNpcText(player, BOT_TEXT_HASTE) << ": " << (haste >= 0 ? "+" : "-") << float(haste) << " " << LocalizedNpcText(player, BOT_TEXT_PCT);
botstring << "\n" << LocalizedNpcText(player, BOT_TEXT_HIT) << ": +" << float(hit) << " " << LocalizedNpcText(player, BOT_TEXT_PCT);
botstring << "\n" << LocalizedNpcText(player, BOT_TEXT_EXPERTISE) << ": " << int32(expertise) << " (-" << float(float(expertise) * 0.25f) << " " << LocalizedNpcText(player, BOT_TEXT_PCT) << ")";
botstring << "\n" << LocalizedNpcText(player, BOT_TEXT_EXPERTISE) << ": " << int32(bot_expertise) << " (-" << float(float(bot_expertise) * 0.25f) << " " << LocalizedNpcText(player, BOT_TEXT_PCT) << ")";
botstring << "\n" << LocalizedNpcText(player, BOT_TEXT_ARMOR_PEN) << ": " << float(me->GetCreatureArmorPenetrationCoef()) << " " << LocalizedNpcText(player, BOT_TEXT_PCT);
botstring << "\n" << LocalizedNpcText(player, BOT_TEXT_SPELL_PEN) << ": " << uint32(spellpen) + uint32(std::abs(me->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, SPELL_SCHOOL_MASK_MAGIC)));

Expand Down
23 changes: 14 additions & 9 deletions src/server/game/Entities/Unit/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2282,15 +2282,6 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy
int32 block_chance = int32(GetUnitBlockChance(attType, victim) * 100.0f);
int32 parry_chance = int32(GetUnitParryChance(attType, victim) * 100.0f);

//npcbot - expertise
if (IsNPCBot())
{
int32 reductionFromExpertise = ToCreature()->GetCreatureExpertise() * 100 / 4;
dodge_chance -= reductionFromExpertise;
parry_chance -= reductionFromExpertise;
}
//end npcbot

// melee attack table implementation
// outcome priority:
// 1. > 2. > 3. > 4. > 5. > 6. > 7. > 8.
Expand Down Expand Up @@ -2770,6 +2761,13 @@ float Unit::GetUnitDodgeChance(WeaponAttackType attType, Unit const* victim) con
// Reduce dodge chance by attacker expertise rating
if (GetTypeId() == TYPEID_PLAYER)
chance -= ToPlayer()->GetExpertiseDodgeOrParryReduction(attType);
//npcbot - manual expertise instead of auras
else if (IsNPCBot())
{
chance -= ToCreature()->GetCreatureExpertise() * 25;
chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25;
}
//end npcbot
else
chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) / 4.0f;
return std::max(chance, 0.0f);
Expand Down Expand Up @@ -2824,6 +2822,13 @@ float Unit::GetUnitParryChance(WeaponAttackType attType, Unit const* victim) con
// Reduce parry chance by attacker expertise rating
if (GetTypeId() == TYPEID_PLAYER)
chance -= ToPlayer()->GetExpertiseDodgeOrParryReduction(attType);
//npcbot - manual expertise instead of auras
else if (IsNPCBot())
{
chance -= ToCreature()->GetCreatureExpertise() * 25;
chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25;
}
//end npcbot
else
chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) / 4.0f;
return std::max(chance, 0.0f);
Expand Down

0 comments on commit 0d4207c

Please sign in to comment.