MCPcopy Create free account
hub / github.com/EasyRPG/Player / CalcNormalAttackToHit

Function CalcNormalAttackToHit

src/algo.cpp:67–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67int 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
109int 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) {

Callers 5

vExecuteMethod · 0.85
testAgiFunction · 0.85
testStatesFunction · 0.85
algo.cppFile · 0.85
testHitRateRowFunction · 0.85

Calls 8

CalcToHitAgiAdjustmentFunction · 0.85
IsRowAdjustedFunction · 0.85
CanActMethod · 0.80
GetHitChanceMethod · 0.45
AttackIgnoresEvasionMethod · 0.45
HasPhysicalEvasionUpMethod · 0.45

Tested by

no test coverage detected