Jump to content

Elin:Code Analysis/Fishing: Difference between revisions

Add fishing spoiler probability calculations.
(Initial fishing spoiler item probability seciton.)
(Add fishing spoiler probability calculations.)
Line 426: Line 426:


Each item or fish has a unique probability of being generated, determined by the following rules and calculations:
Each item or fish has a unique probability of being generated, determined by the following rules and calculations:
{| class="wikitable sortable"
|-
! Roll !! Logic
|-
| Nothing || If this succeeds, no further rolls occur.
|-
| Rare Item || Checked if "Nothing" fails; if this succeeds, no further rolls occur.
|-
| Junk || Checked if both "Nothing" and "Rare Item" fail; if this succeeds, no further rolls occur.
|-
| Fish || The fallback/default roll if all previous rolls fail.
|}


==== Initial Roll: Chance to Catch Nothing ====
==== Initial Roll: Chance to Catch Nothing ====
Line 441: Line 454:
* '''Condition''': If the result is <code>0</code>, the roll fails, and nothing is caught.
* '''Condition''': If the result is <code>0</code>, the roll fails, and nothing is caught.


==== Probability ====
===== Probability =====


The probability of catching nothing decreases as the player's fishing level increases:
The probability of catching nothing decreases as the player's fishing level increases:
Line 459: Line 472:
This means that higher fishing levels significantly reduce the chance of failing the roll and increase the likelihood of catching something.
This means that higher fishing levels significantly reduce the chance of failing the roll and increase the likelihood of catching something.


==== Conditional Rolls: Rare Items and Rewards ====
This section determines whether a rare item or reward is generated. The outermost condition checks if a random roll succeeds. If the condition is met, nested conditions evaluate the type of item to generate.
<syntaxhighlight lang="csharp">
if (rnd(20) == 0)
</syntaxhighlight>
* '''Condition''': Pass a random roll: <code>rnd(20) == 0</code>.
If this condition is satisfied, the following rolls determine the item generated:
===== Ancient Book =====
The Ancient Book is one of the rare items that can be generated during fishing if specific conditions are met. Its generation depends on a random roll after passing the initial check.
<syntaxhighlight lang="csharp">
if (rnd(30) == 0)
{
    text = "book_ancient";
}
</syntaxhighlight>
* '''Condition''': The item is generated if <code>rnd(30) == 0</code>.
* '''Probability''': <code>1 / 30</code>, or approximately 3.33%.
If this condition is satisfied, the Ancient Book is created as the reward.
===== Platinum Coin =====
The Platinum Coin is another rare item that can be generated during fishing. Its generation depends on a random roll.
<syntaxhighlight lang="csharp">
if (rnd(35) == 0)
{
    text = "plat";
}
</syntaxhighlight>
* '''Condition''': The item is generated if <code>rnd(35) == 0</code>.
* '''Probability''': <code>1 / 35</code> (~2.86%).
If this condition is satisfied, a Platinum Coin is created as the reward.
===== Scratch Card =====
The Scratch Card is a replacement item that can be generated after the Platinum Coin roll. Its generation depends on a random roll following the successful Platinum Coin condition.
<syntaxhighlight lang="csharp">
if (rnd(2) == 0)
{
    text = "scratchcard";
}
</syntaxhighlight>
* '''Condition''': The item is generated if <code>rnd(2) == 0</code>, replacing the Platinum Coin.
* '''Probability''': <code>1 / 2</code> (50%), but it depends on the successful Platinum Coin roll.
* '''Dependent Probability''': <code>1 / (20 * 35 * 2)</code> (~0.071%).
** Calculated as:
*** Rare Item Roll: <code>1 / 20</code> (5%).
*** Platinum Coin Roll: <code>1 / 35</code> (~2.86%).
*** Scratch Card Roll: <code>1 / 2</code> (50%).
If this condition is satisfied, the Scratch Card replaces the Platinum Coin as the reward.
===== Casino Coin =====
The Casino Coin is another replacement item that can be generated after the Platinum Coin roll. Its generation depends on a random roll following the successful Platinum Coin condition.
<syntaxhighlight lang="csharp">
if (rnd(3) == 0)
{
    text = "casino_coin";
}
</syntaxhighlight>
* '''Condition''': The item is generated if <code>rnd(3) == 0</code>, replacing the Platinum Coin.
* '''Probability''': <code>1 / 3</code> (~33.33%), but it depends on the successful Platinum Coin roll.
* '''Dependent Probability''': <code>1 / (20 * 35 * 3)</code> (~0.048%).
** Calculated as:
*** Rare Item Roll: <code>1 / 20</code> (5%).
*** Platinum Coin Roll: <code>1 / 35</code> (~2.86%).
*** Casino Coin Roll: <code>1 / 3</code> (~33.33%).
If this condition is satisfied, the Casino Coin replaces the Platinum Coin as the reward.
===== Strange Coin =====
The Strange Coin is another replacement item that can be generated after the Platinum Coin roll. Its generation depends on a random roll following the successful Platinum Coin condition.
<syntaxhighlight lang="csharp">
if (rnd(3) == 0)
{
    text = "gacha_coin";
}
</syntaxhighlight>
* '''Condition''': The item is generated if <code>rnd(3) == 0</code>, replacing the Platinum Coin.
* '''Probability''': <code>1 / 3</code> (~33.33%), but it depends on the successful Platinum Coin roll.
* '''Dependent Probability''': <code>1 / (20 * 35 * 3)</code> (~0.048%).
** Calculated as:
*** Rare Item Roll: <code>1 / 20</code> (5%).
*** Platinum Coin Roll: <code>1 / 35</code> (~2.86%).
*** Strange Coin Roll: <code>1 / 3</code> (~33.33%).
If this condition is satisfied, the Strange Coin replaces the Platinum Coin as the reward.
===== Statues =====
Statues are extremely rare items that can be generated after the Platinum Coin roll. Their generation depends on a random roll, with one of seven possible statues being selected.
<syntaxhighlight lang="csharp">
if (rnd(50) == 0)
{
    text = "Randomly choose one of these statues: "
          "Statue of Earth",
          "Statue of Element",
          "Statue of Harvest",
          "Statue of Healing",
          "Statue of Luck",
          "Statue of Machine",
          "Statue of Wind";
}
</syntaxhighlight>
* '''Condition''': A statue is generated if <code>rnd(50) == 0</code>.
* '''Probability''': <code>1 / 50</code> (2%), but it depends on the successful Platinum Coin roll.
* '''Dependent Probability''': <code>1 / (20 * 35 * 50)</code> (~0.00286%).
** Calculated as:
*** Rare Item Roll: <code>1 / 20</code> (5%).
*** Platinum Coin Roll: <code>1 / 35</code> (~2.86%).
*** Statue Roll: <code>1 / 50</code> (2%).
If this condition is satisfied, one of the following statues is randomly selected:
* '''Statue of Earth'''
* '''Statue of Element'''
* '''Statue of Harvest'''
* '''Statue of Healing'''
* '''Statue of Luck'''
* '''Statue of Machine'''
* '''Statue of Wind'''
Each statue has an equal probability of being selected from the pool of seven statues.
* '''Probability of a Specific Statue''': <code>1 / 7</code> (~14.29%) of the statue roll.
* '''Dependent Probability for a Specific Statue''': <code>1 / (20 * 35 * 50 * 7)</code> (~0.00041%).
===== Small Medal =====
The Small Medal is a rare item that can be generated during fishing. Its generation depends on two random rolls: a base roll and a level-dependent threshold check.
<syntaxhighlight lang="csharp">
if (rnd(40) == 0 && rnd(40) < fishingLevel / 3 + 10)
{
    text = "medal";
}
</syntaxhighlight>
* '''Condition''':
** The first roll succeeds if <code>rnd(40) == 0</code> (2.5%).
** The second roll succeeds if <code>rnd(40) < fishingLevel / 3 + 10</code>.
* '''Probability''':
** The first roll has a fixed probability: <code>1 / 40</code> (2.5%).
** The second roll's probability depends on the player's fishing level:
*** Higher fishing levels increase the threshold (<code>fishingLevel / 3 + 10</code>), making it easier to succeed.
* '''Minimum Fishing Level for Consistent Success''':
** To always pass the second roll, the threshold must reach or exceed 40. Solve for:
*** <code>fishingLevel / 3 + 10 >= 40</code>.
*** <code>fishingLevel >= (40 - 10) * 3</code>.
*** <code>fishingLevel >= 90</code>.
** At <code>fishingLevel = 90</code>, the threshold becomes <code>90 / 3 + 10 = 40</code>, ensuring consistent success.
* '''Dependent Probability''':
** Combined probability: <code>(1 / 20) * (1 / 40) * (fishingLevel-dependent threshold)</code>.
** Example for Fishing Level 10:
*** Threshold: <code>10 / 3 + 10 = ~13.33</code>.
*** Second roll succeeds if <code>rnd(40) < 13</code>, or <code>13 / 40</code> (32.5%).
*** Combined Probability: <code>(1 / 20) * (1 / 40) * (13 / 40)</code> (~0.01625%).
==== Junk Items ====
Junk items are a category of low-value rewards that can be generated during fishing. Their generation depends on a random roll after all higher-priority items (e.g., rare items, medals) have failed to generate.
<syntaxhighlight lang="csharp">
if (rnd(5 + fishingLevel / 3) == 0)
{
    thing = "Randomly choose one of these junk items: "
            "Boots",
            "Empty Bottle (1)",
            "Empty Bottle (2)",
            "Empty Can (1)",
            "Empty Can (2)",
            "Flotsam from the North",
            "Lucky Cat",
            "Rubber Duck",
            "Rubber Putit",
            "Rubber Snail",
            "Sandal (1)",
            "Sandal (2)",
            "Sea Pants";
}
</syntaxhighlight>
* '''Condition''': Junk items are generated if:
** The rare item roll and all higher-priority rolls fail.
** The following roll succeeds: <code>rnd(5 + fishingLevel / 3) == 0</code>.
* '''Probability''':
** The probability depends on the player's fishing level:
*** <code>1 / (5 + fishingLevel / 3)</code>.
*** Higher fishing levels reduce the chance of junk items being generated, as the denominator increases.
* '''Junk Item Pool''':
** If this roll succeeds, one item is randomly selected from the following list (15 items total):
*** '''Boots'''
*** '''Empty Bottle (1)'''
*** '''Empty Bottle (2)'''
*** '''Empty Can (1)'''
*** '''Empty Can (2)'''
*** '''Flotsam from the North'''
*** '''Lucky Cat'''
*** '''Rubber Duck'''
*** '''Rubber Putit'''
*** '''Rubber Snail'''
*** '''Sandal (1)'''
*** '''Sandal (2)'''
*** '''Sea Pants'''
* '''Probability of a Specific Junk Item''':
** Equal chance for each item in the list: <code>1 / 15</code> (~6.67%) of junk roll success.
===== Example Calculation =====
* At '''Fishing Level 10''':
** Threshold for junk roll: <code>5 + 10 / 3 = ~8.33</code>.
** Probability of junk roll succeeding: <code>1 / 8</code> (12.5%).
** Probability of a specific junk item: <code>1 / 8 * 1 / 15 = 1 / 120</code> (~0.83%).
==== Fish ====
The generation of fish happens as the default outcome when all higher-priority rolls fail:
* '''Dependencies''':
** The fish roll occurs if:
*** The "Nothing" roll fails.
*** The "Rare Item" roll fails.
*** The "Junk" roll fails.
===== Probability Context =====
Since the fish roll occurs as the final fallback, its probability is calculated as:
* '''Probability of Fish Roll''':
<code>1 - P(Nothing) - P(Rare Item) - P(Junk)</code>
* '''Dependent Probabilities''':
** This depends on:
*** Fishing level (affects the probability of "Nothing" and "Junk").
*** Success/failure of preceding rolls.
===== Example Calculation for Whale =====
At '''Fishing Level 19''', the '''minimum fishing level''' for the '''Whale''' is 19. If the '''adjustedLV''' is 40 or higher, the '''Whale''' can be caught.
To calculate the probability of catching the '''Whale''':
<syntaxhighlight lang="csharp">
P(Whale) = 50 / Total Chance of All Eligible Fish
</syntaxhighlight>
If the '''total chance''' for all eligible fish at '''Fishing Level 19''' is '''22050''', then:
<syntaxhighlight lang="csharp">
P(Whale) = 50 / 22050 = 0.00227 or ~0.227%
</syntaxhighlight>
===== Fish Probability Table (Fish LV 40) =====
{| class="wikitable sortable"
|-
! Name !! Chance !! Probability (Independent)
|-
| Tadpole || 1000 || 1000 / 22050 (~4.54%)
|-
| Bitterling || 1000 || 1000 / 22050 (~4.54%)
|-
| Turtle || 200 || 200 / 22050 (~0.91%)
|-
| Goby || 1000 || 1000 / 22050 (~4.54%)
|-
| Muddler || 1000 || 1000 / 22050 (~4.54%)
|-
| Goldfish || 200 || 200 / 22050 (~0.91%)
|-
| Carp || 100 || 100 / 22050 (~0.45%)
|-
| Sweetfish || 1000 || 1000 / 22050 (~4.54%)
|-
| Sea Urchin || 200 || 200 / 22050 (~0.91%)
|-
| Sardine || 1000 || 1000 / 22050 (~4.54%)
|-
| Eel || 500 || 500 / 22050 (~2.27%)
|-
| Bass || 1000 || 1000 / 22050 (~4.54%)
|-
| Scad || 1000 || 1000 / 22050 (~4.54%)
|-
| Arowana || 600 || 600 / 22050 (~2.72%)
|-
| Tilefish || 1000 || 1000 / 22050 (~4.54%)
|-
| Tuna || 400 || 400 / 22050 (~1.81%)
|-
| Striped Jack || 1000 || 1000 / 22050 (~4.54%)
|-
| Mackerel || 1000 || 1000 / 22050 (~4.54%)
|-
| Bonito || 1000 || 1000 / 22050 (~4.54%)
|-
| Red Bream || 200 || 200 / 22050 (~0.91%)
|-
| Black Bass || 1000 || 1000 / 22050 (~4.54%)
|-
| Blowfish || 200 || 200 / 22050 (~0.91%)
|-
| Sea Bream || 500 || 500 / 22050 (~2.27%)
|-
| Flatfish || 1000 || 1000 / 22050 (~4.54%)
|-
| Tuna (2) || 500 || 500 / 22050 (~2.27%)
|-
| Sand Borer || 1000 || 1000 / 22050 (~4.54%)
|-
| Salmon || 500 || 500 / 22050 (~2.27%)
|-
| Sunfish || 1000 || 1000 / 22050 (~4.54%)
|-
| Shark || 50 || 50 / 22050 (~0.23%)
|-
| Deep Sea Fish || 1000 || 1000 / 22050 (~4.54%)
|-
| Ancient Fish || 200 || 200 / 22050 (~0.91%)
|-
| Moonfish || 500 || 500 / 22050 (~2.27%)
|-
| Coelacanth || 100 || 100 / 22050 (~0.45%)
|-
| Whale || 50 || 50 / 22050 (~0.23%)
|}
==== All Probability Table ====
{| class="wikitable sortable"
|-
! Item !! Probability (Independent) !! Probability (Dependent) !! Notes
|-
| Nothing || <code>1 / (3 + fishingLevel)</code> || N/A || Higher fishing levels reduce the chance of this outcome.
|-
| Rare Item || <code>1 / 20</code> (5%) || <code>1 / 20</code> || Determines if a rare item roll happens.
|-
| Ancient Book || <code>1 / 30</code> (~3.33%) || <code>1 / (20 * 30)</code> (~0.167%) || Requires a rare item roll success, then its own probability.
|-
| Platinum Coin || <code>1 / 35</code> (~2.86%) || <code>1 / (20 * 35)</code> (~0.143%) || Requires a rare item roll success, then its own probability.
|-
| Scratch Card || <code>1 / 2</code> (50%) || <code>1 / (20 * 35 * 2)</code> (~0.071%) || Replaces Platinum Coin if condition is met.
|-
| Casino Coin || <code>1 / 3</code> (33.3%) || <code>1 / (20 * 35 * 3)</code> (~0.048%) || Replaces Platinum Coin if condition is met.
|-
| Strange Coin || <code>1 / 3</code> (33.3%) || <code>1 / (20 * 35 * 3)</code> (~0.048%) || Replaces Platinum Coin if condition is met.
|-
| Statue || <code>1 / 50</code> (2%) || <code>1 / (20 * 35 * 50)</code> (~0.00286%) || Requires a rare item roll success. One of seven statues is randomly selected.
|-
| Specific Statue || <code>1 / 7</code> (~14.29% of Statue Roll) || <code>1 / (20 * 35 * 50 * 7)</code> (~0.00041%) || Probability of obtaining a specific statue.
|-
| Small Medal || Level-dependent || <code>(1 / 20) * (1 / 40) * (fishingLevel threshold)</code> || Requires two successful rolls. Consistent success at fishingLevel >= 90.
|-
| Junk || Level-dependent || <code>1 / (5 + fishingLevel / 3)</code> || Requires rare item roll to fail. Probability decreases with higher fishing levels.
|-
| Specific Junk || <code>1 / 15</code> (~6.67%) || <code>(1 / (5 + fishingLevel / 3)) * (1 / 15)</code> || Probability of obtaining a specific junk item.
|-
| Fish || <code>fishChance / fishTotalChance</code> || <code>1 - P(Nothing) - P(Rare Item) - P(Junk)</code> || Default outcome if all other rolls fail.
|}
==== Code (EA 23.43) ====
<syntaxhighlight lang="c#" line="1">
public static Thing Makefish(Chara c)
{
int num = c.Evalue(245);
if (EClass.rnd(3 + num) == 0)
{
return null;
}
int[] source = new int[]
{
233,
235,
236,
236,
236,
1170,
1143,
1144,
727,
728,
237,
869,
1178,
1179,
1180
};
int num2 = 1;
string text = "";
if (c.IsPC || EClass.rnd(20) == 0)
{
if (EClass.rnd(30) == 0)
{
text = "book_ancient";
}
if (EClass.rnd(35) == 0 || EClass.debug.enable)
{
text = "plat";
if (EClass.rnd(2) == 0)
{
text = "scratchcard";
}
if (EClass.rnd(3) == 0)
{
text = "casino_coin";
}
if (EClass.rnd(3) == 0)
{
text = "gacha_coin";
}
if (EClass.rnd(50) == 0 || EClass.debug.enable)
{
text = new string[]
{
"659",
"758",
"759",
"806",
"828",
"1190",
"1191"
}.RandomItem<string>();
}
}
if (EClass.rnd(40) == 0 && EClass.rnd(40) < num / 3 + 10)
{
text = "medal";
}
}
Thing thing;
if (text != "")
{
thing = ThingGen.Create(text, -1, -1);
}
else if (EClass.rnd(5 + num / 3) == 0)
{
thing = ThingGen.Create(source.RandomItem<int>().ToString() ?? "", -1, -1);
}
else
{
int num3 = EClass.rnd(num * 2) + 1;
thing = ThingGen.Create("fish", -1, num3);
num2 = EClass.rnd(num / (num3 + 10)) + 1;
int num4 = 5;
if (EClass.Branch != null)
{
num4 += EClass.Branch.Evalue(3604) * 20 + EClass.Branch.Evalue(3605) * 20 + EClass.Branch.Evalue(3706) * 25;
}
if (num4 >= EClass.rnd(100))
{
num2++;
}
}
if (thing != null)
{
thing.SetNum(num2);
thing.SetBlessedState(BlessedState.Normal);
}
return thing;
}
</syntaxhighlight>


[[Category:Elin Spoiler]]
[[Category:Elin Spoiler]]
[[Category:EN]]
[[Category:EN]]
135

edits