View Single Post
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