HereIsJones 20 Posted February 11, 2021 I'm new to scripting, and decided to put together a script to spawn random teams of guerillas in different situations (village incursions, roadblocks, etc.). I've got village incursions working using the CBA Defend module, except I've spawned into coastal waters (off Tanoa) twice now, even though I'm using BIS_fnc_findSafePos. Not sure if this is too contrived, but I only want to spawn in villages, so I'm getting a random pos on the map, then finding a village near it, then converting the village location back to a pos, then finding a safe place to spawn in or around the village location using BIS_fnc_findSafePos. _thisPos = [] call BIS_fnc_randomPos; _thisVillage = nearestLocation [_thisPos, "NameVillage"]; _thisPos = locationPosition _thisVillage; [_thisPos, 10, 50, 5, 0, .25, 0, [], []] call BIS_fnc_findSafePos; Even though I've set waterMode to 0 (can not be in water), my guerillas occasionally end up spawning in the water. Can anyone see what I'm doing wrong? Thx ahead of time. EDIT: Perhaps there is a way to determine the rough center of a village, and spawn there? As long as it doesn't overlap a building. ANOTHER EDIT: Ok, I wasn't assigning _thisPos to the function in the last line. Using this code actually returns good results, but as a new Arma scripter I'm happy to learn a better way. _thisPos = [] call BIS_fnc_randomPos; _thisVillage = (nearestLocations [_thisPos, ["NameVillage", "NameCity", "Airport"], 4000] select 0); _thisPos = locationPosition _thisVillage; _thisPos = nearestBuilding _thisPos; _thisPos = [_thisPos, 10, 100, 2, 0, .5, 0, [], []] call BIS_fnc_findSafePos; Share this post Link to post Share on other sites
pierremgi 4737 Posted February 12, 2021 Your last code seems OK. Personally, I'll not add the line searching for the nearest building. It's useless (and sometimes counter-productive) Bis_fnc_findSafePos is fine, avoiding water and objects within a distance. Test that by creating markers. You can even loop a hundred times for mil_dot markers, checking the location position and a hundred (or even more) found positions. 2 Share this post Link to post Share on other sites
HereIsJones 20 Posted February 14, 2021 Ah, thank you for noting how to test, it didn't occur to me. I'll write something that loops markers onto the map. I've been testing one run at a time. 😛 I had to put in nearestBuilding because (on Tanoa at least) the official village pos can be well outside of the village, and the DEFEND group just marches around in a circle without garrisoning because there are no houses. I noticed it's much better in Altis, but I'll look into other options. Share this post Link to post Share on other sites