1using Microsoft.Xna.Framework;
2using Microsoft.Xna.Framework.Graphics;
4using System.Collections.Generic;
6using Terraria.DataStructures;
7using Terraria.GameInput;
43 internal ModPlayer CreateFor(Player newPlayer) {
45 modPlayer.Name =
Name;
47 modPlayer.player = newPlayer;
48 modPlayer.index = index;
67 public virtual bool Autoload(ref
string name) {
126 [method: Obsolete(
"SetupStartInventory now has an overload with a mediumcoreDeath bool argument, please use that.")]
197 public virtual void SyncPlayer(
int toWho,
int fromWho,
bool newPlayer) {
278 public virtual void UpdateEquips(ref
bool wallSpeedBuff, ref
bool tileSpeedBuff, ref
bool tileRangeBuff) {
336 public virtual bool PreHurt(
bool pvp,
bool quiet, ref
int damage, ref
int hitDirection, ref
bool crit,
337 ref
bool customDamage, ref
bool playSound, ref
bool genGore, ref PlayerDeathReason damageSource) {
349 public virtual void Hurt(
bool pvp,
bool quiet,
double damage,
int hitDirection,
bool crit) {
360 public virtual void PostHurt(
bool pvp,
bool quiet,
double damage,
int hitDirection,
bool crit) {
373 public virtual bool PreKill(
double damage,
int hitDirection,
bool pvp, ref
bool playSound, ref
bool genGore,
374 ref PlayerDeathReason damageSource) {
385 public virtual void Kill(
double damage,
int hitDirection,
bool pvp, PlayerDeathReason damageSource) {
426 public virtual void GetHealLife(Item item,
bool quickHeal, ref
int healValue) {
435 public virtual void GetHealMana(Item item,
bool quickHeal, ref
int healValue) {
444 public virtual void ModifyManaCost(Item item, ref
float reduce, ref
float mult) {
470 [Obsolete(
"Use ModifyWeaponDamage",
true)]
480 [Obsolete(
"Use ModifyWeaponDamage overload with the additional flat parameter")]
542 public virtual bool Shoot(Item item, ref Vector2 position, ref
float speedX, ref
float speedY, ref
int type, ref
int damage, ref
float knockBack) {
581 public virtual void ModifyHitNPC(Item item, NPC target, ref
int damage, ref
float knockback, ref
bool crit) {
592 public virtual void OnHitNPC(Item item, NPC target,
int damage,
float knockback,
bool crit) {
614 public virtual void ModifyHitNPCWithProj(Projectile proj, NPC target, ref
int damage, ref
float knockback, ref
bool crit, ref
int hitDirection) {
625 public virtual void OnHitNPCWithProj(Projectile proj, NPC target,
int damage,
float knockback,
bool crit) {
634 public virtual bool CanHitPvp(Item item, Player target) {
645 public virtual void ModifyHitPvp(Item item, Player target, ref
int damage, ref
bool crit) {
655 public virtual void OnHitPvp(Item item, Player target,
int damage,
bool crit) {
685 public virtual void OnHitPvpWithProj(Projectile proj, Player target,
int damage,
bool crit) {
713 public virtual void OnHitByNPC(NPC npc,
int damage,
bool crit) {
755 public virtual void CatchFish(Item fishingRod, Item bait,
int power,
int liquidType,
int poolSize,
int worldLayer,
int questFish, ref
int caughtType, ref
bool junk) {
764 public virtual void GetFishingLevel(Item fishingRod, Item bait, ref
int fishingLevel) {
873 public virtual void PostSellItem(NPC vendor, Item[] shopInventory, Item item) {
883 public virtual bool CanSellItem(NPC vendor, Item[] shopInventory, Item item) {
893 public virtual void PostBuyItem(NPC vendor, Item[] shopInventory, Item item) {
903 public virtual bool CanBuyItem(NPC vendor, Item[] shopInventory, Item item) {
915 public virtual bool ModifyNurseHeal(NPC nurse, ref
int health, ref
bool removeDebuffs, ref
string chatText) {
926 public virtual void ModifyNursePrice(NPC nurse,
int health,
bool removeDebuffs, ref
int price) {
936 public virtual void PostNurseHeal(NPC nurse,
int health,
bool removeDebuffs,
int price) {
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
A ModPlayer instance represents an extension of a Player instance. You can store fields in the ModPla...
virtual void GetWeaponDamage(Item item, ref int damage)
Allows you to temporarily modify a weapon's damage based on player buffs, etc. This is useful for cre...
virtual void PreSavePlayer()
PreSavePlayer and PostSavePlayer wrap the vanilla player saving code (both are before the ModPlayer....
virtual void UpdateBiomeVisuals()
Allows you to create special visual effects in the area around the player. For example,...
virtual void UpdateDead()
Similar to UpdateDead, except this is only called when the player is dead. If this is called,...
virtual void CatchFish(Item fishingRod, Item bait, int power, int liquidType, int poolSize, int worldLayer, int questFish, ref int caughtType, ref bool junk)
Allows you to change the item the player gains from catching a fish. The fishingRod and bait paramete...
virtual void SendClientChanges(ModPlayer clientPlayer)
Allows you to sync any information that has changed between the server and client....
virtual void ModifyDrawHeadLayers(List< PlayerHeadLayer > layers)
Allows you to modify the drawing of the player head on the minimap. This is done by removing from,...
virtual void ResetEffects()
This is where you reset any fields you add to your ModPlayer subclass to their default states....
virtual void FrameEffects()
Allows you to modify the armor and accessories that visually appear on the player....
virtual void ModifyHitNPCWithProj(Projectile proj, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
Allows you to modify the damage, knockback, etc., that a projectile created by this player does to an...
virtual bool CanBeHitByNPC(NPC npc, ref int cooldownSlot)
Allows you to determine whether the given NPC can hit this player. Return false to block this player ...
virtual void PostUpdate()
This is called at the very end of the Player.Update method. Final general update tasks can be placed ...
virtual void PostHurt(bool pvp, bool quiet, double damage, int hitDirection, bool crit)
Allows you to make anything happen when the player takes damage.
virtual void UpdateLifeRegen()
Allows you to increase the player's life regeneration based on its state. This can be done by increme...
virtual bool ShiftClickSlot(Item[] inventory, int context, int slot)
Called whenever the player shift-clicks an item slot. This can be used to override default clicking b...
virtual void GetFishingLevel(Item fishingRod, Item bait, ref int fishingLevel)
Allows you to modify the player's fishing power. As an example of the type of stuff that should go he...
virtual Texture2D GetMapBackgroundImage()
Allows you to change the background that displays when viewing the map. Return null if you do not wan...
virtual void ModifyHitByProjectile(Projectile proj, ref int damage, ref bool crit)
Allows you to modify the damage, etc., that a hostile projectile does to this player.
virtual void OnHitNPC(Item item, NPC target, int damage, float knockback, bool crit)
Allows you to create special effects when this player hits an NPC by swinging a melee weapon (for exa...
virtual void LoadLegacy(BinaryReader reader)
Allows you to load pre-v0.9 custom data you have saved for this player.
virtual bool CanHitPvp(Item item, Player target)
Allows you to determine whether a melee weapon swung by this player can hit the given opponent player...
string Name
The name of this ModPlayer. Used for distinguishing between multiple ModPlayers added by a single Mod...
virtual void PostSellItem(NPC vendor, Item[] shopInventory, Item item)
Called whenever the player sells an item to an NPC.
virtual void Load(TagCompound tag)
Allows you to load custom data you have saved for this player.
virtual void PostItemCheck()
Allows you to do anything after the update code for the player's held item is run....
virtual void SyncPlayer(int toWho, int fromWho, bool newPlayer)
Allows you to sync information about this player between server and client. The toWho and fromWho par...
virtual void ModifyDrawInfo(ref PlayerDrawInfo drawInfo)
Allows you to modify the drawing parameters of the player before drawing begins.
virtual bool Shoot(Item item, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
This is called before this player's weapon creates a projectile. You can use it to create special eff...
virtual void ModifyHitByNPC(NPC npc, ref int damage, ref bool crit)
Allows you to modify the damage, etc., that an NPC does to this player.
virtual void PostNurseHeal(NPC nurse, int health, bool removeDebuffs, int price)
Called on the Client after the player heals themselves with the Nurse NPC.
virtual void Kill(double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource)
Allows you to make anything happen when the player dies.
virtual ? bool CanHitNPC(Item item, NPC target)
Allows you to determine whether a player can hit the given NPC by swinging a melee weapon....
virtual void MeleeEffects(Item item, Rectangle hitbox)
Allows you to give this player's melee weapon special effects, such as creating light or dust.
virtual void SetControls()
Use this to modify the control inputs that the player receives. For example, the Confused debuff swap...
virtual void OnHitPvp(Item item, Player target, int damage, bool crit)
Allows you to create special effects when this player's melee weapon hits an opponent player.
virtual void GetWeaponKnockback(Item item, ref float knockback)
Allows you to temporarily modify a weapon's knockback based on player buffs, etc. This allows you to ...
virtual void PostSavePlayer()
PreSavePlayer and PostSavePlayer wrap the vanilla player saving code (both are before the ModPlayer....
virtual void UpdateBiomes()
Allows you to set biome variables in your ModPlayer class based on tile counts.
virtual void GetHealLife(Item item, bool quickHeal, ref int healValue)
Allows you to temporarily modify the amount of life a life healing item will heal for,...
virtual void ModifyWeaponDamage(Item item, ref float add, ref float mult)
Allows you to temporarily modify this weapon's damage based on player buffs, etc. This is useful for ...
virtual void CopyCustomBiomesTo(Player other)
In this hook, you should copy the custom biome variables from this player to the other player paramet...
virtual bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
This hook is called whenever the player is about to be killed after reaching 0 health....
virtual void PlayerDisconnect(Player player)
Called when a player disconnects.
virtual void PlayerConnect(Player player)
Called on clients when a player connects.
virtual void OnConsumeAmmo(Item weapon, Item ammo)
Allows you to make things happen when ammo is consumed. Called before the ammo stack is reduced.
virtual void OnEnterWorld(Player player)
Called on the LocalPlayer when that player enters the world. SP and Client. Only called on the player...
virtual bool ModifyNurseHeal(NPC nurse, ref int health, ref bool removeDebuffs, ref string chatText)
Called on the Client while the nurse chat is displayed. Return false to prevent the player from heali...
virtual void SetupStartInventory(IList< Item > items, bool mediumcoreDeath)
Allows you to modify the inventory newly created players or killed mediumcore players will start with...
virtual void Initialize()
Called whenever the player is loaded (on the player selection screen). This can be used to initialize...
virtual void OnHitAnything(float x, float y, Entity victim)
This hook is called when a player damages anything, whether it be an NPC or another player,...
virtual bool CloneNewInstances
Whether each player gets a ModPlayer by cloning the ModPlayer added to the Mod or by creating a new M...
virtual void ModifyHitPvpWithProj(Projectile proj, Player target, ref int damage, ref bool crit)
Allows you to modify the damage, etc., that a projectile created by this player does to an opponent p...
virtual void ModifyNursePrice(NPC nurse, int health, bool removeDebuffs, ref int price)
Called on the Client while the nurse chat is displayed and after ModifyNurseHeal. Allows custom prici...
virtual void clientClone(ModPlayer clientClone)
Allows you to copy information about this player to the clientClone parameter. You should copy inform...
virtual void ModifyHitPvp(Item item, Player target, ref int damage, ref bool crit)
Allows you to modify the damage, etc., that a melee weapon swung by this player does to an opponent p...
virtual void DrawEffects(PlayerDrawInfo drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright)
Allows you to create special effects when this player is drawn, such as creating dust,...
virtual void OnHitPvpWithProj(Projectile proj, Player target, int damage, bool crit)
Allows you to create special effects when a projectile created by this player hits an opponent player...
virtual bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
This hook is called before every time the player takes damage. The pvp parameter is whether the damag...
virtual void OnHitNPCWithProj(Projectile proj, NPC target, int damage, float knockback, bool crit)
Allows you to create special effects when a projectile created by this player hits an NPC (for exampl...
virtual void ProcessTriggers(TriggersSet triggersSet)
Use this to check on hotkeys you have registered. While SetControls is set even while in text entry m...
virtual void OnHitByNPC(NPC npc, int damage, bool crit)
Allows you to create special effects when an NPC hits this player (for example, inflicting debuffs).
virtual void GetHealMana(Item item, bool quickHeal, ref int healValue)
Allows you to temporarily modify the amount of mana a mana healing item will heal for,...
virtual void PreUpdateBuffs()
This is called sometime after SetControls is called, and right before all the buffs update on this pl...
virtual void PreUpdateMovement()
This is called right before modifying the player's position based on velocity. Use this to make direc...
bool TypeEquals(ModPlayer other)
virtual void OnMissingMana(Item item, int neededMana)
Allows you to make stuff happen when a player doesn't have enough mana for the item they are trying t...
virtual TagCompound Save()
Allows you to save custom data for this player. Returns null by default.
virtual void ModifyDrawLayers(List< PlayerLayer > layers)
Allows you to modify the drawing of the player. This is done by removing from, adding to,...
virtual void PreSaveCustomData()
Currently never gets called, so this is useless.
virtual void ModifyScreenPosition()
Use this hook to modify Main.screenPosition after weapon zoom and camera lerp have taken place.
virtual void ModifyManaCost(Item item, ref float reduce, ref float mult)
Allows you to temporarily modify the amount of mana an item will consume on use, based on player buff...
virtual float UseTimeMultiplier(Item item)
Allows you to multiply an item's regular use time. Returns 1f by default. Values greater than 1 incre...
virtual void PostUpdateRunSpeeds()
This is called after the player's horizontal speeds are modified, which is sometime after PostUpdateM...
virtual void GetDyeTraderReward(List< int > rewardPool)
Allows you to modify what items are possible for the player to earn when giving a Strange Plant to th...
virtual void ModifyZoom(ref float zoom)
Use this to modify the zoom factor for the player. The zoom correlates to the percentage of half the ...
virtual void OnRespawn(Player player)
Called when a player respawns in the world.
virtual ? bool CanHitNPCWithProj(Projectile proj, NPC target)
Allows you to determine whether a projectile created by this player can hit the given NPC....
virtual void ReceiveCustomBiomes(BinaryReader reader)
Allows you to do things with the custom biome information you send between client and server.
virtual float MeleeSpeedMultiplier(Item item)
Allows you to multiply an item's regular melee speed. Returns 1f by default. Values greater than 1 in...
virtual void UpdateVanityAccessories()
This is called after VanillaUpdateVanityAccessory() in player.UpdateEquips()
virtual void PostUpdateBuffs()
This is called right after all of this player's buffs update on the player. This can be used to modif...
virtual void OnHitByProjectile(Projectile proj, int damage, bool crit)
Allows you to create special effects when a hostile projectile hits this player.
virtual void PostBuyItem(NPC vendor, Item[] shopInventory, Item item)
Called whenever the player buys an item from an NPC.
virtual void UpdateBadLifeRegen()
Allows you to give the player a negative life regeneration based on its state (for example,...
virtual void SendCustomBiomes(BinaryWriter writer)
Allows you to send custom biome information between client and server.
virtual void Hurt(bool pvp, bool quiet, double damage, int hitDirection, bool crit)
Allows you to make anything happen right before damage is subtracted from the player's health.
virtual void ModifyHitNPC(Item item, NPC target, ref int damage, ref float knockback, ref bool crit)
Allows you to modify the damage, knockback, etc., that this player does to an NPC by swinging a melee...
virtual void SetupStartInventory(IList< Item > items)
virtual bool CanHitPvpWithProj(Projectile proj, Player target)
Allows you to determine whether a projectile created by this player can hit the given opponent player...
virtual void PostUpdateEquips()
This is called right after all of this player's equipment and armor sets update on the player,...
virtual void UpdateAutopause()
Allows you to modify the player's stats while the game is paused due to the autopause setting being o...
virtual void NaturalLifeRegen(ref float regen)
Allows you to modify the power of the player's natural life regeneration. This can be done by multipl...
virtual bool CustomBiomesMatch(Player other)
Whether or not this player and the other player parameter have the same custom biome variables....
virtual bool CanBeHitByProjectile(Projectile proj)
Allows you to determine whether the given hostile projectile can hit this player. Return false to blo...
virtual bool ConsumeAmmo(Item weapon, Item ammo)
Whether or not ammo will be consumed upon usage. Return false to stop the ammo from being depleted....
virtual bool Autoload(ref string name)
Allows you to automatically add a ModPlayer instead of using Mod.AddPlayer. Return true to allow auto...
virtual void PostUpdateMiscEffects()
This is called after miscellaneous update code is called in Player.Update, which is sometime after Po...
Mod mod
The mod that added this type of ModPlayer.
Player player
The Player instance that this ModPlayer instance is attached to.
virtual void OnConsumeMana(Item item, int manaConsumed)
Allows you to make stuff happen when a player consumes mana on use of an item.
virtual void AnglerQuestReward(float rareMultiplier, List< Item > rewardItems)
Allows you to add to, change, or remove from the items the player earns when finishing an Angler ques...
virtual bool CanSellItem(NPC vendor, Item[] shopInventory, Item item)
Return false to prevent a transaction. Called before the transaction.
virtual void UpdateEquips(ref bool wallSpeedBuff, ref bool tileSpeedBuff, ref bool tileRangeBuff)
Called after Update Accessories.
virtual bool PreItemCheck()
Allows you to do anything before the update code for the player's held item is run....
virtual void ModifyWeaponDamage(Item item, ref float add, ref float mult, ref float flat)
Allows you to temporarily modify this weapon's damage based on player buffs, etc. This is useful for ...
virtual bool CanBuyItem(NPC vendor, Item[] shopInventory, Item item)
Return false to prevent a transaction. Called before the transaction.
virtual void PreUpdate()
This is called at the beginning of every tick update for this player, after checking whether the play...
virtual void GetWeaponCrit(Item item, ref int crit)
Allows you to temporarily modify a weapon's crit chance based on player buffs, etc.
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...
A struct that contains information that may help with PlayerLayer drawing.