Step 1: Differentiate the functional equation
Differentiate once:
\[
f'(x)=-2+\int_0^x(-f(t))\,dt
\]
Differentiate again:
\[
f''(x)=-f(x)
\]
Step 2: Solve the differential equation
\[
f''+f=0
\Rightarrow f(x)=A\cos x+B\sin x
\]
Using \(f(0)=1\) and \(f'(0)=-2\):
\[
A=1,\ B=-2
\]
\[
f(x)=\cos x-2\sin x
\]
Step 3: Find critical points of \(g(x)\)
\[
g'(x)=(f(x)+2)^5(x-4)^6(x+12)^7
\]
Critical points:
\[
x=4,\ x=-12,\ f(x)+2=0
\]
\[
\cos x-2\sin x+2=0 \Rightarrow x=\frac{\pi}{2}
\]
Step 4: Nature of extrema
\[
(x-4)^6\ \text{even power},\quad (x+12)^7\ \text{odd power}
\]
Hence:
\[
\text{Local minimum at }x=-12,\quad
\text{Local maximum at }x=4
\]
\[
p=-12,\ q=4
\]
Final Answer:
\[
\boxed{8}
\]