Quantcast
Warrior stance on unit frame - WoWInterface
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
03-08-21, 05:56 AM   #1
jegarn123
A Defias Bandit
Join Date: Mar 2021
Posts: 2
Warrior stance on unit frame

Hello all!

Wow CLASSIC lua question:

I've been looking quite some time for an addon that shows the warrior stance on the unit frame.
After alot of searching, I came across this Lua code:

local _, class = UnitClass("player")
if class ~= "WARRIOR" then return end

local stance = {
2457, -- Battle Stance
71, -- Defensive Stance
2458 -- Berserker Stance
}

for id = 1, #stance do
local _, _, icon = GetSpellInfo(stance[id])
stance[id] = icon
end

-- Override Blizzard's code
PlayerFrame:UnregisterEvent("UNIT_PORTRAIT_UPDATE")
PlayerFrame.portrait = nil

local function UpdatePlayerPortrait()
local icon = stance[GetShapeshiftForm()]
if icon then
SetPortraitToTexture("PlayerPortrait", icon)
end
end

local frame = CreateFrame("Frame", PlayerFrame)
frame:SetScript("OnEvent", UpdatePlayerPortrait)
frame:RegisterUnitEvent("UPDATE_SHAPESHIFT_FORM")

SetPortraitToTexture("PlayerPortrait", stance[1])
UpdatePlayerPortrait()




-----------------------------------------------------------------------------------

I have no idea what I'm doing with Lua codes, but I somehow managed to convert it to an addon, and it did infact work.
Only problem I only want this to show in combat. When I'm out of combat I want my character portrait to show, just like normal. Probably a quick and easy fix, but I have no idea

Can someone experienced please help out?

Regards!
  Reply With Quote
 

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Warrior stance on unit frame

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