# Level Correction Function and pDIF

(Redirected from PDIF)

### Cap Attack/Defense Ratio

The ratio of an attacker's Attack versus the defender's Defense, Ratio, is capped for the purposes of damage calculation:

• Ratio is capped at 2.25 for one-handed melee weapons.
• Ratio is capped at 2.25 for two-handed melee weapons.

Level correction is then applied to find cRatio, upon which the multipliers to find pDIF work. This entails that Level Correction will always have an effect on damage output.

• As an extreme example, an attacker with 600 attack against a target with 200 defense has a melee attack/defense Ratio of 3.0. This Ratio will be capped to 2.2 with a two-handed weapon, meaning only 440 attack is actually required to maximize Melee pDIF output against this target, regardless of its level.

### The Level Correction function

The Level Correction function modifies your (ranged) attack / monster defense ratio before it is used in the calculation of pDIF.

• If the target is a higher level than the attacking player, then a level corrected ratio is needed before calculating pDIF.
• This is not, however, applied in reverse if the player is the higher level being attacked.
• When fighting EM monsters or lower, level correction is always zero, meaning no 'bonus' is applied for attacking lower level targets.

After Ratio is capped at 2.25, or for any lower value:

• Melee cRatio = Ratio - 0.050 x level difference

Using the capped 2.25 Ratio from before, for a level 75 against a level 80 target, melee cRatio is then:

• (2.2 - 0.05*5) = 1.95.

Level correction is also applied to Ranged Attacks, but no Ratio cap has been determined:

• Ranged cRatio = Ratio - 0.025 x level difference

Once the level-corrected ratio is calculated the game generates random numbers between two values 'a' and 'b'. This random number is then multiplied by another random number (uniform between 1 and 1.05). Therefore, the minimum observed value is 'a' and the maximum value observed is 'b*1.05'. Due to flooring, it take a lot of hits to reach those extreme values.

• One Handers, Two Handers and Ranged pDIF scaling multipliers have the same formulas (only verified for 1 handed weapons so far and up to 2.0 ratio).

## Pdif maximum and minimum

### 1-Handers Pdif

Let r=cRatio, as computed as above.

Maximum b has the following formulas:
Ratio Range 'r' Function Value Observed maximum
0 ≤ r < 0.5 b= 1+(10/9)x(r-0.5) 0.467+1.167xr
0.5 ≤ r ≤ 3/4 b= 1 1.05
3/4 < r ≤ 2.25 b = 1 +(10/9)x(r-3/4) b=0.175+1.167xr
and Minimum a has the following formulas:
Ratio Range Function Value
r ≤ 0.5 a = 1/6
0.5 ≤ r < 1.25 a= 1 + (10/9)x(r-1.25)
1.25 ≤ r ≤ 1.5 a = 1
1.5 < r ≤ 2.25 a= 1 + (10/9)x(r-1.5)

A simple way to express the function 'a' and 'b' is to use the positive and negative parts of numbers : p(x)=max(x,0) and n(x)=max(-x,0). Then

• a(r)=1+(10/9)x(p(max(r,0.5)-1.5)-n(max(r,0.5)-1.25))
• b(r)=1+(10/9)x(p(r-0.75)-n(r-0.5))

### 2-Handers Pdif

Note those formulas are likely outdated ; use the 1 handed formulas instead.

Max pDIF has the following formulas:
Ratio Range Function Value
0 ≤ cRatio < 0.5 fMax(cRatio) = 0.4 + 1.2 x cRatio 0.5 ≤ cRatio ≤ 5/6 fMax(cRatio) = 1 5/6 < cRatio ≤ 10/6 fMax(cRatio) = 1.25 x cRatio 10/6 < cRatio ≤ 2 fMax(cRatio) = 1.2 x cRatio • For both one- and two-handed melee weapons, a Critical Hit adds 1.0 to intermediate pDIFa value and capped at 3.0 before the x1.00-1.05 randomization is applied.
and Min pDIF has the following formulas:
Ratio Range Function Value
0 ≤ cRatio < 1.25 fMin(cRatio) = -0.5 + 1.2 x cRatio
if fMin < 0 → fMin = 0 1.25 ≤ cRatio ≤ 1.5 fMin(cRatio) = 1 1.5 < cRatio ≤ 2 fMin(cRatio) = -0.8 + 1.2 x cRatio • For both one- and two-handed melee weapons, a Critical Hit adds 1.0 to intermediate pDIFa value and capped at 3.0 before the x1.00-1.05 randomization is applied.

### Ranged Attack Pdif

Ratio Range Function Value
0 ≤ cRatio < 0.9 fMax(cRatio) = 10/9 x cRatio
0.9 ≤ cRatio ≤ 1.1 fMax(cRatio) = 1
1.1 < cRatio ≤ 3.0 fMax(cRatio) = cRatio
Ratio Range Function Value
0 ≤ cRatio < 0.9 fMin(cRatio) = cRatio
0.9 ≤ cRatio ≤ 1.1 fMin(cRatio) = 1
1.1 < cRatio ≤ 3.0 fMin(cRatio) = -3/19 + 20/19 x cRatio
• When cRatio exceeds 3.0, cRatio is 3.0 (capped for ranged)
Ranged critical hit always multiplies your pDIF by 1.25, and is not capped.
Example: When your pDIF is 3.0 and you score a critical hit, your pDIF will be 3.75

## Distribution of melee hits

For a one handed weapon, with a damage 'DMG' (which includes fstr), and a cratio 'r', the above formula give a minimum pdif called 'a' and a maximum pdif called 'b' (which is the maximum before the randomizer is applied so b*1.05 is the real maximum). Note that the value of b and a used here are almost those above except a has no lower cap :

• a(r)=1+(10/9)x(p(r-1.5)-n(r-1.25))
• b(r)=1+(10/9)x(p(r-0.75)-n(r-0.5))

• For 0 <= r <= 2.0 the distribution of random damage observed in-game follows the following law :
 FinalDamage = Floor[Floor[ Base Damage * (U + (1-U)*Max(Rand(a;b),1/6)) ] * Rand(1;1.05) ]

where rand(x;y) is an uniform randomizer generating values within the range [x,y], and U is a bernouilli variable of parameter 'q' described below (q=P(U=1)). The variables U and the 2 randomizers are independantly generated.

If 0.75 ≤ r ≤ 1.25 q=0.277...=5/18=5/6 - (b-a)

The distribution has a spike appearing in the middle of the distribution in the range [DMG,DMG*1.05]. The spike goes to the upper side if r descreases and goes to the lower side if r increases. Around 28% of the hits values lie in the intervale [DMG,DMG*1.05], and this doesn't vary with r.

If 1.25 ≤ r ≤ 1.5 q=5/3-(10/9)xr=5/6 - (b-a)

When r exceeds 1.25, a remains equal to a=DMG until r=1.5, and the distribution presents a spike on its lower bound. The spike frequency decreases to zero when r reaches r=1.5.

If 0.5 ≤ r ≤ 0.75 q=-5/9+(10/9)xr=5/6 - (b-a)

When r falls below 0.75, b remains equal to b=DMG until r=0.5, and the distribution presents a spike on its upper bound. The spike frequency decreases to zero when r reaches r=0.5.

If 0 ≤ r ≤ 0.5 q=0

DMG doesn't belong to the hits distribution range in this case. The distribution is uniform on the interval [a*1.05*DMG,b*DMG] and logaritmic near the edges (0 on the edges).

If 1.5 ≤ r ≤ 2.25 q=0

DMG doesn't belong to the hits distribution range in this case. The distribution is uniform on the interval [a*1.05*DMG,b*DMG] and logaritmic near the edges (0 on the edges).

• for 0.5<=r<=1.5 the frequency spike equals

q+(1-q)*DMG*ln(1.05)/(b-a)

• Though testing has to be done, crit distribution is expected to follow a similar rule, except the uniform variable is generated between a+1 and b+1, then capped at 3, and then only multiplied by the 5% randomizer. Therefore a spike cannot happen :

critdamage:=(1+min(U,2))*eta

with U uniform on [a,b] and eta uniform on [1,1.05]

## Average pdif expression

Using the above model, we deduce the expression of the average pdif for 1-handed weapons (as well as 2 handed weapons until verifications)

Ratio Range Function Value
r ≤ 0.5 m = .2182870370+.3796296294*r+.7592592591*r^2
0.5 ≤ r < 0.75 m=-.0822530866+1.676697531*r-.6327160494*r^2
0.75 ≤ r ≤ 1.25 m = .2024691355+.8225308644*r
1.25 < r ≤ 1.5 m=1.309722223-.8541666666*r+.6327160494*r^2
1.5 < r ≤ 2.25 m=-.2562500002+1.138888889*r

Using the above model, we deduce the expression of the average crit pdif for 1-handed weapons (as well as 2 handed weapons until verifications) If r<1.65 (ie b<2) then mc=1.025*(1+(a+b)/2) else mc=1.025*(1+(4b-a^2-4)/(2(b-a))

or

Ratio Range Function Value
r ≤ 0.5 mc = 1.338194445+.5694444444*r
0.5 ≤ r < 0.75 mc=1.338194444+.5694444444*r
0.75 ≤ r ≤ 1.25 mc = .9111111111+1.138888889*r
1.25 < r ≤ 1.5 mc=1.622916667+.5694444444*r
1.5 < r ≤ 1.65 mc=.7687499999+1.138888889*r
1.65 < r ≤ 2.25 mc=-1.298333333+3.644444444*r-.7592592593*r^2