# How is the attack dodge rate calculated?

## Regular aim math

Accuracy varies on the Aim Math setting in the Edit Attacks -> Damage Settings... menu. Unfortunately, the OHRRPGCE's hit chance determination is complex and does not give users any help with balancing at all.

First, find the offensive value

• Bad : Aim * 1 of attacker
• Poor : Aim * 2 of attacker
• Normal : Aim * 4 of attacker
• Magic : Magic of attacker

Next, the defensive value

• Bad, Poor and Normal : Dodge of defender
• Magic : Will * 1.25 of defender
• Never Misses : 0

Randomize both values to within +/- 75% Now, if the offensive number is higher than defense, the attack hits, otherwise it misses.

If you have the source code, you can look at the details, currently in inflict in bmodsubs.bas.

Your best bet for calculating the actual hit chances for attacks is to use a utility ( OHRaim by DukeofDellot). This doesn't change the fact that you should always thoroughly test the actual in-game result!

## Calculation Example

Lets say that your hero has an Aim of 20 and attacks an animated towel with a Dodge of 16 with an attack with Normal aim math.

```   20 * 4 vs 16
=> 80     vs 16
```

Now consider the randomisation, which is 75% of each value

```   80 +/- 60 vs 16 +/- 12
=> 20 - 140  vs 4 - 28
```

You can see that the overlap here is not very much, so the attack will probably hit. How exactly do you work out the chance to hit? Not easily at all...

```  if (random(20,140) => 29) then (hit)                111/120 = 92.5%
else (                                              (100% - 92.5%) = 7.5%
if (random(4,28) << 20) then (hit)                15/24 = 62.5%
else (                                            7.5% * (100% - 62.5%) = 2.8%
if (random(20,28) >> random(20,28)) then (miss) 50%
) )

total chance to hit = 100% - 2.8% * 50% = 98.6%
(Note: rounding and strict equality ignored for simplicity, in fact this calculation is not too accurate)
```

## Percentage aim math

Werewaffle introduced percentage-based aim types. These types use simpler math and may be easier for you to balance. The chance to hit with these aim types is Aim * (100 - Dodge)%. In other words, if the target has 0 Dodge, you have an Aim% chance to hit. If the target has 50 Dodge, you have an (Aim/2)% chance to hit (50% of Aim). If the target has 100 Dodge, you have zero chance to hit. Here are more examples:

```Aim - Dodge - Resulting Hit%
100 - 0     - 100%
100 - 25    - 75%
100 - 50    - 50%
100 - 75    - 25%

50  - 0     - 50%
50  - 25    - 37.5%
50  - 50    - 25%
50  - 75    - 12%

150 - 0     - 100% (150%, actually, but guaranteed to hit)
150 - 25    - 100% (112.5%, actually)
150 - 50    - 75%
150 - 75    - 37.5%
```