Posted by
| Nick Gammon
Australia (22,973 posts) bio
Forum Administrator |
Message
| I agree with what David said. Lua is the way to go, as making tables is easy. Below is a plugin I used for Aardwolf to track kills, not quite in the way you wanted, but it should give you a start. You will need to revamp it a bit to get the data, I used the "stats" plugin to find who I had just killed. You could replace that with a suitable trigger.
What the plugin below does is track the last 5 kills (which you can change by changing the variable "MAXAVERAGE = 5"). Each time you kill something, if there are 5 items or more in the table, it throws away the first one. To do what you want, instead you would throw away any which had a time associated with them of over an hour ago. I used 5 items because you tend to get into a rhythm, and then the plugin can predict how long it will take to level, based on your most recent 5 kills.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, July 11, 2008, 5:43 PM -->
<!-- MuClient version 4.33 -->
<!-- Plugin "XP_gain" generated by Plugin Wizard -->
<muclient>
<plugin
name="Aardwolf_Exp_gain"
author="Nick Gammon"
id="e34c9929c87f4f77c24d6687"
language="Lua"
purpose="Estimates time to level based on recent kills"
date_written="2008-07-11 17:41:42"
requires="4.33"
version="1.1"
>
<description trim="y">
<![CDATA[
xp - show names and counts of mobs we killed
xp reset - resets "recent kills" table, use when starting a new killing session
xp reset all - same as "xp reset" plus it removes the list of mobs killed
]]>
</description>
</plugin>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
keep_evaluating="y"
match="^You receive (\d+) experience points?\.$"
regexp="y"
script="mobdied"
sequence="100"
>
</trigger>
</triggers>
<!-- Aliases -->
<aliases>
<alias
script="xp_alias"
match="^xp( reset| reset all)?$"
enabled="y"
regexp="y"
sequence="100"
>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
local MAXAVERAGE = 5 -- max to keep for averages
local xp_table = {}
local mobs = {} -- table of mobs killed
require "commas"
local function plural (count)
if count ~= 1 then
return "s"
else
return ""
end -- if
end -- function plural
function show_calcs (xptogo)
stats = GetPluginVariableList("8a710e0783b431c06d61a54c")
if not stats then return end
level = tonumber (stats.level)
xptogo = xptogo or tonumber (stats.to_level)
local tablesize = #xp_table
-- work out average
local total = 0
for _, v in ipairs (xp_table) do
total = total + v.xpgain
end -- for loop
local av_xp = total / tablesize
if tablesize <= 1 then
return
end
local elapsed = xp_table [#xp_table].time - xp_table [1].time -- time it took to do those kills
kills = math.ceil (xptogo / av_xp)
local time_to_go = (xptogo / av_xp) * elapsed / (tablesize - 1)
local xp_per_hour = av_xp / elapsed * 60 * 60 * (tablesize - 1)
if xp_per_hour < 1 then
return
end -- if
ColourNote ("magenta", "",
string.format ("To level: %s XP (%s) %i avg kill%s. (%s XP/hour)",
commas (xptogo),
convert_time (time_to_go),
kills,
plural (kills),
commas (string.format ("%i", xp_per_hour))
)) -- blue
end -- show_calcs
function mobdied (name, line, wildcards)
stats = GetPluginVariableList("8a710e0783b431c06d61a54c")
if not stats then return end
level = tonumber (stats.level)
xpgain = tonumber (wildcards [1])
xptogo = tonumber (stats.to_level) - xpgain
mob = stats.last_enemy
if not mob then return end
-- remember mob count
mobs [mob] = (mobs [mob] or 0) + 1
local kills = math.ceil (xptogo / xpgain) -- how many such kills that is
if xptogo <= 0 then
return
end -- if levelling right now!
if last_kill_time then
secs_since_last_kill = os.time () - last_kill_time
end -- not first kill
last_kill_time = os.time ()-- remember for next time
-- remember details
local thiskill = {
mob = mob,
xpgain = xpgain,
time = last_kill_time,
} -- end of thiskill table
if #xp_table >= MAXAVERAGE then
table.remove (xp_table, 1) -- remove oldest one
end -- of table full
table.insert (xp_table, thiskill) -- new item
show_calcs (xptogo)
end -- trigger: mobdied function
function xp_alias (name, line, wildcards)
msg = trim ( string.lower (wildcards [1] or ""))
if msg == "reset all" then
mobs = {}
Note ("XP gain mob history reset.")
end -- if reset all
if msg == "reset" or msg == "reset all" then
xp_table = {}
last_xp_amount = nil
Note ("XP gain calculations reset.")
return
end -- if reset
Tell ("Type ")
Hyperlink ("xp reset", "", "", "yellow", "")
Tell (" to reset calculations, ")
Hyperlink ("xp reset all", "", "", "yellow", "")
Note (" to reset everything.")
-- if any mobs killed, show name of mob and number killed, for each different type
if next (mobs) then
local t = {}
local total = 0
-- make list of mob names and number we killed
for k, v in pairs (mobs) do
table.insert (t, string.format ("(%s) x%i", k, v))
total = total + v
end -- for
-- alphabetic order
table.sort (t)
ColourNote ("Teal", "", "Killed: " .. table.concat (t, ", "))
Note (string.format ("%i mob%s killed, %i different mob type%s",
total, plural (total),
#t, plural (#t)))
else
Note ("No mobs killed.")
end -- something in mobs table
show_calcs ()
end -- xp_alias
]]>
</script>
</muclient>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|