The following pseudocode describes the Evade roll in detail. It is based on stock Elona; Elona+ seems to have tweaked the equations somewhat.
The Evade roll has three possible results: !hit: normal hit. !nohit: miss. !crit: critical hit.
dim accp //accuracy dim evap //dodge if defender.dimmed if rand(4) < 1 !crit end if defender.sleep !hit end if defender.blind evap = evap/2 if attacker.blind accp = accp/2 if attacker.confused or attacker.dimmed if attacker.isranged accp = accp/5 else if attacker.ismelee accp = accp*2/3 if accp < defender.greaterEvasion *10 if evap/accp > 3 if rnd(defender.greaterEvasion +250) > 1 !nohit end if evap/accp > 2 if rnd(defender.greaterEvasion +250) > 150 !nohit end if evap/accp > 1.5 if rnd(defender.greaterEvasion +250) > 200 !nohit end if rnd(5000) < attacker.Perception +50 !crit end if attacker.critChance < rnd(200) //max critChance is 30, which requires ~840 Eye of Mind !crit end if 1 >= rnd(20) !nohit end if 1 >= rnd(20) !hit end if accp < 1 !nohit end if evap < 1 !hit end if rnd(accp) > rnd(evap *3/2) !hit end !nohit end
The following is the algorithm in plain text: The game considers any status effects first and makes a few calculations.
- If the defender is Dimmed, there is a 1/4 chance to crit, regardless of all other stats.
- If the defender is Asleep, the attacker will always hit, regardless of all other stats.
- If the attacker is Blind, their accuracy is halved.
- If the attacker is Confused or Dimmed, ranged attacks will have 1/5 their normal accuracy, and melee attacks will have 2/3 their normal accuracy.
Once those calculations are out of the way, the game determines the outcome of an attack in the following order:
- If the attacker's accuracy is less than the defender's Greater Evasion skill level multiplied by 10, then there is a chance to miss depending on the gap between the attacker's accuracy and the defender's evade.
- The attacker is given a chance to land a critical hit based on their Perception attribute.
- The attacker is given a chance to land a critical hit based on their Crit Chance, up to a maximum of 30% chance.
- The attacker has a 1 in 20 chance to miss.
- The attacker has a 1 in 20 chance to hit.
- The attacker will miss if their accuracy is less than 1%.
- The defender will be hit if their evade is less than 1%.
- Finally, the attacker has a chance to hit based on their accuracy versus the defender's Evasion skill level multiplied by 1.5. Otherwise, the attack misses.