ID:144591
 
Code:
        verb/Attack()
set src in oview()
for(var/mob/unit/M in view(arange))
M.overlays += image('misc.dmi')


Problem description: The above code is SUPPOSED to give the overlay to all units within arange (which is 5), but it's not.

What's wrong?

         verb/Attack()
set src in oview()
for(var/mob/unit/M in range(src,5))
M.overlays += image('misc.dmi')
In response to Dark Emrald
Speaking of ranges, just out of curiousity, is a circular range possible, like a radius of 5 instead of a block distance of 5?
In response to FireEmblem
range() already gives you everything in a radius - it's not a block.
In response to Jp
range() works as a rectangle rather than a circle.
In response to DeathAwaitsU
Returns:
A list of objects within Dist tiles of Center.


That's from the reference. You know what we call a list of objects within 'dist' tiles of 'centre'? A circle.

Also, the documentation states that range() is the same as view(), but without visibility concerns. View is a circle, too.

EDIT: Although view() is broken. I posted this in the Bug Reports forum before, this is just a warning - view() seems to ignore sight flags.

EDITEDIT: I was wrong. Testing it in DM/DS indicates that it DOES produce a rectangle.
In response to Jp
View is a circle? That's odd......then it's possible to set the view of the camera/world to be a circle instead of rectangle?
In response to FireEmblem
Upon further testing, view() and range() do produce squares.
In response to Jp
The reference says "You may use any valid view size, so an explicit view size such as "11x17" is also valid. ". 11x17 is a rectangle, not a circle. For further proof; here's a post from one of the developers of BYOND [link].
In response to FireEmblem
range() and view() are rectangles, not circles. I made a mistake.

But there are procedures floating around to draw circles, like the following procedure, from AbyssDragon's BasicMath library:

proc
distance(atom/M,atom/N)
return sqrt((N.x-M.x)**2 + (N.y-M.y)**2)

getcircle(atom/M, radius)
var/list/circle = list()
var/turf/T
for(T as turf in range(radius+3,M)) //The < 0.5 check is to ensure it has the same shape as
if(distance(T, M) < radius + 0.5) //a get_ring() of the same radius
circle += T
return circle


Although it can be done faster:

    getcircle(atom/M, radius)
var/list/circle = list()
var/turf/T
var/i1
var/i2
radius=(radius+0.5)*(radius+0.5)
for(var/turf/T in range(radius+3,M))
if(distsquare(T, M) < radius) circle += T
return circle
distsquare(atom/m, atom/n)
var/ix=m.x-n.x
var/iy=m.y-n.y
return ix*ix+iy*iy




In response to Jp
Interesting. Thanks.
In response to Dark Emrald
Ok, now what if I wanted to continue the code after the player clicked on one of the M's?