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

◆ AI_114_Dragonflies()

void Terraria.NPC.AI_114_Dragonflies ( )
inlineprivate

Definition at line 49805 of file NPC.cs.

49806 {
49807 //IL_00c6: Unknown result type (might be due to invalid IL or missing references)
49808 //IL_00d0: Unknown result type (might be due to invalid IL or missing references)
49809 //IL_00d5: Unknown result type (might be due to invalid IL or missing references)
49810 //IL_002b: Unknown result type (might be due to invalid IL or missing references)
49811 //IL_0030: Unknown result type (might be due to invalid IL or missing references)
49812 //IL_0038: Unknown result type (might be due to invalid IL or missing references)
49813 //IL_0046: Unknown result type (might be due to invalid IL or missing references)
49814 //IL_005d: Unknown result type (might be due to invalid IL or missing references)
49815 //IL_0071: Unknown result type (might be due to invalid IL or missing references)
49816 //IL_0076: Unknown result type (might be due to invalid IL or missing references)
49817 //IL_0080: Unknown result type (might be due to invalid IL or missing references)
49818 //IL_0085: Unknown result type (might be due to invalid IL or missing references)
49819 //IL_0214: Unknown result type (might be due to invalid IL or missing references)
49820 //IL_012c: Unknown result type (might be due to invalid IL or missing references)
49821 //IL_0155: Unknown result type (might be due to invalid IL or missing references)
49822 //IL_013c: Unknown result type (might be due to invalid IL or missing references)
49823 //IL_013e: Unknown result type (might be due to invalid IL or missing references)
49824 //IL_0148: Unknown result type (might be due to invalid IL or missing references)
49825 //IL_014d: Unknown result type (might be due to invalid IL or missing references)
49826 //IL_026a: Unknown result type (might be due to invalid IL or missing references)
49827 //IL_027b: Unknown result type (might be due to invalid IL or missing references)
49828 //IL_047d: Unknown result type (might be due to invalid IL or missing references)
49829 //IL_0482: Unknown result type (might be due to invalid IL or missing references)
49830 //IL_01a6: Unknown result type (might be due to invalid IL or missing references)
49831 //IL_01ba: Unknown result type (might be due to invalid IL or missing references)
49832 //IL_01bf: Unknown result type (might be due to invalid IL or missing references)
49833 //IL_01c9: Unknown result type (might be due to invalid IL or missing references)
49834 //IL_01ce: Unknown result type (might be due to invalid IL or missing references)
49835 //IL_0165: Unknown result type (might be due to invalid IL or missing references)
49836 //IL_0167: Unknown result type (might be due to invalid IL or missing references)
49837 //IL_0171: Unknown result type (might be due to invalid IL or missing references)
49838 //IL_0185: Unknown result type (might be due to invalid IL or missing references)
49839 //IL_018a: Unknown result type (might be due to invalid IL or missing references)
49840 //IL_018f: Unknown result type (might be due to invalid IL or missing references)
49841 //IL_04b0: Unknown result type (might be due to invalid IL or missing references)
49842 //IL_04b6: Unknown result type (might be due to invalid IL or missing references)
49843 //IL_050c: Unknown result type (might be due to invalid IL or missing references)
49844 //IL_0512: Unknown result type (might be due to invalid IL or missing references)
49845 //IL_0560: Unknown result type (might be due to invalid IL or missing references)
49846 //IL_0562: Unknown result type (might be due to invalid IL or missing references)
49847 //IL_0567: Unknown result type (might be due to invalid IL or missing references)
49848 //IL_0568: Unknown result type (might be due to invalid IL or missing references)
49849 //IL_056b: Unknown result type (might be due to invalid IL or missing references)
49850 //IL_0570: Unknown result type (might be due to invalid IL or missing references)
49851 //IL_0573: Unknown result type (might be due to invalid IL or missing references)
49852 //IL_0578: Unknown result type (might be due to invalid IL or missing references)
49853 //IL_0579: Unknown result type (might be due to invalid IL or missing references)
49854 //IL_057e: Unknown result type (might be due to invalid IL or missing references)
49855 //IL_04cf: Unknown result type (might be due to invalid IL or missing references)
49856 //IL_04d3: Unknown result type (might be due to invalid IL or missing references)
49857 //IL_04d8: Unknown result type (might be due to invalid IL or missing references)
49858 //IL_04dd: Unknown result type (might be due to invalid IL or missing references)
49859 //IL_04e2: Unknown result type (might be due to invalid IL or missing references)
49860 //IL_052b: Unknown result type (might be due to invalid IL or missing references)
49861 //IL_052f: Unknown result type (might be due to invalid IL or missing references)
49862 //IL_0534: Unknown result type (might be due to invalid IL or missing references)
49863 //IL_0539: Unknown result type (might be due to invalid IL or missing references)
49864 //IL_053e: Unknown result type (might be due to invalid IL or missing references)
49865 //IL_0625: Unknown result type (might be due to invalid IL or missing references)
49866 //IL_062b: Unknown result type (might be due to invalid IL or missing references)
49867 //IL_0630: Unknown result type (might be due to invalid IL or missing references)
49868 //IL_0635: Unknown result type (might be due to invalid IL or missing references)
49869 //IL_05b6: Unknown result type (might be due to invalid IL or missing references)
49870 //IL_05bb: Unknown result type (might be due to invalid IL or missing references)
49871 //IL_05c1: Unknown result type (might be due to invalid IL or missing references)
49872 //IL_05c6: Unknown result type (might be due to invalid IL or missing references)
49873 //IL_05cb: Unknown result type (might be due to invalid IL or missing references)
49874 //IL_05ee: Unknown result type (might be due to invalid IL or missing references)
49875 //IL_05fd: Unknown result type (might be due to invalid IL or missing references)
49876 //IL_0597: Unknown result type (might be due to invalid IL or missing references)
49877 //IL_059c: Unknown result type (might be due to invalid IL or missing references)
49878 //IL_05a1: Unknown result type (might be due to invalid IL or missing references)
49879 //IL_05ab: Unknown result type (might be due to invalid IL or missing references)
49880 //IL_05b0: Unknown result type (might be due to invalid IL or missing references)
49881 //IL_06ed: Unknown result type (might be due to invalid IL or missing references)
49882 //IL_0701: Unknown result type (might be due to invalid IL or missing references)
49883 if (localAI[0] == 0f && Main.netMode != 1)
49884 {
49885 localAI[0] = 1f;
49886 Vector2 center = base.Center;
49887 ai[2] = center.X;
49888 ai[3] = center.Y;
49889 velocity = (Main.rand.NextVector2Circular(5f, 3f) + Main.rand.NextVector2CircularEdge(5f, 3f)) * 0.4f;
49890 ai[1] = 0f;
49891 ai[0] = 1f;
49892 netUpdate = true;
49893 }
49894 switch ((int)ai[0])
49895 {
49896 case 0:
49897 velocity *= 0.94f;
49898 if (Main.netMode != 1 && (ai[1] += 1f) >= (float)(60 + Main.rand.Next(60)))
49899 {
49900 Vector2 vector = default(Vector2);
49901 ((Vector2)(ref vector))._002Ector(ai[2], ai[3]);
49902 if (Distance(vector) > 96f)
49903 {
49905 }
49906 else if (Distance(vector) > 16f)
49907 {
49908 velocity = DirectionTo(vector) * 1f + Main.rand.NextVector2Circular(1f, 0.5f);
49909 }
49910 else
49911 {
49912 velocity = (Main.rand.NextVector2Circular(5f, 3f) + Main.rand.NextVector2CircularEdge(5f, 3f)) * 0.4f;
49913 }
49914 ai[1] = 0f;
49915 ai[0] = 1f;
49916 netUpdate = true;
49917 }
49918 break;
49919 case 1:
49920 {
49921 int num = 4;
49922 Vector2 other = default(Vector2);
49923 ((Vector2)(ref other))._002Ector(ai[2], ai[3]);
49924 if (Distance(other) > 112f)
49925 {
49926 num = 200;
49927 }
49928 if ((ai[1] += 1f) >= (float)num)
49929 {
49930 ai[1] = 0f;
49931 ai[0] = 0f;
49932 netUpdate = true;
49933 }
49934 int num2 = (int)base.Center.X / 16;
49935 int num3 = (int)base.Center.Y / 16;
49936 int num4 = 3;
49937 for (int i = num3; i < num3 + num4; i++)
49938 {
49939 if (Main.tile[num2, i] != null && ((Main.tile[num2, i].nactive() && Main.tileSolid[Main.tile[num2, i].type]) || Main.tile[num2, i].liquid > 0))
49940 {
49941 if (velocity.Y > 0f)
49942 {
49943 velocity.Y *= 0.9f;
49944 }
49945 velocity.Y -= 0.2f;
49946 }
49947 }
49948 if (!(velocity.Y < 0f))
49949 {
49950 break;
49951 }
49952 int num5 = 30;
49953 bool flag = false;
49954 for (int j = num3; j < num3 + num5; j++)
49955 {
49956 if (Main.tile[num2, j] != null && Main.tile[num2, j].nactive() && Main.tileSolid[Main.tile[num2, j].type])
49957 {
49958 flag = true;
49959 break;
49960 }
49961 }
49962 if (!flag && velocity.Y < 0f)
49963 {
49964 velocity.Y *= 0.9f;
49965 }
49966 break;
49967 }
49968 }
49969 if (velocity.X != 0f)
49970 {
49971 direction = ((velocity.X > 0f) ? 1 : (-1));
49972 }
49973 if (wet)
49974 {
49975 velocity.Y = -3f;
49976 }
49977 if (localAI[1] > 0f)
49978 {
49979 localAI[1] -= 1f;
49980 return;
49981 }
49982 localAI[1] = 15f;
49983 float num6 = 0f;
49984 Vector2 zero = Vector2.Zero;
49985 for (int k = 0; k < 200; k++)
49986 {
49987 NPC nPC = Main.npc[k];
49988 if (nPC.active && nPC.damage > 0 && !nPC.friendly && nPC.Hitbox.Distance(base.Center) <= 100f)
49989 {
49990 num6 += 1f;
49991 zero += DirectionFrom(nPC.Center);
49992 }
49993 }
49994 for (int l = 0; l < 255; l++)
49995 {
49996 Player player = Main.player[l];
49997 if (player.active && player.Hitbox.Distance(base.Center) <= 150f)
49998 {
49999 num6 += 1f;
50000 zero += DirectionFrom(player.Center);
50001 }
50002 }
50003 if (num6 > 0f)
50004 {
50005 float num7 = 2f;
50006 zero /= num6;
50007 zero *= num7;
50008 velocity += zero;
50009 if (((Vector2)(ref velocity)).Length() > 16f)
50010 {
50011 velocity = velocity.SafeNormalize(Vector2.Zero) * 16f;
50012 }
50013 Vector2 vector2 = base.Center + zero * 10f;
50014 ai[1] = -10f;
50015 ai[0] = 1f;
50016 ai[2] = vector2.X;
50017 ai[3] = vector2.Y;
50018 netUpdate = true;
50019 }
50020 else
50021 {
50022 if (Main.netMode == 1)
50023 {
50024 return;
50025 }
50026 Vector2 val = new Vector2(ai[2], ai[3]) - base.Center;
50027 if (!(((Vector2)(ref val)).Length() < 16f))
50028 {
50029 return;
50030 }
50031 int maxValue = 30;
50032 if (Main.tile[(int)ai[2] / 16, (int)ai[3] / 16].type != 519)
50033 {
50034 maxValue = 4;
50035 }
50036 if (Main.rand.Next(maxValue) != 0)
50037 {
50038 return;
50039 }
50040 int cattailX = (int)ai[2];
50041 int cattailY = (int)ai[2];
50042 if (FindCattailTop((int)ai[2] / 16, (int)ai[3] / 16, out cattailX, out cattailY))
50043 {
50044 ai[2] = cattailX * 16;
50045 ai[3] = cattailY * 16;
50046 netUpdate = true;
50047 return;
50048 }
50049 int num8 = (int)(base.Center.X / 16f);
50050 int m;
50051 for (m = (int)(base.Center.Y / 16f); !WorldGen.SolidTile(num8, m) && (double)m < Main.worldSurface; m++)
50052 {
50053 }
50054 m -= Main.rand.Next(3, 6);
50055 ai[2] = num8 * 16;
50056 ai[3] = m * 16;
50057 netUpdate = true;
50058 }
50059 }
bool wet
The Entity is currently in water. Projectile: Affects movement speed and some projectiles die when ...
Definition Entity.cs:57
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 DirectionTo(Vector2 Destination)
Definition Entity.cs:289
float[] localAI
Acts like F:Terraria.NPC.ai, but does not sync to the server. Many vanilla T:Terraria....
Definition NPC.cs:1003
float[] ai
An array with 4 slots used for any sort of data storage, which is occasionally synced from the server...
Definition NPC.cs:997
static bool FindCattailTop(int landX, int landY, out int cattailX, out int cattailY)
Definition NPC.cs:90416
bool netUpdate
Definition NPC.cs:1130

References Terraria.Entity.active, Terraria.NPC.ai, Terraria.Entity.Center, Terraria.Entity.direction, Terraria.Entity.DirectionFrom(), Terraria.Entity.DirectionTo(), Terraria.Entity.Distance(), Terraria.NPC.FindCattailTop(), Terraria.Entity.Hitbox, Terraria.NPC.localAI, Terraria.Main.netMode, Terraria.NPC.netUpdate, Terraria.Main.npc, Terraria.Main.player, Terraria.Main.rand, Terraria.WorldGen.SolidTile(), Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.Entity.velocity, Terraria.Entity.wet, and Terraria.Main.worldSurface.

Referenced by Terraria.NPC.VanillaAI_Inner().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: