Advertisement
Guest User

Run Saber Hitbox Script

a guest
Nov 18th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.41 KB | None | 0 0
  1. while true do
  2.    
  3.     camx = mainmemory.read_u16_le(0x000548)
  4.     camy = mainmemory.read_u16_le(0x00054A)
  5.    
  6.     textX=30
  7.     textY=50
  8.    
  9.     hp = mainmemory.read_u8(0x001F3A)
  10.     gui.text(textX,textY,string.format("HP:  %d",hp))
  11.     diff = mainmemory.read_u8(0x001F0F)
  12.    
  13.     memory.usememorydomain("CARTROM")
  14.    
  15.     hitbox_left = mainmemory.read_u16_le(0x000270)
  16.     hitbox_right = mainmemory.read_u16_le(0x000272)
  17.     hitbox_up = mainmemory.read_u16_le(0x000274)
  18.     hitbox_down = mainmemory.read_u16_le(0x000276)
  19.    
  20.     if(mainmemory.read_u8(0x000E1D)~=0xFF) then
  21.         attack_right = mainmemory.read_u16_le(0x000280)
  22.         attack_left = mainmemory.read_u16_le(0x000282)
  23.         attack_up = mainmemory.read_u16_le(0x000284)
  24.         attack_down = mainmemory.read_u16_le(0x000286)
  25.    
  26.        
  27.             gui.drawBox(attack_left-camx,attack_up-camy,attack_right-camx, attack_down-camy,"green")
  28.            
  29.     end
  30.    
  31.     if(mainmemory.read_u8(0x000E1E)~=0x00) then
  32.         gui.drawBox(hitbox_left-camx,hitbox_up-camy,hitbox_right-camx, hitbox_down-camy,"blue")
  33.     else
  34.         gui.drawBox(hitbox_left-camx,hitbox_up-camy,hitbox_right-camx, hitbox_down-camy,"white")
  35.     end
  36.    
  37.    
  38.     hitbox_left = mainmemory.read_u16_le(0x000278)
  39.     hitbox_right = mainmemory.read_u16_le(0x00027A)
  40.     hitbox_up = mainmemory.read_u16_le(0x00027C)
  41.     hitbox_down = mainmemory.read_u16_le(0x00027E)
  42.    
  43.     if(mainmemory.read_u8(0x000E3D)~=0xFF) then
  44.         attack_right = mainmemory.read_u16_le(0x000288)
  45.         attack_left = mainmemory.read_u16_le(0x00028A)
  46.         attack_up = mainmemory.read_u16_le(0x00028C)
  47.         attack_down = mainmemory.read_u16_le(0x00028E)
  48.    
  49.         gui.drawBox(attack_left-camx,attack_up-camy,attack_right-camx, attack_down-camy,"green")
  50.     end
  51.    
  52.     if(mainmemory.read_u8(0x000E3E)~=0x00) then
  53.         gui.drawBox(hitbox_left-camx,hitbox_up-camy,hitbox_right-camx, hitbox_down-camy,"blue")
  54.     else
  55.         gui.drawBox(hitbox_left-camx,hitbox_up-camy,hitbox_right-camx, hitbox_down-camy,"white")
  56.     end
  57.    
  58.    
  59.    
  60.    
  61.     for i = 2,0x0F,1 do
  62.        
  63.         if(mainmemory.read_u8(0x000e00+(i*0x20))>0) then
  64.        
  65.         ID = mainmemory.read_u8(0x000e00+(i*0x20))*4
  66.        
  67.         NEWDC = mainmemory.read_u8(0x000e1c+(i*0x20))*4
  68.        
  69.         pos_x = mainmemory.read_u16_le(0x000e10+(i*0x20))
  70.         pos_y = mainmemory.read_u16_le(0x000e12+(i*0x20))
  71.        
  72.         offset_x = memory.read_u8(0x038A00+NEWDC)
  73.         length_x = memory.read_u8(0x038A01+NEWDC)
  74.         offset_y = memory.read_u8(0x038A02+NEWDC)
  75.         length_y = memory.read_u8(0x038A03+NEWDC)
  76.        
  77.  
  78.         drop_offset = memory.read_u8(0x0091eb+ID)
  79.         if(drop_offset >=0x04) then
  80.             if(diff==0x00) then
  81.                 drop_sub = bit.rshift(drop_offset,1)
  82.             elseif(diff==0x10) then
  83.                 drop_sub = drop_offset + bit.rshift(drop_offset,2)
  84.             else
  85.                 drop_sub = drop_offset
  86.             end
  87.         else
  88.             drop_sub = drop_offset
  89.         end
  90.        
  91.         gui.drawPixel(pos_x-camx, pos_y-camy,"red")
  92.        
  93.         if(mainmemory.read_u8(0x000E0C+(i*0x20))==0) then
  94.             mycolor = "red"
  95.         else
  96.             mycolor = "white"
  97.         end
  98.        
  99.         if(bit.band(mainmemory.read_u8(0x000e07+(i*0x20)),0x40)~=0) then
  100.             gui.drawBox(pos_x-camx+offset_x-length_x,pos_y-camy-offset_y,pos_x-camx+offset_x, pos_y-camy-offset_y+length_y,mycolor)
  101.         else
  102.             gui.drawBox(pos_x-camx-offset_x+length_x,pos_y-camy-offset_y,pos_x-camx-offset_x, pos_y-camy-offset_y+length_y,mycolor)
  103.         end
  104.        
  105.         damage = mainmemory.read_u8(0x000e14+(i*0x20))
  106.         max_hp = mainmemory.read_u8(0x000e15+(i*0x20))
  107.        
  108.         drop_index = mainmemory.read_u8(0x000e17+(i*0x20))
  109.         drop_count = mainmemory.read_u8(0x000d00+drop_index)
  110.         drop_type = memory.read_u8(0x0091ec+ID)
  111.        
  112.         if(drop_type == 0x05) then
  113.             if(mainmemory.read_u8(0x000e19)==0x01) then
  114.                 drop_color = "red" -- Bomb
  115.             else
  116.                 drop_color = "green" -- Sword Up
  117.             end
  118.         elseif(drop_type == 0x01) then -- HP Up
  119.             if(mainmemory.read_u8(0x000e19)==0x01) then
  120.                 drop_color = "purple" -- HP Up
  121.             else
  122.                 drop_color = "green" -- Sword Up
  123.             end
  124.         elseif(drop_type == 0x03) then -- Big HP Up
  125.             if(mainmemory.read_u8(0x000e19)==0x01) then
  126.                 drop_color = "blue" -- Big HP Up
  127.             else
  128.                 drop_color = "green" -- Sword Up
  129.             end
  130.         elseif(drop_type == 0x07) then -- HP or bomb?
  131.             if(bit.band(mainmemory.read_u8(0x00005c),0x01)==0) then
  132.                 drop_color = "purple" -- HP Up
  133.             else
  134.                 drop_color = "red" -- Bomb
  135.             end
  136.         else
  137.             drop_color = "white"
  138.         end
  139.        
  140.        
  141.         if(max_hp-damage < 128 and max_hp-damage ~= 0) then
  142.  
  143.             gui.drawText(pos_x-camx, pos_y-camy,string.format("%d",max_hp-damage))
  144.            
  145.         end
  146.        
  147.         if(drop_sub<0x20 and drop_sub>0) then
  148.             if(((drop_sub-(drop_count))%drop_sub)~=0) then
  149.                 gui.drawText(pos_x-camx, pos_y-camy+10,string.format("%d",(drop_sub-(drop_count))%drop_sub),drop_color)
  150.             else
  151.                 gui.drawText(pos_x-camx, pos_y-camy+10,string.format("%d",(drop_sub)),drop_color)
  152.             end
  153.         end
  154.        
  155.         end
  156.     end
  157.    
  158.     for i = 0,0x0f,1 do --was 7
  159.         --if(i<8 and i>=0x0c) then
  160.             ID = mainmemory.read_u8(0x000c00+(i*0x10))
  161.             if(ID>0) then
  162.            
  163.                 addr_offset = mainmemory.read_u8(0x000c0e+(i*0x10))*8
  164.            
  165.                 pos_x = mainmemory.read_u16_le(0x000c05+(i*0x10))
  166.                 pos_y = mainmemory.read_u16_le(0x000c07+(i*0x10))
  167.            
  168.                 offset_x = memory.read_u8(0x009045+addr_offset)
  169.                 length_x = memory.read_u8(0x009047+addr_offset)
  170.                 offset_y = memory.read_u8(0x009049+addr_offset)
  171.                 length_y = memory.read_u8(0x00904B+addr_offset)
  172.            
  173.                 gui.drawBox(pos_x-camx+offset_x,pos_y-camy+offset_y,pos_x-camx+offset_x+length_x, pos_y-camy+offset_y+length_y,"purple")
  174.                
  175.                 --gui.drawText(pos_x-camx, pos_y-camy,string.format("%d",mainmemory.read_u8(0x000c01+(i*0x10))))
  176.  
  177.             end
  178.         --end
  179.     end
  180.    
  181.     emu.frameadvance()
  182. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement