WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Adding latency to cast bars, like Quartz? (https://www.wowinterface.com/forums/showthread.php?t=29933)

Victimize 01-10-10 09:51 PM

Adding latency to cast bars, like Quartz?
 
I have P3lim's oUF layout, and I was wondering if there was I bit of code I could add to give my cast bar the latency function, like Quartz does.

zero-kill 01-10-10 10:53 PM

Nope
...but then I'm lazy and haven't found it anywhere in the forums.

wurmfood 01-11-10 12:45 AM

It does include it, though it may not be as exact.

The Castbar element supports the .SafeZone sub element, which can be added and will give an approximate "safe zone" based on current latency. I added it to my layout with this:

Code:

if(unit == 'player') then
        self.Castbar.SafeZone = self.Castbar:CreateTexture(nil,'OVERLAY')
        self.Castbar.SafeZone:SetTexture(texture)
        self.Castbar.SafeZone:SetVertexColor(.69,.31,.31)
end

It's not perfect, but it's close. Note that you don't have to set the positioning for the texture, as the element sets it when a spell is being cast.

Xuerian 01-11-10 01:08 AM

You'll have to figure it out for yourself, the particulars anyway, but it's pretty simple.

Hook UNIT_SPELLCAST_START on your castbar and watch for player cast starts, then use the postCastStart hook to set a spark or something to the point at which you can start casting another spell, determined by measuring the time the spell of that id was sent and that point.

The safezone works alright for predictable latency, but for varying, it's worthless.

It might be helpful to check out Quartz's latency module for tips.

It may end up being simpler for you to use your own OnCastbarUpdate (based on the default one), I had to to add the latency-friendly things (Showing bar when cast actually starts, fading it out, showing instant casts, etc) to my layout that way.

haste 01-11-10 01:12 AM

Do note that the latency average is only updated every 30 sec, as oUF uses GetNetStats() to fetch it. That being said; WoW does a much finer job at handling casting with high latency in 3.x than any human could be. :)

Xuerian 01-11-10 01:19 AM

Quote:

Originally Posted by haste (Post 174147)
Do note that the latency average is only updated every 30 sec, as oUF uses GetNetStats() to fetch it. That being said; WoW does a much finer job at handling casting with high latency in 3.x than any human could be. :)

Sure does. Mash the button and it'll continuously cast, more or less. Unless you run into the GCD or cooldowns your client doesn't think are up, anyway.

It still goes a bit to hell if your latency is hugely unpredictable. I regularly run with a baseline of 250ms with areas where it rides up to 600ms+.

Having a visual indicator can cut down on RSI a bit, when you're mashing chain heal repeatedly.

Phanx 01-11-10 03:19 AM

Quote:

Originally Posted by Xuerian (Post 174148)
mashing chain heal repeatedly.

Don't get me started.

Also, the "real" latency code in Castbars is easier to read through than the code in Quartz, since it isn't full of checks for various options.

Oh, and Xuerian, when are you going to update oUF Smooth Update so I can quit embedding a fixed copy in my layout? :o

Xuerian 01-11-10 06:14 PM

Quote:

Originally Posted by Phanx (Post 174156)
Don't get me started.

Also, the "real" latency code in Castbars is easier to read through than the code in Quartz, since it isn't full of checks for various options.

Oh, and Xuerian, when are you going to update oUF Smooth Update so I can quit embedding a fixed copy in my layout? :o

What's broken? >_>

Phanx 01-12-10 12:06 AM

Bars with smaller max-values (under 150-200ish) don't ever fill completely with it enabled, leaving a 5-10 pixel gap at the end. If you haven't leveled any characters recently and don't play a rogue, warrior, death knight, or feral druid, you probably wouldn't notice. :p

There's comment on the download page with a Pastey URL to a fixed version that alleviates the problem.

juyanith 01-22-10 01:03 PM

1 Attachment(s)
Just to help anyone else out that is interested in this, I modified castbar.lua to calculate the latency. Basically, I added a function for UNIT_SPELLCAST_SENT that simply stores the send time:

Code:

local UNIT_SPELLCAST_SENT = function(self, event, unit, spell, spellrank)
        if(self.unit ~= unit) then return end

        self.Castbar.sentTime = GetTime()
end

Don't forget to register and unregister for the event in Enable and Disable:

Code:

        object:RegisterEvent("UNIT_SPELLCAST_SENT", UNIT_SPELLCAST_SENT)
        -- or --
        object:UnregisterEvent("UNIT_SPELLCAST_SENT", UNIT_SPELLCAST_SENT)


Then I updated UNIT_SPELLCAST_START to calculate and store the latency:

Code:

        if (castbar.sentTime) then
                castbar.latency = GetTime() - castbar.sentTime
        else
                castbar.latency = 0
        end

And finally, I modified onUpdate to use the latency value:

Code:

        if self.SafeZone then
                local width = self:GetWidth() * self.latency / self.max
                if (width < 1) then width = 1 end
                self.SafeZone:SetWidth(width);
        end

This seems to be working for me but it's hardly extensively tested. Do with it as you will. :cool:

EDIT: I updated the code because I was getting errors some of the time when sentTime didn't get set. I'm not sure why this would happen so I just added a check around the latency calculation. Otherwise it worked fine for me while I played for a couple of hours.


All times are GMT -6. The time now is 03:52 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI