TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ AI_009_MagicMissiles()

void Terraria.Projectile.AI_009_MagicMissiles ( )
inlineprivate

Definition at line 44798 of file Projectile.cs.

44799 {
44800 //IL_02ef: Unknown result type (might be due to invalid IL or missing references)
44801 //IL_0189: Unknown result type (might be due to invalid IL or missing references)
44802 //IL_018e: Unknown result type (might be due to invalid IL or missing references)
44803 //IL_01a0: Unknown result type (might be due to invalid IL or missing references)
44804 //IL_03de: Unknown result type (might be due to invalid IL or missing references)
44805 //IL_03e3: Unknown result type (might be due to invalid IL or missing references)
44806 //IL_03e6: Unknown result type (might be due to invalid IL or missing references)
44807 //IL_025b: Unknown result type (might be due to invalid IL or missing references)
44808 //IL_0260: Unknown result type (might be due to invalid IL or missing references)
44809 //IL_0265: Unknown result type (might be due to invalid IL or missing references)
44810 //IL_026c: Unknown result type (might be due to invalid IL or missing references)
44811 //IL_0271: Unknown result type (might be due to invalid IL or missing references)
44812 //IL_0241: Unknown result type (might be due to invalid IL or missing references)
44813 //IL_0246: Unknown result type (might be due to invalid IL or missing references)
44814 //IL_024d: Unknown result type (might be due to invalid IL or missing references)
44815 //IL_0252: Unknown result type (might be due to invalid IL or missing references)
44816 //IL_01cb: Unknown result type (might be due to invalid IL or missing references)
44817 //IL_01da: Unknown result type (might be due to invalid IL or missing references)
44818 //IL_01b1: Unknown result type (might be due to invalid IL or missing references)
44819 //IL_04b9: Unknown result type (might be due to invalid IL or missing references)
44820 //IL_04c3: Unknown result type (might be due to invalid IL or missing references)
44821 //IL_04c8: Unknown result type (might be due to invalid IL or missing references)
44822 //IL_04cf: Unknown result type (might be due to invalid IL or missing references)
44823 //IL_04d4: Unknown result type (might be due to invalid IL or missing references)
44824 //IL_04d7: Unknown result type (might be due to invalid IL or missing references)
44825 //IL_04dc: Unknown result type (might be due to invalid IL or missing references)
44826 //IL_04e6: Unknown result type (might be due to invalid IL or missing references)
44827 //IL_04eb: Unknown result type (might be due to invalid IL or missing references)
44828 //IL_04f0: Unknown result type (might be due to invalid IL or missing references)
44829 //IL_03fa: Unknown result type (might be due to invalid IL or missing references)
44830 //IL_03fd: Unknown result type (might be due to invalid IL or missing references)
44831 //IL_0402: Unknown result type (might be due to invalid IL or missing references)
44832 //IL_0407: Unknown result type (might be due to invalid IL or missing references)
44833 //IL_0409: Unknown result type (might be due to invalid IL or missing references)
44834 //IL_040b: Unknown result type (might be due to invalid IL or missing references)
44835 //IL_0410: Unknown result type (might be due to invalid IL or missing references)
44836 //IL_0427: Unknown result type (might be due to invalid IL or missing references)
44837 //IL_042c: Unknown result type (might be due to invalid IL or missing references)
44838 //IL_0347: Unknown result type (might be due to invalid IL or missing references)
44839 //IL_0354: Unknown result type (might be due to invalid IL or missing references)
44840 //IL_058a: Unknown result type (might be due to invalid IL or missing references)
44841 //IL_058f: Unknown result type (might be due to invalid IL or missing references)
44842 //IL_048e: Unknown result type (might be due to invalid IL or missing references)
44843 //IL_0442: Unknown result type (might be due to invalid IL or missing references)
44844 //IL_0448: Unknown result type (might be due to invalid IL or missing references)
44845 //IL_044d: Unknown result type (might be due to invalid IL or missing references)
44846 //IL_0452: Unknown result type (might be due to invalid IL or missing references)
44847 //IL_0462: Unknown result type (might be due to invalid IL or missing references)
44848 //IL_0468: Unknown result type (might be due to invalid IL or missing references)
44849 //IL_046a: Unknown result type (might be due to invalid IL or missing references)
44850 //IL_046f: Unknown result type (might be due to invalid IL or missing references)
44851 //IL_0474: Unknown result type (might be due to invalid IL or missing references)
44852 //IL_047e: Unknown result type (might be due to invalid IL or missing references)
44853 //IL_0483: Unknown result type (might be due to invalid IL or missing references)
44854 //IL_0488: Unknown result type (might be due to invalid IL or missing references)
44855 //IL_05a3: Unknown result type (might be due to invalid IL or missing references)
44856 //IL_0542: Unknown result type (might be due to invalid IL or missing references)
44857 //IL_0548: Unknown result type (might be due to invalid IL or missing references)
44858 //IL_054d: Unknown result type (might be due to invalid IL or missing references)
44859 //IL_0552: Unknown result type (might be due to invalid IL or missing references)
44860 //IL_0559: Unknown result type (might be due to invalid IL or missing references)
44861 //IL_0563: Unknown result type (might be due to invalid IL or missing references)
44862 //IL_0568: Unknown result type (might be due to invalid IL or missing references)
44863 //IL_04a2: Unknown result type (might be due to invalid IL or missing references)
44864 //IL_04a7: Unknown result type (might be due to invalid IL or missing references)
44865 //IL_04ab: Unknown result type (might be due to invalid IL or missing references)
44866 //IL_04b0: Unknown result type (might be due to invalid IL or missing references)
44867 //IL_05ec: Unknown result type (might be due to invalid IL or missing references)
44868 //IL_05f1: Unknown result type (might be due to invalid IL or missing references)
44869 //IL_05f6: Unknown result type (might be due to invalid IL or missing references)
44870 //IL_05fc: Unknown result type (might be due to invalid IL or missing references)
44871 //IL_0601: Unknown result type (might be due to invalid IL or missing references)
44872 //IL_0606: Unknown result type (might be due to invalid IL or missing references)
44873 //IL_0865: Unknown result type (might be due to invalid IL or missing references)
44874 //IL_086a: Unknown result type (might be due to invalid IL or missing references)
44875 //IL_0871: Unknown result type (might be due to invalid IL or missing references)
44876 //IL_0876: Unknown result type (might be due to invalid IL or missing references)
44877 //IL_0889: Unknown result type (might be due to invalid IL or missing references)
44878 //IL_08b5: Unknown result type (might be due to invalid IL or missing references)
44879 //IL_08ca: Unknown result type (might be due to invalid IL or missing references)
44880 //IL_08d4: Unknown result type (might be due to invalid IL or missing references)
44881 //IL_08d9: Unknown result type (might be due to invalid IL or missing references)
44882 //IL_08e0: Unknown result type (might be due to invalid IL or missing references)
44883 //IL_08f4: Unknown result type (might be due to invalid IL or missing references)
44884 //IL_08f9: Unknown result type (might be due to invalid IL or missing references)
44885 //IL_08fe: Unknown result type (might be due to invalid IL or missing references)
44886 //IL_0904: Unknown result type (might be due to invalid IL or missing references)
44887 //IL_090a: Unknown result type (might be due to invalid IL or missing references)
44888 //IL_0914: Unknown result type (might be due to invalid IL or missing references)
44889 //IL_0919: Unknown result type (might be due to invalid IL or missing references)
44890 //IL_091e: Unknown result type (might be due to invalid IL or missing references)
44891 //IL_068a: Unknown result type (might be due to invalid IL or missing references)
44892 //IL_06ab: Unknown result type (might be due to invalid IL or missing references)
44893 //IL_06b1: Unknown result type (might be due to invalid IL or missing references)
44894 //IL_06c8: Unknown result type (might be due to invalid IL or missing references)
44895 //IL_06d2: Unknown result type (might be due to invalid IL or missing references)
44896 //IL_06d7: Unknown result type (might be due to invalid IL or missing references)
44897 //IL_0765: Unknown result type (might be due to invalid IL or missing references)
44898 //IL_0779: Unknown result type (might be due to invalid IL or missing references)
44899 //IL_077e: Unknown result type (might be due to invalid IL or missing references)
44900 //IL_0783: Unknown result type (might be due to invalid IL or missing references)
44901 //IL_0667: Unknown result type (might be due to invalid IL or missing references)
44902 //IL_0932: Unknown result type (might be due to invalid IL or missing references)
44903 //IL_095e: Unknown result type (might be due to invalid IL or missing references)
44904 //IL_096c: Unknown result type (might be due to invalid IL or missing references)
44905 //IL_0980: Unknown result type (might be due to invalid IL or missing references)
44906 //IL_0985: Unknown result type (might be due to invalid IL or missing references)
44907 //IL_098a: Unknown result type (might be due to invalid IL or missing references)
44908 //IL_0990: Unknown result type (might be due to invalid IL or missing references)
44909 //IL_0996: Unknown result type (might be due to invalid IL or missing references)
44910 //IL_09a0: Unknown result type (might be due to invalid IL or missing references)
44911 //IL_09a5: Unknown result type (might be due to invalid IL or missing references)
44912 //IL_09aa: Unknown result type (might be due to invalid IL or missing references)
44913 //IL_07a6: Unknown result type (might be due to invalid IL or missing references)
44914 //IL_07c7: Unknown result type (might be due to invalid IL or missing references)
44915 //IL_07cd: Unknown result type (might be due to invalid IL or missing references)
44916 //IL_07db: Unknown result type (might be due to invalid IL or missing references)
44917 //IL_07e5: Unknown result type (might be due to invalid IL or missing references)
44918 //IL_07ea: Unknown result type (might be due to invalid IL or missing references)
44919 //IL_07f1: Unknown result type (might be due to invalid IL or missing references)
44920 //IL_07f6: Unknown result type (might be due to invalid IL or missing references)
44921 //IL_0804: Unknown result type (might be due to invalid IL or missing references)
44922 //IL_0818: Unknown result type (might be due to invalid IL or missing references)
44923 //IL_081d: Unknown result type (might be due to invalid IL or missing references)
44924 //IL_0822: Unknown result type (might be due to invalid IL or missing references)
44925 //IL_09d7: Unknown result type (might be due to invalid IL or missing references)
44926 //IL_09f5: Unknown result type (might be due to invalid IL or missing references)
44927 //IL_0a06: Unknown result type (might be due to invalid IL or missing references)
44928 //IL_0a10: Unknown result type (might be due to invalid IL or missing references)
44929 //IL_0a15: Unknown result type (might be due to invalid IL or missing references)
44930 //IL_0a1d: Unknown result type (might be due to invalid IL or missing references)
44931 //IL_0a22: Unknown result type (might be due to invalid IL or missing references)
44932 //IL_0a32: Unknown result type (might be due to invalid IL or missing references)
44933 //IL_0a46: Unknown result type (might be due to invalid IL or missing references)
44934 //IL_0a4b: Unknown result type (might be due to invalid IL or missing references)
44935 //IL_0a50: Unknown result type (might be due to invalid IL or missing references)
44936 //IL_0a64: Unknown result type (might be due to invalid IL or missing references)
44937 //IL_0a6b: Unknown result type (might be due to invalid IL or missing references)
44938 //IL_0a71: Unknown result type (might be due to invalid IL or missing references)
44939 //IL_0a76: Unknown result type (might be due to invalid IL or missing references)
44940 //IL_0a7d: Unknown result type (might be due to invalid IL or missing references)
44941 //IL_0a87: Unknown result type (might be due to invalid IL or missing references)
44942 //IL_0a8c: Unknown result type (might be due to invalid IL or missing references)
44943 //IL_0a91: Unknown result type (might be due to invalid IL or missing references)
44944 if (type == 491)
44945 {
44947 return;
44948 }
44949 int num = 32;
44950 Player player = Main.player[owner];
44951 int num4 = Main.maxTilesY * 16;
44952 int num5 = 0;
44953 if (ai[0] >= 0f)
44954 {
44955 num5 = (int)(ai[1] / (float)num4);
44956 }
44957 bool flag = ai[0] == -1f || ai[0] == -2f;
44958 if (type == 34)
44959 {
44960 if (frameCounter++ >= 4)
44961 {
44962 frameCounter = 0;
44963 if (++frame >= Main.projFrames[type])
44964 {
44965 frame = 0;
44966 }
44967 }
44968 if (penetrate == 1 && ai[0] >= 0f && num5 == 0)
44969 {
44970 ai[1] += num4;
44971 num5 = 1;
44972 netUpdate = true;
44973 }
44974 if (penetrate == 1 && ai[0] == -1f)
44975 {
44976 ai[0] = -2f;
44977 netUpdate = true;
44978 }
44979 if (num5 > 0 || ai[0] == -2f)
44980 {
44981 localAI[0] += 1f;
44982 }
44983 }
44984 if (owner == Main.myPlayer)
44985 {
44986 if (ai[0] >= 0f)
44987 {
44988 if (player.channel && player.HeldItem.shoot == type)
44989 {
44990 Vector2 pointPoisition = Main.MouseWorld;
44991 player.LimitPointToPlayerReachableArea(ref pointPoisition);
44992 if (ai[0] != pointPoisition.X || ai[1] != pointPoisition.Y)
44993 {
44994 netUpdate = true;
44995 ai[0] = pointPoisition.X;
44996 ai[1] = pointPoisition.Y + (float)(num4 * num5);
44997 }
44998 }
44999 else
45000 {
45001 netUpdate = true;
45002 ai[0] = -1f;
45003 ai[1] = -1f;
45005 if (num6 != -1)
45006 {
45007 ai[1] = num6;
45008 }
45009 else if (((Vector2)(ref velocity)).Length() < 2f)
45010 {
45011 velocity = DirectionFrom(player.Center) * (float)num;
45012 }
45013 else
45014 {
45015 velocity = velocity.SafeNormalize(Vector2.Zero) * (float)num;
45016 }
45017 }
45018 }
45019 if (flag && ai[1] == -1f)
45020 {
45022 if (num7 != -1)
45023 {
45024 ai[1] = num7;
45025 netUpdate = true;
45026 }
45027 }
45028 }
45029 Vector2? vector = null;
45030 float amount = 1f;
45031 if (ai[0] > 0f && ai[1] > 0f)
45032 {
45033 vector = new Vector2(ai[0], ai[1] % (float)num4);
45034 }
45035 if (flag && ai[1] >= 0f)
45036 {
45037 int num8 = (int)ai[1];
45038 if (Main.npc.IndexInRange(num8))
45039 {
45040 NPC nPC = Main.npc[num8];
45041 if (nPC.CanBeChasedBy(this))
45042 {
45043 vector = nPC.Center;
45044 float t = Distance(vector.Value);
45045 float num9 = Utils.GetLerpValue(0f, 100f, t, clamped: true) * Utils.GetLerpValue(600f, 400f, t, clamped: true);
45046 amount = MathHelper.Lerp(0f, 0.2f, Utils.GetLerpValue(200f, 20f, 1f - num9, clamped: true));
45047 }
45048 else
45049 {
45050 ai[1] = -1f;
45051 netUpdate = true;
45052 }
45053 }
45054 }
45055 bool flag2 = false;
45056 if (flag)
45057 {
45058 flag2 = true;
45059 }
45060 if (vector.HasValue)
45061 {
45062 Vector2 value = vector.Value;
45063 if (Distance(value) >= 64f)
45064 {
45065 flag2 = true;
45066 Vector2 v = value - base.Center;
45067 Vector2 val = v.SafeNormalize(Vector2.Zero);
45068 float num10 = Math.Min(num, ((Vector2)(ref v)).Length());
45069 Vector2 value2 = val * num10;
45070 if (((Vector2)(ref velocity)).Length() < 4f)
45071 {
45072 velocity += velocity.SafeNormalize(Vector2.Zero).RotatedBy(0.7853981852531433).SafeNormalize(Vector2.Zero) * 4f;
45073 }
45074 if (velocity.HasNaNs())
45075 {
45076 Kill();
45077 }
45078 velocity = Vector2.Lerp(velocity, value2, amount);
45079 }
45080 else
45081 {
45082 velocity *= 0.3f;
45083 velocity += (value - base.Center) * 0.3f;
45084 flag2 = ((Vector2)(ref velocity)).Length() >= 2f;
45085 }
45086 if (timeLeft < 60)
45087 {
45088 timeLeft = 60;
45089 }
45090 }
45091 if (flag && ai[1] < 0f)
45092 {
45093 if (((Vector2)(ref velocity)).Length() != (float)num)
45094 {
45095 velocity = velocity.MoveTowards(velocity.SafeNormalize(Vector2.UnitY) * (float)num, 4f);
45096 }
45097 if (timeLeft > 300)
45098 {
45099 timeLeft = 300;
45100 }
45101 }
45102 if (flag2 && velocity != Vector2.Zero)
45103 {
45104 rotation = rotation.AngleTowards(velocity.ToRotation(), (float)Math.PI / 4f);
45105 }
45106 else
45107 {
45108 rotation = rotation.AngleLerp(0f, 0.2f);
45109 }
45110 bool flag3 = ((Vector2)(ref velocity)).Length() > 0.1f && Vector2.Dot(oldVelocity.SafeNormalize(Vector2.Zero), velocity.SafeNormalize(Vector2.Zero)) < 0.2f;
45111 if (type == 16)
45112 {
45113 if (soundDelay == 0 && Math.Abs(velocity.X) + Math.Abs(velocity.Y) > 2f)
45114 {
45115 soundDelay = 10;
45117 }
45118 if (Main.rand.Next(9) == 0)
45119 {
45120 int num11 = Dust.NewDust(position, width, height, 15, 0f, 0f, 100, default(Color), 2f);
45121 Dust obj = Main.dust[num11];
45122 obj.velocity *= 0.3f;
45123 Main.dust[num11].position.X = position.X + (float)(width / 2) + 4f + (float)Main.rand.Next(-4, 5);
45124 Main.dust[num11].position.Y = position.Y + (float)(height / 2) + (float)Main.rand.Next(-4, 5);
45125 Main.dust[num11].noGravity = true;
45126 Dust obj2 = Main.dust[num11];
45127 obj2.velocity += Main.rand.NextVector2Circular(2f, 2f);
45128 }
45129 if (flag3)
45130 {
45131 int num2 = Main.rand.Next(2, 5);
45132 for (int i = 0; i < num2; i++)
45133 {
45134 Dust dust5 = Dust.NewDustDirect(position, width, height, 15, 0f, 0f, 100, default(Color), 1.5f);
45135 dust5.velocity *= 0.3f;
45136 dust5.position = base.Center;
45137 dust5.noGravity = true;
45138 dust5.velocity += Main.rand.NextVector2Circular(0.5f, 0.5f);
45139 dust5.fadeIn = 2.2f;
45140 }
45141 }
45142 }
45143 if (type != 34)
45144 {
45145 return;
45146 }
45147 float lerpValue = Utils.GetLerpValue(0f, 10f, localAI[0], clamped: true);
45148 Color newColor = Color.Lerp(Color.Transparent, Color.Crimson, lerpValue);
45149 if (Main.rand.Next(6) == 0)
45150 {
45151 Dust dust6 = Dust.NewDustDirect(base.Center, 0, 0, 6, velocity.X * 0.2f, velocity.Y * 0.2f, 100, newColor, 3.5f);
45152 dust6.noGravity = true;
45153 dust6.velocity *= 1.4f;
45154 dust6.velocity += Main.rand.NextVector2Circular(1f, 1f);
45155 dust6.velocity += velocity * 0.15f;
45156 }
45157 if (Main.rand.Next(12) == 0)
45158 {
45159 Dust dust7 = Dust.NewDustDirect(base.Center, 0, 0, 6, velocity.X * 0.2f, velocity.Y * 0.2f, 100, newColor, 1.5f);
45160 dust7.velocity += Main.rand.NextVector2Circular(1f, 1f);
45161 dust7.velocity += velocity * 0.15f;
45162 }
45163 if (flag3)
45164 {
45165 int num3 = Main.rand.Next(2, 5 + (int)(lerpValue * 4f));
45166 for (int j = 0; j < num3; j++)
45167 {
45168 Dust dust4 = Dust.NewDustDirect(position, width, height, 6, 0f, 0f, 100, newColor, 1.5f);
45169 dust4.velocity *= 0.3f;
45170 dust4.position = base.Center;
45171 dust4.noGravity = true;
45172 dust4.velocity += Main.rand.NextVector2Circular(0.5f, 0.5f);
45173 dust4.fadeIn = 2.2f;
45174 dust4.position += (dust4.position - base.Center) * lerpValue * 10f;
45175 }
45176 }
45177 }
static SlotId PlaySound(in SoundStyle? style, Vector2? position=null, SoundUpdateCallback? updateCallback=null)
Attempts to play a sound style with the provided sound style (if it's not null), and returns a valid ...
Vector2 DirectionFrom(Vector2 Source)
Definition Entity.cs:298
Vector2 velocity
The velocity of this Entity in world coordinates per tick.
Definition Entity.cs:33
float Distance(Vector2 Other)
Definition Entity.cs:275
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
Vector2 oldVelocity
Definition Entity.cs:37
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
static readonly SoundStyle Item9
Definition SoundID.cs:695
int owner
The index of the player who owns this projectile. In Multiplayer, Clients "own" projectiles that they...
void AI_009_MagicMissiles_Old()
float[] ai
An array with 3 slots used for any sort of data storage, which is occasionally synced to the server....
bool netUpdate
Set manually to true in M:Terraria.ModLoader.ModProjectile.AI once to make it sync its current F:Terr...
int penetrate
The remaining number of npc can this projectile hit before dying. (Or tile bounces)....
float[] localAI
Acts like F:Terraria.Projectile.ai, but does not sync to the server. Many vanilla T:Terraria....
int FindTargetWithLineOfSight(float maxRange=800f)
Finds the closest NPC to this projectile which can be targeted and which it has line of sight to.
int frame
The frame number in the spritesheet that this projectile will be drawn with. Assign in M:Terraria....
int type
The Projectile ID of this projectile. The Projectile ID is a unique number assigned to each Projectil...
int timeLeft
Time in ticks before this projectile will naturally despawn. Each update timeLeft is decreased by 1...
float rotation
Rotation of the projectile. Radians not Degrees. Use T:Microsoft.Xna.Framework.MathHelper if you want...
int frameCounter
Used as a timer to decide when to change F:Terraria.Projectile.frame. Defaults to 0.

References Terraria.Entity.Center, Terraria.Player.channel, Terraria.Main.dust, Terraria.Utils.GetLerpValue(), Terraria.Player.HeldItem, Terraria.ID.SoundID.Item9, Terraria.Player.LimitPointToPlayerReachableArea(), Terraria.Main.MouseWorld, Terraria.Main.myPlayer, Terraria.Dust.NewDust(), Terraria.Dust.NewDustDirect(), Terraria.Main.npc, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Main.projFrames, Terraria.Main.rand, and Terraria.Item.shoot.

+ Here is the call graph for this function: