Go Back   WowAce Forums > Addon Chat > Libraries
Libraries Threads for new libraries and mixins.

Closed Thread
 
Thread Tools
Old 08-17-2009   #1
Shadowed
Senior Member
 
Join Date: May 2005
Posts: 447
Default LibHealComm-4.0

Since the previous topic is mostly irrelevant as me and xbeeps agreed on 4.0, starting a new topic.

Project: http://www.wowace.com/addons/libhealcomm-4-0/
Documentation: http://www.wowace.com/addons/libpend...1-0/pages/api/

I've got pretty much all of the code/api/event/documentation done at this point, I need to go through and verify it's all 100% and then I'll write the wrapper and it should be ready for testing.
Shadowed is offline  
Old 08-17-2009   #2
xbeeps
Hero Member
 
Join Date: Jul 2008
Posts: 509
Default Re: LibHealComm-4.0

The API looks good. However, for GetHealAmount doesn't seem possible to get the amount of healing incoming to a target from everyone else but yourself before your currently casting heal lands (which is kind of the core functionality used by VisualHeal and the unit frame addons that properly show these as separate, and only show the incoming heals from others that land before your own). For example, if i know that my own heal will land at the time in endTime i will call GetHealAmount like this:

HealComm:GetHealAmount(guid, HealComm.ALL_HEALS, endTime)

However, there's no way to know if the heal I'm currently casting will be included in that, because the timeframe ends exactly on the point where my heal lands. I guess it depends on both rounding errors and whether you use > or >= for comparison, or other subtle things, so it's not possible to subtract the players heal size from the value returned. Regardless, from an API point of view, it should be possible to get the heal amount without the player contribution. LHC-3.0 never returned the heal from yourself in this call, and relied on the addon to remember that value by itself whenever a heal was active (which is just a matter of saving the amount in a local variable whenever a heal start event is triggered with the player as the healer).

Apart from that, i think everything looks good. Perhaps you want to reconsider exposing the internal tables, because when they are exposed you get locked down in how they are laid out, because changing them is an API change.
xbeeps is offline  
Old 08-17-2009   #3
Shadowed
Senior Member
 
Join Date: May 2005
Posts: 447
Default Re: LibHealComm-4.0

Quote:
Originally Posted by xbeeps View Post
The API looks good. However, for GetHealAmount doesn't seem possible to get the amount of healing incoming to a target from everyone else but yourself before your currently casting heal lands (which is kind of the core functionality used by VisualHeal and the unit frame addons that properly show these as separate, and only show the incoming heals from others that land before your own). For example, if i know that my own heal will land at the time in endTime i will call GetHealAmount like this:

HealComm:GetHealAmount(guid, HealComm.ALL_HEALS, endTime)

However, there's no way to know if the heal I'm currently casting will be included in that, because the timeframe ends exactly on the point where my heal lands. I guess it depends on both rounding errors and whether you use > or >= for comparison, or other subtle things, so it's not possible to subtract the players heal size from the value returned. Regardless, from an API point of view, it should be possible to get the heal amount without the player contribution. LHC-3.0 never returned the heal from yourself in this call, and relied on the addon to remember that value by itself whenever a heal was active (which is just a matter of saving the amount in a local variable whenever a heal start event is triggered with the player as the healer).

Apart from that, i think everything looks good. Perhaps you want to reconsider exposing the internal tables, because when they are exposed you get locked down in how they are laid out, because changing them is an API change.
If you wanted to get your own healing, you'd pass your GUID as casterGUID or you could do what Pitbull and agUF do which is when it sees a players heal start/delayed/stopped through the callbacks it saves when the players heal is going to end and requests all heals within that time period.

Besides that for getting the end time it uses the same method 3.0 did with getting the end time through UnitCastingInfo/UnitChannelInfo.

In HealComm-3.0:

Quote:
-- Add in the players own heals
local healed = playerHeals[target] or 0

-- Add in any heals from other people
local incoming = select(2, HealComm:UnitIncomingHealGet(target, 0))
if( incoming ) then
healed = healed + incoming
end

-- Apply any healing debuffs
healed = math.floor(healed * HealComm:UnitHealModifierGet(target))
Would be done something like the below in HealComm-4.0

Code:
	local playerHealed = HealComm:GetHealAmount(guid, HealComm.ALL_HEALS, nil, UnitGUID("player"))
	local restHealed = HealComm:GetHealAmount(guid, HealComm.ALL_HEALS) - playerHealed
	
	playerHealed = math.floor(playerHealed * HealComm:GetHealModifier(guid))
	restHealed = math.floor(restHealed * HealComm:GetHealModifier(guid))
If you needed to get both the total healing incoming and how much the player did.


That's true, the only reason the caster table was exposed is so people can see who has casted a heal or not, but I'll just replace that with a GUIDHasHealed called. The GUID -> Unit table will probably always be there/not changed unless Blizzard decides to let us get units from GUIDs.

Last edited by Shadowed; 08-17-2009 at 10:15 PM.
Shadowed is offline  
Old 08-17-2009   #4
xbeeps
Hero Member
 
Join Date: Jul 2008
Posts: 509
Default Re: LibHealComm-4.0

Hmm, i'm not sure you understand the problem. I want two quantites:

1) The heal that is incoming *only* from others *before* my heal lands.
2) The heal that is incoming from me.

2 is trivial, but 1 is not with the current API. Calling this:

Code:
local restHealed = HealComm:GetHealAmount(guid, HealComm.ALL_HEALS) - playerHealed
Will give me all heals that finish before and after mine, because there is no time frame given. I need those that land before mine only. Therefore, the extra argument is added:

Code:
local restHealed = HealComm:GetHealAmount(guid, HealComm.ALL_HEALS, endTimeOfCurrentlyCastingPlayerSpell) - playerHealed
However, as the boundary time is exactly the same time as the player spell lands, it is not possible to know if the currently casting player spell is or is not included in the quantity returned from GetHealAmount.

Maybe this picture explains it better: http://www.wowace.com/addons/visualh...es/4-heal-bar/

Note the "Incoming heals from others that will complete before yours"
xbeeps is offline  
Old 08-17-2009   #5
Kollektiv
Junior Member
 
Kollektiv's Avatar
 
Join Date: Jun 2006
Location: Massachusetts
Posts: 99
Default Re: LibHealComm-4.0

In response to: http://forums.wowace.com/showpost.ph...6&postcount=90

You should've looked at how LHC4 did it first . The way it does it now is

r1 will do

Code:
lib.healingModifiers = lib.healingModifiers or {
[spellname1] = 0.5,
[spellname2] = 1,
}
and r2 will do

Code:
lib.healingModifiers = lib.healingModifiers or {
[spellname1] = 0.5,
[spellname2] = 1,
[spellname3] = 1,
}
It is not doing it the way you described. The new entries in the upgraded version flat out never get added.

Also, AuraHandler should be something like below
Code:
if AuraHandler then AuraHandler(...) end
Kollektiv is offline  
Old 08-17-2009   #6
Shadowed
Senior Member
 
Join Date: May 2005
Posts: 447
Default Re: LibHealComm-4.0

Quote:
Originally Posted by Kollektiv View Post
In response to: http://forums.wowace.com/showpost.ph...6&postcount=90

You should've looked at how LHC4 did it first . The way it does it now is

-- Snipped --

It is not doing it the way you described. The new entries in the upgraded version flat out never get added.

Also, AuraHandler should be something like below
Code:
if AuraHandler then AuraHandler(...) end
What Xinhuan said is correct, in r1 it will initialize the table and then in r2 onward it will do nothing, if a new entry is added then it's added directly.

So if I add a new spell in r3 it becomes

Code:
lib.healingModifiers = lib.healingModifiers or {
    [1] = 0.50,
    [2] = 1,
}

lib.healingModifiers[3] = 2
Oops forgot that it uses UNIT_AURA for classes without data, fixed.

Quote:
Originally Posted by xbeeps View Post
Hmm, i'm not sure you understand the problem. I want two quantites:

1) The heal that is incoming *only* from others *before* my heal lands.
2) The heal that is incoming from me.

2 is trivial, but 1 is not with the current API. Calling this:

Code:
local restHealed = HealComm:GetHealAmount(guid, HealComm.ALL_HEALS) - playerHealed
Will give me all heals that finish before and after mine, because there is no time frame given. I need those that land before mine only. Therefore, the extra argument is added:

Code:
local restHealed = HealComm:GetHealAmount(guid, HealComm.ALL_HEALS, endTimeOfCurrentlyCastingPlayerSpell) - playerHealed
However, as the boundary time is exactly the same time as the player spell lands, it is not possible to know if the currently casting player spell is or is not included in the quantity returned from GetHealAmount.

Maybe this picture explains it better: http://www.wowace.com/addons/visualh...es/4-heal-bar/

Note the "Incoming heals from others that will complete before yours"
Perhaps instead an API like:

local healed = HealComm:GetOtherHealAmount(guid, bitFlag, endTime, casterGUID)

that will return all heals within the time band (if any) not counting the players heal, if you wanted to get the players heals + everyone else's before yours land it would be:

local playerHealed = HealComm:GetHealAmount(guid, HealComm.ALL_HEALS, endTime, UnitGUID("player"))
local beforePlayer = HealComm:GetOtherHealAmount(guid, HealComm.ALL_HEALS, endTime)

endTime would be something you kept track of through the heal events to figure out the longest player heal, it would look something like:

Code:
function HealComm:GetOtherHealAmount(guid, bitFlag, time)
	local amount = 0
	for casterGUID, spells in pairs(pendingHeals) do
		if( casterGUID ~= playerGUID ) then
			amount = amount + filterData(spells, guid, bitFlag, time)
		end
	end
	
	return amount > 0 and amount or nil
end
Shadowed is offline  
Old 08-17-2009   #7
Kollektiv
Junior Member
 
Kollektiv's Avatar
 
Join Date: Jun 2006
Location: Massachusetts
Posts: 99
Default Re: LibHealComm-4.0

Ah, I see how you'll add new entries. Sorry for wasting your time, I've never done something like that.

One more thing, I think you should register CLEU, CHAT_MSG_ADDON, UNIT_AURA, and the rest for healers only when the player is in a group.
Kollektiv is offline  
Old 08-17-2009   #8
Xinhuan
Asian Sheep Lover
 
Xinhuan's Avatar
 
Join Date: Aug 2007
Location: Singapore
Posts: 4,033
Default Re: LibHealComm-4.0

Quote:
Originally Posted by Kollektiv View Post
You should've looked at how LHC4 did it first . The way it does it now is
<snip>
It is not doing it the way you described. The new entries in the upgraded version flat out never get added.
Yes, if it did that then it was flawed upgrading code. This is why for libraries, authors are encouraged to let as many people review the code as possible before letting a beta version out for testing.

Especially lib upgrading/reembedding code.
__________________
Author/Maintainer of Postal, Omen3, GemHelper, BankItems, WoWEquip, GatherMate, Routes, HandyNotes and some others.
Xinhuan is offline  
Old 08-17-2009   #9
xbeeps
Hero Member
 
Join Date: Jul 2008
Posts: 509
Default Re: LibHealComm-4.0

Quote:
Originally Posted by Shadowed View Post
What Xinhuan said is correct, in r1 it will initialize the table and then in r2 onward it will do nothing, if a new entry is added then it's added directly.

So if I add a new spell in r3 it becomes

Code:
lib.healingModifiers = lib.healingModifiers or {
    [1] = 0.50,
    [2] = 1,
}

lib.healingModifiers[3] = 2
Oops forgot that it uses UNIT_AURA for classes without data, fixed.



Perhaps instead an API like:

local healed = HealComm:GetOtherHealAmount(guid, bitFlag, endTime, casterGUID)

that will return all heals within the time band (if any) not counting the players heal, if you wanted to get the players heals + everyone else's before yours land it would be:

local playerHealed = HealComm:GetHealAmount(guid, HealComm.ALL_HEALS, endTime, UnitGUID("player"))
local beforePlayer = HealComm:GetOtherHealAmount(guid, HealComm.ALL_HEALS, endTime)

endTime would be something you kept track of through the heal events to figure out the longest player heal, it would look something like:

Code:
function HealComm:GetOtherHealAmount(guid, bitFlag, time)
    local amount = 0
    for casterGUID, spells in pairs(pendingHeals) do
        if( casterGUID ~= playerGUID ) then
            amount = amount + filterData(spells, guid, bitFlag, time)
        end
    end
    
    return amount > 0 and amount or nil
end
That'll would work fine. You can also consider just adding a flag to the list of arguments, like this:

GetHealAmount(guid, bitFlag[, time[, includePlayer[, casterGuid]]])

Or perhaps a HealComm.PLAYER_HEALS bit ? Dunno if that would create some other consistency problems though. You decide!
xbeeps is offline  
Old 08-18-2009   #10
Kollektiv
Junior Member
 
Kollektiv's Avatar
 
Join Date: Jun 2006
Location: Massachusetts
Posts: 99
Default Re: LibHealComm-4.0

Not a bug, but I suggest you check that GetSpellInfo(spellid) exists outside the table constructor to safeguard the lib from breaking on patch days. You never know when blizz will remove a spellid.
Kollektiv is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:27 PM.