Sorry for basically disappearing for the last two weeks, but I made good use of the little free time I had. I finally made some headway on a hitbox script! There still seem to be a few kinks to work out, but it should be ok for now.
Language: lua
address = {
X_Speed = 0xFF1CF4,
X_Subspeed = 0xFF1CF6,
X_Position = 0xFF1CEC,
X_Subposition = 0xFF1CEE,
Y_Speed = 0xFF1CF8,
Y_Subspeed = 0xFF1CFA,
Y_Position = 0xFF1CF0,
Y_Subposition = 0xFF1CF2,
X_Hitbox = 0xFF1CE6,
Y_Hitbox = 0xFF1CEA,
X_Camera = 0xFF1BC4,
Y_Camera = 0xFF1BC8,
Boss_HP = 0xFF3601
}
enemy_data = {
Harmful_Unsure = 0xFF21B4,
Health = 0xFF21C0,
X_Hitbox = 0xFF21C6,
Y_Hitbox = 0xFF21CA,
X_Position = 0xFF21CC,
X_Subposition = 0xFF21CE,
Y_Position = 0xFF21D0,
Y_Subposition = 0xFF21D2,
X_Speed = 0xFF21D4,
X_Subspeed = 0xFF21D6,
Y_Speed = 0xFF21D8,
Y_Subspeed = 0xFF21DA,
Slots = 32,
Size = 0x60
}
enemy_value = {
Harmful_Unsure = 0,
Health = 0,
X_Hitbox = 0,
Y_Hitbox = 0,
X_Position = 0,
X_Subposition = 0,
Y_Position = 0,
Y_Subposition = 0,
X_Speed = 0,
X_Subspeed = 0,
Y_Speed = 0,
Y_Subspeed = 0
}
value = {
X_Speed = 0,
X_Subspeed = 0,
X_Position = 0,
X_Subposition = 0,
Y_Speed = 0,
Y_Subspeed = 0,
Y_Position = 0,
Y_Subposition = 0,
X_Hitbox = 0,
Y_Hitbox = 0,
Boss_HP = 0,
X_Camera = 0,
Y_Camera = 0,
}
lagCount = 0
lagCountY = 0
lastX = 0
lastXS = 0
lastY = 0
lastYS = 0
function LagCounter()
XCSpeed = value.X_Speed * 256 + value.X_Subspeed
YCSpeed = value.Y_Speed * 256 + value.Y_Subspeed
XCPos = value.X_Position * 256 + value.X_Subposition
YCPos = value.Y_Position * 256 + value.Y_Subposition
if (lastX == XCPos and lastXS ~= 0) then
lagCount = lagCount + 1
end
if (lastY == YCPos and lastYS ~= 0) then
lagCountY = lagCountY + 1
end
lastX = XCPos
lastY = YCPos
lastXS = XCSpeed
lastYS = YCSpeed
if gens.framecount() == 1 then
lagCount = 0
lagCountY = 0
end
end
function GetInfo()
value.X_Speed = memory.readwordsigned(address.X_Speed)
value.X_Subspeed = memory.readbyte(address.X_Subspeed)
value.X_Position = memory.readwordsigned(address.X_Position)
value.X_Subposition = memory.readbyte(address.X_Subposition)
value.Y_Speed = memory.readwordsigned(address.Y_Speed)
value.Y_Subspeed = memory.readbyte(address.Y_Subspeed)
value.Y_Position = memory.readwordsigned(address.Y_Position)
value.Y_Subposition = memory.readbyte(address.Y_Subposition)
value.X_Hitbox = memory.readwordsigned(address.X_Hitbox)
value.Y_Hitbox = memory.readwordsigned(address.Y_Hitbox)
value.X_Camera = memory.readwordsigned(address.X_Camera)
value.Y_Camera = memory.readwordsigned(address.Y_Camera)
end
function GetEnemyInfo( Slot )
enemy_value.Harmful_Unsure = memory.readwordsigned(enemy_data.Harmful_Unsure + enemy_data.Size * Slot)
enemy_value.Health = memory.readwordsigned(enemy_data.Health + enemy_data.Size * Slot)
enemy_value.X_Hitbox = memory.readwordsigned(enemy_data.X_Hitbox + enemy_data.Size * Slot)
enemy_value.Y_Hitbox = memory.readwordsigned(enemy_data.Y_Hitbox + enemy_data.Size * Slot)
enemy_value.X_Position = memory.readwordsigned(enemy_data.X_Position + enemy_data.Size * Slot)
enemy_value.X_Subposition = memory.readword(enemy_data.X_Subposition + enemy_data.Size * Slot)
enemy_value.Y_Position = memory.readwordsigned(enemy_data.Y_Position + enemy_data.Size * Slot)
enemy_value.Y_Subposition = memory.readword(enemy_data.Y_Subposition + enemy_data.Size * Slot)
enemy_value.X_Speed = memory.readwordsigned(enemy_data.X_Speed + enemy_data.Size * Slot)
enemy_value.X_Subspeed = memory.readword(enemy_data.X_Subspeed + enemy_data.Size * Slot)
enemy_value.Y_Speed = memory.readwordsigned(enemy_data.Y_Speed + enemy_data.Size * Slot)
enemy_value.Y_Subspeed = memory.readword(enemy_data.Y_Subspeed + enemy_data.Size * Slot)
end
function Draw()
GetInfo()
if value.X_Subspeed == 0 then value.X_Subspeed = ""
elseif value.X_Subspeed == 128 then value.X_Subspeed = ".5"
else value.X_Subspeed = ": " .. value.X_Subspeed
end
if value.X_Subposition == 0 then value.X_Subposition = ""
elseif value.X_Subposition == 128 then value.X_Subposition = ".5"
else value.X_Subposition = ": " .. value.X_Subposition
end
gui.box(10, 195, 150, 220, 'black', 'black')
gui.text( 90, 200,"pos", 'cyan')
gui.text( 130, 200,"spd", 'yellow')
gui.text( 70, 209,"X")
gui.text( 87, 209, value.X_Position .. value.X_Subposition, 'cyan')
gui.text( 128, 209, value.X_Speed .. value.X_Subspeed, 'yellow')
gui.text( 70, 220,"Y")
gui.text( 87, 220, value.Y_Position .. ": " .. value.Y_Subposition, 'cyan')
gui.text( 128, 220, value.Y_Speed .. ": " .. value.Y_Subspeed, 'yellow')
gui.text(8,32,lagCount,"#00FF00")
gui.text(8,40,lagCountY,"#00FF00")
gui.box( (value.X_Position - value.X_Camera) - value.X_Hitbox,
(value.Y_Position - value.Y_Camera) - value.Y_Hitbox,
(value.X_Position - value.X_Camera) + value.X_Hitbox,
(value.Y_Position - value.Y_Camera) + value.Y_Hitbox,
'clear', 'green' )
for i=0, enemy_data.Slots do
GetEnemyInfo( i )
if enemy_value.X_Hitbox > 0 and enemy_value.Y_Hitbox > 0 and enemy_value.Health > -1 then
gui.box( (enemy_value.X_Position - value.X_Camera) - enemy_value.X_Hitbox,
(enemy_value.Y_Position - value.Y_Camera) - enemy_value.Y_Hitbox,
(enemy_value.X_Position - value.X_Camera) + enemy_value.X_Hitbox,
(enemy_value.Y_Position - value.Y_Camera) + enemy_value.Y_Hitbox,
'clear', 'red' )
gui.text(enemy_value.X_Position - value.X_Camera,
enemy_value.Y_Position - value.Y_Camera,
enemy_value.Health, 'red', 'black')
end
end
end
savestate.registersave(function(slotnumber)
return lagCount, lastX, lastY, lagCountY, lastXS, lastYS
end)
savestate.registerload(function(slotnumber)
local a, b, c, d, e, f = savestate.loadscriptdata(slotnumber)
if a and b and c then
lagCount = a
lastX = b
lastY = c
end
if d then
lagCountY = d
end
if e and f then
lastXS = e
lastYS = f
else
lastXS = 0
lastYS = 0
end
end)
gui.register ( function()
Draw()
end)
gens.registerafter(function()
GetInfo()
LagCounter()
end)