Diagram:
Legend: @ = Opponent % = monster + = cardinal directions (rook view)
+
+
+
++++++++++@++++++++++++
+
+
% +
+
+
+
Basically, I want % to step three tiles up so it hits the imaginary line.
~~> Dragon Lord
ID:268728
Nov 1 2004, 12:45 pm
|
|
Is there a simple way to figure out a way to find out which turf in a list is the closest item there is without taking diagonal steps? I want to create an AI which would step to a cardinal line from an opponent.
Diagram: Legend: @ = Opponent % = monster + = cardinal directions (rook view) Basically, I want % to step three tiles up so it hits the imaginary line. ~~> Dragon Lord |
Just check the x/y co-ordinates for the various mobs, and then move the mob accordingly. Eg.
Monster is at (3,5,1) and Player is at (6,3,1)
With the x-values, 3-6 = -3, or just 3 for distance.
With the y-values, 5-3 = 2
After this, just check the distance between the two results, and them move the monster accordingly. So we would make the monster move south in this to get it in a cardinal line from the player.