Jump to content

Elin:Code Analysis/Fishing: Difference between revisions

Fixed fish LV calculations.
(Added fishing sea land feat.)
(Fixed fish LV calculations.)
Line 7: Line 7:
<pre>fishLV = rnd(fishingLevel * 2) + 1</pre>
<pre>fishLV = rnd(fishingLevel * 2) + 1</pre>


*'''fishingLevel''': Your current fishing skill level.
* '''fishingLevel''': Your current fishing skill level.
*'''rnd''': A random number between '''0''' and the value passed into the function.
* '''rnd''': A random number between '''0''' and the value passed into the function.


====Example====
==== Adjusted Fish LV ====


If your fishing level is '''3''', the potential fish LV is calculated as:
The adjusted fish LV is calculated during item creation. It uses multiple calls to the '''rnd''' function and adds a hardcoded value of '''+2''' at the end. The final adjusted level becomes:


<pre>rnd(3 * 2) + 1</pre>
<pre>adjustedLV = fishLV + 2 + rnd(rnd(rnd(rnd(Mathf.Min(fishLV * 2, 20)) + 1) + 1) + 1)</pre>


This gives a range of 1 to 6, meaning you can catch fish with LV between 1 and 6.
* The adjustment process involves:
** Determining the base '''fishLV''' as '''rnd(fishingLevel * 2) + 1'''.
** Applying multiple calls to the '''rnd''' function:
*** '''rnd''' generates a random number between '''0''' and '''(max - 1)'''.
*** Each call depends on the result of the previous '''rnd''', gradually narrowing down the possible range.
** Adding a hardcoded '''+2''' to ensure the adjusted LV always has an offset.
 
==== Example ====
 
If your fishing level is '''10''':
 
* '''Base LV''':
** '''fishLV = rnd(10 * 2) + 1 = rnd(20) + 1'''.
** Example result: '''10'''.
 
* '''Adjustments''':
** First '''rnd(20)''' → Result = '''7'''.
** Second '''rnd(7 + 1)''' → Result = '''3'''.
** Third '''rnd(3 + 1)''' → Result = '''2'''.
** Fourth '''rnd(2 + 1)''' → Result = '''0'''.
 
* '''Final Adjusted LV''':
** '''adjustedLV = 10 + 2 + 0 = 12'''.


====Fish LV Range Table====
====Fish LV Range Table====
Line 24: Line 46:
!Fishing Level!!Minimum LV!!Maximum LV
!Fishing Level!!Minimum LV!!Maximum LV
|-
|-
|1||1||2
|1||3||5
|-
|-
|2||1||4
|2||3||7
|-
|-
|3||1||6
|3||3||9
|-
|-
|4||1||8
|4||3||11
|-
|-
|5||1||10
|5||3||13
|-
|-
|6||1||12
|6||3||15
|-
|-
|7||1||14
|7||3||17
|-
|-
|8||1||16
|8||3||19
|-
|-
|9||1||18
|9||3||21
|-
|-
|10||1||20
|10||3||23
|-
|-
|11||1||22
|11||3||25
|-
|-
|12||1||24
|12||3||27
|-
|-
|13||1||26
|13||3||29
|-
|-
|14||1||28
|14||3||31
|-
|-
|15||1||30
|15||3||33
|-
|-
|16||1||32
|16||3||35
|-
|-
|17||1||34
|17||3||37
|-
|-
|18||1||36
|18||3||39
|-
|-
|19||1||38
|19||3||40
|-
|20||1||40
|}
|}


====Code (EA 23.37)====
====Code (EA 23.41)====


<syntaxhighlight lang="c#" line="1">
<syntaxhighlight lang="c#" line="1">
int num3 = EClass.rnd(num * 2) + 1;
int num3 = EClass.rnd(num * 2) + 1;
thing = ThingGen.Create("fish", -1, num3);
thing = ThingGen.Create("fish", -1, num3);
lv = lv + 2 + EClass.rnd(EClass.rnd(EClass.rnd(EClass.rnd(Mathf.Min(lv * 2, 20)) + 1) + 1) + 1);
</syntaxhighlight>
</syntaxhighlight>


133

edits