There is nothing affecting a beam in space. Assuming you have a targetting system capable of making a straight line your movement or the other ships would make little difference (the speed of light thing).
Even assuming your sights are perfect on a rifle there is wind, gravity, and the...