Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- todo check player hitbox by setting breakpoint when he is hit by checking when he loses weapon
- function findbit(p)
- return 2 ^ (p - 1)
- end
- function hasbit(x, p)
- return x % (p + p) >= p
- end
- local function test()
- local x = memory.readbyte(0x206)
- local y = memory.readbyte(0x210)
- local x2 = memory.readbyte(0x228)
- local y2 = memory.readbyte(0x22a)
- local x_offscreen = memory.readbyte(0x207)
- local y_offscreen = memory.readbyte(0x211)
- local x2_offscreen = memory.readbyte(0x229)
- local y2_offscreen = memory.readbyte(0x22b)
- -- Checks if the box went off screen and adjusts
- if x2_offscreen == 1 then
- x2 = 255 + x2
- elseif x2_offscreen == 255 then
- x2 = 0 -(255 - x2)
- end
- if y2_offscreen == 1 then
- y2 = 255 + y
- elseif y2_offscreen == 255 then
- y2 = 0 - (255 - y2)
- end
- if x_offscreen == 1 then
- x = 255 + x
- elseif x_offscreen == 255 then
- x = 0 -(255 - x)
- end
- if y_offscreen == 1 then
- y = 255 + y
- elseif y_offscreen == 255 then
- y = 0 - (255 - y)
- end
- gui.text(100,100,x .. "/" .. x2)
- gui.text(100,108,y .. "/" .. y2)
- gui.text(100,116,"offscreens x/y: " .. x2_offscreen .. "/" .. y2_offscreen)
- gui.box(x,y,x2,y2,"#0000FF35","#0000FFFF")
- end
- local function testobjects()
- local start = 0x240
- local base = 0
- local oend = 33
- local x
- local x_offscreen
- local y
- local y_offscreen
- local xrad
- local yrad
- local active
- local touch
- local projectile
- local hp
- for i = 0,oend,1 do
- base = start
- if i > 0 then
- base = start + (i * 0x40)
- end
- active = memory.readbyte(base + 0x16)
- hp = memory.readword(base + 6)
- if active > 0 then
- touch = hasbit(active,findbit(4))
- projectile = hasbit(active,findbit(5))
- x = memory.readbyte(base + 0xa)
- x2 = memory.readbyte
- x_offscreen = memory.readbyte(base + 0xb)
- y = memory.readbyte(base + 0xe)
- y_offscreen = memory.readbyte(base + 0xf)
- xrad = memory.readwordsigned(base+0x28)
- yrad = memory.readwordsigned(base+0x2A)
- x2 = x
- -- Checks if the box went off screen and adjusts
- if x_offscreen == 1 then
- x = 255 + x
- elseif x_offscreen == 255 then
- x = 0 -(255 - x)
- end
- if y_offscreen == 1 then
- y = 255 + y
- elseif y_offscreen == 255 then
- y = 0 - (255 - y)
- end
- if projectile and touch == true then
- gui.box(x,y,x+ xrad,y+yrad,"#FF000035","#FF0000FF")
- elseif projectile == true then
- gui.box(x,y,x+ xrad,y+yrad,"#00FF0035","#00FF00FF")
- elseif touch == true then
- gui.box(x,y,x + xrad,y + yrad,"#FFFF0035","#FFFF00FF")
- end
- if hp > 0 then
- gui.text(x-5,y-5,"HP: " .. hp)
- end
- end
- end
- end
- while true do
- test()
- testobjects()
- emu.frameadvance()
- end
Add Comment
Please, Sign In to add comment