Advertisement
biosp4rk

Zero Mission - Charlie Script

Jun 16th, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | None | 0 0
  1. -- Charlie uses the following formula for calculating delays:
  2. --     BaseDelay + [808C99C + [3000C77]]
  3. -- BaseDelay = 120 for the first round and when Samus shoots too early
  4. -- BaseDelay = 240 for the second, third, and fourth rounds
  5. -- 3000C77 is a 1 byte frame counter, so its values range from 0-255
  6. -- 808C99C is the location of a table containing the values 0-255 in a random order
  7. -- Therefore, the best delay is 120 or 240, while the worst delay is 375 or 495
  8.  
  9. -- This script displays three different things:
  10. --   The current timer value is in the top left corner
  11. --   The first column shows what the new timer value will be if Charlie
  12. --     is hit successfully within the first n frames it becomes vulnerable
  13. --   The second column shows what the new timer value will be
  14. --     if Samus hits Charlie too early within the next n frames
  15.  
  16. -- change this value to see a different number of frames
  17. frameWindow = 18
  18.  
  19. while true do
  20.    
  21.     -- display timer
  22.     local timer = memory.readword(0x3000814)
  23.     gui.text(2, 2, timer)
  24.    
  25.     -- calculate delay if Charlie is successfully hit
  26.     local frame = memory.readbyte(0x3000C77)
  27.     -- calculation is done 3 frames after being hit
  28.     local vulnerable = (timer + frame + 3) % 256
  29.     for i=1,frameWindow do
  30.         local delay = memory.readbyte(0x808C99C + vulnerable)
  31.         color = { delay, 255 - delay, 32 }
  32.         gui.text(18, -6 + i*8, 240 + delay, color)
  33.         vulnerable = (vulnerable + 1) % 256
  34.     end
  35.    
  36.     -- calculate delay if Samus shoots too early
  37.     for i=1,frameWindow do
  38.         local delay = memory.readbyte(0x808C99C + frame)
  39.         color = { delay, 255 - delay, 32 }
  40.         gui.text(34, -6 + i*8, 120 + delay, color)
  41.         frame = (frame + 1) % 256
  42.     end
  43.  
  44.     vba.frameadvance()
  45.    
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement