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

◆ AI_010()

void Terraria.Projectile.AI_010 ( )
inlineprivate

Definition at line 47786 of file Projectile.cs.

47787 {
47788 if (type == 31 && ai[0] != 2f)
47789 {
47790 if (Main.rand.Next(2) == 0)
47791 {
47792 int num = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 32, 0f, velocity.Y / 2f);
47793 Main.dust[num].velocity.X *= 0.4f;
47794 }
47795 }
47796 else if (type == 39)
47797 {
47798 if (Main.rand.Next(2) == 0)
47799 {
47800 int num2 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 38, 0f, velocity.Y / 2f);
47801 Main.dust[num2].velocity.X *= 0.4f;
47802 }
47803 }
47804 else if (type >= 411 && type <= 414)
47805 {
47806 if (Main.rand.Next(3) == 0)
47807 {
47808 int num3 = 9;
47809 if (type == 412 || type == 414)
47810 {
47811 num3 = 11;
47812 }
47813 if (type == 413)
47814 {
47815 num3 = 19;
47816 }
47817 int num4 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, num3, 0f, velocity.Y / 2f);
47818 Main.dust[num4].noGravity = true;
47819 Main.dust[num4].velocity -= velocity * 0.5f;
47820 }
47821 }
47822 else if (type == 40)
47823 {
47824 if (Main.rand.Next(2) == 0)
47825 {
47826 int num5 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 36, 0f, velocity.Y / 2f);
47827 Main.dust[num5].velocity *= 0.4f;
47828 }
47829 }
47830 else if (type == 42 || type == 31)
47831 {
47832 if (Main.rand.Next(2) == 0)
47833 {
47834 int num6 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 32);
47835 Main.dust[num6].velocity.X *= 0.4f;
47836 }
47837 }
47838 else if (type == 56 || type == 65)
47839 {
47840 if (Main.rand.Next(2) == 0)
47841 {
47842 int num7 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 14);
47843 Main.dust[num7].velocity.X *= 0.4f;
47844 }
47845 }
47846 else if (type == 67 || type == 68)
47847 {
47848 if (Main.rand.Next(2) == 0)
47849 {
47850 int num8 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 51);
47851 Main.dust[num8].velocity.X *= 0.4f;
47852 }
47853 }
47854 else if (type == 71)
47855 {
47856 if (Main.rand.Next(2) == 0)
47857 {
47858 int num9 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 53);
47859 Main.dust[num9].velocity.X *= 0.4f;
47860 }
47861 }
47862 else if (type == 179)
47863 {
47864 if (Main.rand.Next(2) == 0)
47865 {
47866 int num10 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 149);
47867 Main.dust[num10].velocity.X *= 0.4f;
47868 }
47869 }
47870 else if (type == 241 || type == 354)
47871 {
47872 if (Main.rand.Next(2) == 0)
47873 {
47874 int num11 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 36);
47875 Main.dust[num11].velocity.X *= 0.4f;
47876 }
47877 }
47878 else if (type >= 736 && type <= 738)
47879 {
47880 if (Main.rand.Next(40) == 0)
47881 {
47882 int num12 = Dust.NewDust(position, width, height, type - 736 + 275);
47883 if (num12 >= 0)
47884 {
47885 Main.dust[num12].velocity = Main.dust[num12].velocity * 0.5f + velocity * 0.5f;
47886 }
47887 }
47888 }
47889 else if (type != 109 && Main.rand.Next(20) == 0)
47890 {
47891 Dust.NewDust(new Vector2(position.X, position.Y), width, height, 0);
47892 }
47893 if (type >= 736 && type <= 738)
47894 {
47895 if (localAI[0] == 0f)
47896 {
47897 frame = Main.rand.Next(3);
47898 scale = 1f - (float)Main.rand.Next(30) * 0.01f;
47899 }
47900 localAI[0] += 1f;
47901 }
47902 tileCollide = true;
47903 localAI[1] = 0f;
47904 if (Main.myPlayer == owner && ai[0] == 0f)
47905 {
47906 tileCollide = false;
47907 if (Main.player[owner].channel && (type < 736 || type > 738) && type != 40)
47908 {
47909 localAI[1] = -1f;
47910 float num13 = 12f;
47911 Vector2 vector = new Vector2(position.X + (float)width * 0.5f, position.Y + (float)height * 0.5f);
47912 float num14 = (float)Main.mouseX + Main.screenPosition.X - vector.X;
47913 float num15 = (float)Main.mouseY + Main.screenPosition.Y - vector.Y;
47914 if (Main.player[owner].gravDir == -1f)
47915 {
47916 num15 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector.Y;
47917 }
47918 float num16 = (float)Math.Sqrt(num14 * num14 + num15 * num15);
47919 num16 = (float)Math.Sqrt(num14 * num14 + num15 * num15);
47920 if (num16 > num13)
47921 {
47922 num16 = num13 / num16;
47923 num14 *= num16;
47924 num15 *= num16;
47925 if (num14 != velocity.X || num15 != velocity.Y)
47926 {
47927 netUpdate = true;
47928 }
47929 velocity.X = num14;
47930 velocity.Y = num15;
47931 }
47932 else
47933 {
47934 if (num14 != velocity.X || num15 != velocity.Y)
47935 {
47936 netUpdate = true;
47937 }
47938 velocity.X = num14;
47939 velocity.Y = num15;
47940 }
47941 }
47942 else
47943 {
47944 ai[0] = 1f;
47945 netUpdate = true;
47946 }
47947 }
47948 if (ai[0] == 1f && type != 109)
47949 {
47950 if (type == 42 || type == 65 || type == 68 || type == 354)
47951 {
47952 ai[1] += 1f;
47953 if (ai[1] >= 60f)
47954 {
47955 ai[1] = 60f;
47956 velocity.Y += 0.2f;
47957 }
47958 }
47959 else
47960 {
47961 velocity.Y += 0.41f;
47962 }
47963 }
47964 else if (ai[0] == 2f && type != 109)
47965 {
47966 velocity.Y += 0.2f;
47967 if ((double)velocity.X < -0.04)
47968 {
47969 velocity.X += 0.04f;
47970 }
47971 else if ((double)velocity.X > 0.04)
47972 {
47973 velocity.X -= 0.04f;
47974 }
47975 else
47976 {
47977 velocity.X = 0f;
47978 }
47979 }
47980 if (owner == Main.myPlayer && tileCollide)
47981 {
47982 for (int i = (int)(position.X / 16f); i <= (int)((position.X + (float)width) / 16f); i++)
47983 {
47984 for (int j = (int)(position.Y / 16f); j <= (int)((position.Y + (float)height) / 16f); j++)
47985 {
47986 if (!WorldGen.InWorld(i, j))
47987 {
47988 continue;
47989 }
47990 Tile tile = Main.tile[i, j];
47991 if (tile == null || !tile.active())
47992 {
47993 continue;
47994 }
47995 if ((tile.type >= 185 && tile.type <= 187) || tile.type == 165 || tile.type == 12 || tile.type == 665 || tile.type == 639 || tile.type == 105 || tile.type == 178)
47996 {
47997 WorldGen.KillTile(i, j);
47998 }
47999 else if (tile.topSlope() && !TileID.Sets.Platforms[tile.type])
48000 {
48001 WorldGen.SlopeTile(i, j);
48002 if (Main.netMode != 0)
48003 {
48004 NetMessage.SendData(17, -1, -1, null, 14, i, j);
48005 }
48006 position.Y -= 16f;
48007 }
48008 }
48009 }
48010 }
48011 if (type >= 736 && type <= 738)
48012 {
48013 if (frame == 0)
48014 {
48015 rotation -= 0.1f;
48016 }
48017 else if (frame == 1)
48018 {
48019 rotation += 0.1f;
48020 }
48021 else
48022 {
48023 rotation += 0.15f;
48024 }
48025 if (velocity.Y > 10f)
48026 {
48027 velocity.Y = 10f;
48028 }
48029 }
48030 else
48031 {
48032 rotation += 0.1f;
48033 if (velocity.Y > 10f)
48034 {
48035 velocity.Y = 10f;
48036 }
48037 }
48038 }
static double Sqrt(double d)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
static bool[] Platforms
Definition TileID.cs:163

References Terraria.Tile.active(), Terraria.Main.dust, Terraria.WorldGen.InWorld(), Terraria.WorldGen.KillTile(), Terraria.Main.mouseX, Terraria.Main.mouseY, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Dust.NewDust(), Terraria.ID.TileID.Sets.Platforms, Terraria.Main.player, Terraria.Main.rand, Terraria.Main.screenHeight, Terraria.Main.screenPosition, Terraria.NetMessage.SendData(), Terraria.WorldGen.SlopeTile(), System.Math.Sqrt(), Terraria.Main.tile, Terraria.Tile.topSlope(), System.type, Terraria.Tile.type, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.