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

◆ AI_108_DivingFlyer()

void Terraria.NPC.AI_108_DivingFlyer ( )
inlineprivate

Definition at line 57725 of file NPC.cs.

57726 {
57727 //IL_0210: Unknown result type (might be due to invalid IL or missing references)
57728 //IL_0b8b: Unknown result type (might be due to invalid IL or missing references)
57729 //IL_07a2: Unknown result type (might be due to invalid IL or missing references)
57730 //IL_07a7: Unknown result type (might be due to invalid IL or missing references)
57731 //IL_0bb1: Unknown result type (might be due to invalid IL or missing references)
57732 //IL_0bb6: Unknown result type (might be due to invalid IL or missing references)
57733 //IL_090e: Unknown result type (might be due to invalid IL or missing references)
57734 //IL_07d0: Unknown result type (might be due to invalid IL or missing references)
57735 //IL_07d5: Unknown result type (might be due to invalid IL or missing references)
57736 //IL_0930: Unknown result type (might be due to invalid IL or missing references)
57737 //IL_0935: Unknown result type (might be due to invalid IL or missing references)
57738 //IL_0bef: Unknown result type (might be due to invalid IL or missing references)
57739 //IL_080d: Unknown result type (might be due to invalid IL or missing references)
57740 //IL_0812: Unknown result type (might be due to invalid IL or missing references)
57741 //IL_0827: Unknown result type (might be due to invalid IL or missing references)
57742 //IL_0c15: Unknown result type (might be due to invalid IL or missing references)
57743 //IL_0c1a: Unknown result type (might be due to invalid IL or missing references)
57744 rotation = velocity.ToRotation();
57745 float num = 0.4f;
57746 float num2 = 10f;
57747 float num3 = 200f;
57748 float num4 = 750f;
57749 float num5 = 30f;
57750 float num6 = 30f;
57751 float num7 = 0.95f;
57752 int num8 = 50;
57753 float num9 = 14f;
57754 float num10 = 30f;
57755 float num11 = 100f;
57756 float num12 = 20f;
57757 float num13 = 0f;
57758 float num14 = 7f;
57759 bool flag = true;
57760 bool flag2 = true;
57761 int num15 = 120;
57762 bool flag3 = false;
57763 bool flag4 = false;
57764 float num16 = 0.05f;
57765 float num17 = 0f;
57766 bool flag5 = false;
57767 switch (type)
57768 {
57769 case 558:
57770 case 559:
57771 case 560:
57772 flag4 = true;
57773 num = 0.7f;
57774 if (type == 559)
57775 {
57776 num = 0.5f;
57777 }
57778 if (type == 560)
57779 {
57780 num = 0.2f;
57781 }
57782 num2 = 3f;
57783 num3 = 400f;
57784 num4 = 500f;
57785 num5 = 90f;
57786 num6 = 20f;
57787 num7 = 0.95f;
57788 num8 = 0;
57789 num9 = 8f;
57790 num10 = 30f;
57791 num11 = 150f;
57792 num12 = 60f;
57793 num13 = 0.05f;
57794 num14 = 6f;
57795 flag2 = false;
57796 flag5 = true;
57797 break;
57798 case 574:
57799 case 575:
57800 flag4 = true;
57801 num = 0.6f;
57802 if (type == 575)
57803 {
57804 num = 0.4f;
57805 }
57806 num2 = 4f;
57807 num3 = 400f;
57808 num4 = 500f;
57809 num5 = 90f;
57810 num6 = 30f;
57811 num7 = 0.95f;
57812 num8 = 3;
57813 num9 = 8f;
57814 num10 = 30f;
57815 num11 = 150f;
57816 num12 = 10f;
57817 num13 = 0.05f;
57818 num14 = 0f;
57819 num17 = -0.1f;
57820 flag3 = true;
57821 flag5 = true;
57822 break;
57823 }
57826 if (flag5)
57827 {
57828 if (localAI[0] == 0f)
57829 {
57830 alpha = 255;
57831 }
57832 if (localAI[0] == 30f)
57833 {
57835 }
57836 if (localAI[0] < 60f)
57837 {
57838 localAI[0] += 1f;
57839 alpha -= 5;
57840 if (alpha < 0)
57841 {
57842 alpha = 0;
57843 }
57844 int num18 = (int)localAI[0] / 10;
57845 float num19 = base.Size.Length() / 2f;
57846 num19 /= 20f;
57847 int maxValue = 5;
57848 if (type == 576 || type == 577)
57849 {
57850 maxValue = 1;
57851 }
57852 for (int i = 0; i < num18; i++)
57853 {
57854 if (Main.rand.Next(maxValue) == 0)
57855 {
57856 Dust dust = Dust.NewDustDirect(position, width, height, 27, velocity.X * 1f, 0f, 100);
57857 dust.scale = 0.55f;
57858 dust.fadeIn = 0.7f;
57859 dust.velocity *= 0.1f * num19;
57860 dust.velocity += velocity;
57861 }
57862 }
57863 }
57864 }
57865 if (flag4)
57866 {
57867 for (int j = 0; j < 200; j++)
57868 {
57869 if (j != whoAmI && Main.npc[j].active && Main.npc[j].type == type && Math.Abs(position.X - Main.npc[j].position.X) + Math.Abs(position.Y - Main.npc[j].position.Y) < (float)width)
57870 {
57871 if (position.X < Main.npc[j].position.X)
57872 {
57873 velocity.X -= num16;
57874 }
57875 else
57876 {
57877 velocity.X += num16;
57878 }
57879 if (position.Y < Main.npc[j].position.Y)
57880 {
57881 velocity.Y -= num16;
57882 }
57883 else
57884 {
57885 velocity.Y += num16;
57886 }
57887 }
57888 }
57889 }
57890 if (Math.Sign(velocity.X) != 0)
57891 {
57893 }
57894 if (rotation < -(float)Math.PI / 2f)
57895 {
57896 rotation += (float)Math.PI;
57897 }
57898 if (rotation > (float)Math.PI / 2f)
57899 {
57900 rotation -= (float)Math.PI;
57901 }
57902 num13 *= num12;
57903 if (Main.expertMode)
57904 {
57905 num *= Main.GameModeInfo.KnockbackToEnemiesMultiplier;
57906 }
57907 SlotId val;
57908 if (ai[0] == 0f)
57909 {
57910 knockBackResist = num;
57911 float num20 = num2;
57912 Vector2 center = base.Center;
57913 Vector2 vector = targetData.Center - center;
57914 Vector2 vector2 = vector - Vector2.UnitY * num3;
57915 float num21 = vector.Length();
57918 bool flag6 = Collision.CanHit(base.Center, 1, 1, targetData.Center, 1, 1);
57919 if (ai[3] >= (float)num15)
57920 {
57921 flag6 = true;
57922 }
57923 float num22 = 8f;
57924 flag6 = flag6 && vector.ToRotation() > (float)Math.PI / num22 && vector.ToRotation() < (float)Math.PI - (float)Math.PI / num22;
57925 if (num21 > num4 || !flag6)
57926 {
57927 velocity.X = (velocity.X * (num5 - 1f) + vector2.X) / num5;
57928 velocity.Y = (velocity.Y * (num5 - 1f) + vector2.Y) / num5;
57929 if (targetData.Center.Y < base.Center.Y)
57930 {
57931 velocity.Y -= 0.2f;
57932 if (velocity.Y < -10f)
57933 {
57934 velocity.Y = -10f;
57935 }
57936 }
57937 if (!flag6)
57938 {
57939 ai[3] += 1f;
57940 if (ai[3] == (float)num15)
57941 {
57942 netUpdate = true;
57943 }
57944 }
57945 else
57946 {
57947 ai[3] = 0f;
57948 }
57949 }
57950 else
57951 {
57952 ai[0] = 1f;
57953 ai[2] = vector.X;
57954 ai[3] = vector.Y;
57955 netUpdate = true;
57956 }
57957 }
57958 else if (ai[0] == 1f)
57959 {
57960 knockBackResist = 0f;
57961 velocity *= num7;
57962 velocity.Y += num17;
57963 ai[1] += 1f;
57964 if (ai[1] == num6)
57965 {
57966 if (type == 558 || type == 559 || type == 560)
57967 {
57968 float[] array = localAI;
57970 array[1] = ((SlotId)(ref val)).ToFloat();
57971 if (Main.rand.Next(5) == 0)
57972 {
57973 float[] array2 = localAI;
57975 array2[2] = ((SlotId)(ref val)).ToFloat();
57976 }
57977 }
57978 else if (type == 574 || type == 575)
57979 {
57980 float[] array3 = localAI;
57982 array3[1] = ((SlotId)(ref val)).ToFloat();
57984 }
57985 }
57986 if (ai[1] >= num6)
57987 {
57988 ai[0] = 2f;
57989 ai[1] = 0f;
57990 netUpdate = true;
57991 Vector2 vector3 = new Vector2(ai[2], ai[3]) + new Vector2(Main.rand.Next(-num8, num8 + 1), Main.rand.Next(-num8, num8 + 1)) * 0.04f;
57992 vector3.Normalize();
57993 vector3 *= num9;
57994 velocity = vector3;
57995 }
57996 }
57997 else if (ai[0] == 2f)
57998 {
57999 if (ai[1] >= 20f && (type == 574 || type == 575))
58000 {
58002 if (activeSound == null)
58003 {
58004 float[] array4 = localAI;
58006 array4[2] = ((SlotId)(ref val)).ToFloat();
58007 }
58008 else
58009 {
58010 activeSound.Position = base.Center;
58011 }
58012 }
58013 knockBackResist = 0f;
58014 float num23 = num10;
58015 ai[1] += 1f;
58016 bool flag7 = Vector2.Distance(base.Center, targetData.Center) > num11 && base.Center.Y > targetData.Center.Y;
58017 if (flag3)
58018 {
58019 flag7 = false;
58020 }
58021 if ((ai[1] >= num23 && flag7) || velocity.Length() < num14)
58022 {
58023 ai[0] = 0f;
58024 ai[1] = 0f;
58025 ai[2] = 0f;
58026 ai[3] = 0f;
58027 velocity /= 2f;
58028 netUpdate = true;
58029 if (flag)
58030 {
58031 ai[1] = 45f;
58032 ai[0] = 4f;
58033 }
58034 }
58035 else
58036 {
58037 Vector2 center2 = base.Center;
58038 Vector2 vector4 = targetData.Center - center2;
58039 vector4.Normalize();
58040 if (vector4.HasNaNs())
58041 {
58042 vector4 = new Vector2(direction, 0f);
58043 }
58044 velocity = (velocity * (num12 - 1f) + vector4 * (velocity.Length() + num13)) / num12;
58045 }
58046 if (flag2 && Collision.SolidCollision(position, width, height))
58047 {
58048 ai[0] = 3f;
58049 ai[1] = 0f;
58050 ai[2] = 0f;
58051 ai[3] = 0f;
58052 netUpdate = true;
58053 }
58054 }
58055 else if (ai[0] == 4f)
58056 {
58057 ai[1] -= 3f;
58058 if (ai[1] <= 0f)
58059 {
58060 ai[0] = 0f;
58061 ai[1] = 0f;
58062 netUpdate = true;
58063 }
58064 velocity *= 0.95f;
58065 }
58067 if (activeSound2 != null)
58068 {
58069 activeSound2.Position = base.Center;
58070 }
58071 else
58072 {
58073 float[] array5 = localAI;
58074 val = SlotId.Invalid;
58075 array5[1] = ((SlotId)(ref val)).ToFloat();
58076 }
58077 if (type == 558 || type == 559 || type == 560)
58078 {
58080 if (activeSound2 != null)
58081 {
58082 activeSound2.Position = base.Center;
58083 }
58084 else
58085 {
58086 float[] array6 = localAI;
58087 val = SlotId.Invalid;
58088 array6[2] = ((SlotId)(ref val)).ToFloat();
58089 }
58090 }
58091 if (flag2 && ai[0] != 3f && Vector2.Distance(base.Center, targetData.Center) < 64f)
58092 {
58093 ai[0] = 3f;
58094 ai[1] = 0f;
58095 ai[2] = 0f;
58096 ai[3] = 0f;
58097 netUpdate = true;
58098 }
58099 if (ai[0] != 3f)
58100 {
58101 return;
58102 }
58103 position = base.Center;
58104 width = (height = 192);
58105 position.X -= width / 2;
58106 position.Y -= height / 2;
58109 alpha = 255;
58110 if (ai[1] == 0f && (type == 574 || type == 575))
58111 {
58112 for (int k = 0; k < 4; k++)
58113 {
58114 int num24 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 31, 0f, 0f, 100, default(Color), 1.5f);
58115 Main.dust[num24].position = base.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * width / 2f;
58116 }
58117 for (int l = 0; l < 20; l++)
58118 {
58119 int num25 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 6, 0f, 0f, 200, default(Color), 3.7f);
58120 Main.dust[num25].position = base.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * width / 2f;
58121 Main.dust[num25].noGravity = true;
58122 Main.dust[num25].velocity *= 3f;
58123 num25 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 6, 0f, 0f, 100, default(Color), 1.5f);
58124 Main.dust[num25].position = base.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * width / 4f;
58125 Main.dust[num25].velocity *= 2f;
58126 Main.dust[num25].noGravity = true;
58127 Main.dust[num25].fadeIn = 2.5f;
58128 }
58129 for (int m = 0; m < 6; m++)
58130 {
58131 int num26 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 6, 0f, 0f, 0, default(Color), 2.7f);
58132 Main.dust[num26].position = base.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy(velocity.ToRotation()) * width / 2f;
58133 Main.dust[num26].noGravity = true;
58134 Main.dust[num26].velocity *= 3f;
58135 }
58136 for (int n = 0; n < 12; n++)
58137 {
58138 int num27 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 31, 0f, 0f, 0, default(Color), 1.5f);
58139 Main.dust[num27].position = base.Center + Vector2.UnitX.RotatedByRandom(3.1415927410125732).RotatedBy(velocity.ToRotation()) * width / 2f;
58140 Main.dust[num27].noGravity = true;
58141 Main.dust[num27].velocity *= 3f;
58142 }
58143 for (int num28 = 0; num28 < 5; num28++)
58144 {
58145 int num29 = Gore.NewGore(position + new Vector2((float)(width * Main.rand.Next(100)) / 100f, (float)(height * Main.rand.Next(100)) / 100f) - Vector2.One * 10f, default(Vector2), Main.rand.Next(61, 64));
58146 Main.gore[num29].position = base.Center + Vector2.UnitY.RotatedByRandom(3.1415927410125732) * (float)Main.rand.NextDouble() * width / 2f;
58147 Main.gore[num29].velocity *= 0.3f;
58148 Main.gore[num29].velocity.X += (float)Main.rand.Next(-10, 11) * 0.05f;
58149 Main.gore[num29].velocity.Y += (float)Main.rand.Next(-10, 11) * 0.05f;
58150 }
58151 }
58152 ai[1] += 1f;
58153 if (ai[1] >= 3f)
58154 {
58156 life = 0;
58157 HitEffect();
58158 active = false;
58159 }
58160 }
static double Abs(double value)
const double PI
Definition Math.cs:16
static int Sign(decimal value)
Definition Math.cs:1202
static SlotId PlayTrackedSound(SoundStyle style, Vector2 position)
static void PlaySound(int type, Vector2 position, int style=1)
static ActiveSound GetActiveSound(SlotId id)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
static readonly LegacySoundStyle DD2_KoboldIgnite
Definition SoundID.cs:864
static readonly LegacySoundStyle DD2_WyvernScream
Definition SoundID.cs:912
static readonly LegacySoundStyle Item14
Definition SoundID.cs:442
static readonly LegacySoundStyle DD2_KoboldFlyerChargeScream
Definition SoundID.cs:870
static readonly LegacySoundStyle DD2_KoboldIgniteLoop
Definition SoundID.cs:866
static readonly LegacySoundStyle DD2_WyvernDiveDown
Definition SoundID.cs:914
static readonly LegacySoundStyle DD2_EtherianPortalSpawnEnemy
Definition SoundID.cs:922
int damage
Definition NPC.cs:461
float[] localAI
Definition NPC.cs:449
int spriteDirection
Definition NPC.cs:517
NPCAimedTarget GetTargetData(bool ignorePlayerTankPets=true)
Definition NPC.cs:864
float[] ai
Definition NPC.cs:447
float knockBackResist
Definition NPC.cs:495
int type
Definition NPC.cs:445
int alpha
Definition NPC.cs:489
float rotation
Definition NPC.cs:501
int GetAttackDamage_ScaledByStrength(float normalDamage)
Definition NPC.cs:1057
void HitEffect(int hitDirection=0, double dmg=10.0)
Definition NPC.cs:78386
int life
Definition NPC.cs:477
bool netUpdate
Definition NPC.cs:507
static void TargetClosestOldOnesInvasion(NPC searcher, bool faceTarget=true, Vector2? checkPosition=null)
Definition NPCUtils.cs:261
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91
static readonly SlotId Invalid
Definition SlotId.cs:5
static SlotId FromFloat(float value)
Definition SlotId.cs:80

References System.Math.Abs(), Terraria.Entity.active, Terraria.NPC.ai, Terraria.NPC.alpha, System.array, Terraria.Collision.CanHit(), Terraria.NPC.damage, Terraria.ID.SoundID.DD2_EtherianPortalSpawnEnemy, Terraria.ID.SoundID.DD2_KoboldFlyerChargeScream, Terraria.ID.SoundID.DD2_KoboldIgnite, Terraria.ID.SoundID.DD2_KoboldIgniteLoop, Terraria.ID.SoundID.DD2_WyvernDiveDown, Terraria.ID.SoundID.DD2_WyvernScream, Terraria.Entity.direction, Microsoft.Xna.Framework.Vector2.Distance(), Terraria.Main.dust, Terraria.Main.expertMode, ReLogic.Utilities.SlotId.FromFloat(), Terraria.Main.GameModeInfo, Terraria.Audio.SoundEngine.GetActiveSound(), Terraria.NPC.GetAttackDamage_ScaledByStrength(), Terraria.NPC.GetTargetData(), Terraria.Main.gore, Terraria.Entity.height, Terraria.NPC.HitEffect(), ReLogic.Utilities.SlotId.Invalid, Terraria.ID.SoundID.Item14, Terraria.NPC.knockBackResist, Microsoft.Xna.Framework.Vector2.Length(), Terraria.NPC.life, Terraria.NPC.localAI, Terraria.NPC.netUpdate, Terraria.Dust.NewDust(), Terraria.Dust.NewDustDirect(), Terraria.Gore.NewGore(), Microsoft.Xna.Framework.Vector2.Normalize(), Terraria.Main.npc, System.Math.PI, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Audio.SoundEngine.PlayTrackedSound(), Terraria.Entity.position, Terraria.Main.rand, Terraria.NPC.rotation, System.Math.Sign(), Terraria.Collision.SolidCollision(), Terraria.NPC.spriteDirection, Terraria.Utilities.NPCUtils.TargetClosestOldOnesInvasion(), Terraria.NPC.type, Microsoft.Xna.Framework.Vector2.UnitX, Microsoft.Xna.Framework.Vector2.UnitY, Microsoft.Xna.Framework.Graphics.Vector2, Terraria.Entity.velocity, Terraria.Entity.whoAmI, Terraria.Entity.width, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by Terraria.NPC.AI().