Best way to find all mobs within a certain location? in Developer Help
|
|
I'm trying to think of the best way to find the location of mobs on the map, without using for(var/mob/M in world).
The mob (a player) can create two rows of objects that span an entire map, above and below them (see crude display below). These objects are dense, so as to trap other mobs inside. What id like to do is be able to find all mobs within that area between the two lines (so i can do something to those mobs).
(Y) (Y)
-----------------------------------
(P)
X
-----------------------------------
(Y)
So, (P) would have created the lines. And X would be the only one id want to find. The (Y) outside the lines would be ignored.
Previously, id created the objects below the player, and they were added to a list. Then i searched through the list of objects to find Mobs standing in the same turf location as those objects. This worked fine, but now i dont have objects covering where i want to find mobs. The objects just border it.
I dont want to span invisible objects either in this space, as the map is large (125x125) and that would be 1000's of objects.
My original idea was to do some sort of mob.y comparison, but that can change depending on what its taking the Y from.
Anyone think of a simple solution? My only other idea is to create a single non-dense invisible object in the middle of these lines, and then extrapolate the range from that. But then, what would i do, for(var/mob/M in ?) view? Could i do a view thats the map sized?? hmmm. Would be better than looping through every mob to check they are on the same level as me i guess.
Anyone have some better suggestions id love to hear them.
|