Dynamic Rotation Limitation

Hello fellow Blender users:
I am making a tank in Blender Game using Logic Blocks, and I am running into some trouble. I am limiting the amount the gun barrel can travel to -9 degrees. However, at this setting, the gun clips through the rear of the hull. Is there any way I can change the y-limit of the gun barrel’s travel based on the x-rotation value of another object?