finding a roaming mob?

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

Spriali
decaying skeleton
decaying skeleton
Posts: 5
Joined: Thu Feb 19, 2004 10:53 pm
Contact:

finding a roaming mob?

Post by Spriali » Wed Feb 25, 2004 12:52 am

I have been racking my brain all day on some code to efficiently find a roaming mob and this is what I came up with, does anyone have any better ideas or faster code? This works, but it is a lot of work and, well, frankly, quite slow...

Code: Select all

Sub FindRoamer(x1,x2,y1,y2,z)
  /declare i local
  /for i 1 to 2000
     /if n $spawn(@i,x)>=@x1 {
        /if n $spawn(@i,x)<=@x2 {
           /if n $spawn(@i,y)>=@y1 {
             /if n $spawn(@i,y)<=@y2 {
                /if n $spawn(@i,z)==@z {
                   /target id @i
                   /varset HasTarget 1 
                   /varset MobToHunt $target(name) 
                   /return @i
                }
             }
           }
        }
     }
  /next i
/return

daerck
a ghoul
a ghoul
Posts: 134
Joined: Mon Jan 12, 2004 8:44 pm

Post by daerck » Wed Feb 25, 2004 3:24 am

Humm... what exactly is your definition of a roamer?

To me this looks like it will find any npc/pc in a square area specified with the corners x1, x2, y1 & y2 and on exactly the the hight z (which will in most cases be no mob).


If you want to check for a mobs that are moving and leave static mobs alone, you should probably use the $spawn(speed) for that.

And in order to cycle through all mobs you should use $searchspawn(npc,id:@CurId,next) or something similar as the id's aren't continous.

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

Post by ml2517 » Wed Feb 25, 2004 6:18 am

Hahha.

Wow, you get the "I just reinvented the wheel, and all I got was this lousy shirt." award.

There are plenty of bits of code out there that will demonstrate $searchspawn to you. Try a search on it.

Spriali
decaying skeleton
decaying skeleton
Posts: 5
Joined: Thu Feb 19, 2004 10:53 pm
Contact:

Post by Spriali » Wed Feb 25, 2004 7:51 am

There is also only one roamer in this spot and it always roams along one elevation within a set range of coords.

I was messing around with $searchspawn and couldn't quite get it to work right. I'll try again, but the docs are pretty sketchy on what you have available for use with that command and I did try the search function. Even with searchspawn, other that with physical coordinates, is there any idea of how to get the roaming mob? Even speed>0 doesn't work, because the roamer stops and takes breaks periodically.


I'm not asking for someone to write this for me, just some ideas so I can finish up my macro in the next couple of days. This is my first one and I find it a new challenge to EQ :)

Gumby
a ghoul
a ghoul
Posts: 99
Joined: Sat Jan 24, 2004 5:27 pm

Post by Gumby » Wed Feb 25, 2004 11:18 am

If you're writing this as an instant in time macro, then (speed) is about as good as you're going to get unfortunately from a script perspective. Though, if it is instant in time, why not simply pop up the map and watch the npc's in a given vicinity? If it moves, it's a roamer; actually the mq2map spawn id addition I saw (though haven't tried) would be ideal for making this example more convient as well when it comes to picking the mob out of a crowd later.

If you're willing to hang out for a bit, I'd probably just $ss in a radius around a given loc, toss the mob ID and it's current y,x loc into an array, and then on 30 second or minute intervals rerun the check and see if for a given spawn id the mob in question has a new y,x coordinate. If so, it's a roamer.

G

Spriali
decaying skeleton
decaying skeleton
Posts: 5
Joined: Thu Feb 19, 2004 10:53 pm
Contact:

Post by Spriali » Wed Feb 25, 2004 1:07 pm

I'm in the process of rewriting it using $searchspawn, I'll post what I have here in bit. I have a couple questions on it.