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

◆ AI_158_BabyBird()

void Terraria.Projectile.AI_158_BabyBird ( )
inlineprivate

Definition at line 40076 of file Projectile.cs.

40077 {
40078 Player player = Main.player[owner];
40079 if (type == 759)
40080 {
40081 if (player.dead)
40082 {
40083 player.babyBird = false;
40084 }
40085 if (player.babyBird)
40086 {
40087 timeLeft = 2;
40088 }
40089 if (++frameCounter >= 6)
40090 {
40091 frameCounter = 0;
40092 if (++frame >= Main.projFrames[type] - 1)
40093 {
40094 frame = 0;
40095 }
40096 }
40097 }
40098 float num = 6f;
40099 float num2 = 8f;
40100 int num3 = 800;
40101 float num4 = 150f;
40102 int attackTarget = -1;
40104 if (attackTarget != -1)
40105 {
40106 NPC nPC = Main.npc[attackTarget];
40107 if (player.Distance(nPC.Center) > (float)num3)
40108 {
40109 attackTarget = -1;
40110 }
40111 }
40112 if (attackTarget != -1)
40113 {
40114 if (!Collision.SolidCollision(position, width, height))
40115 {
40116 tileCollide = true;
40117 }
40118 NPC nPC2 = Main.npc[attackTarget];
40119 float num5 = Distance(nPC2.Center);
40121 Rectangle value = new Rectangle((int)nPC2.position.X, (int)nPC2.position.Y, nPC2.width, nPC2.height);
40122 if (rectangle.Intersects(value))
40123 {
40124 tileCollide = false;
40125 if (Math.Abs(velocity.X) + Math.Abs(velocity.Y) < num2)
40126 {
40127 velocity *= 1.1f;
40128 }
40129 if (velocity.Length() > num2)
40130 {
40132 }
40133 }
40134 else if (num5 > num4)
40135 {
40136 Vector2 vector = DirectionTo(nPC2.Center);
40137 velocity = Vector2.Lerp(velocity, vector * num, 0.15f);
40138 }
40139 else
40140 {
40141 tileCollide = false;
40142 Vector2 vector2 = DirectionTo(nPC2.Center);
40143 velocity += new Vector2(Math.Sign(vector2.X), Math.Sign(vector2.Y)) * 0.35f;
40144 if (velocity.Length() > num2)
40145 {
40147 }
40148 }
40149 float num6 = 0.025f;
40150 float num7 = width * 3;
40151 for (int i = 0; i < 1000; i++)
40152 {
40153 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) < num7)
40154 {
40155 if (position.X < Main.projectile[i].position.X)
40156 {
40157 velocity.X -= num6;
40158 }
40159 else
40160 {
40161 velocity.X += num6;
40162 }
40163 if (position.Y < Main.projectile[i].position.Y)
40164 {
40165 velocity.Y -= num6;
40166 }
40167 else
40168 {
40169 velocity.Y += num6;
40170 }
40171 }
40172 }
40173 rotation = velocity.X * 0.1f;
40174 direction = ((velocity.X > 0f) ? 1 : (-1));
40175 spriteDirection = ((velocity.X > 0f) ? 1 : (-1));
40176 return;
40177 }
40178 tileCollide = false;
40182 localAI[0] = index;
40184 float num8 = Distance(vector3);
40185 bool flag = player.gravDir > 0f && player.fullRotation == 0f && player.headRotation == 0f;
40186 if (num8 > 2000f)
40187 {
40188 base.Center = vector3;
40189 frame = Main.projFrames[type] - 1;
40190 frameCounter = 0;
40192 direction = (spriteDirection = player.direction);
40193 rotation = 0f;
40194 }
40195 else if (num8 > 40f)
40196 {
40197 float num9 = num + num8 * 0.006f;
40199 vector4 *= MathHelper.Lerp(1f, 5f, Utils.GetLerpValue(40f, 800f, num8, clamped: true));
40200 velocity = Vector2.Lerp(velocity, vector4 * num9, 0.025f);
40201 if (velocity.Length() > num9)
40202 {
40204 }
40205 float num10 = 0.05f;
40206 float num11 = width;
40207 for (int j = 0; j < 1000; j++)
40208 {
40209 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) < num11)
40210 {
40211 if (position.X < Main.projectile[j].position.X)
40212 {
40213 velocity.X -= num10;
40214 }
40215 else
40216 {
40217 velocity.X += num10;
40218 }
40219 if (position.Y < Main.projectile[j].position.Y)
40220 {
40221 velocity.Y -= num10;
40222 }
40223 else
40224 {
40225 velocity.Y += num10;
40226 }
40227 }
40228 }
40229 rotation = velocity.X * 0.04f;
40230 direction = ((velocity.X > 0f) ? 1 : (-1));
40231 spriteDirection = ((velocity.X > 0f) ? 1 : (-1));
40232 }
40233 else if (num8 > 8f + player.velocity.Length())
40234 {
40236 velocity += new Vector2(Math.Sign(vector5.X), Math.Sign(vector5.Y)) * 0.05f;
40237 if (velocity.Length() > num)
40238 {
40239 velocity *= num / velocity.Length();
40240 }
40241 rotation = velocity.X * 0.1f;
40242 direction = ((velocity.X > 0f) ? 1 : (-1));
40243 spriteDirection = ((velocity.X > 0f) ? 1 : (-1));
40244 }
40245 else if (flag)
40246 {
40247 base.Center = vector3;
40248 frame = Main.projFrames[type] - 1;
40249 frameCounter = 0;
40251 direction = (spriteDirection = player.direction);
40252 rotation = 0f;
40253 }
40254 }
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
static double Abs(double value)
static int Sign(decimal value)
Definition Math.cs:1202
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
void Minion_FindTargetInRange(int startAttackRange, ref int attackTarget, bool skipIfCannotHitWithOwnBody, Func< Entity, int, bool > customEliminationCheck=null)
static Vector2 AI_158_GetHomeLocation(Player master, int stackedIndex)
void AI_GetMyGroupIndexAndFillBlackList(List< int > blackListedTargets, out int index, out int totalIndexesInGroup)
static List< int > _ai158_blacklistedTargets
static Vector2 Lerp(Vector2 value1, Vector2 value2, float amount)
Definition Vector2.cs:227

References System.Math.Abs(), Terraria.Player.babyBird, System.Collections.Generic.Dictionary< TKey, TValue >.Clear(), Terraria.Player.dead, Terraria.Entity.direction, Terraria.Entity.Distance(), Terraria.Utils.GetLerpValue(), System.index, Microsoft.Xna.Framework.Vector2.Length(), Microsoft.Xna.Framework.MathHelper.Lerp(), Microsoft.Xna.Framework.Vector2.Lerp(), Terraria.Main.npc, Terraria.Main.player, Terraria.Main.projectile, Terraria.Main.projFrames, System.Math.Sign(), Terraria.Collision.SolidCollision(), System.type, System.value, Terraria.Entity.velocity, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.