And so, thanks to Takeda's scream, a passing boat noticed them, and they were saved without incident.

Literal

This-way Takeda [gen-の] scream [with-で] passerby [gen-の] ship [to-に] noticed [received-てもらえ], incident-nothing obtained [polite-ました].

通りすがりの 'passing by / passerby' is a relative clause formed from the compound verb 通り過ぎる variant. ~てもらえ (potential of ~てもらう) means 'was able to have them notice (for our benefit).' 事なきを得る is a set expression meaning 'to get through without incident / be saved from disaster.' こうして 'in this way' wraps up a narrative sequence.