View Single Post
06-27-13, 08:03 PM   #16
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
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:
  1. local status, endTime, currentCasterID, currentCasterGUID, firstCasterID, firstCasterGUID = LibResInfo:UnitHasIncomingRes(unit)
  2. --[[
  3.     status is either "CASTING" or "PENDING"
  4.     endTime is the time the current caster's spell ends
  5.     currentCasterID and currentCasterGUID are the unitIDs or GUIDs for whomever is the current res caster on "unit"
  6.     firstCasterID and firstCasterGUID are the same as above, but for whomever's cast lands first
  7.     unit is "player", "target", "raid10", etc
  8. ]]--
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:
  1. local doingRessing = {}
  2. function MyAddOn:LibResInfo_ResCastStarted(targetUnit, targetGUID, casterUnit, casterGUID, endTime)
  3.     local _, _, _, isFirst = LibResInfo:UnitIsCastingRes(casterUnit)
  4.     if not doingRessing[casterUnit] then
  5.         if targetUnit then -- class spell. use isFirst for Mass Res since there is no targetUnit
  6.             doingRessing[casterUnit] = {
  7.                 targetID = targetUnit,
  8.                 isFirst = isFirst
  9.             }
  10.         end
  11.     end
  12.     -- if not isFirst and targetUnit then iterate through table to find out who IS first
  13.     -- send chat message to casterUnit with firstCasterID and targetUnit
  14. end
  15.  
  16. function MyAddOn:LibResInfo_ResCastFinished(targetUnit, targetGUID, casterUnit, casterGUID)
  17.     if doingRessing[casterUnit] then
  18.         doingRessing[casterUnit] = nil
  19.     end
  20. 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.
  Reply With Quote