
This explains the problem: If the target is close enough to the turret the heading reported by AimWeaponX is off since it reports the angle between the muzzle of the turret and the target, the turret then rotates around its base which changes the angle between the muzzle and the target. The angles in this pic are exaggerated but for the engine there's no difference: If the turret turns past the target before the next aim call happens, the next call will make it turn in the opposite direction which makes it move back to its previous rotation and back and forth. At larger distances the series of headings converges and at some point the turret will point at the target (and usually the difference between two headings will be small enough to let the turret reach them before the next AimWeapon call happens and thus shoot) but at shorter ranges this will mess up. If you've played Kernel Panic's older versions you probably know the trick where you send a bit right into a byte and the byte's aiming code screws up, making it shake back and forth but never shoot. The same can be observed in mods with units that have gunds that stick out, e.g. Gundam's mechs with rifles.
The solution is simple: Do it like OTA and make AimWeapon report the angle between the AimFromWeaponX piece and the target, usually the AimFromWeapon piece will be the turret base and thus not move as the unit is aiming and have enough distance from the target to report the right angle the first time.