Phanx, you have mentioned you are writing a new version, or at least modifying the existing code. If I can make a suggestion to the API, since I think the code already calculates this: expose both the current casterID
and the first casterID for UnitHasIncomingRes.
Lua Code:
local status, endTime, currentCasterID, currentCasterGUID, firstCasterID, firstCasterGUID = LibResInfo:UnitHasIncomingRes(unit)
--[[
status is either "CASTING" or "PENDING"
endTime is the time the current caster's spell ends
currentCasterID and currentCasterGUID are the unitIDs or GUIDs for whomever is the current res caster on "unit"
firstCasterID and firstCasterGUID are the same as above, but for whomever's cast lands first
unit is "player", "target", "raid10", etc
]]--
This would make comparing isFirst's targetUnit to find out who is the first casterUnit on targetUnit much simpler.
The reason I ask is because I am running into the situation where SmartRes2's collision notification system is giving erroneous results if more than one caster is casting on the same unit, and even more erroneous results when there are more than one collision caster with more than one collision targets. Mass Resurrection's collision doesn't seem to be adversely affected.
My work in progress solution is building a table
Lua Code:
local doingRessing = {}
function MyAddOn:LibResInfo_ResCastStarted(targetUnit, targetGUID, casterUnit, casterGUID, endTime)
local _, _, _, isFirst = LibResInfo:UnitIsCastingRes(casterUnit)
if not doingRessing[casterUnit] then
if targetUnit then -- class spell. use isFirst for Mass Res since there is no targetUnit
doingRessing[casterUnit] = {
targetID = targetUnit,
isFirst = isFirst
}
end
end
-- if not isFirst and targetUnit then iterate through table to find out who IS first
-- send chat message to casterUnit with firstCasterID and targetUnit
end
function MyAddOn:LibResInfo_ResCastFinished(targetUnit, targetGUID, casterUnit, casterGUID)
if doingRessing[casterUnit] then
doingRessing[casterUnit] = nil
end
end
I am going on vacation for the weekend, and will not be able to apply this code and test until next week at the earliest. It is just a thought that if LRI calculates who is the first caster (target or not) in order to provide true/false for isFirst, then exposing both sides would be beneficial.