Monday, April 16, 2012

Differentiate Between Totem and Mob

I ran into an interesting problem as I looked through my latest mob database for my addon (mobmarks). The addon was adding totems to the list of mobs it mousedover. While this isn't a big problem, I wondered if there was a way to tell the difference between actual mobs, and things like totems.

I'm currently using,


Code:
if (UnitIsEnemy("mouseover","player") or (not UnitIsFriend("mouseover","player") and UnitCreatureType("mouseover") ~= "Critter"))

to add attackable mobs, and not critters or mind controlled players to the database.|||I thought of a "hacky" way to do it - check the health of the mouseover and if it's less than 100hp, don't add it to the database. I'm pretty sure totems have very low hp, and there are no mobs (that anyone would care about) has less than 100 hp.

Though I continue to pine for a more elegant solution.|||Yup, totems all have 5hp, except for Stoneclaw. There's no "proper" way to do what you're trying to that I am aware of.|||Thanks for the response Tunga. After leafing through the API, I figured as much. I suppose that I could also check for the specific names of the totems also.|||Yep, you could use a Regex match (string.match() I think) on the word "totem" to save having to code them all specifically.|||You took the words right out of my mouth..er the code right out of my brain. Though i'll also have to match "Healing Ward" and "Protective Ward" too. Do you know if string.match works for strings with spaces in it? My hunch is that it does.|||Pretty sure it's equivalent to a standard Regex match with wildcards on both sides, so spaces would be fine.|||Don't the pet elemental totems also have the same hp as the mobs they spawn ?

Just a thought...?|||Ah yes, they do, I forgot those (and Stoneclaw has more as said before).|||Wouldn't that also filter out mobs that have Totemic in their names??

Winterfall Totemic

Razorfen Totemic

Foulweald Totemic

...

No comments:

Post a Comment