$seachspawn exact match

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

NotHere
a lesser mummy
a lesser mummy
Posts: 40
Joined: Fri Jan 09, 2004 5:59 am

$seachspawn exact match

Post by NotHere » Fri Feb 06, 2004 3:20 pm

Heya.

Trying to do a spawn checker, and ran into the problem that when I have to check for a mob which name are a part of other mobs names, I get the wrong mobs, if they are closer to me than the mob Im looking for.

Eg, doing

Code: Select all

/echo $spawn($searchspawn(npc,"Saryrn"),name)
Inside Plane of Torment, I get

[MQ2] A servent of Saryrn

in my MQ window.

Tried seaching and cant seem to find anything on how to make $seachspawn do an exact match instead of an substring search.

Any ideas?
NotHere
/afk

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Fri Feb 06, 2004 3:42 pm

I'm not at a computer to test it but try something like this:

Code: Select all

#turbo 20

Sub Main
/declare NpcCount global
/declare a local
/call IterateNPC "Saryn"
/if n $return>0 {
    /echo Found Mob:$spawn($return,name,clean) - Mob ID is:$return
} else {
    /echo Mob Not Found.
}
/return


Sub IterateNPC(SearchName)
/declare npcid local
/declare firstnpcid local
/declare lastnpcid local
/varset npcid 0
/varset firstnpcid 0
/varset lastnpcid 0
/varset NpcCount 0
/varset npcid $searchspawn(npc,"@SearchName")
/if n @npcid!=0 /if "$spawn(@npcid,name,clean)"=="@SearchName" /return @npcid
:Loop
/if n @npcid==@firstnpcid {
   /return 0
} else {
   /if n @NpcCount==0 /varset firstnpcid @npcid
   /varset lastnpcid @npcid
   /varset npcid $searchspawn(npc,"@SearchName",id:@lastnpcid,next)
   /if n @npcid!=0 /if "$spawn(@npcid,name,clean)"=="@SearchName" /return @npcid
   /if n @lastnpcid!=0 /varadd NpcCount 1
}
/goto :Loop
/return


NotHere
a lesser mummy
a lesser mummy
Posts: 40
Joined: Fri Jan 09, 2004 5:59 am

Post by NotHere » Fri Feb 06, 2004 11:40 pm

Ah, thanks!

I was thinking about the same thing, but was unsure how to loop through the spawns.

Will check it out when Im slacking at tonights raid.
NotHere
/afk