Finding vectorToAngle opposite

This seems like it should be simple but it's driving me nuts. I worked for a while to get a vectorToAngle formula that allowed an actor to fire bullets at the mouse cursor, and eventually used this one (http://gamesalad.com/forums/topic.php?id=8090) plus the camera offset that works great. It's basically:
vectorToAngle( self.MouseX - self.Position.X + game.camX , self.MouseY - self.Position.Y + game.camY )
Problem is, I'm now trying to set up a mode that fires bullets in the complete opposite direction (directly away from the mouse), and while I remember setting up that way back when I was playing around with the formula before, I can't seem to get it again.
I've tried going negative vectorToAngle, subtracting and adding 180 from the angle, switching the (mouse-position) parts of the formula (that seemed most likely -- I'd want to create a vector from mouse to the actor, no?), and even adding instead of subtracting the camera offset. Nothing I do will send a bullet in that opposite direction. Math guys, what am I doing wrong?
vectorToAngle( self.MouseX - self.Position.X + game.camX , self.MouseY - self.Position.Y + game.camY )
Problem is, I'm now trying to set up a mode that fires bullets in the complete opposite direction (directly away from the mouse), and while I remember setting up that way back when I was playing around with the formula before, I can't seem to get it again.
I've tried going negative vectorToAngle, subtracting and adding 180 from the angle, switching the (mouse-position) parts of the formula (that seemed most likely -- I'd want to create a vector from mouse to the actor, no?), and even adding instead of subtracting the camera offset. Nothing I do will send a bullet in that opposite direction. Math guys, what am I doing wrong?
Comments
I'm sure there's a math-y way to get the opposite vector to angle, but a negative velocity seems to work just as well. Thanks anyway! Going to leave the topic here for anyone who might need it in the future.