public int GetFishingLevel(Item baitItem) { var item = new Item(); item.SetDefaults(ItemID.MechanicsRod, true); int baitPower = 0; //int fishingPole = 30; int fishingPole = item.fishingPole; //num1 = 15; if (baitItem.type == ItemID.TruffleWorm) { return(-1); } baitPower = baitItem.bait; if (baitPower == 0 || fishingPole == 0) { return(0); } int power = baitPower + fishingPole; if (Main.raining) { power = (int)((double)power * 1.20000004768372); } if ((double)Main.cloudBGAlpha > 0.0) { power = (int)((double)power * 1.10000002384186); } if (Main.dayTime && (Main.time < 5400.0 || Main.time > 48600.0)) { power = (int)((double)power * 1.29999995231628); } if (Main.dayTime && Main.time > 16200.0 && Main.time < 37800.0) { power = (int)((double)power * 0.800000011920929); } if (!Main.dayTime && Main.time > 6480.0 && Main.time < 25920.0) { power = (int)((double)power * 0.800000011920929); } if (Main.moonPhase == 0) { power = (int)((double)power * 1.10000002384186); } if (Main.moonPhase == 1 || Main.moonPhase == 7) { power = (int)((double)power * 1.04999995231628); } if (Main.moonPhase == 3 || Main.moonPhase == 5) { power = (int)((double)power * 0.949999988079071); } if (Main.moonPhase == 4) { power = (int)((double)power * 0.899999976158142); } AutofisherHooks.GetFishingLevel(this, baitItem, ref power); return(power); }
public int FishingCheck(bool catchRealFish) { var te = (AutofisherTE)TileEntity.ByID[(int)projectile.ai[1]]; var baitItem = te.GetCurrentBait(); int bobberTileX = (int)(projectile.Center.X / 16.0); int bobberTileY = (int)(projectile.Center.Y / 16.0); if ((int)Main.tile[bobberTileX, bobberTileY].liquid < 0) { ++bobberTileY; } bool lava = false; bool honey = false; int i1 = bobberTileX; int i2 = bobberTileX; while (i1 > 10 && (int)Main.tile[i1, bobberTileY].liquid > 0 && !WorldGen.SolidTile(i1, bobberTileY)) { --i1; } while (i2 < Main.maxTilesX - 10 && (int)Main.tile[i2, bobberTileY].liquid > 0 && !WorldGen.SolidTile(i2, bobberTileY)) { ++i2; } int poolSize = 0; for (int i3 = i1; i3 <= i2; ++i3) { int j2 = bobberTileY; while ((int)Main.tile[i3, j2].liquid > 0 && !WorldGen.SolidTile(i3, j2) && j2 < Main.maxTilesY - 10) { ++poolSize; ++j2; if (Main.tile[i3, j2].lava()) { lava = true; } else if (Main.tile[i3, j2].honey()) { honey = true; } } } if (honey) { poolSize = (int)((double)poolSize * 1.5); } if (poolSize < 75) { if (Main.netMode != NetmodeID.MultiplayerClient) { te.DisplayedFishingInfo = Language.GetTextValue("GameUI.NotEnoughWater"); } } else { int fishingPower = te.GetFishingLevel(baitItem); if (fishingPower == 0) { return(-1); } if (Main.netMode != NetmodeID.MultiplayerClient) { te.DisplayedFishingInfo = Language.GetTextValue("GameUI.FishingPower", (object)fishingPower); } //if(num2 < 0) //{ // if(num2 != -1) // return; // te.DisplayedFishingInfo = Language.GetTextValue("GameUI.FishingWarning"); // if(index >= 380 && index <= Main.maxTilesX - 380 || (num1 <= 1000 || NPC.AnyNPCs(370))) // return; // projectile.ai[1] = (float)(Main.rand.Next(-180, -60) - 100); // projectile.localAI[1] = (float)num2; // projectile.netUpdate = true; //} //else { int num3 = 300; float num4 = (float)(Main.maxTilesX / 4200); float num5 = (float)((projectile.position.Y / 16.0 - (60.0 + 10.0 * (double)(num4 * num4))) / (Main.worldSurface / 6.0)); if ((double)num5 < 0.25) { num5 = 0.25f; } if ((double)num5 > 1.0) { num5 = 1f; } int num6 = (int)((double)num3 * (double)num5); float num7 = (float)poolSize / (float)num6; if ((double)num7 < 1.0) { fishingPower = (int)((double)fishingPower * (double)num7); } float num8 = 1f - num7; if (poolSize < num6 && Main.netMode != NetmodeID.MultiplayerClient) { te.DisplayedFishingInfo = Language.GetTextValue("GameUI.FullFishingPower", (object)fishingPower, (object)-Math.Round((double)num8 * 100.0)); } int num9 = (fishingPower + 75) / 2; if (!catchRealFish) { return(-1); } if (/*Main.player[projectile.owner].wet || */ Main.rand.Next(100) > num9) { return(-1); } int caughtType = 0; int worldLayer = (double)bobberTileY >= Main.worldSurface * 0.5 ? ((double)bobberTileY >= Main.worldSurface ? ((double)bobberTileY >= Main.rockLayer ? (bobberTileY >= Main.maxTilesY - 300 ? 4 : 3) : 2) : 1) : 0; int num12 = 150; int num13 = fishingPower; int maxValue1 = num12 / num13; int num14 = 2; int maxValue2 = num12 * num14 / fishingPower; int num15 = 7; int maxValue3 = num12 * num15 / fishingPower; int num16 = 15; int maxValue4 = num12 * num16 / fishingPower; int num17 = 30; int maxValue5 = num12 * num17 / fishingPower; if (maxValue1 < 2) { maxValue1 = 2; } if (maxValue2 < 3) { maxValue2 = 3; } if (maxValue3 < 4) { maxValue3 = 4; } if (maxValue4 < 5) { maxValue4 = 5; } if (maxValue5 < 6) { maxValue5 = 6; } bool flag3 = false; bool flag4 = false; bool flag5 = false; bool flag6 = false; bool flag7 = false; if (Main.rand.Next(maxValue1) == 0) { flag3 = true; } if (Main.rand.Next(maxValue2) == 0) { flag4 = true; } if (Main.rand.Next(maxValue3) == 0) { flag5 = true; } if (Main.rand.Next(maxValue4) == 0) { flag6 = true; } if (Main.rand.Next(maxValue5) == 0) { flag7 = true; } int num18 = 10; //if(Main.player[projectile.owner].cratePotion) // num18 += 10; int type = -1; var zone = MiscUtils.GetZoneInLocation(te.Position.X, te.Position.Y); bool junk = false; #region Vanilla Fishing Algorithm if (lava) { //if (!ItemID.Sets.CanFishInLava[Main.player[projectile.owner].HeldItem.type]) // return; if (flag7) { caughtType = 2331; } else if (flag6) { caughtType = 2312; } else if (flag5) { caughtType = 2315; } } else if (honey) { if (flag5 || flag4 && Main.rand.Next(2) == 0) { caughtType = 2314; } else if (flag4 && type == 2451) { caughtType = 2451; } } else if (Main.rand.Next(50) > fishingPower && Main.rand.Next(50) > fishingPower && poolSize < num6) { junk = true; caughtType = Main.rand.Next(2337, 2340); } else if (Main.rand.Next(100) < num18) { caughtType = !(flag6 | flag7) ? (!flag5 || !zone.HasFlag(Zone.Corrupt) ? (!flag5 || !zone.HasFlag(Zone.Crimson) ? (!flag5 || !zone.HasFlag(Zone.Holy) ? (!flag5 || !zone.HasFlag(Zone.Dungeon) ? (!flag5 || !zone.HasFlag(Zone.Jungle) ? (!flag5 || worldLayer != 0 ? (!flag4 ? 2334 : 2335) : 3206) : 3208) : 3205) : 3207) : 3204) : 3203) : 2336; } else if (flag7 && Main.rand.Next(5) == 0) { caughtType = 2423; } else if (flag7 && Main.rand.Next(5) == 0) { caughtType = 3225; } else if (flag7 && Main.rand.Next(10) == 0) { caughtType = 2420; } else if (((flag7 ? 0 : (!flag6 ? 1 : 0)) & (flag4 ? 1 : 0)) != 0 && Main.rand.Next(5) == 0) { caughtType = 3196; } else { bool flag8 = zone.HasFlag(Zone.Corrupt); bool flag9 = zone.HasFlag(Zone.Crimson); if (flag8 && flag9) { if (Main.rand.Next(2) == 0) { flag9 = false; } else { flag8 = false; } } if (flag8) { if (flag7 && Main.hardMode && (zone.HasFlag(Zone.Snow) && worldLayer == 3) && Main.rand.Next(3) != 0) { caughtType = 2429; } else if (flag7 && Main.hardMode && Main.rand.Next(2) == 0) { caughtType = 3210; } else if (flag5) { caughtType = 2330; } else if (flag4 && type == 2454) { caughtType = 2454; } else if (flag4 && type == 2485) { caughtType = 2485; } else if (flag4 && type == 2457) { caughtType = 2457; } else if (flag4) { caughtType = 2318; } } else if (flag9) { if (flag7 && Main.hardMode && (zone.HasFlag(Zone.Snow) && worldLayer == 3) && Main.rand.Next(3) != 0) { caughtType = 2429; } else if (flag7 && Main.hardMode && Main.rand.Next(2) == 0) { caughtType = 3211; } else if (flag4 && type == 2477) { caughtType = 2477; } else if (flag4 && type == 2463) { caughtType = 2463; } else if (flag4) { caughtType = 2319; } else if (flag3) { caughtType = 2305; } } else if (zone.HasFlag(Zone.Holy)) { if (flag7 && Main.hardMode && (zone.HasFlag(Zone.Snow) && worldLayer == 3) && Main.rand.Next(3) != 0) { caughtType = 2429; } else if (flag7 && Main.hardMode && Main.rand.Next(2) == 0) { caughtType = 3209; } else if (worldLayer > 1 & flag6) { caughtType = 2317; } else if (worldLayer > 1 & flag5 && type == 2465) { caughtType = 2465; } else if (worldLayer < 2 & flag5 && type == 2468) { caughtType = 2468; } else if (flag5) { caughtType = 2310; } else if (flag4 && type == 2471) { caughtType = 2471; } else if (flag4) { caughtType = 2307; } } if (caughtType == 0 && zone.HasFlag(Zone.Snow)) { if (worldLayer < 2 & flag4 && type == 2467) { caughtType = 2467; } else if (worldLayer == 1 & flag4 && type == 2470) { caughtType = 2470; } else if (worldLayer >= 2 & flag4 && type == 2484) { caughtType = 2484; } else if (worldLayer > 1 & flag4 && type == 2466) { caughtType = 2466; } else if (flag3 && Main.rand.Next(12) == 0 || flag4 && Main.rand.Next(6) == 0) { caughtType = 3197; } else if (flag4) { caughtType = 2306; } else if (flag3) { caughtType = 2299; } else if (worldLayer > 1 && Main.rand.Next(3) == 0) { caughtType = 2309; } } if (caughtType == 0 && zone.HasFlag(Zone.Jungle)) { if (worldLayer == 1 & flag4 && type == 2452) { caughtType = 2452; } else if (worldLayer == 1 & flag4 && type == 2483) { caughtType = 2483; } else if (worldLayer == 1 & flag4 && type == 2488) { caughtType = 2488; } else if (worldLayer >= 1 & flag4 && type == 2486) { caughtType = 2486; } else if (worldLayer > 1 & flag4) { caughtType = 2311; } else if (flag4) { caughtType = 2313; } else if (flag3) { caughtType = 2302; } } if (caughtType == 0 && zone.HasFlag(Zone.Shroom) && (flag4 && type == 2475)) { caughtType = 2475; } if (caughtType == 0) { if (worldLayer <= 1 && (bobberTileX < 380 || bobberTileX > Main.maxTilesX - 380) && poolSize > 1000) { caughtType = !flag6 || Main.rand.Next(2) != 0 ? (!flag6 ? (!flag5 || Main.rand.Next(5) != 0 ? (!flag5 || Main.rand.Next(2) != 0 ? (!flag4 || type != 2480 ? (!flag4 || type != 2481 ? (!flag4 ? (!flag3 || Main.rand.Next(2) != 0 ? (!flag3 ? 2297 : 2300) : 2301) : 2316) : 2481) : 2480) : 2332) : 2438) : 2342) : 2341; } else { //int sandTiles = Main.sandTiles; //doesn't seem to do anything? } } if (caughtType == 0) { caughtType = !(worldLayer < 2 & flag4) || type != 2461 ? (!(worldLayer == 0 & flag4) || type != 2453 ? (!(worldLayer == 0 & flag4) || type != 2473 ? (!(worldLayer == 0 & flag4) || type != 2476 ? (!(worldLayer < 2 & flag4) || type != 2458 ? (!(worldLayer < 2 & flag4) || type != 2459 ? (!(worldLayer == 0 & flag4) ? (((worldLayer <= 0 ? 0 : (worldLayer < 3 ? 1 : 0)) & (flag4 ? 1 : 0)) == 0 || type != 2455 ? (!(worldLayer == 1 & flag4) || type != 2479 ? (!(worldLayer == 1 & flag4) || type != 2456 ? (!(worldLayer == 1 & flag4) || type != 2474 ? (!(worldLayer > 1 & flag5) || Main.rand.Next(5) != 0 ? (!(worldLayer > 1 & flag7) ? (!(worldLayer > 1 & flag6) || Main.rand.Next(2) != 0 ? (!(worldLayer > 1 & flag5) ? (!(worldLayer > 1 & flag4) || type != 2478 ? (!(worldLayer > 1 & flag4) || type != 2450 ? (!(worldLayer > 1 & flag4) || type != 2464 ? (!(worldLayer > 1 & flag4) || type != 2469 ? (!(worldLayer > 2 & flag4) || type != 2462 ? (!(worldLayer > 2 & flag4) || type != 2482 ? (!(worldLayer > 2 & flag4) || type != 2472 ? (!(worldLayer > 2 & flag4) || type != 2460 ? (!(worldLayer > 1 & flag4) || Main.rand.Next(4) == 0 ? (worldLayer <= 1 || !(flag4 | flag3) && Main.rand.Next(4) != 0 ? (!flag4 || type != 2487 ? (!(poolSize > 1000 & flag3) ? 2290 : 2298) : 2487) : (Main.rand.Next(4) != 0 ? 2309 : 2303)) : 2303) : 2460) : 2472) : 2482) : 2462) : 2469) : 2464) : 2450) : 2478) : 2321) : 2320) : 2308) : (!Main.hardMode || Main.rand.Next(2) != 0 ? 2436 : 2437)) : 2474) : 2456) : 2479) : 2455) : 2304) : 2459) : 2458) : 2476) : 2473) : 2453) : 2461; } } #endregion AutofisherHooks.CatchFish(te, zone, baitItem, fishingPower, lava ? 1 : (honey ? 2 : 0), poolSize, worldLayer, ref caughtType, ref junk); if (caughtType <= 0 /*|| Crates.Contains(num10) */) { return(-1); } // if (Main.player[projectile.owner].sonarPotion) // { // Item newItem = new Item(); //int Type = num10; //int num19 = 0; //newItem.SetDefaults(Type, num19 != 0); // Vector2 position = projectile.position; //newItem.position = position; // int stack = 1; //int num20 = 1; //int num21 = 0; //ItemText.NewText(newItem, stack, num20 != 0, num21 != 0); // } //float num22 = (float)num2; //projectile.ai[1] = (float)Main.rand.Next(-240, -90) - num22; //projectile.localAI[1] = (float)num10; //projectile.netUpdate = true; projectile.ai[0] = caughtType; projectile.netUpdate = true; return(junk? -2 : caughtType); } } return(-1); }