My turret will not fire on enemies. It will follow them around (changing dir to aim at it) but it wont fire, heres the code can anyone tell me whats wrong?
turret
icon = 'Blue Tank.dmi'
icon_state = "btank"
name = "turret"
HP = 40
var/think_delay = 15
New()
..()
spawn(rand(1,think_delay)) AILoop()
proc/AILoop(mob/M)
for(M in oview(src)) break
if(!M)
spawn(think_delay) AILoop()
return
if(get_dist(src,M) > 5)
spawn(think_delay) AILoop()
else
var/D = get_dir(src.loc,M.loc)
if(istype(M,/mob/red))
src.dir = D
new/obj/blaser(src.loc)
for(var/obj/blaser/L in src.loc)
walk(L,src.loc,2)
spawn(think_delay) AILoop()
else
spawn(think_delay) AILoop()
ID:148944
![]() Aug 8 2002, 11:35 am
|
|
Thats good, but i dont want to use the missile proc. I want the person to be able to dodge the laser thingy. I really want to know why my code wont work.
|
Jotdaniel wrote:
new/obj/blaser(src.loc) The first two lines are completely screwed up. The only possible reason to loop through every laser at that spot--which is incorrect behavior--is because you didn't assign the new laser to L in the first place, as you should have. The correct code has been shown in enough places--even recently--that you should have no trouble finding it. Do a search on "projectile". Beyond that, the reason your laser isn't moving is because you're telling it to walk toward the spot it's already at (src.loc), so it won't ever move. Lummox JR |
Alatar