NPCs

NPCs are friendly automated non-player characters that provide services to players.

Standing near an NPC and pressing the will open a dialogue window with one or more options for the player to select. Most NPCs are vendors, displaying a shop inventory when the "" option is selected. They sell items to players in exchange for coins, and can be sold items by a player to obtain coins. Some NPCs also have other options that perform other functions.

Most NPCS, appear after various milestones are achieved in game advancement. They move into structures the player must provide, known as houses, which are generally required for town NPCs to remain available. Each NPC will need their own house, with the exception that a pet and non-pet NPC may share a house.

NPCs that have moved into houses reduce enemy spawn rates in the area, an effect that increases the more of them are present. With 3 or more town NPCs nearby, enemies generally stop spawning on or near the visible screen altogether (unless in or ). Players tend to utilize this effect by building large structures (towns or bases) with several integrated houses, to serve as their safe area. These reductions are usually overridden by events like Blood Moons or Goblin Invasions, during which spawn rates return to normal or are elevated, and enemies will once again attack players and NPCs in the area.

Town NPCs generally walk around during the day. They remain still in their assigned houses at night and during events. NPCs have limited health and can take damage, and ultimately die from enemies, traps, lava, or by drowning in water; however, they cannot be attacked directly by players (outside of special Voodoo Doll accessories or Rotten Eggs). They do not suffer from fall damage and their health regenerates over time. The Nurse can furthermore heal herself and other nearby NPCs. Additionally:
 * Town NPCs will attack nearby enemies, each NPC having their own unique form of attack. They will not actively pursue combat, however, but rather attack in an act of self-defense.
 * Town NPCs gain defense and damage boosts based on which bosses have been defeated in the current world.
 * Occasionally, NPCs sit in chairs and randomly "talk" to other NPCs or the player (shown as mouth movement and speech bubbles).

If an NPC is killed, they will respawn after a delay, as long as a suitable vacant house is still available. If the NPC has an inventory or population requirement for their initial spawn (e.g. the 50 silver for the Merchant), that has to be met again for the respawn. However, a rescued NPC will stay rescued, and respawn without needing to be found again.

There are currently 26 /  23 /  22 /  21 /  19 Town NPCs,  8 /  7 /  6 of whom normally appear in Hardmode. An additional 3 /  2 /  1 NPC(s) can be encountered who do not move into houses.

Houses
Each town NPC requires a suitable, vacant house. A house is a room of a certain size enclosed by a frame of blocks, with player-placed background walls, along with a valid light source, flat surface item, and comfort item. Two NPCs cannot live in the same house at the same time. Houses must not be located near Corruption or Crimson, and if those biomes spread too close to an occupied house, the NPC living there may move out from that house.

Town NPC home assignments can be rearranged using NPC flags from the housing menu, where players can also check whether a room is a suitable house.

If a house occupied by an NPC is damaged in a way that makes them invalid, the NPC will move out and walk around the area until a suitable house is restored. If there are vacant houses available in the world, the NPC may move into one of them. If the NPC gets killed and does not have a home, they will not respawn until a new house becomes available.

The Guide and Old Man are unique in that they always spawn upon creating a world. The Guide will usually move into the first house built. The Old Man does not move into a house, but rather remains near the Dungeon's entrance, and respawns the following day if killed (while Skeletron has not yet been defeated).

Buying and selling
Selecting the "" option from the dialogue window, opened by pressing next to a vendor NPC, will display a shop inventory similar to the player's own inventory. Items can be bought by moving them from the shop inventory into the player's inventory; the cost in coins will be subtracted from the player's storage as soon as the item is picked up from the shop inventory. An item can only be bought if their coin cost is available in the player's inventory ( or in the combined player's savings). Holding the button on stackable items allows the player to buy the item in bulk; the buy speed increases the longer the button is held.

Some NPCs sell biome-specific items when they are spoken to in certain biomes. They can be transported there by housing them there and waiting for the night (they will be teleported to their house at night once off-screen) or by using a King or Queen Statue. Note that the NPC does not need to live in the biome; talking to them while the player is in the biome is sufficient.

All NPC vendors can also be used to sell unwanted or surplus items to gain coins. The unwanted item(s) must be in the player's inventory. Hovering over the item while the NPC's inventory screen is open will display its sell value. Items are always sold to vendors at 1/5 of their purchase price. Not all items have a sell value (very common items such as Dirt or Wood have no value). Placing the item in the NPC's shop inventory will sell it, granting the player the sell value into their inventory. Sales to ( and purchases from) NPCs can be cancelled while the NPC's inventory screen is still open: Sold items can be taken back in exchange for the amount they were sold for (and on, purchased items can be sold back in exchange for the amount they were purchased for).

All NPC vendors have the same base buying and selling price. Item prices can be decreased by equipping a Discount Card, which is a rare drop from Pirate Invasions. On, prices can also be higher or lower based on the NPC's happiness level.

Pyons
All NPC vendors will sell when their happiness level is above a certain threshold.

The NPCs are listed in the order in which they are generally likely to be acquired. See Living preferences below for biome and neighbor preferences. The term "other town NPCs" always includes the Old Man, Traveling Merchant, and, but not the.

Town pets
Town pets are special town NPCs that appear at dawn (4:30AM) the day after a pet license item sold by the Zoologist is used. They are not to be confused with pets, which follow the player around. Town pets have distinctive housing assignment banners, and can share houses with another NPC. They count as NPCs for pylon requirements and for decreasing enemy spawn rates in an area, but are not counted as neighboring NPCs in other NPCs' happiness calculations, and indeed do not positively or negatively affect the happiness of other NPCs in any way. Unlike other NPCs, town pets have no means of self-defense.

Town pets offer a unique "" option, which places the player directly in front of the pet when selected, and displays a petting animation. The effect is purely visual.

Other NPCs
The following NPCs are not considered town NPCs because they do not move into houses.

Stat boosts
All NPCs have a base defense stat of 15 (except for the Skeleton Merchant, who has 30), and their base attack stats vary from one NPC to another. In addition, all NPCs gain specific defense and damage boosts based on the bosses that have been defeated so far in the current world. These boosts are completely independent of each other (e.g. the "Hardmode entered" boost can potentially be gained without first attaining the "Eye of Cthulhu beaten" boost, and vice-versa). The boosts are also permanent for a given world, and are applied instantly to all town NPCs, including all Town pets and all other NPCs.

The Dryad also gains boosts to her attack damage. She does not deal damage directly, but rather by inflicting the debuff on enemies. These boosts to the Dryad's Bane debuff are not quite the same as those damage-stat boosts, however, so both kinds of boosts are listed in the following table. Just as with the stat boosts, the Dryad's Bane boosts are independent of each other, are permanent for a given world, and are applied instantly to all enemies inflicted with the debuff.

Defeating the will not give stat boosts to NPCs.

Happiness
NPCs have individual preferences about other NPCs or the biome they live in which in turn affects their prices. When selecting "" in an NPC's dialogue window, the NPC will tell the player if any factors make them currently happy or unhappy, although they will not say what could make them happier or unhappier. For example, if the Guide is located alone in a Forest, he will praise the lack of other NPCs around and the fact he is in a Forest, but he will not hint at the fact he would prefer to live near the Clothier or Zoologist.

Factors that make an NPC happy will lower their prices for goods purchased from them, down to a minimum of, and increase the value of goods sold to them by the inverse of the same modifier, up to a maximum of. Conversely, factors that make an NPC unhappy will raise their prices for goods purchased from them, up to a maximum of, and decrease the value of goods sold to them, down to a minimum. Price modifiers are rounded to the nearest 1% increment. When an NPC that sells items, other than the Skeleton Merchant or Traveling Merchant, has a price modifier at or below 85%, they will allow the player to purchase the pylon for their current biome. The Tax Collector's current tax funds and tax collection limit are both divided by his happiness factor, such that at maximum happiness he will store up to, and at maximum unhappiness he will only store up to ; the amount of taxes that he collects per minute also scales at the same rate.

For the purpose of calculating distances below, the position of an NPC's home tile is considered instead of the NPC itself, unless the NPC is homeless in which case their actual position is considered. The home tile is the block where NPCs stand on during nights and events. NPC's flag will "hook" directly above the home tile. One can easily find the home tile by locating the central column of the 3×3-tile area that the NPC's flag occupies, and then moving all the way down to the tile in the floor of the house. For more detailed definition of a home tile, see House § Home tile score.

Similarly, biome-related preferences will reference the primary biome where the player is, rather than where the NPC or their home is.
 * If the player is in a hybrid biome, and the NPC likes/loves one of the biome, that biome will take priority in the happiness calculation. However, if they are being neutral to, dislike, or hate all the biomes nearby, or they are in the Dungeon, Corruption, or Crimson, the happiness calculation will be based on the following biome priority.
 * Hybrid biomes are not considered, meaning that biomes are evaluated according to priority, with the highest-priority biome the player is in being chosen as the current biome. The list of biomes, in order of greatest to least priority, is as follows:


 * ,, or
 * ,, or
 * ,, or
 * ,, or
 * ,, or
 * ,, or
 * ,, or
 * ,, or
 * ,, or
 * ,, or

An NPC's happiness is computed the moment their chat window is opened, which means that their happiness can be altered very quickly (e.g. by closing their chat window, adding or removing nearby NPC flags, and re-opening the chat window).

Factors affecting happiness
The below price modifiers are applied in the order shown in the table. If the modifier is prefixed with a star, it is multiplied with the running total of the modifier, and if prefixed with an equals sign, the modifier is instead set to that value, overriding all prior logic. The final multiplier is capped at a minimum of 75% and a maximum of 150%. The Traveling Merchant and Skeleton Merchant are special cases; they skip over the happiness-pricing logic in the table below and instead simply always set their multipliers to 100%.

Living preferences
(Note: The Princess is liked by all NPCs, and therefore is not put in every column for the sake of less clutter.)

Emotes
Although it may seem to be random, NPCs "emote" about things depending on their environment.

Tips

 * Each time the Traveling Merchant spawns, he will have a random shop inventory. If the player leaves the world between 4:30AM and 12:00PM, and enters again, there is a 22% chance he will re-spawn (with a new shop inventory).
 * Bound NPCs found underground can be freed by talking to them, after which they will always respawn whenever a vacant house is available. Having an empty room ready for them beforehand will cause them to move in at night as soon as they are off-screen.
 * Bound NPCs can be found by listening to their, especially the Mechanic, as the Dungeon is teeming with enemies.
 * A housing area can be created where all the NPCs can have their biome-specific items: 1500 /  300 Pink Ice Blocks,  101 /  100 Mushroom grass,  140 /  80 Lihzahrd Bricks,  1500 /  1000 Sand Blocks and  7 Gravestone at the  space layer in one screen where the houses are located.
 * Drowning an NPC in water is an easy way to get NPC drops (safer than lava and quicker than Rotten Eggs).
 * Land Mines are a more efficient, but late-game, way to kill NPCs.
 * The book, obtained by fishing during a Blood Moon, can be used to permanently increase the stats of all NPCs.
 * To open a Chest behind an NPC, press the button twice. The first press will open the NPC's dialogue box, the second one will open the Chest.

Trivia

 * During a Blood Moon, all female NPCs except the Party Girl and Princess have dialogue that is more irritable or aggressive than normal. This references, which may cause mood swings and irritability in some people. Both the and the real-world moon cycle occur approximately every 28 days.
 * It is unknown why the Party Girl and Princess are exceptions to this. While the Princess is implied to be a young girl, the Party Girl is certainly an adult.


 * The only NPC interactions required to reach the defeat of the are talking to the Old Man to summon Skeletron and allow the Cultists to spawn, and killing the Guide with the Guide Voodoo Doll to fight the Wall of Flesh.
 * Skeletons will not attack the Skeleton Merchant.
 * The Party Girl is the only NPC to "love" two NPCs as one of their living preference(s).