There is a way to avoid any car collision outside the pits but if the pit event is triggered early in the lap, that would lead to strange behavior. Could surely be limited to close positions to pit lane but you'd have to compute it each frame since the pit event has been triggerd. So I would check how the track pitAIline is designed before ;-)
some tests with AC/CSP AI in lua
Updated to 0.03 because forgot yesterday to add the part where the lapped AI can retrieve its AI spline with full throttle
I made further tests still with MP 4/4 on Monza 1988 and saw decent things.
Seems the parabolica doesn't work well , I'll investigate the value returned by getTrackUpcomingTurn for this particular turn. But overall , many situations where the AI goes right or left and slow, then retrieves its spline just after.
Never had a crash where the AI would get back to my position suddenly while I'm overlapping (altough its lateral move is still a bit sharp I think).
I was able to assess the situation where I was arriving to overlap a train of cars and it did not produce any crash, they just made their lateral move and slowed. Still some situations where some lateral move and slow and other just slow so the train still use most part of the track and you have to find your way between them.
Also I'm not sure the isInPitLane works strictly, I mean, it is possible it is a wider area than the strict pitlane and as such it may explain my impression in several situations while overlapping in the starting/finish straight.
Well, I need more returns with different cars and tracks !