Advertisement
TTS4life

Untitled

Apr 14th, 2020
1,076
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 3.12 KB | None | 0 0
  1. var $totalzcount = 0;                   //defined by the game
  2. var $initialHealth = 150;               //defined by the game
  3. var $zombiecount = 24;                  //defined by the game
  4. function calculateZombieCount() {
  5.     $tempzcount = $zombiecount;
  6.     $currZombHealth = $initialHealth;
  7.     $totalzcount = 0;
  8.  
  9.     if($round.val() == 1) { //if its round 1:
  10.         $tempzcount += parseInt( ($playercount - 1 ) * 6 * 1); //  current zombie count = ( (players in game) - 1 ) * 6 * 1)
  11.         $tempzcount = parseInt( getActualTotal($tempzcount, 1) ); //send round 1 and zombiecount to function getActualTotal for further processing
  12.     }
  13.     else { //round is greater than 1
  14.         //loop through this part for every round after round 2 until you reach the desired round for health/zombie count
  15.         for(i = 2; i <= $round.val(); i++) {
  16.             //health calculations
  17.             //if round is 10 or higher
  18.             if(i >= 10) {
  19.                 $currZombHealth = parseInt($currZombHealth * 1.1); //take the current zombie health and multiply it by 1.1
  20.             }
  21.             else {
  22.                 $currZombHealth = parseInt($currZombHealth += 100); //else add 100 to what it already is
  23.             }
  24.  
  25.             //zombie per round calculations
  26.             //if its round 2, just add 6
  27.             if(i == 2) {
  28.                 $totalzcount += 6;
  29.             }
  30.  
  31.             $tempzcount = 24; //this gets reset to 24 to reset variables for calculation
  32.            
  33.             //take the roundcount and divide it by five to create an exponential multiplier
  34.             $multiplier = i / 5;
  35.             //if its less than one (to prevent the zombie count from shrinking, set it to 1.
  36.             if($multiplier < 1) { $multiplier = 1; }
  37.                
  38.             if(i >= 10) {
  39.                 $multiplier *= (i * .15);
  40.             }
  41.  
  42.             //if solo
  43.             if( $playercount == '1') {
  44.                 $tempzcount += parseInt( (.5 * 6) * $multiplier); //zombiecount is (.5 * 6) * $multiplier which we calculated earlier, added on to the current zombie count (24)
  45.             }
  46.             else {
  47.                 $tempzcount += parseInt( ($playercount - 1 ) * 6 * $multiplier); //its a coop game, subtract 1 from player count, then multiply by 6 and the multiplier we had earlier, and add it to the zombiecount (24).
  48.             }
  49.  
  50.             //send round and current zombie count for further calculation.
  51.             $tempzcount = parseInt(getActualTotal($tempzcount, i));
  52.             $totalzcount += $tempzcount;
  53.         }
  54.     }
  55. }
  56.  
  57.  
  58. function getActualTotal(z, i) {
  59.  
  60. //if its round 1, return 1/4th of what we passed in, which in this case would be 24.
  61. //24 * .25 = 6, which is why round 1 has 6 zombies.
  62. if($('#currentRound').val() == 1) {
  63.     return z * .25;
  64. }      
  65.  
  66. //what round are we on?
  67. switch(i) {
  68.     case 2:
  69.         return (z * .3); //take the zombie count we calculated earlier, and multiply by .3/.5/.7/.9, then send it back.
  70.     case 3:
  71.         return (z * .5);
  72.     case 4:
  73.         return (z * .7);
  74.     case 5:
  75.         return (z * .9);
  76.     default:               //round was none of the numbers before, just return it.
  77.         return z;
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement