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

◆ AI_163_Chum()

void Terraria.Projectile.AI_163_Chum ( )
inlineprivate

Definition at line 43645 of file Projectile.cs.

43646 {
43647 float num = 0.05f;
43648 float num2 = width / 2;
43649 for (int i = 0; i < 1000; i++)
43650 {
43651 if (i != whoAmI && Main.projectile[i].active && Main.projectile[i].type == type && Math.Abs(position.X - Main.projectile[i].position.X) + Math.Abs(position.Y - Main.projectile[i].position.Y) < num2)
43652 {
43653 if (position.X < Main.projectile[i].position.X)
43654 {
43655 velocity.X -= num;
43656 }
43657 else
43658 {
43659 velocity.X += num;
43660 }
43661 if (position.Y < Main.projectile[i].position.Y)
43662 {
43663 velocity.Y -= num;
43664 }
43665 else
43666 {
43667 velocity.Y += num;
43668 }
43669 }
43670 }
43671 if (wet)
43672 {
43673 velocity.X *= 0.9f;
43674 int num3 = (int)(base.Center.X + (float)((width / 2 + 8) * direction)) / 16;
43675 int num4 = (int)(base.Center.Y / 16f);
43676 _ = position.Y / 16f;
43677 int num5 = (int)((position.Y + (float)height) / 16f);
43678 if (Main.tile[num3, num4] == null)
43679 {
43680 Main.tile[num3, num4] = new Tile();
43681 }
43682 if (Main.tile[num3, num5] == null)
43683 {
43684 Main.tile[num3, num5] = new Tile();
43685 }
43686 if (velocity.Y > 0f)
43687 {
43688 velocity.Y *= 0.5f;
43689 }
43690 num3 = (int)(base.Center.X / 16f);
43691 num4 = (int)(base.Center.Y / 16f);
43693 if (base.Center.Y > num6)
43694 {
43695 velocity.Y -= 0.1f;
43696 if (velocity.Y < -8f)
43697 {
43698 velocity.Y = -8f;
43699 }
43700 if (base.Center.Y + velocity.Y < num6)
43701 {
43702 velocity.Y = num6 - base.Center.Y;
43703 }
43704 }
43705 else
43706 {
43707 velocity.Y = num6 - base.Center.Y;
43708 }
43709 }
43710 else
43711 {
43712 if (velocity.Y == 0f)
43713 {
43714 velocity.X *= 0.95f;
43715 }
43716 velocity.X *= 0.98f;
43717 velocity.Y += 0.3f;
43718 if (velocity.Y > 15.9f)
43719 {
43720 velocity.Y = 15.9f;
43721 }
43722 }
43723 if (frameCounter == 0)
43724 {
43725 frameCounter = 1;
43726 frame = Main.rand.Next(4);
43727 }
43728 if (frameCounter < 10 && wet)
43729 {
43730 frameCounter++;
43731 for (float num7 = 0f; num7 < 1f; num7 += 0.5f)
43732 {
43733 Gore gore = Gore.NewGoreDirect(position + Vector2.UnitY * 6f, Vector2.Zero, 1201, scale * 0.7f);
43734 gore.velocity = Main.rand.NextVector2CircularEdge(10f, 10f);
43735 if (gore.velocity.Y > 0f)
43736 {
43737 gore.velocity.Y *= -1f;
43738 }
43739 }
43740 for (float num8 = 0f; num8 < 2f; num8 += 1f)
43741 {
43742 Gore gore2 = Gore.NewGoreDirect(position + Vector2.UnitY * 6f, Vector2.Zero, 1208, scale * 0.7f + Main.rand.NextFloat() * 0.15f);
43743 gore2.velocity = Main.rand.NextVector2CircularEdge(4f, 4f);
43744 if (gore2.velocity.Y > 0f)
43745 {
43746 gore2.velocity.Y *= -1f;
43747 }
43748 }
43749 }
43750 scale = Utils.GetLerpValue(0f, 60f, timeLeft, clamped: true);
43751 rotation += velocity.X * 0.14f;
43752 bool flag = !wet && velocity.Length() < 0.8f;
43753 int maxValue = (wet ? 90 : 5);
43754 if (Main.rand.Next(maxValue) == 0 && !flag)
43755 {
43756 Gore gore3 = Gore.NewGoreDirect(position + Vector2.UnitY * 6f, Vector2.Zero, 1201, scale * 0.7f);
43757 if (wet)
43758 {
43759 gore3.velocity = Vector2.UnitX * Main.rand.NextFloatDirection() * 0.75f + Vector2.UnitY * Main.rand.NextFloat();
43760 }
43761 else if (gore3.velocity.Y < 0f)
43762 {
43763 gore3.velocity.Y = 0f - gore3.velocity.Y;
43764 }
43765 }
43766 Vector2 spot = base.Center + Vector2.UnitY * 16f;
43767 if (ai[0] >= 10f && timeLeft > 60)
43768 {
43769 timeLeft = 60;
43770 netUpdate = true;
43771 }
43772 if (ai[0] < 10f && timeLeft > 60)
43773 {
43774 Main.instance.ChumBucketProjectileHelper.AddChumLocation(spot);
43775 }
43776 }
static double Abs(double value)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
float AI_061_FishingBobber_GetWaterLine(int X, int Y)

References System.Math.Abs(), Terraria.Utils.GetLerpValue(), Terraria.Main.instance, Terraria.Gore.NewGoreDirect(), Terraria.Main.projectile, Terraria.Main.rand, Terraria.DataStructures.Tile, Terraria.Main.tile, System.type, Microsoft.Xna.Framework.Vector2.UnitY, Terraria.Gore.velocity, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.