WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Destro Lock Soul Shard tracking in 7.2.5 (https://www.wowinterface.com/forums/showthread.php?t=55624)

Galaxy119 08-05-17 06:08 AM

Destro Lock Soul Shard tracking in 7.2.5
 
So I just NOW realized the changes to destro locks kinda broke my ouf module for soul shard display for Roth UI, is doesn't show partially filled shards, they are only ever empty or full. This is annoying.

Now that i am aware of the problem, I look back to see how zork handled burning embers, and it was relatively straightforward, however, it relied on an api call for "MAX_POWER_PER_EMBER" but an equivalent for shards doesn't seem to exist, and i can't find any actual documentation of changes to the api in patch 7.2.5

If someone would be able to assist with either helping me check for partially filled shards, or point me to something that shows the diffs between 7.2 and 7.2.5 api's that'd be great.

lightspark 08-05-17 08:09 AM

To get number of fragments per shard, a.k.a. modifier, you need to use this:
Lua Code:
  1. local mod = UnitPowerDisplayMod(7)

Here's a quote of my post from another thread regarding UnitPower and its return.

Quote:

Originally Posted by lightspark (Post 324147)
Use UnitPower's 3 arg to get unmodified values.

Lua Code:
  1. local mod = UnitPowerDisplayMod(8) -- returns 10
  2. local cur_mod = UnitPower("player", 8) -- let's say it returns 15
  3. local cur_unmod = UnitPower("player", 8, true) -- will return 150

You can divide unmodified value by modifier later, when you need to do so.

Just replace 8s w/ 7s or Enum.PowerType.SoulShards.

Everything else is simple maths.

Galaxy119 08-05-17 07:22 PM

Thank you very much!

Galaxy119 08-07-17 08:57 AM

I've been trying to implement this and I've had great success making the addon determine when there is an extra "half shard" ontop of the shards held (IE a shard is being made but not completed yet)

However, I'm hitting a wall when it comes to implementing it into a usable form.

What I WANT it to do, when a shard is full, the shard icon will be purple, if it is being created, it will be green. However the closest I can get is full shards are purple, and when a shard is being created, it turns all the empty slots green, instead of just the next shard slot.

Here's my code;
Lua Code:
  1. if select(2, UnitClass("player")) ~= "WARLOCK" then return end
  2.  
  3. local parent, ns = ...
  4. local oUF = ns.oUF or oUF
  5.  
  6.  
  7.  
  8. local SPELL_POWER_SOUL_SHARDS     = SPELL_POWER_SOUL_SHARDS
  9.  
  10.  
  11. local Update = function(self, event, unit, powerType)
  12.   local bar = self.SoulShardPowerBar
  13.   local mod = UnitPowerDisplayMod(7)
  14.   local cur_unmod = UnitPower("player", 7, true)
  15.   local max_unmod = UnitPowerMax("player", 7, true)
  16.   local cur = UnitPower("player", 7)
  17.   local max = UnitPowerMax("player", 7)
  18.   --adjust the width of the soulshard power frame
  19.   local w = 64*(max+1)
  20.   bar:SetWidth(w)
  21.   for i = 1, bar.maxOrbs do
  22.     local orb = self.SoulShards[i]
  23.     if i > max then
  24.        if orb:IsShown() then orb:Hide() end
  25.     else
  26.       if not orb:IsShown() then orb:Show() end
  27.     end
  28.   end
  29.     for i = 1, bar.maxOrbs do
  30.         local orb = self.SoulShards[i]
  31.         local orb2 = self.SoulShards[i+1]
  32.         local full = cur/max
  33.         if(i <= cur) then
  34.             if full == 1 then
  35.                 orb.fill:SetVertexColor(1,0,0)
  36.                 orb.glow:SetVertexColor(1,0,0)
  37.             else
  38.                 orb.fill:SetVertexColor(bar.color.r,bar.color.g,bar.color.b)
  39.                 orb.glow:SetVertexColor(bar.color.r,bar.color.g,bar.color.b)
  40.             end
  41.             orb.fill:Show()
  42.             orb.glow:Show()
  43.             orb.highlight:Show()
  44.         else
  45.             orb.fill:Hide()
  46.             orb.glow:Hide()
  47.             orb.highlight:Hide()
  48.         end
  49.         if(i > cur) then
  50.             local orb = self.SoulShards[i]
  51.             if cur_unmod/mod > cur then
  52.                 orb.fill:SetVertexColor(0,1,0)
  53.                 orb.glow:SetVertexColor(0,1,0)
  54.                 orb.fill:Show()
  55.                 orb.glow:Show()
  56.                 orb.highlight:Show()
  57.             end
  58.         end
  59.     end
  60. end
  61.  
  62. local Visibility = function(self, event, unit)
  63.   local element = self.SoulShards
  64.   local bar = self.SoulShardPowerBar
  65.   if UnitHasVehicleUI("player")
  66.     or ((HasVehicleActionBar() and UnitVehicleSkin("player") and UnitVehicleSkin("player") ~= "")
  67.     or (HasOverrideActionBar() and GetOverrideBarSkin() and GetOverrideBarSkin() ~= ""))
  68.   then
  69.     bar:Hide()
  70.   elseif(select(2, UnitClass("player")) == "WARLOCK") then
  71.     bar:Show()
  72.     element.ForceUpdate(element)
  73.   else
  74.     bar:Hide()
  75.   end
  76. end
  77.  
  78. local Path = function(self, ...)
  79.   return (self.SoulShards.Override or Update) (self, ...)
  80. end
  81.  
  82. local ForceUpdate = function(element)
  83.   return Path(element.__owner, "ForceUpdate", element.__owner.unit, "SOUL_SHARDS")
  84. end
  85.  
  86. local function Enable(self, unit)
  87.   local element = self.SoulShards
  88.   if(element and unit == "player") then
  89.     element.__owner = self
  90.     element.ForceUpdate = ForceUpdate
  91.  
  92.     self:RegisterEvent("UNIT_POWER_FREQUENT", Path)
  93.     self:RegisterEvent("UNIT_DISPLAYPOWER", Path)
  94.     self:RegisterEvent("PLAYER_TALENT_UPDATE", Visibility, true)
  95.     self:RegisterEvent("SPELLS_CHANGED", Visibility, true)
  96.     self:RegisterEvent("UPDATE_OVERRIDE_ACTIONBAR", Visibility, true)
  97.     self:RegisterEvent("UNIT_ENTERED_VEHICLE", Visibility)
  98.     self:RegisterEvent("UNIT_EXITED_VEHICLE", Visibility)
  99.  
  100.     local helper = CreateFrame("Frame") --this is needed...adding player_login to the visivility events does not do anything
  101.     helper:RegisterEvent("PLAYER_LOGIN")
  102.     helper:SetScript("OnEvent", function() Visibility(self) end)
  103.  
  104.     return true
  105.   end
  106. end
  107.  
  108. local function Disable(self)
  109.   local element = self.SoulShards
  110.   if(element) then
  111.     self:UnregisterEvent("UNIT_POWER_FREQUENT", Path)
  112.     self:UnregisterEvent("UNIT_DISPLAYPOWER", Path)
  113.     self:UnregisterEvent("PLAYER_TALENT_UPDATE", Visibility)
  114.     self:UnregisterEvent("SPELLS_CHANGED", Visibility)
  115.     self:UnregisterEvent("UPDATE_OVERRIDE_ACTIONBAR", Visibility)
  116.     self:UnregisterEvent("UNIT_ENTERED_VEHICLE", Visibility)
  117.     self:UnregisterEvent("UNIT_EXITED_VEHICLE", Visibility)
  118.   end
  119. end
  120.  
  121. oUF:AddElement("SoulShards", Path, Enable, Disable)

The important part is
Lua Code:
  1. for i = 1, bar.maxOrbs do
  2.         local orb = self.SoulShards[i]
  3.         local orb2 = self.SoulShards[i+1]
  4.         local full = cur/max
  5.         if(i <= cur) then
  6.             if full == 1 then
  7.                 orb.fill:SetVertexColor(1,0,0)
  8.                 orb.glow:SetVertexColor(1,0,0)
  9.             else
  10.                 orb.fill:SetVertexColor(bar.color.r,bar.color.g,bar.color.b)
  11.                 orb.glow:SetVertexColor(bar.color.r,bar.color.g,bar.color.b)
  12.             end
  13.             orb.fill:Show()
  14.             orb.glow:Show()
  15.             orb.highlight:Show()
  16.         else
  17.             orb.fill:Hide()
  18.             orb.glow:Hide()
  19.             orb.highlight:Hide()
  20.         end
  21.         if(i > cur) then
  22.             if cur_unmod/mod > cur then
  23.                 orb.fill:SetVertexColor(0,1,0)
  24.                 orb.glow:SetVertexColor(0,1,0)
  25.                 orb.fill:Show()
  26.                 orb.glow:Show()
  27.                 orb.highlight:Show()
  28.             end
  29.         end
  30.     end
  31. end

I don't know how to make the second if function ( if(i > cur) then ) select the NEXT shard icon only.

The local "orb2" was an attempt at having it select the next shard when it fills the previous, however when I change the second if condition's "orb.fill" with "orb2.fill" it gives me an error saying it's a nil value.
It's been awhile since i've done coding and I just can't figure this one out.
Probably doesn't help I haven't slept in 26hrs ><

lightspark 08-07-17 11:44 AM

You're clearly using oUF, why don't you use default element? It supports all types of class powers :p

Also, not being able to see how full is one's shard is kinda bad.

p3lim 08-07-17 12:07 PM

As lightspark suggested, use the ClassPower element and add this PostUpdate callback:
Lua Code:
  1. local function PostUpdateClassPower(element, cur, max, hasMaxChanged, powerType)
  2.     if(powerType == 'SOUL_SHARDS') then
  3.         for i = 1, max do
  4.             if(i <= cur) then
  5.                 -- purple
  6.             else
  7.                 -- green
  8.             end
  9.         end
  10.     end
  11. end


All times are GMT -6. The time now is 07:18 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI