Thread Tools Display Modes
05-19-11, 02:52 PM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Shielded casts trick

I want to share sth I do to make non-interuptable castbars in different color based on the shield texture.

The Show() and Hide() functions of the shield get rewritten to recolor the castbar instead.

lua Code:
  1. --shield for uninterruptable casts
  2.     local s = self.Castbar
  3.     s.Shield = s:CreateTexture(nil,"BACKGROUND",nil,-8)
  4.     s.Shield:SetTexture(0,0,0,0) --make it invisible
  5.     --now replace the Show() and Hide() functions to make them work for us
  6.     s.Shield.Show = function(shield)
  7.       local bar = shield:GetParent()
  8.       bar:SetStatusBarColor(0.6,0.6,0.6,1) --we want to recolor the statusbar in case the shield pops up
  9.       bar.bg:SetVertexColor(0.2,0.2,0.2,0.7) --in case you have a background set
  10.     end
  11.     s.Shield.Hide = function(shield)
  12.       local bar = shield:GetParent()
  13.       bar:SetStatusBarColor(1,0.8,0,1) --back to normal
  14.       bar.bg:SetVertexColor(0.2,0.2,0,0.7) --in case you have a background set
  15.     end
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
05-19-11, 06:10 PM   #2
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
Hm, why not using castbar.interrupt like this:

lua Code:
  1. if (castbar.interrupt and UnitCanAttack("player", unit)) then
  2.     castbar:SetStatusBarColor(0.69, 0.31, 0.31)
  3.     castbar.IconOverlay:SetVertexColor(0.69, 0.31, 0.31)
  4. else
  5.     castbar:SetStatusBarColor(0.55, 0.57, 0.61)
  6.     castbar.IconOverlay:SetVertexColor(0.4, 0.4, 0.4)
  7. end

(castbar.IconOverlay is the icon border for the spell being cast)

I do this in PostCastStart, PostCastInterruptible, PostCastNotInterruptible and PostChannelStart. Btw castbar.interrupt means the cast is not interruptible.
  Reply With Quote
05-19-11, 08:46 PM   #3
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Code:
local PostCastStart = function(Castbar, unit, spell, spellrank)
	if Castbar.interrupt and UnitCanAttack("player", unit) then
-- if cast can't be interrupted, bright pink color
		Castbar:SetStatusBarColor(0.9, 0, 1.0, 0.6) -- cast bar color
		Castbar.IconGlow:SetBackdropColor(0.9, 0, 1.0, 0.6) -- spell icon border
	else
-- normal color (this is what I use to unpack my config color, can be simplified, ofc)
		local cbR, cbG, cbB = unpack(cfg.trdcolor)
		Castbar:SetStatusBarColor(cbR, cbG, cbB, 0.6)
		Castbar.IconGlow:SetBackdropColor(unpack(cfg.brdcolor))	
	end	
end
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
05-20-11, 01:54 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Haste does the check already in the castbar.lua and on conditions shows or hides the shield. Thus: No "PostCast" etc is needed. The only thing that speaks for the PostCast etc is the UnitCanAttack("player", unit) condition which is not done by haste.

So yeah maybe
lua Code:
  1. --check for interruptable spellcast
  2.   local checkShield = function(bar, unit, ...)
  3.     if bar.interrupt and UnitCanAttack("player", unit) then
  4.       bar:SetStatusBarColor(0.6,0.6,0.6,1)   --we want to recolor the statusbar in case the shield pops up
  5.       bar.bg:SetVertexColor(0.2,0.2,0.2,0.7) --in case you have a background set
  6.     else
  7.       bar:SetStatusBarColor(1,0.8,0,1)       --back to normal
  8.       bar.bg:SetVertexColor(0.2,0.2,0,0.7)   --in case you have a background set
  9.     end
  10.   end
  11.  
  12.   self.Castbar.PostCastStart = checkShield
  13.   self.Castbar.PostChannelStart = checkShield

is the best choice.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 05-20-11 at 02:10 AM.
  Reply With Quote
05-20-11, 07:20 AM   #5
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
You could also use PostCastStart and the like for some fancy boss-spells-that-should-be-interrupted-highlighting. This is my currently untested way of doing it if you are interested. I'll just have to figure out if I really need PostCastInterruptible and PostCastNotInterruptible as they don't get a spell name passed and the info whether a cast is interruptible is ready through UnitCastingInfo/UnitChannelInfo at UNIT_SPELLCAST_START/UNIT_SPELLCAST_CHANNEL_START. Or are there any spells that change interruptibility midcast?
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Shielded casts trick


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