Guest User

Untitled

a guest
Oct 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.72 KB | None | 0 0
  1.  
  2. -- todo check player hitbox by setting breakpoint when he is hit by checking when he loses weapon
  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 test()
  12.     local x = memory.readbyte(0x206)
  13.     local y = memory.readbyte(0x210)
  14.     local x2 = memory.readbyte(0x228)
  15.     local y2 = memory.readbyte(0x22a)
  16.     local x_offscreen = memory.readbyte(0x207)
  17.     local y_offscreen = memory.readbyte(0x211)
  18.     local x2_offscreen = memory.readbyte(0x229)
  19.     local y2_offscreen = memory.readbyte(0x22b)
  20.    
  21.     -- Checks if the box went off screen and adjusts
  22.     if x2_offscreen == 1 then
  23.         x2 = 255 + x2
  24.     elseif x2_offscreen == 255 then
  25.         x2 = 0 -(255 - x2)
  26.     end
  27.    
  28.     if y2_offscreen == 1 then
  29.         y2 = 255 + y
  30.     elseif y2_offscreen == 255 then
  31.         y2 = 0 - (255 - y2)
  32.     end
  33.    
  34.     if x_offscreen == 1 then
  35.         x = 255 + x
  36.     elseif x_offscreen == 255 then
  37.         x = 0 -(255 - x)
  38.     end
  39.  
  40.     if y_offscreen == 1 then
  41.         y = 255 + y
  42.     elseif y_offscreen == 255 then
  43.         y = 0 - (255 - y)
  44.     end
  45.    
  46.     gui.text(100,100,x .. "/" .. x2)
  47.     gui.text(100,108,y .. "/" .. y2)
  48.     gui.text(100,116,"offscreens x/y: " .. x2_offscreen .. "/" .. y2_offscreen)
  49.     gui.box(x,y,x2,y2,"#0000FF35","#0000FFFF")
  50. end
  51.  
  52. local function testobjects()
  53.     local start = 0x240
  54.     local base = 0
  55.     local oend = 33
  56.     local x
  57.     local x_offscreen
  58.     local y
  59.     local y_offscreen
  60.     local xrad
  61.     local yrad
  62.     local active
  63.     local touch
  64.     local projectile
  65.     local hp
  66.    
  67.     for i = 0,oend,1 do
  68.         base = start
  69.        
  70.         if i > 0 then
  71.             base = start + (i * 0x40)
  72.         end
  73.        
  74.         active = memory.readbyte(base + 0x16)
  75.         hp = memory.readword(base + 6)
  76.         if active > 0 then
  77.            
  78.             touch = hasbit(active,findbit(4))
  79.             projectile = hasbit(active,findbit(5))
  80.            
  81.             x = memory.readbyte(base + 0xa)
  82.             x2 = memory.readbyte
  83.             x_offscreen = memory.readbyte(base + 0xb)
  84.             y = memory.readbyte(base + 0xe)
  85.             y_offscreen = memory.readbyte(base + 0xf)
  86.             xrad = memory.readwordsigned(base+0x28)
  87.             yrad = memory.readwordsigned(base+0x2A)
  88.             x2  = x
  89.            
  90.             -- Checks if the box went off screen and adjusts
  91.             if x_offscreen == 1 then
  92.                 x = 255 + x
  93.             elseif x_offscreen == 255 then
  94.                 x = 0 -(255 - x)
  95.             end
  96.            
  97.             if y_offscreen == 1 then
  98.                 y = 255 + y
  99.             elseif y_offscreen == 255 then
  100.                 y = 0 - (255 - y)
  101.             end
  102.            
  103.             if projectile and touch == true then
  104.                  gui.box(x,y,x+ xrad,y+yrad,"#FF000035","#FF0000FF")
  105.             elseif projectile == true then
  106.                 gui.box(x,y,x+ xrad,y+yrad,"#00FF0035","#00FF00FF")
  107.             elseif touch == true then
  108.                 gui.box(x,y,x + xrad,y + yrad,"#FFFF0035","#FFFF00FF")
  109.             end
  110.             if hp > 0 then
  111.                 gui.text(x-5,y-5,"HP: " .. hp)
  112.             end
  113.         end
  114.     end
  115.    
  116. end
  117.  
  118. while true do
  119.     test()
  120.     testobjects()
  121.     emu.frameadvance()
  122. end
Add Comment
Please, Sign In to add comment