official-antistasi-community / A3-Antistasi

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

[Bug]: Problems with safeSpawnPosition #1088

Open jaj22 opened 4 years ago

jaj22 commented 4 years ago

Version: Unstable

Mods: Any

Environment: Any, although one point may be environment-sensitive

Issue:

  1. Bug: The randomOffset generation has the brackets in the wrong place, which reduces the search area and gives the placement a strong bias towards +x/+y.

  2. Conceptual flaw: Vehicles are frequently placed with a direction. safeVehicleSpawn doesn't take a direction, but vehicleWillCollideWithPosition depends on it. Therefore setting a vehicle's direction after calling safeVehicleSpawn will frequently cause explosions.

  3. Conceptual flaw: Vehicles are frequently placed on roads. The radius search is inappropriate here, because if you make the radius large enough to avoid vehicles in the vicinity, vehicles are often placed blocked-in behind neighbouring walls, even if the central position was empty.

  4. Arma bug: Calling createVehicle and setPos on the same vehicle in the same scheduled frame appears to bug out the AI such that they won't drive anywhere. They turn the steering wheel but don't start the engine. Working on a simpler replication case for this, but that's how it seems to work so far. Problematic because you can't get the bounding box without a created vehicle, so the method depends on it.

MeltedPixel commented 1 year ago

PATCOM add's a new safeSpawn script. Take a look and see if its something we want to use elsewhere.

jaj22 commented 1 year ago

PATCOM add's a new safeSpawn script. Take a look and see if its something we want to use elsewhere.

You mean getSafePos? Looks like a version of BIS_fnc_findSafePos. Not a fan generally because it can take a very long time in heavily-obstructed areas, but it really depends on what you're trying to spawn. safeSpawnPosition is more "we think there's probably empty space here but find exactly where".