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

◆ AI_061_FishingBobber()

void Terraria.Projectile.AI_061_FishingBobber ( )
inlineprivate

Definition at line 43831 of file Projectile.cs.

43832 {
43833 Player player = Main.player[owner];
43834 bool flag = type >= 986 && type <= 993;
43835 timeLeft = 60;
43836 bool flag2 = false;
43837 if (player.inventory[player.selectedItem].fishingPole == 0 || player.CCed || player.noItems)
43838 {
43839 flag2 = true;
43840 }
43841 else if (player.inventory[player.selectedItem].shoot != type && !flag)
43842 {
43843 flag2 = true;
43844 }
43845 else if (player.pulley)
43846 {
43847 flag2 = true;
43848 }
43849 else if (player.dead)
43850 {
43851 flag2 = true;
43852 }
43853 if (flag2)
43854 {
43855 Kill();
43856 return;
43857 }
43858 if (ai[1] > 0f && localAI[1] != 0f)
43859 {
43860 localAI[1] = 0f;
43861 if (!lavaWet && !honeyWet)
43862 {
43864 }
43865 }
43866 if (ai[0] >= 1f)
43867 {
43868 if (ai[0] == 2f)
43869 {
43870 ai[0] += 1f;
43872 if (!lavaWet && !honeyWet)
43873 {
43875 }
43876 }
43877 if (localAI[0] < 100f)
43878 {
43879 localAI[0] += 1f;
43880 }
43881 if (frameCounter == 0)
43882 {
43883 frameCounter = 1;
43885 }
43886 tileCollide = false;
43887 int num = 10;
43888 Vector2 vector = new Vector2(position.X + (float)width * 0.5f, position.Y + (float)height * 0.5f);
43889 float num2 = player.position.X + (float)(player.width / 2) - vector.X;
43890 float num3 = player.position.Y + (float)(player.height / 2) - vector.Y;
43891 float num4 = (float)Math.Sqrt(num2 * num2 + num3 * num3);
43892 if (num4 > 3000f)
43893 {
43894 Kill();
43895 }
43896 num4 = 15.9f / num4;
43897 num2 *= num4;
43898 num3 *= num4;
43899 velocity.X = (velocity.X * (float)(num - 1) + num2) / (float)num;
43900 velocity.Y = (velocity.Y * (float)(num - 1) + num3) / (float)num;
43901 rotation = (float)Math.Atan2(velocity.Y, velocity.X) + 1.57f;
43902 if (Main.myPlayer == owner && base.Hitbox.Intersects(player.Hitbox))
43903 {
43904 Kill();
43905 }
43906 return;
43907 }
43908 bool flag3 = false;
43909 Vector2 vector2 = new Vector2(position.X + (float)width * 0.5f, position.Y + (float)height * 0.5f);
43910 float num5 = player.position.X + (float)(player.width / 2) - vector2.X;
43911 float num6 = player.position.Y + (float)(player.height / 2) - vector2.Y;
43912 rotation = (float)Math.Atan2(num6, num5) + 1.57f;
43913 if ((float)Math.Sqrt(num5 * num5 + num6 * num6) > 900f)
43914 {
43915 ai[0] = 1f;
43916 }
43917 if (wet)
43918 {
43919 if (shimmerWet)
43920 {
43921 if (Main.myPlayer == owner)
43922 {
43923 Main.player[owner].AddBuff(353, 60);
43924 }
43925 if (localAI[2] == 0f)
43926 {
43927 localAI[2] = 1f;
43928 SoundEngine.PlaySound(19, (int)Main.player[owner].position.X, (int)Main.player[owner].position.Y, 2);
43929 }
43930 }
43931 rotation = 0f;
43932 velocity.X *= 0.9f;
43933 int num7 = (int)(base.Center.X + (float)((width / 2 + 8) * direction)) / 16;
43934 int num8 = (int)(base.Center.Y / 16f);
43935 _ = position.Y / 16f;
43936 int num9 = (int)((position.Y + (float)height) / 16f);
43937 if (Main.tile[num7, num8] == null)
43938 {
43939 Main.tile[num7, num8] = new Tile();
43940 }
43941 if (Main.tile[num7, num9] == null)
43942 {
43943 Main.tile[num7, num9] = new Tile();
43944 }
43945 if (velocity.Y > 0f)
43946 {
43947 velocity.Y *= 0.5f;
43948 }
43949 num7 = (int)(base.Center.X / 16f);
43950 num8 = (int)(base.Center.Y / 16f);
43952 if (base.Center.Y > num10)
43953 {
43954 velocity.Y -= 0.1f;
43955 if (velocity.Y < -8f)
43956 {
43957 velocity.Y = -8f;
43958 }
43959 if (base.Center.Y + velocity.Y < num10)
43960 {
43961 velocity.Y = num10 - base.Center.Y;
43962 }
43963 }
43964 else
43965 {
43966 velocity.Y = num10 - base.Center.Y;
43967 }
43968 if ((double)velocity.Y >= -0.01 && (double)velocity.Y <= 0.01)
43969 {
43970 flag3 = true;
43971 }
43972 }
43973 else
43974 {
43975 if (velocity.Y == 0f)
43976 {
43977 velocity.X *= 0.95f;
43978 }
43979 velocity.X *= 0.98f;
43980 velocity.Y += 0.2f;
43981 if (velocity.Y > 15.9f)
43982 {
43983 velocity.Y = 15.9f;
43984 }
43985 }
43986 if (Main.myPlayer == owner && player.GetFishingConditions().BaitItemType == 2673)
43987 {
43988 player.displayedFishingInfo = Language.GetTextValue("GameUI.FishingWarning");
43989 }
43990 if (ai[1] != 0f)
43991 {
43992 flag3 = true;
43993 }
43994 if (!flag3)
43995 {
43996 return;
43997 }
43998 if (ai[1] == 0f && Main.myPlayer == owner)
43999 {
44000 int finalFishingLevel = player.GetFishingConditions().FinalFishingLevel;
44001 if (Main.rand.Next(300) < finalFishingLevel)
44002 {
44003 localAI[1] += Main.rand.Next(1, 3);
44004 }
44005 localAI[1] += finalFishingLevel / 30;
44006 localAI[1] += Main.rand.Next(1, 3);
44007 if (Main.rand.Next(60) == 0)
44008 {
44009 localAI[1] += 60f;
44010 }
44011 if (localAI[1] > 660f)
44012 {
44013 localAI[1] = 0f;
44014 FishingCheck();
44015 }
44016 }
44017 else if (ai[1] < 0f)
44018 {
44019 if (velocity.Y == 0f || (honeyWet && Math.Abs(velocity.Y) <= 0.01f))
44020 {
44021 velocity.Y = (float)Main.rand.Next(100, 500) * 0.015f;
44022 velocity.X = (float)Main.rand.Next(-100, 101) * 0.015f;
44023 wet = false;
44024 lavaWet = false;
44025 honeyWet = false;
44026 }
44027 ai[1] += Main.rand.Next(1, 5);
44028 if (ai[1] >= 0f)
44029 {
44030 ai[1] = 0f;
44031 localAI[1] = 0f;
44032 netUpdate = true;
44033 }
44034 }
44035 }
static double Atan2(double y, double x)
static double Sqrt(double d)
static double Abs(double value)
static void PlaySound(int type, Vector2 position, int style=1)
bool honeyWet
Definition Entity.cs:34
bool shimmerWet
Definition Entity.cs:32
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
static readonly LegacySoundStyle Item17
Definition SoundID.cs:448
static string GetTextValue(string key)
Definition Language.cs:15
float AI_061_FishingBobber_GetWaterLine(int X, int Y)
void AI_061_FishingBobber_DoASplash()
void ReduceRemainingChumsInPool()

References System.Math.Abs(), System.Math.Atan2(), Terraria.DataStructures.PlayerFishingConditions.BaitItemType, Terraria.Player.CCed, Terraria.Player.dead, Terraria.DataStructures.PlayerFishingConditions.FinalFishingLevel, Terraria.Item.fishingPole, Terraria.Player.GetFishingConditions(), Terraria.Localization.Language.GetTextValue(), Terraria.Entity.height, Terraria.Entity.Hitbox, Terraria.Player.inventory, Terraria.ID.SoundID.Item17, Terraria.Main.myPlayer, Terraria.Player.noItems, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Player.pulley, Terraria.Main.rand, Terraria.Player.selectedItem, Terraria.Item.shoot, System.Math.Sqrt(), Terraria.DataStructures.Tile, Terraria.Main.tile, System.type, Terraria.Entity.width, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.