Advertisement
brunovalads

PwnZ Mixed Script

Jan 9th, 2016
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.88 KB | None | 0 0
  1. local Joypad
  2. local Cheat_active = false
  3. local Options_form = {}
  4.  
  5. -- Compatibility of the memory read/write functions
  6. local u8 =  mainmemory.read_u8
  7. local s8 =  mainmemory.read_s8
  8. local w8 =  mainmemory.write_u8
  9. local u16 = mainmemory.read_u16_le
  10. local s16 = mainmemory.read_s16_le
  11. local w16 = mainmemory.write_u16_le
  12. local u24 = mainmemory.read_u24_le
  13. local s24 = mainmemory.read_s24_le
  14. local w24 = mainmemory.write_u32_le
  15.  
  16. -- RAM
  17. local ADDR_ENEMY_TP = 0x0363
  18. local ADDR_ENEMY_X  = 0x036b
  19. local ADDR_ENEMY_HP = 0x037b
  20. local ADDR_ENEMY_Y  = 0x0373
  21.  
  22. local ADDR_ITEM_X   = 0x0598
  23. local ADDR_ITEM_Y   = 0x05a8
  24. local ADDR_ITEM_ID  = 0x0588
  25. local ADDR_ITEM_TP  = 0x05e8
  26. local ADDR_ITEM_CT  = 0x05f8
  27.  
  28. -- Database
  29. local items = {
  30.     "axe",
  31.     "sword",
  32.     "pistol",
  33.     "smg",
  34.     "lmg",
  35.     "ak",
  36.     "shotgun",
  37.     "sniper",
  38.     "handcannon",
  39.     "rocket",
  40.     "grenade",
  41.     "bandage",
  42.     "healthkit",
  43.     "fuel",
  44.     "sticks",
  45.     "cloth",
  46.     "shirt",
  47.     "pants",
  48.     "metal",
  49.     "gem",
  50.     "gunpowder",
  51.     "campfire",
  52.     "sneakers",
  53.     "wizardhat",
  54.     "armor",
  55.     "tinfoilhat",
  56.     "ghillie",
  57.     "coffee",
  58.     "wine"
  59. }
  60.  
  61.  
  62. --
  63. local fmt = string.format
  64. local floor = math.floor
  65.  
  66. local function draw_grid()
  67.     local delta = 8
  68.     for x = delta, 256 - delta, delta do
  69.         gui.drawLine(x, delta, x, 208 - delta, 0x40ffffff)
  70.     end
  71.     for y = 0, 208 - delta, delta do
  72.         gui.drawLine(delta, y, 256 - delta, y, 0x40ffffff)
  73.     end
  74. end
  75.  
  76.  
  77. function Options_form.create_window()
  78.     Options_form.form = forms.newform(100, 80, "Cheat")
  79.     local xform, yform, delta_y = 2, 0, 20
  80.    
  81.     -- Cheats label
  82.     Options_form.label_cheats = forms.label(Options_form.form, "Cheats:", xform, yform)
  83.    
  84.     yform = yform + delta_y
  85.     Options_form.allow_cheats = forms.checkbox(Options_form.form, "Allow cheats", xform, yform)
  86.     forms.setproperty(Options_form.allow_cheats, "Checked", Cheat_active)
  87. end
  88. Options_form.create_window()
  89.  
  90. -- MAIN
  91.  
  92. event.onexit(function()
  93.     local destroyed = forms.destroy(Options_form.form)
  94.     client.SetGameExtraPadding(0, 0, 0, 0)
  95.     client.SetClientExtraPadding(0, 0, 0, 0)
  96.     print("Finishing script.")
  97. end, "AGDQ-exit")
  98.  
  99. while true do
  100.     -- Get input
  101.     Joypad = joypad.get(1)
  102.     Cheat_active = forms.ischecked(Options_form.allow_cheats)
  103.    
  104.     -- Read main info
  105.     local x_position = u8(0x00df)
  106.     local y_position = u8(0x00e0)
  107.     local axe_timer = u8(0x0785)
  108.     local HP = u8(0x00e3)
  109.     local invisibility_timer = u8(0x0776)
  110.    
  111.     -- Cheat
  112.     if Cheat_active and x_position >= 0 and x_position <= 224 and y_position >= 0 and y_position <= 178 then
  113.         local boost = Joypad["B"] and 4 or 1
  114.         if Joypad["Right"] then w8(0x00df, math.min(x_position + boost, 255)) end
  115.         if Joypad["Left"] then w8(0x00df, math.max(x_position - boost, 0)) end
  116.         if Joypad["Up"] then w8(0x00e0, math.max(y_position - boost, 0)) end
  117.         if Joypad["Down"] then w8(0x00e0, math.min(y_position + boost, 255)) end
  118.     end
  119.    
  120.     -- Display shit
  121.     gui.text(0, 24, fmt("Pos (%d, %d)", x_position, y_position), "white", "black")
  122.     gui.text(0, 38, fmt("HP %d", HP), "white", "black")
  123.     gui.drawRectangle(x_position + 8, y_position + 8, 16, 16, "red", 0x400000ff)
  124.     gui.drawPixel(x_position + 16, y_position + 16, "blue")
  125.    
  126.     -- Near player info
  127.     local x_text, y_text = x_position, y_position - 8
  128.     if axe_timer >= 21 then gui.drawText(x_text, y_text, axe_timer - 21, "white", 0xa0000000, 12) end
  129.     x_text = x_text + 8
  130.     if invisibility_timer ~= 0 then gui.drawText(x_text, y_text, invisibility_timer, "red", 0xa0000000, 12) end
  131.    
  132.     if Cheat_active then gui.text(0, 10, "CHEATING", "red", "blue") end
  133.     draw_grid()
  134.    
  135.     -- asdf script
  136.     local ytext_e = 8
  137.     local ytext_i = 8
  138.     local x_pos = 320
  139.     local delta_x = 10
  140.    
  141.     gui.text(x_pos + 0*delta_x, ytext_e, "EnX")
  142.     gui.text(x_pos + 4*delta_x, ytext_e, "EnY")
  143.     gui.text(x_pos + 8*delta_x, ytext_e, "EnHP")
  144.     gui.text(x_pos + 13*delta_x, ytext_e, "EnTy")
  145.    
  146.     for i = 0, 7 do
  147.         local etype = memory.readbyte(i + ADDR_ENEMY_TP)
  148.  
  149.         if (etype ~= 255) then
  150.             ytext_e = ytext_e + 16
  151.  
  152.             local ex = memory.readbyte(i + ADDR_ENEMY_X)
  153.             local ey = memory.readbyte(i + ADDR_ENEMY_Y)
  154.             local hp = memory.readbyte(i + ADDR_ENEMY_HP)
  155.  
  156.             gui.text(x_pos + 0*delta_x, ytext_e, tostring(ex))
  157.             gui.text(x_pos + 4*delta_x, ytext_e, tostring(ey))
  158.             gui.text(x_pos + 8*delta_x, ytext_e, tostring(hp))
  159.             gui.text(x_pos + 13*delta_x, ytext_e, tostring(etype))
  160.  
  161.             gui.text(2*ex + 11, 2*ey + 20, tostring(hp))
  162.         end
  163.  
  164.         ytext_i = ytext_i + 10
  165.  
  166.         ix = memory.readbyte(i + ADDR_ITEM_X)
  167.         iy = memory.readbyte(i + ADDR_ITEM_Y)
  168.         id = memory.readbyte(i + ADDR_ITEM_ID)
  169.         it = memory.readbyte(i + ADDR_ITEM_TP) + 1
  170.         ic = memory.readbyte(i + ADDR_ITEM_CT)
  171.  
  172.         if id == 18 then
  173.             gui.text(2*ix + 8, 2*iy + 14, items[it].."("..tostring(ic)..")")
  174.         end
  175.     end
  176.    
  177.    
  178.     -- Frame advance
  179.     emu.frameadvance()
  180. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement