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

◆ AI_099_1()

void Terraria.Projectile.AI_099_1 ( )
inlineprivate

Definition at line 56861 of file Projectile.cs.

56862 {
56863 timeLeft = 6;
56864 bool flag = true;
56865 float num = 250f;
56866 float num2 = 0.1f;
56867 float num3 = 15f;
56868 float num4 = 12f;
56869 num *= 0.5f;
56870 num3 *= 0.8f;
56871 num4 *= 1.5f;
56872 if (owner == Main.myPlayer)
56873 {
56874 bool flag2 = false;
56875 for (int i = 0; i < 1000; i++)
56876 {
56877 if (Main.projectile[i].active && Main.projectile[i].owner == owner && Main.projectile[i].aiStyle == 99 && (Main.projectile[i].type < 556 || Main.projectile[i].type > 561))
56878 {
56879 flag2 = true;
56880 }
56881 }
56882 if (!flag2)
56883 {
56884 ai[0] = -1f;
56885 netUpdate = true;
56886 }
56887 }
56888 if (Main.player[owner].yoyoString)
56889 {
56890 num += num * 0.25f + 10f;
56891 }
56892 rotation += 0.5f;
56893 if (Main.player[owner].dead)
56894 {
56895 Kill();
56896 return;
56897 }
56898 if (!flag)
56899 {
56900 Main.player[owner].heldProj = whoAmI;
56901 Main.player[owner].SetDummyItemTime(2);
56902 if (position.X + (float)(width / 2) > Main.player[owner].position.X + (float)(Main.player[owner].width / 2))
56903 {
56904 Main.player[owner].ChangeDir(1);
56905 direction = 1;
56906 }
56907 else
56908 {
56909 Main.player[owner].ChangeDir(-1);
56910 direction = -1;
56911 }
56912 }
56913 if (ai[0] == 0f || ai[0] == 1f)
56914 {
56915 if (ai[0] == 1f)
56916 {
56917 num *= 0.75f;
56918 }
56919 num4 *= 0.5f;
56920 bool flag3 = false;
56921 Vector2 vector = Main.player[owner].Center - base.Center;
56922 if ((double)vector.Length() > (double)num * 0.9)
56923 {
56924 flag3 = true;
56925 }
56926 if (vector.Length() > num)
56927 {
56928 float num5 = vector.Length() - num;
56929 Vector2 vector2 = default(Vector2);
56930 vector2.X = vector.Y;
56931 vector2.Y = vector.X;
56932 vector.Normalize();
56933 vector *= num;
56934 position = Main.player[owner].Center - vector;
56935 position.X -= width / 2;
56936 position.Y -= height / 2;
56937 float num6 = velocity.Length();
56939 if (num5 > num6 - 1f)
56940 {
56941 num5 = num6 - 1f;
56942 }
56943 velocity *= num6 - num5;
56944 num6 = velocity.Length();
56945 Vector2 vector3 = new Vector2(base.Center.X, base.Center.Y);
56946 Vector2 vector4 = new Vector2(Main.player[owner].Center.X, Main.player[owner].Center.Y);
56947 if (vector3.Y < vector4.Y)
56948 {
56949 vector2.Y = Math.Abs(vector2.Y);
56950 }
56951 else if (vector3.Y > vector4.Y)
56952 {
56953 vector2.Y = 0f - Math.Abs(vector2.Y);
56954 }
56955 if (vector3.X < vector4.X)
56956 {
56957 vector2.X = Math.Abs(vector2.X);
56958 }
56959 else if (vector3.X > vector4.X)
56960 {
56961 vector2.X = 0f - Math.Abs(vector2.X);
56962 }
56963 vector2.Normalize();
56964 vector2 *= velocity.Length();
56965 new Vector2(vector2.X, vector2.Y);
56966 if (Math.Abs(velocity.X) > Math.Abs(velocity.Y))
56967 {
56969 vector5.Y += vector2.Y;
56970 vector5.Normalize();
56971 vector5 *= velocity.Length();
56972 if ((double)Math.Abs(vector2.X) < 0.1 || (double)Math.Abs(vector2.Y) < 0.1)
56973 {
56974 velocity = vector5;
56975 }
56976 else
56977 {
56978 velocity = (vector5 + velocity * 2f) / 3f;
56979 }
56980 }
56981 else
56982 {
56984 vector6.X += vector2.X;
56985 vector6.Normalize();
56986 vector6 *= velocity.Length();
56987 if ((double)Math.Abs(vector2.X) < 0.2 || (double)Math.Abs(vector2.Y) < 0.2)
56988 {
56989 velocity = vector6;
56990 }
56991 else
56992 {
56993 velocity = (vector6 + velocity * 2f) / 3f;
56994 }
56995 }
56996 }
56997 if (Main.myPlayer == owner)
56998 {
56999 if (Main.player[owner].channel)
57000 {
57001 Vector2 vector7 = new Vector2(Main.mouseX - Main.lastMouseX, Main.mouseY - Main.lastMouseY);
57002 if (velocity.X != 0f || velocity.Y != 0f)
57003 {
57004 if (flag)
57005 {
57006 vector7 *= -1f;
57007 }
57008 if (flag3)
57009 {
57010 if (base.Center.X < Main.player[owner].Center.X && vector7.X < 0f)
57011 {
57012 vector7.X = 0f;
57013 }
57014 if (base.Center.X > Main.player[owner].Center.X && vector7.X > 0f)
57015 {
57016 vector7.X = 0f;
57017 }
57018 if (base.Center.Y < Main.player[owner].Center.Y && vector7.Y < 0f)
57019 {
57020 vector7.Y = 0f;
57021 }
57022 if (base.Center.Y > Main.player[owner].Center.Y && vector7.Y > 0f)
57023 {
57024 vector7.Y = 0f;
57025 }
57026 }
57027 velocity += vector7 * num2;
57028 netUpdate = true;
57029 }
57030 }
57031 else
57032 {
57033 ai[0] = -1f;
57034 netUpdate = true;
57035 }
57036 }
57037 if (flag || type == 562 || type == 547 || type == 555 || type == 564 || type == 552 || type == 563 || type == 549 || type == 550 || type == 554 || type == 553 || type == 603 || type == 999)
57038 {
57039 float num7 = 800f;
57040 Vector2 vector8 = default(Vector2);
57041 bool flag4 = false;
57042 if (type == 549)
57043 {
57044 num7 = 200f;
57045 }
57046 if (type == 554)
57047 {
57048 num7 = 400f;
57049 }
57050 if (type == 553)
57051 {
57052 num7 = 250f;
57053 }
57054 if (type == 603)
57055 {
57056 num7 = 320f;
57057 }
57058 for (int j = 0; j < 200; j++)
57059 {
57060 if (Main.npc[j].CanBeChasedBy(this))
57061 {
57062 float num8 = Main.npc[j].position.X + (float)(Main.npc[j].width / 2);
57063 float num9 = Main.npc[j].position.Y + (float)(Main.npc[j].height / 2);
57064 float num10 = Math.Abs(position.X + (float)(width / 2) - num8) + Math.Abs(position.Y + (float)(height / 2) - num9);
57065 if (num10 < num7 && (type != 563 || !(num10 < 200f)) && Collision.CanHit(position, width, height, Main.npc[j].position, Main.npc[j].width, Main.npc[j].height) && (double)(Main.npc[j].Center - Main.player[owner].Center).Length() < (double)num * 0.9)
57066 {
57067 num7 = num10;
57068 vector8.X = num8;
57069 vector8.Y = num9;
57070 flag4 = true;
57071 }
57072 }
57073 }
57074 if (flag4)
57075 {
57076 vector8 -= base.Center;
57077 vector8.Normalize();
57078 if (type == 563)
57079 {
57080 vector8 *= 4f;
57081 velocity = (velocity * 14f + vector8) / 15f;
57082 }
57083 else if (type == 553)
57084 {
57085 vector8 *= 5f;
57086 velocity = (velocity * 12f + vector8) / 13f;
57087 }
57088 else if (type == 603)
57089 {
57090 vector8 *= 16f;
57091 velocity = (velocity * 9f + vector8) / 10f;
57092 }
57093 else if (type == 554)
57094 {
57095 vector8 *= 8f;
57096 velocity = (velocity * 6f + vector8) / 7f;
57097 }
57098 else
57099 {
57100 vector8 *= 6f;
57101 velocity = (velocity * 7f + vector8) / 8f;
57102 }
57103 }
57104 }
57105 if (velocity.Length() > num3)
57106 {
57108 velocity *= num3;
57109 }
57110 if (velocity.Length() < num4)
57111 {
57113 velocity *= num4;
57114 }
57115 return;
57116 }
57117 tileCollide = false;
57118 Vector2 vector9 = Main.player[owner].Center - base.Center;
57119 float num11 = vector9.Length();
57120 if (num11 < 40f || vector9.HasNaNs() || num11 > 2000f)
57121 {
57122 Kill();
57123 return;
57124 }
57125 float num12 = num3 * 1.5f;
57126 if (type == 546)
57127 {
57128 num12 *= 1.5f;
57129 }
57130 if (type == 554)
57131 {
57132 num12 *= 1.25f;
57133 }
57134 if (type == 555)
57135 {
57136 num12 *= 1.35f;
57137 }
57138 if (type == 562)
57139 {
57140 num12 *= 1.25f;
57141 }
57142 float num13 = 12f;
57143 vector9.Normalize();
57144 vector9 *= num12;
57145 velocity = (velocity * (num13 - 1f) + vector9) / num13;
57146 }
static double Abs(double value)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14

References System.Math.Abs(), Terraria.Collision.CanHit(), Terraria.Main.lastMouseX, Terraria.Main.lastMouseY, Terraria.Main.mouseX, Terraria.Main.mouseY, Terraria.Main.myPlayer, Terraria.Main.npc, Terraria.Main.player, Terraria.Main.projectile, System.type, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.