ID:153389
 
Well I decided to start back up on game design with BYOND, now having some free time, and I was figuring out a projectile system. What I want is for a missile to launch from the player to the target's position, but not to the target directly (Giving them a chance to move and everything, even if they are targeted), and I came up with this.
obj/seeker
icon='seeker.dmi';density=1
Bump(mob/M)
..()
view(M)<<"[M] was hit by the [src]"
//Damage stuff here
del(src)
Del()
view()<<"[src] explodes!"
//More damage stuff here
..()
//Now this is where the missile launches at the victim's position
proc/track(mob/M,X,Y,Z)
do
sleep(1)
step_towards(src,locate(X,Y,Z))
if(get_dist(src,locate(X,Y,Z))==1)
if(M.loc==locate(X,Y,Z))
Bump(M)
while(get_dist(src,locate(X,Y,Z))!=1&&src)


The reason I made my own is because missile() launches directly at the victim or won't bump into them if they cross paths, and walk_to() won't call bump()... It only hovers around the spot until the victim moves from it. I wish to know if there is a more efficient way I can do this, to cut down on any lag this would produce having at least 30 people doing it at the same time.

Thanks
~Ken~
for my monsters, I use a proc that is a mix of step_to() and step_towards(). it's basically below:
proc
special_walk_to(mob/M,atom/moveable/A,wait)
if(A in oview(1,M)
step_towards(A,M)
else
step_to(A,M)
sleep(wait)
spawn()
special_walk_to(M,A)


I think that would work. It would walk the obj to the mob, and then when it was next to it, use step_towards to make it call bump(). I think....
Using step_to() or walk_to() will cause the object to avoid obstacles, which is why it won't call Bump(). You can just use walk_towards() in place of your tracking procedure, but your projectiles will not move in anything vaguely resembling a straight line; since this is apparently supposed to be a homing weapon (even if it's intended to be an imperfect one), that's not a huge deal, but it would look really ugly for a plain projectile weapon.
obj
Project
Fireball
verb
Shoot()

var/x = usr.loc
sleep(Level)
missile(new/obj/Fire,src,x)
if(usr.loc == x)
..()
else
//damage
Its crude I know but it works.
Basicly if the user is not where it was it dont get hurt.You could improve this somewhat but somthing I made a while back.