User File #11501746348848149

Upload All User Files

#11501746348848149 - HUD display for The Adventures of Batman and Robin v2

TheAdventuresOfBatmanAndRobin.lua
1074 downloads
Uploaded 12/22/2013 11:11 PM by Truncated (see all 22)
Some more changes:
- moved the position and speed info to the right, so that it is not hidden below the "State X saved/loaded".
- changed the colors to match Batman and Robin.
- changed the way position subpixels are presented: one byte rather than two bytes, actual value rather than rounded decimal.
- did not change the speed to the same format, even though I wanted to, because of binary representation of negative numbers.
-- The Adventures of Batman and Robin
-- 2013, feos and r57shell
function EnemyPos(Base)
  x1 = memory.readwordsigned(Base+0x12)-xcam
  y1 = memory.readwordsigned(Base+0x14)
  x2 = memory.readwordsigned(Base+0x16)-xcam
  y2 = memory.readwordsigned(Base+0x18)
  hp = memory.readwordsigned(Base+0x1E)
end
function PlayerPos()
  sbase1 = memory.readword(0xFFAD5C)+0xFF0000
  sbase2 = memory.readword(0xFFADB6)+0xFF0000
  p1speedx = memory.readlongsigned(sbase1+0x18)/0x10000
  p1speedy = memory.readlongsigned(sbase1+0x1C)/0x10000
  p2speedx = memory.readlongsigned(sbase2+0x18)/0x10000
  p2speedy = memory.readlongsigned(sbase2+0x1C)/0x10000
end
function Collision()
  wx1 = memory.getregister("d6") - xcam
  wy1 = memory.getregister("d7")
  wx2 = memory.getregister("d4") - xcam
  wy2 = memory.getregister("d5")
  gui.box(wx1,wy1,wx2,wy2,"#ff000000")
end
function Hitbox(address)
  i = 0
  base = memory.readword(address) 
  while (base~=0) do
    base = base+0xFF0000
    if (memory.readword(base+2) == 0) then
      break
    end
    EnemyPos(base)
    if (address == 0xFFDEB2) then
      gui.box(x1,y1,x2,y2,"#00ff0000")
    elseif (address == 0xFFDEBA) then
      gui.box(x1,y1,x2,y2,"#00ffff00")
      gui.text(x1+2,y1+1,hp,"#ff00ff")
      if (x2<   0) then gui.text(x1+2,y2-7,"x:"..x1    ) end
      if (x1>=320) then gui.text(x1+2,y2-7,"x:"..x1-320) end
      if (y2<   0) then gui.text(x2+2,y2-7,"y:"..y2    ) end    
    end
    base = memory.readword(base+2)
    i = i+1
    if (i>400) then
      break
    end
  end
end
function Main()
  xcam = memory.readwordunsigned(0xFFDFC4)
  ycam = memory.readwordunsigned(0xFFCD70)
  --X1 = memory.readlongsigned(0xFFAD92)/10000
  X1 = memory.readword(0xFFAD92)
  X1sub = memory.readbyte(0xFFAD94)
  --Y1 = memory.readlongsigned(0xFFAD96)/10000
  Y1 = memory.readword(0xFFAD96)
  Y1sub = memory.readbyte(0xFFAD98)
  
  --X2 = memory.readlongsigned(0xFFADEC)/10000
  X2 = memory.readword(0xFFADEC)
  X2sub = memory.readbyte(0xFFADEE)
  --Y2 = memory.readlongsigned(0xFFADF0)/10000
  Y2 = memory.readword(0xFFADF0)
  Y2sub = memory.readbyte(0xFFADF2)
  
  wpn1 = memory.readbyte(0xFFF64D)
  wpn2 = memory.readbyte(0xFFF67B)
  PlayerPos()
  Hitbox(0xFFDEB2)
  Hitbox(0xFFDEBA)
  gui.text( 81,210,string.format("Pos  : %d:%d\nSpeed: %.5f",X1,X1sub,p1speedx),"#AAAAAA")
  gui.text(153,210,string.format("/ %d:%d\n/ %.5f",Y1,Y1sub,p1speedy),"#AAAAAA")
  gui.text(196,210,string.format("Pos  : %d:%d\nSpeed: %.5f",X2,X2sub,p2speedx),"#00BB00")
  gui.text(268,210,string.format("/ %d:%d\n/ %.5f",Y2,Y2sub,p2speedy),"#00BB00")
end
gui.register(Main)
memory.registerexec(0x8C9A, Collision)