Skip to content

Instantly share code, notes, and snippets.

@dragon3025
Created March 16, 2017 21:33
Show Gist options
  • Save dragon3025/b03907ea5f4ca361f53cfbf528cb5bcc to your computer and use it in GitHub Desktop.
Save dragon3025/b03907ea5f4ca361f53cfbf528cb5bcc to your computer and use it in GitHub Desktop.
Fish Problem
public override void CatchFish(Item fishingRod, Item bait, int power, int liquidType, int poolSize, int worldLayer, int questFish, ref int caughtType, ref bool junk)
{
if (junk)
{
return;
}
int crateChance = 0;
if (liquidType == 0 && power >= 50)
{
if (player.FindBuffIndex(BuffID.Crate) > -1)
crateChance = 20;
else
crateChance = 10;
}
else
crateChance = 0;
if ((Main.rand.Next(100)+1) <= crateChance)
{
List<int> fishCatches = new List<int>();
while (fishCatches.Count < 9)
{
int randFish = Main.rand.Next(9);//0 to 8
if (!fishCatches.Contains(randFish))
{
fishCatches.Add(randFish);
}
}
bool reeledIn = false;
foreach (int i in fishCatches)
{
if (!reeledIn)
{
switch (i)
{
case 0:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesWoodenCrate*10000)
{
caughtType = ItemID.WoodenCrate;
reeledIn = true;
}
break;
case 1:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesIronCrate*10000)
{
caughtType = ItemID.IronCrate;
reeledIn = true;
}
break;
case 2:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesJungleCrate*10000)
{
caughtType = ItemID.JungleFishingCrate;
reeledIn = true;
}
break;
case 3:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesSkyCrate*10000)
{
caughtType = ItemID.FloatingIslandFishingCrate;
reeledIn = true;
}
break;
case 4:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesCorruptCrate*10000)
{
caughtType = ItemID.CorruptFishingCrate;
reeledIn = true;
}
break;
case 5:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesCrimsonCrate*10000)
{
caughtType = ItemID.CrimsonFishingCrate;
reeledIn = true;
}
break;
case 6:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesHallowedCrate*10000)
{
caughtType = ItemID.HallowedFishingCrate;
reeledIn = true;
}
break;
case 7:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesDungeonCrate*10000)
{
caughtType = ItemID.DungeonFishingCrate;
reeledIn = true;
}
break;
case 8:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesGoldenCrate*10000)
{
caughtType = ItemID.GoldenCrate;
reeledIn = true;
}
break;
}
}
}
}
else
{
List<int> fishCatches = new List<int>();
while (fishCatches.Count < 9)
{
int randFish = Main.rand.Next(18);//0 to 17
if (!fishCatches.Contains(randFish))
{
fishCatches.Add(randFish);
}
}
bool reeledIn = false;
foreach (int i in fishCatches)
{
if (!reeledIn)
{
switch (i)
{
//Worldlayers: 0, sky; 1, surface; 2, underground; 3, caverns; and 4, underworld.
case 0:
//if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesGoldenCarp*10000 && worldLayer >= 2)
//{
caughtType = ItemID.GoldenCarp;
reeledIn = true;
//}
break;
case 1:
//if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesBlueJellyfish*10000 && worldLayer >= 3 && !player.ZoneCorrupt && !player.ZoneCrimson && !player.ZoneHoly)
//{
caughtType = ItemID.BlueJellyfish;
reeledIn = true;
//}
break;
case 2:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesPinkJellyfish*10000 && worldLayer <= 1 && player.ZoneBeach)
{
caughtType = ItemID.PinkJellyfish;
reeledIn = true;
}
break;
case 3:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesGreenJellyfish*10000 && worldLayer >= 3 && Main.hardMode && !player.ZoneCorrupt && !player.ZoneCrimson && !player.ZoneHoly)
{
caughtType = ItemID.GreenJellyfish;
reeledIn = true;
}
break;
case 4:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesChaosFish*10000 && worldLayer >= 2 && player.ZoneHoly)
{
caughtType = ItemID.ChaosFish;
reeledIn = true;
}
break;
case 5:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesReaverShark*10000 && worldLayer <= 1 && player.ZoneBeach)
{
caughtType = ItemID.ReaverShark;
reeledIn = true;
}
break;
case 6:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesSawtoothShark*10000 && worldLayer <= 1 && player.ZoneBeach)
{
caughtType = ItemID.SawtoothShark;
reeledIn = true;
}
break;
case 7:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesScalyTruffle*10000 && worldLayer == 3 && Main.hardMode && (player.ZoneSnow && (player.ZoneHoly || player.ZoneCorrupt || player.ZoneCrimson)))
{
caughtType = ItemID.ScalyTruffle;
reeledIn = true;
}
break;
case 8:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesZephyrFish*10000)
{
caughtType = ItemID.ZephyrFish;
reeledIn = true;
}
break;
case 9:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesToxikarp*10000 && Main.hardMode && player.ZoneCorrupt)
{
caughtType = ItemID.Toxikarp;
reeledIn = true;
}
break;
case 10:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesBladetongue*10000 && Main.hardMode && player.ZoneCrimson)
{
caughtType = ItemID.Bladetongue;
reeledIn = true;
}
break;
case 11:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesCrystalSerpent*10000 && Main.hardMode)
{
caughtType = ItemID.CrystalSerpent;
reeledIn = true;
}
break;
case 12:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesPurpleClubberfish*10000 && player.ZoneCorrupt)
{
caughtType = ItemID.PurpleClubberfish;
reeledIn = true;
}
break;
case 13:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesRockfish*10000 && worldLayer >= 2)
{
caughtType = ItemID.Rockfish;
reeledIn = true;
}
break;
case 14:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesFrogLeg*10000)
{
caughtType = ItemID.FrogLeg;
reeledIn = true;
}
break;
case 15:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesSwordfish*10000 && worldLayer <= 1 && player.ZoneBeach)
{
caughtType = ItemID.Swordfish;
reeledIn = true;
}
break;
case 16:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesBalloonPufferfish*10000)
{
caughtType = ItemID.BalloonPufferfish;
reeledIn = true;
}
break;
case 17:
if ((Main.rand.Next(10000)+1) <= Config.FishCatchBecomesFrostDaggerfish*10000 && player.ZoneSnow)
{
caughtType = ItemID.FrostDaggerfish;
reeledIn = true;
}
break;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment