[SOLVED] Miirkat Druid Portraits

Hello and good evening / morning. I have an issue which I cannot resolve myself. This has to do with the addon/script which is posted below.
It is taken from Miirkat Druid Portraits .

What the addon does exactly is that it shows class portraits on the target, focus and player portraits but for druids it will replace it in the case of say, bear form it would show the druid bear form icon instead of the normal druid paw. The same is done for cat, flight, swift flight, moonkin, travel and aquatic.

This worked in MoP and almost 99% sure it worked in WoD, however I am not sure when it broke for me, I am assuming sometime during legion or bfa.

I have looked through the API they have listed and I cannot see that anything has changed or maybe I missed it. I used some old sites in hopes of finding someone had updated it or fixed the problem.

I thought that maybe because “DRUID” is used on NA and “Druid” is used on EU that might have been an issue but neither seem to work.

So, I have come to you lovely people, the forum wizards. If anyone would be so kind to get this working again for 8.2 I would be very thankful. However, if you’re able to fix it would you please tell me how and explain why it broke in the first place so I can gain the knowledge or a little bit of insight in how to fix it myself at a later stage?

I have tried using UnitAura instead with “cat form” but that did not seem to work either in the test I did.

Apologies about the formatting, not sure how to do it with code so I did a box instead.

UFP = “UnitFramePortrait_Update”
UICC = “Interface\TargetingFrame\UI-Classes-Circles”
CIT = CLASS_ICON_TCOORDS
hooksecurefunc(UFP, function(self)
if self.portrait then
if select(2,UnitClass(self.unit)) == “DRUID” then
local i, flag=1, false
while UnitBuff(self.unit, i) do
local id = select(11,UnitBuff(self.unit, i))
–cat 768
–bear 5487
–travel 783
–aquatic 1446
–flight 165962
–swift flight 40123
–boomkin 24858
if id == 768 or id == 5487 or id == 783 or id == 1446 or id == 165962 or id == 40123 or id == 24858 then
SetPortraitToTexture(self.portrait, GetSpellTexture(id));
self.portrait:SetTexCoord(0, 1, 0, 1)
flag = true
end
i = i + 1
end
if not flag then
self.portrait:SetTexture(UICC)
self.portrait:SetTexCoord(unpack(CIT.DRUID))
end
else
local t = CIT[select(2,UnitClass(self.unit))]
if t then self.portrait:SetTexture(UICC)
self.portrait:SetTexCoord(unpack(t))
end
end
end
end)

Thanks in advance,
Aikonah

EDIT:
I am trying the AuraUtil but am not entirely sure how to use it. I tried this

      while AuraUtil.FindAuraByName(self.unit, i) do
         local id = select(11,AuraUtil.FindAuraByName(self.unit, i))
	--cat 768
	--bear 5487
	--travel 783
	--aquatic 1446
	--flight 165962
	--swift flight 40123
	--boomkin 24858
	--tree 33891
         if id == Cat Form or id == Bear Form or id == Travel Form or id == Aquatic Form or id == Flight Form or id == Swift Flight Form or id == Moonkin Form or id == Incarnation: Tree of Life then
           SetPortraitToTexture(self.portrait, GetSpellTexture(id));

This however does not work and the portaits don’t display.

Should it be used like this instead:

AuraUtil.FindAuraByName==(i) do

and then the rest of the script?

EDIT2:
Did some more searching, I see that it’s mentioned that you can no longer query id. Do correct me if I am wrong but I would then need to make 3 parts to this for it to work and use I suppose, onUpdate so it always runs through looking for buffs. 1st part playerframe, 2nd for target and 3rd for focus.

I would then need to use i = AuraUtil.FindAuraByName(cat form, player) etc correct, multiple of them to find the form buff? Afterwards I would use a function that calls whatever form it finds and uses a function to replace the portrait icon with the form icon, if nothing is found then use class portrait.

Hi

took me a minute to find this addon. It’s old. :grin:

Formatting can be done in multiple ways.

Inline formatting is done by enclosing the text in ` (grave accent) like `yourCode`. Alternatively use [code]yourCode[/code]

Block formatting is done by adding four spaces before each line. Alternatively use

[code]
function()
  return;
end
[/code]

Now to fixing the addon

When BfA was released, some functions got changed so that they might not return the same information as before or in a different order, take different arguments and so on. If you are interested, you can find more about that in Battle for Azeroth Addon Changes.

The addon uses the function UnitBuff() in line 15:

local id = select(11,UnitBuff(self.unit, i))

UnitBuff() dropped its second return parameter so that select() in the line above no longer returns the needed spellId. To get the spellId the first argument of select() needs to be changed to 10.

Though it works for Travel, Bear, Cat, Moonkin and Tree of Life forms, it doesn’t work for Flight forms. They are both still Travel Form.

You would need to add following code after line 19 to show an icon for Flight Form.

local _, _, flightSpeed = GetUnitSpeed(self.unit)
if id == 783 and flightSpeed > 10 then
    id = 40120
end

If the druid has Travel Form and has a high flight speed they should be flying. :sweat_smile:

Regarding your own solution (long read)
AuraUtil.FindAuraByName(self.unit, i)

The function call above will not work because AuraUtil.FindAuraByName() takes three arguments: auraName, unit and filter. The last one is optional. You are missing the first one auraName and i is an index variable which is useless in this case. A correct function call:

AuraUtil.FindAuraByName("Cat Form", "player")

Your second edit goes into the right direction, but still has some issues. I don’t know how much knowledge you have in programming or Lua/WoW API. Every time the UnitFramePortrait is updated, the addon checks if the unit, which frame was updated, is a druid. If so, it will iterate over all auras of the druid and look if any of them corresponds to shape shifting.

This is done through the implementation of the while loop:

while UnitBuff(self.unit, i) do

This reads as while buff of unit at position i is not nil do. This works because i is increasing and at some point UnitBuff() will return nothing (nil) and end the loop. In the loop the addon checks if one of the unit auras is a druid form.

AuraUtil.FindAuraByName(spellName, unitId) doesn’t work with this implementation since it can’t be used to iterate over all unit auras. It rather gives you information of a specific aura by name.

You would need to throw away the while loop and work with if statements. And rather than copying the if statements you would put the druid forms in a table and use a for loop.

local druidForms = {
    [768]="Cat Form",
    [783]="Travel Form",
    [1066]="Aquatic Form",
    [5487]="Bear Form",
    [24858]="Moonkin Form",
    [33891]="Incarnation: Tree of Life",
    [33943]="Flight Form",
    [40120]="Swift Flight Form"
}
for _, druidForm in pairs(druidForms) do
    local spellId = select(10, AuraUtil.FindAuraByName(druidForm, self.unit))
    if spellId then
        SetPortraitToTexture(self.portrait, GetSpellTexture(spellId))
        self.portrait:SetTexCoord(0, 1, 0, 1)
        flag = true
    end
end

Regards

1 Like

Greetings Amarabael!

Thanks for such a quick response about my question and how to go about it. Much appreciated!

First off, thanks for the formatting help of how to lay it out on the forums, will be a life saver!

Secondly, a big up to you for helping with the addon/script. I am flabbergasted at how simple the fix for it was. I tried all sorts of things before coming to the forum for help and now I want to kick myself. Screaming internally.

Thirdly, belonging to the post itself and my issue I had. This is perfect. I had a look through the changes post you suggested, interesting. That’s great so it would have broken in BFA.

My lua/api knowledge is quite low, basic level scripts to simply resize, change and manipulate the UI and also to display some aura’s when I have certain buffs or conditions are met.

Those I do not think can really be compared to a functioning addon per say. The aura had extensive explaining about how it worked and why.

Thanks for explaining the suggestion in more detail. I understand a bit better how I would make use of the AuraUtil now. If it breaks in the future I feel as though I will be able to fix it myself now.

Have a great day / night!

Thanks,
Aikonah

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.