Sounds like you need to figure out a formula for all the variables that result in a hit (probably distance from target in relation to angle, power etc). In other words, your formula should look a bit like:
If [distance from target] is X, then set [angle] to Y and [power] to Z - where Y and Z are expressed in terms of X.
And then maybe stick some random variables in so the AI doesn't score a perfect hit every time!
If you upload a capx of what you've got so far I'll have a look.