Thread Tools Display Modes
Prev Previous Post   Next Post Next
Unread 02-19-13, 08:17 PM   #29
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,282
Originally Posted by myrroddin View Post
Just so I understand, endTime from UnitHasIncomingRes is when that person's Accept timer runs out (60 seconds), and not the cast time of the caster's resurrection spell?Whereas UnitIsCastingRes' endTime is the cast time of the spell (10 or less seconds)? If that is the case, then I wonder, does LRI add the cast time to 60 in order to get the true time out?
No. The values (including endTime) provided by UnitHasIncomingRes refer to whichever resurrection will be available to the specified unit first. If they already have a pending resurrection, then endTime gives you the time that resurrection will expire. If they do not already have a pending resurrection, but at least one resurrection spell is being cast on them (including Mass Res), then endTime gives you the time that the first of those spells will finish casting. You don't need to do any math.

In your example, while Jixx is still casting Resurrection, endTime refers to the time his cast bar will hit full and the spell will actually be cast. After Jixx has cast Resurrection and Phanx has an accept/cancel dialog box on her screen, endTime refers to the time that dialog box will disappear and Phanx will no longer be able to accept the resurrection.

Originally Posted by myrroddin View Post
... perhaps renaming UnitHasIncomingRes' endTime to expiryTime might be in order to lessen confusion.
You can name the variable whatever you want in your code. The documentation will continue to call it endTime because it can refer to either the end time of a spell cast, or the expiry time of a resurrection offer. That's why the first value returned by UnitHasIncomingRes is a string telling you whether the other values are related to a spell cast or a resurrection offer. At the most basic level, the idea is that you can perform a simple boolean check on the return from UnitHasIncomingRes to find out if you need to cast a res on the unit:

Code:
if LibResInfo:UnitHasIncomingRes(unit) then
    -- don't bother, someone else's res will get to them first
else
    -- they still need a res
end
Originally Posted by myrroddin View Post
The other way to look at it, just to add confusion, is that UnitHasIncomingRes's endTime is not 60 + cast time seconds, and is just end time of the caster's resurrection.
Why would it be 60 + cast time seconds? If the res spell is still being cast, then endTime is the end time of the spell cast.

Here is the basic process:

Code:
function lib:UnitHasIncomingRes(unit)
    if the unit can click "accept" to take a res that was already cast, then:
        return "PENDING", time the res will stop being available

    elseif *one* res spell is being cast on the unit, then
        return "CASTING", time the spell will finish casting, info about the unit casting the spell

    elseif *more than one* res spell is being cast on the unit, then
        determine which spell will finish casting first, and
        return "CASTING", time *that* spell will finish casting, info about the unit casting *that* spell

    end
end
Originally Posted by myrroddin View Post
Personally, I would have endTime in both UnitHasIncomingRes and UnitIsCastingRes = cast time, and make a note on the API page that authors should add 60 to get the Accept expiration time. My reasoning is that authors tend to want the cast time not the expiry time, which I pointed out is simple addition anyway.
Again, you are either not reading the documentation, or not reading the documentation. If the spell has already finished casting, then there is no cast time to provide, because there is no spell being cast.

Also, UnitHasIncomingRes and UnitIsCastingRes are different functions that provide information about different things.

UnitHasIncomingRes tells you about the res the specified unit will be able to take first. If they already have a res waiting to be accepted, then it tells you about that res. If they don't have a res waiting to be accepted, then it tells you about the first res spell that will finish casting on them.

UnitIsCastingRes tells you about the res spell being cast by the specified unit, even if the target of that spell already has a res ready to accept and 20 other people are already casting res spells on the same target.

Read the documenation and stop over-thinking it. It works exactly the way the documentation says it works. You don't need to blindly print the callback args and try to figure out what they mean on your own, because they mean exactly what the documentation says they mean.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
 

Go BackWoWInterface » AddOns, Compilations, Macros » Released AddOns » LibResInfo - resurrection info without comms

Thread Tools
Display Modes

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

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