var
radarrange = 38 //Increasing the range pretty much has a zoom out effect while decreasing it has a zoom in effect. I find 16 to be the most balanced.
radarupdate = 7 //This var is the amount of ticks it waits in between each radar update.
proc
radarupdate()
for(var/obj/HUD/Pointer/O in world) //delete every pointer object in the world.
del O
for(var/mob/M in world) // I've tried range(radarrange,M) for this instead of world. It made the radar behave very wierdly.
if(!M.client) continue
for(var/obj/dragonball/N in world)//range( radarrange ,M))
if(N.z != M.z) continue//Checks Z layer.
if(N == M) continue
//if(N.team != M.team) continue //uncomment this line to make enemies NOT show up on radars
var/r = ((((N.x - M.x)**2)+((N.y - M.y)**2))**0.5) // This nasty piece is the distance formula. It gives me the distance between the two mobs.
if(round(r) > radarrange) continue// I use the distance and make sure it isn't more than 16 units away
var/obj/HUD/Pointer/O = new()
var/x = (N.x - M.x) * round(48/round(radarrange))
var/y = (N.y - M.y) * round(48/round(radarrange))
M.client.screen += O
//if(N.team == M.team) O.icon_state = "ally" //This makes use of a mob var to change the icon of the "Pointer objects."
//else O.icon_state = "enemy"
O.icon_state = "ally"
O.pixel_x = x
O.pixel_y = y
O.screen_loc = "WEST+1:[O.pixel_x],NORTH-1:[O.pixel_y]" // This part just makes the pointers move around on all 9 tiles of the radar
if(get_dir(M,N) == NORTHEAST)
O.pixel_x -= 32
O.pixel_y -= 32
O.screen_loc = "WEST+2:[O.pixel_x],NORTH:[O.pixel_y]"
if(get_dir(M,N) == SOUTHWEST)
O.pixel_x += 32
O.pixel_y += 32
O.screen_loc = "WEST:[O.pixel_x],NORTH-2:[O.pixel_y]"
if(get_dir(M,N) == SOUTHEAST)
O.pixel_x -= 32
O.pixel_y += 32
O.screen_loc = "WEST+2:[O.pixel_x],NORTH-2:[O.pixel_y]"
if(get_dir(M,N) == NORTHWEST)
O.pixel_x += 32
O.pixel_y -= 32
O.screen_loc = "WEST:[O.pixel_x],NORTH:[O.pixel_y]"
if(get_dir(M,N) == NORTH)
O.pixel_y -= 32
O.screen_loc = "WEST+1:[O.pixel_x],NORTH:[O.pixel_y]"
if(get_dir(M,N) == SOUTH)
O.pixel_y += 32
O.screen_loc = "WEST+1:[O.pixel_x],NORTH-2:[O.pixel_y]"
if(get_dir(M,N) == WEST)
O.pixel_x += 32
O.screen_loc = "WEST:[O.pixel_x],NORTH-1:[O.pixel_y]"
if(get_dir(M,N) == EAST)
O.pixel_x -= 32
O.screen_loc = "WEST+2:[O.pixel_x],NORTH-1:[O.pixel_y]"
//world<<"[N]:[N.x],[N.y]. Range:[r]. Dist:[get_dist(M,N)]. Me:[M.x],[M.y]"//debug message
spawn(radarupdate) radarupdate() //restart the loop!
Ive been using darksabers Radar Demo and ive tryed making it into a 10 by 10 radar for a bigger range but i cant figure out how. A point in the right direction and an explination of which line makes it 3x3 and how it works would be appreaciated, or if u want u can just do it for me. :)