Advertisement
biosp4rk

Metroid Fusion - RNG Explanation

Jul 15th, 2014
903
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  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.
  2.  
  3.  
  4. Random elements include:
  5. Enemy spawns
  6. X-parasite refills
  7. Eyedoor open/shoot
  8. Eyedoor opening delay
  9. Zazabi wasted jumps
  10. Zazabi crawl duration
  11. Serris pattern
  12. Yakuza rounds
  13.  
  14. Maybe random:
  15. Arachnus
  16. Mega-X
  17. Nettori shots
  18.  
  19.  
  20. 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.
  21.  
  22. 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:
  23.  
  24. index = (EnemySlot + EnemyX + EnemyY + Frame1 + Frame2) % 32
  25.  
  26. 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.
  27.  
  28. EnemyX: The x position of the enemy, located at 0x3000144 + EnemySlot*56 (unsigned, 2 bytes)
  29.  
  30. EnemyY: The y position of the enemy, located at 0x3000142 + EnemySlot*56 (unsigned, 2 bytes)
  31.  
  32. Frame1: 8-bit frame counter at 0x3000BE5
  33.  
  34. Frame2: 16-bit frame counter at 0x3000002 divided by 16
  35.  
  36.  
  37. This formula will provide a value between 0-31. This serves as the index value for the following array:
  38.  
  39. RNs = {13, 2, 6, 8, 7, 9, 14, 10, 2, 4, 14, 4, 12, 15, 13, 12, 11, 1, 3, 15, 0, 6, 7, 8, 11, 5, 0, 3, 5, 1, 9, 10}
  40.  
  41. 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.
  42.  
  43.  
  44. Red X:
  45. if (RN % 4)*256 + [0x3000BE5] >= 1024 - RedX, then a red x will spawn
  46. RedX = [82E4D58 + EnemyID*14]
  47. note: this is based on where the X spawns, which is not always the same as the enemy's location.
  48.  
  49. Eyedoor open/shoot:
  50. if RN <= 6, then the eyedoor will be vulnerable
  51. else, it will shoot
  52.  
  53. Eyedoor opening delay:
  54. frames = 60 + RN*4
  55.  
  56. Core-X drops:
  57. if RN <= 4, then a green x will spawn
  58. else, a yellow x will spawn
  59.  
  60. Zazabi wasted jumps:
  61. jumps = (CurrRound-1) + RN/4, where CurrRound = [1-3]
  62.  
  63. Zazabi crawl delay:
  64. frames = 60 + RN*8
  65.  
  66. Serris:
  67. TODO
  68.  
  69. Yakuza rounds:
  70. rounds = 1 + RN/4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement