From 66d9371714fccba810484ea0f675f3ffcd774dd8 Mon Sep 17 00:00:00 2001 From: Fryguy Date: Mon, 8 Jan 2024 23:34:41 -0500 Subject: [PATCH] [Bug Fix] Increase Precision in CheckDoubleAttack (#3928) * [Bug Fix] Increase percision on CheckDoubleAttack. On DA Checks where class was a non skill based DA Attacker (Bard or BST with granted DA) The DA check was too steep and should not have been dividing by 500 but rather 100. Also adjusted logic percision to use floats so loss of data does not occur. * logging var names update * Update attack.cpp --------- Co-authored-by: Alex King <89047260+Kinglykrab@users.noreply.github.com> --- zone/attack.cpp | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index f8344e496..7cfacded0 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -3720,22 +3720,39 @@ bool Mob::HasRangedProcs() const bool Client::CheckDoubleAttack() { - int chance = 0; - int skill = GetSkill(EQ::skills::SkillDoubleAttack); //Check for bonuses that give you a double attack chance regardless of skill (ie Bestial Frenzy/Harmonious Attack AA) - int bonusGiveDA = aabonuses.GiveDoubleAttack + spellbonuses.GiveDoubleAttack + itembonuses.GiveDoubleAttack; - if (skill > 0) - chance = skill + GetLevel(); - else if (!bonusGiveDA) + uint32 bonus_give_double_attack = aabonuses.GiveDoubleAttack + spellbonuses.GiveDoubleAttack + itembonuses.GiveDoubleAttack; + + if (!HasSkill(EQ::skills::SkillDoubleAttack) && !bonus_give_double_attack) { return false; + } - if (bonusGiveDA) - chance += bonusGiveDA / 100.0f * 500; // convert to skill value - int per_inc = aabonuses.DoubleAttackChance + spellbonuses.DoubleAttackChance + itembonuses.DoubleAttackChance; - if (per_inc) - chance += chance * per_inc / 100; + float chance = 0.0f; + uint16 skill = GetSkill(EQ::skills::SkillDoubleAttack); - return zone->random.Int(1, 500) <= chance; + int32 bonus_double_attack = 0; + if ((GetClass() == Class::Paladin || GetClass() == Class::ShadowKnight) && (!HasTwoHanderEquipped())) { + LogCombatDetail("Knight class without a 2 hand weapon equipped = No DA Bonus!"); + } else { + bonus_double_attack = aabonuses.DoubleAttackChance + spellbonuses.DoubleAttackChance + itembonuses.DoubleAttackChance; + } + + //Use skill calculations otherwise, if you only have AA applied GiveDoubleAttack chance then use that value as the base. + if (skill) { + chance = (float(skill + GetLevel()) * (float(100.0f + bonus_double_attack + bonus_give_double_attack) / 100.0f)) / 500.0f; + } else { + chance = (float(bonus_give_double_attack + bonus_double_attack) / 100.0f); + } + + LogCombatDetail( + "skill [{}] bonus_give_double_attack [{}] bonus_double_attack [{}] chance [{}]", + skill, + bonus_give_double_attack, + bonus_double_attack, + chance + ); + + return zone->random.Roll(chance); } // Admittedly these parses were short, but this check worked for 3 toons across multiple levels