Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.73 KB | None | 0 0
  1. void CZombiePanic::ChooseRandomZombies( void )
  2. {
  3.     // Our current survivors in total
  4.     int iSurvivors = GetSurvivors( false );
  5.  
  6.     // The amount of carriers we require
  7.     int iMinCarriers = GrabMinCarriers();
  8.  
  9.     // The required amount of zombies
  10.     int iRequired = iSurvivors / 6;
  11.  
  12.     if ( IsHardCore() )
  13.         iRequired = iSurvivors / 3;
  14.  
  15.     bool bGoTroughList = false;
  16.     CUtlVector<CZP_Player*> vSurvivorList;
  17.  
  18.     // Not enough survivors, stop the function
  19.     if ( iSurvivors < 1 )
  20.         return;
  21.  
  22.     // Add all survivors to the list
  23.     for ( int i = 1; i <= gpGlobals->maxClients; i++ )
  24.     {
  25.         CZP_Player *pPlayer = (CZP_Player*) UTIL_PlayerByIndex( i );
  26.  
  27.         if ( pPlayer && pPlayer->GetTeamNumber() == TEAM_SURVIVOR )
  28.             vSurvivorList.AddToTail( pPlayer );
  29.         else
  30.             continue;
  31.     }
  32.  
  33.     // Only go trough the while loop, if we actually have content.
  34.     if ( vSurvivorList.Count() > 0 )
  35.         bGoTroughList = true;
  36.  
  37.     // Go trough the survivor list
  38.     while( bGoTroughList )
  39.     {
  40.         int iRandom = random->RandomInt( 0, vSurvivorList.Count() );
  41.         CZP_Player *pChoosen = vSurvivorList[ iRandom ];
  42.  
  43.         // Make sure the player exist
  44.         // And make sure the player is on the correct team
  45.         if ( pChoosen && pChoosen->GetTeamNumber() == TEAM_SURVIVOR )
  46.         {
  47.             // Do we need carriers?
  48.             if ( iMinCarriers > 0 )
  49.             {
  50.                 // Set our carrier state to true
  51.                 pChoosen->SetCarrier( true );
  52.  
  53.                 // Tell the interger to reduce, that don't require more
  54.                 iMinCarriers--;
  55.             }
  56.  
  57.             // Change to zombie team
  58.             pChoosen->ChangeTeam( TEAM_ZOMBIE );
  59.  
  60.             // Spawn the player
  61.             pChoosen->Spawn();
  62.         }
  63.  
  64.         // Remove after use
  65.         vSurvivorList.Remove( iRandom );
  66.  
  67.         // our list is empty, stop the while loop
  68.         if ( vSurvivorList.Count() <= 0 )
  69.             bGoTroughList = false;
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement