Miscellaneous Forums > Scripting and Reverse Engineering

[FF7] Chocobo Encounters Chance

<< < (2/2)

nfitc1:
I guess I didn't make myself clear in either of my previous posts. It looks like Terrace didn't do enough digging into the actual calculation of the encounter rate to actually pick the formation as they can be pretty different depending on your lure rating.
The World map is divided up into 16 "regions" which can have any of four "zones". These regions/zones don't have to be exclusive, but I assume they are. When a battle is triggered, the first two things the battle module does is check if you are in a Forest (for the mystery ninja fights) and haven't recruited Yuffie or if there are chocobo encounters in the encounter list for that region/zone combination.
IF your party is in a zone that has chocobo encounters AND you have a greater-than-zero chocobo encounter rate the battle module will then perform a calculation based on your lure value vs the encounter chance I posted above. This check behaves as follows:

--- Code: ---Cchance = RND[0..255] << 12 / (lure rate)
CEncounter = (Chocobo Battle 1 chance)
Chosen Battle = -1

If Cchance < CEncounter Then
Chosen Battle = Chocobo Formation 1
Else
CEncounter = CEncounter + (Chocobo Battle 2 chance)
End If

If Cchance < CEncounter Then
Chosen Battle = Chocobo Formation 2
Else
CEncounter = CEncounter + (Chocobo Battle 3 chance)
End If

If Cchance < CEncounter Then
Chosen Battle = Chocobo Formation 3
Else
CEncounter = CEncounter + (Chocobo Battle 4 chance)
End If

If Cchance < CEncounter Then
Chosen Battle = Chocobo Formation 4
End If

If Chosen battle = -1 Then
<pick a random battle from zone's encounter table>
End If

--- End code ---

Let's take a look at the Cchance values:

--- Code: ---Lure rating on the top
RND down the left
4 8 12 16 20 24 28 32
0 0 0 0 0 0 0 0 0
1 1024 512 341 256 204 170 146 128
2 2048 1024 682 512 409 341 292 256
3 3072 1536 1024 768 614 512 438 384
4 4096 2048 1365 1024 819 682 585 512
5 5120 2560 1706 1280 1024 853 731 640
6 6144 3072 2048 1536 1228 1024 877 768
7 7168 3584 2389 1792 1433 1194 1024 896
8 8192 4096 2730 2048 1638 1365 1170 1024
.
.
.
245 250880 125440 83626 62720 50176 41813 35840 31360
246 251904 125952 83968 62976 50380 41984 35986 31488
247 252928 126464 84309 63232 50585 42154 36132 31616
248 253952 126976 84650 63488 50790 42325 36278 31744
249 254976 127488 84992 63744 50995 42496 36425 31872
250 256000 128000 85333 64000 51200 42666 36571 32000
251 257024 128512 85674 64256 51404 42837 36717 32128
252 258048 129024 86016 64512 51609 43008 36864 32256
253 259072 129536 86357 64768 51814 43178 37010 32384
254 260096 130048 86698 65024 52019 43349 37156 32512
255 261120 130560 87040 65280 52224 43520 37302 32640
--- End code ---

You can calculate the rest on your own if you'd like, they're not really important. What is important is at the point that the calculated Cchance is LESS THAN the encounter rate of the zone then you will get a chocobo battle. This is why with a maxed out lure rating of 32 you'll always get a chocobo battle. The largest Cchance is 32640 which is less than each zone's last formation's encounter rate. We can reduce this a little further into two more graphs: Chance you will encounter a chocobo, and chance of each formation is encountered based on lure rate. Here's the chance you'll encounter a chocobo formation by zone:

--- Code: --- 8 12 16 20 24 28 32
Farm 75 100 100 100 100 100 100
Junon 50 75 100 100 100 100 100
Other locations 25 37.5 50 62.5 75 87.5 100
--- End code ---

I don't think lure rate of 4 is possible unmodded so I omitted it. If a chocobo battle IS to be encountered, here's the percentage chance of each formation based on the lure rate:

--- Code: --- 8 12 16 20 24 28 32
Farm1 25 28.1 37.5 46.8 56.3 65.6 75
Farm2 25 28.1 37.5 46.8 43.7 34.4 25
Farm3 25 28.1 25 6.3 0 0 0
Farm4 25 15.6 0 0 0 0 0
Junon1 25 25 25 31.3 37.5 43.8 50
Junon2 25 25 25 31.3 37.5 43.8 50
Junon3 25 25 25 31.3 25 12.5 0
Junon4 25 25 25 6.1 0 0 0
GS/RT1 15.6 15.6 15.6 15.6 15.6 15.6 15.6
GS/RT2 15.6 15.6 15.6 15.6 15.6 15.6 15.6
GS/RT3 34.4 34.4 34.4 34.4 34.4 34.4 34.4
GS/RT4 34.4 34.4 34.4 34.4 34.4 34.4 34.4
Wutai1 25 25 25 25 25 25 25
Wutai2 25 25 25 25 25 25 25
Wutai3 25 25 25 25 25 25 25
Wutai4 25 25 25 25 25 25 25
Snow1 9.4 9.4 9.4 9.4 9.4 9.4 9.4
Snow2 9.4 9.4 9.4 9.4 9.4 9.4 9.4
Snow3 40.6 40.6 40.6 40.6 40.6 40.6 40.6
Snow4 40.6 40.6 40.6 40.6 40.6 40.6 40.6
Mideel1 21.9 21.9 21.9 21.9 21.9 21.9 21.9
Mideel2 21.9 21.9 21.9 21.9 21.9 21.9 21.9
Mideel3 28.1 28.1 28.1 28.1 28.1 28.1 28.1
Mideel4 28.1 28.1 28.1 28.1 28.1 28.1 28.1
--- End code ---

Percentages are approximate. Some formations cannot be encountered with higher lure ratings because the Cchance is never less than the value of the previous formations. ie, Farm4 cannot be encountered with a single mastered lure because the Cchance maxes out at 52224 at that lure rate and that will be caught by Farm3 since it's encounter chance is >73k.

To find the chance to encounter any of these individually as a broader function of "will I encounter this formation when a battle occurs", just multiply these two values together.
For example, the chance of getting Farm1 with a level 1 lure is 25% * 75% = 18.75%
the chance of getting Mideel2 with a level 1 lure with a level 2 lure is 21.9% * 62.5% = 13.7%

Raziel80:

--- Quote from: NFITC1 on 2021-06-30 14:47:50 ---I guess I didn't make myself clear in either of my previous posts.
--- End quote ---
It was clear. I just used the familiar encounter rating system out of habit.

--- Quote from: NFITC1 on 2021-06-30 14:47:50 ---I don't think lure rate of 4 is possible unmodded so I omitted it. If a chocobo battle IS to be encountered, here's the percentage chance of each formation based on the lure rate:

--- Code: --- 8 12 16 20 24 28 32
Farm1 25 28.1 37.5 46.8 56.3 65.6 75
Farm2 25 28.1 37.5 46.8 43.7 34.4 25
Farm3 25 28.1 25 6.3 0 0 0
Farm4 25 15.6 0 0 0 0 0
Junon1 25 25 25 31.3 37.5 43.8 50
Junon2 25 25 25 31.3 37.5 43.8 50
Junon3 25 25 25 31.3 25 12.5 0
Junon4 25 25 25 6.1 0 0 0

--- End code ---

--- End quote ---
I checked it out. Yes, with Chocobo lure rating 32: in the Chocobo Farm Area I only got the Farm1 and Farm2 battles. In the Junon Area I only got the Junon1 and Junon2 chocobo battles.

--- Quote from: NFITC1 on 2021-06-30 14:47:50 ---You can calculate the rest on your own if you'd like, they're not really important. What is important is at the point that the calculated Cchance is LESS THAN the encounter rate of the zone then you will get a chocobo battle. This is why with a maxed out lure rating of 32 you'll always get a chocobo battle. The largest Cchance is 32640 which is less than each zone's last formation's encounter rate. We can reduce this a little further into two more graphs: Chance you will encounter a chocobo, and chance of each formation is encountered based on lure rate. Here's the chance you'll encounter a chocobo formation by zone:

--- Code: --- 8 12 16 20 24 28 32
Farm 75 100 100 100 100 100 100
Junon 50 75 100 100 100 100 100
Costa del Sol &
Rocket Town ~58 ~86.7 100 100 100 100 100
Other locations 25 37.5 50 62.5 75 87.5 100
--- End code ---

--- End quote ---
Costa del Sol &
Rocket Town   ~58   ~86.7   100
Somehow these values do not fit into this table. Something wrong with them. I checked it out.
With Chocobo lure rating 12 (these are ~86.7% of chocobo battles according to the table above): in the Gold Saucer Area I had 25 battles, 10 of them were chocobo battles and 15 were normal battles (10/ 25 = 40% chocobo battles, 15/ 25 = 60% normal battles). In the Rocket Town Area I had 25 battles, 13 of them were chocobo battles and 12 were normal battles (13/ 25 = 52% chocobo battles, 12/ 25 = 48% normal battles).
With Chocobo lure rating 16 (these are 100% of chocobo battles according to the table above): but I didn't have 100% of the chocobo battles in the Gold Saucer/Rocket Town Area, there were also normal battles.

--- Quote from: NFITC1 on 2021-06-30 14:47:50 ---I'm going to have to go back and verify those Costa del Sol/Rocket Town values at some point. They seem skewed in favor of the third formation.
--- End quote ---
Yes, something wrong with them. :) I had Rocket Town4 (RT4) battle with Chocobo lure rating 32.

--- Quote from: NFITC1 on 2021-06-30 14:47:50 ---To find the chance to encounter any of these individually as a broader function of "will I encounter this formation when a battle occurs", just multiply these two values together.
For example, the chance of getting Farm1 with a level 1 lure is 25% * 75% = 18.75%
the chance of getting Mideel2 with a mastered lure is 21.9% * 62.5% = 13.7%

--- End quote ---
According to your table: the chance of getting Mideel2 with a mastered lure is 21.9% * 50% = 10.95%

nfitc1:
Yes, the GS/RT values were way off. I must have typed something into my calculator wrong and just kept on keeping on with the transcription error. The encounter chances are actually

--- Code: ---GS/RT1 5120
GS/RT2 10240
GS/RT3 21504
GS/RT4 32768
--- End code ---

I'll update the tables above accordingly so there's as little duplicate data as possible.

--- Quote from: Raziel80 on 2021-07-01 09:33:09 ---According to your table: the chance of getting Mideel2 with a mastered lure is 21.9% * 50% = 10.95%
--- End quote ---
I thought the mastered lure went up to 20. It does not. You are correct based on the wording I gave.

And thanks for doing some practical tests on these values. I still can't get my game to load and test them myself. :(

Raziel80:

--- Quote from: NFITC1 on 2021-07-01 13:42:10 ---I still can't get my game to load and test them myself.

--- End quote ---