2using System.Collections.Generic;
4using Microsoft.Xna.Framework;
5using Microsoft.Xna.Framework.Graphics;
6using ReLogic.Utilities;
62 public int Music {
get;
set; } = -1;
98 Type type = GetType();
248 public virtual void AI()
static Asset< Texture2D >[] Npc
static readonly IdDictionary Search
static string GetTextValue(string key)
Retrieves the text value for a specified localization key. The text returned will be for the currentl...
Contains methods to access or retrieve localization values. The Localization Guideteaches more about ...
Contains the localization value corresponding to a key for the current game language....
static Dictionary< int, byte > npcLifeBytes
Tag compounds contained named values, serialisable as per the NBT spec: NBT spec wiki page All primi...
Manages content added by mods. Liasons between mod content and Terraria's arrays and oversees the Loa...
virtual ? Color GetAlpha(Color drawColor)
Allows you to determine the color and transparency in which this NPC is drawn. Return null to use the...
override NPC CreateTemplateEntity()
virtual void OnChatButtonClicked(bool firstButton, ref string shopName)
Allows you to make something happen whenever a button is clicked on this NPC's chat window....
virtual void ModifyNPCLoot(NPCLoot npcLoot)
Allows you to add and modify NPC loot tables to drop on death and to appear in the Bestiary....
virtual void BossHeadSlot(ref int index)
Allows you to customize the boss head texture used by an NPC based on its state. Set index to -1 to s...
virtual bool UsesPartyHat()
Allows you to determine whether this town NPC wears a party hat during a party. Returns true by defau...
virtual bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
Allows you to draw things behind this NPC, or to modify the way this NPC is drawn....
virtual bool NeedSaving()
Makes this ModNPC save along the world even if it's not a townNPC. Defaults to false....
int AIType
Determines which type of vanilla NPC this ModNPC will copy the behavior (AI) of. Leave as 0 to not co...
virtual bool CanHitNPC(NPC target)
Allows you to determine whether this NPC can hit the given friendly NPC. Return false to block the NP...
virtual void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
Allows you to set an NPC's information in the Bestiary.
int Banner
The type of NPC that this NPC will be considered as when determining banner drops and banner bonuses....
virtual void TownNPCAttackStrength(ref int damage, ref float knockback)
Allows you to determine the damage and knockback of this town NPC's attack before the damage is scale...
float DrawOffsetY
The vertical offset used for drawing this NPC. Defaults to 0.
virtual void DrawBehind(int index)
When used in conjunction with "NPC.hide = true", allows you to specify that this NPC should be drawn ...
virtual bool CanTownNPCSpawn(int numTownNPCs)
Whether or not the conditions have been met for this town NPC to be able to move into town....
virtual void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown)
Allows you to determine the cooldown between each of this town NPC's attack. The cooldown will be a n...
virtual void ModifyHitByItem(Player player, Item item, ref NPC.HitModifiers modifiers)
Allows you to modify the damage, knockback, etc., that this NPC takes from a melee weapon....
bool TownNPCStayingHomeless
Setting this to true will make the NPC not appear in the housing menu nor make it find an house.
virtual void FindFrame(int frameHeight)
Allows you to modify the frame from this NPC's texture that is drawn, which is necessary in order to ...
virtual void ModifyTypeName(ref string typeName)
Allows you to modify the type name of this NPC dynamically.
virtual bool CanHitPlayer(Player target, ref int cooldownSlot)
Allows you to determine whether this NPC can hit the given player. Return false to block this NPC fro...
virtual void ModifyHitByProjectile(Projectile projectile, ref NPC.HitModifiers modifiers)
Allows you to modify the damage, knockback, etc., that this NPC takes from a projectile....
virtual void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset)
Allows you to determine the speed at which this town NPC throws a projectile when it attacks....
virtual void ReceiveExtraAI(BinaryReader reader)
Use this to receive information that was sent in M:Terraria.ModLoader.ModNPC.SendExtraAI(System....
virtual void SaveData(TagCompound tag)
Allows you to save custom data for the given item. Allows you to save custom data for the given npc....
virtual ? bool CanBeHitByProjectile(Projectile projectile)
Allows you to determine whether this NPC can be hit by the given projectile. Return true to allow hit...
virtual void OnHitByItem(Player player, Item item, NPC.HitInfo hit, int damageDone)
Allows you to create special effects when this NPC is hit by a melee weapon. Runs on the client or ...
virtual void DrawEffects(ref Color drawColor)
Allows you to add special visual effects to this NPC (such as creating dust), and modify the color in...
virtual bool PreKill()
Allows you to determine whether or not this NPC will do anything upon death (besides dying)....
virtual string HeadTexture
The file name of this NPC's head texture file, to be used in autoloading.
virtual ITownNPCProfile TownNPCProfile()
Allows you to set the town NPC profile that this NPC uses. By default, returns null,...
virtual bool PreAI()
Allows you to determine how this NPC behaves. Return false to stop the vanilla AI and the AI hook fro...
virtual void DrawTownAttackSwing(ref Texture2D item, ref Rectangle itemFrame, ref int itemSize, ref float scale, ref Vector2 offset)
Allows you to customize how this town NPC's weapon is drawn when this NPC is swinging it (this NPC mu...
virtual string Texture
The file name of this type's texture file in the mod loader's file space.
virtual void TownNPCAttackSwing(ref int itemWidth, ref int itemHeight)
Allows you to determine the width and height of the item this town NPC swings when it attacks,...
virtual ? bool CanCollideWithPlayerMeleeAttack(Player player, Item item, Rectangle meleeAttackHitbox)
Allows you to determine whether an NPC can be collided with the player melee weapon when swung....
virtual void ResetEffects()
This is where you reset any fields you add to your subclass to their default states....
virtual void DrawTownAttackGun(ref Texture2D item, ref Rectangle itemFrame, ref float scale, ref int horizontalHoldoutOffset)
Allows you to customize how this town NPC's weapon is drawn when this NPC is shooting (this NPC must ...
virtual bool CanBeHitByNPC(NPC attacker)
Allows you to determine whether a friendly NPC can be hit by an NPC. Return false to block the attack...
virtual bool CheckConditions(int left, int right, int top, int bottom)
Allows you to define special conditions required for this town NPC's house. For example,...
virtual void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
Allows you to draw things in front of this NPC. Substract screenPos from the draw position before dra...
int BannerItem
The type of the item this NPC drops for every 50 times it is defeated. For any ModNPC whose banner fi...
virtual void ModifyHitPlayer(Player target, ref Player.HurtModifiers modifiers)
Allows you to modify the damage, etc., that this NPC does to a player. Runs on the local client.
virtual void BossHeadSpriteEffects(ref SpriteEffects spriteEffects)
Allows you to flip this NPC's boss head icon on the map.
virtual void TownNPCAttackShoot(ref bool inBetweenShots)
Allows you to tell the game that this town NPC has already created a projectile and will still create...
virtual void OnSpawn(IEntitySource source)
Gets called when your NPC spawns in world.
virtual void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
Allows you to modify the damage, knockback, etc., that this NPC does to a friendly NPC....
virtual bool CanChat()
Allows you to determine whether this NPC can talk with the player. By default, returns if the NPC is ...
virtual void AutoStaticDefaults()
Automatically sets certain static defaults. Override this if you do not want the properties to be set...
virtual void OnKill()
Allows you to make things happen when this NPC dies (for example, dropping items and setting ModSyste...
virtual void AddShops()
Allows you to add shops to this NPC, similar to adding recipes for items. Make a new T:Terraria....
int Music
The ID of the music that plays when this NPC is on or near the screen. Defaults to -1,...
virtual void UpdateLifeRegen(ref int damage)
Allows you to make the NPC either regenerate health or take damage over time by setting NPC....
virtual void ModifyIncomingHit(ref NPC.HitModifiers modifiers)
Allows you to use a custom damage formula for when this NPC takes damage from any source....
virtual void SetDefaults()
Allows you to set all your NPC's properties, such as width, damage, aiStyle, lifeMax,...
virtual void OnCaughtBy(Player player, Item item, bool failed)
Allows you to make things happen when the given item attempts to catch this NPC.
virtual void AI()
Allows you to determine how this NPC behaves. This will only be called if PreAI returns true.
virtual void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone)
Allows you to create special effects when this NPC is hit by a projectile.
virtual string GetChat()
Allows you to give this NPC a chat message when a player talks to it. By default returns something em...
virtual LocalizedText DisplayName
The translations for the display name of this NPC.
virtual void SetChatButtons(ref string button, ref string button2)
Allows you to set the text for the buttons that appear on this NPC's chat window. A parameter left as...
override void SetupContent()
If you make a new ModType, seal this override, and call M:Terraria.ModLoader.ModType....
virtual void OnHitPlayer(Player target, Player.HurtInfo hurtInfo)
Allows you to create special effects when this NPC hits a player (for example, inflicting debuffs)....
virtual ? bool CanFallThroughPlatforms()
Allows you to determine how and when this NPC can fall through platforms and similar tiles....
virtual ? int PickEmote(Player closestPlayer, List< int > emoteList, WorldUIAnchor otherAnchor)
Allows you to change the emote that the NPC will pick.
virtual ? bool DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
Allows you to control how the health bar for this NPC is drawn. The hbPosition parameter is the same ...
virtual string BossHeadTexture
This file name of this NPC's boss head texture file, to be used in autoloading.
virtual void ModifyActiveShop(string shopName, Item[] items)
Allows you to modify the contents of a shop whenever player opens it. To create a shop,...
virtual void BossHeadRotation(ref float rotation)
Allows you to customize the rotation of this NPC's boss head icon on the map.
virtual void ModifyHoverBoundingBox(ref Rectangle boundingBox)
Allows you to modify the bounding box for hovering over this NPC (affects things like whether or not ...
virtual void TownNPCAttackProj(ref int projType, ref int attackDelay)
Allows you to determine the projectile type of this town NPC's attack, and how long it takes for the ...
virtual int SpawnNPC(int tileX, int tileY)
Allows you to customize how this NPC is created when it naturally spawns (for example,...
virtual void TownNPCAttackMagic(ref float auraLightMultiplier)
Allows you to control the brightness of the light emitted by this town NPC's aura when it performs a ...
virtual bool SpecialOnKill()
Allows you to call OnKill on your own when the NPC dies, rather then letting vanilla call it on its o...
virtual ? bool CanBeHitByItem(Player player, Item item)
Allows you to determine whether this NPC can be hit by the given melee weapon when swung....
virtual void OnHitNPC(NPC target, NPC.HitInfo hit)
Allows you to create special effects when this NPC hits a friendly NPC. Runs in single player or on...
virtual bool ModifyCollisionData(Rectangle victimHitbox, ref int immunityCooldownSlot, ref MultipliableFloat damageMultiplier, ref Rectangle npcHitbox)
Allows you to modify the NPC's T:Terraria.ID.ImmunityCooldownID, damage multiplier,...
virtual void SendExtraAI(BinaryWriter writer)
If you are storing AI information outside of the NPC.ai array, use this to send that AI information b...
virtual List< string > SetNPCNameList()
Allows you to give a list of names this NPC can be given on spawn. By default, returns a blank list,...
virtual void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment)
Allows you to customize this NPC's stats when the difficulty is expert or higher. This runs after F:...
virtual bool CheckDead()
Whether or not this NPC should be killed when it reaches 0 health. You may program extra effects in t...
virtual ? bool CanBeCaughtBy(Item item, Player player)
Allows you to determine whether the given item can catch this NPC. Return true or false to say this ...
int AnimationType
Determines which type of vanilla NPC this ModNPC will copy the animation/framing logic of,...
virtual string LocalizationCategory
The category used by this modded content for use in localization keys. Localization keys follow the p...
virtual float SpawnChance(NPCSpawnInfo spawnInfo)
Whether or not this NPC can spawn with the given spawning conditions. Return the weight for the chanc...
virtual void BossLoot(ref string name, ref int potionType)
Allows you to customize what happens when this boss dies, such as which name is displayed in the defe...
int[] SpawnModBiomes
The ModBiome Types associated with this NPC spawning, if applicable. Used in Bestiary.
virtual bool CanGoToStatue(bool toKingStatue)
Whether this NPC can be teleported to a King or Queen statue. Returns false by default.
virtual void HitEffect(NPC.HitInfo hit)
Allows you to make things happen whenever this NPC is hit, such as creating dust or gores....
virtual void LoadData(TagCompound tag)
Allows you to load custom data that you have saved for this npc.
virtual void OnGoToStatue(bool toKingStatue)
Allows you to make things happen when this NPC teleports to a King or Queen statue....
virtual bool CheckActive()
Whether or not to run the code for checking whether this NPC will remain active. Return false to stop...
This class serves as a place for you to place all your properties and hooks for each NPC....
virtual void SetStaticDefaults()
Allows you to modify the properties after initial loading has completed.
The base type for most modded things.
static void SetDefaults(NPC npc, bool createModNPC=true)
static readonly IDictionary< int, int > bannerToItem
static int Register(ModNPC npc)
This serves as the central class from which NPC-related functions are carried out....
bool boss
Set to true if the NPC is a boss. Prevents off-screen despawn. Bosses also need [AutoloadBossHead] an...
int lifeMax
The maximum life of this NPC.
int type
The NPC ID of this NPC. The NPC ID is a unique number assigned to each NPC loaded into the game....
static int NewNPC(IEntitySource source, int X, int Y, int Type, int Start=0, float ai0=0f, float ai1=0f, float ai2=0f, float ai3=0f, int Target=255)
Spawns an NPC into the game world with the given type. This method should not be called on multipla...
This object encapsulates context information about the source of a particular spawning event of an It...
string Name
The internal name of this instance.
SceneEffectPriority
This enum dictates from low to high which SceneEffect selections take priority. Setting appropriate p...
This readonly struct is a simple shortcut to T:Terraria.GameContent.ItemDropRules....
A struct that stores information regarding where an NPC is naturally spawning and the player it is sp...
Represents a finalized damage calculation for damage about to be applied to an NPC....
Represents a damage calculation in the process of being calculated for damage to be applied to an NPC...