ID:1970732
 
(See the best response by Kaiochao.)
Code:
I am trying to make an enemy for my game that attacks only in a straight line directions and includes the truest northeast southeast southwest and northwest directions. I made a little picture to explain how I'm trying to make it work.

M = Mob
T = Target Spot, Use ability if enemy is in T location.
X = False Do use ability if the enemy is in X location.

T X X X T X X X T
X T X X T X X T X
X X T X T X T X X
X X X T T T X X X
T T T T M T T T T
X X X T T T X X X
X X T X T X T X X
X T X X T X X T X
T X X X T X X X T


My head hurts from thinking about this a little too much and would appreciate some insight on how to go on about this. Thanks in advance!
Best response
The target is on a diagonal line if abs(dx) == abs(dy), where dx is the difference in x and dy is the difference in y.

The target is in a cardinal direction if get_dir(M, target) is a cardinal direction, d & (d - 1) == 0, or either dx or dy are zero.
Thanks mate! I totally forgot about the abs proc. Could definitely rewrite a few things. (Y)