[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Aardwolf time-to-level plugin
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Aardwolf time-to-level plugin

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Nick Gammon   Australia  (21,609 posts)  [Biography] bio   Forum Administrator
Date Sat 12 Jul 2008 11:06 PM (UTC)

Amended on Sun 13 Jul 2008 01:46 AM (UTC) by Nick Gammon

Message
The plugin below helps you work out how much time it will take to level on Aardwolf. It uses the Stats Detector plugin described in this thread:

http://www.gammon.com.au/forum/?id=8776

That plugin lets us know who we have been fighting, and how much XP we need to level.

As an example of its output, after killing a mob, which yields experience, you see a line like this:


To level: 977 XP (18 m) 20 avg kills. (3,183 XP/hour)

later:

To level: 763 XP (7 m) 13 avg kills. (6,598 XP/hour)

then:

To level: 136 XP (3 m) 3 avg kills. (3,183 XP/hour)


It effectively estimates, from the time you took to kill the last 5 mobs and how much XP you got, how many more it will take to level, and how long that will take. Of course, you can throw the calculations out by stopping fighting, dying, fighting different level mobs, or fighting faster. However for normal "grinding" your way through a batch of mobs, it should be fairly accurate.

The XP/hour figure is intended to evaluate the "quality" of the area you are in. If you are getting low XP/hour you might consider moving to an area that gives better experience.

Options:


  • Type "xp" to see a summary of what you have killed:


    Killed: (A black manta ray) x2, (A bloody squid) x1, (A blue crab) x4, (A blue jellyfish) x2, (A cobia) x5, (A large mosquito) x1, (A red crab) x8, (A small mosquito) x2, (A tiny mosquito) x13, (A white jellyfish) x1, (A yellow trogon) x3, (An angry gorilla) x1, (Bluefish) x2, (Bone fish) x4, (Sand dollar) x2

    51 mobs killed, 15 different mob types

    To level: 977 XP (18 m) 20 avg kills. (3,183 XP/hour)


    I can see from that what I have been doing recently, and how many of each I killed.

  • Type "xp reset" to reset the timings from the last 5 mobs. You would usefully do this if you have been resting, or recalled for healing or selling things. Otherwise, the time calculations will be wrong because they will include rest time.

  • Type "xp reset all" to reset all calculations, including lists of mobs. Do this to start again from scratch.




To use it, download the code below and save as Exp_gain.xml in the Aardwolf subdirectory below your Plugins directory. If you haven't used any Aardwolf plugins before you may need to make the Aardwolf directory.

Alternatively, RH click the link below and choose "Save Link As" (or "Save Linked File As") to save the linked file.

http://www.gammon.com.au/mushclient/plugins/Aardwolf/Exp_gain.xml


This plugin also uses the "stats detector" plugin, so you also need this file:

http://www.gammon.com.au/mushclient/plugins/Aardwolf/Stats_Detector.xml

The "Stats detector" plugin uses telnet negotation, so you also need this file:

http://www.gammon.com.au/mushclient/plugins/Aardwolf/telnet_options.lua


In a standard MUSHclient installation these three files should to into this directory:


C:\Program Files\MUSHclient\worlds\plugins\Aardwolf\




Configuration

Change the line below which reads:


local MAXAVERAGE = 5


... to some other figure, to have it calculate average experience and time over more or less mobs (for example, 10 might be a reasonable figure to use).



<?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="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.0"
   >
<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 ()

  stats = GetPluginVariableList("8a710e0783b431c06d61a54c")
  
  if not stats then return end
      
  level = tonumber (stats.level)
  xptogo = 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 kills. (%s XP/hour)",
                        commas (xptogo),
                        convert_time (time_to_go),
                        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 ()
 
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
[Go to top] top

Posted by Nick Gammon   Australia  (21,609 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 13 Jul 2008 01:42 AM (UTC)
Message
This plugin could be easily adapted to any MUD that shows your experience to next level (eg. Smaug).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Bottomfeeder   (42 posts)  [Biography] bio
Date Reply #2 on Mon 11 Aug 2008 07:44 PM (UTC)
Message
Has anyone else had trouble getting this going? I have all the files present, the plugin is installed, but when I type 'xp' it says no mobs killed and will not recognize any kills.

Any help would be appreciated as I'd love to get this going.
[Go to top] top

Posted by Nick Gammon   Australia  (21,609 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Mon 11 Aug 2008 10:10 PM (UTC)
Message
Make sure you have the "stats detector" plugin installed, as this plugin relies on it.

Otherwise, check you are getting the message:


You receive x experience points.


... when you kill a mob. That is what the plugin uses to update its counts. Also, it ignore mobs which give 0 xp, so make sure you kill mobs that actually give xp, as it doesn't count getting no xp as advancing you to the next level. (That also avoids a "divide by zero" error, as if you killed some mobs which give 0 xp, then you would need to kill an infinite number of them to level - or more, were that possible).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Bottomfeeder   (42 posts)  [Biography] bio
Date Reply #4 on Tue 12 Aug 2008 01:10 PM (UTC)
Message
Apparently I had a corrupted stats_detector.xml because once that was deleted and redownloaded everything started working. Love the plugin!
[Go to top] top

Posted by Amigan   (2 posts)  [Biography] bio
Date Reply #5 on Sat 21 Nov 2009 08:09 PM (UTC)
Message
Having the exprate wish seems to break this plugin :(

i.e You receive 172+18 experience points.
[Go to top] top

Posted by Blainer   (191 posts)  [Biography] bio
Date Reply #6 on Sat 21 Nov 2009 09:29 PM (UTC)

Amended on Sat 21 Nov 2009 11:48 PM (UTC) by Blainer

Message
Try this:
Change this trigger's match to what is bellow.
<trigger
   enabled="y"
   keep_evaluating="y"
   match="^You receive (\d+)\+?(\d+)? experience points.$"
   regexp="y"
   script="mobdied"
   sequence="100"
  >
</trigger>

Change this line:
xpgain = tonumber (wildcards [1])

To this line:
xpgain = tonumber (wildcards[1]) + tonumber (wildcards[2] or 0)


I didn't test this but it should work.
[Go to top] top

Posted by Vultaire   Japan  (3 posts)  [Biography] bio
Date Reply #7 on Wed 14 Jul 2010 12:35 PM (UTC)
Message
A few comments:

1. The version of the script here seems to track the mob last killed, not the mob *just* killed. In other words, its tracking is one mob delayed. This is because the mud doesn't send an updated stats line until after the mob's death, and the exp_gain trigger fires before getting the updated info.

Easy to fix: change stats.last_enemy to stats.enemy.

2. I've confirmed the above mentioned XP tracking fix for those with the xp wish. It works.

3. If using the MUSHclient provided by Aardwolf, the scripts on these page should *replace* the ones already included. I don't know if there's any real difference on the telnet stuff, but the stats tracker here tracks more information than the stock one provided.
[Go to top] top

Posted by Vultaire   Japan  (3 posts)  [Biography] bio
Date Reply #8 on Wed 14 Jul 2010 12:42 PM (UTC)
Message
If anyone's interested, here's the output of "diff -u"... hope this might help someone.


--- Exp_gain.xml.orig	2010-07-13 23:41:59.678402700 +0900
+++ Exp_gain.xml	2010-07-14 21:36:42.554190500 +0900
@@ -34,7 +34,7 @@
   <trigger
    enabled="y"
    keep_evaluating="y"
-   match="^You receive (\d+) experience points?\.$"
+   match="^You receive (\d+)\+?(\d+)? experience points?\.$"
    regexp="y"
    script="mobdied"
    sequence="100"
@@ -128,9 +128,9 @@
   if not stats then return end
     
   level = tonumber (stats.level)
-  xpgain = tonumber (wildcards [1])
+  xpgain = tonumber (wildcards [1]) + tonumber (wildcards [2] or 0)
   xptogo = tonumber (stats.to_level) - xpgain
-  mob = stats.last_enemy
+  mob = stats.enemy  -- was stats.last_enemy, but updated stats line doesn't come until next prompt.
   
   if not mob then return end
   
[Go to top] top

Posted by Vultaire   Japan  (3 posts)  [Biography] bio
Date Reply #9 on Mon 18 Oct 2010 01:43 PM (UTC)
Message
Not sure if it was a new MUSHclient version or just a bug from before, but I found breakage in the above "x+y experience" fix.

For simple copy/paste usage, here's the plugin in its entirety:


<?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="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.0"
   >
<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+)\+?(\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 = 10 -- 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 ()

  stats = GetPluginVariableList("8a710e0783b431c06d61a54c")
  
  if not stats then return end
      
  level = tonumber (stats.level)
  xptogo = 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 kills. (%s XP/hour)",
                        commas (xptogo),
                        convert_time (time_to_go),
                        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])

  -- Fix of "%d+%d experience" support for newer versions of MUSHclient.
  xpbonus = wildcards[2]
  if not (xpbonus == nil) then
     if string.len(xpbonus) < 1 then
        xpbonus = nil
     end
  end -- if
  xpbonus = tonumber (xpbonus or 0)

  xptogo = tonumber (stats.to_level) - (xpgain + xpbonus)
  mob = stats.enemy  -- was stats.last_enemy, but updated stats line doesn't come until next prompt.
  
  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 ()
 
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>
[Go to top] top

Posted by Nick Gammon   Australia  (21,609 posts)  [Biography] bio   Forum Administrator
Date Reply #10 on Mon 18 Oct 2010 08:35 PM (UTC)
Message
Thanks for those fixes.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


13,035 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]