## How stats order working

Find all FAQs, HOWTOs and guides here.
Forum rules
READ NOW: L2j Forums Rules of Conduct
Zealar
L2j Veteran
Posts: 1236
Joined: Sun Jul 15, 2007 10:29 am

### How stats order working

"Order" allow us to change basic math operation order.

"Mul" == "Multiplication" == *

For example if we got :

Code: Select all

``Base stat : (10)Add (+30)Mul (* 30)``
In normal math mul is before add so will got follow:

Code: Select all

``10 * 30 + 30 = 330``
But if we use order "2" for (*30) and order "1" for (+30) then will get.

Code: Select all

``(10 + 30 ) * 30 = 1200``
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

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>``
Inside we can see Character with 23 DEX got 3% bonus ( * 1.3)

Code: Select all

``<stat value="23" bonus="1.03" />``
Also need to check default orders for "Mul" and "Add" if they is not changed in DataPack
Mul = 20
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);``
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

Code: Select all

``<baseCritRate>4</baseCritRate>``
That "4" is char base critical rate.

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

Code: Select all

``com.l2jserver.gameserver.model.stats.functions.formulas.FuncAtkCritical.java``
And we see

Code: Select all

``initVal * BaseStats.DEX.calcBonus(effector) * 10``
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

Code: Select all

``4 * 1.09 * 10 = 43.6 = 44``
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%)"

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>``
How formula will be change if use "22160"
FROM

Code: Select all

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

Code: Select all

``(4 * 1.09 * 10) + 15= 58.6 = 59 // Critical Rate``
How formula will be change if use "1077"
FROM

Code: Select all

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

Code: Select all

``(4 * 1.09 * 10) * 1.3 = 56.68 = 57 // Critical Rate``
How formula will be change if use BOTH
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``
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

Code: Select all

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

Code: Select all

``<add order="19" stat="rCrit" val="15" />``
Now that "Add" got lower stat so will be calculate before mul and formula change.
FROM

Code: Select all

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

Code: Select all

``((4 * 1.09 * 10 ) + 15) * 1.3 = 76.18 = 76 // Critical Rate``
What happen if we got weapon.
For weapon will use "(233) Dark Screamer"
That weapon got

Code: Select all

``<set stat="rCrit" val="12" />``
That set override the default value so instant of 4 will got 12 so formula is change.
FROM

Code: Select all

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

TO

Code: Select all

``12 * 1.09 * 10 = 130.8 = 131``
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

Code: Select all

``<add stat="rCrit" val="81.2" />``
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

Code: Select all

``(12 * 1.09 * 10) + 81.2 = 212``
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 :
SPOILER:
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 :
SPOILER:
Zoey76
L2j Inner Circle
Posts: 7005
Joined: Tue Aug 11, 2009 3:36 am

### Re: How stats order working

Moved to FAQ - HOWTO - Guides, thanks.
Powered by Eclipse 4.30 | Eclipse Temurin 21 | MariaDB 11.3.2 | L2J Server 2.6.3.0 - High Five