Code: Select all
auxbox_next_line = 0
session_time = 0
sessionstart = os.time()
function auxbox()
d:auxbox_clear();
auxbox_next_line = 0
auxbox_real_world_time()
auxbox_blank_line()
auxbox_xp()
auxbox_last_few()
auxbox_blank_line()
Items_Left()
end
function auxbox_prop_line(prop_name, prop_val)
local filler = string.rep(" ", 25 - string.len(prop_name) - string.len(prop_val))
auxbox_next_line = auxbox_next_line + 1
d:auxbox_set_line(auxbox_next_line, string.format("%s %s %s", prop_name, filler, prop_val))
end
function auxbox_blank_line()
auxbox_next_line = auxbox_next_line + 1
end
function auxbox_real_world_time()
auxbox_prop_line("Real World Time:", string.format(os.date("%I:%M%p")))
end
session_start_xp = me.xp -- var to calculate xp gain per session
session_start_age = me.age -- var to calculate time played per session
session_time = 0
current_level = 0
-- beginning of XP-array
req_xp = {}
req_xp[1] = 0 -- fixed XP value
req_xp[2] = 200 -- fixed XP value
req_xp[26] = 93000 -- fixed XP value
for i=3,25 do -- adds XP for lvl 3 to 25 to array
req_xp[i] = math.floor(req_xp[i-1]+1.2*(req_xp[i-1]-req_xp[i-2]))
end
for i=27,1000 do -- adds XP for lvl 27 to 1000 to array
req_xp[i] = req_xp[i-1]+(i-26)*1000*4+15000
end
if me.xp >= req_xp[1000] then
current_level = 1000
else
for i = 1,999 do -- getting current player level based on array
if req_xp[i] <= me.xp
and req_xp[i + 1] > me.xp
then
current_level = i
break
end
end
end
-- end of XP-array
function auxbox_xp()
if current_level <= 1000 then
local xptolvl_float = ((me.xp - req_xp[current_level]))/(req_xp[current_level+1]-req_xp[current_level]) -- % needed for next level
local lvl_float = current_level + me.remort_level * 75 + xptolvl_float -- combines actual lvl with the % needed for next lvl
-- checks if player leveled or remorted
if xptolvl_float >= 1 or xptolvl_float < 0 then
for i = 1,999 do
if req_xp[i] <= me.xp
and req_xp[i + 1] > me.xp
then
current_level = i
break
end
end
end
if os.difftime(os.time(), session_start) > session_time then -- just to reduce the script to every second
session_time = os.difftime(os.time(), session_start)
session_d_float = session_time / 60 / 60 / 24
session_d = math.floor(session_d_float)
session_h = math.floor((session_d_float - session_d)*24)
session_m = math.floor(((session_d_float - session_d)*24 - session_h) * 60)
session_s = math.floor((((session_d_float - session_d)*24 - session_h) * 60 - session_m) * 60)
xpgain = me.xp - session_start_xp
xps = xpgain/session_time
if me.age-session_start_age > 0 then
xpmin = xpgain/(me.age-session_start_age)
else
xpmin = 0
end
xptolvl = req_xp[current_level + 1] - me.xp
xpto1k = req_xp[1000] - me.xp
if xps > 0 then
timetolvl = xptolvl / xps
timeto1k = xpto1k / xps
else
timetolvl = 0
timeto1k = 0
end
timetolvl_d_float = timetolvl / 60 / 60 / 24
timetolvl_d = math.floor(timetolvl_d_float)
timetolvl_h = math.floor((timetolvl_d_float - timetolvl_d)*24)
timetolvl_m = math.floor(((timetolvl_d_float - timetolvl_d)*24 - timetolvl_h) * 60)
timetolvl_s = math.floor((((timetolvl_d_float - timetolvl_d)*24 - timetolvl_h) * 60 - timetolvl_m) * 60)
timeto1k_d_float = timeto1k / 60 / 60 / 24
timeto1k_d = math.floor(timeto1k_d_float)
timeto1k_h = math.floor((timeto1k_d_float - timeto1k_d)*24)
timeto1k_m = math.floor(((timeto1k_d_float - timeto1k_d)*24 - timeto1k_h) * 60)
timeto1k_s = math.floor((((timeto1k_d_float - timeto1k_d)*24 - timeto1k_h) * 60 - timeto1k_m) * 60)
end
auxbox_prop_line("XP to Level:", string.format("%d", xptolvl))
--auxbox_prop_line("XP per Minute:" ,string.format("%d", xpmin))
--auxbox_prop_line("Time to Level:" ,string.format("%02.f:%02.f:%02.f:%02.f", timetolvl_d, timetolvl_h, timetolvl_m, timetolvl_s))
end
end
last_session_seconds = 0
last_5_dpst = { g_dpst, g_dpst, g_dpst, g_dpst }
last_5_dtpst = { g_dtpst, g_dtpst, g_dtpst, g_dtpst }
last_dpst = g_dpst
last_dtpst = g_dtpst
recent_dmg = { 0, 0, 0, 0, }
recent_dmgt = { 0, 0, 0, 0, }
function auxbox_last_few()
local session_seconds = os.time() - sessionstart
if session_seconds > last_session_seconds then
last_session_seconds = session_seconds
last_5_dpst[4] = last_5_dpst[3]
last_5_dpst[3] = last_5_dpst[2]
last_5_dpst[2] = last_5_dpst[1]
last_5_dpst[1] = g_dpst
last_5_dpst[4] = last_5_dpst[3]
last_5_dpst[3] = last_5_dpst[2]
last_5_dpst[2] = last_5_dpst[1]
last_5_dpst[1] = g_dtpst
end
if last_dpst ~= g_dpst then
recent_dmg[4] = recent_dmg[3]
recent_dmg[3] = recent_dmg[2]
recent_dmg[2] = recent_dmg[1]
recent_dmg[1] = g_dpst - last_dpst
last_dpst = g_dpst
end
if last_dtpst ~= g_dtpst then
table.remove(recent_dmgt, 4)
table.insert(recent_dmgt, 1, g_dtpst - last_dtpst)
last_dtpst = g_dtpst
end
auxbox_prop_line("Last Few Hits:", "")
auxbox_prop_line(string.format("%d %d %d %d",recent_dmg[4], recent_dmg[3], recent_dmg[2], recent_dmg[1]))
auxbox_prop_line("Last 4 hits taken:")
auxbox_prop_line(string.format("%d %d %d %d",recent_dmgt[4], recent_dmgt[3], recent_dmgt[2], recent_dmgt[1]))
end
function auxbox_prop_line(prop_name, prop_val)
local pvl=0
if prop_name==nil then prop_name="" end
if prop_val==nil then prop_val="" end
local filler = string.rep(" ", 25 - string.len(prop_name) - string.len(prop_val))
auxbox_next_line = auxbox_next_line + 1
d:auxbox_set_line(auxbox_next_line, string.format("%s %s %s", prop_name, filler, prop_val))
function Items_Left()
auxbox_prop_line("Items Left")
auxbox_prop_line("Mega Yellow:", items:get_qty_basecode(363))
auxbox_prop_line("Other Yellow Potions:", items:get_qty_basecode(260))
auxbox_prop_line("Mega Blue Potions:", items:get_qty_basecode(364))
auxbox_prop_line("Blue Potions:", items:get_qty_basecode(261))
auxbox_prop_line("Purple Potions:", items:get_qty_basecode(360))
auxbox_prop_line("Brown Potions:", items:get_qty_basecode(358))
--auxbox_prop_line("Khaki Potions:", items:get_qty_basecode(380))
auxbox_prop_line("White Potions:", items:get_qty_basecode(354))
--auxbox_prop_line("Cyan Potions:", items:get_qty_basecode(356))
auxbox_prop_line("Orange Potions:", items:get_qty_basecode(355))
auxbox_prop_line("Omelettes:", items:get_qty_basecode(1380))
auxbox_prop_line("Dragon Rations:", items:get_qty_basecode(1399))
--auxbox_prop_line("Greater Health:", items:get_qty_basecode(12))
auxbox_prop_line("Scroll of Health:", items:get_qty_basecode(1298)) --should use make_code(1298,0,15,3)
auxbox_prop_line("Scroll of Protection:", items:get_qty_basecode(1297))
auxbox_prop_line("Sanct Lor:", items:get_qty(make_code(286,0,0,18)))
auxbox_prop_line("Black Potions:", items:get_qty_basecode(352))
auxbox_prop_line("Kal Ort Por:", items:get_qty(make_code(286,0,0,13)))
auxbox_prop_line("Town Portal:", items:get_qty_basecode(293))
auxbox_prop_line("Bandages:", items:get_qty_basecode(375))
auxbox_prop_line("Arrows:", items:get_qty_basecode(296))
auxbox_prop_line("Bullets:", items:get_qty_basecode(1294))
auxbox_prop_line("Soul Shards:", items:get_qty_basecode(1283))
end
end