Template:GetNpcInfo

From Terraria Wiki
Jump to navigation Jump to search
This template uses Lua.
This template uses Module:Npcinfo, a script written in the Lua programming language. To learn more about Lua, see Terraria Wiki:Lua.
Important.svg
CAUTION: Terraria Wiki code is complex!!!
If you want to use this code on another wiki, wiki.gg staff are not able to assist you.
Please consider picking a different wiki to adapt code from, or making your own templates!
Remember that content on a wiki is more important than fancy formatting.
Template-info.svg Documentation The documentation below is transcluded from Template:GetNpcInfo/doc. (edit | history)

This template is used to dynamically and reliably display an NPC's stats. It is based on Module:Npcinfo, which takes its data directly from Terraria's source code. This facilitates displaying stats without having to change them in case of updates. {{npcinfo}} can be used as a shortcut for this template.

An example usage can be found on the Bosses page, where the health of almost every boss is presented using this template.

Usage

{{ npcinfo | <name or ID of the NPC> | <specific stat> | <mode> (optional) | format = y/yes (optional) }}

First unnamed parameter

Name or ID of the NPC. If it is the ID, use the parameter $id instead, it is faster. If it is the name, it must be valid per Template:NpcIdFromName.

Second unnamed parameter

Specific stat to be displayed; see the tables below for valid values. See below for how to output all stats.

Third unnamed parameter

Specific game mode; can be expert/e/e_hm/e_pp/expert_prehardmode/expert_hardmode/expert_postplantera/expert_post_planteraexpert_after_plantera/m/master/m_hm...

Original raw variable name
(case-insensitive)
Alias Note
aiStyle ai ID of the AI the NPC uses.
boss Prints 1 if NPC is a boss.
buffImmuneAll Prints 1 if NPC is immune to all buffs.
buffImmune immunities
immune
A comma-separated, linked list of buffs the NPC is immune to.
critter Prints 1 if NPC is a critter (by wiki definition).
damage Damage the NPC deals in normal mode / Expert(Desktop, Console and Mobile versions) pre-Hardmode / Expert Hardmode / Expert post-Plantera.
damage_expert
damage_hardmode
damage_postplantera
DeathSound Sound effect that is played when this NPC takes damage (or reflects a projectile), wrapped in {{sound}} without a caption. Note that the listed sound is only the base sound; it might be played with modified pitch and volume in-game.
defense Defense of the NPC in normal mode / Expert pre-Hardmode / Expert Hardmode / Expert post-Plantera.
defense_expert
defense_hardmode
defense_postplantera
friendly Prints 1 if NPC is a friendly NPC.
HitSound Sound effect that is played when this NPC dies, wrapped in {{sound}} without a caption. Note that the listed sound is only the base sound; it might be played with modified pitch and volume in-game.
internalName internal name Internal name of the NPC.
knockBackResist knockback
kb
Knockback resistance of the NPC in normal mode / Expert pre-Hardmode / Expert Hardmode / Expert post-Plantera.
knockBackResist_expert knockback_expert
kb_expert
knockBackResist_hardmode knockback_hardmode
kb_hardmode
knockBackResist_postplantera knockback_postplantera
kb_postplantera
lifeMax maxlife
health
hp
Max Health of the NPC in normal mode / Expert pre-Hardmode / Expert Hardmode / Expert post-Plantera.
lifeMax_expert maxlife_expert
health_expert
hp_expert
lifeMax_hardmode maxlife_hardmode
health_hardmode
hp_hardmode
lifeMax_postplantera maxlife_postplantera
health_postplantera
hp_postplantera
netID id ID of the NPC.
townNPC Prints 1 if NPC is a Town NPC.
townCritter Prints 1 if NPC is a town critter (by source code definition).
type Corresponding "base" or "master" variant of this NPC if netID is negative. Equal to netID if netID is positive.
projectileNPC Prints 1 if NPC is a projectile.
value coins
coindrop
Amount of coins the NPC drops in normal mode / Expert pre-Hardmode / Expert Hardmode / Expert post-Plantera.
value_expert coins_expert
coindrop_expert
value_hardmode coins_hardmode
coindrop_hardmode
value_postplantera coins_postplantera
coindrop_postplantera
Combined values (only if not using raw=y)
damage_all Displays the combined values of normal mode / Expert pre-Hardmode / Expert Hardmode / Expert post-Plantera. Value (coins dropped) is in Copper Coins.
defense_all
knockBackResist_all knockback_all
kb_all
lifeMax_all maxlife_all
health_all
hp_all
value_all coin_all
coindrop_all
damage_expert_all Displays the combined values of Expert pre-Hardmode / Expert Hardmode / Expert post-Plantera. Value (coins dropped) is in Copper Coins.
defense_expert_all
knockBackResist_expert_all knockback_all
kb_all
lifeMax_expert_all maxlife_all
health_all
hp_all
value_expert_all coin_all
coindrop_all
format = y/yes

Use this parameter to wrap the variable in the magic word {{formatnum:}} (documentation). Only available when using a second unnamed parameter.

raw = y/yes

Use this parameter to output the value exactly as it exists in the source code. See Module:Npcinfo for information about how to interpret the output values. Only available when using a second unnamed parameter. Requires the second unnamed parameter to constitute an original variable name, i.e. no aliases are allowed. format is still applicable. Renders the second unnamed parameter case-sensitive.

Examples

Specific stats

  • The Eye of Cthulhu has {{npcinfo|Eye of Cthulhu|hp|format=y}} / {{expert|{{npcinfo|Eye of Cthulhu|hp_expert}}}} health and deals {{npcinfo|Eye of Cthulhu|damage}} damage. It is immune to the {{npcinfo|Eye of Cthulhu|immunities}} debuff.
results in:
The Eye of Cthulhu has 2,800 / 3640 health and deals 15 damage. It is immune to the Confused debuff.
  • {{npcinfo|Blue Slime|damage}} results in: 7
  • {{npcinfo|1|damage}} results in: 7
  • {{npcinfo|id=1|2=hp_all}} results in: 25/50274330/75411495
  • {{npcinfo|Blue Slime|hp_expert_all}} results in: 50274330/75411495
  • {{npcinfo|Blue Slime|knockback_all}} results in: 0%/10%/20%

Maximum/minimum ID

Use {{npcinfo/maxId}} to display the greatest valid NPC ID: 696.

Use {{npcinfo/minId}} to display the lowest valid NPC ID: -65.

These can be used, for instance, to loop over all NPC IDs: {{#loop:id|{{npcinfo/minId}}|{{#expr:{{npcinfo/maxId}}-{{npcinfo/minId}}+1}}|{{#var:id}}&#32;}} → -65 -64 -63 ... -2 -1 0 1 2 ... 694 695 696

All stats

Use {{npc stats table}} to display all available stats of an NPC.

  • {{npc stats table|Blue Slime|collapsible=yes|style=min-width:270px}} results in:
Blue Slime (ID: 1)
Stat Value
aiStyle 1
alpha 175
banner 1683
behindTiles
boss
buffImmune 30, 375, 20
buffImmuneAll
buffImmuneAllNotWhips
catchItem 0
coldDamage
damage 7
damage_e 14
damage_e_hm 62
damage_e_pp 74
damage_m 21
damage_m_hm 93
damage_m_pp 111
DeathSound NPC_Killed_1
defense 2
defense_e 2
defense_e_hm 10
defense_e_pp 12
defense_m 2
defense_m_hm 10
defense_m_pp 12
dontCountMe
dontTakeDamage
friendly
height 18
HitSound NPC_Hit_1
housingCategory 0
internalName BlueSlime
knockBackResist 1
knockBackResist_e 0.9
knockBackResist_e_hm 0.9
knockBackResist_e_pp 0.9
knockBackResist_m 0.8
knockBackResist_m_hm 0.8
knockBackResist_m_pp 0.8
lavaImmune
lifeMax 25
lifeMax_e 50
lifeMax_e_hm 274
lifeMax_e_pp 330
lifeMax_m 75
lifeMax_m_hm 411
lifeMax_m_pp 495
name Blue Slime
netAlways
netID 1
noGravity
noTileCollide
npcSlots 1
Opacity
rarity 0
scale 1
timeLeft 750
townNPC
trapImmune
type 1
value 25
value_e 62
value_e_hm 250
value_e_pp 300
value_m 62
value_m_hm 250
value_m_pp 300
width 24