WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   (un)interruptable cast (https://www.wowinterface.com/forums/showthread.php?t=30321)

alimjocox 01-28-10 10:22 PM

(un)interruptable cast
 
i was wondering if oUF had a command / function or whatever its called ( not much a of a programmer ) which allowed us to change the color of the casticon/castbar border whether its interruptable or not, i.e. the shield u see in the default UI frames. thx in advance :)

wurmfood 01-28-10 10:39 PM

Not directly. You can use a custom PostCastStart/PostChannelStart function to identify if the spell is interruptible and change the display of the castbar based on that. You should also track the UNIT_SPELLCAST_INTERRUPTABLE/UNIT_SPELLCAST_NOT_INTERRUPTABLE events in case the interrupt-ability of the spell changes during cast (e.g. during the Twin Valkyrs).

To add to this, here's how I'm doing it (in my non-updated version):

Code:

local postCastStart = function(self, event, unit, name, rank, text, castid, interrupt)
        if( interrupt ) then
                self.Castbar.bg:Hide()
                self.Castbar.Shield:Show()
        else
                self.Castbar.bg:Show()
                self.Castbar.Shield:Hide()
        end
end

local spellInterruptable = function(self, event, unitID)
        if( self.unit == unitID ) then
                if( event == 'UNIT_SPELLCAST_NOT_INTERRUPTABLE' ) then
                        self.Castbar.bg:Hide()
                        self.Castbar.Shield:Show()
                else
                        self.Castbar.bg:Show()
                        self.Castbar.Shield:Hide()
                end
        end
end

and in the layout function:

Code:

self:RegisterEvent('UNIT_SPELLCAST_NOT_INTERRUPTABLE', spellInterruptable)
self:RegisterEvent('UNIT_SPELLCAST_INTERRUPTABLE', spellInterruptable)


yj589794 01-29-10 05:26 AM

self.Castbar.Shield is not a standard item, you will need to define this texture yourself.

alimjocox 01-30-10 06:15 AM

Quote:

Originally Posted by wurmfood (Post 176560)
Code:

local postCastStart = function(self, event, unit, name, rank, text, castid, interrupt)
        if( interrupt ) then
                self.Castbar.bg:Hide()
                self.Castbar.Shield:Show()
        else
                self.Castbar.bg:Show()
                self.Castbar.Shield:Hide()
        end
end

local spellInterruptable = function(self, event, unitID)
        if( self.unit == unitID ) then
                if( event == 'UNIT_SPELLCAST_NOT_INTERRUPTABLE' ) then
                        self.Castbar.bg:Hide()
                        self.Castbar.Shield:Show()
                else
                        self.Castbar.bg:Show()
                        self.Castbar.Shield:Hide()
                end
        end
end


hey wurm thx for the reply i was just wondering if

local postCastStart = function(self, event, unit, name, rank, text, castid, interrupt)
if( interrupt ) then
self.Castbar.bg:Hide()
self.Castbar.Shield:Show()
else
self.Castbar.bg:Show()
self.Castbar.Shield:Hide()
end
end

is at all necessary?

wurmfood 01-30-10 02:52 PM

The bg part isn't, really. However, you do need something to show or hide a texture that indicates if the spell can be interrupted or not. The event stuff only triggers if the spell becomes interruptible/not during the cast. Otherwise they don't trigger.

Dawn 01-30-10 04:05 PM

Is there a place/way to test such code? Without a raid/group, if possible.

wurmfood 01-30-10 04:12 PM

The cast option changing? Not that I know of, and I've tried to find one.

v6o 01-30-10 05:00 PM

Quote:

Originally Posted by Dawn (Post 176719)
Is there a place/way to test such code? Without a raid/group, if possible.

Do you mean the events OR just interruptable and non-interruptable casts?

If the latter, you can just target yourself and use your mount or hearthstone.

Dawn 01-31-10 03:25 AM

I meant to find a cast that is un-interruptable, to be able to test the appearance of the texture I want to show for an un-interruptable cast. And to be able see if it works, ofc. :)

Are heartstone and mount really considered non-interruptable? Afaik, you just need to get hit and it's interrupted ... :rolleyes:

wurmfood 01-31-10 05:10 AM

Ah, sorry, I thought you meant casts that changed state. For the non-interrupt casts, various npcs and group quest bosses have casts that cannot be interrupted.

The easiest examples I know of offhand, though, are all dungeon bosses (black knight, Loken, Anub'arak...).

edit: Looks like transmutes are protected. At least, saronite to titanium is.

v6o 01-31-10 06:00 AM

Quote:

Originally Posted by Dawn (Post 176774)
Are heartstone and mount really considered non-interruptable? Afaik, you just need to get hit and it's interrupted ... :rolleyes:

They are believe it or not. They probably just have their own scripted event.

Dawn 01-31-10 06:17 AM

Thanks, after all random heroic, ftw. The final boss from Ahn'kahet casts "Insanity", which worked fine. :)

However, heartstone keeps telling me it can be interrupted. Which means it's not a question of whether I believe it or not, it just won't show up that way. I don't care, though. ;)

sacrife 08-21-10 01:11 PM

I did not have a postCastStart in my layout and failed to create one so I tried to just manually listen for the event in the castbar code. Nothing happens though :p

Any ideas?

Code:

        ------------- target castbar -----------
                elseif ( unit == 'target' ) then
                        self.Castbar:RegisterEvent('UNIT_SPELLCAST_NOT_INTERRUPTABLE')
                        self.Castbar:RegisterEvent('UNIT_SPELLCAST_INTERRUPTABLE')
                        self.Castbar:SetScript('OnEvent', function(self, event, name)
                                if (event == 'UNIT_SPELLCAST_INTERRUPTABLE') then
                                        self.Castbar.Text:SetTextColor(1,0,1)
                                        print("INTERRUPT")
                                end
                        end)
                       
                        self.Castbar.Text:SetWidth(275)
                        self.Castbar.Time = self.Castbar:CreateFontString(nil, 'OVERLAY')               
                        self.Castbar.Time:SetFontObject(SystemFont_Tiny)               
                        self.Castbar.CustomTimeText = function(self, duration)
                                if self.casting then
                                        self.Time:SetFormattedText("%.1f", self.max - duration)
                                elseif self.channeling then
                                        self.Time:SetFormattedText("%.1f", duration)
                                end
                        end

                                self.Castbar:SetToplevel(true)
                                self.Castbar:SetStatusBarColor(1, 1, 1, 0.4)
                                self.Castbar:SetWidth(sett1ngs.mX)
                                self.Castbar:SetHeight(sett1ngs.mhp)
                                self.Castbar:SetParent(self.Health)
                                self.Castbar:SetPoint("TOPLEFT",'oUF_target',"TOPLEFT",0,0)

                                self.Castbar.Spark = self.Castbar:CreateTexture(nil, 'OVERLAY')
                                self.Castbar.Spark:SetHeight(sett1ngs.mhp+sett1ngs.mpower+28)
                                self.Castbar.Spark:SetWidth(10)
                                self.Castbar.Spark:SetBlendMode('ADD')

                                self.Castbar.Text:SetPoint("TOP", self.Castbar, "TOP", 0, 0.5)
                                self.Castbar.Text:SetJustifyH"CENTER"
                                --self.Castbar.Text:SetTextColor(1,1,1)
                               
                                self.Castbar.Time:SetPoint("CENTER", self.Castbar, "CENTER", 0, -3)
                                --self.Castbar.Time:SetTextColor(1,1,1)
                               
                                self.Castbar:SetFrameStrata("HIGH")
                               
                                self.Castbar.Button = CreateFrame('Frame', nil, self.Castbar)
                                self.Castbar.Button:SetHeight(sett1ngs.cbplayerH-3)
                                self.Castbar.Button:SetWidth(sett1ngs.cbplayerH-3)
                                self.Castbar.Button:SetBackdrop(backdrop)
                                self.Castbar.Button:SetBackdropColor(0, 0, 0)
                                self.Castbar.Button:SetPoint('RIGHT', self.Castbar, 'LEFT', -3, -1)
                                self.Castbar.Button.bd = SetBD(self.Castbar.Button, backdrop, sett1ngs.bcolor)
                                self.Castbar.bd = SetBD(self.Castbar, backdrop, sett1ngs.bcolor)

                                self.Castbar.Icon = self.Castbar.Button:CreateTexture(nil, 'ARTWORK')
                                self.Castbar.Icon:SetAllPoints(self.Castbar.Button)
                                self.Castbar.Icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)


v6o 08-21-10 07:33 PM

You will need to add PostCastStart.

Quote:

Originally Posted by wurmfood (Post 176713)
The event stuff only triggers if the spell becomes interruptible/not during the cast. Otherwise they don't trigger.


haste 08-22-10 04:58 AM

oUF already has castbar:PostCastInterruptible(unit) and castbar:PostCastNotInterruptible(unit).

v6o 08-22-10 05:27 AM

Quote:

Originally Posted by haste (Post 203361)
oUF already has castbar:PostCastInterruptible(unit) and castbar:PostCastNotInterruptible(unit).

Why look at that. I take it registering the events is unnecessary as well then?

haste 08-22-10 05:41 AM

Quote:

Originally Posted by v6o (Post 203368)
Why look at that. I take it registering the events is unnecessary as well then?

Yep

The forum thinks my message is too short, so I present you the content of my selection clipboard: http://www.youtube.com/watch?v=xE9_3QjSE08&fmt=18

sacrife 08-22-10 04:30 PM

I tried adding this under within the above posted code.
Got a nil value error for it. What did I do wrong?

Code:

                if self.Castbar:PostCastNotInterruptible(unit) then
                        self.Castbar.Text:SetTextColor(1,0,0)
                        self.Castbar.Time:SetTextColor(1,0,0)
                else
                        self.Castbar.Text:SetTextColor(1,1,1)
                        self.Castbar.Time:SetTextColor(1,1,1)
                end


v6o 08-22-10 06:22 PM

I had a chance to look over 1.4. And please correct me if I'm wrong Haste (or someone else that know)

If all you want to do is show a frame (texture, text or whatever) then you can just define it as Castbar.Shield and it should show and hide automatically.

If you want to do something else, for example the code you posted sacrifice, then you will need to do the following.


Outside style function
Code:

local CastInterruptable = function(self, unit)
  -- Do your thing here
end
local CastNonInterruptable = function(self, unit)
  -- Do your thing here
end
local PostCastStart = function(self, unit, name, rank, castid)
  if self.interrupt then
    CastNonInterruptable(self, unit)
  else
    CastInterruptable(self, unit)
  end
end

Inside style function
Code:

Castbar.PostCastStart = PostCastStart
Castbar.PostCastInterruptible = CastInterruptable
Castbar.PostCastNotInterruptible = CastNonInterruptable


haste 08-23-10 10:33 AM

That looks very much correct.


All times are GMT -6. The time now is 04:53 AM.

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