Thread Tools Display Modes
12-27-06, 08:01 PM   #1
SynchroPriest
A Murloc Raider
Join Date: Dec 2006
Posts: 5
Custom Lifebars

Also posted over at http://forums.worldofwar.net/showthread.php?t=383711

Hi. I am brand new to Lua and am just barely past the HelloWorld stage for WoW mods. But I have an extensive software development background (including UI work with MFC and Swing), am familiar with many scripting languages, and am completely comfortable working with XML, DOM, etc. So I don't imagine this will be too terribly difficult for me to pick up. But I could use a push in the right direction, especially in terms of vocabulary.

I want to create a custom set of lifebars. Let's say I'm in a raid and I want to create a panel (Frame?) that contains only 3 of my friends' lifebars so I can heal only them (no, I'm not looking to be a selfish healer, but I figure a contrived example will better put me on the right path). I want only these 3 raid members' life bars grouped together in the same panel, regardless of the fact that they are actually spread out across different parties.

In practice, will this be a difficult thing to write? Does the WoW client already provide a set of UI components I can reuse (such as when you shift-drag a single member's lifebar off of the raid tab). Or will I have to write my own components from scratch (create a frame, create individual "portrait" components on the frame, create a "lifebar" component and buff/debuff components to fit inside the "portrait", etc).

I think part of my problem really is not knowing the correct terminology. I lookup "lifebars", but of course, this isn't a technically relevant term. What might be the correct terms for me to study?

I'm familiar with CTRaid and similar mods and I suppose I could start scouring their source for examples. But if I can start with a simpler example and avoid having to sift through someone else's forest of code to find a single tree, I would prefer to try that route.

Thanks in advance for your help!
  Reply With Quote
12-27-06, 09:16 PM   #2
tattooedpierre
An Aku'mai Servant
 
tattooedpierre's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 38
I honestly can't begin to help you with specific code for your scenario; as I too have just started with Lua. I can only suggest something like ag_UnitFrames (http://wowace.com/files/) as a starting point to see how 'they' do it. For ag, I know it's Ace2 based which will introduce some libraries perhaps not technically necessary (I understand this mod does slightly more than just customises the lifebars), however, I hope it can help you too.
  Reply With Quote
12-27-06, 09:58 PM   #3
JoshBorke
A Chromatic Dragonspawn
 
JoshBorke's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 185
so 'lifebars' can be complicated in wow 2.0

you'll need to associate units with the frames and those units can change when the raid changes so you'll need to do some stuff with RAID_ROSTER_UPDATE, but that's just the nitty gritty.

you will have to create your own frames, I don't know of any blizzard frames you can reuse (if you want it to look differently/customized). inside the frames you'll need to have a StatusBar frame type that will act as the lifebar, it can grow up and down depending on the values you give it

If you want to be able to know what's going on with each frame you'll need FontStrings that you can set the text to.

um, that's all I can think of atm, check out www.wowwiki.com for a nice listing of functions that you have available. it's not always up-to-date but it is invaluable. for blizzard code you can look at the blizzard addon development kit or wdn.wowinterface.com

hope this helps
  Reply With Quote
12-28-06, 12:02 PM   #4
SynchroPriest
A Murloc Raider
Join Date: Dec 2006
Posts: 5
Thanks for the responses guys. I had come across agUnitFrames and am going to spend some time digging through it today. I see the word "unit" thrown around a lot. "Unit ID", "Unit Frame", and so on. Can I assume a unit is any generic in-game object (like an action, spell, npc, or player) and I will be associating a lifebar "frame" with a player "unit"?

I actually don't care all that much if the frame styling is customized. If I could get at blizzard's default raid frames, I would be happy to use those. My main concern is custom grouping. Also, I'm not that interested in keeping up with the raid roster in realtime. That actually ties into the root cause I've decided to start learning this.

I'm tired of healing in AB/AV because to do so effectively, I need lifebars. And I have no idea who is in proximity without hovering the mouse over each person's lifebar. So I'm stuck putting up lifebars for every person in the raid and playing whack-a-mole, 50% of the time I waste trying to heal/debuff people who aren't even in the area. This by itself is annoying enough. On top of that, I'm constantly rearranging (manually dragging) the lifebars based on class at the start of every battleground, since the raid makeup is constantly different. I find this very tedious. So much so that I've just stopped doing it. I've decided that shadowform is fun enough and putting up with tanks screaming for heals is less of a hassle than trying to setup my lifebars and search through them for Tank-X; standing right in front of me but a needle in my 40-lifebar haystack.

So my idea is to map a key to a script that will automatically rearrange my lifebars for me. It'll iterate over the current raid roster, grab every toon within a certain radius of me, and throw up lifebars for just them. When I run into a new area, I can just regenerate the lifebar configuration with a single keystroke. In this fashion, I can be reasonably certain the people I have lifebars for are actually near me. I don't even want to see people who are out of range. That would be the first stage. Later on, I might add in a polling mechanism that does a status check and reports to a progress indicator showing the percentage of my "local group" who are still within range. So if I can see it drops below 70% or so, I know to regenerate the lifebar layout.

I've taken a look through the FrameXML directory and I found a HealthBar.lua file. This file appears to set the status bar value as well as the color based on health percentage. Incidentally, the 'value' assignments kind of jumped out at me. The 'value' variable appears to be an argument for HealthBar_OnValueChanged(), yet this function doesn't appear to do anything with value except assign new data to it (I was expecting it to either perform a UI update or report value back to another piece of code). This leads me to believe either

A) value is a global variable, so our assignment will be picked up by a later piece of code (seems like a bad idea to name a global variable 'value'),

B) value is a type of instance variable and HealthBar_OnValueChanged() is modifying the current owning object's state (the call to this:SetStatusBarColor() at the end of this function makes me think this might be a reasonable assumption), or

C) Lua is a pass-by-reference language, making the reassignment of value visible outside the scope of the current method. Can anyone tell me which one of these is most likely the case?

Anyway, GameToolTip.xml is the only file that directly references HealthBar.lua. I assume other files use GameToolTip.xml as a dependency to pull in the healthbar code. But I did a quick search in the directory and 5 files make references to HealthBar_OnValueChanged():

GameToolTipTemplate.xml
PartyFrameTemplates.xml
PetFrame.xml
PlayerFrame.xml
TargetFrame.xml

Off the top of my head, I would think PartyFrameTemplates.xml would be a good starting point for my study (though I have a feeling this is the default party view and not a template for raid lifebars). Can anyone shed any light on this?
  Reply With Quote
12-28-06, 12:11 PM   #5
SynchroPriest
A Murloc Raider
Join Date: Dec 2006
Posts: 5
Quick update, PartyMemberFrame.lua looks promising...
  Reply With Quote
12-28-06, 05:35 PM   #6
SynchroPriest
A Murloc Raider
Join Date: Dec 2006
Posts: 5
This piece of code also looks interesting. Just posting it here in case anyone else finds it useful.

From Blizzard_RaidUI.xml:

Code:
<OnDragStart>
   if ( IsShiftKeyDown() ) then
      this.keypressed = "SHIFT";
      RaidPulloutButton_OnDragStart(RaidPullout_GenerateNameFrame(this.name));
   elseif ( IsControlKeyDown() ) then
      this.keypressed = "CONTROL";
      RaidPulloutButton_OnDragStart(RaidPullout_GenerateClassFrame(getglobal(this:GetName().."Class"):GetText(), this.class));
   else
      RaidGroupButton_OnDragStart();
      this.keypressed = nil;
   end
</OnDragStart>
From Blizzard_RaidUI.lua

Code:
function RaidPullout_GenerateNameFrame(name)
	-- construct the button listing
	if ( not name ) then
		name = this.name;
	end
	local id = this:GetID();
	-- Get a handle on a pullout frame
	local pullOutFrame = RaidPullout_GetFrame(name);
	if ( pullOutFrame ) then
		pullOutFrame.filterID = name;
		pullOutFrame.id = id;
		pullOutFrame.single = 1;
		pullOutFrame.showBuffs = nil;
		-- Set pullout name
		getglobal(pullOutFrame:GetName().."Name"):SetText("");
		if ( RaidPullout_SingleUpdate(pullOutFrame) ) then
			return pullOutFrame;		
		end
	end
end
This generates a single "name frame". Doesn't appear to do much in the way of grouping, but I can experiment with it. Also, maybe someone can answer this for me. Does Lua provide automatic garbage collection? When I create a bunch of user frames, and I quickly going to run into memory leaks if I'm not careful handling my own garbage disposal?
  Reply With Quote
12-28-06, 09:34 PM   #7
JoshBorke
A Chromatic Dragonspawn
 
JoshBorke's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 185
as far as raid frames go, try Grid or agUnitframes, I know a lot of people use them.

as far as garbage collection is concerned, frames are never gc'd so you should try to reuse those on your own.

good luck
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Custom Lifebars


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off