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.
254 lines
13 KiB
254 lines
13 KiB
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!DOCTYPE muclient>
|
|
<muclient>
|
|
<plugin
|
|
name="DTrackReports" author="Icecool"
|
|
id="05cd229ae24e869f9da3bf01"
|
|
purpose="Plugin used to report DTRACK data"
|
|
language="Lua" date_written="2019-01-31 00:00:00"
|
|
save_state="n" requires="0.00" version="1.00" > </plugin>
|
|
<aliases>
|
|
<alias regexp = "y" ignore_case="y" enabled="y" echo_alias="y" sequence="95"
|
|
match="^^dre(port)?\s?(?<command>\w+)?\s?(?<channel>\w+)?$$"
|
|
script="ALIAS_report"></alias>
|
|
</aliases>
|
|
<triggers>
|
|
<trigger
|
|
enabled="n" regexp="y" omit_from_output="y" sequence="100" send_to="12" group="dtrack_swings"
|
|
match="^(.*?)$"
|
|
script="TRIGGER_process_dtrack_line" ></trigger>
|
|
<trigger
|
|
enabled="n" regexp="y" omit_from_output="y" sequence="100" send_to="12" group="dtrack_hits"
|
|
match="^(.*?)$"
|
|
script="TRIGGER_process_hits_line" ></trigger>
|
|
</triggers>
|
|
<!-- Get our standard constants -->
|
|
<include name="constants.lua"/>
|
|
<!-- Script -->
|
|
<script>
|
|
<![CDATA[
|
|
--[[ External Resources ]]--
|
|
dofile(GetInfo(60) .. "aardwolf_colors.lua") -- Used to support Aard Colors for the cnote() function
|
|
-- Script Global variables
|
|
Debug = false
|
|
-- Define Colors
|
|
c_dividers = "@w"
|
|
c_primary = "@G"
|
|
c_pnumber = "@W"
|
|
c_inumber = "@Y"
|
|
c_percent = "@R"
|
|
c_prepend = "@C"
|
|
|
|
-- Basic print function that supports aard, xterm, and ANSI color codes [idea from Durel's Inventory script]
|
|
function cnote(string)
|
|
AnsiNote(stylesToANSI(ColoursToStyles(string)))
|
|
end
|
|
function dnote(str)
|
|
if Debug then
|
|
cnote("@R[DEBUG]: @w"..str.."@w")
|
|
end
|
|
end
|
|
function trim(s)
|
|
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
|
end
|
|
function returnStringPosition( item, start, arg ) -- Designed to save on some variable usage in commands
|
|
local position, _ = string.find(arg, item, start, true)
|
|
if position then
|
|
return position
|
|
else
|
|
return -1
|
|
end
|
|
end
|
|
dtrack = { channel="echo" }
|
|
dtrack_track = {
|
|
["Swings Per Round"]="swings",
|
|
["Hit Percentage"]="hitpercent",
|
|
["Damage Per Hit"]="dph",
|
|
["Average"]="trackedavg"
|
|
}
|
|
dtrack_hits = {
|
|
["Hits"]=false,
|
|
["Primary Attack"]=false,
|
|
["Second Attack"]=true,
|
|
["Third Attack"]=true,
|
|
["Fourth Attack"]=true,
|
|
["Fifth Attack"]=false,
|
|
["Sixth Attack"]=false,
|
|
["Dual Wield"]=true,
|
|
["Second Dual"]=false,
|
|
["Third Dual"]=false,
|
|
["Haste Attacks"]=true,
|
|
["Lightspeed"]=false,
|
|
["Knife Attacks"]=true,
|
|
["Unarmed"]=false
|
|
}
|
|
--[[ dtrack swings logic ]]--
|
|
function isTrackedLine(argument)
|
|
return ((argument == "Tracked Spell") or (argument == "Tracked Skill"))
|
|
end
|
|
function returnTracked(argument)
|
|
for index, value in pairs(dtrack_track) do
|
|
if index == argument then
|
|
return value
|
|
end
|
|
end
|
|
return -1
|
|
end
|
|
function TRIGGER_process_dtrack_line(_, line, _, _)
|
|
local columnone = trim(string.sub(line, returnStringPosition(":", 1, line)-12, returnStringPosition(":", 1, line)-1))
|
|
local columntwo = trim(string.sub(line, returnStringPosition(":", 30, line)-20, returnStringPosition(":", 30, line)-1))
|
|
if (trim(line) == "") then
|
|
return
|
|
elseif (string.sub(line, 1, 1) == "-") then
|
|
if not dtrack.regular.start then
|
|
dtrack.regular.start = true
|
|
elseif dtrack.regular.start then
|
|
EnableTriggerGroup("dtrack_swings", false)
|
|
reportSwings()
|
|
end
|
|
elseif (isTrackedLine(trim(string.sub(line,1,13)))) then
|
|
dtrack.regular["sname"] = trim(string.sub(line,returnStringPosition("(",1,line)+1,returnStringPosition("):",1,line)-1))
|
|
else
|
|
if (returnTracked(columnone) ~= -1) then
|
|
dnote(("@D[@GdTrack Reports@D]:@w returnTracked returned @R%s@w. The value found afterwards is @R%0.2f.@w"):format(returnTracked(columnone), tonumber(trim(string.sub(line, returnStringPosition("[", 1, line)+1, returnStringPosition("]", 1, line)-1)))))
|
|
local value = ("%0.2f"):format(tonumber(trim(string.sub(line, returnStringPosition("[", 1, line)+1, returnStringPosition("]", 1, line)-1))))
|
|
dtrack.regular[returnTracked(columnone)] = value
|
|
end
|
|
if (returnTracked(columntwo) ~= -1) then
|
|
dnote(("@D[@GdTrack Reports@D]:@w returnTracked returned @R%s@w. The value found afterwards is @R%0.2f.@w"):format(returnTracked(columntwo), tonumber(trim(string.sub(line, returnStringPosition("[", 30, line)+1, returnStringPosition("]", 30, line)-1)))))
|
|
local value = ("%0.2f"):format(tonumber(trim(string.sub( line, returnStringPosition("[", 30, line)+1, returnStringPosition("]", 30, line)-1))))
|
|
dtrack.regular[returnTracked(columntwo)] = value
|
|
end
|
|
end
|
|
end
|
|
--[[ dtrack hits logic ]]--
|
|
function isHitsAttack(argument)
|
|
local calculate=returnStringPosition(":",1,argument)-(returnStringPosition(":",1,argument)-1)
|
|
local command = trim(string.sub( argument, calculate, returnStringPosition(":",1,argument)-1))
|
|
for index, value in pairs(dtrack_hits) do
|
|
if index == command then
|
|
return true, value, index
|
|
end
|
|
end
|
|
return false, false, index
|
|
end
|
|
function returnAttackNumbers(argument)
|
|
return returnHits(argument), returnInstincts(argument)
|
|
end
|
|
function returnHits(argument)
|
|
return tonumber(trim(string.sub(argument,returnStringPosition("[", 1, argument)+1,returnStringPosition("]", 1, argument)-1)))
|
|
end
|
|
function returnInstincts(argument)
|
|
return tonumber(trim(string.sub(argument,returnStringPosition("(Ins", 1, argument)+9,returnStringPosition(")", 1, argument)-1)))
|
|
end
|
|
function TRIGGER_process_hits_line(_, line, _, _)
|
|
if (string.sub(line, 1, 1) == "-") then
|
|
if not dtrack.hits.start then
|
|
dtrack.hits.start = true
|
|
elseif dtrack.hits.start then
|
|
EnableTriggerGroup("dtrack_hits", false)
|
|
reportHits()
|
|
end
|
|
elseif (trim(line) == "") or (not isHitsAttack(line)) then
|
|
return -- Not a line we care about
|
|
else
|
|
local is_attack, has_instinct, skill = isHitsAttack(line)
|
|
if is_attack and not has_instinct then
|
|
dtrack.hits[skill], _ = returnAttackNumbers(line)
|
|
elseif is_attack and has_instinct then
|
|
dtrack.hits[skill], dtrack.hits["inst_"..skill] = returnAttackNumbers(line)
|
|
end
|
|
end
|
|
end
|
|
function returnPercent( instinct, total )
|
|
if (tonumber(instinct) or tonumber(total)) == nil then
|
|
dnote( "returnPercent() cannot caluclate a percentage on the items provided." )
|
|
return 0
|
|
end
|
|
return (("%0.2f"):format(tonumber(instinct)/tonumber(total)*100))
|
|
end
|
|
function returnTotalInstinctHits()
|
|
return (dtrack.hits["inst_Second Attack"]+dtrack.hits["inst_Third Attack"]+dtrack.hits["inst_Fourth Attack"]+dtrack.hits["inst_Dual Wield"]+dtrack.hits["inst_Haste Attacks"]+dtrack.hits["inst_Knife Attacks"])
|
|
end
|
|
--[[ create report ]]--
|
|
function reportSwings()
|
|
-- Check to see if swing number was reported, if not make the entry = 0
|
|
for _, hit in pairs(dtrack_track) do
|
|
if not tonumber(dtrack.regular[hit]) then
|
|
dnote(("reportSwings() - %s was reported as not a number. Setting it to 0."):format(hit))
|
|
dtrack.regular[hit] = 0
|
|
end
|
|
end
|
|
local message = ("%s %s %sSwings/Round%s[%s%0.2f%s] %sHits%%%s[%s%0.2f%s] %sDPH%s[%s%0.2f%s]"):format(
|
|
dtrack.channel, dtrack.regular.prepend, c_primary, c_dividers, c_pnumber, dtrack.regular.swings, c_dividers, c_primary, c_dividers, c_pnumber, dtrack.regular.hitpercent, c_dividers, c_primary, c_dividers, c_pnumber, dtrack.regular.dph, c_dividers)
|
|
if dtrack.regular.sname then
|
|
message = ("%s %s%s%s(%s%0.2f%s)"):format(message, c_primary, dtrack.regular.sname, c_dividers, c_pnumber, dtrack.regular.trackedavg, c_dividers)
|
|
end
|
|
SendNoEcho( message )
|
|
dtrack.regular = nil
|
|
end
|
|
function reportHits()
|
|
-- Check to see if instinct was reported, if not make the entry = 0
|
|
if not tonumber(dtrack.hits["inst_Second Attack"]) then dtrack.hits["inst_Second Attack"] = 0 end
|
|
if not tonumber(dtrack.hits["inst_Third Attack"]) then dtrack.hits["inst_Third Attack"] = 0 end
|
|
if not tonumber(dtrack.hits["inst_Fourth Attack"]) then dtrack.hits["inst_Fourth Attack"] = 0 end
|
|
if not tonumber(dtrack.hits["inst_Dual Wield"]) then dtrack.hits["inst_Dual Wield"] = 0 end
|
|
if not tonumber(dtrack.hits["inst_Haste Attacks"]) then dtrack.hits["inst_Haste Attacks"] = 0 end
|
|
if not tonumber(dtrack.hits["inst_Knife Attacks"]) then dtrack.hits["inst_Knife Attacks"] = 0 end
|
|
if not tonumber(dtrack.hits["Knife Attacks"]) then dtrack.hits["Knife Attacks"] = 0 end
|
|
-- Build command for SendNoEcho()
|
|
local command = ("%s %s %s%s%s(%s%d%s) %s%s%s(%s%d%s/%s%d %s[%s%0.2f%%%s]) %s%s%s(%s%d%s/%s%d %s[%s%0.2f%%%s]) %s%s%s(%s%d%s/%s%d %s[%s%0.2f%%%s]) %s%s%s(%s%d%s/%s%d %s[%s%0.2f%%%s]) %s%s%s(%s%d%s) %s%s%s(%s%d%s) %s%s%s(%s%d%s/%s%d %s[%s%0.2f%%%s]) %s%s%s(%s%d%s) %s%s%s(%s%d%s/%s%d %s[%s%0.2f%%%s]) %s%s%s(%s%d%s) %s| %sTotal Hits%s(%s%d%s/%s%d %s[%s%0.2f%%%s])"):format(dtrack.channel, dtrack.hits.prepend, c_primary, "Primary Attack", c_dividers, c_pnumber, dtrack.hits["Primary Attack"], c_dividers, c_primary, "Second Attack", c_dividers, c_pnumber, dtrack.hits["Second Attack"], c_dividers, c_inumber, dtrack.hits["inst_Second Attack"], c_dividers, c_percent, returnPercent(dtrack.hits["inst_Second Attack"], dtrack.hits["Hits"] ), c_dividers, c_primary, "Third Attack", c_dividers, c_pnumber, dtrack.hits["Third Attack"], c_dividers, c_inumber, dtrack.hits["inst_Third Attack"], c_dividers, c_percent, returnPercent(dtrack.hits["inst_Third Attack"], dtrack.hits["Hits"] ), c_dividers, c_primary, "Fourth Attack", c_dividers, c_pnumber, dtrack.hits["Fourth Attack"], c_dividers, c_inumber, dtrack.hits["inst_Fourth Attack"], c_dividers, c_percent, returnPercent(dtrack.hits["inst_Fourth Attack"], dtrack.hits["Hits"] ), c_dividers, c_primary, "Dual Wield", c_dividers, c_pnumber, dtrack.hits["Dual Wield"], c_dividers, c_inumber, dtrack.hits["inst_Dual Wield"], c_dividers, c_percent, returnPercent(dtrack.hits["inst_Dual Wield"], dtrack.hits["Hits"] ), c_dividers, c_primary, "Second Dual", c_dividers, c_pnumber, dtrack.hits["Second Dual"], c_dividers, c_primary, "Third Dual", c_dividers, c_pnumber, dtrack.hits["Third Dual"], c_dividers, c_primary, "Haste Attacks", c_dividers, c_pnumber, dtrack.hits["Haste Attacks"], c_dividers, c_inumber, dtrack.hits["inst_Haste Attacks"], c_dividers, c_percent, returnPercent(dtrack.hits["inst_Haste Attacks"], dtrack.hits["Hits"] ), c_dividers, c_primary, "Lightspeed", c_dividers, c_pnumber, dtrack.hits["Lightspeed"], c_dividers, c_primary, "Knife Attacks", c_dividers, c_pnumber, dtrack.hits["Knife Attacks"], c_dividers, c_inumber, dtrack.hits["inst_Knife Attacks"], c_dividers, c_percent, returnPercent(dtrack.hits["inst_Knife Attacks"], dtrack.hits["Hits"] ), c_dividers, c_primary, "Unarmed", c_dividers, c_pnumber, dtrack.hits["Unarmed"], c_dividers, c_prepend, c_pnumber, c_dividers, c_pnumber, dtrack.hits["Hits"], c_dividers, c_inumber, returnTotalInstinctHits(), c_dividers, c_percent, returnPercent(returnTotalInstinctHits(), dtrack.hits["Hits"]), c_dividers )
|
|
SendNoEcho( command )
|
|
dtrack.hits = nil
|
|
end
|
|
--[[ ALIAS command ]]--
|
|
function ALIAS_report(name, line, args)
|
|
if not (args.command) then
|
|
cnote( "@CSyntax: @Gdreport @R<@wswings|hits@R> <@wchannel@R>@w" )
|
|
return
|
|
end
|
|
if args.command:lower() == "help" then
|
|
DREPORT_Help()
|
|
return
|
|
elseif args.command:lower() == "debug" then
|
|
Debug = not Debug
|
|
cnote(("@D[@GdTrack Reports@D]:@w Debug mode is now %s@w."):format(Debug and "@Gon" or "@Roff"))
|
|
end
|
|
if not (args.channel) then
|
|
dtrack.channel = "echo"
|
|
else
|
|
dtrack.channel = args.channel
|
|
end
|
|
if args.command:lower() == "swings" then
|
|
EnableTriggerGroup("dtrack_swings", true)
|
|
dtrack.regular = { start=false, prepend="@C[dTrack Swings]:@w " }
|
|
SendNoEcho( "dtrack" )
|
|
elseif args.command:lower() == "hits" then
|
|
EnableTriggerGroup("dtrack_hits", true)
|
|
dtrack.hits = { start=false, prepend="@C[dTrack Hits]:@w " }
|
|
SendNoEcho( "dtrack hits" )
|
|
else
|
|
DREPORT_Help()
|
|
return
|
|
end
|
|
end
|
|
--[[ Help File ]]--
|
|
function DREPORT_Help()
|
|
cnote("@GdTrack Reports@w")
|
|
cnote("@WUsage:@w")
|
|
cnote("@G dreport help @w:@W This menu@w")
|
|
cnote("@G dreport swings <channel> @w:@W Reports the 'dtrack' main screen to a channel@w")
|
|
cnote("@G dreport hits <channel> @w:@W Reports teh 'dtrack hits' screen to a channel@w")
|
|
Note()
|
|
end
|
|
--[[ MUSH Specific functions for saving/loading Plugin information ]]--
|
|
-- Anytime a variable (designed to save over) is modified, call SaveState() function afterwards.
|
|
function OnPluginSaveState ()
|
|
end -- function OnPluginSaveState
|
|
function OnPluginInstall ()
|
|
cnote("@GdTrack Reports@w initialized. Check out 'dtrack help' for more information.@w")
|
|
end -- function OnPluginInstall
|
|
]]>
|
|
|
|
</script>
|
|
</muclient> |