Lolz yea.... hope nobody take offence.... iz just geme
anyway no prob I hope you can find a way to integrate it into your game.
Just FYI
1)you can mess with the velocity and gravity but if out of range it may not be able to calculate properly so I would maybe have the enemy just face the player until within a certain range that you know works then run the calc.
2) You can take out the choose and just replace with + or - depending if you want the high or low trajectory
3) probably best not to make trails using bullet step like that it will kill perforamce just did it for the effect.
4)sorry (edit) one more thing i just realised. the calculation is made from the pivot point of the "cannon" but the bullet is fired from the end of the "cannon" . you want these points to be as close as possible for best accuracy, i.e. if you had a long cannon where the pivot and exit are far apart you may start missing the target as the length of the cannon is not considered in the calculation. in fact it is best if they are the same point.