User Tools

Site Tools


fusion:technical:rng

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Last revisionBoth sides next revision
fusion:technical:rng [2018/01/27 18:19] – created oneof99fusion:technical:rng [2018/01/27 18:25] oneof99
Line 1: Line 1:
 Random elements on Fusion are determined on a per-enemy basis. Each enemy/sprite has an RNG value between 0-15 (0-F) that changes every frame. This is the primary value used for most randomness in the game. Random elements on Fusion are determined on a per-enemy basis. Each enemy/sprite has an RNG value between 0-15 (0-F) that changes every frame. This is the primary value used for most randomness in the game.
- +  
- +  
-Random elements include: +Random elements include:\\ 
-Enemy spawns +Enemy spawns\\ 
-X-parasite refills +X-parasite refills\\ 
-Eyedoor open/shoot +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, since the 8-bit portion of the 16-bit counter is always the same, but the reason for this is irrelevant. Both counters start running the moment the game starts and they never stop.\\ 
-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, since the 8-bit portion of the 16-bit counter is always the same, but the reason for this is irrelevant. Both counters start running the moment the game starts and they never stop. + \\
 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/sprites in the current room. Each slot is 56 (0x38) in length. This is simply a value from 0-23. +EnemySlot: There are 24 slots for enemies/sprites in the current room. Each slot is 56 (0x38) in length. This is simply a value from 0-23.\\ 
- +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 34:
  
 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's location.\\ 
-note: this is based on where the X spawns, which is not always the same as the enemy's location. + \\ 
-/n +Eyedoor open/shoot:\\ 
-Eyedoor open/shoot: +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
fusion/technical/rng.txt · Last modified: 2018/01/27 18:26 by oneof99