Module:CalcStat/doc

From Lotro-Wiki.com
Jump to navigation Jump to search

This is the documentation page for Module:CalcStat

Overview

CalcStat calculates game stats using a single access function. It originated from the LotroPlan spreadsheet project, initially developed by Giseldah in 2013 (see this forum thread). This module implements the Standard Progression and other progressions, enabling accurate in-game stat calculations directly within the Wiki.

Key Features:

  • Calculates game stats based on various progressions.
  • Includes expression parsing for complex stat derivations.
  • Supports various formatting options for wiki-friendly display of results.

See Also: CalcStat on LoTROInterface - Plugin download page.

Current Version: 2.4.13f

Installation

Retrieving sources

To get the sources, you have two main options:

  1. Direct Download: Download the source code directly from LoTROInterface. The source files will be within the downloaded zip file.
  2. LOTRO Plugin Compendium: Install via LOTRO Plugin Compendium. If installed via Plugin Compendium, the source files can be found in your plugins directory under Giseldah\CalcStat.

Note: Regardless of the installation method, you will need to compile the Lua code for use in the Wiki (see instructions below).

Creating the Wiki Lua Code

To generate the Lua code for Module:CalcStat (the Wiki module), you need to compile the source file calcstat.csv. This is done using the compiler script statdcmp.vbs provided with the source files. Follow these steps to compile the code:

  1. Locate the compiler script: Ensure you have access to the source files from either installation method above. The compiler script statdcmp.vbs is located within these source files.
  2. Run the compiler script: Execute the statdcmp.vbs script on a Windows system.
  3. Select output option: When prompted by the script, choose option 6: "Lua-script (Lotro-Wiki Module)".
  4. Select stats inclusion: Next, choose option 1 to "include all stats".
  5. Locate the output file: The compiler will generate a file named CalcStat.lua. This CalcStat.lua file contains the Lua code for Module:CalcStat and is ready to be copied into the module page.

Important: These compilation steps are necessary to create the Wiki-compatible Lua code from the provided source data.

Usage

{{#invoke:CalcStat|calc|StatName or Expression|Level|NorC|Format|Display}}

Standard CalcStat Parameters

  • StatName or Expression (mandatory): reference to the stat to be calculated or a CalcStat Expression instead. See stat sections below for some of the stat possibilities. The calcstat.csv file contains the complete list (best viewed with a spreadsheet application), but be warned that it's very complex and some stats are only intermediate/internal calculations.
  • Level: can be a character level, item level, virtue rank, etc.
  • NorC: optional parameter. can be either number or text, depending on stat.

Specific Parameters for Wiki use

Assuming a value of 12345.016:
  1. %'d displays a thousand separated number for main stats (whole numbers; rounded down when fractured) like: 12,345
  2. %'+d displays a thousand separated number for main stats (whole numbers; rounded down when fractured) with a forced sign like: +12,345
  3. %.0f (default) displays a number for rating stats (fractured numbers; normal rounding to given precision 0 decimals) like: 12345
  4. %+.0f displays a number for rating stats (fractured numbers; normal rounding to given precision 0 decimals) with a forced sign like: +12345
  5. %'.1f displays a thousand separated number for DPS (fractured numbers; normal rounding to given precision 1 decimal) like: 12,345.0
  6. %'.0.1f displays a thousand separated number (fractured numbers; normal rounding to given precision maximum 1 decimal / removing trailing zeroes up to minimum precision 0 ) like: 12,345
  7. %'.1.2f displays a thousand separated number (fractured numbers; normal rounding to given precision maximum 2 decimal / removing trailing zeroes up to minimum precision 1 ) like: 12,345.02
  • Display: option for display of percentages and other:
  1. AddP: Display Additive Percentage (with a 0.0002 correction).
  2. AddP100: Mutltiply by 100 & display as Additive Percentage (with a 0.0002 correction).
  3. MultiP: Display Multiplier Percentage (with a 0.0002 correction).
  4. MultiP100: Mutltiply by 100 & display as Multiplier Percentage (with a 0.0002 correction).
  5. Worth: Displays value in gold/silver/copper (from number value in format ..ggggssscc).
  6. Corr: Correction. 0.0002 is added to any fractured number (this is the default for numbers).
  7. NoAdj: No adjustments - to override any defaults.

Default Number Formatting for Wiki

Module:CalcStat and most depending modules automatically attempt to apply appropriate number formatting based on keywords found in the StatName or Expression, unless an overriding Format parameter is provided. This ensures a sensible default display for various stat types.
The following table outlines the default formatting rules, in order of detection (non-case sensitive). Note that if a detected sequence is followed by the character 'P', the formatting is skipped.

Sequences Format Notes
ARMOURLOW, CLOTHARMOUR %'d Specific Armour values on items.
ARMOUR%a+, %w+ARMOUR %.0f Targeting non item related Armour values.
MAIN, AGILITY, FATE, MIGHT, VITALITY, WILL, ARMOUR %'d Targeting whole number main stats with a thousand separator.
WPNDMGMIN, WPNDMGMAX, SKILLPOWERCOST %'.0f Fractured stats requiring thousand separator and 0 decimals.
WPNDPS %'.1f Same as above, but with 1 decimal.
ICMR, ICPR, NCMR, NCPR, POWER %.0.3f Regeneration and Power stats with 0-3 decimals.
(No match) %.0f Default format if no sequence is detected.

Expressions

CalcStat Expressions provide a powerful way to create custom stat calculations beyond simple stat selection. They allow you to combine stats, constants, operations, and functions to derive new values and result texts.

Introduction

A StatName in CalcStat is essentially a predefined expression linked to an internal identifier. Expressions allow you to define your own calculations directly within the #invoke call. You can for example do some simple calculations:

{{#invoke:CalcStat|calc|1+1}}

2

{{#invoke:CalcStat|calc|5*-3^2^-2+28*(4/6+1)+1/3*2|||%.0.8f|NoAdj}}

40.75296327

Magic Words

Note that in Wiki the pipe character '|' and equal sign '=' are processed as part of the #invoke argument parsing. If you want to use these in your Expressions code then you need to use {{!}} or {{=}} respectively.
Tip: if you number all arguments to the invoke like this then you don't need to use {{=}} for using the equal sign (still need to use {{!}}).

{{#invoke:CalcStat|calc|1=StatName or Expression|2=Level|3=NorC|4=Format|5=Display}}

For example:

{{#invoke:CalcStat|calc|1=with($A=$L+$N:$A+2)|2=100|3=|4=Level: %.0f|5=NOADJ}}

Level: 103

Comments

You can add comments to expressions if you place them between /* */.
For example:

{{#invoke:CalcStat|calc|/* lol */}}

Translation error in CalcStat:Expressions invoked by Module:CalcStat
Code: 12 (Missing expression)
Obviously, this gives not an error because of the comment, but because we didn't supply any expression at all.

{{#invoke:CalcStat|calc|5 /* let's add something to this lowly value */ + 1 /* can we do more please? */ + 4 /* ok, fine*/}}

10

Operators

In expressions you can use the same operators as used in Lua version 5.1, minus the '#'. They are also processed in the same order of priority and direction.
Syntax in expressions is not case-sensitive, so AND and Or are fine.
From low to high priority:

Operators Processing direction Notes
or
and
< > <= >= ~= ==
.. string concatenation
+ -
* / % % is modulo/remainder
not - unary -
^

Of course you can also use parentheses () and what is in-between will have priority above all else.

Constants/values

Numbers

Accepted as valid numbers are:

  • a series of digits. (like 123)
  • a series of digits including a decimal dot '.', but not at the edges. (like 0.123, but not .123)

Strings

Strings are encapsulated between double quotes: "tekst".
Accepted escape characters in strings are:

  • \q or \" double quote
  • \\ backslash
  • \n new line

Booleans

Booleans are True and False, non-case-sensitive.

Variables

In CalcStat you have variables which can be used in expressions:

  • L - stands for some kind of level, rank, etc. It's value is equal to the parameter which you supply in the template.
  • N - an extra number value defined in the NorC parameter. N is automatically detected when NorC can be converted to a number.
  • C - a text string from the NorC parameter: anything which is not a number.

These variables can be used in expressions by prefixing a $ sign, so like $L, $N, $C.

{{#invoke:CalcStat|calc|"(L)evel {{=}} "..$L.." and (N)umber {{=}} "..$N|5|9.5}} ('=' between {{}} to avoid processing of '=' characters by Wiki)

(L)evel = 5 and (N)umber = 9.5

{{#invoke:CalcStat|calc|$L*($N+1)+5.30106|5|9.5|%.1.2f|NoAdj}}

57.8

Using Stats

You can use CalcStat stat values in your own expression by using the name of the stat with the @ prefix. Any number attached at the back is interpreted as being the $L to pass to the stat calculation (current $L is passed by default if nothing is specified).

{{#invoke:CalcStat|calc|"1 point of player level Might at level 130: "..@MightT130}}

1 point of player level Might at level 130: 300

{{#invoke:CalcStat|calc|"1 point of item level Might at ilvl 130: "..@Might130}}

1 point of item level Might at ilvl 130: 50

You can also pass a $N parameter to the stat by attaching a # sign followed by a number for the $N to pass. If you only attach a # with no number after it then current $N is passed to the stat.

{{#invoke:CalcStat|calc|"2.6 points of player level Critical Rating at level 100: "..@CritHitT100#2.6}}

2.6 points of player level Critical Rating at level 100: 1180

{{#invoke:CalcStat|calc|"2.6 points of item level Critical Rating at ilvl 100: "..@CritHit100#2.6}}

2.6 points of item level Critical Rating at ilvl 100: 538.33331298828

Instead of a number for $L and $N, you might want to pass an expression. In that case just use parentheses () instead of the numbers.
This is also the way that you can pass a tekst parameter $C (any string expression containing things like constants "tekst", current $C or a stat which returns a string)

{{#invoke:CalcStat|calc|"1/2 points of item level Critical Rating at ilvl "..$L..": "..@CritHit#(1/2)|123}}

1/2 points of item level Critical Rating at ilvl 123: 131.67500305176

{{#invoke:CalcStat|calc|"Armour value for heavy incomparable boots at ilvl "..$L..": "..@Armour#($C)|412|HBT}}

Armour value for heavy incomparable boots at ilvl 412: 2344

{{#invoke:CalcStat|calc|"At ilvl "..$L..", @Vitality#2 is "..@Vitality#2.." and 2*@Vitality#1 equals "..2*@Vitality#1.."... "..iif(@Vitality#2{{=}}{{=}}2*@Vitality#1,"Ok.","It's not the same!")|468}}

At ilvl 468, @Vitality#2 is 863 and 2*@Vitality#1 equals 862... It's not the same!

Functions

Adding functions is an ongoing process. These are the functions currently supported:

Name Notes
Abs(<number expression>) Absolute value (make positive).
Afd(<number expression>, <display option string expression>) Adjust for display. See Specific parameters for Wiki use. Default is "Corr".
Afd(<number expression>)
CalcStat(<Stat name string expression>, <Level number expression>, <NorC expression>) Can be used instead of the shortcut @StatName(Level)#(NorC).
CalcStat(<Stat name string expression>, <Level number expression>)
CalcStat(<Stat name string expression>)
Ceil(<number expression>) Rounds value up to whole number.
Choose(<index number expression>, <parameter list>) Chooses a parameter (any expression), based on the first which is the index.
DecSng(<number expression>) Converts a standard double float precision value to the decimal presentation of the equivalent single float value.
EquSng(<number expression>) Converts a standard double float precision value to equivalent single float value.
Floor(<number expression>) Rounds value down to whole number.
Format(<expression>, "format string") Format to specific text output. See also Specific parameters for Wiki use. Default is "%.0f" for numbers.
Format(<expression>)
GraphVal(<Interpolation Key number expression>, <Point Key number expression1>, <Point Value number expression1>, ..etc) Derives a Value from a set of graph points by interpolation.
IIf(<logical expression>, <expression1>, <expression2>) If the logical expression is true then returns expression1, otherwise expression2.
Log10(<number expression>) Gives the base-10 logarithm.
Min(<number expression1>, <number expression2>) Returns the smallest of 2 numbers.
Max(<number expression1>, <number expression2>) Returns the largest of 2 numbers.
Replace(<Source string expression>, <Search string expression1>, <Replacement expression1>, ...etc) Replaces all occurrences of Search string <> in Source string with Replacement boolean/number/string <>. Processes multiple search & replace pairs.
Round(<Value number expression>, <Decimals number expression>) Rounds a number value, optionally to a specified number of decimals.
Round(<Value number expression>)
RoundUp(<Value number expression>, <Decimals number expression>) Rounds a number value upward, optionally to a specified number of decimals.
RoundUp(<Value number expression>)
RoundDown(<Value number expression>, <Decimals number expression>) Rounds a number value downward, optionally to a specified number of decimals.
RoundDown(<Value number expression>)
RoundLotro(<Value number expression>) Rounds a number value upward using a 3 digit precision.
RoundProg(<Value number expression>) Rounds a number value to a varying amount of decimals, which depends on the value.
SESel(<test expression>, <interval expression1>, <result expression1>, ..etc, <otherwise expression>) Smaller-Equal Select: see below.
Sqrt(<number expression>) Gives the square root.
Switch(<test expression>, case <comparison expression1>: <result expression1>, case..etc, default: <otherwise expression>) Returns a value when a comparison is true.
Until(<initial variable assignment list>: <loop variable assignment list>: <loop termination condition logical expression>: <result expression>) Executes an Until loop until a termination condition is met and returns a processing result.
While(<initial variable assignment list>: <loop execution condition logical expression>: <loop variable assignment list>: <result expression>) Executes a While loop while an execution condition is met and returns a processing result.
With(<variable assignment list>:<result expression>) Assigns values to (custom) variables and returns a value based on these.

Choose

The first parameter is the index into the remaining parameters. An index value of 1 selects parameter 2 etc. Gives an error when the index is out of bounce.

{{#invoke:CalcStat|calc|
Choose(
     $L,
          "Adam",
          "Cindy",
          "Sandy",
          "Thom"
)
|2}}

Cindy

DecSng

DecSng constrains a double float number(64bit) to the decimal presentation value (8 significant digits) of a single precision number(32bit).

{{#invoke:CalcStat|calc|"Normal double: "..$L.."<br>".."Decimal presentation single: "..DecSng($L)|5.3333333333333333333}}

Normal double: 5.3333333333333
Decimal presentation single: 5.3333335

EquSng

Calculations in CalcStat are done with double float numbers(64bit), but the game client uses single precision(32bit). EquSng constrains a double float number to the precision of an equivalent single float number. See also IEEE-754 Floating Point Converter.

{{#invoke:CalcStat|calc|"Normal double: "..$L.."<br>".."Equivalent single: "..EquSng($L)|5.3333333333333333333}}

Normal double: 5.3333333333333
Equivalent single: 5.3333334922791

GraphVal

This function calculates a Value (Y-coordinate) from a set of graph points for a given Key (X-coordinate), by using Linear Interpolation.
Graph points (Key,Value) are first sorted by Key (should be whole numbers and each being unique) and then the Interpolation Key is used to determine the two calculation interval points.
Through these two points you can draw an imaginary line and from this line the Interpolation Value will be calculated using the Interpolation Key.
Stat progressions are almost always using these graphs (linear lines connecting points), except where exponential growth is required.

Note: Linear Extrapolation will be used when the key is outside the bounds of the first or last point, by either using the first two points or the last two points (a minimum amount of two points is mandatory).

The following example defines graph points (1,2), (30,20), (50,50), (100,120) and (999,200). Using $L (40) as the Interpolation Key, it's determined that the two points are (30,20) and (50,50), because the Key is between 30 and 50. From these two points 35 is calculated (40 is exactly in the middle of 30-50, so the interpolated value will also be in the middle of 20-50).

{{#invoke:CalcStat|calc|
GraphVal($L,
1,2,
30,20,
50,50,
100,120,
999,200
)
|40}}

35

Replace

Replaces text parts inside a text with other texts. Note that text replacements proceed from left to right, in sequential order.

{{#invoke:CalcStat|calc|
Replace("Rune-keeper 1","-","","k","K","1",2)
}}

RuneKeeper 2

SESel

Smaller-Equal Select. This function works like Switch, but is more focused on breaking up a range into intervals. It behaves like a Switch(operand1, case <= operand2: operand3, case <= operand4: operand5, etc default: operandn) with the last parameter being the default (value for the remaining/top interval).

{{#invoke:CalcStat|calc|
SESel(
     $L,
         75, 1,
        100, 2,
        105, 3,
        120, 4,
        130, 5,
             6
)
|121}}

5

Switch

You can combine multiple cases for one result value/expression, like with <100 and >120 in this example. Note that after 'default' nothing will be processed.
Also, in Expressions only the parts which need to be processed are being processed, so comparisons are executed top-down until true and then the single result value is evaluated.
The same for the IIf function: only the condition is being evaluated and then one of the results will be processed depending on the outcome.

{{#invoke:CalcStat|calc|
$L..": "..
switch(
    $L,
        case < 20:
            iif($L < 10, "smaller than 10", "smaller than 20, but equal or larger than 10"),
        case < 30:
            "smaller than 30",
        case < 100:
        case > 120:
            "smaller than 100 or larger than 120",
        default:
            "in the range of 100 to 120"
)
|15}}

15: smaller than 20, but equal or larger than 10

Until

This is a Do..Until loop so the loop condition is checked after processing the variable assignment list inside the loop and the loop cycles until the termination condition becomes true.
You can use the initial variable assignments to setup a loop control variable, like a counter, and a result variable, which you can change inside the loop and return at the end of the processing.
The Until function has a counterpart in While(), which checks for an execution condition to be true before each cycle is run.
The maximum number of cycles is limited to 1000.

{{#invoke:CalcStat|calc|
Until(
     $NameRows{{=}}"", $NameIdx{{=}}1:
          $Name{{=}}Choose($NameIdx,"Rose","William","Kees",""),
          $NameRows{{=}}$NameRows..Iif($Name{{=}}{{=}}"","",
               $NameIdx..". "..$Name.."<br>"
          ),
          $NameIdx{{=}}$NameIdx+1:
     $Name{{=}}{{=}}"":
     $NameRows
)
}}

1. Rose
2. William
3. Kees

While

This is a While..Do loop so the loop condition is checked before processing the variable assignment list inside the loop and the loop cycles while the execution condition stays true.
You can use the initial variable assignments to setup a loop control variable, like a counter, and a result variable, which you can change inside the loop and return at the end of the processing.
The While function has a counterpart in Until(), which checks for a termination condition to be true at the end of each cycle.
The maximum number of cycles is limited to 1000.

{{#invoke:CalcStat|calc|
With(
     $iLvl{{=}}512:
          "<u>Item Stats at iLvl "..$iLvl.."</u><br>"..
          While(
               $Result{{=}}"", $Index{{=}}1:
               $Index<{{=}}5:
                    $StatName{{=}}Choose($Index,"Agility","Fate","Might","Vitality","Will"),
                    $Result{{=}}$Result..$Index..". "..$StatName..": "..CalcStat($StatName,$iLvl).."<br>",
                    $Index{{=}}$Index+1:
               $Result
          )
)
}}

Item Stats at iLvl 512
1. Agility: 823
2. Fate: 675
3. Might: 823
4. Vitality: 801
5. Will: 823

With

You can assign values to multiple variables separated by a comma, which you can name anything you like(only alphabetical characters). The With function returns the value of the expression after the ':'.

{{#invoke:CalcStat|calc|
With(
    $LplusTen {{=}} $L+10,
    $LminusFive {{=}} $L-5:
        $LplusTen*2+$LminusFive*3
)
|8}}

45
Note that no such thing as a variable scope exists in these expressions, so all variables are 'global'. This means that these variables are permanent and do exist outside the With function.
Also, nothing stands in the way of changing predefined variables as $L with the same impact. Avoid doing this as it may lead to unpredictable results.

{{#invoke:CalcStat|calc|
With(
    $L {{=}} $L+1:
        $L
)
+2*$L
|3}}

12

Stats

These (most of the normalized)stats are only a part of the collection. A full list can be found in the calcstat.csv file, which is in the ..\The Lord of the Rings Online\Plugins\Giseldah\CalcStat directory when you have installed the plugin.

Rating to Percentage and vice versa

All rating percentages related stat names kind of look the same. The first part of the name is the type of percentage and the part at the end selects the data or calculation for it.

First Part Notes
Block Block Chance
BPE Block/Parry/Evade Chance (general reference)
CritDef Critical Defence
CritHit Critical Hit Chance
CritMagn Critical/Devastating Hit Magnitude
DevHit Devastating Hit Chance
Evade Evade Chance
Finesse Finesse
InDmg Another ring was made.. (depreciated)
InHeal Incoming Healing
MitHeavy Mitigation Heavy classes (general reference)
MitLight Mitigation Light classes (general reference)
MitMedium Mitigation Medium classes (general reference)
OutDmg Outgoing Damage (general reference)
OutHeal Outgoing Healing
Parry Parry Chance
PartBlock Partial Block Chance
PartBlockMit Partial Block Mitigation
PartBPE Partial Block/Parry/Evade Chance (general reference)
PartEvade Partial Evade Chance
PartEvadeMit Partial Evade Mitigation
PartMit Partial Block/Parry/Evade Mitigation (general reference)
PartParry Partial Parry Chance
PartParryMit Partial Parry Mitigation
PhyDmg Physical Damage
PhyMitH Physical Mitigation Heavy classes
PhyMitL Physical Mitigation Light classes
PhyMitM Physical Mitigation Medium classes
Resist Resistance
TacDmg Tactical Damage
TacMitH Tactical Mitigation Heavy classes
TacMitL Tactical Mitigation Light classes
TacMitM Tactical Mitigation Medium classes
End Part L NorC Notes
PBonus PlayerLvl Percentage Bonus
PPRat PlayerLvl N=percentage Percentage to Rating
PRatP PlayerLvl N=rating Rating to Percentage
PRatPA PlayerLvl A
PRatPB PlayerLvl B-rating
PRatPC PlayerLvl C (curve constant)
PRatPCap PlayerLvl Percentage Cap
PRatPCapR PlayerLvl Percentage Cap Rating (rating required)

General references are not preferred to be used. However, if you want to refer to BPE chances in general without being specific about one of the three then go ahead.

Examples

Calculating the basic Evade Chance percentage for 30000 Evade rating at player level 107.

{{#invoke:CalcStat|calc|EvadePRatP|107|30000|%.1f%%|AddP}}

13.0%

You should also add the percentage bonus like with Partial Evade Mitigation (Partial Mitigations are currently the only one with a 0.1 bonus):

{{#invoke:CalcStat|calc|@PartEvadeMitPRatP#+@PartEvadeMitPBonus|107|30000|%.1f%%|AddP}}

35.1%

Calculating the Evade rating required to reach 10.5% Evade Chance (without accounting for any PBONUS) at player level 120.

{{#invoke:CalcStat|calc|EvadePPRat|120|10.5|%f|NoAdj}}

16578.947368

The previous rating should be rounded up, so you could use the expression:

{{#invoke:CalcStat|calc|Ceil(@EvadePPRat#)|120|10.5|%f|NoAdj}}

16579

Main

Many stats have a player level and an item level version. I first created calculations for item stats, so the names for those are the most straightforward. For player stats I appended a 'T' at the name, which stands for Traits. That category is much too narrow though: these stats are used anywhere where stats are player level related like in Effects.
Notes:

  • Stat Main is the general reference here. This stat is equal to Agility, Might and Will. Fate & Vitality stats are currently on different progressions.
  • The N parameter should contain the number of stat points. Default for N is 1, so if you don't supply a specific number then you get the standard 1 point. Note that, in general, because of internal 3 digit rounding introduced a while ago, N * (1 point of Stat) is not same as (N points of Stat) anymore.
  • Main stat values are always whole numbers. Module:CalcStatTable tries to apply format %'d, so whole number format with thousand separator, based on the statname. Module:CalcStat treats them like any other number.
Item level stat
StatName L NorC Notes
Agility ItemLvl N=points
Fate ItemLvl N=points
Main ItemLvl N=points (general reference)
Might ItemLvl N=points
Vitality ItemLvl N=points
Will ItemLvl N=points
Player level stat
StatName L NorC Notes
AgilityT PlayerLvl N=points
FateT PlayerLvl N=points
MainT PlayerLvl N=points (general reference)
MightT PlayerLvl N=points
VitalityT PlayerLvl N=points
WillT PlayerLvl N=points

Percentage Ratings

Notes:

  • The N parameter should contain the number of stat points. Default for N is 1, so if you don't supply a specific number then you get the standard 1 point. Note that, in general, because of internal 3 digit rounding introduced a while ago, N * (1 point of Stat) is not same as (N points of Stat) anymore.
  • Rating stat values are fractured numbers. Module:CalcStat applies the format %.0f as default, so fractured number format rounded to 0 decimals.
Item level stat
StatName L NorC Notes
AcidMit ItemLvl N=points Acid Mitigation
Armour ItemLvl C=code See Armour section.
ArmourLow ItemLvl C=code (Decrepit) See Armour section.
-
Block ItemLvl N=points Block Rating
BPE ItemLvl N=points Block/Parry/Evade Rating (general reference)
CritDef ItemLvl N=points Critical Defence
CritHit ItemLvl N=points Critical Rating
CryResist ItemLvl N=points Cry Resist Rating
DiseaseResist ItemLvl N=points Disease Resist Rating
DmgTypeMit ItemLvl N=points (Acid/Fire/etc) Mitigation (general reference)
Evade ItemLvl N=points Evade Rating
FearResist ItemLvl N=points Fear Resist Rating
Finesse ItemLvl N=points Finesse Rating
FireMit ItemLvl N=points Fire Mitigation
FrostMit ItemLvl N=points Frost Mitigation
InHeal ItemLvl N=points Incoming Healing Rating
LightMit ItemLvl N=points Light Mitigation
LightningMit ItemLvl N=points Lightning Mitigation
Mastery ItemLvl N=points Mastery Rating (general reference)
OrcMit ItemLvl N=points Orc-Craft Mitigation
OutHeal ItemLvl N=points Outgoing Healing Rating
Parry ItemLvl N=points Parry Rating
PhyMas ItemLvl N=points Physical Mastery Rating
PhyMit ItemLvl N=points Physical Mitigation
PhyResist ItemLvl N=points Physical Resist Rating
PoisonResist ItemLvl N=points Poison Resist Rating
Resist ItemLvl N=points Resistance Rating
ResistAdd ItemLvl N=points (Cry/Song/etc) Resist Rating (general reference)
ShadowMit ItemLvl N=points Shadow Mitigation
SongResist ItemLvl N=points Song Resist Rating
TacMas ItemLvl N=points Tactical Mastery Rating
TacMit ItemLvl N=points Tactical Mitigation
TacResist ItemLvl N=points Tactical Resist Rating
WoundResist ItemLvl N=points Wound Resist Rating
Player level stat
StatName L NorC Notes
AcidMitT PlayerLvl N=points Acid Mitigation
ArmourT PlayerLvl N=points Armour Value
-
ArmourPenT PlayerLvl N=points Armour Penetration
BlockT PlayerLvl N=points Block Rating
BPET PlayerLvl N=points Block/Parry/Evade Rating (general reference)
CritDefT PlayerLvl N=points Critical Defence
CritHitT PlayerLvl N=points Critical Rating
CryResistT PlayerLvl N=points Cry Resist Rating
DiseaseResistT PlayerLvl N=points Disease Resist Rating
DmgTypeMitT PlayerLvl N=points (Acid/Fire/etc) Mitigation (general reference)
EvadeT PlayerLvl N=points Evade Rating
FearResistT PlayerLvl N=points Fear Resist Rating
FinesseT PlayerLvl N=points Finesse Rating
FireMitT PlayerLvl N=points Fire Mitigation
FrostMitT PlayerLvl N=points Frost Mitigation
InHealT PlayerLvl N=points Incoming Healing Rating
LightMitT PlayerLvl N=points Light Mitigation
LightningMitT PlayerLvl N=points Lightning Mitigation
MasteryT PlayerLvl N=points Mastery Rating (general reference)
-
OutHealT PlayerLvl N=points Outgoing Healing Rating
ParryT PlayerLvl N=points Parry Rating
PhyMasT PlayerLvl N=points Physical Mastery Rating
PhyMitT PlayerLvl N=points Physical Mitigation
PhyResistT PlayerLvl N=points Physical Resist Rating
PoisonResistT PlayerLvl N=points Poison Resist Rating
ResistT PlayerLvl N=points Resistance Rating
ResistAddT PlayerLvl N=points (Cry/Song/etc) Resist Rating (general reference)
ShadowMitT PlayerLvl N=points Shadow Mitigation
SongResistT PlayerLvl N=points Song Resist Rating
TacMasT PlayerLvl N=points Tactical Mastery Rating
TacMitT PlayerLvl N=points Tactical Mitigation
TacResistT PlayerLvl N=points Tactical Resist Rating
WoundResistT PlayerLvl N=points Wound Resist Rating

Health & Energy

Notes:

  • The N parameter should contain the number of stat points. Default for N is 1, so if you don't supply a specific number then you get the standard 1 point.
  • Health & Energy stat values are fractured numbers. Module:CalcStat applies the format %.0f as default, so fractured number format rounded to 0 decimals.
Item level stat
StatName L NorC Notes
Morale ItemLvl N=points Maximum Morale
ICMR ItemLvl N=points In-Combat Morale Regeneration
NCMR ItemLvl N=points Non-Combat Morale Regeneration
Power ItemLvl N=points Maximum Power
ICPR ItemLvl N=points In-Combat Power Regeneration
NCPR ItemLvl N=points Non-Combat Power Regeneration
Player level stat
StatName L NorC Notes
MoraleT PlayerLvl N=points Maximum Morale
ICMRT PlayerLvl N=points In-Combat Morale Regeneration
NCMRT PlayerLvl N=points Non-Combat Morale Regeneration
PowerT PlayerLvl N=points Maximum Power
ICPRT PlayerLvl N=points In-Combat Power Regeneration
NCPRT PlayerLvl N=points Non-Combat Power Regeneration
SkillPowerCost PlayerLvl N=points Skill use Power Cost[1]
  1. See Skill Power Cost Calculation for a table with cost values. If you know the value in the skill's tooltip then you can look it up in this table and determine the amount of points it represents.

Examples

Showing 3.5 points worth of Skill Power Cost at level cap.

[{{#invoke:CalcStat|calc|SkillPowerCost|{{Level Cap}}|3.5}} at Level {{Level Cap}}]

[471 at Level 150]

Showing Skill Power Cost at level cap for a channeled skill needs an additional format, because it needs to be rounded down (d takes the integer/whole number part only):

[{{#invoke:CalcStat|calc|SkillPowerCost|{{Level Cap}}|0.05|%'d}} at Level {{Level Cap}}]

[7 at Level 150]

Armour (on wearable items)

For armour on items we have 2 normalized stats, of which Armour is the most common used by far. Some lower level items can have a type which I call 'decrepit' armour. A kind of half functioning armour whatever. An example is this item: Item:Dannasen's Shirt. The StatName for this type of armour is ArmourLow. Furthermore, we have a 3rd depreciated / old stat armour which has the StatName 'ClothArmour'.

Item level stat
StatName L NorC Notes
Armour ItemLvl C=code Normal armour
ArmourLow ItemLvl C=code Decrepit armour
ClothArmour ItemLvl Id 1879073002

The normalized stats work with an 'ArmourCode', which is passed by using the C parameter (NorC). It's a letter code which consists out of 3 parts as shown in the table below. You need to choose one of the options for each position and just put them together in sequence. For example, rare medium gloves has the code MGP. A heavy incomparable shield is HShT.
Notes:

  • A special case is the CLoak/back item. This item is currently always medium(used to be light) and therefore doesn't have a category attached. These items are like CLP, CLG, etc.
  • The ArmourLow/Decrepit armour uses only 2 positions. It has it's own unique quality, so position 3 is omitted. Codes for these are like MC, HB, etc.
  • Armour on items is always a whole number (and should be displayed with a thousand separator, which should be specified in the format: %'d). The player level counterpart ArmourT behaves more like a rating and gives a fractured result (default format will be fine).
  • ClothArmour only needs the item level. No armour codes required. It's a very simple Armour value = item level up to a maximum of 50.
  • Be aware that the armour code for an item is not directly linked to how the item is displayed. Sometimes, SSG can make an error or wants to give less armour than is appropriate for the item. For instance, it has happened that gold cloaks (CLG) received the armour values for incomparable versions (CLT). I can't remember more than one quality level difference.
  • For shields: MSh, Medium Shield aka Warden Shield. LSh, Light Shield aka Shield (as for minstrels and captains). HSh, Heavy Shield.. yes.

Armour codes:

Position 1:
Category
L ight
M edium
H eavy

nothing for CLoak
Position 2:
Type/Slot
H elmet (head)
S houlders
CL oak (back)
C hest
G loves (hands)
L eggings (legs)
B oots (feet)
Sh ield
Position 3:
Quality
W hite (normal)
Y ellow (uncommon)
P urple (rare)
T eal (incomparable)
G old (epic)

nothing for Decrepit

Weapon

These stats cover most weapons. Some low level weapons are on other progressions.

Item level stat
StatName L NorC Notes
CombatBaseTacDPS ItemLvl (Li2)Tactical Damage Rating
CombatBaseTacHPS ItemLvl (Li2)Tactical Healing Rating
CombatInHeal ItemLvl (Li2)Incoming Healing Rating (currently: @InHeal#2)
WpnDmgMax ItemLvl C=code (Physical) Weapon Damage Maximum
WpnDmgMin ItemLvl C=code (Physical) Weapon Damage Minimum
WpnDPS ItemLvl C=code (Physical) Weapon DPS

The physical weapon damage stats work with a 'WeaponCode', which is passed by using the C parameter (NorC). It's a letter code which consists out of 3 parts as shown in the table below. You need to choose one of the options for each position and just put them together in sequence. For example, a Li2(Legendary Item new style) bow has the code HBG.
Notes:

  • DPS for a bow is the same as for a two-hander. The difference is the larger variance (difference between min and max damage) in damage.
  • These weapon stats are all fractured numbers. Module:CalcStatTable applies format %'.0f, so fractured number format with thousand separator, to both WpnDmg stats. WpnDPS gets %'.1f which is like the others but with one decimal. Module:CalcStat treats them like any other number.

Weapon codes:

Position 1:
Category
L ight
H eavy
Position 2:
Type
B ow
O ne-handed
T wo-handed
Position 3:
Quality
W hite (normal)
Y ellow (uncommon)
P urple (rare)
T eal (incomparable)
G old (epic)

Creep

<First Part>C at level cap automatically returns <First Part>CI at an item level, which is currently relevant for the requested amount of points in N. In general this is 525, but many exceptions exist which still use the old 515.
<First Part>CI has only been validated for 485(U37), 510(U38), 515(U38.1) and 520(U42). All the Raw versions are rarely used. In those few cases you need to round the fractured values upward to the nearest number dividable by 10.

First Part Notes
Agility
Armour Armour Value
Block Block Rating
BPE Block/Parry/Evade Rating (general reference)
CritDef Critical Defence
CritHit Critical Rating
Evade Evade Rating
Fate
Finesse Finesse Rating
ICMR In-Combat Morale Regeneration
ICPR In-Combat Power Regeneration
Main Agility/Fate/Might/Will (general reference)
Mastery Physical/Tactical Mastery Rating (general reference)
Might
Parry Parry Rating
PhyMas Physical Mastery Rating
PhyMit Physical Mitigation
Resist Resistance Rating
TacMas Tactical Mastery Rating
TacMit Tactical Mitigation
Vitality
Will
End Part L NorC Notes
C PlayerLvl N=points Values only make sense at level cap(150)
CRaw PlayerLvl N=points Non-rounded version
CI ItemLvl N=points Item Level is normally 525, by exception 515
CIRaw ItemLvl N=points Non-rounded version

Examples

Normally:

{{#invoke:CalcStat|calc|ResistC|150|0.6}}

3480

{{#invoke:CalcStat|calc|ResistCI|515|0.6}}

3070

{{#invoke:CalcStat|calc|ResistCI|520|0.6}}

3270

Exception for N=2.4:

{{#invoke:CalcStat|calc|ResistC|150|2.4}}

12300

{{#invoke:CalcStat|calc|ResistCI|515|2.4}}

12300

{{#invoke:CalcStat|calc|ResistCI|520|2.4}}

13100

Raw value:

{{#invoke:CalcStat|calc|ResistCRaw|150|2.4|%f|NoAdj}}

12245.224490

{{#invoke:CalcStat|calc|RoundUp(@ResistCRaw#,-1)|150|2.4|%f|NoAdj}}

12250.000000

Class Data

CalcStat can provide various class related data/stats. The stats can be accessed by using a class name plus 'CD' (Class Data) as a prefix.
The following names are being used:

Class Name
Beorning
Brawler
Burglar
Captain
Champion
Guardian
Hunter
LoreMaster
Mariner
Minstrel
RuneKeeper
Warden

So for example, the correct prefix for a Rune-keeper would be: RuneKeeperCD
In plugins, the prefix can be obtained by using the stat ClassName, with L = ClassId. ClassId is the number which is returned by Player.GetClass(), see GetClass.

Class Data is usually provided in a flexible open way. For instance, a class might have some rating contribution from a main stat, but maybe it hasn't. CalcStat always returns a 0 value when a stat doesn't exists.
Statname postfixes are in a pattern. You need to provide (main) stat and rating stat names like they are in use elsewhere.

Last Part/Postfix Pattern L NorC Notes
<Stat1>To<Stat2> PlayerLvl Stat contribution factor to an other stat. Like MightToBlock, TacMasToOutHeal, FateToCritHit, VitalityToMorale, ArmourToTacMit, etc.
Base<Stat> PlayerLvl Base Stats are stats which you automatically get based on your level. Like BaseAgility, BasePower, BaseMorale, BaseICMR, etc.
CalcTypeComPhyMit PlayerLvl Calculation Type to be used for calculating Common Physical Mitigation percentage.
CalcTypeNonPhyMit PlayerLvl Calculation Type to be used for calculating Non-common Physical Mitigation percentage.
CalcTypeTacMit PlayerLvl Calculation Type to be used for calculating Tactical Mitigation percentage.
CanBlock PlayerLvl Gives 1, if the class is normally able to block at specified level.
HasPower PlayerLvl Normally 1, except for Beorning: 0.

Examples

Calculating the Fate to Critical Rating contribution factor for a Lore-master at player level 91.

{{#invoke:CalcStat|calc|LoreMasterCDFateToCritHit|91||%.0.2f|NoAdj}}

0

Calculating the Base ICMR for a Champion at player level 12.

{{#invoke:CalcStat|calc|ChampionCDBaseICMR|12||%.0.2f|NoAdj}}

0.2

Tactical Mitigation Calculation Type for a Beorning.

{{#invoke:CalcStat|calc|BeorningCDCalcTypeTacMit}}

27

You can use the following mapping for getting to the related stat name for percentage calculations:

Calculation
Type
First Part
Stat Name
12 PhyMitL
13 PhyMitM
14 PhyMitH
25 TacMitL
26 TacMitM
27 TacMitH

Race Data

CalcStat can also provide a few race related data/stats. The stats can be accessed by using a race name plus 'RD' (Race Data) as a prefix.
The following names are being used:

Race Name
Beorning
Dwarf
Elf
HighElf
Hobbit
Man
Hunter
StoutAxe

So for example, the correct prefix for a Stout-axe would be: StoutAxeRD
In plugins, the prefix can be obtained by using the stat RaceName, with L = RaceId. RaceId is the number which is returned by Player.GetRace(), see GetRace.

Race Data is query based like Class Data.
Statname postfixes are in a pattern. You need to provide (main) stat and rating stat names like they are in use elsewhere.

Last Part/Postfix Pattern L NorC Notes
Trait<Stat> PlayerLvl These stats are an accumulation based on (passive) Racial Skills / Characteristics. Examples are TraitFate, TraitVitality, etc.

Examples

Calculating the Trait ICMR for a Dwarf at player level 10.

{{#invoke:CalcStat|calc|DwarfRDTraitICMR|10||%.0.2f|NoAdj}}

0.17

This stat is based on  Unwearying in Battle which can also be calculated with:

{{#invoke:CalcStat|calc|DwarfUnwearBattleICMR|10||%.0.2f|NoAdj}}

0.17

Wiki specific use cases

Negative predefined stat in -[x at Level ...]

In case of a debuff effect, a predefined CalcStat stat has usually a negative value, so it can be used in a table without issues. However, in the case of -[x at Level ...] you run into trouble, because you would get a double minus sign like -[-x at Level ...].
For this we have a couple of solutions:

  • Turn a statname into an expression. Any statname passed which can not not be identified as such, meaning not being composed of only a series of alphanumerical characters, is treated as an expression. As soon as you apply maths like multiplication * etc. this will be automatically the case. What you can do with a negative number is negating it with a minus sign in front of it. However, to use stats in expressions, you'll need to prefix any statnames with the '@' sign first. Also, if needed, to pass a NorC parameter the statname needs to have a '#' appended as well.
  • Less appealing aesthetically, but effective is just removing the '-' outside the brackets.

Examples

In this example '-@' is prefixed, so firstly the stat is recognized as a stat in an expression and then a negation calculation is performed on it. Also, '#' is appended because a ranknumber '3' needs to be passed.

{{color|deeppink|-[{{#invoke:CalcStat|calc|-@HntArmourRendParry#|{{Level Cap}}|3}} at Level {{Level Cap}}] Parry Rating}}

-[15200 at Level 150] Parry Rating

Here, no rank is required, so it's fine to leave out the '#' (wouldn't hurt either, but just not needed).

-[{{#invoke:CalcStat|calc|-@BrgAllInOnExpFinesse|{{Level Cap}}}} at Level {{Level Cap}}] Finesse Rating

-[881 at Level 150] Finesse Rating

Note that with expressions, in many cases you'll need to handle formatting: specify format %'d for main stats for the thousand separator to appear and use %.0.3f for 3 decimals max in power stats. Default is %.0f which simply displays whole numbers without decimals and thousand separators, like in the examples above.

Matching trait/effect stats points from in-game numbers

Predefined stats already have a points amount defined and are tested with game data on a regular bases. You want to prefer to always use these if available. However, where not available, you can use the general stats as described in this article. With this you might have a problem with finding the right amount of stat points when you try to match numbers from tool-tips in-game. Be aware that:

  • Stat point amounts are always 'nice'. They usually can have 1 decimal and steps of 0.2 is a common thing (in more rare cases 0.1). SkillPowerCost can have 2 decimals in the lower region. See Skill Power Cost Calculation for all point amounts.
  • You might have stats buffed by a trait or other effect.
  • Trait/effect(+skill) stats are usually character level stats, so they need the 'T' postfix stat versions. However in some cases, devs chose to use item stats instead. This might have happened intentionally, because the stat will become much lower, perhaps the desired point amount was not available (in the database) to them at a critical time, or it's just a bug. In these cases, you will notice that you need weird point amounts when applying character level statnames. When you get this: try the item level version instead.

Error Codes

Module:CalcStat

Code Description Notes
1001 Missing stat name or expression When no stat name or expression has been given in the template.

CalcStat

Code Description Notes
-1 Missing stat name No stat name has been passed to the function.
-2 Illegal stat name The passed stat name is not a valid name.
-3 Illegal level The passed level parameter is not a number.
-4 Illegal N or C The passed NorC parameter is not a number or text type.

Expressions

Code Description Notes
1 Too many variables used When the number of variables exceeds the maximum(1000).
2 Syntax error Expected to find something logical, but failed to do so.
3 Invalid number of operands When the number of parameters given to an operation/function does not meet expectations.
4 Invalid operand type When a type of a parameter given to an operation/function is not of an expected type.
5 Out of range Within a Choose function, when a selection can't be made based on current index parameter and the number of provided data parameters.
6 Execution error Didn't find an expression result operand, likely because of a problem during translation.
7 Unknown unary operator Based on it's position, a character sequence/token is likely an unary operator (a calculation based on 1 value), but it can't be recognized.
8 Unknown binary operator Based on it's position, a character sequence/token is likely a binary operator (a calculation based on 2 values), but it can't be recognized.
9 Missing binary operator A second value in a binary operation was expected, but not found.
10 Unidentified operand Something was found, but it's not of a recognized identity.
11 Unknown function The used function is not supported.
12 Missing expression Expected a valid expression, but nothing was given like in () with no content.
13 Non-matching operand type Might be when trying to compare two values of different types, like a string and a number.
14 Uninitialized variable When a variable is used in an expression, but it didn't got a value assigned, like in a With construction.
15 Reached maximum processing requests The maximum number of processing requests has been reached during translation (max 10000) or during execution (max 10000 in Wiki and 100000 in Lotro-client plugin).
16 Missing Switch Default expression The Switch construct was not closed with a mandatory Default expression.
17 Missing Switch Case condition A Case condition was expected in a Switch construct, but couldn't be found.
18 Syntax error in Switch Expected a Case or Default inside a Switch construction, but found something else.
19 Missing assignment variable Expected a variable to assign a value to in an assignment group.
20 Missing assignment token '=' A variable was found in an assignment group, but an assignment token is missing.
21 Missing assignment expression A variable assignment was found, but the value or expression to assign is missing.
22 Missing SEsel Default expression SEsel function call detected without the mandatory default expression in the last parameter.
23 Too many parameter groups Parameter groups are like in Until constructs, separated by ':' (so 4 groups for Until).
24 Missing parameter group(s) A parameter group like variable assignments is allowed to be empty, but like with Until, you will always need a fixed number of ":" separators to separate the required number of groups.
25 Parameter group after Switch Default No new Case condition should come after a Default 'condition'.
26 Invalid stat reference Invalid reference like @ Statname (space between @ and name).
27 Double defined level in stat reference When at the same time an attached level and a level expression are used in a stat reference, like @Statname100(200). Either use @Statname100 or @Statname(200) in this case.
28 Unknown error A run-time error occurred in native code.
29 Missing Translation object A public function was called in native code, without providing the mandatory Translation object.
30 Graph point Key already exists Keys (X-coordinates) in the graph points should be unique, but a double value was encountered.