ID:159777
 
I'm using shadowdarke's pixel projectiles lib so it looks like this so far

obj
Turret
New()
.=..()
spawn(1)
Attack()
proc/Attack()
FireSpread(src, src:target, src:bullettype, src:pellets, src:spread)
spawn(30)
Attack()


How do I get the object to target anyone on another team by itself and stop targeting them when the user is out of range?
    proc
target(mob/M in oview())
if(!M in oview())
return
else
Attack()


For that to work you need to change attack from a verb to a proc and call it from the verb:

verb
attack()
Attack()
In response to Hi1
You need parentheses in there.

if(!M in oview())
//to
if(!(M in oview()))
Don't use :, ever. Typecasting and . are the better alternatives, as they will give you compiler errors, rather than potentially game destroying runtime errors. You can even type cast internal types if you really wanted to.

appearance/var
icon
icon_state

mob/verb/Change_All_Overlays_Icon_State(t as text)
for(var/appearance/A as anything in overlays) A.icon_state = t


Note that the as anything is necessary here because overlays don't have a user accessible type and for() filters by type.
In response to Hi1
No usr in proc.
In response to Mizukouken Ketsu
Note that oview() and other related procs default to usr, not src, so you may have problems with that.
In response to Jeff8500
So toss 'src' into the oview() function :)