official-antistasi-community / A3-Antistasi

Antistasi Community Version - work in progress - Discord https://discord.com/invite/TYDwCRKnKX
https://antistasi.de
Other
225 stars 156 forks source link

[Change Request]: Rework spacing of convoys #561

Open wurzel0701 opened 4 years ago

wurzel0701 commented 4 years ago

The convoy uses setVelocity to seperate the vehicles on spawn. This is not a good method to do that and will kill convoys if they spawn in too many vehicles. It does work for only a few vehicles, but thats not how it should work.

Improve spacing by sending vehicles directly on the path, while pushing helicopters a bit further

jaj22 commented 4 years ago

I think the velocity method is workable, but there are two serious problems with the current spawn code:

  1. Currently, drivers don't get any orders until every vehicle has been spawned, with a delay of at least 0.7 seconds per vehicle + 0.2 per crew/cargo. Depending on how different vehicles perform under setVelocity and how straight the road is, this is likely to end up with a pileup.

  2. Later, vehicles are teleported back to the spawn point using findEmptyPosition. Given that findEmptyPosition ignores moving vehicles, searches close to the target first, and the vehicle velocity isn't adjusted, this should naturally lead to a second pileup.

Hand vehicles their FSM immediately after setting the velocity and remove the backwards teleport and I think it has a chance of working semi-reliably, although I would also cut the velocity in half.

jaj22 commented 4 years ago

I'm getting regular convoy spawn crashes with mass fatalities in convoys with more than one ground vehicle. Death timing is consistently one frame after the group splitting, so I'm guessing that the findEmptyPosition teleport mentioned above is responsible.

I'm going to try out my proposed solution later tonight and see if that works any better.

Spoffy commented 4 years ago

The trick with reliable vehicle spawning/set position is to space it out, so they spawn a few seconds apart.

Equally, use A3A_fnc_safeVehicleSpawn and A3A_fnc_vehicleWillCollideAtPosition to make sure they don't spawn into an existing vehicle or object.

Bob-Murphy commented 4 years ago

@wurzel0701 Any update on this one? Still an issue or already fixed?

jaj22 commented 4 years ago

I fixed most of the convoy spacing related bugs in #598, although convoys can still explode if there are coincidental objects on the path, as safeVehicleSpawn wasn't functional at the time and (worse problem in practice) some convoy start/end points are plain bad. I'm shelving all work on convoys as there are changes in Wurzel's garrison branch that are likely to conflict.

Current state is fine for the moment. The worst spawn case I found was on Tembelan, but apparently you're not running that anymore.

wurzel0701 commented 4 years ago

I will rework that again in the upcoming convoy rework, the spacing is still shit as the vehicles aren't following the setSpeedLimit command. Proof is:

20200323164540_1

jaj22 commented 4 years ago

I believe they do obey setSpeedLimit, but it's set so high that most of the vehicles struggle to reach it while navigating real roads, and so in practice each vehicle is driving at its natural AI speed. A related issue is that land convoys travel far faster when not spawned.

A better algorithm for the speed limit would help, and possibly switching waypoints earlier (I already bumped it from 20 to 50m). Alternatively you could constrain the speed of the first vehicle by the distance to the last, although that increases the complexity substantially.

wurzel0701 commented 4 years ago

Might be, I would do something like a script which checks the distance to the followed vehicle and adjust speed based on that. Will probably do so in the convoy rework