Description:
This is a small addon for Grid which publishes the state "hostile unit" if a unit in the raid has turned hostile (propably because it is charmed).
The idea for this addon comes originally from oodyboo from WoW-Ace!
Please report any not or wrong detected hostile units.
How to activate:
Go to the grid configuration. Go to Frames and select the state "hostile unit" for the frame you want to display it in.
For example if you want to turn the healthbar red if a Unit turns hostile you would check the "hostile unit" state for the frame "HealthBar".
Known problems:
"Find one bug, get another one for free!"
- none
Thanks to:
- oodyboo from WoW-Ace for the idea for this addon
It seems to work in all cases - but ... strangely it seemed to not be working in heroic slave pens after the big crab guy when my group got MC'd but I'm not sure why. I'll let you know if I'm able to reproduce this issue.
While trying to convert the addon for grid2 I've remembered the problem I had when writing this addon. Maybe someone can help me solve it (at least partly):
The Problem:
1. I need an event which is triggered when the hostility of an unit has or might be changed.
2. I need an function to get the definite hostility state of an unit.
My current solution in GridStatusHostileUnit:
1. There are several events which might indicate an hostility change, by now I just listen to all of them, which definitly produces some overhead but is pretty failsafe. These events are:
UNIT_FLAGS - Triggered when the flags of an unit have changed. Problem is, I don't have the slightest idea what these flags are, but hostility could be among them.
UNIT_DYNAMIC_FLAGS - Same as UNIT_FLAGS
UNIT_AURA - Almost every hostility of a former normaly friendly unit is caused by some debuff, so if the (for example) Mind Control debuff appears at an unit, I'll will get it...together with every other buff or debuff gain and loss.
UNIT_AURASTATE - Same as UNIT_AURA, don't really know what the difference is.
UNIT_LOYALTY - The name is very promising, but I have no idea what this event really indicates.
2. There are several methods which could return the hostility of an unit, by now I just ask all of them and if one of them says the unit is hostile I assume the unit is hostile. These methods are:
UnitIsCharmed(unitid) - Very promising method, but I don't know for sure if every hostile unit counts as "charmed". And if every charmed unit is really hostile, or maybe just put out of action.
UnitIsEnemy("player", unitid) - Besides the fact that this method won't work for the player himself this easily, I don't know if a charmed (normally friend) unit really counts as enemy.
not UnitIsFriend("player", unitid) - Same as UnitIsEnemy, only the other way around.
UnitCanAttack(unitid, "player") - A method I don't use at the moment but which could be also used, because every unit in the raid which can attack you has to be hostile. The problem is that I don't know if this method still returns true if the hostile unit gets sheeped or something like that. Because in this state he can't really attack the player...but could.
So at the moment I'm probably producing some overhead in GridStatusHostileUnit, but since the addon doesn't really need much cpu-power anyway I will stay with this method as long I have no definite no or yes to some of these events/methods.
So if someone has some information on or more of these items (if they do or not do the job) I'll be glad to be able to optimize it. (Which actually is the cause for this thread :)
When you get mind controlled yourself, it does not force a Grid Refresh/Update whatever for all unit frames. This means that hostile unit frame indicators don't update immediately. They turn red as other events trigger their frame updates. This can be confusing right after being mind controlled because only one or two party members will turn red, looking as if *they* are the mind controlled players.
Maybe it could force a refresh on all the unit frames when you yourself are mindcontrolled?
I'm not sure how hard that hits the CPU, so I'll leave it to you veterans to decide if that's a reasonable solution or not.
When you get mind controlled yourself, it does not force a Grid Refresh/Update whatever for all unit frames. This means that hostile unit frame indicators don't update immediately. They turn red as other events trigger their frame updates. This can be confusing right after being mind controlled because only one or two party members will turn red, looking as if *they* are the mind controlled players.
Maybe it could force a refresh on all the unit frames when you yourself are mindcontrolled?
I'm not sure how hard that hits the CPU, so I'll leave it to you veterans to decide if that's a reasonable solution or not.
I think I'll just commit my "long written but not testet because of little time and mindcontrols"-version where it reacts correctly when the player himself gets mindcontrolled.
I hope I can react quick enough to the "oh my god! its broken"-replies :)
Personally I'd prefer to only see the player unit frame with the MC status instead of displaying all other units as MCd. While it's true that everyone else is 'hostile', the player still is the only person that's mind controlled. It should easily be possible to 'invert' the display to make sure that not the entire raid turns red when the player is MCd.
I think I'll just commit my "long written but not testet because of little time and mindcontrols"-version where it reacts correctly when the player himself gets mindcontrolled.
I hope I can react quick enough to the "oh my god! its broken"-replies :)
I have to correct myself: The "long written"-version wasn't as good as I thought and I don't have the time to rewrite AND test it. So I won't commit it, but I'll attach a zip containing a version which tries to detect hostile units only by listening to UNIT_AURA and calling UnitCharmed(). I whould be glad if some people could test it and tell me when it worked and when it didn't.
@Maia: Totally agree with you and the new Version does it that way.
Is that attached zip more or less what you changed in 0.71?
What attached Zip do you mean? If you mean the Zip I attached to my post from last year then: No. That was Version 0.7 in 0.71 I only added a change from a comment of saiket:
Was it your intention to have friendly mind-controlled units show up as hostile even though they are not attackable? I understand that you use UnitIsCharmed for performance reasons, but having priests' mind controlled NPCs show up as hostile is confusing. Would it be possible to swap the original hostile check,
local hostile = UnitIsCharmed(unitid)
...with this one that additionally checks hostility only if the unit is actually charmed?
local hostile = UnitIsCharmed(unitid) and UnitIsEnemy(unitid, "player")
The additional UnitIsEnemy call hardly affects performance in this case, because 99% of the time it won't be called.
This is a small addon for Grid which publishes the state "hostile unit" if a unit in the raid has turned hostile (propably because it is charmed).
The idea for this addon comes originally from oodyboo from WoW-Ace!
Please report any not or wrong detected hostile units.
How to activate:
Go to the grid configuration. Go to Frames and select the state "hostile unit" for the frame you want to display it in.
For example if you want to turn the healthbar red if a Unit turns hostile you would check the "hostile unit" state for the frame "HealthBar".
Known problems:
"Find one bug, get another one for free!"
- none
Thanks to:
- oodyboo from WoW-Ace for the idea for this addon
SVN: http://svn.wowace.com/wowace/trunk/GridStatusHostileUnit/
Version History:
Revision 2:
- code cleanup
- new hostile detection (should display it correct now if the player itself is hostile)
Version 0.1:
- first release
Thanks so much for making this.
It seems to work in all cases - but ... strangely it seemed to not be working in heroic slave pens after the big crab guy when my group got MC'd but I'm not sure why. I'll let you know if I'm able to reproduce this issue.
The Problem:
1. I need an event which is triggered when the hostility of an unit has or might be changed.
2. I need an function to get the definite hostility state of an unit.
My current solution in GridStatusHostileUnit:
1. There are several events which might indicate an hostility change, by now I just listen to all of them, which definitly produces some overhead but is pretty failsafe. These events are:
2. There are several methods which could return the hostility of an unit, by now I just ask all of them and if one of them says the unit is hostile I assume the unit is hostile. These methods are:
So at the moment I'm probably producing some overhead in GridStatusHostileUnit, but since the addon doesn't really need much cpu-power anyway I will stay with this method as long I have no definite no or yes to some of these events/methods.
So if someone has some information on or more of these items (if they do or not do the job) I'll be glad to be able to optimize it. (Which actually is the cause for this thread :)
best action would be doing a UnitCanAttack() call on UNIT_AURA events.
if the player is CC'ed while hostile they are still hostile.
Ok. Thanks.
Yeah, but does a cc'd hostile unit can still attack me?
Same problem with this when I'm cc'ed :)
Maybe it could force a refresh on all the unit frames when you yourself are mindcontrolled?
I'm not sure how hard that hits the CPU, so I'll leave it to you veterans to decide if that's a reasonable solution or not.
I think I'll just commit my "long written but not testet because of little time and mindcontrols"-version where it reacts correctly when the player himself gets mindcontrolled.
I hope I can react quick enough to the "oh my god! its broken"-replies :)
I have to correct myself: The "long written"-version wasn't as good as I thought and I don't have the time to rewrite AND test it. So I won't commit it, but I'll attach a zip containing a version which tries to detect hostile units only by listening to UNIT_AURA and calling UnitCharmed(). I whould be glad if some people could test it and tell me when it worked and when it didn't.
@Maia: Totally agree with you and the new Version does it that way.
Is that attached zip more or less what you changed in 0.71?
What attached Zip do you mean? If you mean the Zip I attached to my post from last year then: No. That was Version 0.7 in 0.71 I only added a change from a comment of saiket: