Editing Module:NpcData/doc

Jump to navigation Jump to search
Warning: You are not logged in. Once you make an edit, a temporary account will be created for you. Learn more. Log in or create an account to continue receiving notifications after this account expires, and to access other features.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision Your text
Line 10: Line 10:


=== Get a Single or Nested Stat (`get_npc_var`) ===
=== Get a Single or Nested Stat (`get_npc_var`) ===
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).
This is the primary function for retrieving NPC data. It can get a simple top-level stat or traverse into nested objects and arrays using additional parameters.


'''Syntax'''
'''Syntax'''
Line 16: Line 16:


'''Parameters'''
'''Parameters'''
* '''NPC Name:''' The internal key for the NPC (e.g., `npc_boss_tier2`, `trooper_normal`).
* '''NPC Name:''' The internal key for the NPC. For example, `npc_boss_tier2` or `trooper_medic`.
* '''Key 1, Key 2, ...:''' The path to the stat you want.
* '''Key 1, Key 2, ...:''' The path to the stat you want.
** For a simple stat, this is one key (e.g., `MaxHealth`).
** For a simple stat, this is just one key (e.g., `MaxHealth`).
** For nested data, provide each key in order (e.g., `RebirthModifier`, `RespawnDelay`).
** For a nested stat, provide each key as a separate parameter (e.g., `Shield`, `BaseAbsorptionPerSecond`).
** 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.
* '''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 max health of a Normal Trooper:
* To get the max health of a Medic Trooper (a simple stat):
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|trooper_normal|MaxHealth}}</nowiki></code>
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|trooper_medic|MaxHealth}}</nowiki></code>
** '''Result:''' {{#invoke:NpcData|get_npc_var|trooper_normal|MaxHealth}}
** '''Result:''' {{#invoke:NpcData|get_npc_var|trooper_medic|MaxHealth}}


* To get the name of a Walker's second ability (nested in BoundAbilities):
* To get the base shield absorption of the Mid-Boss (a nested stat):
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|npc_boss_tier2|BoundAbilities|ESlot_Signature_2|Name}}</nowiki></code>
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|npc_super_neutral|Shield|BaseAbsorptionPerSecond}}</nowiki></code>
** '''Result:''' {{#invoke:NpcData|get_npc_var|npc_boss_tier2|BoundAbilities|ESlot_Signature_2|Name}}
** '''Result:''' {{#invoke:NpcData|get_npc_var|npc_super_neutral|Shield|BaseAbsorptionPerSecond}}


* To get a value from a list of modifiers (nested array):
* To get the name of the Tier 2 Boss's first bound ability (nested in an object and an array):
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|npc_boss_tier2|IntrinsicModifiers|1|BULLET_ARMOR_DAMAGE_RESIST}}</nowiki></code>
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|npc_boss_tier2|BoundAbilities|1|Name}}</nowiki></code>
** '''Result:''' {{#invoke:NpcData|get_npc_var|npc_boss_tier2|IntrinsicModifiers|1|BULLET_ARMOR_DAMAGE_RESIST}}
** '''Result:''' {{#invoke:NpcData|get_npc_var|npc_boss_tier2|BoundAbilities|1|Name}}


* If a path is incorrect, an error message will show the full path attempted:
* If you misspell a stat, you will see an error:
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|trooper_normal|InvalidKey|Stat}}</nowiki></code>
** '''Code:''' <code><nowiki>{{#invoke:NpcData|get_npc_var|trooper_medic|MaxHeath}}</nowiki></code> <!-- Note the typo -->
** '''Result:''' <span class="error">Error: Key "InvalidKey" not found in path "trooper_normal".</span>
** '''Result:''' {{#invoke:NpcData|get_npc_var|trooper_medic|MaxHeath}}
 
----
=== Get an Item from a List (`get_list_elem`) ===
While `get_npc_var` can also access list items, this function is specifically for that purpose and is used by {{tl|NpcData}} when the `index` parameter is set.
 
'''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}}
 
<includeonly>
</includeonly>
Please note that all contributions to The Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see Deadlock:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template

Pages included on this page: