proc/Turret_Loop() // the loop begins
while(src)//while the mobs in range
src << sound('rocket1i.wav')
for(var/mob/M in range(src, 5))//detect how far away it is
M.overlays -= /turf/Explosions/one // if M somehow still has overlay delete it
var/obj/Weapon/O = new src.gun//define a var named o for the weapon the turret is using
O.dir = src.dir//face the direction of the turret
O.loc = src.loc//start at the turrets location
var/turf/D = M.loc//the turf the mob its attacking is on
while(O)//while the missle exists
step_towards(O, D)//go one tile towards the turf the mob was on
var/turf/Y = get_step_towards(O, D)//the turf the missle is on
if(!Y)//if their is no turf
del(O)//delete the missle
var/turf/X = O.loc//the turf the missle on again
if(X.density && X.type != /turf/Water)//if the turf isnt water and its density is 1
del(O)//blow the missle to smithereans
for(var/mob/N as mob in X)//detect if theirs a mob on the turf the missles on
M<< sound('r_exp3.wav')
M.Damage(N, O.damage)//give damage to the mob for how much damage the missle had
M.overlays += /turf/Explosions/one//make an overlay for the mob
spawn(4)//wait .4 seconds
M.overlays -= /turf/Explosions/one//delete the overlay
del(O)//delete the missle
if(O)//if the missles still there
if(O.loc == D)//the missle gets to the turf the mob was on
del(O)//delete the missle
if(O)//if the missle is still there
sleep(O.speed)//wait the number of time the missle takes to move
if(!src)//If the turret is destroyed delete the missle
del(O)
sleep(src.rate)
Whenever the turrent which is calling this proc is deleted the proc stops running.
[Edited this post to fix the closing DM tag; you forgot the slash. - Lummox JR]