| 65 | } |
| 66 | |
| 67 | int CalcNormalAttackToHit(const Game_Battler &source, |
| 68 | const Game_Battler &target, |
| 69 | Game_Battler::Weapon weapon, |
| 70 | lcf::rpg::System::BattleCondition cond, |
| 71 | bool emulate_2k3_enemy_row_bug) { |
| 72 | auto to_hit = source.GetHitChance(weapon); |
| 73 | |
| 74 | // If target has rm2k3 state which grants 100% dodge. |
| 75 | if (target.EvadesAllPhysicalAttacks()) { |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | // If target has Restriction "do_nothing", the attack always hits |
| 80 | if (!target.CanAct()) { |
| 81 | return 100; |
| 82 | } |
| 83 | |
| 84 | // Modify hit chance for each state the source has |
| 85 | to_hit = (to_hit * source.GetHitChanceModifierFromStates()) / 100; |
| 86 | |
| 87 | // Stop here if attacker ignores evasion. |
| 88 | if (source.AttackIgnoresEvasion(weapon)) { |
| 89 | return to_hit; |
| 90 | } |
| 91 | |
| 92 | // AGI adjustment. |
| 93 | to_hit = CalcToHitAgiAdjustment(to_hit, source, target, weapon); |
| 94 | |
| 95 | // If target has physical dodge evasion: |
| 96 | if (target.HasPhysicalEvasionUp()) { |
| 97 | to_hit -= 25; |
| 98 | } |
| 99 | |
| 100 | // Defender row adjustment |
| 101 | if (Feature::HasRow() && IsRowAdjusted(target, cond, false, emulate_2k3_enemy_row_bug)) { |
| 102 | to_hit -= 25; |
| 103 | } |
| 104 | |
| 105 | return to_hit; |
| 106 | } |
| 107 | |
| 108 | |
| 109 | int CalcSkillToHit(const Game_Battler& source, const Game_Battler& target, const lcf::rpg::Skill& skill, lcf::rpg::System::BattleCondition cond, bool emulate_2k3_enemy_row_bug) { |
no test coverage detected