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

◆ AI_169_Smolstars()

void Terraria.Projectile.AI_169_Smolstars ( )
inlineprivate

Definition at line 37687 of file Projectile.cs.

37688 {
37689 Player player = Main.player[owner];
37690 bool num = type == 864;
37691 Vector2 vector = player.Top + new Vector2(0f, -30f);
37692 if (num)
37693 {
37694 if (player.dead)
37695 {
37696 player.smolstar = false;
37697 }
37698 if (player.smolstar)
37699 {
37700 timeLeft = 2;
37701 }
37702 if (ai[0] == 0f)
37703 {
37705 float num2 = (float)Math.PI * 2f / (float)totalIndexesInGroup;
37706 float num3 = (float)totalIndexesInGroup * 0.66f;
37707 Vector2 vector2 = new Vector2(30f, 6f) / 5f * (totalIndexesInGroup - 1);
37708 Vector2 vector3 = Vector2.UnitY.RotatedBy(num2 * (float)index + Main.GlobalTimeWrappedHourly % num3 / num3 * ((float)Math.PI * 2f));
37709 vector += vector3 * vector2;
37710 vector.Y += player.gfxOffY;
37711 vector = vector.Floor();
37712 }
37713 }
37714 if (ai[0] == 0f)
37715 {
37716 Vector2 vector4 = vector - base.Center;
37717 float num4 = 10f;
37718 float lerpValue = Utils.GetLerpValue(200f, 600f, vector4.Length(), clamped: true);
37719 num4 += lerpValue * 30f;
37720 if (vector4.Length() >= 3000f)
37721 {
37722 base.Center = vector;
37723 }
37724 velocity = vector4;
37725 if (velocity.Length() > num4)
37726 {
37728 }
37729 int startAttackRange = 800;
37730 int attackTarget = -1;
37732 if (attackTarget != -1)
37733 {
37734 ai[0] = 60f;
37735 ai[1] = attackTarget;
37736 netUpdate = true;
37737 }
37738 float targetAngle = velocity.SafeNormalize(Vector2.UnitY).ToRotation() + (float)Math.PI / 2f;
37739 if (vector4.Length() < 40f)
37740 {
37741 targetAngle = Vector2.UnitY.ToRotation() + (float)Math.PI / 2f;
37742 }
37743 rotation = rotation.AngleLerp(targetAngle, 0.2f);
37744 return;
37745 }
37746 if (ai[0] == -1f)
37747 {
37748 if (ai[1] == 0f)
37749 {
37750 SoundEngine.PlaySound(0, (int)position.X, (int)position.Y);
37751 for (int i = 0; i < 2; i++)
37752 {
37753 Dust dust = Dust.NewDustDirect(position, width, height, 15, oldVelocity.X * 0.2f, oldVelocity.Y * 0.2f, 0, default(Color), 1.4f);
37754 if (Main.rand.Next(3) != 0)
37755 {
37756 dust.scale *= 1.3f;
37757 dust.velocity *= 1.1f;
37758 }
37759 dust.noGravity = true;
37760 dust.fadeIn = 0f;
37761 }
37762 velocity += Main.rand.NextVector2CircularEdge(4f, 4f);
37763 }
37764 ai[1] += 1f;
37765 rotation += velocity.X * 0.1f + velocity.Y * 0.05f;
37766 velocity *= 0.92f;
37767 if (ai[1] >= 9f)
37768 {
37769 ai[0] = 0f;
37770 ai[1] = 0f;
37771 }
37772 return;
37773 }
37774 NPC nPC = null;
37775 int num5 = (int)ai[1];
37776 if (Main.npc.IndexInRange(num5) && Main.npc[num5].CanBeChasedBy(this))
37777 {
37778 nPC = Main.npc[num5];
37779 }
37780 if (nPC == null)
37781 {
37782 ai[0] = -1f;
37783 ai[1] = 0f;
37784 netUpdate = true;
37785 }
37786 else if (player.Distance(nPC.Center) >= 900f)
37787 {
37788 ai[0] = 0f;
37789 ai[1] = 0f;
37790 netUpdate = true;
37791 }
37792 else
37793 {
37794 Vector2 vector5 = nPC.Center - base.Center;
37795 float num6 = 16f;
37796 velocity = vector5;
37797 if (velocity.Length() > num6)
37798 {
37800 }
37801 float targetAngle2 = velocity.SafeNormalize(Vector2.UnitY).ToRotation() + (float)Math.PI / 2f;
37802 rotation = rotation.AngleLerp(targetAngle2, 0.4f);
37803 }
37804 float num7 = 0.1f;
37805 float num8 = width * 5;
37806 for (int j = 0; j < 1000; j++)
37807 {
37808 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) < num8)
37809 {
37810 if (position.X < Main.projectile[j].position.X)
37811 {
37812 velocity.X -= num7;
37813 }
37814 else
37815 {
37816 velocity.X += num7;
37817 }
37818 if (position.Y < Main.projectile[j].position.Y)
37819 {
37820 velocity.Y -= num7;
37821 }
37822 else
37823 {
37824 velocity.Y += num7;
37825 }
37826 }
37827 }
37828 }
static double Abs(double value)
const double PI
Definition Math.cs:16
static void PlaySound(int type, Vector2 position, int style=1)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
Vector2 oldVelocity
Definition Entity.cs:20
void Minion_FindTargetInRange(int startAttackRange, ref int attackTarget, bool skipIfCannotHitWithOwnBody, Func< Entity, int, bool > customEliminationCheck=null)
void AI_GetMyGroupIndexAndFillBlackList(List< int > blackListedTargets, out int index, out int totalIndexesInGroup)

References System.Math.Abs(), Terraria.Player.dead, Terraria.Entity.Distance(), Terraria.Utils.GetLerpValue(), Terraria.Player.gfxOffY, System.index, Terraria.Dust.NewDustDirect(), Terraria.Main.npc, System.Math.PI, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Main.projectile, Terraria.Main.rand, Terraria.Player.smolstar, System.type, Microsoft.Xna.Framework.Vector2.UnitY, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.