View Bug Report
Improved handling for ALTERNATE spell power
Bug #: 7834
File: MikScrollingBattleText
Date: 10-04-12 01:38 PM
By: cmtitan
Status: Unconfirmed
Alternate power is not handled very nicely by MSBT at the moment. Lots of power gains are not detected and if they are they are unknown. It seems not all changes are handed down the Blizzard API correctly, but most changes can be caught and handled nicely. Below a number of changes that will improve the way MSBT handles alternate power gains.

These were all tested while on the quest Hatred Becomes Us. There the alternate power is called Hatred and is affected by three things: just being there will slowly build Hatred, being inside the large or small, user-created safe area you quickly loose Hatred. The changes will correctly pick up the Hatred changes from all but the large safe area, which simply does not seem to trigger the events that even Blizz themselves listen for (but you're still in the area, which triggers the event and they just use the current value at each event, not the amount of change).

All changes below are in MSBTMain.lua unless otherwise noted. The changes were made in release 5.7.123



DON'T SHOW ALTERNATE POWER AS UNKNOWN
Alternate power has no correctly associated name with it - especially since it's always different. This change picks up the correct name.

Line 387 reads:

local powerString = _G[powerTokens[powerType] or "UNKNOWN"]

Change this to:

local powerString
if powerType == SPELL_POWER_ALTERNATE_POWER then
powerString = select( 10, UnitAlternatePowerInfo("PLAYER") )
else
powerString = _G[powerTokens[powerType] or "UNKNOWN"]
end



HANDLING NEGATIVE GAINS
The gains of alternate power can actually be negative, which means they show as "+-2 ..." by default. A bit strange. Two fixes are required for this.

Change line 362 from:

if (powerType == powerTypes["ECLIPSE"]) then formattedAmount = math_abs(amount) end

to:

if (powerType == powerTypes["ECLIPSE"]) or (powerType == SPELL_POWER_ALTERNATE_POWER) then formattedAmount = math_abs(amount) end

Line 964 reads:

local eventTypeString = eventTypePrefix .. (parserEvent.isDrain and "LOSS" or "GAIN")

This should become:

local eventTypeString
if parserEvent.isDrain then
eventTypeString = eventTypePrefix .. "LOSS"
else
eventTypeString = eventTypePrefix .. (amount > 0 and "GAIN" or "LOSS")
end



ALLOW THROTTLING OF ALTERNATE POWER CHANGES NO MATTER THEIR ORIGIN
Alternate power gains can come from different sources. Each source will be throttled on its own. Use these two changes to have those throttles combined.

Line 961 reads:

if (parserEvent.powerType == powerTypes["ALTERNATE_POWER"]) then eventTypePrefix = "NOTIFICATION_ALT_POWER_" end

Change this to:

local effectName = parserEvent.skillName
if (parserEvent.powerType == powerTypes["ALTERNATE_POWER"]) then
eventTypePrefix = "NOTIFICATION_ALT_POWER_"
effectName = select( 10, UnitAlternatePowerInfo("PLAYER") )
end

Change line 966 from:

return eventTypeString, parserEvent.skillName, nil, nil, true

to:

return eventTypeString, effectName, nil, nil, true



HANDLE ALL ALTERNATE POWER GAINS WHILE ALLOWING THROTTLING
Most power gains only trickle down via the UNIT_POWER event. This is also the event Blizz uses for their alternate power bar. To have the data from that event seep through one can add a special case in that event handler for alternate power. Since alternate power, contrary to the other cases, might need to be throttled, it should really pass through the ParserEventsHandler. So a fake ParserEvent is created and passed on. This also requires including the (erroneous?) power type "ALTERNATE" (instead of ALTERNATE_POWER) in MSBTTriggers' powerTypes array.

At line 1341, insert the special case for alternate power:

-- Handle alternate power uniquely.
elseif (powerToken == "ALTERNATE") or (powerToken == "ALTERNATE_POWER") then
if lastPowerAmount == nil then lastPowerAmount = 0 end
if (powerAmount ~= lastPowerAmount) then
local amount = powerAmount - lastPowerAmount
-- Build a fake parser event. This is done to let the parser handler handle the message, including throttling and all.
local parserEvent = {}
parserEvent.sourceUnit = "unknown"
parserEvent.recipientUnit = "player"
parserEvent.eventType = "power"
parserEvent.isGain = (amount > 0)
parserEvent.amount = math.abs(amount)
parserEvent.powerType = powerTypes["ALTERNATE_POWER"]
parserEvent.isLeech = false
ParserEventsHandler(parserEvent)
end

In MSBTTriggers.lua, line 877, include:

powerTypes["ALTERNATE"] = SPELL_POWER_ALTERNATE_POWER

RSS 2.0 Feed for Bug CommentsNotes Sort Options
By: Mikord - 10-06-12 07:51 PM
Thanks. I will apply this shortly.
\