Advertisement
Guest User

Untitled

a guest
Dec 15th, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.90 KB | None | 0 0
  1. -- Congo Caper's Collision Box Viewer
  2. -- Author: Pasky13
  3.  
  4. camx = 0
  5. camy = 0
  6.  
  7. memory.usememorydomain("CARTROM")
  8.  
  9. function findbit(p)
  10.     return 2 ^ (p - 1)
  11. end
  12.  
  13. function hasbit(x, p)
  14.     return x % (p + p) >= p
  15. end
  16.  
  17. local function RetrieveBox(obase, switch)
  18.     if switch == 1 then
  19.         pointer = mainmemory.read_u8(obase + 0x19)
  20.     elseif switch == 2 then
  21.         pointer = mainmemory.read_u8(obase + 0x18)
  22.     elseif switch == 3 then
  23.         pointer = mainmemory.read_u8(obase + 0x1A)
  24.     end
  25.    
  26.     local pointer = bit.lshift(pointer,3)
  27.     local base = 0x66962
  28.     local box = {0, 0, 0, 0 }
  29.     box[1] = memory.read_s16_le(base + pointer) -- x1
  30.     box[2] = memory.read_s16_le(base + pointer + 4) -- y1
  31.     box[3] = memory.read_s16_le(base + pointer + 2) -- x2
  32.     box[4] = memory.read_s16_le(base + pointer + 6) -- y2
  33.     return box
  34. end
  35.  
  36. local function camera()
  37.     camx = mainmemory.read_u16_le(0x7E0427)
  38.     camy = mainmemory.read_u16_le(0x7E0429)
  39. end
  40.  
  41. local function player()
  42.     local x = mainmemory.read_u16_le(0x23) - camx
  43.     local y = mainmemory.read_u16_le(0x26) - camy
  44.     local face = mainmemory.read_u8(0x2D)
  45.     local box
  46.     local box = RetrieveBox(0x20,1)
  47.     if hasbit(face,findbit(7)) then
  48.         gui.drawBox(x - box[1],y + box[2],x - box[3],y + box[4],0xFF0000FF,0x350000FF) -- Hurt box
  49.         box = RetrieveBox(0x20,2)
  50.         gui.drawBox(x - box[1],y + box[2],x - box[3],y + box[4],0xFFFFFFFF,0x35FFFFFF) -- Hit box
  51.     else
  52.         gui.drawBox(x + box[1],y + box[2],x + box[3],y + box[4],0xFF0000FF,0x350000FF) -- Hurt box
  53.         box = RetrieveBox(0x20,2)
  54.         gui.drawBox(x + box[1],y + box[2],x + box[3],y + box[4],0xFFFFFFFF,0x35FFFFFF) -- Hit box
  55.     end
  56. end
  57.  
  58. local function enemies()
  59.     local ebase = 0x1100
  60.     for i = 0,64,1 do
  61.         base = ebase + (i * 0x40)
  62.         if mainmemory.read_u8(base) > 0 then
  63.             local x = mainmemory.read_u16_le(base + 3) - camx
  64.             local y = mainmemory.read_u16_le(base + 6) - camy
  65.                    
  66.            
  67.             local face = mainmemory.read_u8(base + 0xD)
  68.             local box = RetrieveBox(base,2)
  69.            
  70.             if hasbit(face,findbit(7)) then
  71.                 gui.drawBox(x - box[1],y + box[2],x - box[3],y + box[4],0xFFFF0000,0x35FF0000) -- Hit box
  72.                 box = RetrieveBox(base,1)
  73.                 gui.drawBox(x - box[1],y + box[2],x - box[3],y + box[4],0xFF0000FF,0x350000FF) -- Hurt box
  74.                 box = RetrieveBox(base,3)
  75.                 gui.drawBox(x - box[1],y + box[2],x - box[3],y + box[4],0xFF00FF00,0x3500FF00) -- Can be jumped on box
  76.             else
  77.                 gui.drawBox(x + box[1],y + box[2],x + box[3],y + box[4],0xFFFF0000,0x35FF0000) -- Hit  box
  78.                 box = RetrieveBox(base,1)
  79.                 gui.drawBox(x + box[1],y + box[2],x + box[3],y + box[4],0xFF0000FF,0x350000FF) -- Hurt box
  80.                 box = RetrieveBox(base,3)
  81.                 gui.drawBox(x + box[1],y + box[2],x + box[3],y + box[4],0xFF00FF00,0x3500FF00)  -- Can be jumped on box
  82.             end
  83.         end
  84.     end
  85. end
  86.  
  87.  
  88.  
  89. local function scaler()
  90.     xm = client.screenwidth() / 256
  91.     ym = client.screenheight() / 224
  92. end
  93.  
  94. while true do
  95.     scaler()
  96.     camera()
  97.     player()
  98.     enemies()
  99.     emu.frameadvance()
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement