#1) How to hit a robot with a cannon round:
<< start code >>
// calculate the time needed for a shot to hit the target at it's current range
value13 = distance_to_target / kSpeedCannon;// time_to_target
// calculate how far the target moved last frame
vec_diff(value17,target_pos_vec,value14); //vec_delta = target_pos_vec - old_target_pos_vec
// normalize the vector by the change in time
value20 = 1/time_delta;
vec_scale(value17,value20); //vec_delta = vec_delta / time_delta
// calculate estimated location of target in the time it takes for the shot to reach it
vec_scale(value17,value13);// vec_delta = vec_delta * time_to_target
vec_add(value17,target_pos_vec);// est_shot_loc = vec_delta + target_pos_vec;
// store the current target pos in value14,15,16 for use in next calculation
vec_set(value14,target_pos_vec);
<< end code >>
Of chores this only works if your target is moving in a straight line, but it will improve your aim. Or you can just calculate the target's speed, wait until it stops (i.e. it hits a wall) and then fire.