<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Monday, May 15, 2006, 12:17 PM -->
<!-- MuClient version 3.70 -->

<!-- Plugin "Aardwolf_SpellupLUA" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Aardwolf_SpellupLUA"
   author="Onoitsu2"
   id="4d41b78adc358ae824fb70f6"
   language="Lua"
   purpose="This eases the spellup process"
   save_state="y"
   date_written="2006-05-15 12:10:03"
   requires="3.65"
   version="1.1"
   >
<description trim="n">
<![CDATA[
Commands are as follows: (without the <> of course)
addother <spellname>			- adds spell to the spellup list for other people
addspell <spellname> 			- adds spell to the spellup list for personal spellups
spellup                       	- casts personal spellups
spellup <name>  			    - casts spellups on that person
listspells <other>				- lists other spells (take out the other to see personal)
remother <spellname> 			- removes spell from other spellup list
remspell <spellname>  			- removes spell from personal spellup list
v2skill <skillname>      		- sets v2clanskill to use upon spellup
v2clear                       	- clears the v2skill to use
spellhelp						- shows this list of commands

]]>
</description>

</plugin>


<!--  Get our standard constants -->

<include name="constants.lua"/>

<!--  Triggers  -->

<triggers>
  <trigger
   group="spellup"
   match="^You lost your concentration while trying to cast ([\w\s]*)\."
   regexp="y"
   script="recastfailed"
   sequence="100"
  >
  </trigger>
  <trigger
   group="spellup"
   match="^Skill\: (.+) \(.*\)"
   omit_from_output="y"
   regexp="y"
   script="skillon"
   sequence="100"
  >
  </trigger>
  <trigger
   group="spellup"
   match="^Spell\: (.+) \(.*\)"
   omit_from_output="y"
   regexp="y"
   script="spellon"
   sequence="100"
  >
  </trigger>
  <trigger
   group="spellup"
   match="^You are affected by (.*)\."
   regexp="y"
   script="somespells"
   sequence="100"
  >
  </trigger>
  <trigger
   group="spellup"
   match="^You are affected by the following\:$"
   omit_from_output="y"
   regexp="y"
   sequence="100"
  >
  </trigger>
  <trigger
   group="spellup"
   match="^You are not affected by any skills or spells\."
   regexp="y"
   script="nospells"
   sequence="100"
  >
  </trigger>
</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   match="v2clear"
   enabled="y"
   group="spell"
   script="v2skillclear"
   sequence="100"
  >
  </alias>
  <alias
   match="v2skill *"
   enabled="y"
   expand_variables="y"
   group="spell"
   script="v2setskill"
   sequence="100"
  >
  </alias>
  <alias
   match="^addother ([\w\s]+)$"
   enabled="y"
   group="spell"
   regexp="y"
   script="addspellother"
   sequence="100"
  >
  </alias>
  <alias
   match="^addspell ([\w\s]+)$"
   enabled="y"
   group="spell"
   regexp="y"
   script="addspell"
   sequence="100"
  >
  </alias>
  <alias
   match="^listspells\s?(.*)$"
   enabled="y"
   group="spell"
   regexp="y"
   script="listspells"
   sequence="100"
  >
  </alias>
  <alias
   match="^remother ([\w\s]+)$"
   enabled="y"
   group="spell"
   regexp="y"
   script="removespellother"
   sequence="100"
  >
  </alias>
  <alias
   match="^remspell ([\w\s]+)$"
   enabled="y"
   group="spell"
   regexp="y"
   script="removespell"
   sequence="100"
  >
  </alias>
  <alias
   match="^spellup\s?([[:alpha:]]*)$"
   enabled="y"
   group="spell"
   regexp="y"
   script="spellup"
   omit_from_output="y"
   sequence="100"
  >
  </alias>
</aliases>

<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   regexp="y"
   group="spell"
   match="^spellhelp$"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[

spells = GetVariable("spells")
cspells = GetVariable("currentspells")
ospells = GetVariable("otherspells")
v2clanskill = GetVariable("v2clanskill")
v2clanskillcast = GetVariable("v2skillcast")
if spells == nil then
spells = ""
end
if cspells == nil then
cspells = ""
end
if ospells == nil then
ospells = ""
end
if v2clanskill == nil then
v2clanskill = ""
end
if v2clanskillcast == nil then
v2clanskillcast = ""
end
-- startup loading

function OnPluginSaveState()
SetVariable("spells", spells)
SetVariable("currentspells", cspells)
SetVariable("otherspells", ospells)
SetVariable("v2clanskill", v2clanskill)
SetVariable("v2skillcast", v2clanskillcast)
end

function addspell(sName, sLine, wildcards)
local spellist = spells
spellname = string.lower(wildcards[1])
if spellist == "" then
	spellist = wildcards[1]
	ColourNote("white", "blue", "Added Spell: " .. string.upper(spellname))
else
	for spell in string.gfind(spellist, "[^||]+") do
	if spell == spellname then
		ColourNote("white", "red", "Spell " .. string.upper(spellname) ..  " already in Your Spell List")
		return
	end
	end
	spellist = spellist .. "||" .. spellname
	ColourNote("white", "blue", "Added Spell: " .. string.upper(spellname))
end
spells = spellist
SaveState()
end -- addspell

function addspellother(sName, sLine, wildcards)
local spellist = ospells
ospellname = string.lower(wildcards[1])
if spellist == "" then
	spellist = wildcards[1]
	ColourNote("white", "blue", "Added Spell: " .. string.upper(ospellname))
else
	for spell in string.gfind(spellist, "[^||]+") do
	if spell == ospellname then
		ColourNote("white", "red", "Spell " .. string.upper(ospellname) ..  " already in your Others Spell List")
		return
	end
	end
	spellist = spellist .. "||" .. ospellname
	ColourNote("white", "blue", "Added Spell: " .. string.upper(ospellname))
end
ospells = spellist
SaveState()
end -- addspellother

function listspells(sName, sLine, wildcards)
count = 0
if wildcards[1] == "" then
	local spellist = spells
	if spellist == "" or spellist == nil then
	ColourNote("white", "red", "No spells in Your Spellup List")
	return
	end
	print ("")
	for spell in string.gfind(spellist, "[^||]+") do
		if count == 0 then
			ColourNote("white", "blue", "-- Your Spell List --")
		end
		ColourNote("white", "blue", spell)
		count = count + 1
	end
	if count > 0 then
		ColourNote("white", "blue", count .. " spell(s)")
	else
		ColourNote("white", "red", "No spells in your spellup list")
	end
	ColourNote("white", "black", "")
	v2skill = v2clanskill
	if not v2skill == "" then
		ColourNote("white", "blue", "V2 Clanskill set: " .. v2skill)
		ColourNote("white", "black", "")
	end
else
	if wildcards[1] == "other" then
		local spellist = ospells
		if spellist == "" or spellist == nil then
		ColourNote("white", "red", "No spells in your Other Spellup List")
		return
		end
		print ("")
		for spell in string.gfind(spellist, "[^||]+") do
			if count == 0 then
				ColourNote("white", "blue", "-- Other Spell List --")
			end
			ColourNote("white", "blue", spell)
			count = count + 1
		end
		if count > 0 then
			ColourNote("white", "blue", count .. " spell(s)")
		else
			ColourNote("white", "red", "No spells in your Other Spellup List")
		end
		ColourNote("white", "black", "")
	else
		ColourNote("white", "red", "Invalid option: " .. wildcards[1])
	end
end
end -- listspells

function spellup(nName,sLine,wildcards)
count = 0
target = string.lower(wildcards[1])
print (target)
if target == "" then
  EnableTriggerGroup("spellup", 1)
  cspells = ""
  if not v2clanskill == "" then
    v2skillcast = 1
  end
  Send("saff")
else
	local spellist = ospells
	if spellist == "" or spellist == nil then
	ColourNote("white", "red", "No spells in your Other Spellup List")
	return
	end
	print ("")
	for spell in string.gfind(spellist, "[^||]+") do
		Send("cast '" .. spell .. "' " .. target)
	count = count + 1
	end
	if count > 0 then
		ColourNote("white", "blue", count .. " spell(s) cast")
	else
		ColourNote("white", "red", "No spells to cast.")
	end
	ColourNote("white", "black", "")
end
end -- spellup

function removespell(sName,sLine,wildcards)
local spellist = spells
swanted = string.lower(wildcards[1])
sfound = 0
snewlist = ""
count = 0
for spell in string.gfind(spellist, "[^||]+") do
	if spell == swanted then
		sfound = 1
	else
		if count > 0 then
			snewlist = snewlist .. "||"
		end
	count = count + 1
	snewlist = snewlist .. spell
	end
end
if sfound == 0 then
  ColourNote("white", "red", "Spell " .. string.upper(swanted) .. " not in Your Spell List")
else
  spells = snewlist
  SaveState()
  ColourNote("white", "green",  "Spell " .. string.upper(swanted) .. " removed from Your Spell List")
end
end -- removespell

function removespellother(sName,sLine,wildcards)
local spellist = ospells
swanted = string.lower(wildcards[1])
sfound = 0
snewlist = ""
count = 0
for spell in string.gfind(spellist, "[^||]+") do
	if spell == swanted then
		sfound = 1
	else
		if count > 0 then
			snewlist = snewlist .. "||"
		end
	snewlist = snewlist .. spell
	count = count + 1
	end
end
if sfound == 0 then
  ColourNote("white", "red", "Spell " .. string.upper(swanted) .. " not in your Others Spell List")
else
  ospells = snewlist
  SaveState()
  ColourNote("white", "green",  "Spell " .. string.upper(swanted) .. " removed from your Others Spell List")
end
end -- removespellother

function v2setskill(sName,sLine,wildcards)
v2clanskill = wildcards[1]
ColourNote("white", "blue", wildcards[1] .. " added as V2 Clanskill.")
SaveState()
end -- v2setskill

function v2skillclear(sName,sLine,wildcards)
ColourNote("white","blue","V2 Clanskill '" .. string.upper(v2clanskill0) .. "' removed from spellup.")
v2clanskill = ""
SaveState()
end -- v2skillclear

function nospells(sName,sLine,wildcards)
spellist = spells
count = 0
if v2skillcast == 1 then
Send(v2clanskill)
end
for spell in string.gfind(spellist, "[^||]+") do
	Send("cast '" .. spell .. "'")
	count = count + 1
end
if v2skillcast == 1 then
ColourNote("white", "green", "V2 Skill reapplied")
end
if count > 0 then
  ColourNote("white", "blue", count .. " spell(s) cast")
else
  ColourNote("white", "red", "No spells to cast.")
end
EnableTriggerGroup("spellup", 0)
end -- nospells

function somespells(sName,sLine,wildcards)
local curspells = cspells
local spellist = spells
local sfound = 0
count = 0
if v2skillcast == 1 then
Send(v2clanskill)
end
for spell in string.gfind(spellist, "[^||]+") do
	sfound = 0
	for cspell in string.gfind (curspells, "[^|]+") do
		if cspell == spell then
			sfound = 1
			break
		end
	end
	if sfound == 0 then
	Send("cast '" .. spell .. "'")
	count = count + 1
	end
end
if v2skillcast == 1 then
  ColourNote("white", "green", "V2 Clanskill reapplied")
end
	if count > 0 then
		ColourNote("white", "blue", count .. " spell(s) cast")
	else
		ColourNote("white", "red", "No spells to cast.")
	end
	ColourNote("white", "black", "")
EnableTriggerGroup("spellup",0)
end -- somespells

function spellon(sName,sLine,wildcards)
curspells = cspells
newspell = string.lower(wildcards[1])
if curspells == "" then
	curspells = newspell .. "|"
else
	curspells = curspells .. "|" .. newspell .. "|"
end
cspells = curspells
SaveState()
end -- spellon

function skillon(sName,sLine,wildcards)
if string.lower(wildcards[1]) == v2clanskill then
	v2skillcast = 0
end
SaveState()
end -- skillon

function recastfailed(sName,sLine,wildcards)
spelllist = spells
failed = wildcards[1]
for spell in string.gfind (spellist, "[^||]+") do
	if spell == failed then
	Send("cast '" .. spell .. "'")
	end
end
end -- recastfailed

function OnPluginInstall()
OnHelp()
end

function OnHelp(sName, sLine, wildcards)
  Note(world.GetPluginInfo(world.GetPluginID(), 3))
end
]]>
</script> 

</muclient>
