This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
fusion:technical:rng [2018/01/27 18:19] – created oneof99 | fusion:technical:rng [2018/01/27 18:26] (current) – oneof99 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | === RNG Doc === | ||
+ | |||
Random elements on Fusion are determined on a per-enemy basis. Each enemy/ | Random elements on Fusion are determined on a per-enemy basis. Each enemy/ | ||
- | + | ||
- | + | ||
- | Random elements include: | + | Random elements include:\\ |
- | Enemy spawns | + | Enemy spawns\\ |
- | X-parasite refills | + | X-parasite refills\\ |
- | Eyedoor open/ | + | Eyedoor open/shoot\\ |
- | Eyedoor opening delay | + | Eyedoor opening delay\\ |
- | Zazabi wasted jumps | + | Zazabi wasted jumps\\ |
- | Zazabi crawl duration | + | Zazabi crawl duration\\ |
- | Serris pattern | + | Serris pattern\\ |
- | Yakuza rounds | + | Yakuza rounds\\ |
- | + | \\ | |
- | Maybe random: | + | Maybe random:\\ |
- | Arachnus | + | Arachnus\\ |
- | Mega-X | + | Mega-X\\ |
- | Nettori shots | + | Nettori shots\\ |
- | + | \\ | |
- | + | There are two frame counters involved in the calculation. One is a 16-bit counter at 0x3000002 (unsigned, 2 bytes) and the other is an 8-bit counter at 0x3000BE5 (unsigned, 1 byte). The 8-bit counter seems unnecessary, | |
- | There are two frame counters involved in the calculation. One is a 16-bit counter at 0x3000002 (unsigned, 2 bytes) and the other is an 8-bit counter at 0x3000BE5 (unsigned, 1 byte). The 8-bit counter seems unnecessary, | + | \\ |
Getting the RNG value is a two part process. First, an index value is calculated. Then, the index value is used to get the RNG value from an array of fixed values. The first part is shown below: | Getting the RNG value is a two part process. First, an index value is calculated. Then, the index value is used to get the RNG value from an array of fixed values. The first part is shown below: | ||
index = (EnemySlot + EnemyX + EnemyY + Frame1 + Frame2) % 32 | index = (EnemySlot + EnemyX + EnemyY + Frame1 + Frame2) % 32 | ||
- | EnemySlot: There are 24 slots for enemies/ | + | EnemySlot: There are 24 slots for enemies/ |
- | + | EnemyX: The x position of the enemy, located at 0x3000144 + EnemySlot*56 (unsigned, 2 bytes)\\ | |
- | EnemyX: The x position of the enemy, located at 0x3000144 + EnemySlot*56 (unsigned, 2 bytes) | + | EnemyY: The y position of the enemy, located at 0x3000142 + EnemySlot*56 (unsigned, 2 bytes)\\ |
- | + | Frame1: 8-bit frame counter at 0x3000BE5\\ | |
- | EnemyY: The y position of the enemy, located at 0x3000142 + EnemySlot*56 (unsigned, 2 bytes) | + | Frame2: 16-bit frame counter at 0x3000002 divided by 16\\ |
- | + | \\ | |
- | Frame1: 8-bit frame counter at 0x3000BE5 | + | |
- | + | ||
- | Frame2: 16-bit frame counter at 0x3000002 divided by 16 | + | |
- | + | ||
This formula will provide a value between 0-31. This serves as the index value for the following array: | This formula will provide a value between 0-31. This serves as the index value for the following array: | ||
Line 40: | Line 36: | ||
The array contains two of every value from 0-15. Most random elements are determined the frame before it happens, so this is when the value is read. | The array contains two of every value from 0-15. Most random elements are determined the frame before it happens, so this is when the value is read. | ||
- | + | \\ | |
- | + | Red X:\\ | |
- | Red X: | + | if (RN % 4)*256 + [0x3000BE5] >= 1024 - RedX, then a red x will spawn\\ |
- | if (RN % 4)*256 + [0x3000BE5] >= 1024 - RedX, then a red x will spawn | + | RedX = [82E4D58 + EnemyID*14]\\ |
- | RedX = [82E4D58 + EnemyID*14] | + | note: this is based on where the X spawns, which is not always the same as the enemy' |
- | note: this is based on where the X spawns, which is not always the same as the enemy' | + | \\ |
- | /n | + | Eyedoor open/shoot:\\ |
- | Eyedoor open/ | + | if RN <= 6, then the eyedoor will be vulnerable\\ |
- | if RN <= 6, then the eyedoor will be vulnerable | + | else, it will shoot\\ |
- | else, it will shoot | + | \\ |
- | + | Eyedoor opening delay:\\ | |
- | Eyedoor opening delay: | + | frames = 60 + RN*4\\ |
- | frames = 60 + RN*4 | + | \\ |
- | + | Core-X drops:\\ | |
- | Core-X drops: | + | if RN <= 4, then a green x will spawn\\ |
- | if RN <= 4, then a green x will spawn | + | else, a yellow x will spawn\\ |
- | else, a yellow x will spawn | + | \\ |
- | + | Zazabi wasted jumps:\\ | |
- | Zazabi wasted jumps: | + | jumps = (CurrRound-1) + RN/4, where CurrRound = [1-3]\\ |
- | jumps = (CurrRound-1) + RN/4, where CurrRound = [1-3] | + | \\ |
- | + | Zazabi crawl delay:\\ | |
- | Zazabi crawl delay: | + | frames = 60 + RN*8\\ |
- | frames = 60 + RN*8 | + | \\ |
- | + | Serris:\\ | |
- | Serris: | + | TODO\\ |
- | TODO | + | \\ |
- | + | Yakuza rounds:\\ | |
- | Yakuza rounds: | + | rounds = 1 + RN/4\\ |
- | rounds = 1 + RN/4 | + | \\ |
+ | Thanks to biospark for providing this information |