Advertisement
biosp4rk

Zero Mission - Eyedoor Script

Feb 13th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.68 KB | None | 0 0
  1. index = 1
  2. 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 }
  3.  
  4. while true do
  5.  
  6.     if memory.readword(0x30001C0 + index*56) > 0 then
  7.         -- display eyedoor activation region
  8.         local cameraX, cameraY = memory.readword(0x30013B8), memory.readword(0x30013BA)
  9.         local enemyX, enemyY = memory.readword(0x30001B0 + index*56), memory.readword(0x30001AE + index*56)
  10.  
  11.         local xStart = bit.arshift(enemyX - 0x1C0 - cameraX, 2)
  12.         local yStart = bit.arshift(enemyY - 0x80 - cameraY, 2)
  13.         local xEnd = bit.arshift(enemyX + 0x1C0 - cameraX, 2)
  14.         local yEnd = bit.arshift(enemyY + 0x80 - cameraY, 2)
  15.    
  16.         gui.box(xStart, yStart, xEnd, yEnd, "#00F00020", "#20C020")
  17.    
  18.         -- check if in range
  19.         local samusX, samusY = memory.readword(0x30013E6), memory.readword(0x30013E8)
  20.         if math.abs(samusX - enemyX) < 0x1C0 and math.abs(samusY - enemyY) < 0x80 then
  21.             gui.text(3, 11, "In", "green")
  22.         else
  23.             gui.text(3, 11, "Out", "red")
  24.         end
  25.    
  26.         -- calculate when eyedoor will open
  27.         local timer1 = memory.readbyte(0x30001D8 + index*56)
  28.    
  29.         local frame1 = (memory.readbyte(0x3000C77) + timer1) % 256
  30.         local frame2 = (memory.readword(0x3000002) + timer1) % 65536
  31.         local enRN = rns[((frame1 + bit.rshift(frame2, 4) + index + enemyX + enemyY) % 32) + 1]
  32.         local timer2 = timer1 + 61 + enRN * 4
  33.    
  34.         frame1 = (memory.readbyte(0x3000C77) + timer2) % 256
  35.         frame2 = (memory.readword(0x3000002) + timer2) % 65536
  36.         enRN = rns[((frame1 + bit.rshift(frame2, 4) + index + enemyX + enemyY) % 32) + 1]
  37.         local timer3 = timer2 + 61 + enRN * 4
  38.    
  39.         gui.text(3, 19, timer1)
  40.         gui.text(3, 27, timer2)
  41.         gui.text(3, 35, timer3)
  42.     end
  43.    
  44.     vba.frameadvance()
  45.  
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement