Thread Tools Display Modes
05-17-06, 01:19 AM   #1
GizmoC
A Murloc Raider
Join Date: May 2006
Posts: 5
My idea, experianced modders please read

Hello

I am new to LUA and WoW modding, but not new to programming.
I started this endeavor because I think I have a really good idea for a mod, and I would like to make it a reality. Its not an overly complex mod either.

I am SURE that most of the functionality/logic I need, has already been coded and is "somewhere out there". So, I have some questions.

1) Is it possible to determine the distance from one player to another? For instance, is it possible to determine if playerX is within 10 yards of playerY, or if playerX is within AE heal range of playerY(Priest) ?

2) Assume there is a raid.
I want to constantly keep track of the TOTAL HP of every group.
There are advanced mods out there (CTRaidAssist comes to mind) that constantly keep track of the health of every member in the raid. They do this by using the raid assist channel (I think?).
I dont want to reinvent the wheel, so is there a way my mod could subscribe to this channel and "extract" the health information from it? How do I go about doing this?
  Reply With Quote
05-17-06, 08:11 AM   #2
JoshBorke
A Chromatic Dragonspawn
 
JoshBorke's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 185
1) Not really. You can sort of do it with spell range checking, but that doesn't really work. in short, no.
2) Unit health is available in the form of UnitHealth('raid<n>') format. You can try registering for UNIT_HEALTH_CHANGED to catch the updates, but like has been said in a similar thread, you won't get all events. The other way is to use an OnUpdate that checks for the health of every member, but you'll get a pretty big performance hit for that I'd think.

hope this helps
  Reply With Quote
05-17-06, 08:41 AM   #3
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
There can be pretty huge performance gains by using OnUpdate over UNIT_HEALTH, especially in a raid setting, depending on what you plan to do.

The key to remember is that "bare" lua (without frame methods or calling other functions that you don't know what they do) is extremely fast.

You could combine the approaches:

UNIT_HEALTH:
raidNeedsUpdating[arg1] = 1

OnUpdate:
Code:
this.timer = this.timer + arg1
if this.timer > .5 then
  this.timer = 0
  for unit in raidNeedsUpdating do
    -- this unit's health changed in last half second
    -- do what you planned to do when health changed
    raidNeedsUpdating[unit] = nil
  end
end
That will update the health for only those that received a UNIT_HEALTH update, without doing the whole event in response to every UNIT_HEALTH.

On the distances between players, you'll probably be disappointed to find out the limitations. You can determine the distance to a unit with SpellCanTargetUnit but they *must* be in spell targeting mode (blue glowing cursor, awaiting a spell target). Otherwise you need to target a person to determine if they're in range of an ability.

The coordinates between friendly players doesn't work in instances.

edit: to take the dirty flag approach further, you could have a metatimer within the OnUpdate to stop the OnUpdates (hide the frame) after say 5 seconds of no UNIT_HEALTH happening. A frame:Show() on an already-shown frame is very fast. However I don't suggest hiding the frame every .5 seconds. Something like:

UNIT_HEALTH:
Code:
raidNeedsUpdating[arg1] = 1
this.idleTimer = 0
this:Show() -- time it! it's faster than you think
Code:
<OnLoad>
  this.idleTimer = 0
  this.updateTimer = 0
</OnLoad>

<OnUpdate>
  this.idleTimer = this.idleTimer + arg1
  this.updateTimer = this.updateTimer + arg1
  if this.updateTimer > .5 then
    this.updateTimer = 0
    for unit in raidNeedsUpdating do
      -- this unit's health changed in last half second
      -- do what you planned to do when health changed
      raidNeedsUpdating[unit] = nil
    end
  end
  if this.idleTimer > 5 then
    this:Hide()
  end
</OnUpdate>
The above will do a health update every .5 seconds. After 5 seconds of inactivity the OnUpdate will shut down.

Last edited by Gello : 05-17-06 at 08:54 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » My idea, experianced modders please read


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