A lua script for hitboxes is actually a pretty tall request. Sure, you paint boxes, how hard can that be? Unfortunately, the person making the script has to find out how the game handles it. Where in memory it is. All that stuff. And code up a script to handle that.
Since this thread creation, I was working at the script. No, not every minute of the day, but I spent a fair amount of time on it. This should give an idea on the effort needed to fulfill your request. I did not mention I was working on it so that there would be no chance to disappoint you should I fail on the script.
I must warn, however, I did not get the camera worked out fully. Expect glitches with the lua display. Still, this is probably more than what you had before.
EDIT: The warning applies less now. I've faked up a good upper byte for the camera now. I assume Barry is always onscreen, and pick an upper byte for the camera accordingly.
Download TheFlashHitboxes.luaLanguage: lua
local R1u, R1s= memory.readbyte, memory.readbytesigned -- 1 byte
local R2u, R2s= memory.readword, memory.readwordsigned -- 2 byte Little endian
--*****************************************************************************
local function u2R(a) return R1u(a)*256 + R1u(a+1) end -- 2 byte Big endian
local function s2R(a) return R1s(a)*256 + R1u(a+1) end -- 2 byte Big endian
--*****************************************************************************
--memory.readword fails. Numbers in The Flash are big endian.
--*****************************************************************************
local function HexStr(v)
--*****************************************************************************
-- Returns a string. If it's negative, specifically forces a negative sign
-- instead of returning "FFFFFFxx" stuff.
local str= ""
if v < 0 then
str= "-"
v= -v
end
return str .. string.upper(string.format("%x",v))
end
--*****************************************************************************
local function GuiTextRight(x,y,str,c1,c2)
--*****************************************************************************
-- The default for gui.text is left-justified. This is right-justified.
-- Specify the right-side pixel instead of the left.
-- Ideal for when you are listing numbers, as the magnitude of each digit are
-- aligned for easy comparison.
str= tostring(str)
x= x - (#str)*4
gui.text(x,y,str,c1,c2)
end
-- 0xC2A0 -- Start of the array containing character information.
-- Data size is 0x36. So the second character has info stored in 0xC2D6
-- Apparently, there's room for 23 of these things.
--*****************************************************************************
local function PutHitbox(obj, CamX, CamY)
--*****************************************************************************
-- Paints a hitbox. It wants the object base address and camera position.
gui.box(
math.floor(u2R(obj+0x10)/16) - CamX, -- Left
math.floor(u2R(obj+0x12)/16) - CamY, -- Top
math.floor(u2R(obj+0x14)/16) - CamX, -- Right
math.floor(u2R(obj+0x16)/16) - CamY, -- Bottom
0, -- Fill color (Transparant)
0x0040FFFF -- Border color (Blue)
-- If you need 0x80 red or higher, switch to strings "#FF0000FF", as
-- a numeric 0x800000FF fails due to the 80Red glitch.
)
end
--*****************************************************************************
local function FakeCamPos()
--*****************************************************************************
-- Gets the camera position. Actually, fakes the camera position. This uses
-- Barry's position to produce the upper byte for the camera.
local obj= 0xC2A0 -- The Barry object is located here
-- But first, check if Barry exists... Assume he's always the first object.
if R1u(obj) == 0xFF then return R1u(0xC145), R1u(0xC146) end
-- Now we assume the camera has the greatest possible value that's less than
-- Barry's position.
local CamX, CamY= R1u(0xC145), R1u(0xC146)
local UpperByte= math.floor((u2R(obj+1)/16 - CamX)/256)
CamX= CamX + UpperByte*256
UpperByte= math.floor((u2R(obj+3)/16 - CamY)/256)
CamY= CamY + UpperByte*256
return CamX, CamY
end
local StartAddr= 0xC2A0
--*****************************************************************************
local function IterateObjects()
--*****************************************************************************
-- Will go through all 23 objects.
local CamX, CamY= FakeCamPos()
for i= 0, 22 do
local obj= StartAddr + 0x36*i
if R1u(obj) ~= 0xFF then -- Does the object exist?
PutHitbox(obj, CamX, CamY)
end
end
end
gui.register(IterateObjects) -- I prefer the gui over "boundary"
-- 0xC2A0 [size=0x36][count=23] Object Array
-- +0x00,1x Object ID. 0xFF = No object All 2-byte values
-- +0x01,2u X position are assumed to be
-- +0x03,2u Y position big endian unless
-- +0x05,2s X velocity noted otherwise.
-- +0x07,2s Y velocity
-- +0x08,
-- +0x09,
-- +0x0A,
-- +0x0B,
-- +0x0C,
-- +0x0D,
-- +0x0E,
-- +0x0F,
-- +0x10,2u Hitbox, left
-- +0x12,2u Hitbox, top
-- +0x14,2u Hitbox, right
-- +0x16,2u Hitbox, bottom
-- +0x18,2u Hitbox, left (mirror?)
-- +0x1A,2u Hitbox, top (mirror?)
-- +0x1C,2u Hitbox, right (mirror?)
-- +0x1E,2u Hitbox, bottom (mirror?)
-- +0x20,
-- +0x21,
-- +0x22,
-- +0x23,
-- +0x24,
-- +0x25,
-- +0x26,
-- +0x27,
-- +0x28,
-- +0x29,
-- +0x2A,
-- +0x2B,
-- +0x2C,
-- +0x2D,
-- +0x2E,
-- +0x2F,
-- +0x30,
-- +0x31,
-- +0x32,
-- +0x33,
-- +0x34,
-- +0x35,
Incidentally, the upper byte of the camera position does not need to exist in the game. The hitboxes themselves have all the information necessary to tell when there's a collision, and this does not require a camera. And if that upper byte does not exist, a strange method will need to be used to fake one up to get rid of most of these glitches.
Said strange method is using Barry's position to guess the actual camera location.