API
It is relatively straightforward to setup your addon to work with LibHealComm-4.0, the first thing you need to do is to figure out what event you want to register. Below is an example of how you would register HealComm_HealStarted.
Example
local AddOn = {} local HealComm = LibStub("LibHealComm-4.0") -- Register for the event with the library HealComm.RegisterCallback(AddOn, "HealComm_HealStarted", "HealStarted") function AddOn:HealStarted(event, casterGUID, spellID, spellType, endTime, ...) -- Create a list of players being healed local players for i=1, select("#", ...) do if( players ) then players = players .. "," .. select(i, ...) else players = select(i, ...) end end -- Figure out how many seconds are left in the cast local secondsLeft = endTime - GetTime() -- Grab the spell name (can also get the spell rank/icon/etc from this function) local spellName = GetSpellInfo(spellID) print(string.format("%s is casting %s in %.2f seconds on %s", casterGUID, spellName, secondsLeft, players) end
Keep in mind
In HealComm-3.0 if you wanted to show all heals that are going to land within the time period the players current, you would just save players end time for their heal and then use that for the time frame. With 4.0 you can no longer do this because it supports heals like Tranquility which last longer than a few seconds.
Instead you can try something like the below that would show all heals landing within the players cast time, but it will cap how far in advance it shows incoming heals to 4 seconds.
local time = GetTime() local timeBand -- The player has a cast active, show all heals that are incoming within the cast time of their heal, or within 4 seconds if the players heal exceeds 4 seconds if( playerEndTime ) then timeBand = math.min(playerEndTime - time, 4) else timeBand = 4 end local healed = (HealComm:GetHealAmount(frame.unitGUID, HealComm.ALL_HEALS, time + timeBand) or 0) * HealComm:GetHealModifier(frame.unitGUID) print(string.format("Total healing incoming is %d", healed))
Bit Fields
There are a few constants provided that are used for identifying what kind of heal is triggered as well as used when filtering heals, they are:
Fields
- HealComm.ALL_HEALS
- Any type of heal, only necessary when you don't want to filter out a specific type of heal.
- HealComm.DIRECT_HEALS
- Casted heals (Flash Heal/Holy Light/Healing Touch)
- HealComm.CHANNEL_HEALS
- Channeled heals (Penance/Tranquility)
- HealComm.HOT_HEALS
- Heals over time (Rejuvenation/Renew/Lifebloom hot)
- HealComm.BOMB_HEALS
- Heals that are at the end of a heal over time (Lifebloom bloom)
- HealComm.CASTED_HEALS
- Constant that is the equivalent of doing bit.bor(HealComm.DIRECT_HEALS, HealComm.CHANNEL_HEALS)
Events
HealComm_HealStarted(event, casterGUID, spellID, healType, endTime, ...)
Calls whenever a new direct heal, channeled heal or heal over time is started.
Parameters
- event
- Event name that was triggered ("HealComm_HealStarted")
- casterGUID
- GUID of the person who casted the heal
- spellID
- An unique identifier that can be used to get various information on the spell, such as name, rank or icon
- healType
- Bit field indicating what type of heal it is
- endTime
- The time at which the heal is finished, subtract GetTime() from *endTime* to get the exact seconds
- ...
- List of player GUIDs that the heal is going to land on
HealComm_HealUpdated(event, casterGUID, spellID, type, endTime, ...)
Triggered whenever a channel or a heal over time ticks, each tick of Rejuvenation or Penance will fire this.
Also will fire when a HoT changes due to a stack of it being removed.
Parameters
- event
- Event name that was triggered ("HealComm_HealUpdated")
- casterGUID
- GUID of the person who casted the heal
- spellID
- An unique identifier that can be used to get various information on the spell, such as name, rank or icon
- healType
- Bit field indicating what type of heal it is
- endTime
- The time at which the heal is finished, subtract GetTime() from *endTime* to get the exact second
- ...
- List of player GUIDs that the heal has been updated for
HealComm_HealDelayed(event, casterGUID, spellID, type, endTime, ...)
Triggered when a direct or channeled heal is delayed and either going to end sooner or take longer before it lands. Because hots do not have a cast or channel time they cannot be delayed and will not trigger this event.
Parameters
- event
- Event name that was triggered ("HealComm_HealDelayed")
- casterGUID
- GUID of the person who casted the heal
- spellID
- An unique identifier that can be used to get various information on the spell, such as name, rank or icon
- healType
- Bit field indicating what type of heal it is
- endTime
- The new end time of when the heal is going to end
- ...
- List of player GUIDs that the heal has been delayed on
HealComm_HealStopped(event, casterGUID, spellID, type, interrupted, ...)
Triggered whenever a heal that has had HealComm_HealStarted triggered is finished.
Called for both heals that finished casting and heals that were interrupted early
Parameters
- event
- Event name that was triggered ("HealComm_HealStopped")
- casterGUID
- GUID of the person who casted the heal
- spellID
- An unique identifier that can be used to get various information on the spell, such as name, rank or icon
- healType
- Bit field indicating what type of heal it is
- interrupted
- True when the heal was interrupted early, false if the heal was successful
- ...
- List of player GUIDs that the heal ended on
HealComm_ModifierChanged(event, guid)
Triggered whenever a healing modifier changes for a player, the heal amount will need to be updated using the value from *HealComm:GetHealModifier(guid)*
Parameters
- event
- Event name that was triggered ("HealComm_ModifierChanged")
- guid
- GUID of the player who had a modifier change
HealComm_GUIDDisappeared(event, guid)
Triggered when a GUID has disappeared, either they left the group, were unsummoned (if a pet or vehicle) or the unit went outside the 100 yard range with an active hot on themselves.
When this is triggered an update of the healing incoming on guid is needed to prevent healing from becoming "stuck."
Parameters
- guid
- GUID of the player that disappeared and needs to be updated
API
HealComm:GetPlayerHealingMod()
Returns the current modifier that is applied to a players heal as a decimal. For example, paladins with Avenging Wrath active will see a return of 1.2.
HealComm:GetHealModifier(guid)
Returns the current healing modifier for the passed GUID
Parameters
- guid
- GUID of the player you want to retrieve the current healing modifier on
Return value
Returns the new healing value as a decimal: 0.75 = 25% less healing, 1.30 = 30% more healing, 1 = no change in healing.
HealComm:GetHealAmount(guid, healFlags[, timeFrame[, casterGUID]])
Returns the healing amount using the passed filters.
For hots with a time frame, it will return the ticks. For example Rejuvenation ticks for 3,000 at 3s, 6s, 9s, 12s and you retrieve only the last 6 seconds then you will get 6,000.
Parameters
- guid
- GUID of the player to retrieve healing incoming on
- healFlags
- Bit flag for the heal type, lets you retrieve a specific type of heals, see Bit Fields for more information.
- timeFrame
- Retrieves all heals that are going to end or tick before the time period given, when nil is passed it gets all pending heals.
- casterGUID
- Retrieves heals only from the passed GUID, when nil is passed then it gets pending heals from all casters.
Return value
Returns the total amount of healing that is going to be done using the provided filters, if no heaing is incoming using the given filters then nil is returned.
Examples
Retrieve all heals that will be cast on the player within the next 5 seconds.
local HealComm = LibStub("LibHealComm-4.0") local heal = HealComm:GetHealAmount(UnitGUID("player"), HealComm.ALL_HEALS, GetTime() + 5) or 0 print(string.format("You have at least %d healing incoming in the next 5 seconds.", heal))
Retrieve only direct and channeled heals in the next 2 seconds, ignores hots.
local HealComm = LibStub("LibHealComm-4.0") local heal = HealComm:GetHealAmount(UnitGUID("player"), HealComm.CASTED_HEALS, GetTime() + 2) or 0 print(string.format("You have at least %d healing incoming through casted and channeled heals in the next 2 seconds.", heal))
HealComm:GetOthersHealAmount(guid, healFlags[, timeFrame])
Same as GetHealAmount except it will return healing data for everyone except the player.
If you want to see all heals that land before the players does, you would use this with a time frame.
Parameters
- guid
- GUID of the player to retrieve healing incoming on
- healFlags
- Bit flag for the heal type, lets you retrieve a specific type of heals, see Bit Fields for more information.
- timeFrame
- Retrieves all heals that are going to end or tick before the time period given, when nil is passed it gets all pending heals.
Return value
Returns the total amount of healing that is going to be done using the provided filters, not including heals done by the player. If no healing is incoming using the given filters then nil is returned.
HealComm:GetCasterHealAmount(casterGUID, healFlags[, timeFrame])
Gets all the heals that the casterGUID is casting given the passed parameters.
This is for seeing that Healer X is casting for Y amount rather than Target A is receiving B amount of healing.
Parameters
- casterGuid
- GUID of the caster who you want all of their pending heals on
- healFlags
- Bit flag for the heal type, lets you retrieve a specific type of heals, see Bit Fields for more information.
- timeFrame
- Retrieves all heals that are going to end or tick before the time period given, when nil is passed it gets all pending heals.
Return value
Returns the total amount of healing the casterGUID is going to be doing using the given filters. If no healing is incoming then nil is returned.
HealComm:GetNextHealAmount(guid, healFlags[, timeFrame[, ignoreGUID]])
Gets the next heal that is going to land on the given guid using the passed parameters.
Parameters
- guid
- GUID you want to see the next heal that is going to be landing on them
- healFlags
- Bit flag for the heal type, lets you retrieve a specific type of heals, see Bit Fields for more information.
- timeFrame
- Time frame to look at, if you do GetTime() + 2 it will only return a next heal if it is landing within 2 seconds
- ignoreGUID
- GUID to ignore heals for, if you pass UnitGUID("player") it will not look at heals that are landing casted by the player.
Return value
local healTime, healFrom, healAmount = HealComm:GetNextHealAmount(...)
- healTime
- GetTime() of when the heal is going to land, or nil if no heal matches the given parameters
- healFrom
- GUID of the caster who is going to land the next heal
- healAmount
- Amount of healing the heal will do.
HealComm:GUIDHasHealed(casterGUID)
Returns whether or not the GUID has casted a heal that was caught by LibHealComm-4.0 (at any point in time)
Parameters
- casterGUID
- GUID to check if they ever healed.
Return value
True if they have, nil otherwise
HealComm:GetGUIDUnitMapTable()
Returns a table that contains a map of GUID to UnitID of grouped players and their pets or vehicles.
Keep in mind that it is possible to have a LibHealComm-4.0 event fire with a GUID that is not in the map, you need to make sure that the map returns an unit and that the unit exists.
When updating units, do not rely only on this map. Especially for heals ending, its possible you will not have a valid unit map causing heals to "freeze" because you can't find the frame to update.
This is a protected table, you cannot modify or delete it.
You can call this once on file load and store the table then reference that. Multiple calls to this function are unnecessary, but will not adversely effect performance.
Return value
Hash table that contains a map of GUID -> Unit.