Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CZombiePanic::ChooseRandomZombies( void )
- {
- // Our current survivors in total
- int iSurvivors = GetSurvivors( false );
- // The amount of carriers we require
- int iMinCarriers = GrabMinCarriers();
- // The required amount of zombies
- int iRequired = iSurvivors / 6;
- if ( IsHardCore() )
- iRequired = iSurvivors / 3;
- bool bGoTroughList = false;
- CUtlVector<CZP_Player*> vSurvivorList;
- // Not enough survivors, stop the function
- if ( iSurvivors < 1 )
- return;
- // Add all survivors to the list
- for ( int i = 1; i <= gpGlobals->maxClients; i++ )
- {
- CZP_Player *pPlayer = (CZP_Player*) UTIL_PlayerByIndex( i );
- if ( pPlayer && pPlayer->GetTeamNumber() == TEAM_SURVIVOR )
- vSurvivorList.AddToTail( pPlayer );
- else
- continue;
- }
- // Only go trough the while loop, if we actually have content.
- if ( vSurvivorList.Count() > 0 )
- bGoTroughList = true;
- // Go trough the survivor list
- while( bGoTroughList )
- {
- int iRandom = random->RandomInt( 0, vSurvivorList.Count() );
- CZP_Player *pChoosen = vSurvivorList[ iRandom ];
- // Make sure the player exist
- // And make sure the player is on the correct team
- if ( pChoosen && pChoosen->GetTeamNumber() == TEAM_SURVIVOR )
- {
- // Do we need carriers?
- if ( iMinCarriers > 0 )
- {
- // Set our carrier state to true
- pChoosen->SetCarrier( true );
- // Tell the interger to reduce, that don't require more
- iMinCarriers--;
- }
- // Change to zombie team
- pChoosen->ChangeTeam( TEAM_ZOMBIE );
- // Spawn the player
- pChoosen->Spawn();
- }
- // Remove after use
- vSurvivorList.Remove( iRandom );
- // our list is empty, stop the while loop
- if ( vSurvivorList.Count() <= 0 )
- bGoTroughList = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement