Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --2024.09.24发布
- --首发 http://forum.cheatmaker.org/
- --显示血量
- --按下大键盘 1- 9 开启作弊.
- -- 玩家地址信息
- local playerHPAddress = 0x519
- local playerXAddress = 0x50B
- local playerYAddress = 0x512
- local playerSubXAddress = 0x402
- local whipStatusAddress = 0x51C
- local playerSlotAddress = 0x500 -- 玩家槽地址
- local cheatCodes = {
- { code = "00B-348-195", name = "Don't Die From Falling Down A Pit" }, --不要因掉入坑而死
- { code = "00A-CF8-3B7", name = "Don't Lose Weapon From Getting Hit" }, --不要因为被击中而丢失武器
- { codes = {"002-71D-E62", "002-61D-A22"}, name = "Hit Anywhere" }, --全屏攻击.
- { code = "FF7-3CE-E69", name = "Improve Speed Slightly" }, --速度可能略有提升?
- { code = "C9A-8C8-E69", name = "Invincibility against Enemies" }, --无敌.
- { codes = {"FA8-55E-919", "FA4-17D-C41", "FA4-27D-C41", "FA3-BDD-D59", "FA4-1FD-C41"}, name = "Invincibility Against Spikes" }, --对抗尖刺所向披靡
- { codes = {"009-C9E-3B7", "CD9-BDE-4CA", "329-BEE-C42", "1A9-BFE-F77"}, name = "Jump In Midair" }, --按连发键的 跳进半空中.慎用.
- { code = "006-94F-3B7", name = "Infinite lives" }, --无限生命数.
- { code = "013-8CF-081", name = "Infinite Time" }, --无限时间.
- }
- local activeCheats = {} -- 激活中的作弊列表
- local memoryType = emu.memType.gbWorkRam
- local enemyAddresses = {0x600, 0x620, 0x640, 0x660, 0x680, 0x6A0, 0x6C0, 0x6E0}
- local fontColor = 0x0FFFFFFF
- local bgColor = 0x0FB8DF8B
- local borderColor = 0x0F000000
- local padding = 1
- -- 初始化变量
- local baseX = 0x59
- local whipStatusFrames = 0
- local lastWhipStatus = -1
- local cheatLog = "" -- 用于存储激活/禁用作弊信息
- local cheatLogFrames = 0 -- 用于跟踪作弊日志显示的帧数
- -- 获取玩家信息函数
- local function getPlayerInfo()
- local hp = emu.read(playerHPAddress, memoryType)
- local x = emu.read(playerXAddress, memoryType)
- local y = emu.read(playerYAddress, memoryType)
- local subX = emu.read(playerSubXAddress, memoryType)
- return hp, x, y, subX
- end
- local function getTextBoxWidth(text)
- local charWidth = 6 -- 调整字符宽度以适应菜单
- return #text * charWidth + padding * 2
- end
- local function toggleCheat(cheat)
- if activeCheats[cheat.name] then
- activeCheats[cheat.name] = nil
- cheatLog = "Cheat disabled: " .. cheat.name
- cheatLogFrames = 0 -- 重置帧计数器
- emu.log(cheatLog)
- emu.clearCheats()
- for _, activeCheat in ipairs(cheatCodes) do
- if activeCheats[activeCheat.name] then
- for _, code in ipairs(activeCheat.codes or {activeCheat.code}) do
- emu.addCheat(emu.cheatType.gbGameGenie, code)
- end
- end
- end
- else
- activeCheats[cheat.name] = true
- cheatLog = "Cheat activated: " .. cheat.name
- cheatLogFrames = 0
- emu.log(cheatLog)
- for _, code in ipairs(cheat.codes or {cheat.code}) do
- emu.addCheat(emu.cheatType.gbGameGenie, code)
- end
- end
- end
- local function drawWhipStatus()
- local playerSlotValue = emu.read(playerSlotAddress, memoryType)
- if playerSlotValue == 0x0 then
- return
- end
- local whipStatus = emu.read(whipStatusAddress, memoryType)
- local whipString = ""
- if whipStatus == 0x00 then
- whipString = "普通鞭子"
- elseif whipStatus == 0x01 then
- whipString = "金属鞭子"
- elseif whipStatus == 0x02 then
- whipString = "火球鞭子"
- else
- whipString = "未知"
- end
- if whipStatus ~= lastWhipStatus then
- whipStatusFrames = 0
- lastWhipStatus = whipStatus
- else
- whipStatusFrames = whipStatusFrames + 1
- end
- if whipStatusFrames <= 100 then
- local boxY = 131
- local fixedBoxX = 66
- emu.drawString(fixedBoxX, boxY, whipString, fontColor, 0x00000000)
- end
- end
- local function drawPlayerHP(hp, playerX, playerY, subX)
- local playerSlotValue = emu.read(playerSlotAddress, memoryType) -- 读取玩家槽地址的值
- if playerSlotValue == 0x0 then
- return
- end
- local hpString = tostring(hp)
- local boxWidth = getTextBoxWidth(hpString)
- local boxY = playerY - 40
- local boxX = (subX <= 3 and playerX <= 0x58) and playerX - (boxWidth / 2) - 9 or baseX - (boxWidth / 2) - 9
- emu.drawRectangle(boxX - 1, boxY - 1, boxWidth + 2, 9 + 2, borderColor, true)
- emu.drawRectangle(boxX, boxY, boxWidth, 9, bgColor, true)
- emu.drawString(boxX + padding, boxY + padding, hpString, fontColor, bgColor)
- end
- local function drawPlayerHPFixed()
- local playerSlotValue = emu.read(playerSlotAddress, memoryType) -- 读取玩家槽地址的值
- if playerSlotValue == 0x0 then
- return
- end
- local playerHP = emu.read(playerHPAddress, memoryType)
- local hpString = tostring(playerHP)
- local boxWidth = getTextBoxWidth(hpString)
- local fixedBoxX = 5
- local fixedBoxY = 132
- emu.drawRectangle(fixedBoxX - 1, fixedBoxY - 1, boxWidth + 2, 9 + 2, borderColor, true)
- emu.drawRectangle(fixedBoxX, fixedBoxY, boxWidth, 9, bgColor, true)
- emu.drawString(fixedBoxX + padding, fixedBoxY + padding, hpString, fontColor, bgColor)
- end
- local function drawEnemyHP()
- local fixedBoxX = 5
- local fixedBoxY = 120
- for _, enemyAddress in ipairs(enemyAddresses) do
- local enemyStatus = emu.read(enemyAddress, memoryType)
- if enemyStatus == 0x80 then
- local enemyHP = emu.read(enemyAddress + 0x19, memoryType)
- if enemyHP ~= 0xFF and enemyHP ~= 0 then
- local hpString = tostring(enemyHP)
- local boxWidth = getTextBoxWidth(hpString)
- emu.drawRectangle(fixedBoxX - 1, fixedBoxY - 1, boxWidth + 2, 9 + 2, borderColor, true)
- emu.drawRectangle(fixedBoxX, fixedBoxY, boxWidth, 9, bgColor, true)
- emu.drawString(fixedBoxX + padding, fixedBoxY + padding, hpString, fontColor, bgColor)
- end
- end
- end
- end
- local function drawHPs()
- local playerHP, playerX, playerY, playerSubX = getPlayerInfo()
- drawPlayerHP(playerHP, playerX, playerY, playerSubX)
- drawPlayerHPFixed()
- drawEnemyHP()
- drawWhipStatus()
- if cheatLog ~= "" then
- emu.drawString(5, 5, cheatLog, fontColor, 0x00000000,150)
- cheatLogFrames = cheatLogFrames + 1 -- 增加帧计数器
- if cheatLogFrames >= 100 then
- cheatLog = ""
- end
- end
- end
- emu.addEventCallback(drawHPs, emu.eventType.endFrame)
- local previousKeys = {}
- emu.addEventCallback(function()
- for i = 1, #cheatCodes do
- if emu.isKeyPressed(tostring(i)) and not previousKeys[i] then
- toggleCheat(cheatCodes[i])
- end
- end
- previousKeys = {}
- for i = 1, #cheatCodes do
- previousKeys[i] = emu.isKeyPressed(tostring(i))
- end
- end, emu.eventType.inputPolled)
Advertisement