View Full Version : Unit Tokens
elidion
24-02-2007, 07:50 AM
So now that I am gathering info from my Combat Log Events, I am now getting an invalid unit token when it reads someone of the opposite faction casting a spell. since I have it read
Lets use for example my renew spell
the combat log says
"Deramon gains renew"
so the mod takes "Deramon" and puts it into a variable named modname
so now when I do a UnitFactionGroup(modname) it will work correctly if the person was my faction, but if the opposite faction gets the same buff and I pick it up, it will popup with an error (invalid unit token "personsname"
I get now that you can't use an opposing factions actual name for "unit" so what is the way around this? Is there one?
What is dumb is I am only listening to
CHAT_MSG_SPELL_PERIODIC_PARTY_BUFFS
CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_BUFFS
CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS
so I don't know why horde buffs are showing up there.
Duugu
24-02-2007, 02:19 PM
UnitFactionGroup expects a UnitID ... not a name. See http://www.wowwiki.com/API_TYPE_UnitId
This won't work:
modname = "Deramon";
UnitFactionGroup(modname);
You'll have to use:
modname = "player";
UnitFactionGroup(modname);
Furthermore UnitFactionGroup could be used for you faction and the opposit faction (would be useless without this ... or not?).
elidion
24-02-2007, 05:13 PM
Actually UnitID can take player names as long as they are in your faction. Try doing a /script DEFAULT_MESSAGE_FRAME:AddMessage(UnitFactionGroup("Duugu")) or replace Duggu with any of the players around of the same faction and it will print out "alliance" or "Horde", but if you put someone with the opposite faction in, then it will pop up with an error saying "Unknown Unit Token". Also try this with UnitSex or UnitLevel...it takes a name
As I said in my first post, I get that I can't use a the unitID, what my question is, is there a way around it.
If I am searching for events, and I am getting
"Deramon gains renew"
mod takes deramon and does what it needs with its name
"duugu gains renew"
mod takes duugu and does what it needs to do
"someotherfaction player gains renew"
ERROR invalid unit token.
I obviously couldn't use "player" because that would only use myself, and I can't use "target" because then it would only parse the combat log of whoever my target is and that won't work either.
So I am just wondering if there is a way to filter it out if it is going to cause an error, like a "if unitID is invalid then" type of deal. I really see no way around this, it sucks that Blizz puts opposite faction on CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_BUFFS
if they changed them to hostileplayer_buffs it would make life so much more easier.
with all the damage meter and healing meter mods I assume they have to filtering this out somehow.
elidion
24-02-2007, 05:25 PM
I guess another way to get around this is to index my entire party or raid member names, and when "someotherfactionplayer gains renew" and puts modname = someotherfactionplayer
I could check to see if modname matches any of the players in my party or raid.
I know how to do this for a raid with GetRaidRosterInfo(index) but I'm not sure about party.
What do you guys think? It sucks I even have to think this way...it's getting way too complicated to filter this thing out.
Wintrow
26-02-2007, 01:42 PM
if you use pcall, it will catch the error
so basically:
local myfactionname;
myfactionname = UnitFactionGroup('player');
local name = "Elidion";
local retOK, faction;
retOK, faction = pcall(UnitFactionGroup(name));
if not retOK or faction ~= myfactionname then
-- Not your faction
else
-- Your faction
See http://www.wowwiki.com/API_pcall for more info
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.