local x, y, d, timer, rngindex, actors, f, spd, nextind, distind, maxdist, tile, doornum, dooropen, level
local enemyx, enemyy, enemyd, enemyh, enemyt, enemyc
local last_x = 0
local last_y = 0
local last_d = 0
local last_f = 0
local last_l = 0
local dx = 0
local dy = 0
local dd = 0
local wolfmap = {}
for i=0,4095,1 do
wolfmap[i] = 0
end
local htable = {}
for i=1,150,1 do
htable[i] = 0
end
local hstring = ""
local rndtable = {0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66, 74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36, 95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188, 52, 140, 202, 120, 68, 145, 62, 70, 184, 190, 91, 197, 152, 224, 149, 104, 25, 178, 252, 182, 202, 182, 141, 197, 4, 81, 181, 242, 145, 42, 39, 227, 156, 198, 225, 193, 219, 93, 122, 175, 249, 0, 175, 143, 70, 239, 46, 246, 163, 53, 163, 109, 168, 135, 2, 235, 25, 92, 20, 145, 138, 77, 69, 166, 78, 176, 173, 212, 166, 113, 94, 161, 41, 50, 239, 49, 111, 164, 70, 60, 2, 37, 171, 75, 136, 156, 11, 56, 42, 146, 138, 229, 73, 146, 77, 61, 98, 196, 135, 106, 63, 197, 195, 86, 96, 203, 113, 101, 170, 247, 181, 113, 80, 250, 108, 7, 255, 237, 129, 226, 79, 107, 112, 166, 103, 241, 24, 223, 239, 120, 198, 58, 60, 82, 128, 3, 184, 66, 143, 224, 145, 224, 81, 206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95, 28, 139, 123, 98, 125, 196, 15, 70, 194, 253, 54, 14, 109, 226, 71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36, 17, 46, 52, 231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106, 197, 242, 98, 43, 39, 175, 254, 145, 190, 84, 118, 222, 187, 136, 120, 163, 236, 249}
local LuaCanvas = gui.createcanvas(550,625)
memory.usememorydomain('Conventional Memory')
function refresh ()
for i=0,4095,1 do
wolfmap[i] = memory.read_u8(0x45D98+i)
end
end
refresh()
--add ae4
while true do
LuaCanvas.Clear('BLACK')
x = memory.read_u32_le(0x0049D3A) --49256
y = memory.read_u32_le(0x0049D3E)
d = memory.read_u16_le(0x00049D54)
timer = memory.read_u16_le(0x47DD4)
rngindex = memory.read_u8(0x279D0)
actors = memory.read_u8(0x47DD2)
level = memory.read_u8(0x4E01E) -- might be bad?
if level ~= last_l then refresh() end
--custom = memory.read_u16_le(0x48886)
f = emu.framecount()
spd = math.sqrt(dx * dx + dy * dy)
LuaCanvas.DrawText(0, 0, string.format("(%7d,%7d) %3d [%+5d,%+5d](%f) %+3d", x, y, d, dx, dy, spd, dd),'LIME')
LuaCanvas.DrawText(0, 528, string.format("Time: %5d",timer),'LIME')
--LuaCanvas.DrawText(120, 432, string.format("Custom: %5d",custom),'LIME')
LuaCanvas.DrawText(0, 544, "Index",'LIME')
LuaCanvas.DrawText(88, 544, tostring(rngindex),'LIME')
LuaCanvas.DrawText(0, 560, "Dist 0-1",'LIME')
LuaCanvas.DrawText(0, 576, "Dist 2+",'LIME')
LuaCanvas.DrawText(0, 594, "Max Dist",'LIME')
if f ~= last_f then
dx = x - last_x
dy = y - last_y
dd = d - last_d
last_x = x
last_y = y
last_d = d
last_f = f
end
for i=1,10,1 do
nextind = rngindex+i+1
if nextind>256 then nextind = nextind - 256 end
LuaCanvas.DrawText(144+40*(i-1), 544, tostring(nextind-1),'LIME')
LuaCanvas.DrawText(144+40*(i-1), 560, tostring(math.floor((rndtable[nextind])/4)),'LIME')
LuaCanvas.DrawText(144+40*(i-1), 576, tostring(math.floor((rndtable[nextind])/6)),'LIME')
if i>1 then
distind = nextind - 1
if distind<1 then distind=256 end
maxdist = math.floor(rndtable[distind]/12)
if maxdist<4 then maxdist = 3 end
LuaCanvas.DrawText(144+40*(i-1), 594, tostring(maxdist),'LIME')
end
end
for i=0,4095,1 do
tile = wolfmap[i]
if tile>0x7F then
doornum = tile - 0x80
dooropen = memory.read_u8(0x43B07+doornum*2)
if dooropen<0xFF then
LuaCanvas.DrawRectangle(8+math.floor(i/64)*8,16+(i%64)*8,math.floor(((0xFF-dooropen)/0xFF)*7),7,'AQUA','AQUA')
end
elseif tile>0 then
LuaCanvas.DrawRectangle(8+math.floor(i/64)*8,16+(i%64)*8,7,7,'LIGHTGRAY','LIGHTGRAY')
end
end
LuaCanvas.DrawEllipse(math.floor(x/8192)+5,math.floor(y/8192)+13,6,6,'ORANGE','ORANGE')
LuaCanvas.DrawEllipse(math.floor(x/8192)+7+math.cos(math.rad(d))*4,math.floor(y/8192)-math.sin(math.rad(d))*4+15,2,2,'ORANGE','ORANGE')
for i=0,actors,1 do
enemyt = memory.read_u16_le(0x49D6A+60*i) -- enemy type
enemyh = memory.read_s16_le(0x49D92+60*i) -- enemy health , OLD: 49272
if enemyh>0 then -- it's alive, otherwise move on
enemyx = memory.read_u16_le(0x49D77+60*i)
enemyy = memory.read_u16_le(0x49D7B+60*i)
enemyd = memory.read_u8(0x49D74+60*i)
if enemyt==3 then -- guard
enemyc = 'TAN'
elseif enemyt==4 then -- officer
enemyc = 'WHITE'
elseif enemyt==5 then -- SS
enemyc = 'BLUE'
elseif enemyt==6 then -- dog
enemyc = 'PINK'
elseif enemyt==11 then -- mutant
enemyc = 'GREEN'
else -- boss or unknown
enemyc = 'RED'
end
LuaCanvas.DrawEllipse(math.floor(enemyx/32)+5,math.floor(enemyy/32)+13,6,6,enemyc,enemyc)
LuaCanvas.DrawEllipse(math.floor(enemyx/32)+7+math.cos(math.rad(enemyd*45))*4,math.floor(enemyy/32)-math.sin(math.rad(enemyd*45))*4+15,2,2,enemyc,enemyc)
end
if enemyh~=htable[i+1] then -- damage has been done
hstring = string.format("Last damage dealt: %3d",(htable[i+1]-enemyh))
end
LuaCanvas.DrawText(200,528, hstring,'LIME')
htable[i+1]=enemyh
end
last_l = level
LuaCanvas.Refresh()
emu.frameadvance()
end