Terraria Wiki
Advertisement
Terraria Wiki
Siehe auch die englische Modulseite: Module:Npcinfo. Sie enthält möglicherweise umfassendere oder aktuellere Informationen.
Important.svg Diese Seite ist nicht oder unvollständig übersetzt.
Hilf mit, indem du den Text übersetzt und anschließend diesen Hinweis entfernst. Dies entfernt diese Seite auch aus der Liste von Seiten mit unzureichender Übersetzung.

This module is used to obtain the base statistics of each NPC.

It can calculate NPC stats for different numbers of players (for multiplayer) and/or different stages/modes of the game (normal / expert pre-Hardmode / expert Hardmode / expert post-Plantera).

The code is synchronized with version 1.3.5.3Desktop-, Konsolen- und Mobilversion of Terraria.

Usage[]

{{#invoke:Npcinfo|getInfo| id = <npcid> | players = <active players count> | prefix = <prefix for output varnames> }}

id

NPC id. Can be -1 to -65, 1 to 579 (except 76, 146, 408). (76/146/408 are unused)

(optional) players

The number of active players, default is 1. For some bosses and boss-like NPCs in Expert mode, the number of players determines the health.

(optional) prefix

The prefix for the output variable. Default is _npcinfo_. For example, the default variable name for damage is _npcinfo_damage. If you used prefix=my_, the variable name would be my_damage.

When you use this module, it sets a number of DPL variables you can retrieve by using {{#dplvar:_npcinfo_defense}}, for instance. Use {{getNpcInfo}} for easily retrieving these variables and using them in articles.

Main variables:

dplvar
(without prefix)
Content
aiStyle The id of the AI it uses.
boss <empty> = false, 1 = true.
buffImmuneAll Is it immune to all buffs? <empty> = false, 1 = true.
buffImmune A comma-separated list of buffs the NPC is immune to. Only makes sense when buffImmuneAll is false.
friendly Is it a friendly NPC? <empty> = false, 1 = true.
townNPC Is it a town NPC? <empty> = false, 1 = true.
townCritter Is it a town Critter?(by source code, NPCID.Sets.TownCritter) <empty> = false, 1 = true.
critter Is it a critter? (by Critter page.)<empty> = false, 1 = true.
projectileNPC Is it a projectile? <empty> = false, 1 = true.
playersCount The value of the players parameter you used.
netID NPC id, the value of the id parameter you used.
type NPC type id. For a positive NPC id, it is equal to netID. For a negative NPC id, it is the id of the corresponding "master" variant.
internalName NPC internal name.
damage
damage_expert
damage_hardmode
damage_postplantera
damage / defense / knockBack /l ifeMax values for normal, expert pre-Hardmode, expert Hardmode, and expert post-Plantera, respectively.
The knockBackResist values are original value, the value displayed in the NPC infobox is (1 - knockBackResist).
defense
defense_expert
defense_hardmode
defense_postplantera
knockBackResist
knockBackResist_expert
knockBackResist_hardmode
knockBackResist_postplantera
lifeMax
lifeMax_expert
lifeMax_hardmode
lifeMax_postplantera
value
value_expert
value_hardmode
value_postplantera
Coins dropped for normal, expert pre-Hardmode, expert Hardmode, and expert post-Plantera, respectively. Counted in Copper Coins.

Examples[]

See the source code of this documentation for details.

id= -3 (Green Slime):

aiStyle: 1
boss:
buffImmune: 20
buffImmuneAll:
damage: 6
damage_expert:
damage_hardmode:
damage_postplantera:
defense: 0
defense_expert:
defense_hardmode:
defense_postplantera:
dontCountMe:
friendly:
knockBackResist: 1.2
knockBackResist_expert:
knockBackResist_hardmode:
knockBackResist_postplantera:
lifeMax: 14
lifeMax_expert:
lifeMax_hardmode:
lifeMax_postplantera:
internalName: GreenSlime
netID: -3
npcSlots: 1
playersCount:
rarity: 0
scale: 0.9
townNPC:
townCritter:
type: 1
value: 3
value_expert:
value_hardmode:
value_postplantera:

id=4 (Eye of Cthulhu):

aiStyle: 4
boss: 1
buffImmune: 31
buffImmuneAll:
damage: 15
damage_expert:
damage_hardmode:
damage_postplantera:
defense: 12
defense_expert:
defense_hardmode:
defense_postplantera:
dontCountMe:
friendly:
knockBackResist: 0
knockBackResist_expert:
knockBackResist_hardmode:
knockBackResist_postplantera:
lifeMax: 2800
lifeMax_expert:
lifeMax_hardmode:
lifeMax_postplantera:
internalName: EyeofCthulhu
netID: 4
npcSlots: 5
playersCount:
rarity: 0
scale: 1
townNPC:
townCritter:
type: 4
value: 30000
value_expert:
value_hardmode:
value_postplantera:

id=4 (Eye of Cthulhu), players=3 (more health):

aiStyle: 4
boss: 1
buffImmune: 31
buffImmuneAll:
damage: 15
damage_expert:
damage_hardmode:
damage_postplantera:
defense: 12
defense_expert:
defense_hardmode:
defense_postplantera:
dontCountMe:
friendly:
knockBackResist: 0
knockBackResist_expert:
knockBackResist_hardmode:
knockBackResist_postplantera:
lifeMax: 2800
lifeMax_expert:
lifeMax_hardmode:
lifeMax_postplantera:
internalName: EyeofCthulhu
netID: 4
npcSlots: 5
playersCount:
rarity: 0
scale: 1
townNPC:
townCritter:
type: 4
value: 30000
value_expert:
value_hardmode:
value_postplantera:

id=54 (Clothier, NPC):

aiStyle: 7
boss:
buffImmune: 31
buffImmuneAll:
damage: 10
damage_expert:
damage_hardmode:
damage_postplantera:
defense: 15
defense_expert:
defense_hardmode:
defense_postplantera:
dontCountMe:
friendly: 1
knockBackResist: 0.5
knockBackResist_expert:
knockBackResist_hardmode:
knockBackResist_postplantera:
lifeMax: 250
lifeMax_expert:
lifeMax_hardmode:
lifeMax_postplantera:
internalName: Clothier
netID: 54
npcSlots: 1
playersCount:
rarity: 0
scale: 1
townNPC: 1
townCritter:
type: 54
value: 0
value_expert:
value_hardmode:
value_postplantera:


local data = mw.loadData( 'Module:npcinfo/data' ) -- loading data table.

local getArg = function(frame, key)
	local value = frame.args[key]
	if not value then
		return nil
	end
	value = mw.text.trim(value)
	if value == '' then
		return nil
	else
		return value
	end
end

local fields = {'DeathSound',
'HitSound',
'Opacity',
'aiStyle',
'alpha',
'behindTiles',
'banner',
'boss',
'buffImmune',
'buffImmuneAll',
'buffImmuneAllNotWhips',
'catchItem',
'coldDamage',
'damage',
'damage_e',
'damage_e_hm',
'damage_e_pp',
'damage_m',
'damage_m_hm',
'damage_m_pp',
'defense',
'defense_e',
'defense_e_hm',
'defense_e_pp',
'defense_m',
'defense_m_hm',
'defense_m_pp',
'dontCountMe',
'dontTakeDamage',
'friendly',
'height',
'housingCategory',
'internalName',
'knockBackResist',
'knockBackResist_e',
'knockBackResist_e_hm',
'knockBackResist_e_pp',
'knockBackResist_m',
'knockBackResist_m_hm',
'knockBackResist_m_pp',
'lavaImmune',
'lifeMax',
'lifeMax_e',
'lifeMax_e_hm',
'lifeMax_e_pp',
'lifeMax_m',
'lifeMax_m_hm',
'lifeMax_m_pp',
'name',
'netAlways',
'netID',
'noGravity',
'noTileCollide',
'npcSlots',
'rarity',
'scale',
'timeLeft',
'townNPC',
'trapImmune',
'type',
'value',
'value_e',
'value_e_hm',
'value_e_pp',
'value_m',
'value_m_hm',
'value_m_pp',
'width',}


local statname = {}

local clear = function (frame)
		local prefix = getArg(frame, 'prefix') or '_npcinfo_'

		local args = {}
		for i,v in ipairs(fields) do
			table.insert(args, prefix .. v)
			table.insert(args, '')
		end

		frame:callParserFunction{ name = '#dplvar:set', args = args }
	end

local p = {
	getInfo = function (frame)
		local npcid = tonumber(getArg(frame, 'id') or 0)
		local prefix = getArg(frame, 'prefix') or '_npcinfo_'
		local count = tonumber(getArg(frame, 'players') or 1)
		
		if not npcid then
			return
		end

		-- 76/146/408 not used.
		if npcid < -65 or npcid > 667 then
			clear(frame) -- reset all dpl vars
			return
		end

		local result = {}
		for k,v in pairs(data[0]) do
			result[k] = v
		end
		for k,v in pairs(data[npcid]) do
			result[k] = v
		end
		
		local args = {}
		for k,v in pairs(result) do
			args[#args + 1] = prefix .. k
			args[#args + 1] = v
		end
		
		args[#args + 1] = prefix .. '_fields'
		args[#args + 1] = table.concat(fields, ',')
		
		args[#args + 1] = prefix
		args[#args + 1] = 'InvalidNpcinfoStatName'

		frame:callParserFunction{ name = '#dplvar:set', args = args }

	end,

	clear = clear,


	getStat = function (frame)
		local npcid = tonumber(getArg('id')) or tonumber(getArg(1)) or 0
		local stat = getArg('stat') or getArg(2)
		stat = statname[stat] or stat

		if npcid < -65 or npcid > 667 then
			return 
		end

		if not stat then
			return
		end

		return data[npcid][stat] or data[0][stat]

	end,

	-- for module.
	stat = function(npcid, stat)
		stat = statname[stat] or stat

		if npcid < -65 or npcid > 667 then
			return 
		end

		if not stat then
			return
		end

		return data[npcid][stat] or data[0][stat]

	end,
}
p.getinfo = p.getInfo
p.GetInfo = p.getInfo
p.getstat = p.getStat
p.GetStat = p.getStat
return p
Advertisement