View Single Post
XDglory
Member
Join Date: May 2012
Old 07-10-2020 , 12:33   Re: [L4D & L4D2] Left 4 DHooks Direct (1.16a) [16-Jun-2020]
Reply With Quote #129

Quote:
Originally Posted by Silvers View Post
L4D_GetRandomPZSpawnPosition to get the pos, L4D_GetNearestNavArea or L4D2Direct_GetTerrorNavArea to get the nav area and check its valid otherwise select another pos. There maybe other plugins/extensions to check the NavArea and return the flags for example. I don't know the best solution for finding a random valid position along the flow for survivors.
Not sure if I'm doing this right.

Code:
void SpawnWitch(){
	int player = GetSurvivorMaxPercent(true); // retrieve player who holds max flow 
	float pos_player[3], pos_witchSpawnPre[3], pos_witchSpawn[3];
	GetClientAbsOrigin(player, pos_player);

	bool WitchSpawnSuccess = L4D_GetRandomPZSpawnPosition(player, 7, 20, pos_witchSpawnPre);
	
	if (WitchSpawnSuccess){
		L4D_FindRandomSpot(L4D_GetNearestNavArea(pos_witchSpawnPre), pos_witchSpawn);
		L4D2_SpawnWitch(pos_witchSpawn, NULL_VECTOR);
	} else
		PrintToChatAll("Failed to find a spot for witch.");
}
Witch spawned by this function still can be at a place survivor is not reachable, like the roof of the vendor near starting safe room on c2m2.

Last edited by XDglory; 07-10-2020 at 12:34.
XDglory is offline