I really hate it when that happens. I just found out why my reworked war code occassionally crashed while creating a ship. It has nothing to do with my code of course, but with what I repurposed from the original war code from Egosoft
Just in case you ever encounter the "!lib.get.randomshiptype" script be aware it misses an important fallback. In case there is no ship Type matching the chosen race + class combination it quite literally kills itself.
The example I encountered was:
$shipType = [THIS]-> call script '!lib.get.randomshiptype' : a.race=[ATF] a.class=[M8] a.blocked=null a.onlyFirst=[TRUE]
Apparently The ATF doesn't have no love for bombers. Why the original war code worked? ... I'm glad you asked sunny jim. Because for some totally random reason they don't create M8s in the war scripts. I guess I just found out why
The fix is easy though. All you need to do is add "return null" at the end of the '!lib.get.randomshiptype' script and you're safe .