proc/WeakHoming(obj/projectile,mob/target)
projectile.destination = target
//save the location of the target, and head for it
//if the target moves in the next few ticks, it will remain headed for that location
var/x = 8
while(p&&x)
x--
step_towards(projectile,projectile.destination)
sleep(0.35)
//after 8 loops, it stops seeking that location, and heads in a straight line
walk(projectile,projectile.dir)
Problem description:
So this function works to sent a projectile towards the target, and ceases homing after 8*0.35 ticks, and then goes in a straight line from there on out.
The goal was to have a projectile aimed at a target, but allow the target the opportunity to use skill to evade. I figured the best way to achieve this was to do the above. But I can't get the movement to be 'natural', the above code can miss stationary targets if the step_x/y are unfavourable, and the distance is far enough.
Other attempts I've made end up with the projectile being too precise, or other undesirable results.
There must be a better way to have the projectile vaugely find its way to the target? Something like, perfect homing for 30% of the distance -> homing for where the target is now standing (in case theyve moved since you created it) -> once it reaches that destination, it will travel in a straight line given the angle it is currently travelling based on its trajectory from the 30% distance mark...
help?
You have a few options for your home-and-forget strategy. One is to give it so many ticks, like you said. Another is to reduce turn_speed gradually until it reaches 0, so homing is strongest in the beginning but gets weaker.
You can take another approach that uses acceleration, which is kind of cooler. In this case your projectile's speed isn't fixed.