All you need is a firing script that makes the AI fire its weapon, and a script that turns the unit's weapon around. You could make your own firing script, or you can search for inkompetents simple firing script (inko_sfs).
To change the gun direction, use the setFormDir command, which I've used in the past for moving searchlights around, but you could also use it for a gun direction of static weapons.