1using Microsoft.Xna.Framework;
2using Microsoft.Xna.Framework.Graphics;
4using System.Collections.Generic;
6using System.Text.RegularExpressions;
61 public virtual string Texture => (GetType().Namespace +
"." +
Name).Replace(
'.',
'/');
93 projectile.modProjectile =
this;
126 clone.projectile = projectileClone;
131 copy.projectile = projectileClone;
182 public virtual void AI() {
216 public virtual bool TileCollideStyle(ref
int width, ref
int height, ref
bool fallThrough) {
251 public virtual void Kill(
int timeLeft) {
291 public virtual void ModifyHitNPC(NPC target, ref
int damage, ref
float knockback, ref
bool crit, ref
int hitDirection) {
301 public virtual void OnHitNPC(NPC target,
int damage,
float knockback,
bool crit) {
318 public virtual void ModifyHitPvp(Player target, ref
int damage, ref
bool crit) {
327 public virtual void OnHitPvp(Player target,
int damage,
bool crit) {
353 public virtual void OnHitPlayer(Player target,
int damage,
bool crit) {
362 public virtual bool?
Colliding(Rectangle projHitbox, Rectangle targetHitbox) {
383 public virtual bool PreDraw(SpriteBatch spriteBatch, Color lightColor) {
390 public virtual void PostDraw(SpriteBatch spriteBatch, Color lightColor) {
410 public virtual void UseGrapple(Player player, ref
int type) {
447 public virtual void DrawBehind(
int index, List<int> drawCacheProjsBehindNPCsAndTiles, List<int> drawCacheProjsBehindNPCs, List<int> drawCacheProjsBehindProjectiles, List<int> drawCacheProjsOverWiresUI) {
Manages content added by mods. Liasons between mod content and Terraria's arrays and oversees the Loa...
static Texture2D GetTexture(string name)
Gets the texture with the specified name. The name is in the format of "ModFolder/OtherFolders/FileNa...
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
This class serves as a place for you to place all your properties and hooks for each projectile....
virtual void ModifyDamageHitbox(ref Rectangle hitbox)
Allows you to change the hitbox used by this projectile for damaging players and NPCs.
virtual bool Autoload(ref string name)
Allows you to automatically load a projectile instead of using Mod.AddProjectile. Return true to allo...
virtual void AI()
Allows you to determine how this projectile behaves. This will only be called if PreAI returns true.
virtual void OnHitPvp(Player target, int damage, bool crit)
Allows you to create special effects when this projectile hits an opponent player.
virtual bool OnTileCollide(Vector2 oldVelocity)
Allows you to determine what happens when this projectile collides with a tile. OldVelocity is the ve...
bool drawHeldProjInFrontOfHeldItemAndArms
If this projectile is held by the player, determines whether it is drawn in front of or behind the pl...
virtual void PostAI()
Allows you to determine how this projectile behaves. This will be called regardless of what PreAI ret...
virtual ? bool CanUseGrapple(Player player)
This code is called whenever the player uses a grappling hook that shoots this type of projectile....
virtual void ModifyHitPvp(Player target, ref int damage, ref bool crit)
Allows you to modify the damage, etc., that this projectile does to an opponent player.
virtual void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
Allows you to modify the damage, knockback, etc., that this projectile does to an NPC....
virtual void SetDefaults()
Allows you to set all your projectile's properties, such as width, damage, aiStyle,...
virtual bool MinionContactDamage()
Whether or not this minion can damage NPCs by touching them. Returns false by default....
virtual ? bool CanHitNPC(NPC target)
Allows you to determine whether this projectile can hit the given NPC. Return true to allow hitting t...
virtual void UseGrapple(Player player, ref int type)
This code is called whenever the player uses a grappling hook that shoots this type of projectile....
virtual bool PreAI()
Allows you to determine how this projectile behaves. Return false to stop the vanilla AI and the AI h...
virtual void CutTiles()
Code ran when the projectile cuts tiles. Only runs if CanCutTiles() returns true. Useful when program...
virtual bool CanHitPvp(Player target)
Allows you to determine whether this projectile can hit the given opponent player....
virtual void OnHitNPC(NPC target, int damage, float knockback, bool crit)
Allows you to create special effects when this projectile hits an NPC (for example,...
virtual ModProjectile Clone()
Returns a clone of this ModProjectile. Allows you to decide which fields of your ModProjectile class ...
Projectile projectile
The projectile object that this ModProjectile controls.
virtual bool CanDamage()
Whether or not this projectile is capable of killing tiles (such as grass) and damaging NPCs/players....
virtual ? Color GetAlpha(Color lightColor)
Allows you to determine the color and transparency in which this projectile is drawn....
virtual bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough)
Allows you to determine how this projectile interacts with tiles. Width and height determine the proj...
virtual string GlowTexture
The file name of this projectile's glow texture file in the mod loader's file space....
virtual ModProjectile NewInstance(Projectile projectileClone)
Create a new instance of this ModProjectile for a Projectile instance. Called at the end of Projectil...
virtual string Texture
The file name of this projectile's texture file in the mod loader's file space.
int drawOffsetX
How far to the right of its position this projectile should be drawn. Defaults to 0.
virtual void NumGrappleHooks(Player player, ref int numHooks)
How many of this type of grappling hook the given player can latch onto blocks before the hooks start...
int drawOriginOffsetY
The vertical origin offset from the projectile's center when it is drawn. The origin is essentially t...
virtual float GrappleRange()
How far away this grappling hook can travel away from its player before it retracts.
virtual void PostDraw(SpriteBatch spriteBatch, Color lightColor)
Allows you to draw things in front of a projectile. This method is called even if PreDraw returns fal...
virtual void DrawBehind(int index, List< int > drawCacheProjsBehindNPCsAndTiles, List< int > drawCacheProjsBehindNPCs, List< int > drawCacheProjsBehindProjectiles, List< int > drawCacheProjsOverWiresUI)
When used in conjunction with "projectile.hide = true", allows you to specify that this projectile sh...
virtual void OnHitPlayer(Player target, int damage, bool crit)
Allows you to create special effects when this hostile projectile hits a player.
int aiType
Determines which type of vanilla projectile this ModProjectile will copy the behavior (AI) of....
Mod mod
The mod object that this ModProjectile originates from.
float drawOriginOffsetX
The horizontal origin offset from the projectile's center when it is drawn.
int cooldownSlot
Determines which of the player's cooldown counters to use (-1, 0, or 1) when this projectile damages ...
ModTranslation DisplayName
The translations for the display name of this projectile.
virtual void Kill(int timeLeft)
Allows you to control what happens when this projectile is killed (for example, creating dust or maki...
virtual ? bool SingleGrappleHook(Player player)
Whether or not a grappling hook can only have one hook per player in the world at a time....
virtual bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
Allows you to draw things behind this projectile, or to modify the way this projectile is drawn....
virtual void ModifyHitPlayer(Player target, ref int damage, ref bool crit)
Allows you to modify the damage, etc., that this hostile projectile does to a player.
virtual void SetStaticDefaults()
Allows you to set all your projectile's static properties, such as names/translations and the arrays ...
virtual void GrapplePullSpeed(Player player, ref float speed)
The speed at which the grapple pulls the player after hitting something. Defaults to 11,...
virtual bool PreDrawExtras(SpriteBatch spriteBatch)
Allows you to draw things behind this projectile. Returns false to stop the game from drawing extras ...
virtual bool ShouldUpdatePosition()
Whether or not this projectile should update its position based on factors such as its velocity,...
virtual void GrappleRetreatSpeed(Player player, ref float speed)
The speed at which the grapple retreats back to the player after not hitting anything....
virtual void AutoStaticDefaults()
Automatically sets certain static defaults. Override this if you do not want the properties to be set...
virtual void ReceiveExtraAI(BinaryReader reader)
Use this to receive information that was sent in SendExtraAI.
virtual ? bool CanCutTiles()
Return true or false to specify if the projectile can cut tiles, like vines. Return null for vanilla ...
virtual bool CanHitPlayer(Player target)
Allows you to determine whether this hostile projectile can hit the given player. Return false to blo...
virtual bool PreKill(int timeLeft)
Allows you to determine whether the vanilla code for Kill and the Kill hook will be called....
virtual void SendExtraAI(BinaryWriter writer)
If you are storing AI information outside of the projectile.ai array, use this to send that AI inform...
virtual void GrappleTargetPoint(Player player, ref float grappleX, ref float grappleY)
The location that the grappling hook pulls the player to. Defaults to the center of the hook projecti...
string Name
The internal name of this ModProjectile.
virtual ? bool Colliding(Rectangle projHitbox, Rectangle targetHitbox)
Allows you to use custom collision detection between this projectile and a player or NPC that this pr...
virtual bool CloneNewInstances
Whether instances of this ModProjectile are created through a memberwise clone or its constructor....
void SetDefault(string value)
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...