Template:NpcData/doc: Difference between revisionsGive feedback
No edit summary |
Updated doc to reflect current code and made it easier to understand |
||
| Line 1: | Line 1: | ||
This template | This template allows you to display NPC stats automatically using the game files. It pulls data directly from [[Data:NpcData.json]]. | ||
== ⚡ 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>. | |||
'''Basic Example:''' | |||
<code><nowiki>{{NpcData|trooper_medic|MaxHealth}}</nowiki></code> | |||
== | == 📖 How to Build a Path == | ||
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 === | ||
<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). | |||
=== 2. Follow the Boxes (The "Double Box" Rule) === | |||
When looking at the [[Data:NpcData.json|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:'' <code>ShieldLogic</code> is a standard box. | ||
*: '''Code:''' <code><nowiki>{{NpcData|npc_super_neutral|ShieldLogic|BaseAbsorptionPerSecond}}</nowiki></code> | |||
* | * '''List / Array (Double Box):''' | ||
* | *: '''Important:''' If you see a '''box inside a box''' (like <code>IntrinsicModifiers</code> or <code>ResistValues</code>), 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:'' <code>IntrinsicModifiers</code> is a list. | |||
*: '''Code:''' <code><nowiki>{{NpcData|npc_super_neutral|IntrinsicModifiers|1|HEALTH_REGEN_PER_SECOND}}</nowiki></code> | |||
=== 3. Rounding (Optional) === | |||
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. | ||
* <code>...|2}}</code> turns <code>1250</code> into <code>1300</code>. | |||
* <code>...|2}}</code> turns <code>0.125</code> into <code>0.13</code>. | |||
== 📋 Copy-Paste Examples == | |||
; Simple Stats | |||
: <code><nowiki>{{NpcData|trooper_medic|MaxHealth}}</nowiki></code> → {{NpcData|trooper_medic|MaxHealth}} | |||
; Nested Stats (Shields, Regen) | |||
<code><nowiki>{{NpcData| | : <code><nowiki>{{NpcData|npc_super_neutral|ShieldLogic|BaseAbsorptionPerSecond}}</nowiki></code> → {{NpcData|npc_super_neutral|ShieldLogic|BaseAbsorptionPerSecond}} | ||
; 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> | <templatedata> | ||
{ | { | ||
"description": " | "description": "Displays NPC stats from game files. Use the Data:NpcData.json page to find the correct paths.", | ||
"params": { | "params": { | ||
"1": { | "1": { | ||
"label": "NPC Name", | "label": "NPC Name", | ||
"description": "The internal key | "description": "The internal key (e.g., npc_boss_tier2).", | ||
"type": "string", | "type": "string", | ||
"required": true, | "required": true, | ||
"example": "trooper_medic" | "example": "trooper_medic" | ||
}, | }, | ||
"2": { | "2": { | ||
"label": " | "label": "Path Step 1", | ||
"description": "The | "description": "The first step in the path (e.g., MaxHealth or BoundAbilities).", | ||
"type": "string", | "type": "string", | ||
"required": true, | "required": true, | ||
"example": "MaxHealth" | "example": "MaxHealth" | ||
}, | }, | ||
"3": { | "3": { | ||
"label": " | "label": "Path Step 2 / Rounding", | ||
"description": "The | "description": "The next step in the path OR an optional rounding number.", | ||
"type": "string", | "type": "string", | ||
"required": false | "required": false | ||
}, | }, | ||
"4": { | "4": { | ||
"label": " | "label": "Path Step 3 / Rounding", | ||
"description": "The | "description": "The next step in the path OR an optional rounding number.", | ||
"type": "string", | "type": "string", | ||
"required": false | "required": false | ||
}, | }, | ||
"5": { | "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", | "label": "Rounding", | ||
"description": " | "description": "Optional: Round to this many Significant Figures (e.g., 2). Only used if this is the final parameter.", | ||
"type": "number", | "type": "number", | ||
"required": false | "required": false | ||
} | } | ||
}, | }, | ||