Template:NpcData/doc: Difference between revisions

From The Deadlock Wiki
Jump to navigation Jump to search
LVL (talk | contribs)
Created page with "This template is a shortcut for Module:NpcData to make it easier to display NPC stats on a page. It can be used to get a single stat (like `MaxHealth`) or an item from a list of stats (like the 4th value in a list of resistances). == How to Use == === Getting a Single Stat === This is the most common use. Provide the information in the following order. '''Syntax''' <code><nowiki>{{NpcData|NPC Name|Stat Name|Rounding}}</nowiki></code> '''Parameters''' * '''First..."
 
LVL (talk | contribs)
Updated doc to reflect current code and made it easier to understand
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
This template is a shortcut for [[Module:NpcData]] to make it easier to display NPC stats on a page.
This template allows you to display NPC stats automatically using the game files. It pulls data directly from [[Data:NpcData.json]].


It can be used to get a single stat (like `MaxHealth`) or an item from a list of stats (like the 4th value in a list of resistances).
== ⚡ Quick Start ==
# Go to [[Data:NpcData.json]] and find the NPC you want.
# Look at the "path" to the stat you need.
# Copy that path into the template, separating each step with a pipe <code>|</code>.


== How to Use ==
'''Basic Example:'''
<code><nowiki>{{NpcData|trooper_medic|MaxHealth}}</nowiki></code>


=== Getting a Single Stat ===
== 📖 How to Build a Path ==
This is the most common use. Provide the information in the following order.
JSON data is like a set of nested folders. To get a specific number, you have to tell the template which folders to open.


'''Syntax'''
=== 1. Find the NPC Name ===
<code><nowiki>{{NpcData|NPC Name|Stat Name|Rounding}}</nowiki></code>
The first parameter is always the "internal name" of the unit.
* '''Common names:''' <code>npc_boss_tier2</code> (Walker), <code>trooper_normal</code> (Trooper), <code>npc_super_neutral</code> (Mid Boss).


'''Parameters'''
=== 2. Follow the Boxes (The "Double Box" Rule) ===
* '''First parameter (NPC Name):''' The internal key for the NPC (e.g., `npc_boss_tier2`).
When looking at the [[Data:NpcData.json|Data Viewer]], follow the lines to your stat.
* '''Second parameter (Stat Name):''' The name of the stat you want to look up (e.g., `MaxHealth`).
* '''Third parameter (Rounding):''' (Optional) A number to round the result to that many significant figures.


'''Examples'''
* '''Standard Stat (Single Box):'''
* To get the max health of a Medic Trooper:
*: If the stat is just inside a standard box, just add its name.
** '''Code:''' <code><nowiki>{{NpcData|trooper_medic|MaxHealth}}</nowiki></code>
*: ''Example:'' <code>ShieldLogic</code> is a standard box.
** '''Result:''' {{NpcData|trooper_medic|MaxHealth}}
*: '''Code:''' <code><nowiki>{{NpcData|npc_super_neutral|ShieldLogic|BaseAbsorptionPerSecond}}</nowiki></code>


* If you misspell a stat, you will see an error:
* '''List / Array (Double Box):'''
** '''Code:''' <code><nowiki>{{NpcData|trooper_medic|MaxHeath}}</nowiki></code> <!-- Note the typo -->
*: '''Important:''' If you see a '''box inside a box''' (like <code>IntrinsicModifiers</code> or <code>ResistValues</code>), this is a '''List'''.
** '''Result:''' {{NpcData|trooper_medic|MaxHeath}}
*: You cannot just ask for the stat; you must use a '''Number''' to tell the template which item in the list to look at (1 for the 1st, 2 for the 2nd, etc.).
*: ''Example:'' <code>IntrinsicModifiers</code> is a list.
*: '''Code:''' <code><nowiki>{{NpcData|npc_super_neutral|IntrinsicModifiers|1|HEALTH_REGEN_PER_SECOND}}</nowiki></code>


----
=== 3. Rounding (Optional) ===
=== Getting an Item from a List ===
If the number is too long (e.g., 0.333333), you can add a number at the very end to round it.
To get a single value from a list, you must use the named `index=` parameter.
* '''Note:''' This uses '''Significant Figures''', not decimal places.
* <code>...|2}}</code> turns <code>1250</code> into <code>1300</code>.
* <code>...|2}}</code> turns <code>0.125</code> into <code>0.13</code>.


'''Syntax'''
== 📋 Copy-Paste Examples ==
<code><nowiki>{{NpcData|NPC Name|List Name|index=Position Number}}</nowiki></code>


'''Parameters'''
; Simple Stats
* '''First parameter (NPC Name):''' The internal key for the NPC.
: <code><nowiki>{{NpcData|trooper_medic|MaxHealth}}</nowiki></code> → {{NpcData|trooper_medic|MaxHealth}}
* '''Second parameter (List Name):''' The name of the list property (e.g., `NearbyEnemyResistanceValues`).
* '''index=''' The position in the list. The first item is `1`, the second is `2`, and so on.


'''Example'''
; Nested Stats (Shields, Regen)
* The Tier 2 Boss has a list of resistance values. To get the 4th value in that list:
: <code><nowiki>{{NpcData|npc_super_neutral|ShieldLogic|BaseAbsorptionPerSecond}}</nowiki></code> → {{NpcData|npc_super_neutral|ShieldLogic|BaseAbsorptionPerSecond}}
** '''Code:''' <code><nowiki>{{NpcData|npc_boss_tier2|NearbyEnemyResistanceValues|index=4}}</nowiki></code>
 
** '''Result:''' {{NpcData|npc_boss_tier2|NearbyEnemyResistanceValues|index=4}}
; Abilities (Using Slot Names)
: <code><nowiki>{{NpcData|npc_boss_tier2|BoundAbilities|ESlot_Signature_1|Damage}}</nowiki></code> → {{NpcData|npc_boss_tier2|BoundAbilities|ESlot_Signature_1|Damage}}
 
; Lists/Arrays (Using Numbers)
: ''Getting the 4th value from a list of resistance numbers:''
: <code><nowiki>{{NpcData|npc_boss_tier2|NearbyEnemyResist|ResistValues|4}}</nowiki></code> → {{NpcData|npc_boss_tier2|NearbyEnemyResist|ResistValues|4}}
 
; Rounding
: <code><nowiki>{{NpcData|npc_boss_tier2|MaxHealth|2}}</nowiki></code> → {{NpcData|npc_boss_tier2|MaxHealth|2}}
 
== ❌ Common Errors ==
* <span class="error">Error: Key "X" not found...</span>
*: You likely spelled the stat name wrong, or you forgot a step in the path (like missing a folder name).
* <span class="error">Error: Path points to a table/object...</span>
*: You stopped too early! You pointed to a "folder" (like <code>ShieldLogic</code>) instead of a specific number inside it. Add one more parameter to get the specific stat.
 
<templatedata>
{
"description": "Displays NPC stats from game files. Use the Data:NpcData.json page to find the correct paths.",
"params": {
"1": {
"label": "NPC Name",
"description": "The internal key (e.g., npc_boss_tier2).",
"type": "string",
"required": true,
"example": "trooper_medic"
},
"2": {
"label": "Path Step 1",
"description": "The first step in the path (e.g., MaxHealth or BoundAbilities).",
"type": "string",
"required": true,
"example": "MaxHealth"
},
"3": {
"label": "Path Step 2 / Rounding",
"description": "The next step in the path OR an optional rounding number.",
"type": "string",
"required": false
},
"4": {
"label": "Path Step 3 / Rounding",
"description": "The next step in the path OR an optional rounding number.",
"type": "string",
"required": false
},
"5": {
"label": "Path Step 4 / Rounding",
"description": "The next step in the path OR an optional rounding number.",
"type": "string",
"required": false
},
"6": {
"label": "Path Step 5 / Rounding",
"description": "The next step in the path OR an optional rounding number.",
"type": "string",
"required": false
},
"7": {
"label": "Path Step 6 / Rounding",
"description": "The next step in the path OR an optional rounding number.",
"type": "string",
"required": false
},
"8": {
"label": "Rounding",
"description": "Optional: Round to this many Significant Figures (e.g., 2). Only used if this is the final parameter.",
"type": "number",
"required": false
}
},
"format": "inline"
}
</templatedata>
 
<includeonly>
[[Category:Templates]]
</includeonly><noinclude>
[[Category:Template documentation]]
</noinclude>

Latest revision as of 15:51, 7 February 2026

This template allows you to display NPC stats automatically using the game files. It pulls data directly from Data:NpcData.json.

⚡ Quick Start

[edit source]
  1. Go to Data:NpcData.json and find the NPC you want.
  2. Look at the "path" to the stat you need.
  3. Copy that path into the template, separating each step with a pipe |.

Basic Example: {{NpcData|trooper_medic|MaxHealth}}

📖 How to Build a Path

[edit source]

JSON data is like a set of nested folders. To get a specific number, you have to tell the template which folders to open.

1. Find the NPC Name

[edit source]

The first parameter is always the "internal name" of the unit.

  • Common names: npc_boss_tier2 (Walker), trooper_normal (Trooper), npc_super_neutral (Mid Boss).

2. Follow the Boxes (The "Double Box" Rule)

[edit source]

When looking at the Data Viewer, follow the lines to your stat.

  • Standard Stat (Single Box):
    If the stat is just inside a standard box, just add its name.
    Example: ShieldLogic is a standard box.
    Code: {{NpcData|npc_super_neutral|ShieldLogic|BaseAbsorptionPerSecond}}
  • List / Array (Double Box):
    Important: If you see a box inside a box (like IntrinsicModifiers or ResistValues), this is a List.
    You cannot just ask for the stat; you must use a Number to tell the template which item in the list to look at (1 for the 1st, 2 for the 2nd, etc.).
    Example: IntrinsicModifiers is a list.
    Code: {{NpcData|npc_super_neutral|IntrinsicModifiers|1|HEALTH_REGEN_PER_SECOND}}

3. Rounding (Optional)

[edit source]

If the number is too long (e.g., 0.333333), you can add a number at the very end to round it.

  • Note: This uses Significant Figures, not decimal places.
  • ...|2}} turns 1250 into 1300.
  • ...|2}} turns 0.125 into 0.13.

📋 Copy-Paste Examples

[edit source]
Simple Stats
{{NpcData|trooper_medic|MaxHealth}} → 350
Nested Stats (Shields, Regen)
{{NpcData|npc_super_neutral|ShieldLogic|BaseAbsorptionPerSecond}} → 35
Abilities (Using Slot Names)
{{NpcData|npc_boss_tier2|BoundAbilities|ESlot_Signature_1|Damage}}Error: Key "Damage" not found in path "npc_boss_tier2.BoundAbilities.ESlot_Signature_1".
Lists/Arrays (Using Numbers)
Getting the 4th value from a list of resistance numbers:
{{NpcData|npc_boss_tier2|NearbyEnemyResist|ResistValues|4}} → 20
Rounding
{{NpcData|npc_boss_tier2|MaxHealth|2}} → 6000

❌ Common Errors

[edit source]
  • Error: Key "X" not found...
    You likely spelled the stat name wrong, or you forgot a step in the path (like missing a folder name).
  • Error: Path points to a table/object...
    You stopped too early! You pointed to a "folder" (like ShieldLogic) instead of a specific number inside it. Add one more parameter to get the specific stat.

Displays NPC stats from game files. Use the Data:NpcData.json page to find the correct paths.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
NPC Name1

The internal key (e.g., npc_boss_tier2).

Example
trooper_medic
Stringrequired
Path Step 12

The first step in the path (e.g., MaxHealth or BoundAbilities).

Example
MaxHealth
Stringrequired
Path Step 2 / Rounding3

The next step in the path OR an optional rounding number.

Stringoptional
Path Step 3 / Rounding4

The next step in the path OR an optional rounding number.

Stringoptional
Path Step 4 / Rounding5

The next step in the path OR an optional rounding number.

Stringoptional
Path Step 5 / Rounding6

The next step in the path OR an optional rounding number.

Stringoptional
Path Step 6 / Rounding7

The next step in the path OR an optional rounding number.

Stringoptional
Rounding8

Optional: Round to this many Significant Figures (e.g., 2). Only used if this is the final parameter.

Numberoptional