Advertisement
Guest User

Mega Man ZX enemy GUI stuff

a guest
Apr 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.28 KB | None | 0 0
  1. currentIndex = 1
  2. maxIndex = 30
  3. firstSpawnIndex = 0x02153A1A
  4. indexOffset = 0xD0
  5.  
  6. -- Custom commands
  7. local lastInput = {}
  8. function executeCustomCommands()
  9.     local Input = input.get()
  10.    
  11.     if Input.F and not lastInput.F then
  12.         increaseIndex()
  13.         -- if you reached an illegal index, continue increasing it
  14.         -- stop at 1 in any case to prevent an endless loop
  15.         local loopCounter = maxIndex
  16.         while loopCounter > 0 and controlSpawnByte(getIndexAddr(currentIndex)) == false do
  17.         increaseIndex()
  18.         loopCounter = loopCounter - 1
  19.         end
  20.     -- Print a notice for the user
  21.     print("New index = " .. currentIndex)
  22.     end
  23.     if Input.D and not lastInput.D then
  24.         print("Number of spawned enemies: " .. countEnemies())
  25.     end
  26.     lastInput = Input
  27. end
  28.  
  29. function countEnemies()
  30.     local counter = 0
  31.     local i = 1
  32.     while i <= maxIndex do
  33.         if controlSpawnByte2(getIndexAddr(i)) then
  34.             counter = counter + 1
  35.         end
  36.         i = i + 1
  37.     end
  38.     return counter
  39. end
  40.  
  41. function increaseIndex()
  42.     currentIndex = currentIndex + 1
  43.     if currentIndex > maxIndex then
  44.         currentIndex = 1
  45.     end
  46. end
  47.  
  48. function getIndexAddr(index)
  49.     return firstSpawnIndex + (index - 1) * indexOffset
  50. end
  51.  
  52. function controlSpawnByte(spawnByte)
  53.     local value = memory.readbyte(spawnByte)
  54.     return value ~= 0
  55. end
  56.  
  57. function controlSpawnByte2(spawnByte)
  58.     local value = memory.readbyte(spawnByte)
  59.     return value == 5 or value == 0x17 or value == 7 or value == 4
  60. end
  61.  
  62. function drawEnemyInfo(spawnByte)
  63.     local spawnValue = memory.readbyte(spawnByte)
  64.     if controlSpawnByte(spawnByte) then
  65.         addr1 = spawnByte - 0x10
  66.         value1 = memory.readbyte(addr1)
  67.         addr2 = spawnByte - 0xF
  68.         value2 = memory.readbyte(addr2)
  69.         addr3 = spawnByte - 0xA
  70.         value3 = memory.readbyte(addr3)
  71.         status = spawnByte - 0x8
  72.         value4 = memory.readbyte(status)
  73.         AI = spawnByte - 0x6
  74.         value5 = memory.readbyte(AI)
  75.         addr6 = spawnByte - 0x4
  76.         value6 = memory.readbyte(addr6)
  77.         addr7 = spawnByte - 0x3
  78.         value7 = memory.readbyte(addr7)
  79.         spawn4 = spawnByte - 0x2
  80.         value8 = memory.readdword(spawn4)
  81.         changeCrash = spawnByte + 0x1
  82.         value9 = memory.readbyte(changeCrash)
  83.         addr10 = spawnByte + 0x10
  84.         value10 = memory.readbyte(addr10)
  85.         addr11 = spawnByte + 0x11
  86.         value11 = memory.readbyte(addr11)
  87.         X = spawnByte + 0x42
  88.         value12 = memory.readdwordsigned(X)
  89.         Y = spawnByte + 0x46
  90.         value13 = memory.readdwordsigned(Y)
  91.         Xspeed = spawnByte + 0x4A
  92.         value14 = memory.readdwordsigned(Xspeed)
  93.         Yspeed = spawnByte + 0x4E
  94.         value15 = memory.readdwordsigned(Yspeed)
  95.         health = spawnByte + 0x90
  96.         value16 = memory.readbyte(health)
  97.         home = spawnByte + 0xA6
  98.         value17 = memory.readdword(home)
  99.         addr18 = spawnByte + 0xAE
  100.         value18 = memory.readbyte(addr18)
  101.         addr19 = spawnByte + 0xB2
  102.         value19 = memory.readbyte(addr19)
  103.         gui.text(1, 1, string.format ("%X", addr1) .. ": after death weird (try 0x13): " .. "0x" .. string.format ("%X", value1))
  104.         gui.text(1, 10, string.format ("%X", addr2) .. ": RB=visibility; LB=facing: " .. "0x" .. string.format ("%X", value2))
  105.         gui.text(1, 20, string.format ("%X", addr3) .. ": LB=huge hitbox possible: " .. "0x" .. string.format ("%X", value3))
  106.         gui.text(1, 30, "Status: " .. value4)
  107.         gui.text(1, 40, "AI: " .. value5)
  108.         gui.text(1, 50, "Animation wait timer: " .. value6)
  109.         gui.text(1, 60, string.format ("%X", spawn4) .. ": Spawn 4 bytes: " .. "0x" .. string.format ("%X", value8), "#00FF00")
  110.         gui.text(1, 70, "If changed, crashes: " .. value9)
  111.         gui.text(1, 80, string.format ("%X", addr10) .. ": " .. value10)
  112.         gui.text(1, 90, string.format ("%X", addr11) .. ": " .. value11)
  113.         gui.text(1, 100, string.format ("%X", X) .. ": X: " .. value12, "#00FF00")
  114.         gui.text(1, 110, string.format ("%X", Y) .. ": Y: " .. value13, "#00FF00")
  115.         gui.text(1, 120, string.format ("%X", Xspeed) .. ": X Speed: " .. value14)
  116.         gui.text(1, 130, string.format ("%X", Yspeed) .. ": Y Speed: " .. value15)
  117.         gui.text(1, 140, "Health: " .. value16, "#00FF00")
  118.         gui.text(1, 150, "Home: " .. value17)
  119.         gui.text(1, 160, string.format ("%X", addr18) .. ": " .. value18)
  120.         gui.text(1, 170, string.format ("%X", addr19) .. ": " .. value19)
  121.         gui.text(1, 180, "Spawn byte: " .. "0x" .. string.format ("%X", spawnValue))
  122.     end
  123. end
  124.  
  125. function drawGUI()
  126.     executeCustomCommands()
  127.     spawnByte = getIndexAddr(currentIndex)
  128.     drawEnemyInfo(spawnByte)
  129. end
  130.  
  131. gui.register(drawGUI)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement