--=== V1.2 ===-- include("classes/statemanager.lua"); include("classes/states/teststate.lua"); local windowList = findWindowList("*", "Radiant Arcana"); if( #windowList == 0 ) then print("You need to run rom first!"); return 0; end function getWin() if( __WIN == nil ) then __WIN = windowList[1] end return __WIN; end function getProc() if( __PROC == nil or not windowValid(__WIN) ) then if( __PROC ) then closeProcess(__PROC) end; __PROC = openProcess( findProcessByWindow(getWin()) ); end return __PROC; end function memoryReadRepeat(_type, proc, address, offset) local readfunc; local ptr = false; local val; if( type(proc) ~= "userdata" ) then error("Invalid proc", 2); end if( type(address) ~= "number" ) then error("Invalid address", 2); end if( _type == "int" ) then readfunc = memoryReadInt; elseif( _type == "uint" ) then readfunc = memoryReadUInt; elseif( _type == "float" ) then readfunc = memoryReadFloat; elseif( _type == "byte" ) then readfunc = memoryReadByte; elseif( _type == "string" ) then readfunc = memoryReadString; elseif( _type == "intptr" ) then readfunc = memoryReadIntPtr; ptr = true; elseif( _type == "uintptr" ) then readfunc = memoryReadUIntPtr; ptr = true; elseif( _type == "byteptr" ) then readfunc = memoryReadBytePtr; ptr = true; else return nil; end for i = 1, 10 do if( ptr ) then val = readfunc(proc, address, offset); else val = readfunc(proc, address); end if( val ~= nil ) then return val; end end end function setwindow() unregisterTimer("setwindow") local function _window() updatehp() setWindowName(getHwnd(),sprintf("Max HP: "..playermaxhp.." Actual HP: "..playerhp)) end registerTimer("setwindow", secondsToTimer(1), _window); end function distance(x1, z1, y1, x2, z2, y2) if z2 == nil and y2 == nil then -- assume x1,z1,x2,z2 values (2 dimensional) z2 = x2 x2 = y1 y1 = nil end if( x1 == nil or z1 == nil or x2 == nil or z2 == nil ) then error("Error: nil value passed to distance()", 2); end if y1 == nil or y2 == nil then -- 2 dimensional calculation return math.sqrt( (z2-z1)*(z2-z1) + (x2-x1)*(x2-x1) ); else -- 3 dimensional calculation return math.sqrt( (z2-z1)*(z2-z1) + (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) ); end end function angleDifference(angle1, angle2) if( math.abs(angle2 - angle1) > math.pi ) then return (math.pi * 2) - math.abs(angle2 - angle1); else return math.abs(angle2 - angle1); end end function updatehp() local playerAddress = memoryReadRepeat("intptr", proc, 0x9D94AC, 0x6B0); playerhp = memoryReadRepeat("int", proc, playerAddress + 0x2CC) or 1000 playermaxhp = memoryReadRepeat("int", proc, playerAddress+ 0x2D4) or 1000 end function updatecoords() local playerAddress = memoryReadRepeat("intptr", proc, 0x9D94AC, 0x6B0); local Vec1 = memoryReadRepeat("float", proc, playerAddress + 0x34) or 0.0 local Vec2 = memoryReadRepeat("float", proc, playerAddress + 0x3C) or 0.0 local Vec3 = memoryReadRepeat("float", proc, playerAddress + 0x38) or 0.0 playerX = memoryReadRepeat("float", proc, playerAddress + 0x28) or 0 playerZ = memoryReadRepeat("float", proc, playerAddress + 0x30) or 0 playerY = memoryReadRepeat("float", proc, playerAddress + 0x2C) or 0 playerDirection = (math.atan2(Vec2, Vec1)+ math.pi) end attach(getWin()); proc = getProc() updatehp() setwindow()