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

◆ AI_160_Kites()

void Terraria.Projectile.AI_160_Kites ( )
inlineprivate

Definition at line 39792 of file Projectile.cs.

39793 {
39794 Player player = Main.player[owner];
39795 Vector2 vector = player.RotatedRelativePoint(player.MountedCenter);
39796 timeLeft = 60;
39797 bool flag = false;
39798 if (player.CCed || player.noItems)
39799 {
39800 flag = true;
39801 }
39802 else if (player.inventory[player.selectedItem].shoot != type)
39803 {
39804 flag = true;
39805 }
39806 else if (player.pulley)
39807 {
39808 flag = true;
39809 }
39810 else if (player.dead)
39811 {
39812 flag = true;
39813 }
39814 if (!flag)
39815 {
39816 flag = (player.Center - base.Center).Length() > 2000f;
39817 }
39818 if (flag)
39819 {
39820 Kill();
39821 return;
39822 }
39823 float num = 4f;
39824 float num2 = 500f;
39825 float num3 = num2 / 2f;
39826 if (owner == Main.myPlayer && extraUpdates == 0)
39827 {
39828 float num4 = ai[0];
39829 if (ai[0] == 0f)
39830 {
39831 ai[0] = num3;
39832 }
39833 float num5 = ai[0];
39834 if (Main.mouseRight)
39835 {
39836 num5 -= 5f;
39837 }
39838 if (Main.mouseLeft)
39839 {
39840 num5 += 5f;
39841 }
39842 ai[0] = MathHelper.Clamp(num5, num, num2);
39843 if (num4 != num5)
39844 {
39845 netUpdate = true;
39846 }
39847 }
39848 if (numUpdates == 1)
39849 {
39850 extraUpdates = 0;
39851 }
39852 int num6 = 0;
39853 float cloudAlpha = Main.cloudAlpha;
39854 float num7 = 0f;
39855 if (WorldGen.InAPlaceWithWind(position, width, height))
39856 {
39857 num7 = Main.WindForVisuals;
39858 }
39859 float num8 = Utils.GetLerpValue(0.2f, 0.5f, Math.Abs(num7), clamped: true) * 0.5f;
39860 switch (num6)
39861 {
39862 case 0:
39863 {
39864 Vector2 mouseWorld = Main.MouseWorld;
39865 mouseWorld = base.Center;
39866 mouseWorld += new Vector2(num7, (float)Math.Sin(Main.GlobalTimeWrappedHourly) + cloudAlpha * 5f) * 25f;
39867 Vector2 v = mouseWorld - base.Center;
39868 v = v.SafeNormalize(Vector2.Zero) * (3f + cloudAlpha * 7f);
39869 if (num8 == 0f)
39870 {
39871 v = velocity;
39872 }
39873 float num9 = Distance(mouseWorld);
39874 float lerpValue = Utils.GetLerpValue(5f, 10f, num9, clamped: true);
39875 float y = velocity.Y;
39876 if (num9 > 10f)
39877 {
39878 velocity = Vector2.Lerp(velocity, v, 0.075f * lerpValue);
39879 }
39880 velocity.Y = y;
39881 velocity.Y -= num8;
39882 velocity.Y += 0.02f + num8 * 0.25f;
39883 velocity.Y = MathHelper.Clamp(velocity.Y, -2f, 2f);
39884 if (base.Center.Y + velocity.Y < mouseWorld.Y)
39885 {
39886 velocity.Y = MathHelper.Lerp(velocity.Y, velocity.Y + num8 + 0.01f, 0.75f);
39887 }
39888 velocity.X *= 0.98f;
39889 float num10 = Distance(vector);
39890 float num11 = ai[0];
39891 if (num10 > num11)
39892 {
39894 float num12 = num10 - num11;
39895 base.Center += vector3 * num12;
39896 bool num13 = Vector2.Dot(vector3, Vector2.UnitY) < 0.8f || num8 > 0f;
39897 velocity.Y += vector3.Y * 0.05f;
39898 if (num13)
39899 {
39900 velocity.Y -= 0.15f;
39901 }
39902 velocity.X += vector3.X * 0.2f;
39903 if (num11 == num && owner == Main.myPlayer)
39904 {
39905 Kill();
39906 return;
39907 }
39908 }
39909 break;
39910 }
39911 case 1:
39912 {
39914 velocity = Vector2.Lerp(velocity, vector2 * 16f, 1f);
39915 if (Distance(vector) < 10f && owner == Main.myPlayer)
39916 {
39917 Kill();
39918 return;
39919 }
39920 break;
39921 }
39922 }
39923 timeLeft = 2;
39924 Vector2 vector4 = base.Center - vector;
39925 int dir = ((vector4.X > 0f) ? 1 : (-1));
39926 if (Math.Abs(vector4.X) > Math.Abs(vector4.Y) / 2f)
39927 {
39928 player.ChangeDir(dir);
39929 }
39930 Vector2 vector5 = DirectionTo(vector).SafeNormalize(Vector2.Zero);
39931 if (num8 == 0f && velocity.Y > -0.02f)
39932 {
39933 rotation *= 0.95f;
39934 }
39935 else
39936 {
39937 float num14 = (-vector5).ToRotation() + (float)Math.PI / 4f;
39938 if (spriteDirection == -1)
39939 {
39940 num14 -= (float)Math.PI / 2f * (float)player.direction;
39941 }
39942 rotation = num14 + velocity.X * 0.05f;
39943 }
39944 float num15 = velocity.Length();
39945 switch (type)
39946 {
39947 case 771:
39948 case 822:
39949 case 823:
39950 case 827:
39951 case 830:
39952 case 838:
39953 case 843:
39954 case 844:
39955 case 845:
39956 case 846:
39957 case 850:
39958 case 852:
39959 frame = 0;
39960 break;
39961 case 828:
39962 case 829:
39963 if (num15 < 6f)
39964 {
39965 frame = 1;
39966 }
39967 else
39968 {
39969 frame = 0;
39970 }
39971 break;
39972 case 826:
39973 frame = (int)ai[1];
39974 break;
39975 case 824:
39976 case 839:
39977 case 840:
39978 case 853:
39979 if (num8 < 0.15f)
39980 {
39981 frame = 0;
39982 break;
39983 }
39984 frameCounter++;
39985 if ((float)frameCounter > (1f - num8) * 10f)
39986 {
39987 frameCounter = 0;
39988 frame = Main.rand.Next(4);
39989 }
39990 break;
39991 default:
39992 if (num15 < 3f)
39993 {
39994 frame = 0;
39995 }
39996 else if (num15 < 5f)
39997 {
39998 frame = 1;
39999 }
40000 else if (num15 < 7f)
40001 {
40002 frame = 2;
40003 }
40004 else
40005 {
40006 frame = 3;
40007 }
40008 break;
40009 }
40010 spriteDirection = player.direction;
40011 }
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
static double Abs(double value)
static double Sin(double a)
const double PI
Definition Math.cs:16
Vector2 velocity
Definition Entity.cs:16
float Distance(Vector2 Other)
Definition Entity.cs:187
Vector2 position
Definition Entity.cs:14
Vector2 DirectionTo(Vector2 Destination)
Definition Entity.cs:197
static float Dot(Vector2 value1, Vector2 value2)
Definition Vector2.cs:121
static Vector2 Lerp(Vector2 value1, Vector2 value2, float amount)
Definition Vector2.cs:227

References System.Math.Abs(), Terraria.Player.CCed, Terraria.Player.ChangeDir(), Microsoft.Xna.Framework.MathHelper.Clamp(), Terraria.Main.cloudAlpha, Terraria.Player.dead, Terraria.Entity.direction, Microsoft.Xna.Framework.Vector2.Dot(), Terraria.Utils.GetLerpValue(), Terraria.Main.GlobalTimeWrappedHourly, Terraria.WorldGen.InAPlaceWithWind(), Terraria.Player.inventory, Microsoft.Xna.Framework.MathHelper.Lerp(), Microsoft.Xna.Framework.Vector2.Lerp(), Terraria.Player.MountedCenter, Terraria.Main.mouseLeft, Terraria.Main.mouseRight, Terraria.Main.MouseWorld, Terraria.Main.myPlayer, Terraria.Player.noItems, System.Math.PI, Terraria.Main.player, Terraria.Player.pulley, Terraria.Main.rand, Terraria.Player.RotatedRelativePoint(), Terraria.Player.selectedItem, Terraria.Item.shoot, System.Math.Sin(), System.type, Microsoft.Xna.Framework.Vector2.UnitY, Terraria.Main.WindForVisuals, and Microsoft.Xna.Framework.Vector2.Zero.