LunaUnitFrames

LunaUnitFrames

268k Downloads

DruidManaLib returns incorrect mana value when shapeshifted

Galawer opened this issue · 1 comments

commented

The returned value is the correct value minus the cost of shapeshifting, as if the shapeshift spell was cast twice.
After some poking around I’ve figured out what’s happening:

  1. You shapeshift.
  2. OnEvent() is triggered by the event UNIT_MANA. At this point you’re not yet shapeshifted, so the condition UnitPowerType(arg1) == 0 is true and curMana is set to UnitMana("player"), which is your current mana after shapeshifting, which is the correct value that should be returned.
  3. After that, OnEvent() is triggered again by PLAYER_AURAS_CHANGED. At this point you’re actually in a shapeshift form and inform is set to true, to indicate that your mana bar is no longer accessible. However, Subtract() is also called.
  4. The Subtract() function does a check whether or not Rune of Metamorphosis is up. If not, then it subtracts subtractMana, which is the mana cost of shapeshifting, from curMana and causes the bug.

This is easily fixed just by removing the Subtract() function, the subtractMana var and the GetShapeshiftCost() function, which it relies on, since they serve no purpose. The correct value of current mana after shapeshifting is already found without any guesswork by the remaining code.

I've looked thought some older reports of this issue and you've closed them, saying you couldn't reproduce the bug on an instant 60 server. That's because the GetShapeshiftCost() function is dependent on having Bear Form in your spellbook. If you don't have Bear Form, which is possible since it's not taught by a trainer and instead requires a quest, subtractMana stays at 0 and the Subtract() function does nothing.

Tested on Kronos and Kronos PTR.

commented

Thank you for identifying the issue for me. I don't have the time to level a druid on every server, so i can't verify the functionality there.
It is however not a bug in "my" code. I stole most of it from the addon DruidBar. And since that addon is actually from the time 1.12.1 was on retail i believe it to be the way how it is supposed to be working. If you look through its code you will find the function that gets the shapeshift cost from the spellbook, making it clear that the shapeshift cost should only be substracted from your mana AFTER you switched into form. This is the case on both RetroWoW and Elysium.
Oh and "GetShapeshiftCost()" is working correctly because "Bear Form" and "Dire Bear Form" both share the same icon and thats the condition to detect the spell to get shapeshifting cost from (Bear & cat share the same cost).
So i suggest opening a ticket on the Kronos bugtracker.