Quote:
Originally Posted by Silvers
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.