Advertisement
Treedestroyed

TestMutator

Jun 15th, 2021 (edited)
2,666
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class TestMutator extends Mutator;
  2.  
  3. var config string MaxMonsters;
  4. var config string FakedPlayers;
  5.  
  6. var array<int> MaxMonstersInt;
  7. var array<int> FakedPlayersInt;
  8.  
  9. event PreBeginPlay()
  10. {
  11.     super.PreBeginPlay();
  12.  
  13.     InitDynamicSettings();
  14.    
  15.     SetMaxMonsters();
  16.     SetFakedPlayers();
  17. }
  18.  
  19. function SetMaxMonsters()
  20. {
  21.     local KFGameType KFGT;
  22.     local int TotalMaxMonsters;
  23.    
  24.     KFGT = KFGameType( Level.Game );
  25.    
  26.     if ( KFGT != None )
  27.     {
  28.         TotalMaxMonsters = MaxMonstersInt[Clamp( GetTruePlayerNum() - 1, 0, 128 )];
  29.         TotalMaxMonsters = Clamp( TotalMaxMonsters, 5, 254 );
  30.        
  31.         KFGT.MaxZombiesOnce = TotalMaxMonsters;
  32.         KFGT.StandardMaxZombiesOnce = TotalMaxMonsters;
  33.         KFGT.MaxMonsters = Clamp( KFGT.TotalMaxMonsters, 5, TotalMaxMonsters );        
  34.     }
  35. }
  36.  
  37. function SetFakedPlayers()
  38. {
  39.     local KFGameType KFGT;
  40.     local int TotalFakedPlayers;
  41.    
  42.     TotalFakedPlayers = FakedPlayersInt[Clamp( GetTruePlayerNum() - 1, 0, 128 )];
  43.    
  44.     KFGT = KFGameType( Level.Game );
  45.  
  46.     if ( KFGT != none )
  47.         KFGT.NumPlayers = GetTruePlayerNum() + TotalFakedPlayers;
  48. }
  49.  
  50.  
  51. function int GetTruePlayerNum()
  52. {
  53.     local Controller C;
  54.     local PlayerReplicationInfo PRI;
  55.     local int i;
  56.  
  57.     i = 0;
  58.    
  59.     for ( C = Level.ControllerList; C != None; C = C.NextController )
  60.     {
  61.         PRI = C.PlayerReplicationInfo;
  62.    
  63.         if ( ( PRI != None ) && !PRI.bBot && MessagingSpectator( C ) == None )
  64.             i++;
  65.     }
  66.    
  67.     return i;
  68. }
  69.  
  70. private simulated function InitDynamicSettings()
  71. {
  72.     SetDynamicIntegerString( MaxMonstersInt, MaxMonsters );
  73.     SetDynamicIntegerString( FakedPlayersInt, FakedPlayers );
  74. }
  75.  
  76. simulated function SetDynamicIntegerString( out array<int> OutValue, string OutString )
  77. {
  78.     local string S;
  79.     local array<string> ArrayString;
  80.    
  81.     ParseStringIntoArray( OutString, ArrayString, ",", true );
  82.    
  83.     foreach ArrayString( S )
  84.         OutValue.AddItem( int( S ) );
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement