Advertisement
Guest User

Mask

a guest
Nov 3rd, 2013
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.74 KB | None | 0 0
  1. local camx
  2. local camy
  3. function findbit(p)
  4.     return 2 ^ (p - 1)
  5. end
  6.  
  7. function hasbit(x, p)
  8.     return x % (p + p) >= p
  9. end
  10.  
  11. local function hex(val)
  12.     val = string.format("%X",val)
  13.     if string.len(val) == 1 then
  14.         val = "0" .. val
  15.     end
  16.     return val
  17. end
  18.  
  19. local function camera()
  20.     camx = memory.readword(0x47)
  21.     camy = memory.readword(0x4F)
  22. end
  23.  
  24. local function drawbox(x1,x2,y1,y2,outl,fill)
  25.     gui.box(x1,y1,x2,y2,outl,fill)
  26. end
  27.  
  28. local function player()
  29.     local x = memory.readword(0x185C) - camx
  30.     local y = memory.readword(0x1860) - camy
  31.  
  32.     memory.registerexec(0x80B3F7, function()
  33.             if memory.getregister("Y") == 0x1858 then -- is player
  34.                 local x1 = memory.readword(0x7B) -camx
  35.                 local x2 = memory.readword(0x7D) -camx
  36.                 local y1 = memory.readword(0x7F) -camy
  37.                 local y2 = memory.readword(0x81) -camy
  38.                 drawbox(x1,x2,y1,y2,"#0000FF40","#0000FFFF")
  39.             end
  40.     end)
  41. end
  42.  
  43. local function enemies()
  44.     memory.registerexec(0x80AD32, function()
  45.    
  46.         if hasbit(memory.readword(0x1E + memory.getregister("Y")),findbit(15)) then
  47.             local flip = true
  48.         else
  49.             local flip = false
  50.         end
  51.        
  52.         local x = memory.readword((memory.getregister("DB") * 0x10000) + 4 + memory.getregister("Y")) -camx
  53.         local y = memory.readword((memory.getregister("DB") * 0x10000) + 8 + memory.getregister("Y")) -camy
  54.        
  55.         local x1 = memory.readword(0x77) -camx
  56.         local x2 = memory.readword(0x79) -camx
  57.         local y1 = memory.readwordsigned(0x838002 + memory.getregister("X")) + y
  58.         local y2 = memory.readwordsigned(0x838006 + memory.getregister("X")) + y
  59.        
  60.         drawbox(x1,x2,y1,y2,"#FF000040","#FF0000FF")
  61.     end)
  62. end
  63.  
  64. local function test()
  65.     --memory.writeword(0x7E2b96,1240)
  66. end
  67.  
  68. while true do
  69.     camera()
  70.     player()
  71.     enemies()
  72.     test()
  73.     emu.frameadvance()
  74. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement