Thread Tools Display Modes
06-14-05, 06:58 PM   #1
Coskesh
A Deviate Faerie Dragon
Join Date: Jun 2005
Posts: 11
Best way to determine if party member is in range for a buff?

Been working on modifying an existing script to not only buff myself, but also my group members at the press of one button (one buff per keystroke of course).

I've gotten it to the point where it works, but gets hung up when party members are out of range. I haven't found a command that checks range of a spell by name, only by action id. Now I'm looking at either determing x,y coordinates and comparing them to mine or (if possible) to check for spell failure and/or 'out of range' message then to put a 5 min timer to skip that party member.

Is there a better method? Any suggestions would be appreciated.
  Reply With Quote
06-14-05, 07:27 PM   #2
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
Pretty sure that function you found (IsActionInRange) is your best bet. You can scan the action bars for a buff of that name, possibly reuse it since buffs seem to be mostly 30 yards. Or if this is a macro you can add a /cast to the end of the macro and use that action slot's id.

By design, there aren't a lot of ways to get distances from the UI.

If you're doing a macro or not too concerned about getting max distance, you can see if CheckInteractDistance with index of 4 works for you. It will return true if you're in range to follow the unit you specify.

If you're doing it via AddOn, another way would be to remember who you attempted to buff last. If your next buff is trying to buff the same person, then have it skip them until it's tried everyone else.
  Reply With Quote
06-14-05, 11:54 PM   #3
Coskesh
A Deviate Faerie Dragon
Join Date: Jun 2005
Posts: 11
Gello, thank you again for the help. I'm using the CheckInteractDistance command, and it's working very nicely. I am going to look into scanning the actionbar in the future.

Only one minor problem at the moment: for mages.. I dont want to cast Arcane Intellect for tank-type classes. The following statement will not cast AI on anyone and I'm not sure why. I have to comment out the UnitClass stuff in order to buff a group comprised of druids and mages, for example.

Can I not use 'not' with the UnitClass check?


inrange = (CheckInteractDistance("party1", 4));
if inrange and (not IsBuffActive("Arcane Intellect","party1")) and (not UnitClass("party1")=="Rogue") and (not UnitClass("party1")=="Warrior") then
TargetUnit("party1");
ArcaneIntellect_Cast_Other()
  Reply With Quote
06-15-05, 02:06 AM   #4
Inokis
EQInterface Staff
 
Inokis's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 156
( not UnitClass("party1") == "Rogue" ) and ( not UnitClass("party1") == "Warrior" )
__________________
If not yourself, who can you count on...
  Reply With Quote
06-15-05, 04:24 PM   #5
Coskesh
A Deviate Faerie Dragon
Join Date: Jun 2005
Posts: 11
Inokis, it seems that you have added some extra spaces, otherwise the code is exactly the same. Does spacing make a difference? Haven't had a chance to try it out with the extra spacing yet.

Thanks.
  Reply With Quote
06-15-05, 07:28 PM   #6
Inokis
EQInterface Staff
 
Inokis's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 156
with conditional statements = > < etc, you need a space between the text and the symbol on either side. As far as the space at the end of the parens, thats just something I do from an example in the default LUA files.

I'm pretty sure that not having spaces on either end of your value symbols is causiing the issue.
__________________
If not yourself, who can you count on...
  Reply With Quote
06-15-05, 07:44 PM   #7
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
You can use ~= as "not equal" also btw.

if UnitClass("party1")~="Rogue"

is same as

if ( not UnitClass("party1")=="Rogue" )
  Reply With Quote
06-16-05, 01:03 PM   #8
Coskesh
A Deviate Faerie Dragon
Join Date: Jun 2005
Posts: 11
The spacing didn't seem to make a difference. I will try the using ~= .

Thanks!
  Reply With Quote
06-22-05, 09:51 PM   #9
Littlejohn
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Jun 2005
Posts: 90
Originally Posted by Gello
if UnitClass("party1")~="Rogue"

is same as

if ( not UnitClass("party1")=="Rogue" )
This is not true. (ha ha. well, ok, actually, that's not funny.)

if UnitClass("part1") ~= "Rogue"

is same as

if (not (UnitClass("party1") == "Rogue"))

In other words, the == binds looser than the not. If you leave off the parens around the == test, then you are actually meaning something like

if ((not UnitClass("party1")) == "Rogue")

Read the Lua manual section on operator precedence for all the gory details. If you don't want to remember the precedence, use parens around anything you're not sure of. The parens don't cost anything in terms of run-time speed so go crazy with them.

http://www.lua.org/manual/5.0/manual.html#2.5.5

BTW, spacing has absolutely nothing to do with it. You can add or remove spaces at your whim.

- Ken
  Reply With Quote
06-22-05, 11:40 PM   #10
Syllani
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Apr 2005
Posts: 18
Perhaps try something different altogether?

if (UnitPowerType("party1")>0)

to check if they have rage or energy (as opposed to mana)

http://www.wowwiki.com/API_UnitPowerType

EDIT: Unfortunately, I'm unsure whether it will cause you to skip over buffing a shapeshifted druid or not.
  Reply With Quote
07-21-05, 12:02 PM   #11
Drowsey
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Jul 2005
Posts: 7
well of course you know that the change in 1.6 prevents you from ranging to players outside your group or raid, inside either you could use the maplibrary addon to get ranges between you and another member. I have the same type issue in my own addon, but do have internal range checking code. My main problem is with Line of Sight. You may be able to capture the spell information when the spell is cast, and monitor events to check if it was successfull or not. That what I am converting all of my checking to now.

Originally Posted by Coskesh
Been working on modifying an existing script to not only buff myself, but also my group members at the press of one button (one buff per keystroke of course).

I've gotten it to the point where it works, but gets hung up when party members are out of range. I haven't found a command that checks range of a spell by name, only by action id. Now I'm looking at either determing x,y coordinates and comparing them to mine or (if possible) to check for spell failure and/or 'out of range' message then to put a 5 min timer to skip that party member.

Is there a better method? Any suggestions would be appreciated.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Best way to determine if party member is in range for a buff?


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