|
|
|
<?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 eprint() function
|
|
|
|
-- 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 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.regular = { start=false, prepend="[dTrack Swings]: " }
|
|
|
|
dtrack.hits = { start=false, prepend="[dTrack Hits]: " }
|
|
|
|
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,
|
|
|
|
["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
|
|
|
|
dtrack.regular[returnTracked(columnone)] = ("%0.2f"):format(tonumber(trim(string.sub(line, returnStringPosition("[", 1, line)+1, returnStringPosition("]", 1, line)-1))))
|
|
|
|
end
|
|
|
|
if (returnTracked(columntwo) ~= -1) then
|
|
|
|
dtrack.regular[returnTracked(columntwo)] = ("%0.2f"):format(tonumber(trim(string.sub( line, returnStringPosition("[", 30, line)+1, returnStringPosition("]", 30, line)-1))))
|
|
|
|
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
|
|
|
|
print( "[ERROR]: 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"])
|
|
|
|
end
|
|
|
|
--[[ create report ]]--
|
|
|
|
function reportSwings()
|
|
|
|
local message = ("%s %s Swings/Round[%0.2f] Hits%%[%0.2f] DPH[%0.2f]"):format(
|
|
|
|
dtrack.channel,
|
|
|
|
dtrack.regular.prepend,
|
|
|
|
dtrack.regular.swings,
|
|
|
|
dtrack.regular.hitpercent,
|
|
|
|
dtrack.regular.dph)
|
|
|
|
if dtrack.regular.sname then
|
|
|
|
message = ("%s %s(%0.2f)"):format(message, dtrack.regular.sname, dtrack.regular.trackedavg)
|
|
|
|
end
|
|
|
|
SendNoEcho( message )
|
|
|
|
end
|
|
|
|
function reportHits()
|
|
|
|
local command = ("%s %s %s(%d) %s(%d/%d [%0.2f%%]) %s(%d/%d [%0.2f%%]) %s(%d/%d [%0.2f%%]) %s(%d/%d [%0.2f%%]) %s(%d) %s(%d) %s(%d/%d [%0.2f%%]) %s(%d) | Total Hits(%d/%d [%0.2f%%])"):format( dtrack.channel,
|
|
|
|
dtrack.hits.prepend, "Primary Attack", dtrack.hits["Primary Attack"], "Second Attack", dtrack.hits["Second Attack"], dtrack.hits["inst_Second Attack"], returnPercent(dtrack.hits["inst_Second Attack"], dtrack.hits["Hits"] ), "Third Attack", dtrack.hits["Third Attack"], dtrack.hits["inst_Third Attack"], returnPercent(dtrack.hits["inst_Third Attack"], dtrack.hits["Hits"] ), "Fourth Attack", dtrack.hits["Fourth Attack"], dtrack.hits["inst_Fourth Attack"], returnPercent(dtrack.hits["inst_Fourth Attack"], dtrack.hits["Hits"] ), "Dual Wield", dtrack.hits["Dual Wield"], dtrack.hits["inst_Dual Wield"], returnPercent(dtrack.hits["inst_Dual Wield"], dtrack.hits["Hits"] ), "Second Dual", dtrack.hits["Second Dual"], "Third Dual", dtrack.hits["Third Dual"], "Haste Attacks", dtrack.hits["Haste Attacks"], dtrack.hits["inst_Haste Attacks"], returnPercent(dtrack.hits["inst_Haste Attacks"], dtrack.hits["Hits"] ), "Lightspeed", dtrack.hits["Lightspeed"], dtrack.hits["Hits"], returnTotalInstinctHits(), returnPercent(returnTotalInstinctHits(), dtrack.hits["Hits"]) )
|
|
|
|
SendNoEcho( command )
|
|
|
|
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
|
|
|
|
end
|
|
|
|
if not (args.channel) then
|
|
|
|
dtrack.channel = "echo"
|
|
|
|
end
|
|
|
|
if args.command:lower() == "swings" then
|
|
|
|
EnableTriggerGroup("dtrack_swings", true)
|
|
|
|
SendNoEcho( "dtrack" )
|
|
|
|
elseif args.command:lower() == "hits" then
|
|
|
|
EnableTriggerGroup("dtrack_hits", true)
|
|
|
|
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>
|