TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches
Terraria.Projectile Class Reference
+ Inheritance diagram for Terraria.Projectile:
+ Collaboration diagram for Terraria.Projectile:

Classes

struct  HallowBossPelletStormInfo
 
class  NPCDistanceByIndexComparator
 

Public Member Functions

bool TurretShouldPersist ()
 
void CloneDefaults (int TypeToClone)
 
void SetDefaults (int Type)
 
void DefaultToSpray ()
 
void DefaultToWhip ()
 
void StatusNPC (int i)
 
void StatusPvP (int i)
 
void ghostHurt (int dmg, Vector2 Position, Entity victim)
 
void ghostHeal (int dmg, Vector2 Position, Entity victim)
 
void vampireHeal (int dmg, Vector2 Position, Entity victim)
 
void StatusPlayer (int i)
 
bool CanHitWithMeleeWeapon (Entity ent)
 
bool CanHitWithOwnBody (Entity ent)
 
void Damage ()
 
bool IsDamageDodgable ()
 
bool Colliding (Rectangle myRect, Rectangle targetRect)
 
void ProjLight ()
 
Rectangle getRect ()
 
void Update (int i)
 
void EmitEnchantmentVisualsAt (Vector2 boxPosition, int boxWidth, int boxHeight)
 
void FishingCheck ()
 
bool CanBeReflected ()
 
Color GetFairyQueenWeaponsColor (float alphaChannelMultiplier=1f, float lerpToWhite=0f, float? rawHueOverride=null)
 
float GetLastPrismHue (float laserIndex, ref float laserLuminance, ref float laserAlphaMultiplier)
 
void ProjectileFixDesperation ()
 
bool ShouldUseWindPhysics ()
 
bool IsInterruptible (Player player)
 
void Interrupt (Player player)
 
void Resize (int newWidth, int newHeight)
 Changes the F:Terraria.Entity.width and F:Terraria.Entity.height of the projectile while preserving the P:Terraria.Entity.Center. Useful for explosive projectiles that expand their hitbox while exploding.
 
void AI ()
 
void VanillaAI ()
 
void ResetLocalNPCHitImmunity ()
 
NPC FindTargetWithinRange (float maxRange, bool checkCanHit=false)
 
Color AI_173_GetColor ()
 
Color AI_171_GetColor ()
 
int AI_172_GetPelletStormsCount ()
 
HallowBossPelletStormInfo AI_172_GetPelletStormInfo (int stormIndex)
 
int FindTargetWithLineOfSight (float maxRange=800f)
 Finds the closest NPC to this projectile which can be targeted and which it has line of sight to.
 
bool AI_019_Spears_GetExtensionHitbox (out Rectangle extensionBox)
 
void Minion_FindTargetInRange (int startAttackRange, ref int attackTarget, bool skipIfCannotHitWithOwnBody, Func< Entity, int, bool > customEliminationCheck=null)
 
bool IsInRangeOfMeOrMyOwner (Entity entity, float maxDistance, out float myDistance, out float playerDistance, out bool closerIsMe)
 
Color AI_156_GetColor ()
 
Color GetCeleb2Color ()
 
void CheckUsability (Player player, ref bool currentlyUsable)
 
void CreateImpactExplosion (int dustAmountMultiplier, Vector2 explosionOrigin, ref Point scanAreaStart, ref Point scanAreaEnd, int explosionRange, out bool causedShockwaves)
 
void CreateImpactExplosion2_FlailTileCollision (Vector2 explosionOrigin, bool causedShockwaves, Vector2 velocityBeforeCollision)
 
bool AI_137_CanHit (Vector2 targetPosition)
 
Color GetFirstFractalColor ()
 
void Kill_DirtAndFluidProjectiles_RunDelegateMethodPushUpForHalfBricks (Point pt, float size, Utils.TileActionAttempt plot)
 
bool IsAttachedTo (NPC npc)
 
void Kill ()
 
bool ShouldWallExplode (Vector2 compareSpot, int radius, int minI, int maxI, int minJ, int maxJ)
 Determines if walls should be exploded by checking if there is an empty wall within the specified radius and bounds. Use in conjunction with M:Terraria.Projectile.ExplodeTiles(Microsoft.Xna.Framework.Vector2,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Boolean).
 
Color GetFloatingDaggerMinionGlowColor ()
 
bool CanExplodeTile (int x, int y)
 
void ExplodeTiles (Vector2 compareSpot, int radius, int minI, int maxI, int minJ, int maxJ, bool wallSplode)
 Explodes tiles within a radius of the given position and within the bounds passed in. The wallSplode parameter should be the result of M:Terraria.Projectile.ShouldWallExplode(Microsoft.Xna.Framework.Vector2,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32) and dictates if walls will also be destroyed. This method honors the tile and wall explosion conditions.
 
void ExplodeCrackedTiles (Vector2 compareSpot, int radius, int minI, int maxI, int minJ, int maxJ)
 
bool TryGetContainerIndex (out int containerIndex)
 
bool IsInteractible ()
 
Color GetAlpha (Color newColor)
 
override string ToString ()
 
GetGlobalProjectile< T > ()
 Gets the instance of the specified GlobalProjectile type. This will throw exceptions on failure.
 
GetGlobalProjectile< T > (T baseInstance)
 Gets the local instance of the type of the specified GlobalProjectile instance. This will throw exceptions on failure.
 
bool TryGetGlobalProjectile< T > (out T result)
 Gets the instance of the specified GlobalProjectile type.
 
bool TryGetGlobalProjectile< T > (T baseInstance, out T result)
 Safely attempts to get the local instance of the type of the specified GlobalProjectile instance.
 
void ApplyStatsFromSource (IEntitySource spawnSource)
 Transfers stat modifiers from the spawn source to the projectile.
Adds P:Terraria.Projectile.CritChance and P:Terraria.Projectile.ArmorPenetration bonuses from players (T:Terraria.DataStructures.EntitySource_Parent), weapons (T:Terraria.DataStructures.EntitySource_ItemUse)
If the source is a T:Terraria.DataStructures.EntitySource_Parent projectile, CritChance and ArmorPenetration from the parent will be added, in order to transfer the original item/player bonus values.


To support minions, sentries and P:Terraria.Projectile.ContinuouslyUpdateDamageStats, P:Terraria.Projectile.OriginalCritChance and P:Terraria.Projectile.OriginalArmorPenetration are also copied from item sources and parent projectiles.
 
bool TryGetOwner ([NotNullWhen(true)] out Player? player)
 
bool CountsAsClass< T > ()
 
bool CountsAsClass (DamageClass damageClass)
 This is used to check if the projectile is considered to be a member of a specified T:Terraria.ModLoader.DamageClass.
 
float AngleTo (Vector2 Destination)
 
float AngleFrom (Vector2 Source)
 
float Distance (Vector2 Other)
 
float DistanceSQ (Vector2 Other)
 
Vector2 DirectionTo (Vector2 Destination)
 
Vector2 DirectionFrom (Vector2 Source)
 
bool WithinRange (Vector2 Target, float MaxRange)
 
IEntitySource GetSource_FromThis (string? context=null)
 
IEntitySource GetSource_FromAI (string? context=null)
 
IEntitySource GetSource_DropAsItem (string? context=null)
 
IEntitySource GetSource_Loot (string? context=null)
 
IEntitySource GetSource_GiftOrReward (string? context=null)
 
IEntitySource GetSource_OnHit (Entity victim, string? context=null)
 
IEntitySource GetSource_OnHurt (Entity? attacker, string? context=null)
 
IEntitySource GetSource_Death (string? context=null)
 
IEntitySource GetSource_Misc (string context)
 
IEntitySource GetSource_TileInteraction (int tileCoordsX, int tileCoordsY, string? context=null)
 
IEntitySource GetSource_ReleaseEntity (string? context=null)
 
IEntitySource GetSource_CatchEntity (Entity caughtEntity, string? context=null)
 

Static Public Member Functions

static void InitializeStaticThings ()
 
static void ResetImmunity ()
 
static bool IsNPCIndexImmuneToProjectileType (int projectileType, int npcIndex)
 
static int GetNextSlot ()
 
static int NewProjectile (IEntitySource spawnSource, Vector2 position, Vector2 velocity, int Type, int Damage, float KnockBack, int Owner=-1, float ai0=0f, float ai1=0f, float ai2=0f)
 

This particular overload uses a Vector2 instead of X and Y to determine the actual spawn position and a Vector2 to dictate the initial velocity.
 
static int FindOldestProjectile ()
 
static int NewProjectile (IEntitySource spawnSource, float X, float Y, float SpeedX, float SpeedY, int Type, int Damage, float KnockBack, int Owner=-1, float ai0=0f, float ai1=0f, float ai2=0f)
 Spawns a projectile into the game world with the given type. The spawn position is given in world coordinates by the X and Y parameters. SpeedX and SpeedY dictate the initial velocity. Damage and KnockBack are self-explanatory. Owner is the player who spawned the projectile, almost always Main.myPlayer. ai0, ai1, and ai2 will initialize the Projectile.ai[] array with the supplied values. This can be used to pass in information to the Projectile. The Projectile AI code will have to be written to utilize those values. The return value is the index of the spawned Projectile within the F:Terraria.Main.projectile array.
Make sure that this method is called only by the client in charge of the source causing this projectile to spawn. Failure to do this will result in the projectile spawning once for each player in the world. For example, if Player code uses this method, make sure to first check.
 
static Color GetGolfTrailColor (Projectile proj)
 
static void KillOldestJavelin (int protectedProjectileIndex, int projectileType, int targetNPCIndex, Point[] bufferForScan)
 
static void EmitBlackLightningParticles (NPC targetNPC)
 
static int GetByUUID (int owner, float uuid)
 
static int GetByUUID (int owner, int uuid)
 
static void UseGasTrapInChest (int chestIndex, Chest theChest, int gasTrapIndex, int gasOffsetX, int gasOffsetY)
 
static bool GasTrapCheck (int x, int y, Player user)
 
static void AI_192_GetJuminoFall (Projectile proj, out float timeSinceFall, out float fall)
 
static void RandomizeInsanityShadowFor (Entity targetEntity, bool isHostile, out Vector2 spawnposition, out Vector2 spawnvelocity, out float ai0, out float ai1)
 
static Vector2 AI_164_GetHomeLocation (Player master, int stackedIndex, int totalIndexes)
 
static void FillWhipControlPoints (Projectile proj, List< Vector2 > controlPoints)
 
static void GetWhipSettings (Projectile proj, out float timeToFlyOut, out int segments, out float rangeMultiplier)
 
static Vector2 AI_158_GetHomeLocation (Player master, int stackedIndex)
 
static int GetBallistraShotDelay (Player player)
 
static int GetExplosiveTrapCooldown (Player player)
 
static Projectile NewProjectileDirect (IEntitySource spawnSource, Vector2 position, Vector2 velocity, int type, int damage, float knockback, int owner=-1, float ai0=0f, float ai1=0f, float ai2=0f)
 

This particular overload uses a Vector2 instead of X and Y to determine the actual spawn position and a Vector2 to dictate the initial velocity. The return value is the actual Projectile instance rather than the index of the spawned Projectile within the F:Terraria.Main.projectile array.
A short-hand for
 
static void DropGeodeLoot (Entity entity)
 Will drop loot the same way as when F:Terraria.ID.ProjectileID.Geode is cracked open.
 
static ? IEntitySource GetSource_None ()
 
static ? IEntitySource InheritSource (Entity entity)
 
static IEntitySource GetSource_NaturalSpawn ()
 
static IEntitySource GetSource_TownSpawn ()
 

Public Attributes

float ownerHitCheckDistance = 1000f
 
bool arrow
 
int numHits
 
bool bobber
 
bool netImportant
 Indicates that this projectile will be synced to a joining player (by default, any projectiles active before the player joins (besides projectiles with type in F:Terraria.Main.projPet) are not synced over). Example: glowsticks
Defaults to false.
 
bool noDropItem
 Set to true if you don't want this projectile to have a chance to recover the ammo item that shot this. For example, if you shoot the F:Terraria.ID.ProjectileID.WoodenArrowFriendly projectile, it will sometimes drop the F:Terraria.ID.ItemID.WoodenArrow item. If your weapon shoots multiple arrows for 1 ammo, you might want to consider setting this field to prevent infinite ammo glitches.
In M:Terraria.ModLoader.ModProjectile.OnKill(System.Int32), check this and F:Terraria.Projectile.owner to decide if the item should drop:
 
bool counterweight
 
float scale = 1f
 Scales how large the projectile will be drawn. Will also affect the hitbox (F:Terraria.Entity.width, F:Terraria.Entity.height) if assigned in SetDefaults. If changed elsewhere it will not affect the hitbox, so that will have to be adjusted manually via code in that situation if needed.
 
float rotation
 Rotation of the projectile. Radians not Degrees. Use T:Microsoft.Xna.Framework.MathHelper if you want to convert degrees to radians. 0 is facing right, F:Microsoft.Xna.Framework.MathHelper.PiOver2 is facing down, and so on. Note that hitboxes do not rotate.
The Basic Projectile Guideteaches more about projectile rotation.
Defaults to 0f.
 
int type
 The Projectile ID of this projectile. The Projectile ID is a unique number assigned to each Projectile loaded into the game. This will be equal to either an T:Terraria.ID.ProjectileID entry or M:Terraria.ModLoader.ModContent.ProjectileType``1, for example F:Terraria.ID.ProjectileID.WoodenArrowFriendly or ModContent.ProjectileType<MyModProjectile>(). To check if a Projectile instance is a specific Projectile, check Projectile.type == ProjectileID.VanillaProjectileHere or Projectile.type == ModContent.ProjectileType<ModdedProjectileHere>() in an if statement.
 
int alpha
 How transparent to draw this projectile. 0 to 255. 255 is completely transparent.
ExampleBulletsets this to 255, and the projectile aiStyle of F:Terraria.ID.ProjAIStyleID.Arrow automatically decreases alpha each tick, letting the projectile fade in quickly after being spawned. Useful for projectiles that look odd when initially spawned on the weapon because of texture overlap.
The Basic Projectile Guideteaches more about projectile fade in and out.
Defaults to 0.
 
bool sentry
 Indicates that this projectile is a sentry
Defaults to false.
All sentries should set F:Terraria.Projectile.timeLeft to F:Terraria.Projectile.SentryLifeTime.
When a sentry is spawned, M:Terraria.Player.UpdateMaxTurrets should be called immediately after.
 
short glowMask
 
int owner = 255
 The index of the player who owns this projectile. In Multiplayer, Clients "own" projectiles that they shoot, while the Server "owns" projectiles spawned by NPCs and the World.
NPC never own projectiles, do not use owner to index into F:Terraria.Main.npc.
It is very important to check if (Projectile.owner == Main.myPlayer) for things like dropping items or spawning projectiles in M:Terraria.ModLoader.ModProjectile.AI and some other methods because AI runs simultaneously on all Clients and the Server. This check gates some of the code that should only run on the owners computer. ExamplePaperAirplaneProjectilechecks owner for spawning the recovered ammo item. If you don't do this, you will run into desync bugs in your mod.
Defaults to the owner parameter of Projectile.NewProjectile, which should always be set to F:Terraria.Main.myPlayer to correspond to the client that owns the projectile..
 
float[] ai = new float[maxAI]
 An array with 3 slots used for any sort of data storage, which is occasionally synced to the server. Each vanilla T:Terraria.ID.ProjAIStyleID uses these slots for different purposes. Set F:Terraria.Projectile.netUpdate to true during AI methods to manually sync. The advantage of using these 3 floats is that they are synced automatically. Using fields in your P:Terraria.Projectile.ModProjectile class will work just the same, but they might need to be synced via M:Terraria.ModLoader.ModProjectile.SendExtraAI(System.IO.BinaryWriter) and M:Terraria.ModLoader.ModProjectile.ReceiveExtraAI(System.IO.BinaryReader) if necessary.
Clever use of Reference return valuesas seen in ExampleLightPetProjectile.cscan be used to reuse the ai array entries with readable names.
Defaults to the values passed into M:Terraria.Projectile.NewProjectile(Terraria.DataStructures.IEntitySource,System.Single,System.Single,System.Single,System.Single,System.Int32,System.Int32,System.Single,System.Int32,System.Single,System.Single,System.Single), usually [0, 0, 0].
 
float[] localAI = new float[maxAI]
 Acts like F:Terraria.Projectile.ai, but does not sync to the server. Many vanilla T:Terraria.ID.ProjAIStyleID use these slots for various purposes.
Defaults to [0, 0, 0].
 
float gfxOffY
 An offset from the actual position of the projectile that will be added to the draw position. Used to offset some held projectiles to match the players F:Terraria.Player.gfxOffY, thereby keeping the projectile visually in sync with the player. F:Terraria.ID.ProjectileID.Sets.HeldProjDoesNotUsePlayerGfxOffY can be used to ignore that usage.
 
float stepSpeed = 1f
 Has nothing to do with the speed that this projectile travels, that is dictated by AI code adjusting F:Terraria.Entity.velocity.
 
int aiStyle
 Selects which vanilla code to use for the AI method. Vanilla projectile AI styles are enumerated in the T:Terraria.ID.ProjAIStyleID class. Modders can use vanilla aiStyle and optionally P:Terraria.ModLoader.ModProjectile.AIType to mimic AI code already in the game. This is usually only useful as a prototyping tool since it is difficult to customize existing aiStyle code. See P:Terraria.ModLoader.ModProjectile.AIType and ExampleCloneProjectileto see how to use vanilla ai. If you are using custom AI code, there is no need to set this field.
The Basic Projectile Guideteaches how to use an existing aiStyle.
Customizing an existing aiStyle usually requires following the Vanilla Code Adaption Guide.
Defaults to 0.
 
int timeLeft
 Time in ticks before this projectile will naturally despawn.
Each update timeLeft is decreased by 1. Once timeLeft hits 0, the Projectile will naturally despawn. The default value, 3600, is measured in ticks, which are usually 60 per seconds, so the default despawn time is about 60 seconds. Adjust this if you want the projectile to fizzle early rather than travel infinitely. Note that F:Terraria.Projectile.extraUpdates will cause it to decrease faster than normal time because Update is being called more often.
Defaults to 3600.
 
int soundDelay
 
int damage
 This will always be set in Projectile.NewProjectile based on the weapons damage and player stat modifiers. Modders should not set this in M:Terraria.ModLoader.ModProjectile.SetDefaults as it will be overwritten.
 
int originalDamage
 
int spriteDirection = 1
 
bool hostile
 If True, this projectile will hurt players and friendly NPCs (F:Terraria.NPC.friendly)
Defaults to false.
 
bool reflected
 
float knockBack
 This will always be set in Projectile.NewProjectile based on the weapons knockback and player stat modifiers. Modders should not set this in M:Terraria.ModLoader.ModProjectile.SetDefaults as it will be overwritten.
 
bool friendly
 If True, this projectile will hurt enemies (!F:Terraria.NPC.friendly)
Defaults to false.
 
int penetrate = 1
 The remaining number of npc can this projectile hit before dying. (Or tile bounces). Assign this field in SetDefaults and use it in ModProjectile logic if needed. A value of -1 means the projectile will penetrate infinitely. See ExamplePiercingProjectilefor more information on how penetrate influences NPC immunity frames.
Defaults to 1. Used to automatically assigned a value to F:Terraria.Projectile.maxPenetrate at the end of SetDefaults.
 
int[] localNPCImmunity = new int[200]
 
bool usesLocalNPCImmunity
 If true, this projectile manages it's own immunity timers for each npc.
Use this rather than F:Terraria.Projectile.usesIDStaticNPCImmunity if you want multiple projectiles of the same type to have a chance to attack rapidly, but don't want a single projectile to hit rapidly.
F:Terraria.Projectile.localNPCHitCooldown controls the cooldown timing and must be assigned a suitable value to work properly.

 
bool usesIDStaticNPCImmunity
 If true, all projectiles of this type share an immunity cooldown for each npc.
Use this rather than F:Terraria.Projectile.usesLocalNPCImmunity if you want other projectile types a chance to attack the npc, but don't want projectile of the same projectile type to hit an npc rapidly.
F:Terraria.Projectile.idStaticNPCHitCooldown controls the cooldown timing and must be assigned a suitable value to work properly.

 
bool appliesImmunityTimeOnSingleHits
 If true, this projectile will apply immunity to an npc despite having a F:Terraria.Projectile.penetrate value of 1. Used only for firework rockets in Terraria content.
 
int maxPenetrate = 1
 How many npc can this projectile hit before dying. (Or tile bounces)
Automatically set at the end of SetDefaults to the value of F:Terraria.Projectile.penetrate.
 
int identity
 The projectile's universal unique identifier, which is the same on all clients and the server. Usually used to find the same projectile on multiple clients and/or the server, e.g. Projectile match = Main.projectile.FirstOrDefault(x => x.identity == identity);
Projectile.whoAmI indexes are not consistent between clients.
 
float light
 Set to a value above 0f to make this projectile emit a white light (higher number: more intensive light. 1f being stronger than a torch))
The Basic Projectile Guideteaches more about lighting, including non-white lighting, dust light, and glow behavior.
Defaults to 0.
 
bool netUpdate
 Set manually to true in M:Terraria.ModLoader.ModProjectile.AI once to make it sync its current F:Terraria.Projectile.ai[] array to the server and other clients (depending on what the F:Terraria.Main.netMode is where this is set to true)
 
bool netUpdate2
 Used internally to check for projectiles that spam F:Terraria.Projectile.netUpdate. Don't use it yourself manually.
 
int netSpam
 
Vector2[] oldPos = (Vector2[])(object)new Vector2[10]
 Holds the value of F:Terraria.Entity.position from previous updates from newest to oldest. Use for drawing trails. Must be used with F:Terraria.ID.ProjectileID.Sets.TrailCacheLength and F:Terraria.ID.ProjectileID.Sets.TrailingMode to be used properly.
 
float[] oldRot = new float[10]
 Holds the value of F:Terraria.Projectile.rotation from previous updates from newest to oldest. Use for drawing trails. Must be used with F:Terraria.ID.ProjectileID.Sets.TrailCacheLength and F:Terraria.ID.ProjectileID.Sets.TrailingMode to be used properly.
 
int[] oldSpriteDirection = new int[10]
 Holds the value of F:Terraria.Projectile.spriteDirection from previous updates from newest to oldest. Use for drawing trails. Must be used with F:Terraria.ID.ProjectileID.Sets.TrailCacheLength and F:Terraria.ID.ProjectileID.Sets.TrailingMode to be used properly.
 
bool minion
 Indicates that this projectile is a minion
Defaults to false.
 
float minionSlots
 Set to 1f on a minion to count it towards the minion limit of the summoning player (Optic Staff summons two minions at once with 0.5f each)
Make sure to set F:Terraria.ID.ItemID.Sets.StaffMinionSlotsRequired for the minion summoning item to the sum of the minionSlots values of the minions that will be spawned.
Defaults to 0f.
 
int minionPos
 A number indicating the order of minions. Minion AI code typically uses this value to determine a suitable idle position that results in minions lining up neatly in relation to the player without bunching up.
 
int restrikeDelay
 
bool tileCollide
 If true, the projectile will collide with tiles, usually bouncing or killing the tile depending on M:Terraria.ModLoader.ModProjectile.OnTileCollide(Microsoft.Xna.Framework.Vector2). ExampleBulletshows how to implement bounce.
Defaults to true.
 
int extraUpdates
 Additional update steps per tick. Useful for really fast projectiles such as Shadowbeam Staff. If your projectile is mistakenly occasionally traveling through tiles, you may need to increase this to prevent that.
Defaults to 0.
 
bool stopsDealingDamageAfterPenetrateHits
 
int numUpdates
 
bool ignoreWater
 The projectile will not be affected by water.
Defaults to false.
 
bool isAPreviewDummy
 
bool hide
 Projectile is not drawn normally. Held projectiles (F:Terraria.Player.heldProj) and projectiles specified to be drawn at specific layers (M:Terraria.ModLoader.ModProjectile.DrawBehind(System.Int32,System.Collections.Generic.List<System.Int32>,System.Collections.Generic.List<System.Int32>,System.Collections.Generic.List<System.Int32>,System.Collections.Generic.List<System.Int32>,System.Collections.Generic.List<System.Int32>)) use this.
 
bool ownerHitCheck
 If true, then this projectile will only deal damage if its owner has line of sight to the hit.
Useful for melee projectiles, such as spears and shortswords.
Defaults to false.
 
bool usesOwnerMeleeHitCD
 
int[] playerImmune = new int[255]
 
string miscText = ""
 
bool coldDamage
 
bool noEnchantments
 
bool noEnchantmentVisuals
 
bool trap
 If true, this projectile was spawned by a trap tile.
 
bool npcProj
 If true, this projectile was spawned by a friendly Town NPC.
 
bool originatedFromActivableTile
 
int frameCounter
 Used as a timer to decide when to change F:Terraria.Projectile.frame.
Defaults to 0.
 
int frame
 The frame number in the spritesheet that this projectile will be drawn with. Assign in M:Terraria.ModLoader.ModProjectile.AI based on the state of the projectile and F:Terraria.Projectile.frameCounter.
F:Terraria.Main.projFrames must be set in ModProjectile.SetStaticDefaults as well.
Example: projectile has 4 frames, then frame can have values between 0 and 3
The Basic Projectile Guideteaches how to animate projectiles.
Defaults to 0.
 
bool manualDirectionChange
 
int projUUID = -1
 
bool decidesManualFallThrough
 
bool shouldFallThrough
 
int localNPCHitCooldown = -2
 When used in conjunction with F:Terraria.Projectile.usesLocalNPCImmunity, determines how many ticks must pass before this projectile can deal damage again to the same npc. A value of -1 indicates that it can only hit a specific npc once. The default value of -2 has no effect, so this must be assigned if usesLocalNPCImmunity is true.
 
int idStaticNPCHitCooldown = -1
 When used in conjunction with F:Terraria.Projectile.usesIDStaticNPCImmunity, determines how many ticks must pass before any projectile of the same type can deal damage again to the same npc. This must be assigned a suitable value if usesIDStaticNPCImmunity is true.
 
int bannerIdToRespondTo
 
List< Vector2 > WhipPointsForCollision = new List<Vector2>()
 
WhipSettings WhipSettings
 
int whoAmI
 The index of this Entity within its specific array. These arrays track the entities in the world.
Item: unused
Projectile: F:Terraria.Main.projectile
NPC: F:Terraria.Main.npc
Player: F:Terraria.Main.player
 
bool active
 If true, the Entity actually exists within the game world. Within the specific entity array, if active is false, the entity is junk data. Always check active if iterating over the entity array.
 
Vector2 position
 The position of this Entity in world coordinates.
 
Vector2 velocity
 The velocity of this Entity in world coordinates per tick.
 
Vector2 oldPosition
 
Vector2 oldVelocity
 
int oldDirection
 
int direction = 1
 
int width
 The width of this Entity's hitbox, in pixels.
 
int height
 The height of this Entity's hitbox, in pixels.
 
bool wet
 The Entity is currently in water.
Projectile: Affects movement speed and some projectiles die when wet. F:Terraria.Projectile.ignoreWater prevents this.
 
bool shimmerWet
 
bool honeyWet
 
byte wetCount
 
bool lavaWet
 

Static Public Attributes

static uint[][] perIDStaticNPCImmunity = new uint[ProjectileID.Count][]
 
const int SentryLifeTime = 36000
 
const int ArrowLifeTime = 1200
 
static int maxAI = 3
 

Package Functions

IEntitySource GetNPCSource_FromThis ()
 
IEntitySource GetProjectileSource_FromThis ()
 
IEntitySource GetItemSource_FromThis ()
 
IEntitySource GetItemSource_DropAsItem ()
 
IEntitySource GetProjectileSource_OnHit (Entity victim, int projectileSourceId)
 
IEntitySource GetItemSource_OnHit (Entity victim, int itemSourceId)
 

Static Package Functions

static IEntitySource GetNoneSource ()
 

Package Attributes

GlobalProjectile[] _globals
 
long entityId
 

Properties

bool melee [get, set]
 
bool ranged [get, set]
 
bool magic [get, set]
 
string Name [get, set]
 
bool WipableTurret [get]
 
float Opacity [get, set]
 
int MaxUpdates [get, set]
 
NPC OwnerMinionAttackTargetNPC [get]
 
ModProjectile ModProjectile [get, set]
 The ModProjectile instance that controls the behavior of this projectile. This property is null if this is not a modded projectile.
 
int IEntityWithGlobals< GlobalProjectile >. Type [get]
 
RefReadOnlyArray< GlobalProjectileEntityGlobals [get]
 
EntityGlobalsEnumerator< GlobalProjectileGlobals [get]
 
DamageClass DamageType [get, set]
 The damage type assigned to this projectile, represented as a DamageClass. Leave blank or use DamageClass.Default to prevent damage type scaling of any kind for this projectile. Use DamageClass.Generic/Melee/Ranged/Magic/Summon/Throwing for vanilla damage types. Refer to ExampleMod for more information on how to create and use your own damage types.
 
int ArmorPenetration [get, set]
 The number of defense points that this projectile can ignore on its own. Cannot be set to negative values. Defaults to 0. On spawn, if this projectile was fired from a weapon, this value has the total armor penetration of the weapon that made the projectile added to itself.
 
int CritChance [get, set]
 The critical strike chance modifier of this projectile. Cannot be set to negative values. Defaults to 0. On spawn, if this projectile was fired from a weapon, this value has the total critical strike chance of the weapon that made the projectile added to itself.
 
int OriginalCritChance [get, set]
 The crit chance of this projectile, without any player bonuses, similar to F:Terraria.Projectile.originalDamage
Used by P:Terraria.Projectile.ContinuouslyUpdateDamageStats to recalculate P:Terraria.Projectile.CritChance in combination with M:Terraria.Player.GetTotalCritChance(Terraria.ModLoader.DamageClass)
 
int OriginalArmorPenetration [get, set]
 The crit chance of this projectile, without any player bonuses, similar to F:Terraria.Projectile.originalDamage
Used by P:Terraria.Projectile.ContinuouslyUpdateDamageStats to recalculate P:Terraria.Projectile.ArmorPenetration in combination with M:Terraria.Player.GetTotalArmorPenetration(Terraria.ModLoader.DamageClass)
 
bool ContinuouslyUpdateDamageStats [get, set]
 If set F:Terraria.Projectile.damage will be recalculated based on F:Terraria.Projectile.originalDamage, P:Terraria.Projectile.DamageType and the F:Terraria.Projectile.owner player, just like minions and sentries.
Similarly for P:Terraria.Projectile.CritChance and P:Terraria.Projectile.ArmorPenetration.
 
bool ContinuouslyUpdateDamage [get, set]
 
bool IsMinionOrSentryRelated [get]
 Checks if the projectile is a minion, sentry, minion shot, or sentry shot.

 
virtual Vector2 VisualPosition [get]
 
Vector2 Center [get, set]
 
Vector2 Left [get, set]
 
Vector2 Right [get, set]
 
Vector2 Top [get, set]
 
Vector2 TopLeft [get, set]
 
Vector2 TopRight [get, set]
 
Vector2 Bottom [get, set]
 
Vector2 BottomLeft [get, set]
 
Vector2 BottomRight [get, set]
 
Vector2 Size [get, set]
 
Rectangle Hitbox [get, set]
 

Private Member Functions

Rectangle Damage_GetHitbox ()
 
void BombsHurtPlayers (Rectangle projRectangle, int j)
 
int CountEnemiesWhoAreImmuneToMeRightNow (int cap)
 
void TryDoingOnHitEffects (Entity entity)
 
void SummonSuperStarSlash (Vector2 target)
 
void SummonMonkGhast ()
 
void CutTiles ()
 
void CutTilesAt (Vector2 boxPosition, int boxWidth, int boxHeight)
 
bool CanCutTiles ()
 
bool AutomaticallyChangesDirection ()
 
void UpdateEnchantmentVisuals ()
 
void HandleMovement (Vector2 wetVelocity, out int overrideWidth, out int overrideHeight)
 
void LightDisc_Bounce (Vector2 hitPoint, Vector2 normal)
 
void AI_149_GolfBall ()
 
void MakeBoulderOfEarthExplosion ()
 
void UpdatePosition (Vector2 wetVelocity)
 
void FishingCheck_RollEnemySpawns (ref FishingAttempt fisher)
 
void FishingCheck_RollItemDrop (ref FishingAttempt fisher)
 
void FishingCheck_ProbeForQuestFish (ref FishingAttempt fisher)
 
void FishingCheck_RollDropLevels (int fishingLevel, out bool common, out bool uncommon, out bool rare, out bool veryrare, out bool legendary, out bool crate)
 
void AI_151_SuperStar ()
 
void AI_152_SuperStarSlash ()
 
void Shimmer ()
 
void AI_195_JimsDrone ()
 
void AI_111_DryadsWard ()
 
void AI_194_HorsemanPumpkin ()
 
void AI_193_Flamethrower ()
 
void AI_047_MagnetSphere ()
 
void AI_047_MagnetSphere_TryAttacking ()
 
void AI_192_JuminoAnimation ()
 
void AI_191_TrueNightsEdge ()
 
void AI_190_NightsEdge ()
 
void AI_188_LightsBane ()
 
void AI_189_Volcano ()
 
void AI_066_TryInterceptingTarget (Vector2 targetDir, Vector2 targetVelocity, float speed)
 
void AI_187_ShadowHand ()
 
void AI_187_ShadowHand_GetVariation (out int variation, out float fakeCounter, out float counterMax)
 
void AI_185_LifeDrain ()
 
void AI_186_PrincessWeapon ()
 
void AI_184_BadTorchLuck ()
 
void AI_121_StardustDragon ()
 
Projectile FindStardustDragonHeadOfOwner ()
 
void AI_183_ZoologistStrike ()
 
void AI_182_FinalFractal ()
 
void AI_181_FairyQueenRangedItemShot ()
 
void AI_009_MagicMissiles ()
 
void AI_009_MagicMissiles_Old ()
 
void AI_015_HandleMovementCollision (ref Vector2 wetVelocity, ref Vector2 lastVelocity)
 
void AI_015_Flails ()
 
void AI_015_HandleMovementCollision_Old (ref Vector2 wetVelocity, ref Vector2 lastVelocity)
 
void AI_015_Flails_Old ()
 
void AI_015_Flails_Dust (bool doFastThrowDust)
 
void AI_100_Medusa ()
 
void AI_120_StardustGuardian ()
 
void AI_120_StardustGuardian_FindTarget (float lookupRange, ref int targetNPCIndex, ref float distanceToClosestTarget)
 
void AI_180_FairyQueenSunDance ()
 
void AI_179_FairyQueenLance ()
 
void AI_176_EdgyLightning ()
 
void AI_177_IceWhipSlicer ()
 
void AI_178_FireExplosion ()
 
void AI_175_TitaniumStormShards ()
 
void AI_174_MultisegmentPet ()
 
void AI_173_HallowBossRainbowTrail ()
 
void AI_171_HallowBossRainbowStreak ()
 
void AI_172_HallowBossRainbowPelletStorm ()
 
void AI_170_FairyGlowstick ()
 
void AI_169_Smolstars ()
 
void AI_019_Spears ()
 
void AI_019_Spears_Old ()
 
void AI_168_FirstFractal ()
 
void AI_167_SparkleGuitar ()
 
void AI_164_StormTigerGem ()
 
void AI_162_TigerPounce ()
 
void PrepareBombToBlow ()
 
void AI_016 ()
 
void AI_166_Dove ()
 
void AI_161_RapierStabs ()
 
void AI_165_Whip ()
 
void AI_160_Kites ()
 
void AI_159_PaperAirplanes ()
 
void AI_158_BabyBird ()
 
bool AI_067_CustomEliminationCheck_Pirates (Entity otherEntity, int currentTarget)
 
bool AI_067_TigerSpecialAttack ()
 
void AI_067_FreakingPirates ()
 
void AI_157_SharpTears ()
 
void AI_156_BatOfLight ()
 
void AI_156_Think (List< int > blacklist)
 
void AI_156_StartAttack ()
 
int AI_156_TryAttackingNPCs (List< int > blackListedTargets, bool skipBodyCheck=false)
 
void AI_GetMyGroupIndexAndFillBlackList (List< int > blackListedTargets, out int index, out int totalIndexesInGroup)
 
void AI_156_GetIdlePosition (int stackedIndex, int totalIndexes, out Vector2 idleSpot, out float idleRotation)
 
void AI_155_MysticSnakeCoil ()
 
void AI_155_RemoveRope (Point start, Point end)
 
void AI_155_SpawnRopeIn (int x, int y)
 
void AI_154_VoidLens ()
 
void AI_153_ToiletPop ()
 
void AI_150_GolfClubHelper ()
 
void AI_007_GrapplingHooks ()
 
bool AI_007_GrapplingHooks_CanTileBeLatchedOnTo (int x, int y)
 
void AI_147_Celeb2Rocket ()
 
void AI_148_StarSpawner ()
 
void AI_147_Explosion ()
 
void CreateGroundExplosion (float MAX_SPREAD, int fluff, int distFluff, int layerStart, int layerEnd, int layerJump)
 
void AI_163_Chum ()
 
void ReduceRemainingChumsInPool ()
 
void AI_061_FishingBobber ()
 
float AI_061_FishingBobber_GetWaterLine (int X, int Y)
 
void AI_061_FishingBobber_DoASplash ()
 
void AI_061_FishingBobber_GiveItemToPlayer (Player thePlayer, int itemType)
 
void AI_146_DD2Victory ()
 
void BetsySharpnel (int npcIndex)
 
void CopyLocalNPCImmunityTimes (Projectile p)
 
void AI_001 ()
 
void AI_010 ()
 
void AI_026 ()
 
bool Chester_IsAnyPlayerTrackingThisProjectile ()
 
void AI_062 ()
 
void AI_075 ()
 
void AI_099_1 ()
 
void AI_099_2 ()
 
void AI_130_FlameBurstTower ()
 
int AI_130_FlameBurstTower_FindTarget (float shot_range, float angleRatioMax, Vector2 shootingSpot, bool canChangeDirection=true)
 
int AI_134_Ballista_FindTarget (float shot_range, float deadBottomAngle, Vector2 shootingSpot)
 
void AI_131_FlameBurstShot ()
 
void AI_134_Ballista ()
 
void AI_135_OgreStomp ()
 
void AI_136_BetsyBreath ()
 
void AI_137_LightningAura ()
 
void AI_138_ExplosiveTrap ()
 
void AI_139_ExplosiveTrapExplosion ()
 
void AI_140_MonkStaffT1 ()
 
void AI_141_MonkStaffT1Explosion ()
 
void CreateImpactExplosion2_SleepyOctopod (Vector2 explosionOrigin, bool causedShockwaves)
 
void AI_142_MonkStaffT2And3 ()
 
void AI_143_MonkStaffT2Ghast ()
 
void AI_144_DD2Pet ()
 
void AI_145_BookStaffStorm ()
 
Point GetScarabBombDigDirectionSnap8 ()
 
void BoulderExplosion ()
 
void SpawnWebs ()
 
void DropGeodeGems ()
 
void TryGettingHitByOtherPlayersExplosives ()
 
void DoRainbowCrystalStaffExplosion ()
 

Static Private Member Functions

static void FindBannerToAssociateTo (IEntitySource spawnSource, Projectile next)
 
static void GetFishingPondState (int x, int y, out bool lava, out bool honey, out int numWaters, out int chumCount)
 
static void GetFishingPondWidth (int x, int y, out int minX, out int maxX)
 
static void VanillaWhipSettings (Projectile proj, out int segments, out float rangeMultiplier)
 

Private Attributes

string nameOverride
 
DamageClass _damageClass = DamageClass.Default
 
int _armorPenetration
 
int _crit
 

Static Private Attributes

static Conditions.IsSolid _cachedConditions_solid = new Conditions.IsSolid()
 
static Conditions.NotNull _cachedConditions_notNull = new Conditions.NotNull()
 
static Point[] _javelinsMax6 = (Point[])(object)new Point[6]
 
static Point[] _javelinsMax8 = (Point[])(object)new Point[8]
 
static Point[] _javelinsMax10 = (Point[])(object)new Point[10]
 
static Rectangle _lanceHitboxBounds = new Rectangle(0, 0, 300, 300)
 
static List< Tuple< int, float > > _medusaHeadTargetList = new List<Tuple<int, float>>()
 
static NPCDistanceByIndexComparator _medusaTargetComparer = new NPCDistanceByIndexComparator()
 
static List< int > _ai164_blacklistedTargets = new List<int>()
 
static List< int > _ai158_blacklistedTargets = new List<int>()
 
static List< int > _ai156_blacklistedTargets = new List<int>()
 
static float[] _CompanionCubeScreamCooldown = new float[255]
 

Detailed Description

Definition at line 33 of file Projectile.cs.


The documentation for this class was generated from the following file: