Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Joypad
- local Cheat_active = false
- local Options_form = {}
- -- Compatibility of the memory read/write functions
- local u8 = mainmemory.read_u8
- local s8 = mainmemory.read_s8
- local w8 = mainmemory.write_u8
- local u16 = mainmemory.read_u16_le
- local s16 = mainmemory.read_s16_le
- local w16 = mainmemory.write_u16_le
- local u24 = mainmemory.read_u24_le
- local s24 = mainmemory.read_s24_le
- local w24 = mainmemory.write_u32_le
- -- RAM
- local ADDR_ENEMY_TP = 0x0363
- local ADDR_ENEMY_X = 0x036b
- local ADDR_ENEMY_HP = 0x037b
- local ADDR_ENEMY_Y = 0x0373
- local ADDR_ITEM_X = 0x0598
- local ADDR_ITEM_Y = 0x05a8
- local ADDR_ITEM_ID = 0x0588
- local ADDR_ITEM_TP = 0x05e8
- local ADDR_ITEM_CT = 0x05f8
- -- Database
- local items = {
- "axe",
- "sword",
- "pistol",
- "smg",
- "lmg",
- "ak",
- "shotgun",
- "sniper",
- "handcannon",
- "rocket",
- "grenade",
- "bandage",
- "healthkit",
- "fuel",
- "sticks",
- "cloth",
- "shirt",
- "pants",
- "metal",
- "gem",
- "gunpowder",
- "campfire",
- "sneakers",
- "wizardhat",
- "armor",
- "tinfoilhat",
- "ghillie",
- "coffee",
- "wine"
- }
- --
- local fmt = string.format
- local floor = math.floor
- local function draw_grid()
- local delta = 8
- for x = delta, 256 - delta, delta do
- gui.drawLine(x, delta, x, 208 - delta, 0x40ffffff)
- end
- for y = 0, 208 - delta, delta do
- gui.drawLine(delta, y, 256 - delta, y, 0x40ffffff)
- end
- end
- function Options_form.create_window()
- Options_form.form = forms.newform(100, 80, "Cheat")
- local xform, yform, delta_y = 2, 0, 20
- -- Cheats label
- Options_form.label_cheats = forms.label(Options_form.form, "Cheats:", xform, yform)
- yform = yform + delta_y
- Options_form.allow_cheats = forms.checkbox(Options_form.form, "Allow cheats", xform, yform)
- forms.setproperty(Options_form.allow_cheats, "Checked", Cheat_active)
- end
- Options_form.create_window()
- -- MAIN
- event.onexit(function()
- local destroyed = forms.destroy(Options_form.form)
- client.SetGameExtraPadding(0, 0, 0, 0)
- client.SetClientExtraPadding(0, 0, 0, 0)
- print("Finishing script.")
- end, "AGDQ-exit")
- while true do
- -- Get input
- Joypad = joypad.get(1)
- Cheat_active = forms.ischecked(Options_form.allow_cheats)
- -- Read main info
- local x_position = u8(0x00df)
- local y_position = u8(0x00e0)
- local axe_timer = u8(0x0785)
- local HP = u8(0x00e3)
- local invisibility_timer = u8(0x0776)
- -- Cheat
- if Cheat_active and x_position >= 0 and x_position <= 224 and y_position >= 0 and y_position <= 178 then
- local boost = Joypad["B"] and 4 or 1
- if Joypad["Right"] then w8(0x00df, math.min(x_position + boost, 255)) end
- if Joypad["Left"] then w8(0x00df, math.max(x_position - boost, 0)) end
- if Joypad["Up"] then w8(0x00e0, math.max(y_position - boost, 0)) end
- if Joypad["Down"] then w8(0x00e0, math.min(y_position + boost, 255)) end
- end
- -- Display shit
- gui.text(0, 24, fmt("Pos (%d, %d)", x_position, y_position), "white", "black")
- gui.text(0, 38, fmt("HP %d", HP), "white", "black")
- gui.drawRectangle(x_position + 8, y_position + 8, 16, 16, "red", 0x400000ff)
- gui.drawPixel(x_position + 16, y_position + 16, "blue")
- -- Near player info
- local x_text, y_text = x_position, y_position - 8
- if axe_timer >= 21 then gui.drawText(x_text, y_text, axe_timer - 21, "white", 0xa0000000, 12) end
- x_text = x_text + 8
- if invisibility_timer ~= 0 then gui.drawText(x_text, y_text, invisibility_timer, "red", 0xa0000000, 12) end
- if Cheat_active then gui.text(0, 10, "CHEATING", "red", "blue") end
- draw_grid()
- -- asdf script
- local ytext_e = 8
- local ytext_i = 8
- local x_pos = 320
- local delta_x = 10
- gui.text(x_pos + 0*delta_x, ytext_e, "EnX")
- gui.text(x_pos + 4*delta_x, ytext_e, "EnY")
- gui.text(x_pos + 8*delta_x, ytext_e, "EnHP")
- gui.text(x_pos + 13*delta_x, ytext_e, "EnTy")
- for i = 0, 7 do
- local etype = memory.readbyte(i + ADDR_ENEMY_TP)
- if (etype ~= 255) then
- ytext_e = ytext_e + 16
- local ex = memory.readbyte(i + ADDR_ENEMY_X)
- local ey = memory.readbyte(i + ADDR_ENEMY_Y)
- local hp = memory.readbyte(i + ADDR_ENEMY_HP)
- gui.text(x_pos + 0*delta_x, ytext_e, tostring(ex))
- gui.text(x_pos + 4*delta_x, ytext_e, tostring(ey))
- gui.text(x_pos + 8*delta_x, ytext_e, tostring(hp))
- gui.text(x_pos + 13*delta_x, ytext_e, tostring(etype))
- gui.text(2*ex + 11, 2*ey + 20, tostring(hp))
- end
- ytext_i = ytext_i + 10
- ix = memory.readbyte(i + ADDR_ITEM_X)
- iy = memory.readbyte(i + ADDR_ITEM_Y)
- id = memory.readbyte(i + ADDR_ITEM_ID)
- it = memory.readbyte(i + ADDR_ITEM_TP) + 1
- ic = memory.readbyte(i + ADDR_ITEM_CT)
- if id == 18 then
- gui.text(2*ix + 8, 2*iy + 14, items[it].."("..tostring(ic)..")")
- end
- end
- -- Frame advance
- emu.frameadvance()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement