Module:NpcData/doc: Difference between revisions

From The Deadlock Wiki
Jump to navigation Jump to search
LVL (talk | contribs)
No edit summary
Available Functions: outdated example
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
This module allows you to display stats for any NPC (Non-Player Character) from the game's data files which can be found here [[Data:NpcData.json]].
This module allows you to display stats for any NPC (Non-Player Character) from the game's data files which can be found here [[Data:NpcData.json]]. For most uses, it is recommended to use the {{tl|NpcData}} template.


== How to Use ==
== How to Use ==
Line 9: Line 9:
== Available Functions ==
== Available Functions ==


=== Get a Single Stat (`get_npc_var`) ===
=== Get a Single or Nested Stat (`get_npc_var`) ===
This is the most common function. It gets a single number or piece of text for an NPC.
This is the primary function for retrieving NPC data. It can get a simple top-level stat or traverse deeply into nested objects and arrays (up to 6 levels deep via the template).


'''Syntax'''
'''Syntax'''
<code><nowiki>{{#invoke:NpcData|get_npc_var|NPC Name|Stat Name|Rounding}}</nowiki></code>
<code><nowiki>{{#invoke:NpcData|get_npc_var|NPC Name|Key 1|Key 2|...|Rounding}}</nowiki></code>


'''Parameters'''
'''Parameters'''
* '''NPC Name:''' The internal key for the NPC. For example, `npc_boss_tier2` or `trooper_medic`.
* '''NPC Name:''' The internal key for the NPC (e.g., `npc_boss_tier2`, `trooper_normal`).
* '''Stat Name:''' The name of the stat you want to look up. For example, `MaxHealth` or `StompDamage`.
* '''Key 1, Key 2, ...:''' The path to the stat you want.
* '''Rounding:''' (Optional) A number to round the result to that many significant figures.
** For a simple stat, this is one key (e.g., `MaxHealth`).
** For nested data, provide each key in order (e.g., `RebirthModifier`, `RespawnDelay`).
** For arrays (lists), use the position number as a key (e.g., `IntrinsicModifiers`, `1`, `BULLET_ARMOR_DAMAGE_RESIST`).
* '''Rounding:''' (Optional) A number to round the result to that many significant figures. This should always be the last parameter.


'''Examples'''
'''Examples'''
* To get the stomp damage of the Tier 2 Boss:
* To get the max health of a Normal Trooper:
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|npc_boss_tier2|StompDamage}}</nowiki></code>
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|trooper_normal|MaxHealth}}</nowiki></code>
** '''Result:''' {{#invoke:NpcData|get_npc_var|npc_boss_tier2|StompDamage}}
** '''Result:''' {{#invoke:NpcData|get_npc_var|trooper_normal|MaxHealth}}


* To get the max health of a Medic Trooper:
* To get the name of a Walker's second ability (nested in BoundAbilities):
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|trooper_medic|MaxHealth}}</nowiki></code>
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|npc_boss_tier2|BoundAbilities|ESlot_Signature_2|Name}}</nowiki></code>
** '''Result:''' {{#invoke:NpcData|get_npc_var|trooper_medic|MaxHealth}}
** '''Result:''' {{#invoke:NpcData|get_npc_var|npc_boss_tier2|BoundAbilities|ESlot_Signature_2|Name}}


* If you misspell a stat, you will see an error:
* To get a value from a list of modifiers (nested array):
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|trooper_medic|MaxHeath}}</nowiki></code> <!-- Note the typo -->
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|npc_boss_tier2|IntrinsicModifiers|1|BULLET_ARMOR_DAMAGE_RESIST}}</nowiki></code>
** '''Result:''' {{#invoke:NpcData|get_npc_var|trooper_medic|MaxHeath}}
** '''Result:''' {{#invoke:NpcData|get_npc_var|npc_boss_tier2|IntrinsicModifiers|1|BULLET_ARMOR_DAMAGE_RESIST}}


----
* If a path is incorrect, an error message will show the full path attempted:
=== Get an Item from a List (`get_list_elem`) ===
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|trooper_normal|InvalidKey|Stat}}</nowiki></code>
Some NPCs have data stored in lists (or arrays). This function lets you get a single item from a list by its position.
** '''Result:''' <span class="error">Error: Key "InvalidKey" not found in path "trooper_normal".</span>
 
'''Syntax'''
<code><nowiki>{{#invoke:NpcData|get_list_elem|NPC Name|List Name|Position Number}}</nowiki></code>
 
'''Parameters'''
* '''NPC Name:''' The internal key for the NPC.
* '''List Name:''' The name of the list property, e.g., `NearbyEnemyResistanceValues`.
* '''Position Number:''' The position in the list. The first item is `1`, the second is `2`, and so on.
 
'''Example'''
* The Tier 2 Boss has a list of resistance values. To get the 4th value in that list:
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_list_elem|npc_boss_tier2|NearbyEnemyResistanceValues|4}}</nowiki></code>
** '''Result:''' {{#invoke:NpcData|get_list_elem|npc_boss_tier2|NearbyEnemyResistanceValues|4}}
 
----
=== Get an Ability Name (`get_ability_key`) ===
Use this to find the name of an ability in a specific slot for an NPC.
 
'''Syntax'''
<code><nowiki>{{#invoke:NpcData|get_ability_key|NPC Name|Slot Name}}</nowiki></code>
 
'''Parameters'''
* '''NPC Name:''' The internal key for the NPC.
* '''Slot Name:''' The ability slot. Common examples are `ESlot_Weapon_Primary` or `ESlot_Signature_1`.
 
'''Example'''
* To get the name of the Tier 2 Boss's third signature ability:
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_ability_key|npc_boss_tier2|ESlot_Signature_3}}</nowiki></code>
** '''Result:''' {{#invoke:NpcData|get_ability_key|npc_boss_tier2|ESlot_Signature_3}}
 
<includeonly>
</includeonly>

Latest revision as of 14:07, 11 August 2026

This module allows you to display stats for any NPC (Non-Player Character) from the game's data files which can be found here Data:NpcData.json. For most uses, it is recommended to use the {{NpcData}} template.

How to Use

[edit source]

To get data from the module, you use a command that looks like {{#invoke:NpcData|...}}. You will tell it which function to use, which NPC you want, and what information you need.

The basic format is: {{#invoke:NpcData|function_name|parameter1|parameter2|...}}

Available Functions

[edit source]

Get a Single or Nested Stat (`get_npc_var`)

[edit source]

This is the primary function for retrieving NPC data. It can get a simple top-level stat or traverse deeply into nested objects and arrays (up to 6 levels deep via the template).

Syntax {{#invoke:NpcData|get_npc_var|NPC Name|Key 1|Key 2|...|Rounding}}

Parameters

  • NPC Name: The internal key for the NPC (e.g., `npc_boss_tier2`, `trooper_normal`).
  • Key 1, Key 2, ...: The path to the stat you want.
    • For a simple stat, this is one key (e.g., `MaxHealth`).
    • For nested data, provide each key in order (e.g., `RebirthModifier`, `RespawnDelay`).
    • For arrays (lists), use the position number as a key (e.g., `IntrinsicModifiers`, `1`, `BULLET_ARMOR_DAMAGE_RESIST`).
  • Rounding: (Optional) A number to round the result to that many significant figures. This should always be the last parameter.

Examples

  • To get the max health of a Normal Trooper:
    • Code: {{#invoke:NpcData|get_npc_var|trooper_normal|MaxHealth}}
    • Result: 300
  • To get the name of a Walker's second ability (nested in BoundAbilities):
    • Code: {{#invoke:NpcData|get_npc_var|npc_boss_tier2|BoundAbilities|ESlot_Signature_2|Name}}
    • Result: Laser
  • To get a value from a list of modifiers (nested array):
    • Code: {{#invoke:NpcData|get_npc_var|npc_boss_tier2|IntrinsicModifiers|1|BULLET_ARMOR_DAMAGE_RESIST}}
    • Result: 35
  • If a path is incorrect, an error message will show the full path attempted:
    • Code: {{#invoke:NpcData|get_npc_var|trooper_normal|InvalidKey|Stat}}
    • Result: Error: Key "InvalidKey" not found in path "trooper_normal".