ID:1725123
 
Is it possible to do what is in the title? My code works fine until the target is behind something opaque, and it becomes possible to attack it even when it's invisible.
fireball()
for(var/mob/enemy/Z in oview())
target = Z

if(target)
var/obj/weapon/arrow/I = new /obj/weapon/arrow(loc=usr.loc,dir=usr.dir)
walk_to(I,target,0,8)
spawn(100) del(I)
u
if(I.loc == target:loc)
del(I)
damage = rand(3,6)
target:HP -= damage
if(target:HP <= 0)
world<<"<b><SPAN STYLE='color: red'>[target] dies!</SPAN></b>"
var/obj/gold/G = new(target:loc)
G.amount = rand(1,30)
del(target)
else
sleep(5)
goto u


BTW, what can I use for detecting collisions with walls, when I can't set density to 1?
Cross would probably work with denseless objects. I suggest you also add a break in that for loop.
OK, I fixed it by adding
 
if(target)
target = null

and stopped them going through walls using Move().