User:Blaziken257/Telefang RNG: Difference between revisions
Blaziken257 (talk | contribs) (Created page with "In Telefang 1, random events rely on a random number generator. It is generated using the following variables: * The frame counter, located at <tt>0x3C30</tt> in RAM. This i...") |
Blaziken257 (talk | contribs) m (I don't know why I had the page structured like that...) |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
In [[Telefang 1]], random events rely on a random number generator. It is generated using the following variables: | In [[Telefang 1]], random events rely on a random number generator. It is generated using the following variables: | ||
* The frame counter, located at <tt> | * The frame counter, located at <tt>0xC3C0</tt> in RAM. This is an 8-bit number, and it increments by 1 for every frame that passes (1 frame = 1/60 second). However, it temporarily freezes in certain situations, mainly when the game has to load screens. The frame counter makes random actions frame dependent. | ||
* Seed 1, located at <tt>0xC41F</tt> in RAM. This value is also an 8-bit number, and it changes every time a random event occurs, and its value depends on the current value of the frame counter, as well as the current values of both seeds. | * Seed 1, located at <tt>0xC41F</tt> in RAM. This value is also an 8-bit number, and it changes every time a random event occurs, and its value depends on the current value of the frame counter, as well as the current values of both seeds. | ||
* Seed 2, located at <tt>0xC420</tt> in RAM. This 8-bit value functions similarly to Seed 1, although it influences the randomly generated number more than Seed 1. | * Seed 2, located at <tt>0xC420</tt> in RAM. This 8-bit value functions similarly to Seed 1, although it influences the randomly generated number more than Seed 1. | ||
Line 87: | Line 87: | ||
| 0-19, 240-255<span class="explain" title="This is most likely a bug.">*</span> | | 0-19, 240-255<span class="explain" title="This is most likely a bug.">*</span> | ||
| <span class="explain" title="36/256 or 14.0625%">14%</span> | | <span class="explain" title="36/256 or 14.0625%">14%</span> | ||
| 0 | | 0 - のんびり | ||
|- | |- | ||
| 20-39 | | 20-39 | ||
| <span class="explain" title="20/256 or 7.8125%">8%</span> | | <span class="explain" title="20/256 or 7.8125%">8%</span> | ||
| 1 | | 1 - ちょーのんびり | ||
|- | |- | ||
| 40-59 | | 40-59 | ||
| <span class="explain" title="20/256 or 7.8125%">8%</span> | | <span class="explain" title="20/256 or 7.8125%">8%</span> | ||
| 2 | | 2 - あわてもの | ||
|- | |- | ||
| 60-79 | | 60-79 | ||
| <span class="explain" title="20/256 or 7.8125%">8%</span> | | <span class="explain" title="20/256 or 7.8125%">8%</span> | ||
| 3 | | 3 - ちょーあわてもの | ||
|- | |- | ||
| 80-99 | | 80-99 | ||
| <span class="explain" title="20/256 or 7.8125%">8%</span> | | <span class="explain" title="20/256 or 7.8125%">8%</span> | ||
| 4 | | 4 - わがまま | ||
|- | |- | ||
| 100-119 | | 100-119 | ||
| <span class="explain" title="20/256 or 7.8125%">8%</span> | | <span class="explain" title="20/256 or 7.8125%">8%</span> | ||
| 5 | | 5 - ちょーわがまま | ||
|- | |- | ||
| 120-139 | | 120-139 | ||
| <span class="explain" title="20/256 or 7.8125%">8%</span> | | <span class="explain" title="20/256 or 7.8125%">8%</span> | ||
| 6 | | 6 - おくびょう | ||
|- | |- | ||
| 140-159 | | 140-159 | ||
| <span class="explain" title="20/256 or 7.8125%">8%</span> | | <span class="explain" title="20/256 or 7.8125%">8%</span> | ||
| 7 | | 7 - ちょーおくびよう | ||
|- | |- | ||
| 160-179 | | 160-179 | ||
| <span class="explain" title="20/256 or 7.8125%">8%</span> | | <span class="explain" title="20/256 or 7.8125%">8%</span> | ||
| 8 | | 8 - おこりんぼ | ||
|- | |- | ||
| 180-199 | | 180-199 | ||
| <span class="explain" title="20/256 or 7.8125%">8%</span> | | <span class="explain" title="20/256 or 7.8125%">8%</span> | ||
| 9 | | 9 - ちょーおこりんぼ | ||
|- | |- | ||
| 200-219 | | 200-219 | ||
| <span class="explain" title="20/256 or 7.8125%">8%</span> | | <span class="explain" title="20/256 or 7.8125%">8%</span> | ||
| 10 | | 10 - りちぎ | ||
|- | |- | ||
| 220-239 | | 220-239 | ||
| <span class="explain" title="20/256 or 7.8125%">8%</span> | | <span class="explain" title="20/256 or 7.8125%">8%</span> | ||
| 11 | | 11 - ちょーりちぎ | ||
|} | |||
===Battle events=== | |||
====Move accuracy==== | |||
<!--167E9--> | |||
''More research needed!'' | |||
(<0xD597>/8 + 245 - <0xD49B>/2)/256 | |||
Little is known about 0xD597, but preliminary research suggests that it's based on the speed of the attacking Denjuu. Accuracy modifiers seem to increase this value, but this appears to max out at a certain value (which seems to vary based on other variables), possibly to prevent overflow in the formula. Likewise, little is known about 0xD49B, but preliminary research suggests that it's based on the speed of the defending Denjuu. Evasion modifiers seem to increase this value (there may be a limit, but it isn't known yet). Despite the values being based off of the speed stat, speed modifiers don't affect this value. | |||
If the move used doesn't target the opponent Denjuu (i.e. it affects itself, like a stat boosting move), then both of these values seem to be based on the Speed stat (likely with evasion modifiers applied, but this is not confirmed) of the ''opponent'' Denjuu. | |||
====Critical hits==== | |||
<!--1707B--> | |||
{| class="wikitable" | |||
|- | |||
! Random number range | |||
! Probability | |||
! Effect | |||
|- | |||
| 0-15 | |||
| <span class="explain" title="16/256">6.25%</span> | |||
| Critical hit! | |||
|- | |||
| 16-255 | |||
| <span class="explain" title="240/256">93.75%</span> | |||
| Regular hit | |||
|} | |} | ||
====Damage calculation==== | |||
====Added effects of moves==== | |||
====Status effects==== | |||
====Personality flaws==== | |||
<!--154BE (0-3) / 13746 (4-5) / 16D0C (6-7) / 14B38 (8-9) --> | |||
''More research needed!'' | |||
== | For some personalities, including 0 (のんびり), 1 (ちょーのんびり), 2 (あわてもの), 3 (ちょーあわてもの) (late to arrive), 6 (おくびょう), 7 (ちょーおくびよう) (prone to run away), 8 (おこりんぼ), and 9 (ちょーおこりんぼ) (attacking on its own): | ||
=== | {| class="wikitable" | ||
=== | |- | ||
=== | ! Random number range | ||
=== | ! Probability | ||
=== AI === | ! Effect | ||
==== Target selection ==== | |- | ||
==== Move selection ==== | | colspan="3" | Probability: ((FD*2+55) mod 256)/256 | ||
=== Escaping === | |- | ||
| colspan="3" | When FD = 1: | |||
|- | |||
| 0-56 | |||
| <span class="explain" title="57/256 or 22.265625%">22%</span> | |||
| Act normal | |||
|- | |||
| 57-255 | |||
| <span class="explain" title="199/256 or 77.734375%">78%</span> | |||
| Misbehave | |||
|- | |||
| colspan="3" | When FD = 100: | |||
|- | |||
| 0-254 | |||
| <span class="explain" title="255/256 or 99.609375%">99.6%</span> | |||
| Act normal | |||
|- | |||
| 255 | |||
| <span class="explain" title="1/256 or .390625%">.4%</span> | |||
| Misbehave | |||
|} | |||
For other personalities, including 4 (わがまま) and 5 (ちょーわがまま) (refusing to attack): | |||
{| class="wikitable" | |||
|- | |||
! Random number range | |||
! Probability | |||
! Effect | |||
|- | |||
| colspan="3" | Probability: ((FD+155) mod 256)/256 | |||
|- | |||
| colspan="3" | When FD = 1: | |||
|- | |||
| 0-155 | |||
| <span class="explain" title="156/256 or 60.9375%">61%</span> | |||
| Act normal | |||
|- | |||
| 156-255 | |||
| <span class="explain" title="100/256 or 39.0625%">39%</span> | |||
| Misbehave | |||
|- | |||
| colspan="3" | When FD = 100: | |||
|- | |||
| 0-254 | |||
| <span class="explain" title="255/256 or 99.609375%">99.6%</span> | |||
| Act normal | |||
|- | |||
| 255 | |||
| <span class="explain" title="1/256 or .390625%">.4%</span> | |||
| Misbehave | |||
|} | |||
Notes: | |||
* In both cases, due to an oversight, when FD = 100, there is a 1/256 chance that the Denjuu will misbehave, which occurs when the random number comes up as 255. This is similar to the 99.6% accuracy glitch in early Pokémon games. | |||
* There is a [http://s15.zetaboards.com/Tulunk_Village/topic/6997763/1/ glitch] that makes it possible to make the Denjuu's FD exceed 100. Since the formulas are not meant for the FD to exceed 100, an integer overflow glitch occurs, making the probability of the Denjuu acting normal very low. | |||
====AI==== | |||
=====Target selection===== | |||
=====Move selection===== | |||
====Escaping==== | |||
<!--70A99--> | <!--70A99--> | ||
''More research needed!'' | ''More research needed!'' | ||
When 0xD504 <= 0xD546 (note: these addresses' behavior | When 0xD504 <= 0xD546 (note: these addresses' behavior aren't completely known; see below): | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 152: | Line 244: | ||
! Random number range | ! Random number range | ||
! Probability | ! Probability | ||
! | ! Effect | ||
|- | |- | ||
| 0-199 | | 0-199 | ||
Line 163: | Line 255: | ||
|} | |} | ||
When 0xD504 > 0xD546 (note: these addresses' behavior | When 0xD504 > 0xD546 (note: these addresses' behavior aren't completely known; see below): | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 169: | Line 261: | ||
! Random number range | ! Random number range | ||
! Probability | ! Probability | ||
! | ! Effect | ||
|- | |- | ||
| 0-84 | | 0-84 | ||
Line 180: | Line 272: | ||
|} | |} | ||
== Denjuu giving out number == | Little is known about 0xD504, although it appears to be based on the Speed of the user's leading Denjuu. This appears to be affected by speed modifiers as well. Likewise, little is known about 0xD546, although it appears to be based on the Speed of the opponent's leading Denjuu, and may also be affected by speed modifiers (although this is not confirmed). | ||
Before a battle, however, these values are always 0. Therefore, when trying to escape before the battle starts, the probability of being able to escape is always 22%. | |||
Note: In some battles, particularly where a boss or other NPC is fought, the RNG is not invoked, and the player will never be able to escape. | |||
===Denjuu giving out number=== | |||
<!-- 741C9 --> | |||
If player does not yet have any other befriended Denjuu of the same species: | |||
{| class="wikitable" | |||
|- | |||
! Random number range | |||
! Probability | |||
! Effect | |||
|- | |||
| 0-152 | |||
| <span class="explain" title="153/256 or 59.765625%">60%</span> | |||
| Denjuu offers number | |||
|- | |||
| 153-255 | |||
| <span class="explain" title="103/256 or 40.234375%">40%</span> | |||
| Denjuu does not offer number | |||
|} | |||
If player has at least one other befriended Denjuu of the same species: | |||
{| class="wikitable" | |||
|- | |||
! Random number range | |||
! Probability | |||
! Effect | |||
|- | |||
| 0-15 | |||
| <span class="explain" title="16/256">6.25%</span> | |||
| Denjuu offers number | |||
|- | |||
| 16-255 | |||
| <span class="explain" title="240/256">93.75%</span> | |||
| Denjuu does not offer number | |||
|} |
Latest revision as of 17:39, 12 June 2012
In Telefang 1, random events rely on a random number generator. It is generated using the following variables:
- The frame counter, located at 0xC3C0 in RAM. This is an 8-bit number, and it increments by 1 for every frame that passes (1 frame = 1/60 second). However, it temporarily freezes in certain situations, mainly when the game has to load screens. The frame counter makes random actions frame dependent.
- Seed 1, located at 0xC41F in RAM. This value is also an 8-bit number, and it changes every time a random event occurs, and its value depends on the current value of the frame counter, as well as the current values of both seeds.
- Seed 2, located at 0xC420 in RAM. This 8-bit value functions similarly to Seed 1, although it influences the randomly generated number more than Seed 1.
- Seed sum, the 8-bit sum of the two seeds, located at 0xC400 in RAM. This is the randomly generated number, most directly used to determine random events.
Seed calculation[edit]
Note: Original thread here: http://s15.zetaboards.com/Tulunk_Village/topic/6967791/1/
First, the game takes the current value of the frame counter and uses a formula to calculate a new 16-bit number, which is later added to the seeds.
F = (Frame counter * 256) + ((int(((Swap nibbles(Frame counter) + 1) mod 256) / 2) + 135) mod 256)
Next, the game calculates a number based on the current value of the two seeds. This formula is simpler:
S = Seed 1 * 256 + Seed 2
To obtain seed 1:
Seed 1new = ((F+S) mod 256)
To obtain seed 2:
Seed 2new = (int(((F+S) mod 65536)/256)) xor ((F+S) mod 256)
The seeds are then added together (reduced to 8 bits), and this is the randomly generated number.
Random events[edit]
Wild Denjuu[edit]
Species[edit]
For more information, see one of these pages.
Random number range | Probability | Denjuu Group |
---|---|---|
0-24 | 10% | Denjuu 4 |
25-75 | 20% | Denjuu 3 |
76-152 | 30% | Denjuu 2 |
153-255 | 40% | Denjuu 1 |
Level[edit]
Random number range | Probability | Level offset |
---|---|---|
0-63 | 25% | +1 |
64-127 | 25% | -1 |
128-255 | 50% | 0 |
Personality[edit]
Random number range | Probability | Personality |
---|---|---|
0-19, 240-255* | 14% | 0 - のんびり |
20-39 | 8% | 1 - ちょーのんびり |
40-59 | 8% | 2 - あわてもの |
60-79 | 8% | 3 - ちょーあわてもの |
80-99 | 8% | 4 - わがまま |
100-119 | 8% | 5 - ちょーわがまま |
120-139 | 8% | 6 - おくびょう |
140-159 | 8% | 7 - ちょーおくびよう |
160-179 | 8% | 8 - おこりんぼ |
180-199 | 8% | 9 - ちょーおこりんぼ |
200-219 | 8% | 10 - りちぎ |
220-239 | 8% | 11 - ちょーりちぎ |
Battle events[edit]
Move accuracy[edit]
More research needed!
(<0xD597>/8 + 245 - <0xD49B>/2)/256
Little is known about 0xD597, but preliminary research suggests that it's based on the speed of the attacking Denjuu. Accuracy modifiers seem to increase this value, but this appears to max out at a certain value (which seems to vary based on other variables), possibly to prevent overflow in the formula. Likewise, little is known about 0xD49B, but preliminary research suggests that it's based on the speed of the defending Denjuu. Evasion modifiers seem to increase this value (there may be a limit, but it isn't known yet). Despite the values being based off of the speed stat, speed modifiers don't affect this value.
If the move used doesn't target the opponent Denjuu (i.e. it affects itself, like a stat boosting move), then both of these values seem to be based on the Speed stat (likely with evasion modifiers applied, but this is not confirmed) of the opponent Denjuu.
Critical hits[edit]
Random number range | Probability | Effect |
---|---|---|
0-15 | 6.25% | Critical hit! |
16-255 | 93.75% | Regular hit |
Damage calculation[edit]
Added effects of moves[edit]
Status effects[edit]
Personality flaws[edit]
More research needed!
For some personalities, including 0 (のんびり), 1 (ちょーのんびり), 2 (あわてもの), 3 (ちょーあわてもの) (late to arrive), 6 (おくびょう), 7 (ちょーおくびよう) (prone to run away), 8 (おこりんぼ), and 9 (ちょーおこりんぼ) (attacking on its own):
Random number range | Probability | Effect |
---|---|---|
Probability: ((FD*2+55) mod 256)/256 | ||
When FD = 1: | ||
0-56 | 22% | Act normal |
57-255 | 78% | Misbehave |
When FD = 100: | ||
0-254 | 99.6% | Act normal |
255 | .4% | Misbehave |
For other personalities, including 4 (わがまま) and 5 (ちょーわがまま) (refusing to attack):
Random number range | Probability | Effect |
---|---|---|
Probability: ((FD+155) mod 256)/256 | ||
When FD = 1: | ||
0-155 | 61% | Act normal |
156-255 | 39% | Misbehave |
When FD = 100: | ||
0-254 | 99.6% | Act normal |
255 | .4% | Misbehave |
Notes:
- In both cases, due to an oversight, when FD = 100, there is a 1/256 chance that the Denjuu will misbehave, which occurs when the random number comes up as 255. This is similar to the 99.6% accuracy glitch in early Pokémon games.
- There is a glitch that makes it possible to make the Denjuu's FD exceed 100. Since the formulas are not meant for the FD to exceed 100, an integer overflow glitch occurs, making the probability of the Denjuu acting normal very low.
AI[edit]
Target selection[edit]
Move selection[edit]
Escaping[edit]
More research needed!
When 0xD504 <= 0xD546 (note: these addresses' behavior aren't completely known; see below):
Random number range | Probability | Effect |
---|---|---|
0-199 | 78% | Unable to escape |
200-255 | 22% | Able to escape |
When 0xD504 > 0xD546 (note: these addresses' behavior aren't completely known; see below):
Random number range | Probability | Effect |
---|---|---|
0-84 | 33% | Unable to escape |
85-255 | 67% | Able to escape |
Little is known about 0xD504, although it appears to be based on the Speed of the user's leading Denjuu. This appears to be affected by speed modifiers as well. Likewise, little is known about 0xD546, although it appears to be based on the Speed of the opponent's leading Denjuu, and may also be affected by speed modifiers (although this is not confirmed).
Before a battle, however, these values are always 0. Therefore, when trying to escape before the battle starts, the probability of being able to escape is always 22%.
Note: In some battles, particularly where a boss or other NPC is fought, the RNG is not invoked, and the player will never be able to escape.
Denjuu giving out number[edit]
If player does not yet have any other befriended Denjuu of the same species:
Random number range | Probability | Effect |
---|---|---|
0-152 | 60% | Denjuu offers number |
153-255 | 40% | Denjuu does not offer number |
If player has at least one other befriended Denjuu of the same species:
Random number range | Probability | Effect |
---|---|---|
0-15 | 6.25% | Denjuu offers number |
16-255 | 93.75% | Denjuu does not offer number |