Update MikScrollingBattleText.lua

fix event merging for spell damage procs
This commit is contained in:
pepopo978
2024-01-22 11:14:52 -08:00
committed by GitHub
parent 13f191b9d2
commit b7e3415d16
@@ -721,97 +721,101 @@ end
-- Merges like animation events.
-- **********************************************************************************
function MikSBT.MergeEvents(mergeData, numEvents)
-- Hold whether or not the event was merged.
local eventMerged = false;
-- Don't attempt to merge any more events than were available when the function was called since
-- more events may get added while the merge is taking place.
for x = 1, numEvents do
-- Loop through all of the events in the merged events array.
for _, animationEvent in mergeData.MergedEvents do
-- Check if the event types match and the effect names are the same.
if ((mergeData.UnmergedEvents[x].EventType == animationEvent.EventType) and
(mergeData.UnmergedEvents[x].EffectName == animationEvent.EffectName)) then
-- Check if there is no effect name
if (mergeData.UnmergedEvents[x].EffectName == nil) then
-- Check if the affected unit name is the same.
if ((mergeData.UnmergedEvents[x].Name == animationEvent.Name) and mergeData.UnmergedEvents[x].Name ~= nil) then
-- Hold whether or not the event was merged.
local eventMerged = false;
-- Don't attempt to merge any more events than were available when the function was called since
-- more events may get added while the merge is taking place.
for x = 1, numEvents do
-- Loop through all of the events in the merged events array.
for _, animationEvent in mergeData.MergedEvents do
local unmergedEventMatched = false;
-- Check if the event types match and the effect names are the same.
if ((mergeData.UnmergedEvents[x].EventType == animationEvent.EventType) and
(mergeData.UnmergedEvents[x].EffectName == animationEvent.EffectName)) then
-- Check if there is no effect name
if (mergeData.UnmergedEvents[x].EffectName == nil) then
-- Check if the affected unit name is the same.
if ((mergeData.UnmergedEvents[x].Name == animationEvent.Name) and mergeData.UnmergedEvents[x].Name ~= nil) then
-- Do Merge.
eventMerged = true;
unmergedEventMatched = true;
end -- Same name.
-- There is an effect name.
else
-- Check if there is a name and replace it with the multiple targets string.
if (animationEvent.Name ~= nil) then
animationEvent.Name = MikSBT.MSG_MULTIPLE_TARGETS;
end
-- Do Merge.
eventMerged = true;
end -- Same name.
-- There is an effect name.
else
-- Check if there is a name and replace it with the multiple targets string.
if (animationEvent.Name ~= nil) then
animationEvent.Name = MikSBT.MSG_MULTIPLE_TARGETS;
unmergedEventMatched = true;
end -- Effect name?
end -- Event types match and effect names the same.
-- Check if the event should be merged.
if (unmergedEventMatched) then
-- Set the event merged flag for the event being merged.
mergeData.UnmergedEvents[x].EventMerged = true;
-- If the events have an amount then total them.
if (animationEvent.Amount ~= nil and mergeData.UnmergedEvents[x].Amount ~= nil) then
animationEvent.Amount = tonumber(animationEvent.Amount, 10)
if animationEvent.Amount and type(animationEvent.Amount) == "number" and mergeData.UnmergedEvents[x].Amount then
animationEvent.Amount = animationEvent.Amount + mergeData.UnmergedEvents[x].Amount;
end
-- Do Merge.
eventMerged = true;
end -- Effect name?
end -- Event types match and effect names the same.
-- Check if the event should be merged.
if (eventMerged) then
-- Set the event merged flag for the event being merged.
mergeData.UnmergedEvents[x].EventMerged = true;
-- If the events have an amount then total them.
if (animationEvent.Amount ~= nil and mergeData.UnmergedEvents[x].Amount ~= nil) then
animationEvent.Amount = tonumber(animationEvent.Amount, 10)
if animationEvent.Amount and type(animationEvent.Amount) == "number" and mergeData.UnmergedEvents[x].Amount then
animationEvent.Amount = animationEvent.Amount + mergeData.UnmergedEvents[x].Amount;
end
-- animationEvent.Amount = animationEvent.Amount + mergeData.UnmergedEvents[x].Amount;
-- animationEvent.Amount = animationEvent.Amount + mergeData.UnmergedEvents[x].Amount;
end
-- Check if there is an overheal amount and total it.
if (mergeData.UnmergedEvents[x].OverhealAmount ~= nil) then
animationEvent.OverhealAmount = (animationEvent.OverhealAmount or 0) + mergeData.UnmergedEvents[x].OverhealAmount;
end
-- Clear any partial effect text.
animationEvent.PartialEffectText = nil;
-- Increment the number of merged events.
animationEvent.NumMerged = animationEvent.NumMerged + 1;
-- Check if the event being merged is a crit and increment the number of crits.
if (mergeData.UnmergedEvents[x].IsCrit) then
animationEvent.NumCrits = animationEvent.NumCrits + 1;
end
-- Make sure the merged event is not flagged as a crit.
animationEvent.IsCrit = false;
end -- Do Merge.
end -- Loop through all merged events.
-- If the event wasn't merged add it to the end of the merged events array.
if (not eventMerged) then
local animationEvent = mergeData.UnmergedEvents[x];
animationEvent.NumMerged = 0;
-- Check if the event is a crit and set the number of crits appropriately.
if (animationEvent.IsCrit) then
animationEvent.NumCrits = 1;
else
animationEvent.NumCrits = 0;
end
-- Check if there is an overheal amount and total it.
if (mergeData.UnmergedEvents[x].OverhealAmount ~= nil) then
animationEvent.OverhealAmount = (animationEvent.OverhealAmount or 0) + mergeData.UnmergedEvents[x].OverhealAmount;
end
-- Clear any partial effect text.
animationEvent.PartialEffectText = nil;
-- Increment the number of merged events.
animationEvent.NumMerged = animationEvent.NumMerged + 1;
-- Check if the event being merged is a crit and increment the number of crits.
if (mergeData.UnmergedEvents[x].IsCrit) then
animationEvent.NumCrits = animationEvent.NumCrits + 1;
end
-- Make sure the merged event is not flagged as a crit.
animationEvent.IsCrit = false;
end -- Do Merge.
end -- Loop through all merged events.
-- If the event wasn't merged add it to the end of the merged events array.
if (not eventMerged) then
local animationEvent = mergeData.UnmergedEvents[x];
animationEvent.NumMerged = 0;
-- Check if the event is a crit and set the number of crits appropriately.
if (animationEvent.IsCrit) then
animationEvent.NumCrits = 1;
else
animationEvent.NumCrits = 0;
-- Add the animation event to the end of the merged events array.
table.insert(mergeData.MergedEvents, animationEvent);
end
-- Add the animation event to the end of the merged events array.
table.insert(mergeData.MergedEvents, animationEvent);
-- Reset the event merged flag.
eventMerged = false;
end
-- Reset the event merged flag.
eventMerged = false;
end
-- Loop through each event in the merged events array.
for _, animationEvent in mergeData.MergedEvents do
@@ -2803,4 +2807,4 @@ function MikSBT.DisplayMessage(message, displayType, isSticky, colorR, colorG, c
-- Add the event to the animation system.
MikSBT.AddAnimation(animationEvent);
end
end