Guest User

Untitled

a guest
Jul 1st, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. local camx
  2. local camy
  3.  
  4. function findbit(p)
  5.     return 2 ^ (p - 1)
  6. end
  7.  
  8. function hasbit(x, p)
  9.     return x % (p + p) >= p
  10. end
  11.  
  12. local function hex(val)
  13.     val = string.format("%X",val)
  14.     if string.len(val) == 1 then
  15.         val = "0" .. val
  16.     end
  17.     return val
  18. end
  19.  
  20. local function camera()
  21.     camx = memory.readword(0x1E16)
  22.     camy = memory.readword(0x1E18)
  23. end
  24.  
  25. local function player()
  26.     local sword = 0x19C0
  27.     local x = memory.readword(0x19A4 + 2) - camx
  28.     local y = memory.readword(0x19A4 + 4) - camy
  29.     local xrad = memory.readbyte(0x019BA)
  30.     local yrad = memory.readbyte(0x019BC)
  31.     gui.box(x+xrad,y+yrad,x-xrad,y-yrad,"#0000FF30","#0000FFFF")
  32.    
  33.     -- Player sword:
  34.     if memory.readbyte(sword + 0xE) ~= 0 then
  35.         x = memory.readword(sword + 2) - camx
  36.         y = memory.readword(sword + 4) - camy
  37.         xrad = memory.readbyte(sword + 0x16)
  38.         yrad = memory.readbyte(sword + 0x18)
  39.         gui.box(x+xrad,y+yrad,x-xrad,y-yrad)
  40.     end
  41.    
  42.     gui.text(x,y,"P")
  43. end
  44.  
  45. local function objects()
  46.     for i = 2,31,1 do
  47.         local obase = memory.readword(0x83136E + (i * 2))
  48.         local otype = memory.readword(obase)
  49.         if obase ~= 0 then
  50.             if memory.readbyte(obase + 0x0E) and memory.readword(obase) ~= 01 then
  51.                 local x = memory.readword(obase + 2) - camx
  52.                 local y = memory.readword(obase + 4) - camy
  53.                 local xrad = memory.readbyte(obase + 0x16)
  54.                 local yrad = memory.readbyte(obase + 0x18)
  55.                
  56.                 gui.box(x+xrad,y+yrad,x-xrad,y-yrad,"#FF000030","#FF0000FF")
  57.                 --gui.text(x,y,"E" .. i .. "/" .. hex(obase) .. "/" .. hex(memory.readword(obase)))
  58.                
  59.             end
  60.         end
  61.     end
  62.  
  63.     local pjbase
  64.     --projectiles
  65.     for i = 0,31, 1 do
  66.         pjbase = 0x1BD4 + (0x12 * i)
  67.         local pj_type = memory.readbyte(pjbase)
  68.         local pj_xrad = 0
  69.         local pj_yrad = 0
  70.         if pj_type > 0 then
  71.             local pj_x = memory.readword(pjbase + 2) - camx
  72.             local pj_y = memory.readword(pjbase + 4) - camy
  73.            
  74.             if pj_type == 0x81 then
  75.                 pj_xrad = 4
  76.                 pj_yrad = 4
  77.                 gui.box(pj_x+pj_xrad,pj_y+pj_yrad,pj_x-pj_xrad,pj_y-pj_yrad,"#FF000030","#FF0000FF")
  78.             elseif pj_type == 1 then -- Player's bullets
  79.                 pj_xrad = 4
  80.                 pj_yrad = 4
  81.                 gui.box(pj_x+pj_xrad,pj_y+pj_yrad,pj_x-pj_xrad,pj_y-pj_yrad)
  82.             end
  83.         end
  84.     end
  85.    
  86. end
  87.  
  88. while true do
  89.     camera()
  90.     player()
  91.     objects()
  92.     emu.frameadvance()
  93. end
Advertisement
Add Comment
Please, Sign In to add comment