PDA

View Full Version : Differentiate Between Totem and Mob


modernq
11-08-2008, 10:26 PM
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,

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.

modernq
12-08-2008, 06:49 PM
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.

Tunga
12-08-2008, 07:44 PM
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.

modernq
12-08-2008, 08:31 PM
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.

Tunga
13-08-2008, 12:03 AM
Yep, you could use a Regex match (string.match() I think) on the word "totem" to save having to code them all specifically.

modernq
13-08-2008, 04:30 PM
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.

Tunga
13-08-2008, 04:59 PM
Pretty sure it's equivalent to a standard Regex match with wildcards on both sides, so spaces would be fine.

Telic
17-08-2008, 10:09 AM
Don't the pet elemental totems also have the same hp as the mobs they spawn ?
Just a thought...?

Tunga
18-08-2008, 10:52 AM
Ah yes, they do, I forgot those (and Stoneclaw has more as said before).

Wintrow
04-09-2008, 01:40 PM
Wouldn't that also filter out mobs that have Totemic in their names??

Winterfall Totemic
Razorfen Totemic
Foulweald Totemic
...

Tunga
04-09-2008, 01:56 PM
Well not if you match a whitespace either side of "totem".

Wintrow
05-09-2008, 11:05 AM
will that also account for when "totem" is the first or last word in the name?

What is the creaturetype of a totem anyway? I guess you can safely say that, if it's humanoid, it ain't a totem :tongue:.

Tunga
05-09-2008, 02:09 PM
It's a regex match, it does what you want it to do.

Wintrow
06-09-2008, 10:59 AM
Well, colour me ignorant. But I only had a tiny bit of Linux-experience in college. And outside of that... regular expressions aren't THAT popular for me to know a lot about them.

Nevertheless, if it works I'm happy. And if I contributed, I'm even happier :grin:.

Tunga
09-09-2008, 10:45 PM
Well, colour me ignorant. But I only had a tiny bit of Linux-experience in college. And outside of that... regular expressions aren't THAT popular for me to know a lot about them.I've used them in a dozen different languages and never run Linux. Just assume that they are amazingly powerful and versatile and can do whatever you need them to do.