Jump to content
gc8

BIS_fnc_spawnGroup safe pos

Recommended Posts

Hi

Does any one have any good ideas how to get good spawn pos for vehicles created by BIS_fnc_spawnGroup?

 

The problem is the vehicles tend to spawn on bad pos and explode.

 

Maybe I need to write custom group spawn script so I can use BIS_fnc_findSafePos for each vehicle but existing solution would be nice.

 

thx!

Share this post


Link to post
Share on other sites

maybe you got a solution for this already ...

 

you can run BIS_fnc_findSafePos first to define the position (the objDist argument allows you to define how close the nearest object can be) then use this to spawn the units onto. so something like

 

Quote

_spawnPos = [center, 1, 200, 10, 0] call BIS_fnc_findSafePos;

 

_spawnGroup = [_spawnPos , east, "className"] call BIS_fnc_spawnGroup;

 

for vehicles i also found finding a random pos and then running BIS_fnc_nearestRoad           works pretty good too

  • Like 1

Share this post


Link to post
Share on other sites

@lordfrith Yeah I already wrote a custom group spawn function where I use the BIS_fnc_findSafePos to find position for each spawned vehicle. I find that BIS_fnc_findSafePos doesn't always return good positions but sometimes the pos is too close to building or other vehicle. I fixed this with some near-object checks for the position returned by BIS_fnc_findSafePos. And then I just call BIS_fnc_findSafePos again with different parameters for min/max distance

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, gc8 said:

I find that BIS_fnc_findSafePos doesn't always return good positions but sometimes the pos is too close to building or other vehicle.

 

You can also check for

 

https://community.bistudio.com/wiki/findEmptyPosition

 

https://community.bistudio.com/wiki/isFlatEmpty

 

This will be in the GF Missions script update:

 

my ex:

Spoiler

//________________	Safe Distance Position Updater	________________
 
GF_Missions_Safe_Zone_distance_initialized = false;	
[] spawn {
	while {true} do {
 	
private ["_Position","_isFlatEmpty"];

	_isFlatEmpty = false;
	while {!_isFlatEmpty} do {
	_Position = [] call BIS_fnc_randomPos;
	
	//	Check if area 10m around the position is relatively flat and empty:
	//	https://community.bistudio.com/wiki/isFlatEmpty
	_isFlatEmpty = !(_Position isFlatEmpty  [10, -1, 0.3, 10, -1] isEqualTo []);
	
if (GF_Missions_Systemchat_info) then {
systemchat format ["_isFlatEmpty %1",_isFlatEmpty];
};	
		
	if (
	
	//________________	Add Safe Distance from all Players	________________
	(({((_Position distance _x) > GF_Missions_Safe_Zone_distance)} count GF_Missions_allPlayers) isEqualTo 0)
		
	//________________	Add here your Safe Zones ( for more )	________________
	&& ((_Position distance GF_Missions_Safe_Zone_1) > GF_Missions_Safe_Zone_distance) 
	&& ((_Position distance GF_Missions_Safe_Zone_2) > GF_Missions_Safe_Zone_distance)
	&& ((_Position distance GF_Missions_Safe_Zone_3) > GF_Missions_Safe_Zone_distance) 
	&& ((_Position distance GF_Missions_Safe_Zone_4) > GF_Missions_Safe_Zone_distance)
	&& ((_Position distance GF_Missions_Safe_Zone_5) > GF_Missions_Safe_Zone_distance)
	
	&& !(isOnRoad _Position)
	&& (isNull roadAt _Position)
	
	) then {
	
	_isFlatEmpty = !(_Position isFlatEmpty  [10, -1, 0.3, 10, -1] isEqualTo []);
	
if (GF_Missions_Systemchat_info) then {
systemchat format ["_isFlatEmpty %1",_isFlatEmpty];
};	
		};
	};

	GF_Missions_pos = [(_Position select 0) , (_Position select 1) , (_Position select 2)];

	GF_Missions_Safe_Zone_distance_initialized = true;
	
	//________________	Spawn TEST	________________
	//	_Civilian_Group = createGroup civilian;
	//	_Civilian_1 = _Civilian_Group createUnit ["O_G_Survivor_F", GF_Missions_pos, [], 0, "CAN_COLLIDE"];

if (GF_Missions_Systemchat_info) then {
systemchat "Safe Distance Position Updated";
systemchat format ["%1",GF_Missions_pos]; 
};	

	_time = diag_tickTime + 20;	//	every  % second
    _i = 0;
    waitUntil {
	sleep 1;
    _i = _i + 1;		
    diag_tickTime >= _time
		};
	};
};


waitUntil {GF_Missions_Safe_Zone_distance_initialized};

 

maybe you can add instead of random position BIS_fnc_findSafePos

 

i don't know how to get this faster but in Stratis , that is a little bit of a thing , it does the work !

 

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites
Quote

that BIS_fnc_findSafePos doesn't always return good positions but sometimes the pos is too close to building or other vehicle

 

You can add a check to findSafePos to prevent it from spawning units too close to buildings or rocks. There's a parameter for it -- objDist.

 

I'm not 100% sure this method will work for preventing the spawning of units on the same side too close together, but you can always just add a condition to not spawn the units anywhere near existing units of a certain side.

Share this post


Link to post
Share on other sites
31 minutes ago, Vauun said:

You can add a check to findSafePos to prevent it from spawning units too close to buildings or rocks. There's a parameter for it -- objDist.

 

I know but it doesn't work reliably

 

Share this post


Link to post
Share on other sites
12 minutes ago, gc8 said:

 

I know but it doesn't work reliably

 

 

I'm not sure why you're saying that, I've done it before in the past and it's worked fine. What're your custom conditions for spawning?

Share this post


Link to post
Share on other sites
1 minute ago, Vauun said:

 

I'm not sure why you're saying that, I've done it before in the past and it's worked fine. What're your custom conditions for spawning?

 

Have you tried it on Tanoa map? I had it working on one of my projects in malden map but when I tried to spawn lot of vehicles on Tanoa town I get a lot of explosions and objdist didn't really help

Share this post


Link to post
Share on other sites
1 minute ago, gc8 said:

 

Have you tried it on Tanoa map? I had it working on one of my projects in malden map but when I tried to spawn lot of vehicles on Tanoa town I get a lot of explosions and objdist didn't really help

That's because Tanoa is filled with objects especially -- There's very little open space on that map. From the Biki entry on findSafePos:

 

"Specifying quite large distance here will slow the function and might often fail to find suitable position."

 

For Tanoa, mostly anything is a large distance since the game has to search so much for a suitable position. You can try to clear some spawn areas by using the clear objects module in 3den.

Share this post


Link to post
Share on other sites

@Vauun Thanks but I got my custom spawn position code working like I said before.

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×