I have made an auto sipper plugin that does work as it is right now. I am new to scripting so there is still a few things that I would like to do with this to make it easier for myself and others to use.
Now, bare in mind that I am new to scripting so I am surprised that I even got this to work. I could not have done it without looking over some of nicks plugins. In fact this plugin is based on nicks ATCP.NJG plugin. If you want to use this you will have to have that plugin. Another note on this is that you will have to manually change each vial ID that your character will use for health and mana.
My question about this plugin is what could I have done to clean it up, make it better...etc. I would also like to streamline this by allowing some variable to store the vial id and a alias that can be used to change the variable. Something like Set HpVial vial("ID number") and Set MaVial vial("Id Number"). Any feedback will be greatly appreciated.
Here is my plugin. Just copy to a blank notepad and save as:
Achaea_Auto_Sipper.xml in the plugins folder for mushclient.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, November 08, 2012, 10:53 PM -->
<!-- MuClient version 4.84 -->
<!-- Plugin "Achaea_Auto_Sipper" generated by Plugin Wizard -->
<muclient>
<plugin
name="Achaea_Auto_Health_Sipper"
author="Jeremy Bable"
id="5cd2e76a2bb0bd52d49aaf4a"
language="Lua"
purpose="Heals when below 70% health or 50% Mana"
save_state="y"
date_written="2012-11-08 22:48:36"
requires="4.84"
version="1.0"
>
<description trim="y">
<![CDATA[
This plugin is intended to automate the sipping of health and
mana vials in Achaea. It is based off of Nick Gammon's ATCP.NJG
plugin for ATCP muds. You will need that plugin in order for this
one to work.
I am still in the begining of learning lua and scripting so I did
copy a few things from the ATCP.NJG file. Particularly the Stats
table and The OnPluginBroadcast funtions. (I believe giving props
where they are due. Thanks Nick!!!)
So far this is version one of this plugin. For now you will have
to manually change the health vial id and the mana vial id to your
own for it to work. As I learn more about scripting I intend to make
this easier by adding an alias that will change the vials for you.
]]>
</description>
</plugin>
<!-- Get our standard constants -->
<include name="constants.lua"/>
<!-- Triggers -->
<triggers>
<trigger
enabled="y"
group="Base"
match="The elixir heals and soothes you\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>SetVariable("SipAllow", 0)</send>
</trigger>
<trigger
enabled="y"
group="Base"
match="You may drink another health or mana elixir or tonic\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>SetVariable("SipAllow", 1)</send>
</trigger>
<trigger
enabled="y"
group="Defenses"
match="You close your eyes\, bow your head\, and empty your mind of all thought\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>SetVariable("Meditate", 1)</send>
</trigger>
<trigger
enabled="y"
group="Defenses"
match="You cease your meditation having achieved full will and mana\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>SetVariable("Meditate", 0)</send>
</trigger>
<trigger
enabled="y"
group="Defenses"
match="You snap your head up as you break your meditation\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>SetVariable ("Meditate", 0)</send>
</trigger>
</triggers>
<!-- Variables -->
<variables>
<variable name="SipAllow">1</variable>
<variable name="Meditate">0</variable>
</variables>
<!-- Script -->
<script>
<![CDATA[
require "checkplugin"
stats = {}
function got_vitals (s)
stats.health, stats.maxhealth,
stats.mana, stats.maxmana,
stats.endurance, stats.maxendurance,
stats.willpower, stats.maxwillpower,
stats.exp, stats.maxexp = string.match (s, "^H:(%d+)/(%d+) M:(%d+)/(%d+) E:(%d+)/(%d+) W:(%d+)/(%d+) NL:(%d+)/(%d+)")
if stats.health then -- Health/Mana Auto-Sipper
hp = tonumber (stats.health)
max_hp = tonumber (stats.maxhealth)
HpPer = math.floor ((hp / max_hp) * 100)
ma = tonumber (stats.mana)
max_ma = tonumber (stats.maxmana)
MaPer = math.floor ((ma / max_ma) * 100)
sipallow = tonumber (GetVariable ("SipAllow"))
meditate = tonumber (GetVariable ("Meditate"))
if HpPer < 70 then -- Health/Mana Percentage Check
if sipallow == 1 then -- Test for the sip ability
Send "sip vial317486" -- Sip health Vial
end -- Sip Allowed Check
elseif meditate == 0 then -- Meditation Check
if MaPer < 50 then -- Mana Perectage Check
Send "sip vial373911" -- Sip mana vial
end -- Defenses Up Check
end -- Health/Mana Perecentage Check
end -- Health/Mana Auto-Sipper
end -- function got_vitals
function OnPluginBroadcast (msg, id, name, text)
if id == "85f72d0e263d75df7bde6f00" then
if msg == 1 then
got_vitals (text) -- eg. "H:496/496 M:412/412 E:1380/1380 W:960/960 NL:89/100 "
end -- if
end -- if ATCP message
end
function OnPluginListChanged ()
do_plugin_check_now ("85f72d0e263d75df7bde6f00", "ATCP_NJG") -- check we have ATCP plugin
end -- OnPluginListChanged
]]>
</script>
</muclient>
|