You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Endy-AutoPrac/Aard_Practice_Spellups.xml

392 lines
8.6 KiB

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Tuesday, May 29, 2018, 4:44 PM -->
<!-- MuClient version 5.06-pre -->
<!-- Plugin "Aard_Practice_Spellups" generated by Plugin Wizard -->
<muclient>
<plugin
name="Aard_Practice_Skills_Spellups"
author="Endymion"
id="b03f0bec97a2924e5b3b5f04"
language="Lua"
purpose="Practice automatic skills and spellup spells."
date_written="2018-05-29 16:43:56"
requires="4.30"
version="1.0"
>
</plugin>
<!-- Triggers -->
<triggers>
-- Spellup spells
<trigger
enabled="n"
name="start"
match="{practice_spellup_start}"
script="enable_triggers"
sequence="100"
omit_from_output="y"
group="spellups"
>
</trigger>
<trigger
enabled="n"
match="^(Level [\d\s]+:)?\s+(?<spell>\w+[\s\w]+\w)\s+(?<mana>\d+)\s+(?<pct>\d+)%\s+(?<num>\d+)$"
regexp="y"
script="spell_line"
sequence="100"
omit_from_output="y"
group="spellups"
>
</trigger>
<trigger
enabled="n"
match="^(Level [\d\s]+:)?\s+(?<skill>\w+[\s\w]+\w)\s+(?<pct>\d+)%$"
regexp="y"
script="skill_line"
sequence="100"
omit_from_output="y"
group="spellups"
>
</trigger>
<trigger
enabled="n"
match="^.*$"
regexp="y"
sequence="110"
omit_from_output="y"
group="spellups"
>
</trigger>
<trigger
enabled="n"
match="{practice_spellup_end}"
script="disable_triggers"
sequence="100"
omit_from_output="y"
group="spellups"
>
</trigger>
-- spell practice triggers
<trigger
enabled="n"
name="practice"
match="{practice_start}"
script="enable_practice_triggers"
omit_from_output="y"
sequence="100"
>
</trigger>
<trigger
enabled="n"
match="^You spend (?<spent>\d+) practices? to increase (?<name>[\w\s]+) to (?<pct>\d+%)\.$"
regexp="y"
script="prac_ok"
sequence="100"
omit_from_output="y"
group="practice"
>
</trigger>
<trigger
enabled="n"
match="^It will cost you (?<cost>\d+) practices? to increase [\w\s]+ to \d+%\.$"
regexp="y"
script="prac_nok"
sequence="100"
omit_from_output="y"
group="practice"
>
</trigger>
<trigger
enabled="n"
match="^There is nobody here to help you practice\.$"
regexp="y"
script="cant_prac"
sequence="100"
omit_from_output="y"
group="practice"
>
</trigger>
<trigger
enabled="n"
match="^.*$"
regexp="y"
sequence="110"
omit_from_output="y"
group="practice111111111111111111111111111"
>
</trigger>
<trigger
enabled="n"
match="{practice_end}"
script="disable_practice_triggers"
sequence="100"
omit_from_output="y"
group="practice"
>
</trigger>
-- all spells practice triggers
<trigger
enabled="n"
match="{start_practice_all}"
script="start_practice_all"
sequence="100"
omit_from_output="y"
group="practice_all"
>
</trigger>
<trigger
enabled="n"
match="{end_practice_all}"
script="end_practice_all"
sequence="100"
omit_from_output="y"
group="practice_all"
>
</trigger>
<trigger
enabled="n"
regexp="y"
match="^$"
sequence="100"
name="next_blank_line"
script="next_blank_line"
omit_from_output="y"
>
</trigger>
</triggers>
<!-- Aliases -->
<aliases>
<alias
match="^prs( (?<limit>\d+))?$"
enabled="y"
regexp="y"
script="start"
sequence="100"
>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
require "gmcphelper"
local char = {}
local spells = {} -- spell, mana, pct, num
local retry = ""
local limit = 85
local cant = false
local pracs_cost = 0
local pracs_spent = 0
local spells_prac = 0
local spells_left = 0
function note(msg)
ColourNote("darkcyan", "", ">> ", "silver", "", msg)
end
function start(name, line, args)
limit = 85
spells = {}
if args.limit ~= "" then
limit = tonumber(args.limit)
note("Practice limit temporarily set to "..limit.."%.")
end
if not char.status or not char.status.state then
retry = line
Send_GMCP_Packet("request char")
return
end
if char.status.state ~= "3" then
note("Cannot practice skills/spells unless you are standing.")
return
end
note("Checking automatic skills and spellup spells...")
EnableTrigger("start", true)
SendNoEcho("echo {practice_spellup_start}")
SendNoEcho("spells spellup")
SendNoEcho("spells resist")
SendNoEcho("spells healing")
SendNoEcho("spells curative")
SendNoEcho("skills passive")
SendNoEcho("skills movement")
SendNoEcho("echo {practice_spellup_end}")
end
function in_spells(sp)
for i, spell in ipairs(spells) do
if spell.name == sp then
return true
end
end
return false
end
function spell_line(name, line, args)
if not in_spells(args.spell) then
table.insert(spells, {type = "spell", name = args.spell, mana = args.mana, pct = args.pct, num = args.num})
end
end
function skill_line(name, line, args)
if not in_spells(args.spell) then
table.insert(spells, {type = "skill", name = args.skill, pct = args.pct})
end
end
function practice_spells()
for i, sp in ipairs(spells) do
if tonumber(sp.pct) < limit then
EnableTrigger("practice", true)
SendNoEcho("echo {practice_start}")
SendNoEcho("practice "..sp.name.." full")
SendNoEcho("echo {practice_end}")
table.remove(spells, i)
return
end
end
SendNoEcho("echo {end_practice_all}")
end
function start_practice_all()
note("Practicing automatic skills and spellup spells...")
EnableTrigger("next_blank_line", true)
pracs_cost = 0
pracs_spent = 0
spells_prac = 0
spells_left = 0
pracs_left = 0
cant = false
end
function end_practice_all()
EnableTrigger("practice", false)
EnableTriggerGroup("practice_all", false)
if cant then
note("You cannot practice here!")
return
end
note("Spent "..pracs_spent.." practices on "..spells_prac.." skills/spells.")
if spells_left > 0 then
note("Need "..pracs_cost.." practices for "..spells_left.." skills/spells.")
end
note("Done practicing automatic skills and spellup spells.")
-- report practices needed, if necessary
-- otherwise report practices spent on total spells
-- tl = gettriggerlist()
-- if tl then
-- for k, v in ipairs(tl) do
-- note(v.." "..gettriggeroption(v, "enabled"))
-- end -- for
-- end -- if we have any triggers
end
function enable_practice_triggers()
EnableTriggerGroup("practice", true)
end
function disable_practice_triggers()
EnableTriggerGroup("practice", false)
EnableTrigger("next_blank_line", true)
practice_spells()
end
function enable_triggers()
EnableTriggerGroup("spellups", true)
end
function disable_triggers()
EnableTriggerGroup("spellups", false)
EnableTrigger("next_blank_line", true)
local sp = prac_count("spell")
local sk = prac_count("skill")
note("Found "..sk.." automatic skills and "..sp.." spellup spells less than "..limit.."% practiced.")
if (sp + sk) > 0 then
EnableTriggerGroup("practice_all", true)
SendNoEcho("echo {start_practice_all}")
practice_spells()
end
end
function prac_count(t)
local x = 0
for i, sp in ipairs(spells) do
if tonumber(sp.pct) < limit and sp.type == t then
x = x + 1
end
end
return x
end
function prac_ok(name, line, args)
pracs_spent = pracs_spent + args.spent
spells_prac = spells_prac + 1
note("'"..string_capitalize(args.name).."' practiced to "..args.pct..".")
end
function prac_nok(name, line, args)
pracs_cost = pracs_cost + args.cost
spells_left = spells_left + 1
end
function cant_prac()
cant = true
end
function next_blank_line()
EnableTrigger("next_blank_line", false)
end
function string_capitalize(str)
if #str < 2 then
return string.upper(str)
end
return (string.upper(string.sub(str, 1, 1))..string.sub(str, 2))
end
function OnPluginBroadcast (msg, id, name, text)
if id == "3e7dedbe37e44942dd46d264" then
if text == "char.status" then
char = gmcp("char")
if retry ~= "" then
Execute(retry)
retry = ""
end
end
end
end
function help()
ColourNote("silver", "", "\nThis plugin will practice the following types of skills/spells:")
ColourNote("white", "", " spellup")
ColourNote("white", "", " resist")
ColourNote("white", "", " healing")
ColourNote("white", "", " curative")
ColourNote("white", "", " passive")
ColourNote("white", "", " movement")
ColourNote("silver", "", "The command to practice all is ", "white", "", "prs", "silver", "", ".\n")
end
DoAfterSpecial(.2, "help()", 12)
]]>
</script>
</muclient>