### How stats order working

Posted:

**Fri Nov 21, 2014 9:55 pm**"Order" allow us to change basic math operation order.

"Add" == "Addition" == +

"Mul" == "Multiplication" == *

For example if we got :
In normal math mul is before add so will got follow:
But if we use order "2" for (*30) and order "1" for (+30) then will get.
In other words we tell to calculator to calculate "Add" before "Mul".

For see example how orders can be used in L2J and what effect they will have lets do some calculations with characters Critical Rate (Crit. Rate).

Before we look in formulas and order need to understand what is DEX bonus and how to see proper value.

See file game\data\stats\statBonus.xml
Inside we can see Character with 23 DEX got 3% bonus ( * 1.3)
Also need to check default orders for "Mul" and "Add" if they is not changed in DataPack

Mul = 20

Add = 30

Or Mul will be calculate before Add if order is not set to different values in DP.

For see default values for all stats look java.com.l2jserver.gameserver.enums.StatFunction.java
Lower value mean will be used first.

=======================================

For that example will use:

Class : Maestro

Level : 85

Equip : None

For calculate proper critical rate we need to look inside char template.

game\data\stats\chars\baseStats\Maestro.xml

Look the line
That "4" is char base critical rate.

Then we need the formula for critical rate so we look inside
And we see
Or "val * dexBonus * 10"

Is time for replace "val" and "dex" bonus.

Maestro got 29 dex what give us 1.09 bonus, and we got 4 base when replace in formula we be Critical Rate

For that example will use 2 skills one give "Add 15 critical (15 static)" and second one give "Mul 1.3 critical(30%)"
How formula will be change if use "22160"

FROM
TO
How formula will be change if use "1077"

FROM
TO
How formula will be change if use BOTH

FROM

TO
Ok now lets play with orders. Add got order 30 by default so is calc last but what will happen if we put it before Mul.

Mul got order 20. So we change skill "22160"

FROM
TO
Now that "Add" got lower stat so will be calculate before mul and formula change.

FROM
TO
What happen if we got weapon.

For weapon will use "(233) Dark Screamer"

That weapon got
That set override the default value so instant of 4 will got 12 so formula is change.

FROM

TO
Lets say we switch weapon to "(4772)Dark Screamer - Focus"

That weapon got "<set stat="rCrit" val="12" />"

But also give skill "3011" and that skill got
We know need to replace base "4" with set "12" then we look the StatFunction and see where Add is. Add got value 30 so is add last. then formula change to
Q & A

|_______________________________|

Q : In com.l2jserver.gameserver.mode.stats.functions.formulas.* each formula got "Order" called in constructor super for what that is used?

A :
Q : In com.l2jserver.gameserver.mode.stats.functions.formulas.* Orders used in that formulas effect the other formulas?

For example order inside FuncAtkAccuracy effect in some way FuncAtkCritical?

A : No

Q : Why there is some items what not use default orders and they got custom one like Jewels and Armors

A :

"Add" == "Addition" == +

"Mul" == "Multiplication" == *

For example if we got :

Code: Select all

`Base stat : (10)Add (+30)Mul (* 30)`

Code: Select all

`10 * 30 + 30 = 330`

Code: Select all

`(10 + 30 ) * 30 = 1200`

For see example how orders can be used in L2J and what effect they will have lets do some calculations with characters Critical Rate (Crit. Rate).

Before we look in formulas and order need to understand what is DEX bonus and how to see proper value.

See file game\data\stats\statBonus.xml

Code: Select all

` <DEX> <!-- 1.009^(DEX-19.360) --> <stat value="20" bonus="1.01" /> <stat value="21" bonus="1.01" /> <stat value="22" bonus="1.02" /> <stat value="23" bonus="1.03" /> <stat value="24" bonus="1.04" /> <stat value="25" bonus="1.05" /> <stat value="26" bonus="1.06" /> <stat value="27" bonus="1.07" /> <stat value="28" bonus="1.08" /> <stat value="29" bonus="1.09" /> </DEX></list>`

Code: Select all

`<stat value="23" bonus="1.03" />`

Mul = 20

Add = 30

Or Mul will be calculate before Add if order is not set to different values in DP.

For see default values for all stats look java.com.l2jserver.gameserver.enums.StatFunction.java

Code: Select all

` ADD("Add", 30), DIV("Div", 20), ENCHANT("Enchant", 0), ENCHANTHP("EnchantHp", 40), MUL("Mul", 20), SET("Set", 0), SHARE("Share", 30), SUB("Sub", 30);`

=======================================

For that example will use:

Class : Maestro

Level : 85

Equip : None

For calculate proper critical rate we need to look inside char template.

game\data\stats\chars\baseStats\Maestro.xml

Look the line

Code: Select all

`<baseCritRate>4</baseCritRate>`

Then we need the formula for critical rate so we look inside

Code: Select all

`com.l2jserver.gameserver.model.stats.functions.formulas.FuncAtkCritical.java`

Code: Select all

`initVal * BaseStats.DEX.calcBonus(effector) * 10`

Is time for replace "val" and "dex" bonus.

Maestro got 29 dex what give us 1.09 bonus, and we got 4 base when replace in formula we be

Code: Select all

`4 * 1.09 * 10 = 43.6 = 44`

For that example will use 2 skills one give "Add 15 critical (15 static)" and second one give "Mul 1.3 critical(30%)"

Code: Select all

`<skill id="22160" name="Vesper Critical Power"> <for> <effect name="Buff"> <add stat="rCrit" val="15" /> </effect> </for></skill>`

Code: Select all

`<skill id="1077" name="Focus"> <for> <effect name="Buff"> <mul stat="rCrit" val="1.3" /> </effect> </for></skill>`

FROM

Code: Select all

`4 * 1.09 * 10 = 43.6 = 44 // Critical Rate`

Code: Select all

`(4 * 1.09 * 10) + 15= 58.6 = 59 // Critical Rate`

FROM

Code: Select all

`4 * 1.09 * 10 = 43.6 = 44 // Critical Rate`

Code: Select all

`(4 * 1.09 * 10) * 1.3 = 56.68 = 57 // Critical Rate`

FROM

Code: Select all

`4 * 1.09 * 10 = 43.6 = 44 // Critical Rate`

TO

Code: Select all

`(4 * 1.09 * 10 * 1.3) + 15 = 71.68 = 72 // Critical Rate`

Mul got order 20. So we change skill "22160"

FROM

Code: Select all

`<add stat="rCrit" val="15" />`

Code: Select all

`<add order="19" stat="rCrit" val="15" />`

FROM

Code: Select all

`(4 * 1.09 * 10 * 1.3) + 15 = 71.68 = 72 // Critical Rate`

Code: Select all

`((4 * 1.09 * 10 ) + 15) * 1.3 = 76.18 = 76 // Critical Rate`

For weapon will use "(233) Dark Screamer"

That weapon got

Code: Select all

`<set stat="rCrit" val="12" />`

FROM

Code: Select all

`4 * 1.09 * 10 = 43.6 = 44 // Critical Rate`

TO

Code: Select all

`12 * 1.09 * 10 = 130.8 = 131`

That weapon got "<set stat="rCrit" val="12" />"

But also give skill "3011" and that skill got

Code: Select all

`<add stat="rCrit" val="81.2" />`

Code: Select all

`(12 * 1.09 * 10) + 81.2 = 212`

|_______________________________|

Q : In com.l2jserver.gameserver.mode.stats.functions.formulas.* each formula got "Order" called in constructor super for what that is used?

A :

**SPOILER:**

For example order inside FuncAtkAccuracy effect in some way FuncAtkCritical?

A : No

Q : Why there is some items what not use default orders and they got custom one like Jewels and Armors

A :

**SPOILER:**