Jump to content

Elin:Code Analysis/Fishing: Difference between revisions

Added fishing sea land feat.
m (Fix small fishing spoiler format.)
(Added fishing sea land feat.)
Line 98: Line 98:
The initial chance of catching one extra fish starts at '''5%'''.
The initial chance of catching one extra fish starts at '''5%'''.


If the land feats include '''Beach (3604)''' and '''Fishing Spot (3706)''', these feats will contribute additional chances to the base chance.
If the land feats include:
* '''Beach (3604)''': Adds '''20%''' to the base chance.
* '''Sea (3605)''': Adds '''20%''' to the base chance.
* '''Fishing Spot (3706)''': Adds '''25%''' to the base chance.


For example:
Since only '''Sea (3605)''' or '''Beach (3604)''' can be present at the same time (not both), the total chance is calculated as:
* '''Beach (3604)''' adds '''20%''' to the base chance.
* '''Fishing Spot (3706)''' adds '''25%''' to the base chance.
 
Starting with a '''5% chance''', the total chance is calculated using the following code:


<pre>
<pre>
chanceForOneMoreFish = 5
chanceForOneMoreFish = 5
chanceForOneMoreFish += isBeach * 20 + isFishingSpot * 25
chanceForOneMoreFish += isBeach * 20 + isSea * 20 + isFishingSpot * 25
</pre>
</pre>


Where:
Where:
* '''isBeach''' is a flag (either 0 or 1) indicating whether the land feat is a '''Beach (3604)'''.
* '''isBeach''': A flag (either 0 or 1) indicating whether the land feat is a '''Beach (3604)'''.
* '''isFishingSpot''' is a flag (either 0 or 1) indicating whether the land feat is a '''Fishing Spot (3706)'''.
* '''isSea''': A flag (either 0 or 1) indicating whether the land feat is '''Sea (3605)'''.
 
* '''isFishingSpot''': A flag (either 0 or 1) indicating whether the land feat is a '''Fishing Spot (3706)'''.
If both features are present (i.e., both flags are set to 1), then:


For example:
* If '''Sea (3605)''' is present, and '''Fishing Spot (3706)''' is also present:
<pre>
chanceForOneMoreFish = 5 + 1 * 20 + 1 * 25 = 50
</pre>
* If '''Beach (3604)''' is present instead of '''Sea (3605)''':
<pre>
<pre>
chanceForOneMoreFish = 5 + 1 * 20 + 1 * 25 = 50
chanceForOneMoreFish = 5 + 1 * 20 + 1 * 25 = 50
Line 123: Line 127:
==== Checking the Chance to Increase the Number of Fish ====
==== Checking the Chance to Increase the Number of Fish ====


The '''chanceForOneMoreFish''' value is then compared to a random number generated by the <code>rnd(100)</code> function. The value of <code>rnd(100)</code> generates a random number between '''0''' and '''99''' (inclusive).
The '''chanceForOneMoreFish''' value is compared to a random number generated by the <code>rnd(100)</code> function, which produces a number between '''0''' and '''99''' (inclusive).


If the value of '''chanceForOneMoreFish''' is greater than or equal to the random number, the number of fish will increase by '''1'''.
If '''chanceForOneMoreFish''' is greater than or equal to the random number, the number of fish will increase by '''1'''.


This check is done with:
This check is implemented with:


<pre>
<pre>
Line 133: Line 137:
</pre>
</pre>


* If the random number generated by <code>rnd(100)</code> is '''50 or less''', the number of fish will increase by '''1'''.
For example:
* If the random number is '''greater than 50''', the number of fish will remain the same.
* If '''chanceForOneMoreFish = 50''', and the random number generated by <code>rnd(100)</code> is '''50 or less''', you will catch an additional fish.


Thus, the probability of increasing the number of fish is '''50%''' (because '''chanceForOneMoreFish = 50''' ).
==== Example with Land Feats ====


==== Example with Land Feats ====
===== Example 1: Fishing Spot (3706) and Sea (3605) =====


Let's say your fishing level is '''22''', and the fish LV is '''1'''. You calculate the base number of fish as:
Let's say your fishing level is '''22''', and the fish LV is '''1'''. The base number of fish is calculated as:


<pre>numberOfFish = rnd(22 / (1 + 10)) + 1 = rnd(2) + 1</pre>
<pre>
numberOfFish = rnd(22 / (1 + 10)) + 1 = rnd(2) + 1
</pre>


Thus, you could catch '''1 or 2 fish''', based on the random result.
This gives '''1 or 2 fish''', depending on the random result.


Now, you evaluate the land feats:
Now, evaluating the land feats:
* Starting with '''chanceForOneMoreFish = 5''' (the base chance).
* Start with '''chanceForOneMoreFish = 5''' (base chance).
* If the land feats are present:
* '''Sea (3605)''' adds '''20'''.
** '''Beach (3604)''' adds '''20''' to '''chanceForOneMoreFish'''.
* '''Fishing Spot (3706)''' adds '''25'''.
** '''Fishing Spot (3706)''' adds '''25''' to '''chanceForOneMoreFish'''.


So, the new '''chanceForOneMoreFish''' becomes:
The new '''chanceForOneMoreFish''' becomes:


<pre>
<pre>
Line 160: Line 165:
Next, the random chance is checked:
Next, the random chance is checked:


<pre>if (chanceForOneMoreFish >= rnd(100))</pre>
<pre>
if (chanceForOneMoreFish >= rnd(100))
</pre>
 
If the random number generated by <code>rnd(100)</code> is '''50 or less''', the number of fish will increase by '''1'''. Thus:
* '''numberOfFish = numberOfFish + 1''' (if the random check passes).
* If the random number exceeds '''50''', the number of fish remains unchanged.


If the random number generated by <code>rnd(100)</code> is '''50 or less''', '''numberOfFish''' will increase by 1. This means that if the random number is between '''0 and 50''' (inclusive), you will catch an additional fish, making '''numberOfFish''' increase by 1.
===== Example 2: Fishing Spot (3706) and Beach (3604) =====


So, '''numberOfFish''' is increased by '''1''' based on land feats, making it:
For the same fishing level and fish LV, the land feats contribute:
* '''Beach (3604)''' adds '''20'''.
* '''Fishing Spot (3706)''' adds '''25'''.


* '''numberOfFish = numberOfFish + 1''' (if the random check passes).
The total '''chanceForOneMoreFish''' remains:
* If the random number exceeds '''50''', '''numberOfFish''' remains the same.
 
<pre>
chanceForOneMoreFish = 5 + 20 + 25 = 50
</pre>
 
The random check behaves the same as above, with the same chance for an additional fish.


====Number of Fish Table====
====Number of Fish Table====
Line 194: Line 212:
|}
|}


====Code (EA 23.37)====
==== Code (EA 23.40) ====


<syntaxhighlight lang="c#" line="1">
<syntaxhighlight lang="c#" line="1">
Line 201: Line 219:
if (EClass.Branch != null)
if (EClass.Branch != null)
{
{
     num4 += EClass.Branch.Evalue(3604) * 20 + EClass.Branch.Evalue(3706) * 25;
     num4 += EClass.Branch.Evalue(3604) * 20 + EClass.Branch.Evalue(3605) * 20 + EClass.Branch.Evalue(3706) * 25;
}
}
if (num4 >= EClass.rnd(100))
if (num4 >= EClass.rnd(100))
133

edits