Thread: UnitPowerAlt
View Single Post
02-20-11, 03:32 PM   #17
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Originally Posted by Rainrider View Post
I did some testing on Zombies vs Plants and thats what I got

All the altPower infos are reported for player and not for vehicle
/run print(UnitAlternatePowerInfo("player")) -- returns the normal bunch of values
/run print(UnitPower("player", ALTERNATE_POWER_INDEX)) -- returns 0
/run print(UnitPowerMax("player", ALTERNATE_POWER_INDEX)) -- returns 4

The three above return nothing, 0, 0 respectevely when I use vehicle as unit.

Thus in oUF/elements/altpowerbar.lua Toggler would be called when unit == "vehicle" and self.unit == "vehicle" and will fail as UnitPowerMax(unit, ALTERNATE_POWER_INDEX) would return 0. UpdatePower fails then because powerType for unit vehicle is always ENERGY.

I then commented out in Toggler
Code:
if(unit ~= self.unit) then return end
and changed in UpdatePower
Code:
if(self.unit ~= unit or powerType ~= 'ALTERNATE') then return end
to
Code:
if(powerType ~= 'ALTERNATE') then return end
Toggler calls then UpdatePower on every UNIT_POWER for all units (initially failing to show the altpowerbar as min and max are both 0 because at UNIT_POWER_BAR_SHOW it gets unit == "pet" and unit == "vehicle"). After some zombies die, the altpowerbar changes to 25% for unit == "player" and self.unit == "vehicle". It fails again to show the bar because of
Code:
local cur = UnitPower(unit, ALTERNATE_POWER_INDEX)
local max = UnitPowerMax(self.unit, ALTERNATE_POWER_INDEX)
in UpdatePower. Changing this to local max = UnitPowerMax(unit, ALTERNATE_POWER_INDEX) updates and shows the powerbar.

I hope this helps somehow.
Thanks for further investigation. Someone should open a ticket over at github. *cough*
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote