I'd like some input on a library I'm coding, the idea is that addons that perform role specific functions can simply embed this and feel free to call the Blizzard role API.
As you can see it isn't anything complex, it simply sets your role automatically when you're in a raid, according to your spec. Then the only thing the addon needs to worry about is calling the Blizz role API.
As well as input on the idea itself, I'd like some input on the best way to expose the "specific" variable (The variable is either "melee" or "ranged"). I figured this might be needed for some more advanced addons, and wondered if it would be best to make it a specifically named global variable, or a call to the library itself.
I think the library should listen to RAID_ROSTER_UPDATE (entering/leaving raid, beware of infinite recursion since I think SetUnitRole triggers it) and obviously ACTIVE_TALENT_GROUP_CHANGED.
Also, Blizzard added some API to ease detecting roles. For the player, you would do something like this:
[snip]
role1 should contain "HEALER", "TANKER" or "DAMAGER". role2 might contain another role. AFAIK, GetTalentTreeRoles only returns two values for feral druids : "DAMAGER", "TANK".
Thanks Xinhuan and thanks for the input Adirelle, but there are a few flaws with that.
ACTIVE_TALENT_GROUP_CHANGED probably won't fire when changing from bear to cat spec.
It doesn't account for example, a raid leader changing someones role because they want the player to go X role, but then change their mind, and want them to stay Y role without changing the role back. Hence mine triggers when you enter combat in an instance.
You can set your role fine in Combat.
It's better having "specific" not set than set to unknown until it is set.
Anyway I've updated my original post with draft 2 and included it here: http://paste.wowace.com/3353/ Includes your suggestion of doing a check when entering a raid.
ACTIVE_TALENT_GROUP_CHANGED probably won't fire when changing from bear to cat spec.
ACTIVE_TALENT_GROUP_CHANGED is fired even when the primary tree (or the role) is unchanged between the two specs. Going from feral (1st spec) to feral (2nd spec) triggers it.
It doesn't account for example, a raid leader changing someones role because they want the player to go X role, but then change their mind, and want them to stay Y role without changing the role back. Hence mine triggers when you enter combat in an instance.
You can set your role fine in Combat.
Right. In that case, it should probably listen to both ACTIVE_TALENT_GROUP_CHANGED and PLAYER_REGEN_DISABLED and systematically call UnitSetRole. I think in most case one would be happy to know the actual roles before the combat starts.
How many addons would actually use this library simultaneously? My intuition is that if 2 addons will never be installed together that simultaneously uses a library, then it shouldn't be a library in the first place and should be addon-specific code.
Right now, I don't see why a user would require 2 addons that sets his role.
LibGroupTalents-1.0 and LibTalentQuery-1.0 are for querying others' talents. LibRaidRole would be only to get your own role (and ranged/melee status), as well as automatically setting your role in raid (using Blizzard dedicated API).
You would use LibGroupTalents-1.0 and call UnitSetRole as soon as you get talent information for the others. This could be pretty long as talent requests are throttled and you could not do it unless your were raid assistant or raid leader.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Here is a preview: http://paste.wowace.com/3353/ (draft 2)
As you can see it isn't anything complex, it simply sets your role automatically when you're in a raid, according to your spec. Then the only thing the addon needs to worry about is calling the Blizz role API.
As well as input on the idea itself, I'd like some input on the best way to expose the "specific" variable (The variable is either "melee" or "ranged"). I figured this might be needed for some more advanced addons, and wondered if it would be best to make it a specifically named global variable, or a call to the library itself.
Thanks.
For the specific, you could simply add a getter :
I think the library should listen to RAID_ROSTER_UPDATE (entering/leaving raid, beware of infinite recursion since I think SetUnitRole triggers it) and obviously ACTIVE_TALENT_GROUP_CHANGED.
Also, Blizzard added some API to ease detecting roles. For the player, you would do something like this:
[snip]
role1 should contain "HEALER", "TANKER" or "DAMAGER". role2 might contain another role. AFAIK, GetTalentTreeRoles only returns two values for feral druids : "DAMAGER", "TANK".
It updates the player role as soon as he joins a raid or changes his active spec.
ACTIVE_TALENT_GROUP_CHANGED probably won't fire when changing from bear to cat spec.
It doesn't account for example, a raid leader changing someones role because they want the player to go X role, but then change their mind, and want them to stay Y role without changing the role back. Hence mine triggers when you enter combat in an instance.
You can set your role fine in Combat.
It's better having "specific" not set than set to unknown until it is set.
Anyway I've updated my original post with draft 2 and included it here: http://paste.wowace.com/3353/ Includes your suggestion of doing a check when entering a raid.
ACTIVE_TALENT_GROUP_CHANGED is fired even when the primary tree (or the role) is unchanged between the two specs. Going from feral (1st spec) to feral (2nd spec) triggers it.
Right. In that case, it should probably listen to both ACTIVE_TALENT_GROUP_CHANGED and PLAYER_REGEN_DISABLED and systematically call UnitSetRole. I think in most case one would be happy to know the actual roles before the combat starts.
How many addons would actually use this library simultaneously? My intuition is that if 2 addons will never be installed together that simultaneously uses a library, then it shouldn't be a library in the first place and should be addon-specific code.
Right now, I don't see why a user would require 2 addons that sets his role.