If you said which game/mod you were working on, I could go right there and pull up the code for you. Anyway, I am using the BFV T72 code as an example, because tank turrets are coded very similar in the Battlefield Series.
Take a look at the code for the turret:
CODE
rem *** T72Turret ***
ObjectTemplate.create RotationalBundle T72Turret
ObjectTemplate.networkableInfo T72TurretInfo
ObjectTemplate.attachToListener 1
ObjectTemplate.loadSoundScript Sounds/T54Tower.ssc
ObjectTemplate.geometry ve_T72_turret_m1
ObjectTemplate.hasCollisionPhysics 1
rem -------------------------------------
ObjectTemplate.addTemplate T72GunBase
ObjectTemplate.setPosition 0/0.3/1.175
ObjectTemplate.addTemplate T72MG_PCO1
ObjectTemplate.setPosition 0/0.75/-0.199
rem -------------------------------------
ObjectTemplate.maxSpeed 20/0/0
ObjectTemplate.acceleration 1000/0/0
ObjectTemplate.inputToYaw c_PIMouseLookX
rem *** T72GunBase ***
ObjectTemplate.create RotationalBundle T72GunBase
ObjectTemplate.networkableInfo T72GunInfo
ObjectTemplate.attachToListener 1
ObjectTemplate.loadSoundScript Sounds/T54GunBase.ssc
rem -------------------------------------
ObjectTemplate.addTemplate lodT72Cockpit
ObjectTemplate.addTemplate T72GunBarrel
ObjectTemplate.setPosition 0/0/-0.104
ObjectTemplate.addTemplate T72Camera
ObjectTemplate.setPosition -0.461/0.432/0.07
ObjectTemplate.addTemplate Driver_MG
ObjectTemplate.setPosition -0.367/-0.091/0.08
rem -------------------------------------
ObjectTemplate.minRotation 0/-20/0
ObjectTemplate.maxRotation 0/0/0
ObjectTemplate.maxSpeed 0/15/0
ObjectTemplate.acceleration 0/1000/0
ObjectTemplate.inputToPitch c_PIMouseLookY
First of all, you need to understand that most weapon systems are controlled by two rotational bundles.
The first one is in T72turret and it controls the left and right rotation of the weapon. But where is the code for the min and max rotation? It's not needed because it's unlimited. I know this because of this line:
CODE
ObjectTemplate.inputToYaw c_PIMouseLookX
( Yaw and the X axis are the horizontal rotation)
However, if you wanted the turret rotation to 90 degrees left or right you would add these lines:
CODE
ObjectTemplate.minRotation -90/0/0
ObjectTemplate.maxRotation 90/0/0
Now the T72 Turrent is linked to the T72GunBase which controls the up and down rotation (vertical rotation). Which is set in these lines:
CODE
ObjectTemplate.minRotation 0/-20/0
ObjectTemplate.maxRotation 0/0/0
The middle numbers are the vertical rotation settings. Try these settings to start and play with the numbers until you find the limits that you like:
CODE
ObjectTemplate.minRotation 0/-40/0
ObjectTemplate.maxRotation 0/45/0
If playing with bots don't forget to change the AI to match:
CODE
aiTemplatePlugIn.create ControlInfo T72Ctrl
aiTemplatePlugIn.driveTurnControl PIYaw
aiTemplatePlugIn.driveThrottleControl PIThrottle
aiTemplatePlugIn.aimHorizontalControl PIMouseLookX
aiTemplatePlugIn.aimVerticalControl PIMouseLookY
aiTemplatePlugIn.lookHorizontalControl PIMouseLookX
aiTemplatePlugIn.lookVerticalControl PIMouseLookY
aiTemplatePlugIn.throttleSensitivity -1.0
rem aiTemplatePlugIn.pitchSensitivity 0.021817
rem aiTemplatePlugIn.rollSensitivity -0.021817
aiTemplatePlugIn.pitchSensitivity 0.21817
aiTemplatePlugIn.rollSensitivity -0.21817
aiTemplatePlugIn.yawSensitivity -2.5
rem aiTemplatePlugIn.lookVerticalSensitivity 0.021817
rem aiTemplatePlugIn.lookHorizontalSensitivity -0.021817
aiTemplatePlugIn.lookVerticalSensitivity 0.21817
aiTemplatePlugIn.lookHorizontalSensitivity -0.21817
aiTemplatePlugIn.throttleLookAhead 1.0
aiTemplatePlugIn.pitchLookAhead 1.0
aiTemplatePlugIn.rollLookAhead 1.0
aiTemplatePlugIn.yawLookAhead 1.0
aiTemplatePlugIn.lookVerticalLookAhead 1.0
aiTemplatePlugIn.lookHorizontalLookAhead 1.0
aiTemplatePlugIn.throttleScale 1.0
rem *** Angle in radians ***
aiTemplatePlugIn.pitchScale 5.0
aiTemplatePlugIn.rollScale 5.0
aiTemplatePlugIn.yawScale 0.0020
aiTemplatePlugIn.lookVerticalScale 1.0
aiTemplatePlugIn.lookHorizontalScale 1.0
rem *** CHECK NONAI OBJECT.CON FOR THESE VALUES << Thanks devs for the reminder!
aiTemplatePlugIn.setCameraRelativeMinRotationDeg -360/-40/0 <<<< change this line to match
aiTemplatePlugIn.setCameraRelativeMaxRotationDeg 360/45/0 <<<< change this line to match
For the AI -360 and 360 represent unlimited horizontal rotational movement and -40 and 45 are the limits of the vertical rotational movement.