Step 1: Find the centroid of the triangle.
The centroid of a triangle with vertices
\[
(x_1,y_1,z_1),\quad (x_2,y_2,z_2),\quad (x_3,y_3,z_3)
\]
is
\[
\left(
\frac{x_1+x_2+x_3}{3},
\frac{y_1+y_2+y_3}{3},
\frac{z_1+z_2+z_3}{3}
\right).
\]
Here, the vertices are
\[
(4,p,-3),\quad (-1,-1,2),\quad (3,5,-8).
\]
So, centroid is
\[
\left(
\frac{4-1+3}{3},
\frac{p-1+5}{3},
\frac{-3+2-8}{3}
\right).
\]
\[
=
\left(
2,
\frac{p+4}{3},
-3
\right).
\]
Step 2: Find the midpoint of the given points.
The midpoint of
\[
(1,4,-2)
\]
and
\[
(q,2,-4)
\]
is
\[
\left(
\frac{1+q}{2},
\frac{4+2}{2},
\frac{-2-4}{2}
\right).
\]
\[
=
\left(
\frac{1+q}{2},
3,
-3
\right).
\]
Step 3: Equate the centroid and midpoint.
Since both are equal,
\[
\left(
2,
\frac{p+4}{3},
-3
\right)
=
\left(
\frac{1+q}{2},
3,
-3
\right).
\]
Comparing \(x\)-coordinates,
\[
2=\frac{1+q}{2}
\]
\[
4=1+q
\]
\[
q=3.
\]
Comparing \(y\)-coordinates,
\[
\frac{p+4}{3}=3
\]
\[
p+4=9
\]
\[
p=5.
\]
Step 4: Find \(p^2+q^2\).
\[
p^2+q^2=5^2+3^2
\]
\[
=25+9
\]
\[
=34
\]
Step 5: Final conclusion.
Therefore,
\[
\boxed{34}
\]