ID:154929
 
Hello, i wanna know a code to check how much mob/obj are in the usr oview(x)... and i wanna pick the far less as my target(the verb of target is ok, is just bugging when have two or more mob in the oview and the distance is the same)... and if the distance of both mob/obj is the same, i wanna pick the direction of location x (not the same x in the oview(), x as x in map, you know...).
Karrasko wrote:
Hello, i wanna know a code to check how much mob/obj are in the usr oview(x)...

for(var/atom/movable/target in oview(arguments))


Loop through all of the mobs/objects in your <code>oview()</code>.

Tell me what your second want is, I don't read it clearly.
In response to Neimo
Well, i want to check if the NPC1 is closer than the NPC2, of the character... and then pick the NPC1 as the target...

If you know how i can check this, i maybe know how to pick the NPC as the target...
In response to Karrasko
Loop through mobs with <code>in get_dist(arguments)</code>, if no mobs are found within the first check, add on to a position that changes when no mobs are located.
In response to Neimo
Well, i don't understand ... how can i use get_dist(), is with numbers like get_dist(0,3)?
In response to Karrasko
<code>Format: get_dist(Loc1,Loc2) Returns: The distance between Loc1 and Loc2, in tiles. This is the number of full-tile movements (disregarding any obstacles and allowing diagonal moves) required to go from one to the other. Args: Loc1: An object on the map. Loc2: An object on the map. At this time, get_dist() never returns a value greater than 127.</code>
In response to Neimo
well, i'm trying to use
for(src in get_dis(usr,3))

but it isn't working.


I want to use the target system but when two mobs are in the same distance, the target system doesn't choose none of them.
I'd like the target system could choose one of the mobs randomly, and when I use the verb again it choose the other mob.
In response to Karrasko
You have not read over the reference-post I have provided for you.

Look over the <code>developer</code> guide to learn the basics of DM programming.
In response to Neimo
i have readed, but, i don't know, how to do it... with and without it... i think you don't know what i'm trying to say...


I want to use the target system but when two mobs are in the same distance, the target system doesn't choose none of them.
I'd like the target system could choose one of the mobs randomly, and when I use the verb again it choose the other mob.
In response to Karrasko
:P