ID:142015
 
Code:
mob
turret
name = "Turret"
icon = 'turret.dmi'
New()
serp
icon_state = ""
src.health = 100
src.isplayer = 0
src.race = "Turret"
density = 1
src.turretisauto = 0
src.frozen = 1
for(var/mob/M in oview(12))
if(istype(M,/mob/zombie/))
if(src.turretisauto == 0)
src.icon_state = "attack"
oview(12) << sound('autodef.wav', 0)
src.turretisauto = 1
oview(12) << sound('turretfiring.wav', 0)
src.dir = get_dir(src,M)
if(istype(M,/mob/zombie))
var/damage = 10000
M.health -= damage
if(M.CheckDeath())
M.Death()
goto serp
else
src.icon_state = "attack"
oview(12) << sound('turretfiring.wav', 0)
src.dir = get_dir(src,M)
if(istype(M,/mob/zombie))
var/damage = 10000
M.health -= damage
if(M.CheckDeath())
M.Death()
goto serp
else
return


Problem description: THe turret is supposed to shoot all the zombies in its oview(12) but they never even change icon_state so can someone help?

Three problems with this:
1) Never, ever, ever, ever, ever, ever, EVER use goto.
2) Use Boolean logic.
3) The last else return bit is unnescesary.
In response to Popisfizzy
why dont use goto? what should i use?
In response to SadoSoldier
A real loop such as for or while.

George Gough
In response to KodeNerd
Or recursion.
In response to Popisfizzy
Good point though I consider it a type of loop.

George Gough