Step 1: Use powers of \(i\).
We know that
\[
i^1=i,\quad i^2=-1,\quad i^3=-i,\quad i^4=1
\]
The powers of \(i\) repeat after every \(4\) powers.
Step 2: Simplify \(i^{18}\).
\[
i^{18}=i^{16}i^2
\]
Since
\[
i^{16}=(i^4)^4=1
\]
therefore,
\[
i^{18}=i^2=-1
\]
Step 3: Simplify \(-3i^7\).
\[
i^7=i^4i^3
\]
Since
\[
i^4=1
\]
and
\[
i^3=-i
\]
we get
\[
i^7=-i
\]
Thus,
\[
-3i^7=-3(-i)=3i
\]
Step 4: Simplify \(i^2(1+i^4)(i)^{22}\).
Since
\[
i^2=-1
\]
and
\[
i^4=1
\]
we get
\[
1+i^4=1+1=2
\]
Now,
\[
i^{22}=i^{20}i^2
\]
Since
\[
i^{20}=(i^4)^5=1
\]
therefore,
\[
i^{22}=i^2=-1
\]
So,
\[
i^2(1+i^4)i^{22}=(-1)(2)(-1)=2
\]
Step 5: Add all simplified terms.
Now,
\[
i^{18}-3i^7+i^2(1+i^4)i^{22}
=
-1+3i+2
\]
\[
=1+3i
\]
Step 6: Final conclusion.
Therefore,
\[
\boxed{1+3i}
\]