ID:155166
 
How would I do this? I can see making the mob shooting a projectile once, but how do I get it to loop while the player is in front of it or behind it?
I won't program it I'll say it.

*DM*
If the players (P) is in src's oview (make sure you check that), then if P is get_dist (a certain distance away), you'll shoot the blast every, say, 1 to 5 seconds, you choose.
*DM*

There is probably a better way. But I hope this helps you figure out how to program an NPC shooting projectiles at a player.
In response to A. Ness (#1)
Ness that cycles through everyone in view, not a particular direction. To get only mobs above or below, I think you'd have to do something like this:

mob/NPC/proc/Look_Around()

if(target) // If the NPC has a target
return // stop the proc

for(var/mob/M in view())
if(M.y == src.y && get_dist(src, M) < 6) //you can add "&& M.x == src.x" if you sideways shooting as well
// If the "Up" and "Down" of the mob in view is equal to the NPC's Up and Down.
// And if the distance between the NPC and the mob in view is under 6 tiles

target = M // You target the mob

src.dir = get_dir(src, target) // NPC faces the mob which is now the target.

AI_Fire() // This proc is where you do your snazzy projectile stuff.


I spaced it out so it wouldn't look so cluttered.

This doesn't give you the perfect AI code, but shows you how to do what your trying to do.

Learn get_step and get_dist from "Help On..." under the Help tag in Dream Maker. I tried to explain it so you'd understand what everything does. Correct me if I'm wrong about anything Byondlings.