Terraria ModLoader  0.10.1.5
A framework for Terraria mods
Terraria.ModLoader.ModProjectile Class Reference

This class serves as a place for you to place all your properties and hooks for each projectile. Create instances of ModProjectile (preferably overriding this class) to pass as parameters to Mod.AddProjectile. More...

+ Collaboration diagram for Terraria.ModLoader.ModProjectile:

Public Member Functions

 ModProjectile ()
 
virtual void AI ()
 Allows you to determine how this projectile behaves. This will only be called if PreAI returns true. More...
 
virtual bool Autoload (ref string name)
 Allows you to automatically load a projectile instead of using Mod.AddProjectile. Return true to allow autoloading; by default returns the mod's autoload property. Name is initialized to the overriding class name. Use this method to either force or stop an autoload, or to change the default internal name. More...
 
virtual void AutoStaticDefaults ()
 Automatically sets certain static defaults. Override this if you do not want the properties to be set for you. More...
 
virtual bool CanCutTiles ()
 Return true or false to specify if the projectile can cut tiles, like vines. Return null for vanilla decision. More...
 
virtual bool CanDamage ()
 Whether or not this projectile is capable of killing tiles (such as grass) and damaging NPCs/players. Return false to prevent it from doing any sort of damage. Returns true by default. More...
 
virtual bool CanHitNPC (NPC target)
 Allows you to determine whether this projectile can hit the given NPC. Return true to allow hitting the target, return false to block this projectile 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)
 Allows you to determine whether this hostile projectile can hit the given player. Return false to block this projectile from hitting the target. Returns true by default. More...
 
virtual bool CanHitPvp (Player target)
 Allows you to determine whether this projectile can hit the given opponent player. Return false to block this projectile from hitting the target. Returns true by default. More...
 
virtual bool CanUseGrapple (Player player)
 This code is called whenever the player uses a grappling hook that shoots this type of projectile. Use it to change what kind of hook is fired (for example, the Dual Hook does this), to kill old hook projectiles, etc. More...
 
virtual ModProjectile Clone ()
 Returns a clone of this ModProjectile. Allows you to decide which fields of your ModProjectile class are copied over when a new Projectile is created. By default this will return a memberwise clone; you will want to override this if your GlobalProjectile contains object references. Only called if CloneNewInstances is set to true. More...
 
virtual bool Colliding (Rectangle projHitbox, Rectangle targetHitbox)
 Allows you to use custom collision detection between this projectile and a player or NPC that this projectile can damage. Useful for things like diagonal lasers, projectiles that leave a trail behind them, etc. More...
 
virtual void CutTiles ()
 Code ran when the projectile cuts tiles. Only runs if CanCutTiles() returns true. Useful when programming lasers and such. More...
 
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 should be drawn behind certain elements. Add the index to one and only one of the lists. For example, the Nebula Arcanum projectile draws behind NPCs and tiles. More...
 
virtual Color GetAlpha (Color lightColor)
 Allows you to determine the color and transparency in which this projectile is drawn. Return null to use the default color (normally light and buff color). Returns null by default. More...
 
virtual void GrapplePullSpeed (Player player, ref float speed)
 The speed at which the grapple pulls the player after hitting something. Defaults to 11, but the Bat Hook uses 16. More...
 
virtual float GrappleRange ()
 How far away this grappling hook can travel away from its player before it retracts. More...
 
virtual void GrappleRetreatSpeed (Player player, ref float speed)
 The speed at which the grapple retreats back to the player after not hitting anything. Defaults to 11, but vanilla hooks go up to 24. More...
 
virtual void Kill (int timeLeft)
 Allows you to control what happens when this projectile is killed (for example, creating dust or making sounds). Also useful for creating retrievable ammo. More...
 
virtual bool MinionContactDamage ()
 Whether or not this minion can damage NPCs by touching them. Returns false by default. Note that this will only be used if this projectile is considered a pet. More...
 
virtual void ModifyDamageHitbox (ref Rectangle hitbox)
 Allows you to change the hitbox used by this projectile for damaging players and NPCs. More...
 
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. More...
 
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. More...
 
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. More...
 
virtual ModProjectile NewInstance (Projectile projectileClone)
 Create a new instance of this GlobalProjectile for a Projectile instance. Called at the end of Projectile.SetDefaults. If CloneNewInstances is true, just calls Clone() Otherwise calls the default constructor and copies fields More...
 
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 disappearing. Change the numHooks parameter to determine this; by default it will be 3. More...
 
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, inflicting debuffs). More...
 
virtual void OnHitPlayer (Player target, int damage, bool crit)
 Allows you to create special effects when this hostile projectile hits a player. More...
 
virtual void OnHitPvp (Player target, int damage, bool crit)
 Allows you to create special effects when this projectile hits an opponent player. More...
 
virtual bool OnTileCollide (Vector2 oldVelocity)
 Allows you to determine what happens when this projectile collides with a tile. OldVelocity is the velocity before tile collision. The velocity that takes tile collision into account can be found with projectile.velocity. Return true to allow the vanilla tile collision code to take place (which normally kills the projectile). Returns true by default. More...
 
virtual void PostAI ()
 Allows you to determine how this projectile behaves. This will be called regardless of what PreAI returns. More...
 
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 false. More...
 
virtual bool PreAI ()
 Allows you to determine how this projectile 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, Color lightColor)
 Allows you to draw things behind this projectile, or to modify the way this projectile is drawn. Return false to stop the game from drawing the projectile (useful if you're manually drawing the projectile). Returns true by default. More...
 
virtual bool PreDrawExtras (SpriteBatch spriteBatch)
 Allows you to draw things behind this projectile. Returns false to stop the game from drawing extras textures related to the projectile (for example, the chains for grappling hooks), useful if you're manually drawing the extras. Returns true by default. More...
 
virtual bool PreKill (int timeLeft)
 Allows you to determine whether the vanilla code for Kill and the Kill hook will be called. Return false to stop them from being called. Returns true by default. Note that this does not stop the projectile from dying. More...
 
virtual void ReceiveExtraAI (BinaryReader reader)
 Use this to receive information that was sent in SendExtraAI. More...
 
virtual void SendExtraAI (BinaryWriter writer)
 If you are storing AI information outside of the projectile.ai array, use this to send that AI information between clients and servers. More...
 
virtual void SetDefaults ()
 Allows you to set all your projectile's properties, such as width, damage, aiStyle, penetrate, etc. More...
 
virtual void SetStaticDefaults ()
 Allows you to set all your projectile's static properties, such as names/translations and the arrays in ProjectileID.Sets. More...
 
virtual bool ShouldUpdatePosition ()
 Whether or not this projectile should update its position based on factors such as its velocity, whether it is in liquid, etc. Return false to make its velocity have no effect on its position. Returns true by default. More...
 
virtual bool SingleGrappleHook (Player player)
 Whether or not a grappling hook can only have one hook per player in the world at a time. Return null to use the vanilla code. Returns null by default. More...
 
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 projectile's hitbox for tile collision, and default to -1. Leave them as -1 to use the projectile's real size. Fallthrough determines whether the projectile can fall through platforms, etc., and defaults to true. More...
 
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. Use it to change what kind of hook is fired (for example, the Dual Hook does this), to kill old hook projectiles, etc. More...
 

Public Attributes

int aiType = 0
 Determines which type of vanilla projectile this ModProjectile will copy the behavior (AI) of. Leave as 0 to not copy any behavior. Defaults to 0. More...
 
virtual bool CloneNewInstances => false
 Whether instances of this ModProjectile are created through a memberwise clone or its constructor. Defaults to false. More...
 
int cooldownSlot = -1
 Determines which of the player's cooldown counters to use (-1, 0, or 1) when this projectile damages it. Defaults to -1. More...
 
bool drawHeldProjInFrontOfHeldItemAndArms = false
 If this projectile is held by the player, determines whether it is drawn in front of or behind the player's arms. Defaults to false. More...
 
int drawOffsetX = 0
 How far to the right of its position this projectile should be drawn. Defaults to 0. More...
 
float drawOriginOffsetX = 0f
 The horizontal origin offset from the projectile's center when it is drawn. More...
 
int drawOriginOffsetY = 0
 The vertical origin offset from the projectile's center when it is drawn. The origin is essentially the point of rotation. This field will also determine the vertical drawing offset of the projectile. More...
 
virtual string GlowTexture => Texture + "_Glow"
 The file name of this projectile's glow texture file in the mod loader's file space. If it does not exist it is ignored. More...
 
virtual string Texture => (GetType().Namespace + "." + Name).Replace('.', '/')
 The file name of this projectile's texture file in the mod loader's file space. More...
 

Properties

ModTranslation DisplayName [get, set]
 The translations for the display name of this projectile. More...
 
Mod mod [get, set]
 The mod object that this ModProjectile originates from. More...
 
string Name [get, set]
 The internal name of this ModProjectile. More...
 
Projectile projectile [get, set]
 The projectile object that this ModProjectile controls. More...
 

Detailed Description

This class serves as a place for you to place all your properties and hooks for each projectile. Create instances of ModProjectile (preferably overriding this class) to pass as parameters to Mod.AddProjectile.

Definition at line 13 of file ModProjectile.cs.

Constructor & Destructor Documentation

Terraria.ModLoader.ModProjectile.ModProjectile ( )

Definition at line 91 of file ModProjectile.cs.

91  {
92  projectile = new Projectile();
93  projectile.modProjectile = this;
94  }
Projectile projectile
The projectile object that this ModProjectile controls.

Member Function Documentation

virtual void Terraria.ModLoader.ModProjectile.AI ( )
virtual

Allows you to determine how this projectile behaves. This will only be called if PreAI returns true.

Definition at line 182 of file ModProjectile.cs.

182  {
183  }
virtual bool Terraria.ModLoader.ModProjectile.Autoload ( ref string  name)
virtual

Allows you to automatically load a projectile instead of using Mod.AddProjectile. Return true to allow autoloading; by default returns the mod's autoload property. Name is initialized to the overriding class name. Use this method to either force or stop an autoload, or to change the default internal name.

Parameters
nameThe internal name.
Returns
Whether or not to autoload.

Definition at line 100 of file ModProjectile.cs.

Referenced by Terraria.ModLoader.Mod.AutoloadProjectile().

100  {
101  return mod.Properties.Autoload;
102  }
Mod mod
The mod object that this ModProjectile originates from.
ModProperties Properties
Definition: Mod.cs:49
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...

+ Here is the caller graph for this function:

virtual void Terraria.ModLoader.ModProjectile.AutoStaticDefaults ( )
virtual

Automatically sets certain static defaults. Override this if you do not want the properties to be set for you.

Definition at line 158 of file ModProjectile.cs.

References Terraria.ModLoader.ModContent.GetTexture().

Referenced by Terraria.ModLoader.Mod.LoadEffect().

158  {
159  Main.projectileTexture[projectile.type] = ModContent.GetTexture(Texture);
160  Main.projFrames[projectile.type] = 1;
161  if (projectile.hostile) {
162  Main.projHostile[projectile.type] = true;
163  }
164  if (projectile.aiStyle == 7) {
165  Main.projHook[projectile.type] = true;
166  }
167  if (DisplayName.IsDefault())
168  DisplayName.SetDefault(Regex.Replace(Name, "([A-Z])", " $1").Trim());
169  }
Projectile projectile
The projectile object that this ModProjectile controls.
virtual string Texture
The file name of this projectile&#39;s texture file in the mod loader&#39;s file space.
ModTranslation DisplayName
The translations for the display name of this projectile.
string Name
The internal name of this ModProjectile.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual bool Terraria.ModLoader.ModProjectile.CanCutTiles ( )
virtual

Return true or false to specify if the projectile can cut tiles, like vines. Return null for vanilla decision.

Definition at line 231 of file ModProjectile.cs.

231  {
232  return null;
233  }
virtual bool Terraria.ModLoader.ModProjectile.CanDamage ( )
virtual

Whether or not this projectile is capable of killing tiles (such as grass) and damaging NPCs/players. Return false to prevent it from doing any sort of damage. Returns true by default.

Definition at line 257 of file ModProjectile.cs.

257  {
258  return true;
259  }
virtual bool Terraria.ModLoader.ModProjectile.CanHitNPC ( NPC  target)
virtual

Allows you to determine whether this projectile can hit the given NPC. Return true to allow hitting the target, return false to block this projectile from hitting the target, and return null to use the vanilla code for whether the target can be hit. Returns null by default.

Parameters
targetThe target.

Definition at line 279 of file ModProjectile.cs.

279  {
280  return null;
281  }
virtual bool Terraria.ModLoader.ModProjectile.CanHitPlayer ( Player  target)
virtual

Allows you to determine whether this hostile projectile can hit the given player. Return false to block this projectile from hitting the target. Returns true by default.

Parameters
targetThe target.

Definition at line 334 of file ModProjectile.cs.

334  {
335  return true;
336  }
virtual bool Terraria.ModLoader.ModProjectile.CanHitPvp ( Player  target)
virtual

Allows you to determine whether this projectile can hit the given opponent player. Return false to block this projectile from hitting the target. Returns true by default.

Parameters
targetThe target

Definition at line 308 of file ModProjectile.cs.

308  {
309  return true;
310  }
virtual bool Terraria.ModLoader.ModProjectile.CanUseGrapple ( Player  player)
virtual

This code is called whenever the player uses a grappling hook that shoots this type of projectile. Use it to change what kind of hook is fired (for example, the Dual Hook does this), to kill old hook projectiles, etc.

Definition at line 396 of file ModProjectile.cs.

396  {
397  return null;
398  }
virtual ModProjectile Terraria.ModLoader.ModProjectile.Clone ( )
virtual

Returns a clone of this ModProjectile. Allows you to decide which fields of your ModProjectile class are copied over when a new Projectile is created. By default this will return a memberwise clone; you will want to override this if your GlobalProjectile contains object references. Only called if CloneNewInstances is set to true.

virtual bool Terraria.ModLoader.ModProjectile.Colliding ( Rectangle  projHitbox,
Rectangle  targetHitbox 
)
virtual

Allows you to use custom collision detection between this projectile and a player or NPC that this projectile can damage. Useful for things like diagonal lasers, projectiles that leave a trail behind them, etc.

Parameters
projHitboxThe hitbox of the projectile.
targetHitboxThe hitbox of the target.
Returns
Whether they collide or not.

Definition at line 362 of file ModProjectile.cs.

362  {
363  return null;
364  }
virtual void Terraria.ModLoader.ModProjectile.CutTiles ( )
virtual

Code ran when the projectile cuts tiles. Only runs if CanCutTiles() returns true. Useful when programming lasers and such.

Definition at line 238 of file ModProjectile.cs.

238  {
239  }
virtual void Terraria.ModLoader.ModProjectile.DrawBehind ( int  index,
List< int >  drawCacheProjsBehindNPCsAndTiles,
List< int >  drawCacheProjsBehindNPCs,
List< int >  drawCacheProjsBehindProjectiles,
List< int >  drawCacheProjsOverWiresUI 
)
virtual

When used in conjunction with "projectile.hide = true", allows you to specify that this projectile should be drawn behind certain elements. Add the index to one and only one of the lists. For example, the Nebula Arcanum projectile draws behind NPCs and tiles.

Definition at line 441 of file ModProjectile.cs.

441  {
442  }
virtual Color Terraria.ModLoader.ModProjectile.GetAlpha ( Color  lightColor)
virtual

Allows you to determine the color and transparency in which this projectile is drawn. Return null to use the default color (normally light and buff color). Returns null by default.

Definition at line 369 of file ModProjectile.cs.

369  {
370  return null;
371  }
virtual void Terraria.ModLoader.ModProjectile.GrapplePullSpeed ( Player  player,
ref float  speed 
)
virtual

The speed at which the grapple pulls the player after hitting something. Defaults to 11, but the Bat Hook uses 16.

Definition at line 435 of file ModProjectile.cs.

435  {
436  }
virtual float Terraria.ModLoader.ModProjectile.GrappleRange ( )
virtual

How far away this grappling hook can travel away from its player before it retracts.

Definition at line 416 of file ModProjectile.cs.

416  {
417  return 300f;
418  }
virtual void Terraria.ModLoader.ModProjectile.GrappleRetreatSpeed ( Player  player,
ref float  speed 
)
virtual

The speed at which the grapple retreats back to the player after not hitting anything. Defaults to 11, but vanilla hooks go up to 24.

Definition at line 429 of file ModProjectile.cs.

429  {
430  }
virtual void Terraria.ModLoader.ModProjectile.Kill ( int  timeLeft)
virtual

Allows you to control what happens when this projectile is killed (for example, creating dust or making sounds). Also useful for creating retrievable ammo.

Definition at line 251 of file ModProjectile.cs.

251  {
252  }
virtual bool Terraria.ModLoader.ModProjectile.MinionContactDamage ( )
virtual

Whether or not this minion can damage NPCs by touching them. Returns false by default. Note that this will only be used if this projectile is considered a pet.

Definition at line 264 of file ModProjectile.cs.

264  {
265  return false;
266  }
virtual void Terraria.ModLoader.ModProjectile.ModifyDamageHitbox ( ref Rectangle  hitbox)
virtual

Allows you to change the hitbox used by this projectile for damaging players and NPCs.

Parameters
hitbox

Definition at line 272 of file ModProjectile.cs.

272  {
273  }
virtual void Terraria.ModLoader.ModProjectile.ModifyHitNPC ( NPC  target,
ref int  damage,
ref float  knockback,
ref bool  crit,
ref int  hitDirection 
)
virtual

Allows you to modify the damage, knockback, etc., that this projectile does to an NPC.

Parameters
targetThe target.
damageThe modifiable damage.
knockbackThe modifiable knockback.
critThe modifiable crit.
hitDirectionThe modifiable hit direction.

Definition at line 291 of file ModProjectile.cs.

291  {
292  }
virtual void Terraria.ModLoader.ModProjectile.ModifyHitPlayer ( Player  target,
ref int  damage,
ref bool  crit 
)
virtual

Allows you to modify the damage, etc., that this hostile projectile does to a player.

Parameters
targetThe target.
damageThe modifiable damage.
critThe modifiable crit.

Definition at line 344 of file ModProjectile.cs.

344  {
345  }
virtual void Terraria.ModLoader.ModProjectile.ModifyHitPvp ( Player  target,
ref int  damage,
ref bool  crit 
)
virtual

Allows you to modify the damage, etc., that this projectile does to an opponent player.

Parameters
targetThe target.
damageThe modifiable damage.
critThe modifiable crit.

Definition at line 318 of file ModProjectile.cs.

318  {
319  }
virtual ModProjectile Terraria.ModLoader.ModProjectile.NewInstance ( Projectile  projectileClone)
virtual

Create a new instance of this GlobalProjectile for a Projectile instance. Called at the end of Projectile.SetDefaults. If CloneNewInstances is true, just calls Clone() Otherwise calls the default constructor and copies fields

Definition at line 123 of file ModProjectile.cs.

References Terraria.ModLoader.ModProjectile.aiType, Terraria.ModLoader.ModProjectile.cooldownSlot, Terraria.ModLoader.ModProjectile.drawHeldProjInFrontOfHeldItemAndArms, Terraria.ModLoader.ModProjectile.drawOffsetX, Terraria.ModLoader.ModProjectile.drawOriginOffsetX, Terraria.ModLoader.ModProjectile.drawOriginOffsetY, Terraria.ModLoader.ModProjectile.mod, Terraria.ModLoader.ModProjectile.Name, and Terraria.ModLoader.ModProjectile.projectile.

123  {
124  if (CloneNewInstances) {
125  ModProjectile clone = Clone();
126  clone.projectile = projectileClone;
127  return clone;
128  }
129 
130  ModProjectile copy = (ModProjectile)Activator.CreateInstance(GetType());
131  copy.projectile = projectileClone;
132  copy.mod = mod;
133  copy.Name = Name;
134  copy.aiType = aiType;
135  copy.cooldownSlot = cooldownSlot;
136  copy.drawOffsetX = drawOffsetX;
137  copy.drawOriginOffsetY = drawOriginOffsetY;
138  copy.drawOriginOffsetX = drawOriginOffsetX;
139  copy.drawHeldProjInFrontOfHeldItemAndArms = drawHeldProjInFrontOfHeldItemAndArms;
140  return copy;
141  }
int drawOffsetX
How far to the right of its position this projectile should be drawn. Defaults to 0...
virtual bool CloneNewInstances
Whether instances of this ModProjectile are created through a memberwise clone or its constructor...
bool drawHeldProjInFrontOfHeldItemAndArms
If this projectile is held by the player, determines whether it is drawn in front of or behind the pl...
Mod mod
The mod object that this ModProjectile originates from.
int aiType
Determines which type of vanilla projectile this ModProjectile will copy the behavior (AI) of...
int cooldownSlot
Determines which of the player&#39;s cooldown counters to use (-1, 0, or 1) when this projectile damages ...
int drawOriginOffsetY
The vertical origin offset from the projectile&#39;s center when it is drawn. The origin is essentially t...
virtual ModProjectile Clone()
Returns a clone of this ModProjectile. Allows you to decide which fields of your ModProjectile class ...
virtual string Name
Stores the name of the mod. This name serves as the mod&#39;s identification, and also helps with saving ...
Definition: Mod.cs:39
string Name
The internal name of this ModProjectile.
float drawOriginOffsetX
The horizontal origin offset from the projectile&#39;s center when it is drawn.
virtual void Terraria.ModLoader.ModProjectile.NumGrappleHooks ( Player  player,
ref int  numHooks 
)
virtual

How many of this type of grappling hook the given player can latch onto blocks before the hooks start disappearing. Change the numHooks parameter to determine this; by default it will be 3.

Definition at line 423 of file ModProjectile.cs.

423  {
424  }
virtual void Terraria.ModLoader.ModProjectile.OnHitNPC ( NPC  target,
int  damage,
float  knockback,
bool  crit 
)
virtual

Allows you to create special effects when this projectile hits an NPC (for example, inflicting debuffs).

Parameters
targetThe target.
damageThe damage.
knockbackThe knockback.
critThe critical hit.

Definition at line 301 of file ModProjectile.cs.

301  {
302  }
virtual void Terraria.ModLoader.ModProjectile.OnHitPlayer ( Player  target,
int  damage,
bool  crit 
)
virtual

Allows you to create special effects when this hostile projectile hits a player.

Parameters
targetThe target.
damageThe damage.
critThe critical hit.

Definition at line 353 of file ModProjectile.cs.

353  {
354  }
virtual void Terraria.ModLoader.ModProjectile.OnHitPvp ( Player  target,
int  damage,
bool  crit 
)
virtual

Allows you to create special effects when this projectile hits an opponent player.

Parameters
targetThe target.
damageThe damage.
critThe critical hit.

Definition at line 327 of file ModProjectile.cs.

327  {
328  }
virtual bool Terraria.ModLoader.ModProjectile.OnTileCollide ( Vector2  oldVelocity)
virtual

Allows you to determine what happens when this projectile collides with a tile. OldVelocity is the velocity before tile collision. The velocity that takes tile collision into account can be found with projectile.velocity. Return true to allow the vanilla tile collision code to take place (which normally kills the projectile). Returns true by default.

Parameters
oldVelocityThe velocity of the projectile upon collision.

Definition at line 224 of file ModProjectile.cs.

224  {
225  return true;
226  }
virtual void Terraria.ModLoader.ModProjectile.PostAI ( )
virtual

Allows you to determine how this projectile behaves. This will be called regardless of what PreAI returns.

Definition at line 188 of file ModProjectile.cs.

188  {
189  }
virtual void Terraria.ModLoader.ModProjectile.PostDraw ( SpriteBatch  spriteBatch,
Color  lightColor 
)
virtual

Allows you to draw things in front of a projectile. This method is called even if PreDraw returns false.

Definition at line 390 of file ModProjectile.cs.

390  {
391  }
virtual bool Terraria.ModLoader.ModProjectile.PreAI ( )
virtual

Allows you to determine how this projectile behaves. Return false to stop the vanilla AI and the AI hook from being run. Returns true by default.

Returns
Whether or not to stop other AI.

Definition at line 175 of file ModProjectile.cs.

175  {
176  return true;
177  }
virtual bool Terraria.ModLoader.ModProjectile.PreDraw ( SpriteBatch  spriteBatch,
Color  lightColor 
)
virtual

Allows you to draw things behind this projectile, or to modify the way this projectile is drawn. Return false to stop the game from drawing the projectile (useful if you're manually drawing the projectile). Returns true by default.

Definition at line 383 of file ModProjectile.cs.

383  {
384  return true;
385  }
virtual bool Terraria.ModLoader.ModProjectile.PreDrawExtras ( SpriteBatch  spriteBatch)
virtual

Allows you to draw things behind this projectile. Returns false to stop the game from drawing extras textures related to the projectile (for example, the chains for grappling hooks), useful if you're manually drawing the extras. Returns true by default.

Definition at line 376 of file ModProjectile.cs.

376  {
377  return true;
378  }
virtual bool Terraria.ModLoader.ModProjectile.PreKill ( int  timeLeft)
virtual

Allows you to determine whether the vanilla code for Kill and the Kill hook will be called. Return false to stop them from being called. Returns true by default. Note that this does not stop the projectile from dying.

Definition at line 244 of file ModProjectile.cs.

244  {
245  return true;
246  }
virtual void Terraria.ModLoader.ModProjectile.ReceiveExtraAI ( BinaryReader  reader)
virtual

Use this to receive information that was sent in SendExtraAI.

Definition at line 200 of file ModProjectile.cs.

200  {
201  }
virtual void Terraria.ModLoader.ModProjectile.SendExtraAI ( BinaryWriter  writer)
virtual

If you are storing AI information outside of the projectile.ai array, use this to send that AI information between clients and servers.

Definition at line 194 of file ModProjectile.cs.

194  {
195  }
virtual void Terraria.ModLoader.ModProjectile.SetDefaults ( )
virtual

Allows you to set all your projectile's properties, such as width, damage, aiStyle, penetrate, etc.

Definition at line 146 of file ModProjectile.cs.

146  {
147  }
virtual void Terraria.ModLoader.ModProjectile.SetStaticDefaults ( )
virtual

Allows you to set all your projectile's static properties, such as names/translations and the arrays in ProjectileID.Sets.

Definition at line 152 of file ModProjectile.cs.

Referenced by Terraria.ModLoader.Mod.LoadEffect().

152  {
153  }

+ Here is the caller graph for this function:

virtual bool Terraria.ModLoader.ModProjectile.ShouldUpdatePosition ( )
virtual

Whether or not this projectile should update its position based on factors such as its velocity, whether it is in liquid, etc. Return false to make its velocity have no effect on its position. Returns true by default.

Definition at line 206 of file ModProjectile.cs.

206  {
207  return true;
208  }
virtual bool Terraria.ModLoader.ModProjectile.SingleGrappleHook ( Player  player)
virtual

Whether or not a grappling hook can only have one hook per player in the world at a time. Return null to use the vanilla code. Returns null by default.

Definition at line 403 of file ModProjectile.cs.

403  {
404  return null;
405  }
virtual bool Terraria.ModLoader.ModProjectile.TileCollideStyle ( ref int  width,
ref int  height,
ref bool  fallThrough 
)
virtual

Allows you to determine how this projectile interacts with tiles. Width and height determine the projectile's hitbox for tile collision, and default to -1. Leave them as -1 to use the projectile's real size. Fallthrough determines whether the projectile can fall through platforms, etc., and defaults to true.

Parameters
widthWidth of the hitbox.
heightHeight of the hitbox.
fallThroughIf the projectile can fall through platforms etc.

Definition at line 216 of file ModProjectile.cs.

216  {
217  return true;
218  }
virtual void Terraria.ModLoader.ModProjectile.UseGrapple ( Player  player,
ref int  type 
)
virtual

This code is called whenever the player uses a grappling hook that shoots this type of projectile. Use it to change what kind of hook is fired (for example, the Dual Hook does this), to kill old hook projectiles, etc.

Definition at line 410 of file ModProjectile.cs.

410  {
411  }

Member Data Documentation

int Terraria.ModLoader.ModProjectile.aiType = 0

Determines which type of vanilla projectile this ModProjectile will copy the behavior (AI) of. Leave as 0 to not copy any behavior. Defaults to 0.

Definition at line 69 of file ModProjectile.cs.

Referenced by Terraria.ModLoader.ModProjectile.NewInstance().

virtual bool Terraria.ModLoader.ModProjectile.CloneNewInstances => false

Whether instances of this ModProjectile are created through a memberwise clone or its constructor. Defaults to false.

Definition at line 107 of file ModProjectile.cs.

int Terraria.ModLoader.ModProjectile.cooldownSlot = -1

Determines which of the player's cooldown counters to use (-1, 0, or 1) when this projectile damages it. Defaults to -1.

Definition at line 73 of file ModProjectile.cs.

Referenced by Terraria.ModLoader.ModProjectile.NewInstance().

bool Terraria.ModLoader.ModProjectile.drawHeldProjInFrontOfHeldItemAndArms = false

If this projectile is held by the player, determines whether it is drawn in front of or behind the player's arms. Defaults to false.

Definition at line 89 of file ModProjectile.cs.

Referenced by Terraria.ModLoader.ModProjectile.NewInstance().

int Terraria.ModLoader.ModProjectile.drawOffsetX = 0

How far to the right of its position this projectile should be drawn. Defaults to 0.

Definition at line 77 of file ModProjectile.cs.

Referenced by Terraria.ModLoader.ModProjectile.NewInstance().

float Terraria.ModLoader.ModProjectile.drawOriginOffsetX = 0f

The horizontal origin offset from the projectile's center when it is drawn.

Definition at line 85 of file ModProjectile.cs.

Referenced by Terraria.ModLoader.ModProjectile.NewInstance().

int Terraria.ModLoader.ModProjectile.drawOriginOffsetY = 0

The vertical origin offset from the projectile's center when it is drawn. The origin is essentially the point of rotation. This field will also determine the vertical drawing offset of the projectile.

Definition at line 81 of file ModProjectile.cs.

Referenced by Terraria.ModLoader.ModProjectile.NewInstance().

virtual string Terraria.ModLoader.ModProjectile.GlowTexture => Texture + "_Glow"

The file name of this projectile's glow texture file in the mod loader's file space. If it does not exist it is ignored.

Definition at line 65 of file ModProjectile.cs.

virtual string Terraria.ModLoader.ModProjectile.Texture => (GetType().Namespace + "." + Name).Replace('.', '/')

The file name of this projectile's texture file in the mod loader's file space.

Definition at line 61 of file ModProjectile.cs.

Property Documentation

ModTranslation Terraria.ModLoader.ModProjectile.DisplayName
getset

The translations for the display name of this projectile.

Definition at line 53 of file ModProjectile.cs.

Referenced by Terraria.ModLoader.Mod.AddProjectile(), and Terraria.ModLoader.ModContent.RefreshModLanguage().

Mod Terraria.ModLoader.ModProjectile.mod
getset

The mod object that this ModProjectile originates from.

The mod.

Definition at line 34 of file ModProjectile.cs.

Referenced by Terraria.ModLoader.Mod.AddProjectile(), Terraria.ModLoader.Mod.AutoloadProjectile(), and Terraria.ModLoader.ModProjectile.NewInstance().

string Terraria.ModLoader.ModProjectile.Name
getset

The internal name of this ModProjectile.

The name.

Definition at line 45 of file ModProjectile.cs.

Referenced by Terraria.ModLoader.Mod.AddProjectile(), and Terraria.ModLoader.ModProjectile.NewInstance().

Projectile Terraria.ModLoader.ModProjectile.projectile
getset