It seems to be related to walls and corners in some way, in that it shows the path clear when targetting but 'catches' the corner and explodes right next to you instead.
I was thinking a fix for this, and a bit of nicety in general, would be to have the 'Are you sure you want to target yourself?' prompt appear when you are included in your own area spell rather than just when you put the center of the spell on yourself - assuming that the check is more accurate than the targetting circle of course

Also, a minor, unrelated bug - if you target two or more creatures with piercing shot, it won't hit the furthest one unless you target a square beyond them. For example in the diagram below, if @ is the character and you target D, it will hit C and stop one square in front of D. Firing at the square on the other side of D will hit both of them.
@.........C..D..