Yea....I figured out the error, apparently I had an extra set of "triggers" that was causing it to have compile errors. To answer the question about the return 0 part. It was a troubleshooting step that chatgpt made me do to figure out why it was having said compile error. I've since just abandoned the whole scripting/triggers portion and through it all into an xml file and using it via plug-in. It has debugging features that set the label and the target (per chatgpt). Example:
The energy in your Sauzer Blade intensifies as you continue to slash Super Saiyan Cabba.
[MH] Label set to: Sauzer Blade
[=====---]=-=[1072222]=-=[61%]
You violently slice through Super Saiyan Cabba with your Sauzer Blade.
[MH] Finisher seen. target='Super Saiyan Cabba', label='Sauzer Blade'
[=====---]=-=[1072222]=-=[61%]
However, it still won't print out number of hits or total yet (I'm trying to do that after the last hit), since it was funny and using a nonsensical trigger that it made up that thought ended combat and put the print-out on that when it shouldn't have.
The file is this now:
<?xml version="1.0" encoding="utf-8"?>
<muclient>
<plugin
name="MultiHitAggregator"
author="Xandler"
id="c0ffee1234deadbeef001122"
language="Lua"
purpose="Sum multi-hit damage and print a summary line (flush on last hit)"
save_state="y"
date_written="2025-08-12"
/>
<script><![CDATA[
-- ========= Multi-hit damage aggregator (flush on last hit) =========
mh = {
active=false, hits=0, sum=0,
label=nil, target=nil,
last_hit_time=0, debounce=0.6,
pending_final=false, -- finisher seen; next damage is the last
debug=true, -- set false to hide [MH] lines
}
local function fmt(n)
local s = tostring(n or 0)
s = s:reverse():gsub("(%d%d%d)","%1,"):reverse():gsub("^,","")
return s
end
local function dbg(msg)
if mh.debug then ColourNote("silver","", "[MH] "..msg) end
end
-- Damage line: [bar]=-[12345]=-[xx%]
function mh_on_damage(name, line, wc)
local dmg = tonumber(wc[1]) or 0
mh.sum = (mh.sum or 0) + dmg
mh.hits = (mh.hits or 0) + 1
mh.active = true
mh.last_hit_time = utils.timer()
dbg("DMG "..dmg.." (hits="..mh.hits..", sum="..mh.sum..")")
-- If finisher already seen, this is the last hit: flush now
if mh.pending_final then
mh.pending_final = false
dbg("Flushing immediately on last hit")
mh__flush(true)
return
end
-- Fallback: quiet-time flush in case finisher text doesn't appear
DoAfterSpecial(mh.debounce, 'mh__try_flush()', 12) -- 12 = send to script
end
-- Label capture: "The energy in your X intensifies ..."
function mh_capture_label(name, line, wc)
local lbl = wc[1]
if lbl and #lbl > 0 then mh.label = lbl end
dbg("Label set to: "..(mh.label or "nil"))
end
-- Finisher marker:
-- Matches both "violently slice through" and "slice through".
function mh_mark_final(name, line, wc)
local tgt, lbl = wc[1], wc[2]
if tgt and #tgt > 0 then mh.target = tgt end
if lbl and #lbl > 0 then mh.label = lbl end
mh.pending_final = true
dbg("Finisher seen. target='"..(mh.target or "?").."', label='"..(mh.label or "?").."'")
end
function mh__try_flush()
if not mh.active then return end
if utils.timer() - (mh.last_hit_time or 0) < (mh.debounce - 0.05) then return end
dbg("Quiet-time flush")
mh__flush(false)
end
function mh__flush(_forced)
if not mh.active or (mh.hits or 0) == 0 then mh__reset(); return end
local label = mh.label or "attack"
local times = (mh.hits == 1) and "time" or "times"
local tgt = mh.target and (" on " .. mh.target) or ""
ColourNote("gold","",string.format(
"Your %s hit %d %s%s for %s total damage.",
label, mh.hits, times, tgt, fmt(mh.sum)))
mh__reset()
end
function mh__reset()
mh.active=false; mh.hits=0; mh.sum=0
mh.label=nil; mh.target=nil
mh.last_hit_time=0; mh.pending_final=false
dbg("State reset")
end
]]></script>
<triggers>
<!-- DAMAGE: run EARLY and keep evaluating -->
<trigger enabled="y" group="multi-hit"
match="^\[[^\]]+\]=-\[(\d+)\]=-\[[^\]]+\]$"
regexp="y" script="mh_on_damage"
keep_evaluating="y" send_to="0" sequence="1" />
<!-- FINISHER cue: "... slice through TARGET with your LABEL." -->
<trigger enabled="y" group="multi-hit"
match="^You .*slice through (.+?) with your (.+?)\.$"
regexp="y" script="mh_mark_final"
keep_evaluating="y" send_to="0" sequence="2" />
<!-- Optional label capture (intensifies) -->
<trigger enabled="y" group="multi-hit"
match="^The energy in your (.+?) intensifies\b.*$"
regexp="y" script="mh_capture_label"
keep_evaluating="y" send_to="0" sequence="3" />
</triggers>
</muclient>
|