# Qhimm.com Forums

## Miscellaneous Forums => Scripting and Reverse Engineering => Topic started by: Raziel80 on 2021-06-27 09:22:17

Title: [FF7] Chocobo Encounters Chance
Post by: Raziel80 on 2021-06-27 09:22:17
How does Chocobo Lure rating affect the chance of chocobo battles on the world map? Need a calculation formula.
What are the chances of chocobo battles on the world map with a Chocobo Lure rating of 12, 20, 28?

Probability for Chocobo battles on the world map:
Chocobo Ranch: 4 battles with probability 24 each: 24*4=96 total
Junon: 4 battles with probability 16 each: 16*4=64 total
Everywhere else: total probability = 32

Code: [Select]
`Chocobo Encounter Chart:.-------------.-------.---------------.---------------.-----------------------.|Chocobo Lure |Rating:|Chance Chocobo |Chance Chocobo |Chance Chocobo         ||Materia Lvl: |       |battle Ranch:  |battle Junon:  |battle everywhere else:||-------------|-------|---------------|---------------|-----------------------||Level 1&2    |   8   |     75%       |      50%      |         25%           ||Level 3&4    |  16   |    100%       |     100%      |         50%           ||2x Lvl 3 or 4|  32   |    100%       |     100%      |        100%           |'-------------'-------'---------------'---------------'-----------------------'`
Chocobo Lure Materia
Lvl
1:  + 8 Chocobo Lure Rating
2:  +12 Chocobo Lure Rating
3:  +16 Chocobo Lure Rating
Title: Re: [FF7] Chocobo Encounters Chance
Post by: nfitc1 on 2021-06-28 19:35:05
Each polygon of the WM has a flag that labels it as having chocobo tracks. If you are on one of those polygons and your chocobo rating is > 0 (max of 32) then it will check for a chocobo formation.

A "random" encounter byte will be chosen from the encounter PRNGLUT and be multiplied by 4096 then be divided by the chocobo encounter rate. If the chocobo formation encounter chance is greater than this rate, then a chocobo battle will be selected. There are 28 chocobo formations

Code: [Select]
`Area formation chance1,0,0 38 24,576 - Farm1,0,1 39 49,152 1,0,2 3C 73,7281,0,3 3D 98,3042,0,0 4E 16,384 - near Junon2,0,1 4F 32,7682,0,2 50 49,1522,0,3 51 65,5364,0,0 62 5,120 - outside Gold Saucer desert4,0,1 63 10,2404,0,2 68 21,5044,0,3 69 32,7688,0,0 98 5,120 - North of Rocket Town8,0,1 99 10,2408,0,2 9C 21,5048,0,3 9D 32,7689,1,0 0A2 8,192 - Wutai island9,1,1 0A3 16,3849,1,2 0A6 24,5769,1,3 0A7 32,768B,1,0 0CA 3,072 - Snow fieldsB,1,1 0CB 6,144B,1,2 0CE 19,456B,1,3 0CF 32,768C,0,0 0D6 7,168 - Outside MideelC,0,1 0D7 14,336C,0,2 0DA 23,552C,0,3 0DB 32,768`
I can't guarantee those locations are accurate and don't worry about what the area column means; They're not the point. What IS the point is that the value in the encounter rate has to be LESS than any of these numbers in order to encounter a chocobo in the designated area. If none of these formations are selected then a random battle in the region will be selected. There's some other check I don't recognize that doesn't influence the calculations at all.

For example, I'm in the area around Junon with two max level chocobo lures. The chocobo rating is capped at 32.
A battle check occurs and the PRNGLUT gives me a 36.
36 << 12 = 147,456
147,456 / 32 = 4,608
Chocobo Formation 4E is encountered

If the PRNGLUT gives me 160, then I get
100 << 12 = 655,360
655,360 / 32 = 20,480
Chocobo Formation 4F is encountered
Title: Re: [FF7] Chocobo Encounters Chance
Post by: Raziel80 on 2021-06-29 22:39:57
For example, I'm in the area around Junon with two max level chocobo lures. The chocobo rating is capped at 32.
A battle check occurs and the PRNGLUT gives me a 36.
36 << 12 = 147,456
147,456 / 32 = 4,608
Chocobo Formation 4E is encountered

If the PRNGLUT gives me 160, then I get
160 << 12 = 655,360
655,360 / 32 = 20,480
Chocobo Formation 4F is encountered

Thanks. I'm also interested in the probability of all 4 chocobo battles on different areas of the world map.
So, according to this table:
Code: [Select]
`.-------------.-------.---------------.---------------.-----------------------.|Chocobo Lure |Rating:|Chance Chocobo |Chance Chocobo |Chance Chocobo         ||Materia Lvl: |       |battle Ranch:  |battle Junon:  |battle everywhere else:||-------------|-------|---------------|---------------|-----------------------||Level 1      |   8   |     75%       |      50%      |         25%           ||Level 3&4    |  16   |    100%       |     100%      |         50%           ||2x Lvl 3 or 4|  32   |    100%       |     100%      |        100%           |'-------------'-------'---------------'---------------'-----------------------'`The sum of the probabilities of 4 chocobo battles:
Chocobo Farm: 96
Junon: 64
Everywhere else: 32
I think that, max total probability of chocobo battles = 128. (Usually max total probability for other battles (encounters) = 64, as we can see in the Makou Reactor)
Which means that near the chocobo farm probability is 96 (or 75%) ( if the Chocobo Lure Rating = 8 ): 96 / 128 = 75%
Junon: 64 / 128 = 50%
everywhere else: 32 / 128 = 25%
So, if the Chocobo Lure Rating = 12, then: ( 96 * 12 / 8 ) / 128 = 144 / 128 = 112,5% (max 100%), where 96 - Overall probability of 4 chocobo battles at chocobo farm; 12 - Chocobo Lure Rating;
Junon: ( 64 * 12 / 8 ) / 128 = 96 / 128 = 75%
Everywhere else: ( 32 * 12 / 8 ) / 128 = 48 / 128 = 37,5%
But, this is just my theory based on the table above. Can you confirm my theory?
Title: Re: [FF7] Chocobo Encounters Chance
Post by: nfitc1 on 2021-06-30 00:09:00
You can probably work that out based on the information I posted above. With a maxed out lure rating of 32 you're guaranteed a chocobo encounter each time. They're not quite selected the same way a random battle is. If your lure value is high enough you will get a chocobo battle, else it will be a regular battle. Are you talking about encounter rates? Those are a little different and don't work the same way on the WM than they do on the fields.

Based on your table, a level 1 lure will give each battle encounter a 25% chance of being a chocobo battle "everywhere else" which isn't true because North of Rocket Town and Costa del Sol regions have higher chances of an encounter (about 58%). The Farm and Junon are correct, though. That "everywhere else" only applies to Wutai's, Mideel's, and Snow Field's tracks.

If you need a more detailed explanation and an actual table I might be able to provide one tomorrow.
Title: Re: [FF7] Chocobo Encounters Chance
Post by: Raziel80 on 2021-06-30 03:58:06
Are you talking about encounter rates? Those are a little different and don't work the same way on the WM than they do on the fields.
Yes. I want to know the chance of chocobo battles that are based on encounter rating.

Example for Special Formation battles (Back Attack 1, Back Attack 2, Side Attack, Ambush):
Junon Area - Grass                             Encounter Value:  32
Normal Battle #1:  16/64 Chance       Back Attack #1:     4/64 Chance
Row 1: 2x Nerosuferoth                Row 2: 2x Nerosuferoth
Normal Battle #2:  16/64 Chance       Back Attack #2:     4/64 Chance
Row 1: 2x Nerosuferoth                Row 1: 1x Nerosuferoth
Row 2: 1x Formula                        Row 2: 2x Nerosuferoth
Normal Battle #3:  16/64 Chance
Row 1: 1x Zemzelett
Normal Battle #4:  16/64 Chance
Row 1: 1x Zemzelett,
2x Nerosuferoth

We have 2 special formation battles with 4/64 Chance: 4 + 4 = 8/64 Chance for special formation battles, and 64 - 8 = 56 / 64 = Chance for Normal Battles.

According to the Enemy Mechanics FAQ by TFergusson:
Spoiler: show
Each unique area can support up to: 6 Normal battles and 4 Special Formation battles.
In addition, World Map areas can support a further 4 Chocobo battles.
As soon as the chance succeeds and a random battle is going to occur, the following things are considered in order:
Unique/Chocobo Battles
Pre-emptive Chance
Special Formations
Normal Battles

If the area has any Special Formation battles, you have a chance of getting them first.
All Special Formation Battles have a chance out of 64 of occurring.
The chance of not getting a Special Formation battle is equal to 64/64 minus the sum of the probabilities of all available Special Formation battles.

Example for Chocobo Battles 1, 2, 3, 4:
Junon Area - Chocobo tracks (if Chocobo lure rating > 0)
Chocobo Battle 1 = 16/128 Chance (I think it is 16/128, and not 16/64)
Chocobo Battle 2 = 16/128 Chance
Chocobo Battle 3 = 16/128 Chance
Chocobo Battle 4 = 16/128 Chance
16*4 = 64/128 Chance for Chocobo battles (50% as we can see in the table above)

Chocobo Farm Area - Chocobo tracks
Chocobo Battle 1 = 24/128 Chance (I think it is 24/128, and not 24/64)
Chocobo Battle 2 = 24/128 Chance
Chocobo Battle 3 = 24/128 Chance
Chocobo Battle 4 = 24/128 Chance
24*4 = 96/128 Chance (75% as we can see in the table above)

Gold Saucer Area - Chocobo tracks (near Gold Saucer Desert)
Chocobo Battle 1 = 5/128 Chance
Chocobo Battle 2 = 5/128 Chance
Chocobo Battle 3 = 11/128 Chance
Chocobo Battle 4 = 11/128 Chance
5+5+11+11 = 32/128 Chance (25%)
Spoiler: show

Rocket Town Area - Chocobo tracks
Chocobo Battle 1 = 5/128 Chance
Chocobo Battle 2 = 5/128 Chance
Chocobo Battle 3 = 11/128 Chance
Chocobo Battle 4 = 11/128 Chance
5+5+11+11 = 32/128 Chance (25%)

Wutai Area - Chocobo tracks
Chocobo Battle 1 = 8/128 Chance
Chocobo Battle 2 = 8/128 Chance
Chocobo Battle 3 = 8/128 Chance
Chocobo Battle 4 = 8/128 Chance
8*4 = 32/128 Chance (25%)

Icicle Area (Snow Field) - Chocobo tracks
Chocobo Battle 1 = 3/128 Chance
Chocobo Battle 2 = 3/128 Chance
Chocobo Battle 3 = 13/128 Chance
Chocobo Battle 4 = 13/128 Chance
3+3+13+13 = 32/128 Chance (25%)

Mideel Area - Chocobo tracks
Chocobo Battle 1 = 7/128 Chance
Chocobo Battle 2 = 7/128 Chance
Chocobo Battle 3 = 9/128 Chance
Chocobo Battle 4 = 9/128 Chance
7+7+9+9 = 32/128 Chance (25%)

But 32/128 Chance (25%) if the Chocobo lure rating = 8.
And 32/128 Chance (25%) possibly multiplied by Chocobo lure rating and divided by 8: (32 * 8/8) / 128 = 32/128 (25%).
So,  for Chocobo lure rating 16:  (32 * 16/8) / 128 = 64/128 Chance (50%);
for Chocobo lure rating 32: (32 * 32/8) / 128 = 128/128 Chance (100%), which is the same as the table above. I don't know who created this table, but it seems to be true. Because with Chocobo lure rating we can increase chance for Chocobo battles. And of course, this is just a theory based on the table.

If you need a more detailed explanation and an actual table I might be able to provide one tomorrow.
Yes, it would be nice. Because I do not know, how Chocobo lure rating increases chance for Chocobo battles. My only guess is that the Chocobo lure rating increases the Chocobo encounter rating while calculating the instructions, and this increases the chance of chocobo battles.
Title: Re: [FF7] Chocobo Encounters Chance
Post by: nfitc1 on 2021-06-30 14:47:50
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: [Select]
`Cchance = RND[0..255] << 12 / (lure rate)CEncounter = (Chocobo Battle 1 chance)Chosen Battle = -1If Cchance < CEncounter Then   Chosen Battle = Chocobo Formation 1Else   CEncounter = CEncounter + (Chocobo Battle 2 chance)End IfIf Cchance < CEncounter Then   Chosen Battle = Chocobo Formation 2Else   CEncounter = CEncounter + (Chocobo Battle 3 chance)End IfIf Cchance < CEncounter Then   Chosen Battle = Chocobo Formation 3Else   CEncounter = CEncounter + (Chocobo Battle 4 chance)End IfIf Cchance < CEncounter Then   Chosen Battle = Chocobo Formation 4End IfIf Chosen battle = -1 Then   <pick a random battle from zone's encounter table> End If`
Let's take a look at the Cchance values:

Code: [Select]
`Lure rating on the topRND down the left 4 8 12 16 20 24 28 320 0 0 0 0 0 0 0 01 1024 512 341 256 204 170 146 1282 2048 1024 682 512 409 341 292 2563 3072 1536 1024 768 614 512 438 3844 4096 2048 1365 1024 819 682 585 5125 5120 2560 1706 1280 1024 853 731 6406 6144 3072 2048 1536 1228 1024 877 7687 7168 3584 2389 1792 1433 1194 1024 8968 8192 4096 2730 2048 1638 1365 1170 1024...245 250880 125440 83626 62720 50176 41813 35840 31360246 251904 125952 83968 62976 50380 41984 35986 31488247 252928 126464 84309 63232 50585 42154 36132 31616248 253952 126976 84650 63488 50790 42325 36278 31744249 254976 127488 84992 63744 50995 42496 36425 31872250 256000 128000 85333 64000 51200 42666 36571 32000251 257024 128512 85674 64256 51404 42837 36717 32128252 258048 129024 86016 64512 51609 43008 36864 32256253 259072 129536 86357 64768 51814 43178 37010 32384254 260096 130048 86698 65024 52019 43349 37156 32512255 261120 130560 87040 65280 52224 43520 37302 32640`
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: [Select]
` 8 12 16 20 24 28 32Farm 75 100 100 100 100 100 100Junon 50 75 100 100 100 100 100Other locations 25 37.5 50 62.5 75 87.5 100`
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: [Select]
` 8 12 16 20 24 28 32Farm1 25 28.1 37.5 46.8 56.3 65.6 75Farm2 25 28.1 37.5 46.8 43.7 34.4 25Farm3 25 28.1 25 6.3 0 0 0Farm4 25 15.6 0 0 0 0 0Junon1 25 25 25 31.3 37.5 43.8 50Junon2 25 25 25 31.3 37.5 43.8 50Junon3 25 25 25 31.3 25 12.5 0Junon4 25 25 25 6.1 0 0 0GS/RT1 15.6 15.6 15.6 15.6 15.6 15.6 15.6GS/RT2 15.6 15.6 15.6 15.6 15.6 15.6 15.6GS/RT3 34.4 34.4 34.4 34.4 34.4 34.4 34.4GS/RT4 34.4 34.4 34.4 34.4 34.4 34.4 34.4Wutai1 25 25 25 25 25 25 25Wutai2 25 25 25 25 25 25 25Wutai3 25 25 25 25 25 25 25Wutai4 25 25 25 25 25 25 25Snow1 9.4 9.4 9.4 9.4 9.4 9.4 9.4Snow2 9.4 9.4 9.4 9.4 9.4 9.4 9.4Snow3 40.6 40.6 40.6 40.6 40.6 40.6 40.6Snow4 40.6 40.6 40.6 40.6 40.6 40.6 40.6Mideel1 21.9 21.9 21.9 21.9 21.9 21.9 21.9Mideel2 21.9 21.9 21.9 21.9 21.9 21.9 21.9Mideel3 28.1 28.1 28.1 28.1 28.1 28.1 28.1Mideel4 28.1 28.1 28.1 28.1 28.1 28.1 28.1`
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%
Title: Re: [FF7] Chocobo Encounters Chance
Post by: Raziel80 on 2021-07-01 09:33:09
I guess I didn't make myself clear in either of my previous posts.
It was clear. I just used the familiar encounter rating system out of habit.

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: [Select]
` 8 12 16 20 24 28 32Farm1 25 28.1 37.5 46.8 56.3 65.6 75Farm2 25 28.1 37.5 46.8 43.7 34.4 25Farm3 25 28.1 25 6.3 0 0 0Farm4 25 15.6 0 0 0 0 0Junon1 25 25 25 31.3 37.5 43.8 50Junon2 25 25 25 31.3 37.5 43.8 50Junon3 25 25 25 31.3 25 12.5 0Junon4 25 25 25 6.1 0 0 0`
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.

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: [Select]
` 8 12 16 20 24 28 32Farm 75 100 100 100 100 100 100Junon 50 75 100 100 100 100 100Costa del Sol &Rocket Town ~58 ~86.7 100 100 100 100 100Other locations 25 37.5 50 62.5 75 87.5 100`
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.

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.
Yes, something wrong with them. :) I had Rocket Town4 (RT4) battle with Chocobo lure rating 32.

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%
According to your table: the chance of getting Mideel2 with a mastered lure is 21.9% * 50% = 10.95%
Title: Re: [FF7] Chocobo Encounters Chance
Post by: nfitc1 on 2021-07-01 13:42:10
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: [Select]
`GS/RT1 5120GS/RT2 10240GS/RT3 21504GS/RT4 32768`
I'll update the tables above accordingly so there's as little duplicate data as possible.

According to your table: the chance of getting Mideel2 with a mastered lure is 21.9% * 50% = 10.95%
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. :(
Title: Re: [FF7] Chocobo Encounters Chance
Post by: Raziel80 on 2021-07-03 11:16:42
I still can't get my game to load and test them myself.