2009-09-16 03:38:48 +00:00
|
|
|
-- Just something quick for Mike Tyson's Punch Out!!
|
|
|
|
-- Intended to help time hits in real time.
|
|
|
|
--FatRatKnight
|
|
|
|
|
|
|
|
|
|
|
|
local EHP= 0x0398 -- Enemy HP address
|
2009-09-16 04:41:21 +00:00
|
|
|
local TMR= 23 -- Frames in advance for your punches.
|
2009-09-16 03:38:48 +00:00
|
|
|
local BND= -8 -- KEEP NEGATIVE!! Frames after the golden zone.
|
|
|
|
|
2009-09-16 04:41:21 +00:00
|
|
|
local DISPx= 180
|
2009-09-16 03:38:48 +00:00
|
|
|
local DISPy= 180
|
2009-09-16 16:55:38 +00:00
|
|
|
local DISPx2= DISPx+11 -- Right side of box. Adjust that plus to your need
|
2009-09-16 03:38:48 +00:00
|
|
|
|
2009-09-16 04:32:39 +00:00
|
|
|
local timer= 0
|
2009-09-16 03:38:48 +00:00
|
|
|
|
|
|
|
local EnemyHP
|
|
|
|
local lastEHP
|
|
|
|
local LastHit=-50
|
2009-09-16 16:55:38 +00:00
|
|
|
local HitTiming= BND-1
|
2009-09-16 03:38:48 +00:00
|
|
|
|
|
|
|
--*****************************************************************************
|
2009-09-16 04:32:39 +00:00
|
|
|
function Is_Hit()
|
2009-09-16 03:38:48 +00:00
|
|
|
--*****************************************************************************
|
|
|
|
if EnemyHP ~= lastEHP then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2009-09-16 04:32:39 +00:00
|
|
|
local LastButtons= {}
|
|
|
|
local Buttons= {}
|
2009-09-16 03:38:48 +00:00
|
|
|
--*****************************************************************************
|
|
|
|
function IsPress()
|
|
|
|
--*****************************************************************************
|
2009-09-16 04:32:39 +00:00
|
|
|
LastButtons["A"]= Buttons["A"]
|
|
|
|
LastButtons["B"]= Buttons["B"]
|
2009-09-16 03:38:48 +00:00
|
|
|
|
2009-09-16 04:32:39 +00:00
|
|
|
Buttons= joypad.get(1)
|
|
|
|
if (Buttons["A"] and not LastButtons["A"]) or (Buttons["B"] and not LastButtons["B"]) then
|
2009-09-16 03:38:48 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--*****************************************************************************
|
|
|
|
while true do
|
|
|
|
--*****************************************************************************
|
|
|
|
EnemyHP= memory.readbyte(EHP)
|
2009-09-16 03:50:58 +00:00
|
|
|
gui.text(144,22,EnemyHP)
|
2009-09-16 03:38:48 +00:00
|
|
|
|
2009-09-16 04:32:39 +00:00
|
|
|
if IsPress() then
|
2009-09-16 16:55:38 +00:00
|
|
|
HitTiming= LastHit
|
|
|
|
LastHit= BND-1
|
|
|
|
timer= -18
|
2009-09-16 03:38:48 +00:00
|
|
|
end
|
|
|
|
|
2009-09-16 04:32:39 +00:00
|
|
|
if Is_Hit() then
|
|
|
|
LastHit= TMR
|
|
|
|
end
|
2009-09-16 03:38:48 +00:00
|
|
|
|
2009-09-16 16:55:38 +00:00
|
|
|
|
2009-09-16 03:38:48 +00:00
|
|
|
for i= 1, TMR do
|
|
|
|
local color= "black"
|
|
|
|
if i == LastHit then
|
2009-09-16 16:55:38 +00:00
|
|
|
color= "green"
|
|
|
|
elseif i == HitTiming and timer < 0 then
|
|
|
|
color= "red"
|
|
|
|
gui.text(100,80,"early " .. i)
|
2009-09-16 03:38:48 +00:00
|
|
|
end
|
2009-09-16 16:55:38 +00:00
|
|
|
gui.drawbox(DISPx, DISPy-3 - 4*i,DISPx2, DISPy-1 - 4*i,color)
|
2009-09-16 03:38:48 +00:00
|
|
|
end
|
|
|
|
|
2009-09-16 16:55:38 +00:00
|
|
|
if HitTiming == 0 and timer < 0 then
|
|
|
|
gui.text(128,80,"OK")
|
|
|
|
gui.drawbox(128,80,144,90,"green")
|
2009-09-16 04:32:39 +00:00
|
|
|
local color= "white"
|
2009-09-16 16:55:38 +00:00
|
|
|
if (timer % 3) == 0 then
|
2009-09-16 04:32:39 +00:00
|
|
|
color= "green"
|
|
|
|
elseif (timer % 3) == 1 then
|
|
|
|
color= "blue"
|
|
|
|
end
|
2009-09-16 16:55:38 +00:00
|
|
|
gui.drawbox(DISPx , DISPy , DISPx2, DISPy+2, color)
|
|
|
|
gui.drawbox(DISPx-2, DISPy-2, DISPx2+2, DISPy+4, color)
|
2009-09-16 04:32:39 +00:00
|
|
|
else
|
|
|
|
local color= "black"
|
2009-09-16 16:55:38 +00:00
|
|
|
if i == LastHit then
|
|
|
|
color= "green"
|
2009-09-16 04:32:39 +00:00
|
|
|
end
|
2009-09-16 16:55:38 +00:00
|
|
|
gui.drawbox(DISPx , DISPy ,DISPx2, DISPy+2,color)
|
|
|
|
gui.drawbox(DISPx-2, DISPy-2,DISPx2+2, DISPy+4,"white")
|
2009-09-16 03:38:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
for i= BND, -1 do
|
|
|
|
local color= "black"
|
|
|
|
if i == LastHit then
|
2009-09-16 16:55:38 +00:00
|
|
|
color= "green"
|
|
|
|
elseif i == HitTiming and timer < 0 then
|
|
|
|
color= "red"
|
|
|
|
gui.text(146,80,"late " .. -i)
|
2009-09-16 03:38:48 +00:00
|
|
|
end
|
2009-09-16 16:55:38 +00:00
|
|
|
gui.drawbox(DISPx, DISPy+3 - 4*i,DISPx2, DISPy+5 - 4*i,color)
|
2009-09-16 03:38:48 +00:00
|
|
|
end
|
|
|
|
|
2009-09-16 16:55:38 +00:00
|
|
|
LastHit= LastHit-1
|
2009-09-16 03:38:48 +00:00
|
|
|
FCEU.frameadvance()
|
|
|
|
lastEHP= EnemyHP
|
2009-09-16 04:32:39 +00:00
|
|
|
timer= timer+1
|
2009-09-16 03:38:48 +00:00
|
|
|
end
|