ID:164659
 
Right, So as the title Says Targeting I have a simple system for when you click someone it adds them to your target list.. But, If more than one person is clicked it stacks I need it to take off the mob when another Mob is clicked and if possible add an overlay that can only be seen to the user (I've never been good with Images)


mob
var
list
mob
targets = new/list()
target = 1

Click()
if(istype(src,/mob))
if(src.target)
if(src in usr.targets)
usr.targets -= src
else
usr.targets += src

Thanks if you can help ^_^
I just happened to have been working on the same thing only 4 days ago. I used lists and the code is as follows:-

mob
var/tmp
targets[1]
oldT
newT
mob/enemy
enemy_marker
target_icon = 'target.dmi'

client
Click(M)
if(istype(M,/mob))
call(usr,/mob/proc/Target)(M)
else
if(usr.newT)
var/mob/P = usr.newT
var/p = P.targets.Find(usr)
if(p) P.targets.Remove(usr)
del usr.enemy_marker

..()

mob
proc
Target(mob/M)
if(src.newT)
var/mob/P = src.newT
var/p = P.targets.Find(src)
if(p) P.targets.Remove(src)
del src.enemy_marker
src.target_icon = 'target.dmi'
src.enemy = M
src.enemy_marker = image(usr.target_icon,M)
src << usr.enemy_marker
M.targets.Add(src)
if(src.newT) src.oldT=src.newT
src.newT=M


This gives every mob a list of players that have it targetted.

NewT and oldT are used to make a note of what was last targeted, so u can remove your self from the list of players that has it targeted. It may not be exaclty what you want but it should give you a good indication of what to do.



(Supaz)
In response to Supanova
Kudos, Thanks alot was kinda stuck with that but you solved everything ^_^