function getSmoothRotation(t)local s=t[1]local P=t[2]local G=tankStats.GunHandling.GunDepression.Value local W=tankStats.GunHandling.GunTraverse.Value if math.abs(s)>G then s=G*sign(s)end if math.abs(P)>W then P=W*sign(P)end local f=s-currentElev if math.abs(f)<.01 then currentElev=s else currentElev=currentElev+.01*sign(f)end local g=P-currentRot local U=tankStats.GunHandling.TurretSpeed.Value if math.abs(g)<U then currentRot=P else currentRot=currentRot+U*sign(g)end local B={}B[1]=s B[2]=P return B end
-- Using the desired target rotation and elevation, determine where the gun should point right now (smoothly turn)
function getSmoothRotation(rotations)
	local targElev = rotations[1]
	local targRot = rotations[2]

	local maxGunDepression = tankStats.GunHandling.GunDepression.Value
	local maxTraverse = tankStats.GunHandling.GunTraverse.Value

	-- Restrict the height of travel of the gun
	if math.abs(targElev) > maxGunDepression then
		targElev = maxGunDepression * sign(targElev)
	end

	if math.abs(targRot) > maxTraverse then
		targRot = maxTraverse * sign(targRot)
	end

	-- Once target angles are set, slowly turn turret towards them
	-- Elevation
	local elevDiff = targElev - currentElev
	if math.abs(elevDiff) < 0.01 then -- If they're close
		currentElev = targElev
	else -- Move towards it
		currentElev = currentElev + 0.01 * sign(elevDiff)
	end

	local rotDiff = targRot - currentRot
	local turretSpeed = tankStats.GunHandling.TurretSpeed.Value

	if math.abs(rotDiff) < turretSpeed then -- If they're close
		currentRot = targRot
	else -- Move towards it
		currentRot = currentRot + turretSpeed * sign(rotDiff)
	end

	-- Put rotation and elevation into an array
	local rotations = {}
	rotations[1] = targElev
	rotations[2] = targRot

	return rotations
end
