ID:162659
 
Well I have been looking at the dm guide a lot lately, due to some massive recoding, but as I start rebuilding my AI system, I wanted to figure out how to turn the NPC towards a player. I understand the get_dir() proc and turn, but the turn proc doesn't offer what I'm looking for. It needs an angle to turn it. Now I have thought of several ways to do this by making other procs but they are far too complex to be server-friendly.

Any suggestions?
If you understand get_dir(), you would be able to do it.

Self.dir = get_dir(Self,Target)


get_dir(A,B) returns the direction where B is from A

Therefore, the dir of 'Self' now becomes where 'Self' looks at 'Target' (diagonals are a different story >_>)
In response to GhostAnime
I should have been more clear. I wanted to find a way to align them one the same x line or y line depending on their direction, then make them face the player. Now, I can make them face it, because the turntowards proc works. But aligning them is more difficult. I have something made up but for some reason the npcs don't appear to even use the proc, although it is called. Im going to do some more testing with this and repost again if nothing turns up.
In response to SS10trunks
Hm, let me see if I get what you want:

1) You want it to precisely look at the person at whatever angle it may be at, even diagonally (at the person, not near the person)

2) You want it to look at the person only if they match to either the same X or Y (in other words, no diagonals)

If it's one or neither of those two, let me know. I already thought of a few ways to help you with.

Don't forget, there's 2 different first argument for the turn(X,Y) procs:

If X is a dir value, it'll return the dir to one of the 8 (N,S,E,W,NE,NW,SE,SW), not to a specific angle [the angle in the DM ref helps determine which of those general 8 dir it'll choose... ex: 180 degrees of SOUTH will return NORTH]

if X is an icon, it'll turn the icon to the angle entered (or calculated ;/)