ID:156929
 
Hey, it's been a while, so I pretty much forget my DM.. Umm, I want to be able to check if a mob is in the direction youre facing, and in your view. I don't even remember how to check if a mob is in your view, it's been way too long (But I know I can easily remember everything with some help). The direction youre facing thing is the most important, and I have never done anything where you check for something in the direction youre facing.

Basically, I need something that will check if there is a mob in the direction youre facing, AND in your view (so you dont effect things across the map). I can easily tell which mob it is and everything.. Man I can't believe I forgot so much (Although I'm not sure if the direction thing is even possible without checking for x and y).

So uhh, yeah.. I hope you can understand?
var/mob/M
if(usr.dir == get_dir(usr,M) && M in view())
In response to Albro1
I am still getting negative results.
In response to Xyphon101
Aah, sorry. Forgot.

Instead of view(), do view(,usr)

Or src, if you are using a proc.
In response to Albro1
EDIT: I fixed everything, but there is a problem, it either reads only one, or all of them at once, depending on if I put return or not. If all at once it will say "You have failed" and you have succeeded at the same time, if only one, it may say "You have failed" because it thought you were trying to use it on another enemy.
In response to Albro1
Albro1 wrote:
Instead of view(), do view(,usr)

The two are equivalent. view() and related procs accept arguments in either order.
In response to Xyphon101
It checks the closest mob first, so if it finds all of them, without the return, then it will give you a result of multiple fails and any number of successes (for those mobs in the field of view).


As such when checking and using a return it will stop at the first mob in your view, the closest one to you, so It'd be best to look at all of them and only return the one that can be seen. so, if it succeeds, then return the mob, if it fails, continue to search through the mobs in your view, until it comes to the end of the list. Then, if none of them are in your view, it will return as failed.