ID:143957
 
Code:
mob
DblClick()
if(src.client||src==usr)
return
if(src.owner==usr.key)
src.overlays-=image('Others.dmi',"owner")
src.owner=""
else
for(var/mob/M in world)
if(M.owner == usr.key)
M.overlays-=image('Others.dmi',"owner")
src.owner=usr.key
src.overlays+=image('Others.dmi',"owner")
turf
Click(turf/T)
for(var/mob/M in world)
if(M.owner == usr.key)
if(M.bussy)
return
walk_to(M,T)
sleep(2)
while(get_dist(M,T) >0)
sleep(2)


Problem description:

I'm making a RTS game and my current select0unit system is bugged. Can someone post link to better one?
The current one is too buggy and lame, it selects more then one unit, they get buggy while moving, ect.
mob
var
mob/Owner
image/IMAGE
selected = 0
list/Selected = list()
DblClick()
if(src==usr) return
if(Owner!=usr) return
else
if(src in usr.Selected)
usr.Selected -= src
for(var/image/I in usr.client.images)
if(I == IMAGE)
usr.client.images -= I
else
usr.Selected += src
IMAGE = image('Overlay.dmi',src,"Selected") // This would be the pointer, or whatever you use to mark the selected units
usr << IMAGE
..()
turf
Click()
for(var/mob/M in usr.Selected)
walk_towards(M,src,2)
..()

This allows you to select and move units.
Also, only >you< can see which units are selected.
NOTE: be sure to give the mobs an owner,, otherwise you won't be able to select/mvoe your units.
NOTE #2: I used walk_towards instead of walk_to, because when you have multiple units selected, and you tell them to mvoe using walk_to, only one mob will arrive at the turf, and the others will start to walk around him, trying to get into the turf. walk_towards doesn't include dense objects, so...

Well, if you have any doubts, contact me.
<font color=silver>[email protected]</font>
In response to Gooseheaded
Ty