1. #1

    [WA] Show lowest % party member?

    Hey,

    Is there a way to display the lowest %HP party member? I understand you can't click or interact with weakauras icons or bars but I'd just like a visual queue to show who is the lowest in my current party or raid. Seems like this should be doable?

    Cheers.

  2. #2
    Hello again,

    So I actually found an addon that does what I want but I'm wondering if there's a way to adapt the functionality of the addon as a WeakAuras script. I've been trying to adapt it on my own but unfortunately I'm not familiar enough with LUA. Obviously the particular frame it uses wouldn't be able to be adapted but a simple bar with text displaying the units name should be handled the same way, I think?

    Here's the addon code. Any help would be appreciated!

    Code:
    --Globals to locals to prevent errors that could occur when a function is edited.
    local GetNumGroupMembers = GetNumGroupMembers
    local RAID_CLASS_COLORS = RAID_CLASS_COLORS
    local UnitHealthMax = UnitHealthMax
    local CreateFrame = CreateFrame
    local UnitInRange = UnitInRange
    local UnitHealth = UnitHealth
    local UnitClass = UnitClass
    local IsInGroup = IsInGroup
    local UnitName = UnitName
    local IsInRaid = IsInRaid
    local GetTime = GetTime
    local unpack = unpack
    
    local function round( num )
    	return num >= 0 and math.floor( num + 0.5 ) or math.ceil( num - 0.5 )
    end
    
    local function HexToRGBA( I )
    	I = I:gsub( "#","" ):gsub( " ","" )
    	return { 
    		r = tonumber( I:sub( 1, 2 ), 16 ) / 255,
    		g = tonumber( I:sub( 3, 4 ), 16 ) / 255,
    		b = tonumber( I:sub( 5, 6 ), 16) / 255,
    		a = string.sub( I, 7, 8 ) ~= "" and tonumber( I:sub( 7 ,8 ), 16 ) / 255 or 1
    	}
    end
    
    local MouseDownColor = HexToRGBA( "ffa500" )
    local NoUnitColor = HexToRGBA( "aaaaaa" )
    
    local function Create_Addon( lui )
    	LowestUnitFrame = LowestUnitFrame or {}
    
    	lui:SetPoint( LowestUnitFrame.pos or "CENTER", LowestUnitFrame.x or 0, LowestUnitFrame.y or 0 )
    	lui:SetFrameLevel( 0 )
    	lui:SetWidth( 180 )
    	lui:SetHeight( 20 )
    	lui:SetMovable( true )
    	lui.alpha = 0 -- float for alpha channel
    	lui.fade = false -- int for fade
    
    	lui.lui_texture = lui:CreateTexture( nil, "HIGH" ) -- Texture frame
    	lui.lui_texture:SetTexture( 0, 0, 0, 0 )
    	lui.lui_texture:SetAllPoints( lui )
    	
    	lui.text = lui:CreateFontString( nil, "ARTWORK", "NumberFont_Shadow_Med" ) -- Text Frame
    	lui.text:SetAllPoints( true )
    	lui.text:SetJustifyH( "LEFT" )
    
    	lui:SetScript( "OnMouseDown", function( self, button )
    		if not self.isMoving then
    			self:StartMoving()
    			self.isMoving = true
    			self.alpha = 1
    			self.fade = false
    			self.lui_texture:SetTexture( MouseDownColor.r, MouseDownColor.g, MouseDownColor.b, MouseDownColor.a )
    		end
    	end )
    
    	lui:SetScript( "OnMouseUp", function( self, button )
    		if self.isMoving then
    			self:StopMovingOrSizing()
    			self.isMoving = false
    			self.fade = true
    			self.fadestart = GetTime()
    		end
    	end )
    
    	lui:SetScript( "OnUpdate", function( self, elapsed )
    	
    		if self.isMoving then
    			local pos, _, _, x, y = self:GetPoint()
    			LowestUnitFrame.pos = pos
    			LowestUnitFrame.x = round( x )
    			LowestUnitFrame.y = round( y )
    			self:SetPoint( LowestUnitFrame.pos, LowestUnitFrame.x, LowestUnitFrame.y )
    		end
    		
    		self.t = self.t and self.t + elapsed or elapsed
    		if self.t >= 0.1 then
    			self.t = 0 --reset timer
    			
    			local Unit = ( IsInRaid() and "RAID" ) or ( IsInGroup() and "PARTY" ) or false
    			local LowestUnit = "player"
    			local LowestHealth = UnitHealth( LowestUnit ) / UnitHealthMax( LowestUnit ) * 100
    
    			if Unit then
    				-- Get Lowest Unit
    				for i = 1, GetNumGroupMembers() do
    					local health = UnitHealth( Unit .. i ) / UnitHealthMax( Unit .. i ) * 100
    					if UnitInRange( Unit .. i ) and health < LowestHealth and health > 0 then
    						LowestHealth = health
    						LowestUnit = Unit .. i
    					end
    				end
    			end
    			
    			-- Edit frame with new info
    			if LowestHealth < 100 then
    				self.text:SetText( string.format( "%s %.2f%%", UnitName( LowestUnit ), LowestHealth ) )
    				local _, Class = UnitClass( LowestUnit )
    				local tbl = RAID_CLASS_COLORS[ Class ] -- This makes it ready for the future
    				self.text:SetTextColor( tbl.r or 0, tbl.g or 0, tbl.b or 0 ) -- nil check just in case
    			else
    				self.text:SetText( "Lowest Unit Frame" )
    				self.text:SetTextColor( NoUnitColor.r, NoUnitColor.g, NoUnitColor.b )
    			end
    		end
    
    		-- check if we need to fade the frame
    		if self.fade then
    			self.alpha = 1 - ( ( GetTime() - self.fadestart ) / 0.5 )
    			self.lui_texture:SetTexture( MouseDownColor.r, MouseDownColor.g, MouseDownColor.b, self.alpha > 0 and self.alpha or 0 )
    			if self.alpha < 0 then 
    				self.fade = false
    			end
    		end
    	end )
    end
    
    local LowestUnitInterface = CreateFrame( "Frame", UIParent ) -- Main frame
    LowestUnitInterface:RegisterEvent( "ADDON_LOADED" )
    LowestUnitInterface:SetScript( "OnEvent", function( self, _, name )
    	if name == "LowestUnitFrame" then -- Make sure it is this addon
    		self:SetScript( "OnEvent", nil ) -- remove event
    		self:UnregisterEvent( "ADDON_LOADED" )
    		Create_Addon( self ) -- continue
    	end
    end )
    mods.curse.com/addons/wow/lowestunitframe

  3. #3
    Quote Originally Posted by OsamaBinDrinkin View Post
    Hey,

    Is there a way to display the lowest %HP party member? I understand you can't click or interact with weakauras icons or bars but I'd just like a visual queue to show who is the lowest in my current party or raid. Seems like this should be doable?

    Cheers.
    Not sure on design or anything but this seems to work in party and raid. Hopefully if this is what you want. You can mess around with it and make it work more to your liking.


    Code:
    dmeZlaGij5sOkPrbKtbuRsOWSaPe3sO0UKu)cvPgMOQJHQAzIk9meLMMqvxtOY2ek6BikghivDoiL3bsrMNOKUhIyFGuPfcsH2iKQ8rrjgjIQtkkQvk1mffu3esLDkk0pbPIHcsjTuqk1tfYufrxfvXEf8xiv1GvhgIfdsr9yu0KHKlJ0MbLplQy0I0PLy1GuWRffy2iCBuy3a(nknCry5OYZbvthQRdITlkY3rKgVOuNhKSEuLy(IcY(Pd8djdrmcrOc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ggbllhiq8auWKtriWPGQ4qkOQ86AVaM38auWKtriWPOdjBqvCifuvEDTxadog8ZNhST7U7U7U7U7U7U7KMY6K4aimO2U7U7U7U7U7ofaLT7U7U7U7ofaL72U7U7Utbqz7U7U7UT7Utbqz7U72U7UT7UB7U7CumeoaN0uwVU2RCqvEDTtWskfo2RR9kELxbxztbqzBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBhIGc6adgCkoGEXLhn0id)4ilFOp344hxUKjal24jtiIJMtHfijujOHimnBCicHjUKjAsUso5q5qhlkAiJXYpFiQauWOptwgjiOykQqg5hIkOcrzywsPWXo0kLJjfahIqvGdnabGjUKjAicHGierAbfonGEXr2yMBUKnM5JjzINF855hZaSyJpUqu2qhyWGtXb0lMOHgzJNFCKbn(8HE(qpzjBawSXhFicacJKCLCYHYbpKr(HOuAjNuCa9IzCOHgz4ZNm5H(45tw0Il3aSyJhTqeeamxjNCOCHKHiMqGJzzeISHbbGjUWcacST7UxG5zgEMbYchlKeGa74ukGT7U7U7CumeoahgcbCQT7UtjGtTD3D3DNJIHWb4yoiuB3DNcGY2D3TPaOSTTTTTTTTTTTTTTTTd4qeblcQqYqegHGcGdjdrmGqGlHKbCahIqvGbRWecbgQqYqedie4sizahWHiowcAiziIbecCjKmGd4quImLaJqqbWHKHigqiWLqYaoGdrWqyIlSaHKHigqiWLqYaoGdrCimPHKHigqiWLqYaoGd4qeMRKtouUqYqegQe0qetiWXSmcrqaOzIcGdriqWSHiMqGJzzG(yOsqdrWXiyiWdrmHahZYiezddcatCHfaeyB3DVaZZm8mdKfowijab2XPuaB3D3D35OyiCaoMdc12D3PaOSPaOSTTTTTTTTTTTTdrqGtrFiafCaAmeXmLYmdcrqsGcbtd4aoebpeLBDU15whFiktHmYp(C5hWHa
    Last edited by Cyzen; 2016-12-31 at 02:31 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •