ID:176825
 
Does anyone know a code that makes your character walk to and face a mob that you click on? Please tell me if you know how to do this.
Well, let's split this up into a few parts. First there's the click. For that, you want the Click() proc. More specifically, you want to put your code in the Click() proc of the mob that's getting clicked.
mob/clickable/Click()

Call it whatever you want. Next is walking to that mob. You probably want walk_to(). It's pretty simple to use:
    walk_to(usr, src)

Remember here, usr is the person doing the clicking, and src is the mob being clicked.

Finally, you want to face the mob that was clicked when you get there. Whoops! walk_to() is a background proc which means you have no good way of knowing when you actually get to the destination. Looks like you'll have to do a little more work then for step two. Let's scrap that walk_to() line up there.

To do this, make a while loop that does two things: steps to the target (clicked) mob, and checks to see if you've gotten there - if the distance between you and the mob is 1.
    while (get_dist(usr, src) > 1 && step_to(usr,src))
sleep(4)

Put whatever delay you like in the sleep(). Ok, now we're ready to face the direction of the target mob. Easy, just use get_dir().
    usr.dir = get_dir(usr,src)

Make sure that's indented the same as the while() line, not the sleep() line.

That should work for simple cases. If you need more complex pathing (lots of obstacles) or more constraints (for example, don't allow diagonal movement) you might look at using Deadron.PathFinding.