If each pile is going to have more than $q$ stones, you might as well set aside $qx$ stones ahead of time in which to distribute $q$ to each pile; there is no choice involved in that procedure. The only choices left are how to distribute $n-qx$ stones to $x$ locations in which each pile has at least $1$ stone but less than $r-q$ stones. If the piles are ordered, respectively unordered, this amounts to counting integer partitions, respectively integer compositions, of $n-qx$ into $x$ parts each of size $
Using generating functions, these counts are given respectively by
$$[t^x w^{n-qx}]\left(\frac{w}{1-tw}\frac{w^2}{1-tw^2}\cdots\frac{w^{r-q-1}}{1-tw^{r-q-1}}\right), \qquad [w^{n-qx}]\left(\frac{w^{r-q}-w}{w-1}\right)^x.\quad$$
I doubt the first has a nice explicit form. Via Newton-Binomial expansion, the second is
$$(-1)^{n-(q+1)x}\sum_{t=0}^x (-1)^{(r-q)t}\binom{x}{t}\binom{-x}{n-(q+1)x-(r-q-1)t}.$$