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

◆ FishingCheck()

void Terraria.Projectile.FishingCheck ( )
inline

Definition at line 19511 of file Projectile.cs.

19512 {
19513 //IL_0055: Unknown result type (might be due to invalid IL or missing references)
19514 //IL_006e: Unknown result type (might be due to invalid IL or missing references)
19515 //IL_0014: Unknown result type (might be due to invalid IL or missing references)
19516 //IL_0036: Unknown result type (might be due to invalid IL or missing references)
19517 //IL_003d: Unknown result type (might be due to invalid IL or missing references)
19518 //IL_067f: Unknown result type (might be due to invalid IL or missing references)
19519 //IL_06ca: Unknown result type (might be due to invalid IL or missing references)
19520 //IL_06cf: Unknown result type (might be due to invalid IL or missing references)
19521 //IL_074f: Unknown result type (might be due to invalid IL or missing references)
19522 if (Main.player[owner].wet && !(base.Center.Y >= Main.player[owner].RotatedRelativePoint(Main.player[owner].MountedCenter).Y))
19523 {
19524 return;
19525 }
19527 fisher.X = (int)(base.Center.X / 16f);
19528 fisher.Y = (int)(base.Center.Y / 16f);
19529 fisher.bobberType = type;
19530 GetFishingPondState(fisher.X, fisher.Y, out fisher.inLava, out fisher.inHoney, out fisher.waterTilesCount, out fisher.chumsInWater);
19531 if (Main.notTheBeesWorld && Main.rand.Next(2) == 0)
19532 {
19533 fisher.inHoney = false;
19534 }
19535 if (fisher.waterTilesCount < 75)
19536 {
19537 Main.player[owner].displayedFishingInfo = Language.GetTextValue("GameUI.NotEnoughWater");
19538 return;
19539 }
19540 fisher.playerFishingConditions = Main.player[owner].GetFishingConditions();
19541 if (fisher.playerFishingConditions.BaitItemType == 2673)
19542 {
19543 Main.player[owner].displayedFishingInfo = Language.GetTextValue("GameUI.FishingWarning");
19544 if ((fisher.X < 380 || fisher.X > Main.maxTilesX - 380) && fisher.waterTilesCount > 1000 && !NPC.AnyNPCs(370))
19545 {
19546 ai[1] = Main.rand.Next(-180, -60) - 100;
19547 localAI[1] = 1f;
19548 netUpdate = true;
19549 }
19550 return;
19551 }
19552 fisher.fishingLevel = fisher.playerFishingConditions.FinalFishingLevel;
19553 if (fisher.fishingLevel == 0)
19554 {
19555 return;
19556 }
19557 fisher.CanFishInLava = ItemID.Sets.CanFishInLava[fisher.playerFishingConditions.PoleItemType] || ItemID.Sets.IsLavaBait[fisher.playerFishingConditions.BaitItemType] || Main.player[owner].accLavaFishing;
19558 if (fisher.chumsInWater > 0)
19559 {
19560 fisher.fishingLevel += 11;
19561 }
19562 if (fisher.chumsInWater > 1)
19563 {
19564 fisher.fishingLevel += 6;
19565 }
19566 if (fisher.chumsInWater > 2)
19567 {
19568 fisher.fishingLevel += 3;
19569 }
19570 Main.player[owner].displayedFishingInfo = Language.GetTextValue("GameUI.FishingPower", fisher.fishingLevel);
19571 fisher.waterNeededToFish = 300;
19572 float num = (float)Main.maxTilesX / 4200f;
19573 num *= num;
19574 fisher.atmo = (float)((double)(position.Y / 16f - (60f + 10f * num)) / (Main.worldSurface / 6.0));
19575 if ((double)fisher.atmo < 0.25)
19576 {
19577 fisher.atmo = 0.25f;
19578 }
19579 if (fisher.atmo > 1f)
19580 {
19581 fisher.atmo = 1f;
19582 }
19583 fisher.waterNeededToFish = (int)((float)fisher.waterNeededToFish * fisher.atmo);
19584 fisher.waterQuality = (float)fisher.waterTilesCount / (float)fisher.waterNeededToFish;
19585 if (fisher.waterQuality < 1f)
19586 {
19587 fisher.fishingLevel = (int)((float)fisher.fishingLevel * fisher.waterQuality);
19588 }
19589 fisher.waterQuality = 1f - fisher.waterQuality;
19590 if (fisher.waterTilesCount < fisher.waterNeededToFish)
19591 {
19592 Main.player[owner].displayedFishingInfo = Language.GetTextValue("GameUI.FullFishingPower", fisher.fishingLevel, 0.0 - Math.Round(fisher.waterQuality * 100f));
19593 }
19594 if (Main.player[owner].luck < 0f)
19595 {
19596 if (Main.rand.NextFloat() < 0f - Main.player[owner].luck)
19597 {
19598 fisher.fishingLevel = (int)((double)fisher.fishingLevel * (0.9 - (double)Main.rand.NextFloat() * 0.3));
19599 }
19600 }
19601 else if (Main.rand.NextFloat() < Main.player[owner].luck)
19602 {
19603 fisher.fishingLevel = (int)((double)fisher.fishingLevel * (1.1 + (double)Main.rand.NextFloat() * 0.3));
19604 }
19605 int num2 = (fisher.fishingLevel + 75) / 2;
19606 if (Main.rand.Next(100) > num2)
19607 {
19608 return;
19609 }
19610 fisher.heightLevel = 0;
19611 if (Main.remixWorld)
19612 {
19613 if ((double)fisher.Y < Main.worldSurface * 0.5)
19614 {
19615 fisher.heightLevel = 0;
19616 }
19617 else if ((double)fisher.Y < Main.worldSurface)
19618 {
19619 fisher.heightLevel = 1;
19620 }
19621 else if ((double)fisher.Y < Main.rockLayer)
19622 {
19623 fisher.heightLevel = 3;
19624 }
19625 else if (fisher.Y < Main.maxTilesY - 300)
19626 {
19627 fisher.heightLevel = 2;
19628 }
19629 else
19630 {
19631 fisher.heightLevel = 4;
19632 }
19633 if (fisher.heightLevel == 2 && Main.rand.Next(2) == 0)
19634 {
19635 fisher.heightLevel = 1;
19636 }
19637 }
19638 else if ((double)fisher.Y < Main.worldSurface * 0.5)
19639 {
19640 fisher.heightLevel = 0;
19641 }
19642 else if ((double)fisher.Y < Main.worldSurface)
19643 {
19644 fisher.heightLevel = 1;
19645 }
19646 else if ((double)fisher.Y < Main.rockLayer)
19647 {
19648 fisher.heightLevel = 2;
19649 }
19650 else if (fisher.Y < Main.maxTilesY - 300)
19651 {
19652 fisher.heightLevel = 3;
19653 }
19654 else
19655 {
19656 fisher.heightLevel = 4;
19657 }
19658 FishingCheck_RollDropLevels(fisher.fishingLevel, out fisher.common, out fisher.uncommon, out fisher.rare, out fisher.veryrare, out fisher.legendary, out fisher.crate);
19663 bool flag = false;
19664 AdvancedPopupRequest sonar = default(AdvancedPopupRequest);
19665 Vector2 sonarPosition = default(Vector2);
19666 ((Vector2)(ref sonarPosition))._002Ector(position.X, position.Y);
19667 PlayerLoader.CatchFish(Main.player[owner], fisher, ref fisher.rolledItemDrop, ref fisher.rolledEnemySpawn, ref sonar, ref sonarPosition);
19668 if (sonar.Text != null && Main.player[owner].sonarPotion)
19669 {
19670 PopupText.AssignAsSonarText(PopupText.NewText(sonar, sonarPosition));
19671 }
19672 if (fisher.rolledItemDrop > 0)
19673 {
19674 if (sonar.Text == null && Main.player[owner].sonarPotion)
19675 {
19676 Item item = new Item();
19677 item.SetDefaults(fisher.rolledItemDrop);
19678 item.position = position;
19679 PopupText.AssignAsSonarText(PopupText.NewText(PopupTextContext.SonarAlert, item, 1, noStack: true));
19680 }
19681 float num3 = fisher.fishingLevel;
19682 ai[1] = (float)Main.rand.Next(-240, -90) - num3;
19683 localAI[1] = fisher.rolledItemDrop;
19684 netUpdate = true;
19685 flag = true;
19686 }
19687 if (fisher.rolledEnemySpawn > 0)
19688 {
19689 if (sonar.Text == null && Main.player[owner].sonarPotion)
19690 {
19691 PopupText.AssignAsSonarText(PopupText.NewText(PopupTextContext.SonarAlert, fisher.rolledEnemySpawn, base.Center, stay5TimesLonger: false));
19692 }
19693 float num4 = fisher.fishingLevel;
19694 ai[1] = (float)Main.rand.Next(-240, -90) - num4;
19695 localAI[1] = -fisher.rolledEnemySpawn;
19696 netUpdate = true;
19697 flag = true;
19698 }
19699 if (!flag && fisher.inLava)
19700 {
19701 int num5 = 0;
19702 if (ItemID.Sets.IsLavaBait[fisher.playerFishingConditions.BaitItemType])
19703 {
19704 num5++;
19705 }
19706 if (ItemID.Sets.CanFishInLava[fisher.playerFishingConditions.PoleItemType])
19707 {
19708 num5++;
19709 }
19710 if (Main.player[owner].accLavaFishing)
19711 {
19712 num5++;
19713 }
19714 if (num5 >= 2)
19715 {
19716 localAI[1] += 240f;
19717 }
19718 }
19719 if (fisher.CanFishInLava && fisher.inLava)
19720 {
19722 }
19723 }
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
static void HandleSpecialEvent(Player player, int eventID)
static bool[] CanFishInLava
If true for a given item type (F:Terraria.Item.type), then fishing rods (F:Terraria....
Definition ItemID.cs:1268
static bool[] IsLavaBait
If true for a given item type (F:Terraria.Item.type), then bait (F:Terraria.Item.bait > 0) of that ty...
Definition ItemID.cs:1275
static string GetTextValue(string key)
Retrieves the text value for a specified localization key. The text returned will be for the currentl...
Definition Language.cs:35
Contains methods to access or retrieve localization values. The Localization Guideteaches more about ...
Definition Language.cs:12
static void ModifyFishingAttempt(Player player, ref FishingAttempt attempt)
static void CatchFish(Player player, FishingAttempt attempt, ref int itemDrop, ref int enemySpawn, ref AdvancedPopupRequest sonar, ref Vector2 sonarPosition)
This is where all ModPlayer hooks are gathered and called.
void FishingCheck_RollDropLevels(int fishingLevel, out bool common, out bool uncommon, out bool rare, out bool veryrare, out bool legendary, out bool crate)
int owner
The index of the player who owns this projectile. In Multiplayer, Clients "own" projectiles that they...
static void GetFishingPondState(int x, int y, out bool lava, out bool honey, out int numWaters, out int chumCount)
float[] ai
An array with 3 slots used for any sort of data storage, which is occasionally synced to the server....
bool netUpdate
Set manually to true in M:Terraria.ModLoader.ModProjectile.AI once to make it sync its current F:Terr...
float[] localAI
Acts like F:Terraria.Projectile.ai, but does not sync to the server. Many vanilla T:Terraria....
void FishingCheck_RollItemDrop(ref FishingAttempt fisher)
int type
The Projectile ID of this projectile. The Projectile ID is a unique number assigned to each Projectil...
void FishingCheck_ProbeForQuestFish(ref FishingAttempt fisher)
void FishingCheck_RollEnemySpawns(ref FishingAttempt fisher)

References Terraria.Projectile.ai, Terraria.NPC.AnyNPCs(), Terraria.PopupText.AssignAsSonarText(), Terraria.ID.ItemID.Sets.CanFishInLava, Terraria.ModLoader.PlayerLoader.CatchFish(), Terraria.Projectile.FishingCheck_ProbeForQuestFish(), Terraria.Projectile.FishingCheck_RollDropLevels(), Terraria.Projectile.FishingCheck_RollEnemySpawns(), Terraria.Projectile.FishingCheck_RollItemDrop(), Terraria.Projectile.GetFishingPondState(), Terraria.Localization.Language.GetTextValue(), Terraria.GameContent.Achievements.AchievementsHelper.HandleSpecialEvent(), Terraria.ID.ItemID.Sets.IsLavaBait, Terraria.Projectile.localAI, Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.ModLoader.PlayerLoader.ModifyFishingAttempt(), Terraria.Projectile.netUpdate, Terraria.PopupText.NewText(), Terraria.Main.notTheBeesWorld, Terraria.Projectile.owner, Terraria.Main.player, Terraria.Entity.position, Terraria.Main.rand, Terraria.Main.remixWorld, Terraria.Main.rockLayer, Terraria.Item.SetDefaults(), Terraria.AdvancedPopupRequest.Text, Terraria.Projectile.type, and Terraria.Main.worldSurface.

+ Here is the call graph for this function: