ID:260034
 
What about instead of view,range, etc... inDirection()?

So you could say inDirection(5,Northeast,src) and it'd check all the squares northeast of the mob?

You can do this pretty easily without a built-in proc.

mob/verb/Say(t as text)
if(!text) return
for(var/mob/M in oview(5)) if(get_dir(src,M)==src.dir) M<< "[src]: [t]"


Something like that.
In response to CaptFalcon33035
eh ya, but I was more thinking one that wouldn't loop through all the turfs in the area (as that's kind of inefficient) and just check the ones straight to the northeast...

Since if you have 200 mobs in the world in a pathfinding check it'd be a pain in the butt if there was nothing TO the northeast and you had to check all the surrounding ones as well just to find that out.
In response to CaptFalcon33035
CaptFalcon33035 wrote:
You can do this pretty easily without a built-in proc.

> mob/verb/Say(t as text)
> if(!text) return
> for(var/mob/M in oview(5)) if(get_dir(src,M)==src.dir) M<< "[src]: [t]"
>


Minor problem there: This will count anything even slightly diagonal as entirely diagonal. For direction, you should probably use a loop with get_step():

proc/direction(atom/ref, dir, range)
. = list()
var/turf/T = ref
if(!T || isarea(T)) return
while(!isturf(T)) T = T.loc
for(var/dist=0, dist<=range, ++dist)
. += T
. += T.contents
T = get_step(T, dir)
if(!T) break

proc/odirection(atom/ref, dir, range)
. = direction(ref, dir, range) - ref


Lummox JR
In response to Jon Snow
Maybe something like:

mob/proc/Get_Mobs_North(max_dist as num)
var/list/mobs = new
for(var/dist=1, dist<=max_dist, dist++)
for(var/mob/M in locate(x, y+dist, z))
mobs += M
return mobs


That could've just as easily been a proc that read in a direction as a second argument, and searched the specified direction.

Aside from that, my example is less efficient than it could be, and I may have made some error/s. But the point I'm trying to make is that you don't have to loop through an entire area; you can loop just one direction.

Hiead
In response to Hiead
hmm interesting, never thought of doing it that way before. Thanks for the ideas :)