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

◆ AI_158_BabyBird()

void Terraria.Projectile.AI_158_BabyBird ( )
inlineprivate

Definition at line 51788 of file Projectile.cs.

51789 {
51790 //IL_00ba: Unknown result type (might be due to invalid IL or missing references)
51791 //IL_0465: Unknown result type (might be due to invalid IL or missing references)
51792 //IL_046a: Unknown result type (might be due to invalid IL or missing references)
51793 //IL_046d: Unknown result type (might be due to invalid IL or missing references)
51794 //IL_00d4: Unknown result type (might be due to invalid IL or missing references)
51795 //IL_0100: Unknown result type (might be due to invalid IL or missing references)
51796 //IL_0168: Unknown result type (might be due to invalid IL or missing references)
51797 //IL_04ac: Unknown result type (might be due to invalid IL or missing references)
51798 //IL_04cf: Unknown result type (might be due to invalid IL or missing references)
51799 //IL_04d4: Unknown result type (might be due to invalid IL or missing references)
51800 //IL_0225: Unknown result type (might be due to invalid IL or missing references)
51801 //IL_022a: Unknown result type (might be due to invalid IL or missing references)
51802 //IL_022f: Unknown result type (might be due to invalid IL or missing references)
51803 //IL_0233: Unknown result type (might be due to invalid IL or missing references)
51804 //IL_0238: Unknown result type (might be due to invalid IL or missing references)
51805 //IL_0245: Unknown result type (might be due to invalid IL or missing references)
51806 //IL_0252: Unknown result type (might be due to invalid IL or missing references)
51807 //IL_025c: Unknown result type (might be due to invalid IL or missing references)
51808 //IL_0261: Unknown result type (might be due to invalid IL or missing references)
51809 //IL_0266: Unknown result type (might be due to invalid IL or missing references)
51810 //IL_01ef: Unknown result type (might be due to invalid IL or missing references)
51811 //IL_01f4: Unknown result type (might be due to invalid IL or missing references)
51812 //IL_01f9: Unknown result type (might be due to invalid IL or missing references)
51813 //IL_01fd: Unknown result type (might be due to invalid IL or missing references)
51814 //IL_0202: Unknown result type (might be due to invalid IL or missing references)
51815 //IL_0205: Unknown result type (might be due to invalid IL or missing references)
51816 //IL_020f: Unknown result type (might be due to invalid IL or missing references)
51817 //IL_0214: Unknown result type (might be due to invalid IL or missing references)
51818 //IL_019e: Unknown result type (might be due to invalid IL or missing references)
51819 //IL_01a8: Unknown result type (might be due to invalid IL or missing references)
51820 //IL_01ad: Unknown result type (might be due to invalid IL or missing references)
51821 //IL_0515: Unknown result type (might be due to invalid IL or missing references)
51822 //IL_0517: Unknown result type (might be due to invalid IL or missing references)
51823 //IL_051c: Unknown result type (might be due to invalid IL or missing references)
51824 //IL_051e: Unknown result type (might be due to invalid IL or missing references)
51825 //IL_0541: Unknown result type (might be due to invalid IL or missing references)
51826 //IL_0546: Unknown result type (might be due to invalid IL or missing references)
51827 //IL_054a: Unknown result type (might be due to invalid IL or missing references)
51828 //IL_054f: Unknown result type (might be due to invalid IL or missing references)
51829 //IL_0553: Unknown result type (might be due to invalid IL or missing references)
51830 //IL_055d: Unknown result type (might be due to invalid IL or missing references)
51831 //IL_0562: Unknown result type (might be due to invalid IL or missing references)
51832 //IL_027b: Unknown result type (might be due to invalid IL or missing references)
51833 //IL_028d: Unknown result type (might be due to invalid IL or missing references)
51834 //IL_0292: Unknown result type (might be due to invalid IL or missing references)
51835 //IL_01c5: Unknown result type (might be due to invalid IL or missing references)
51836 //IL_01d7: Unknown result type (might be due to invalid IL or missing references)
51837 //IL_01dc: Unknown result type (might be due to invalid IL or missing references)
51838 //IL_074b: Unknown result type (might be due to invalid IL or missing references)
51839 //IL_074d: Unknown result type (might be due to invalid IL or missing references)
51840 //IL_0752: Unknown result type (might be due to invalid IL or missing references)
51841 //IL_0756: Unknown result type (might be due to invalid IL or missing references)
51842 //IL_075b: Unknown result type (might be due to invalid IL or missing references)
51843 //IL_0768: Unknown result type (might be due to invalid IL or missing references)
51844 //IL_0775: Unknown result type (might be due to invalid IL or missing references)
51845 //IL_077f: Unknown result type (might be due to invalid IL or missing references)
51846 //IL_0784: Unknown result type (might be due to invalid IL or missing references)
51847 //IL_0789: Unknown result type (might be due to invalid IL or missing references)
51848 //IL_0578: Unknown result type (might be due to invalid IL or missing references)
51849 //IL_058b: Unknown result type (might be due to invalid IL or missing references)
51850 //IL_0590: Unknown result type (might be due to invalid IL or missing references)
51851 //IL_080f: Unknown result type (might be due to invalid IL or missing references)
51852 //IL_0832: Unknown result type (might be due to invalid IL or missing references)
51853 //IL_0837: Unknown result type (might be due to invalid IL or missing references)
51854 //IL_079e: Unknown result type (might be due to invalid IL or missing references)
51855 //IL_07b0: Unknown result type (might be due to invalid IL or missing references)
51856 //IL_07b5: Unknown result type (might be due to invalid IL or missing references)
51857 Player player = Main.player[owner];
51859 if (type == 759)
51860 {
51861 if (player.dead)
51862 {
51863 player.babyBird = false;
51864 }
51865 if (player.babyBird)
51866 {
51867 timeLeft = 2;
51868 }
51870 if (totalIndexesInGroup >= 6)
51871 {
51872 frameCounter = 0;
51874 if (totalIndexesInGroup >= Main.projFrames[type] - 1)
51875 {
51876 frame = 0;
51877 }
51878 }
51879 }
51880 float num = 6f;
51881 float num4 = 8f;
51882 int num5 = 800;
51883 float num6 = 150f;
51884 int attackTarget = -1;
51886 if (attackTarget != -1)
51887 {
51888 NPC nPC = Main.npc[attackTarget];
51889 if (player.Distance(nPC.Center) > (float)num5)
51890 {
51891 attackTarget = -1;
51892 }
51893 }
51894 if (attackTarget != -1)
51895 {
51896 if (!Collision.SolidCollision(position, width, height))
51897 {
51898 tileCollide = true;
51899 }
51900 NPC nPC2 = Main.npc[attackTarget];
51901 float num7 = Distance(nPC2.Center);
51902 Rectangle rectangle = default(Rectangle);
51903 ((Rectangle)(ref rectangle))._002Ector((int)position.X, (int)position.Y, width, height);
51904 Rectangle value = default(Rectangle);
51905 ((Rectangle)(ref value))._002Ector((int)nPC2.position.X, (int)nPC2.position.Y, nPC2.width, nPC2.height);
51906 if (((Rectangle)(ref rectangle)).Intersects(value))
51907 {
51908 tileCollide = false;
51909 if (Math.Abs(velocity.X) + Math.Abs(velocity.Y) < num4)
51910 {
51911 velocity *= 1.1f;
51912 }
51913 if (((Vector2)(ref velocity)).Length() > num4)
51914 {
51915 velocity *= num4 / ((Vector2)(ref velocity)).Length();
51916 }
51917 }
51918 else if (num7 > num6)
51919 {
51920 Vector2 vector = DirectionTo(nPC2.Center);
51921 velocity = Vector2.Lerp(velocity, vector * num, 0.15f);
51922 }
51923 else
51924 {
51925 tileCollide = false;
51926 Vector2 vector2 = DirectionTo(nPC2.Center);
51927 velocity += new Vector2((float)Math.Sign(vector2.X), (float)Math.Sign(vector2.Y)) * 0.35f;
51928 if (((Vector2)(ref velocity)).Length() > num4)
51929 {
51930 velocity *= num4 / ((Vector2)(ref velocity)).Length();
51931 }
51932 }
51933 float num8 = 0.025f;
51934 float num9 = width * 3;
51935 for (int i = 0; i < 1000; i++)
51936 {
51937 if (i != whoAmI && Main.projectile[i].active && Main.projectile[i].owner == owner && Main.projectile[i].type == type && Math.Abs(position.X - Main.projectile[i].position.X) + Math.Abs(position.Y - Main.projectile[i].position.Y) < num9)
51938 {
51939 if (position.X < Main.projectile[i].position.X)
51940 {
51941 velocity.X -= num8;
51942 }
51943 else
51944 {
51945 velocity.X += num8;
51946 }
51947 if (position.Y < Main.projectile[i].position.Y)
51948 {
51949 velocity.Y -= num8;
51950 }
51951 else
51952 {
51953 velocity.Y += num8;
51954 }
51955 }
51956 }
51957 rotation = velocity.X * 0.1f;
51958 direction = ((velocity.X > 0f) ? 1 : (-1));
51959 spriteDirection = ((velocity.X > 0f) ? 1 : (-1));
51960 return;
51961 }
51962 tileCollide = false;
51966 localAI[0] = index;
51967 Vector2 vector3 = AI_158_GetHomeLocation(player, index);
51968 float num10 = Distance(vector3);
51969 bool flag = player.gravDir > 0f && player.fullRotation == 0f && player.headRotation == 0f;
51970 if (num10 > 2000f)
51971 {
51972 base.Center = vector3;
51973 frame = Main.projFrames[type] - 1;
51974 frameCounter = 0;
51975 velocity = Vector2.Zero;
51976 direction = (spriteDirection = player.direction);
51977 rotation = 0f;
51978 }
51979 else if (num10 > 40f)
51980 {
51981 float num11 = num + num10 * 0.006f;
51982 Vector2 vector4 = DirectionTo(vector3);
51983 vector4 *= MathHelper.Lerp(1f, 5f, Utils.GetLerpValue(40f, 800f, num10, clamped: true));
51984 velocity = Vector2.Lerp(velocity, vector4 * num11, 0.025f);
51985 if (((Vector2)(ref velocity)).Length() > num11)
51986 {
51987 velocity *= num11 / ((Vector2)(ref velocity)).Length();
51988 }
51989 float num2 = 0.05f;
51990 float num3 = width;
51991 for (int j = 0; j < 1000; j++)
51992 {
51993 if (j != whoAmI && Main.projectile[j].active && Main.projectile[j].owner == owner && Main.projectile[j].type == type && Math.Abs(position.X - Main.projectile[j].position.X) + Math.Abs(position.Y - Main.projectile[j].position.Y) < num3)
51994 {
51995 if (position.X < Main.projectile[j].position.X)
51996 {
51997 velocity.X -= num2;
51998 }
51999 else
52000 {
52001 velocity.X += num2;
52002 }
52003 if (position.Y < Main.projectile[j].position.Y)
52004 {
52005 velocity.Y -= num2;
52006 }
52007 else
52008 {
52009 velocity.Y += num2;
52010 }
52011 }
52012 }
52013 rotation = velocity.X * 0.04f;
52014 direction = ((velocity.X > 0f) ? 1 : (-1));
52015 spriteDirection = ((velocity.X > 0f) ? 1 : (-1));
52016 }
52017 else if (num10 > 8f + ((Vector2)(ref player.velocity)).Length())
52018 {
52019 Vector2 vector5 = DirectionTo(vector3);
52020 velocity += new Vector2((float)Math.Sign(vector5.X), (float)Math.Sign(vector5.Y)) * 0.05f;
52021 if (((Vector2)(ref velocity)).Length() > num)
52022 {
52023 velocity *= num / ((Vector2)(ref velocity)).Length();
52024 }
52025 rotation = velocity.X * 0.1f;
52026 direction = ((velocity.X > 0f) ? 1 : (-1));
52027 spriteDirection = ((velocity.X > 0f) ? 1 : (-1));
52028 }
52029 else if (flag)
52030 {
52031 base.Center = vector3;
52032 frame = Main.projFrames[type] - 1;
52033 frameCounter = 0;
52034 velocity = Vector2.Zero;
52035 direction = (spriteDirection = player.direction);
52036 rotation = 0f;
52037 }
52038 }
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Definition Entity.cs:16
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 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
Vector2 DirectionTo(Vector2 Destination)
Definition Entity.cs:289
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
int owner
The index of the player who owns this projectile. In Multiplayer, Clients "own" projectiles that they...
float[] localAI
Acts like F:Terraria.Projectile.ai, but does not sync to the server. Many vanilla T:Terraria....
void Minion_FindTargetInRange(int startAttackRange, ref int attackTarget, bool skipIfCannotHitWithOwnBody, Func< Entity, int, bool > customEliminationCheck=null)
int frame
The frame number in the spritesheet that this projectile will be drawn with. Assign in M:Terraria....
static Vector2 AI_158_GetHomeLocation(Player master, int stackedIndex)
int type
The Projectile ID of this projectile. The Projectile ID is a unique number assigned to each Projectil...
bool tileCollide
If true, the projectile will collide with tiles, usually bouncing or killing the tile depending on M:...
int timeLeft
Time in ticks before this projectile will naturally despawn. Each update timeLeft is decreased by 1...
float rotation
Rotation of the projectile. Radians not Degrees. Use T:Microsoft.Xna.Framework.MathHelper if you want...
void AI_GetMyGroupIndexAndFillBlackList(List< int > blackListedTargets, out int index, out int totalIndexesInGroup)
static List< int > _ai158_blacklistedTargets
int frameCounter
Used as a timer to decide when to change F:Terraria.Projectile.frame. Defaults to 0.

References Terraria.Player.babyBird, Terraria.Player.dead, Terraria.Entity.direction, Terraria.Entity.Distance(), Terraria.Utils.GetLerpValue(), Terraria.Main.npc, Terraria.Main.player, Terraria.Main.projectile, Terraria.Main.projFrames, Terraria.Collision.SolidCollision(), and Terraria.Entity.velocity.

+ Here is the call graph for this function: