Counting mobs

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

User avatar
Undies
a ghoul
a ghoul
Posts: 94
Joined: Mon Oct 20, 2003 9:12 pm

Post by Undies » Thu Dec 11, 2003 6:37 am

Yes it seems to work, Blueninja is right

Code: Select all

Sub Main
    /zapvars
    /declare id1 global
    
    /varset id1 $searchspawn(npc,loc:$char(x):$char(y),radius:1000) 
    /echo $spawn(@id1,name,clean) 
    /varset id1 $searchspawn(npc,loc:$char(x):$char(y),radius:1000,"id:@id1","next") 
    /echo $spawn(@id1,name,clean) 
    /varset id1 $searchspawn(npc,loc:$char(x):$char(y),radius:1000,"id:@id1","next") 
    /echo $spawn(@id1,name,clean) 
/endm
returns 3 different npc names.
It should be easy to set up a loop to check when @id1 no longer changes and insert a counter variable in the loop to count #npcs.

brat
orc pawn
orc pawn
Posts: 15
Joined: Fri Nov 21, 2003 10:46 am

Post by brat » Thu Dec 11, 2003 11:58 am

The count routine is ok as long as you aren't being hit

you press ESC and expect /target to bring a "new" mob on your target - if you are getting hit an "old" mob can get on your target and be re-counted repeatedly - since endloop condition is nothing on target within a delay 3

I addeded a simply ID array and IDnum and do a "if this mob is in array, I counted it already :skip"

not at my home machine to paste in the code..

I was levaging your snippet to help me on a "slow all nearby" routine for my BLord-bot

Edit: BLEH - apparently I can't read either - this also is Player centered, not mob target

Code: Select all

Sub FindClose
/varset NearNum 0
/alert clear 1 
/alert add 1 id -1 |This line circumvents some bugginess with alerts. 
:CountLoop 
/target npc radius 50 noalert 1 
/delay 3 
/if $target()=="TRUE" { 
  /varset Loop 0
:loop
  /if n @Loop==@NearNum /goto :notinlist
  /if n $target(id)==@NearIDs(@Loop) /goto :doneadding
  /varadd Loop 1
  /goto :loop
:notinlist
  /varset NearIDs(@NearNum) $target(id)
  /varadd NearNum 1
  /alert add 1 id $target(id) 
  /goto :CountLoop 
} 
:doneadding
/return 

User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Thu Dec 11, 2003 7:18 pm

You can do the same thing with $searchspawn. That way you won't have to target everything which is much better imo (targetting is not only annoying cause it can mess up other stuff you do, it also sends a packet to the server that you've selected a new target).

User avatar
Undies
a ghoul
a ghoul
Posts: 94
Joined: Mon Oct 20, 2003 9:12 pm

Post by Undies » Thu Dec 11, 2003 7:29 pm

Targetting mobs halfway across the zone (or even many in succession close by) is a bit of a giveaway. These days it is more sensible to use $searchspawn and remove the possibility.

There is another thread on these boards where a GM asked an MQ user why he had a mob targetted across the zone...

Not to mention using $searchspawn will be faster because it doesn't send data across your internet link...