DruidManaLib returns incorrect mana value when shapeshifted
Galawer opened this issue · 1 comments
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:
- You shapeshift.
OnEvent()
is triggered by the eventUNIT_MANA
. At this point you’re not yet shapeshifted, so the conditionUnitPowerType(arg1) == 0
is true andcurMana
is set toUnitMana("player")
, which is your current mana after shapeshifting, which is the correct value that should be returned.- After that,
OnEvent()
is triggered again byPLAYER_AURAS_CHANGED
. At this point you’re actually in a shapeshift form andinform
is set to true, to indicate that your mana bar is no longer accessible. However,Subtract()
is also called. - The
Subtract()
function does a check whether or not Rune of Metamorphosis is up. If not, then it subtractssubtractMana
, which is the mana cost of shapeshifting, fromcurMana
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.
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.