This class serves as a place for you to place all your properties and hooks for each NPC. Create instances of ModNPC (preferably overriding this class) to pass as parameters to Mod.AddNPC.
More...
|
virtual void | AI () |
| Allows you to determine how this NPC behaves. This will only be called if PreAI returns true.
|
|
virtual void | AutoStaticDefaults () |
| Automatically sets certain static defaults. Override this if you do not want the properties to be set for you.
|
|
virtual void | BossHeadRotation (ref float rotation) |
| Allows you to customize the rotation of this NPC's boss head icon on the map. More...
|
|
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 stop the texture from being displayed. More...
|
|
virtual void | BossHeadSpriteEffects (ref SpriteEffects spriteEffects) |
| Allows you to flip this NPC's boss head icon on the map. More...
|
|
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 defeat message and what type of potion it drops. More...
|
|
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 NPC can or cannot be caught, respectively, regardless of vanilla rules.
Returns null by default, which allows vanilla's NPC catching rules to decide the target's fate.
If this returns false, CombinedHooks.OnCatchNPC is never called.
NOTE: this does not classify the given item as an NPC-catching tool, which is necessary for catching NPCs in the first place.
To do that, you will need to use the "CatchingTool" set in ItemID.Sets. More...
|
|
virtual ? bool | CanBeHitByItem (Player player, Item item) |
| Allows you to determine whether this NPC can be hit by the given melee weapon when swung. Return true to allow hitting the NPC, return false to block hitting the NPC, and return null to use the vanilla code for whether the NPC can be hit. Returns null by default. More...
|
|
virtual ? bool | CanBeHitByProjectile (Projectile projectile) |
| Allows you to determine whether this NPC can be hit by the given projectile. Return true to allow hitting the NPC, return false to block hitting the NPC, and return null to use the vanilla code for whether the NPC can be hit. Returns null by default. More...
|
|
virtual bool | CanChat () |
| Allows you to determine whether this NPC can talk with the player. By default, returns if the NPC is a town NPC. More...
|
|
virtual ? bool | CanFallThroughPlatforms () |
| Allows you to determine how and when this NPC can fall through platforms and similar tiles.
Return true to allow this NPC to fall through platforms, false to prevent it. Returns null by default, applying vanilla behaviors (based on aiStyle and type).
|
|
virtual bool | CanGoToStatue (bool toKingStatue) |
| Whether this NPC can be telported to a King or Queen statue. Returns false by default. More...
|
|
virtual ? bool | CanHitNPC (NPC target) |
| Allows you to determine whether this NPC can hit the given friendly NPC. Return true to allow hitting the target, return false to block this NPC from hitting the target, and return null to use the vanilla code for whether the target can be hit. Returns null by default. More...
|
|
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 from hitting the target. Returns true by default. CooldownSlot determines which of the player's cooldown counters to use (-1, 0, or 1), and defaults to -1. More...
|
|
virtual bool | CanTownNPCSpawn (int numTownNPCs, int money) |
| Whether or not the conditions have been met for this town NPC to be able to move into town. For example, the Demolitionist requires that any player has an explosive. More...
|
|
virtual bool | CheckActive () |
| Whether or not to run the code for checking whether this NPC will remain active. Return false to stop this NPC from being despawned and to stop this NPC from counting towards the limit for how many NPCs can exist near a player. Returns true by default. More...
|
|
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, Truffle requires the house to be in an aboveground mushroom biome. More...
|
|
virtual bool | CheckDead () |
| Whether or not this NPC should be killed when it reaches 0 health. You may program extra effects in this hook (for example, how Golem's head lifts up for the second phase of its fight). Return false to stop this NPC from being killed. Returns true by default. More...
|
|
virtual void | DrawBehind (int index) |
| When used in conjunction with "NPC.hide = true", allows you to specify that this NPC should be drawn behind certain elements. Add the index to one of Main.DrawCacheNPCsMoonMoon, DrawCacheNPCsOverPlayers, DrawCacheNPCProjectiles, or DrawCacheNPCsBehindNonSolidTiles. More...
|
|
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 which the NPC is drawn. More...
|
|
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 as Main.hbPosition; it determines whether the health bar gets drawn above or below the NPC by default. The scale parameter is the health bar's size. By default, it will be the normal 1f; most bosses set this to 1.5f. Return null to let the normal vanilla health-bar-drawing code to run. Return false to stop the health bar from being drawn. Return true to draw the health bar in the position specified by the position parameter (note that this is the world position, not screen position). More...
|
|
virtual void | DrawTownAttackGun (ref float scale, ref int item, ref int closeness) |
| Allows you to customize how this town NPC's weapon is drawn when this NPC is shooting (this NPC must have an attack type of 1). Scale is a multiplier for the item's drawing size, item is the ID of the item to be drawn, and closeness is how close the item should be drawn to the NPC. More...
|
|
virtual void | DrawTownAttackSwing (ref Texture2D item, 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 must have an attack type of 3). Item is the Texture2D instance of the item to be drawn (use Main.itemTexture[id of item]), itemSize is the width and height of the item's hitbox (the same values for TownNPCAttackSwing), scale is the multiplier for the item's drawing size, and offset is the offset from which to draw the item from its normal position. More...
|
|
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 animate NPCs. More...
|
|
virtual ? Color | GetAlpha (Color drawColor) |
| Allows you to determine the color and transparency in which this NPC is drawn. Return null to use the default color (normally light and buff color). Returns null by default. More...
|
|
virtual string | GetChat () |
| Allows you to give this NPC a chat message when a player talks to it. By default returns something embarrassing. More...
|
|
virtual void | HitEffect (int hitDirection, double damage) |
| Allows you to make things happen whenever this NPC is hit, such as creating dust or gores.
This hook is client side. Usually when something happens when an NPC dies such as item spawning, you use NPCLoot, but you can use HitEffect paired with a check for if (NPC.life <= 0) to do client-side death effects, such as spawning dust, gore, or death sounds.
|
|
virtual void | LoadData (TagCompound tag) |
| Allows you to load custom data that you have saved for this npc. More...
|
|
virtual void | ModifyHitByItem (Player player, Item item, ref int damage, ref float knockback, ref bool crit) |
| Allows you to modify the damage, knockback, etc., that this NPC takes from a melee weapon. More...
|
|
virtual void | ModifyHitByProjectile (Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) |
| Allows you to modify the damage, knockback, etc., that this NPC takes from a projectile. This method is only called for the owner of the projectile, meaning that in multi-player, projectiles owned by a player call this method on that client, and projectiles owned by the server such as enemy projectiles call this method on the server. More...
|
|
virtual void | ModifyHitNPC (NPC target, ref int damage, ref float knockback, ref bool crit) |
| Allows you to modify the damage, knockback, etc., that this NPC does to a friendly NPC. More...
|
|
virtual void | ModifyHitPlayer (Player target, ref int damage, ref bool crit) |
| Allows you to modify the damage, etc., that this NPC does to a player. More...
|
|
virtual void | ModifyHoverBoundingBox (ref Rectangle boundingBox) |
| Allows you to modify the bounding box for hovering over this NPC (affects things like whether or not its name is displayed). More...
|
|
virtual void | ModifyNPCLoot (NPCLoot npcLoot) |
| Allows you to add and modify NPC loot tables to drop on death and to appear in the Bestiary.
The Basic NPC Drops and Loot 1.4 Guideexplains how to use this hook to modify NPC loot.
This hook only runs once during mod loading, any dynamic behavior must be contained in the rules themselves. More...
|
|
virtual void | ModifyTypeName (ref string typeName) |
| Allows you to modify the type name of this NPC dynamically.
|
|
virtual bool | NeedSaving () |
| Makes this ModNPC save along the world even if it's not a townNPC. Defaults to false.
NOTE: A town NPC will always be saved.
NOTE: A NPC that needs saving will not despawn naturally.
|
|
virtual void | OnCaughtBy (Player player, Item item, bool failed) |
| Allows you to make things happen when the given item attempts to catch this NPC. More...
|
|
virtual void | OnChatButtonClicked (bool firstButton, ref bool shop) |
| Allows you to make something happen whenever a button is clicked on this NPC's chat window. The firstButton parameter tells whether the first button or second button (button and button2 from SetChatButtons) was clicked. Set the shop parameter to true to open this NPC's shop. More...
|
|
virtual void | OnGoToStatue (bool toKingStatue) |
| Allows you to make things happen when this NPC teleports to a King or Queen statue. This method is only called server side. More...
|
|
virtual void | OnHitByItem (Player player, Item item, int damage, float knockback, bool crit) |
| Allows you to create special effects when this NPC is hit by a melee weapon. More...
|
|
virtual void | OnHitByProjectile (Projectile projectile, int damage, float knockback, bool crit) |
| Allows you to create special effects when this NPC is hit by a projectile. More...
|
|
virtual void | OnHitNPC (NPC target, int damage, float knockback, bool crit) |
| Allows you to create special effects when this NPC hits a friendly NPC. More...
|
|
virtual void | OnHitPlayer (Player target, int damage, bool crit) |
| Allows you to create special effects when this NPC hits a player (for example, inflicting debuffs). More...
|
|
virtual void | OnKill () |
| Allows you to make things happen when this NPC dies (for example, dropping items and setting ModSystem fields). This hook runs on the server/single player. For client-side effects, such as dust, gore, and sounds, see HitEffect
|
|
virtual void | OnSpawn (IEntitySource source) |
| Gets called when your NPC spawns in world
|
|
virtual void | PostAI () |
|
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 drawing. This method is called even if PreDraw returns false. More...
|
|
virtual bool | PreAI () |
| Allows you to determine how this NPC behaves. Return false to stop the vanilla AI and the AI hook from being run. Returns true by default. More...
|
|
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. Substract screenPos from the draw position before drawing. Return false to stop the game from drawing the NPC (useful if you're manually drawing the NPC). Returns true by default. More...
|
|
virtual bool | PreKill () |
| Allows you to determine whether or not this NPC will do anything upon death (besides dying). Returns true by default. More...
|
|
virtual void | ReceiveExtraAI (BinaryReader reader) |
| Use this to receive information that was sent in SendExtraAI.
Called whenever MessageID.SyncNPC is successfully received.
Only called on the client. More...
|
|
virtual void | ResetEffects () |
| This is where you reset any fields you add to your subclass to their default states. This is necessary in order to reset your fields if they are conditionally set by a tick update but the condition is no longer satisfied. (Note: This hook is only really useful for GlobalNPC, but is included in ModNPC for completion.)
|
|
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.
NOTE: The provided tag is always empty by default, and is provided as an argument only for the sake of convenience and optimization.
NOTE: Try to only save data that isn't default values.
NOTE: The npc may be saved even if NeedSaving returns false and this is not a townNPC, if another mod returns true on NeedSaving. More...
|
|
virtual void | ScaleExpertStats (int numPlayers, float bossLifeScale) |
| Allows you to customize this NPC's stats in expert mode. This is useful because expert mode's doubling of damage and life might be too much sometimes (for example, with bosses). Also useful for scaling life with the number of players in the world. More...
|
|
virtual void | SendExtraAI (BinaryWriter writer) |
| If you are storing AI information outside of the NPC.ai array, use this to send that AI information between clients and servers, which will be handled in ReceiveExtraAI.
Called whenever MessageID.SyncNPC is successfully sent, for example on NPC creation, on player join, or whenever NPC.netUpdate is set to true in the update loop for that tick.
Only called on the server. More...
|
|
virtual void | SetBestiary (BestiaryDatabase database, BestiaryEntry bestiaryEntry) |
| Allows you to set an NPC's information in the Bestiary. More...
|
|
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 an empty string will not be included as a button on the chat window. More...
|
|
virtual void | SetDefaults () |
| Allows you to set all your NPC's properties, such as width, damage, aiStyle, lifeMax, etc.
|
|
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, which means the NPC will simply use its type name as its given name when prompted. More...
|
|
sealed override void | SetupContent () |
| If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
|
|
virtual void | SetupShop (Chest shop, ref int nextSlot) |
| Allows you to add items to this NPC's shop. Add an item by setting the defaults of shop.item[nextSlot] then incrementing nextSlot. In the end, nextSlot must have a value of 1 greater than the highest index in shop.item that contains an item. More...
|
|
virtual float | SpawnChance (NPCSpawnInfo spawnInfo) |
| Whether or not this NPC can spawn with the given spawning conditions. Return the weight for the chance of this NPC to spawn compared to vanilla mobs. All vanilla mobs combined have a total weight of 1. Returns 0 by default, which disables natural spawning. Remember to always use spawnInfo.player and not Main.LocalPlayer when checking Player or ModPlayer fields, otherwise your mod won't work in Multiplayer. More...
|
|
virtual int | SpawnNPC (int tileX, int tileY) |
| Allows you to customize how this NPC is created when it naturally spawns (for example, its position or ai array). Return the return value of NPC.NewNPC. By default this method spawns this NPC on top of the tile at the given coordinates. More...
|
|
virtual bool | SpecialOnKill () |
| Allows you to call OnKill on your own when the NPC dies, rather then letting vanilla call it on its own. Returns false by default. More...
|
|
virtual bool | StrikeNPC (ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) |
| Allows you to use a custom damage formula for when this NPC takes damage from any source. For example, you can change the way defense works or use a different crit multiplier. Return false to stop the game from running the vanilla damage formula; returns true by default. More...
|
|
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 number greater than or equal to the first parameter, and less then the sum of the two parameters. More...
|
|
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 magic attack. Only used when the town NPC has an attack type of 2 (magic) More...
|
|
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 projectile to actually appear. This hook is only used when the town NPC has an attack type of 0 (throwing), 1 (shooting), or 2 (magic). More...
|
|
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. Multiplier is the speed of the projectile, gravityCorrection is how much extra the projectile gets thrown upwards, and randomOffset allows you to randomize the projectile's velocity in a square centered around the original velocity. This hook is only used when the town NPC has an attack type of 0 (throwing), 1 (shooting), or 2 (magic). More...
|
|
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 more projectiles as part of a single attack so that the game can animate the NPC's attack properly. Only used when the town NPC has an attack type of 1 (shooting). More...
|
|
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 scaled. (More information on scaling in GlobalNPC.BuffTownNPCs.) More...
|
|
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, which controls the range of this NPC's swung weapon. Only used when the town NPC has an attack type of 3 (swinging). More...
|
|
virtual ITownNPCProfile | TownNPCProfile () |
| Allows you to set the town NPC profile that this NPC uses.
By default, returns null, meaning that the NPC doesn't use one.
|
|
virtual void | UpdateLifeRegen (ref int damage) |
| Allows you to make the NPC either regenerate health or take damage over time by setting NPC.lifeRegen. Regeneration or damage will occur at a rate of half of NPC.lifeRegen per second. The damage parameter is the number that appears above the NPC's head if it takes damage over time. More...
|
|
virtual bool | UsesPartyHat () |
| Allows you to determine whether this town NPC wears a party hat during a party. Returns true by default. More...
|
|
virtual TModType | Clone (TEntity newEntity) |
| Create a copy of this instanced global. Called when an entity is cloned. More...
|
|
virtual bool | IsLoadingEnabled (Mod mod) |
| Allows you to stop Mod.AddContent from actually adding this content. Useful for items that can be disabled by a config. More...
|
|
virtual void | Load () |
| Allows you to perform one-time loading tasks. Beware that mod content has not finished loading here, things like ModContent lookup tables or ID Sets are not fully populated. More...
|
|
virtual TModType | NewInstance (TEntity entity) |
| Create a new instance of this ModType for a specific entity More...
|
|
virtual void | SetStaticDefaults () |
| Allows you to modify the properties after initial loading has completed.
|
|
virtual void | SetupContent () |
| If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
|
|
virtual void | Unload () |
| Allows you to safely unload things you added in Load. More...
|
|
virtual bool | IsLoadingEnabled (Mod mod) |
| Whether or not this type should be loaded when it's told to. Returning false disables Mod.AddContent from actually loading this type. More...
|
|
abstract void | Load (Mod mod) |
| Called when loading the type. More...
|
|
abstract void | Unload () |
| Called during unloading when needed. More...
|
|