The cosmic event horizon represents the furthest distance that light can travel due to the expansion of the universe. Or in other words, it represents the furthest distance which, when we send a light beam "now" the information can be received and send back to us in a finite amount of time. Further, then that distance, the light would never reach us back.
The only problem is that, the radius of the cosmic event horizon changes with respect to time. The reason is the change in the scale factor. The cosmological constant becomes dominant in the energy density while the matter density dilutes in time. In this sense scale factor also changes with respect to time and it affects the radius of the cosmic event horizon.
For this reason, the cosmic event horizon will increase a bit and will stop increasing likely in $\approx20$ billion years later at a distance of $\approx 17.5$ billion ly.
Proper distance to the cosmic event horizon is defined as,
$$d_{hor}(t_0)=a(t_0)\int_0^{\infty}cdt/a(t)$$
So we can reach to any oject near to the cosmic horizon. The distance to the cosmic horizon is defined as above. But if you wait until the galaxy leaves the cosmic event horizon then the distance calculations becomes easier (which its what we assumed). Because we will be the near at the cosmic horizon with respect to the galaxy. So this proper distance would be,
$$d_{hor}(t)=a(t)\int_t^{\infty}cdt/a(t)$$
So the total distance trip, in proper distance
$$D=d_{hor}(t_0)+d_{hor}(t)$$
$$D=a(t)[\int_0^{\infty} \frac {cdt } {a(t)}+\int_{t}^{\infty} \frac {cdt } {a(t)}]$$
where $t$ is the time it took to reach us the galaxy at near horizon.
And the scale factor
$$a(t)=(\Omega_m/\Omega_{\Lambda})^{1/3}sinh^{2/3}(t/t_{\Lambda})$$
for $t_{\Lambda}=\frac {2} {3H_0\sqrt {\Omega_{\Lambda}}}$
The first term represents the comoving distance to the cosmic event horizon and the second term represents the comoving distance between galaxy and earth. And in last to find the proper distance we are multiplying these values with $a(t)$.
To find the total time trip we just have to divide this distance by $c$,
$$T=\frac {D} {c}=a(t)[\int_0^{\infty} \frac {dt } {a(t)}+\int_{t}^{\infty} \frac {dt } {a(t)}]$$
So these are the general equations. The $D$ that I defined only represents the distance to the cosmic event horizon plus the returning distance.
There's no need to define a function $f(d,t)$ because you can send any object within the radius of the cosmic event horizon and you can wait until the galaxy is about to leave the cosmic horizon. And then you can send your space-ship back when the galaxy is about the cross the cosmic event horizon.
Since you are asking the furthest distance, the spacecraft can go furthest as the distance to the cosmic event horizon. I just added the returning distance to the equation.
But we can write an equation for that too. Lets suppose you wanted to go somewhere within the radius of the event horizon and then you wanted to wait until the galaxy crosses the event horizon.
So within the cosmic event horizon, pick a planet, measure the z and the proper distance to that planet is defined as
$$R=a(t)[\frac {c} {H} \int_0^z \frac {dz} {E(z)}]$$
I write the equation in terms of redshift(z) but not in time (t) because the redshift is the observable value.
Then the total trip distance would be
$$D=a(t)[\frac {c} {H} \int_0^z \frac {dz} {E(z)}+\int_{t}^{\infty} \frac {dt } {a(t)}]$$
For $$E(z)=\sqrt{\Omega_{\Lambda}+\Omega_m(1+z)^3+\Omega_r(1+z)^4+\Omega_{\kappa}(1+z)^2}$$
or simplified version for current values,
$$E(z)=\sqrt{0.69+0.31(1+z)^3}$$