Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var $totalzcount = 0; //defined by the game
- var $initialHealth = 150; //defined by the game
- var $zombiecount = 24; //defined by the game
- function calculateZombieCount() {
- $tempzcount = $zombiecount;
- $currZombHealth = $initialHealth;
- $totalzcount = 0;
- if($round.val() == 1) { //if its round 1:
- $tempzcount += parseInt( ($playercount - 1 ) * 6 * 1); // current zombie count = ( (players in game) - 1 ) * 6 * 1)
- $tempzcount = parseInt( getActualTotal($tempzcount, 1) ); //send round 1 and zombiecount to function getActualTotal for further processing
- }
- else { //round is greater than 1
- //loop through this part for every round after round 2 until you reach the desired round for health/zombie count
- for(i = 2; i <= $round.val(); i++) {
- //health calculations
- //if round is 10 or higher
- if(i >= 10) {
- $currZombHealth = parseInt($currZombHealth * 1.1); //take the current zombie health and multiply it by 1.1
- }
- else {
- $currZombHealth = parseInt($currZombHealth += 100); //else add 100 to what it already is
- }
- //zombie per round calculations
- //if its round 2, just add 6
- if(i == 2) {
- $totalzcount += 6;
- }
- $tempzcount = 24; //this gets reset to 24 to reset variables for calculation
- //take the roundcount and divide it by five to create an exponential multiplier
- $multiplier = i / 5;
- //if its less than one (to prevent the zombie count from shrinking, set it to 1.
- if($multiplier < 1) { $multiplier = 1; }
- if(i >= 10) {
- $multiplier *= (i * .15);
- }
- //if solo
- if( $playercount == '1') {
- $tempzcount += parseInt( (.5 * 6) * $multiplier); //zombiecount is (.5 * 6) * $multiplier which we calculated earlier, added on to the current zombie count (24)
- }
- else {
- $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).
- }
- //send round and current zombie count for further calculation.
- $tempzcount = parseInt(getActualTotal($tempzcount, i));
- $totalzcount += $tempzcount;
- }
- }
- }
- function getActualTotal(z, i) {
- //if its round 1, return 1/4th of what we passed in, which in this case would be 24.
- //24 * .25 = 6, which is why round 1 has 6 zombies.
- if($('#currentRound').val() == 1) {
- return z * .25;
- }
- //what round are we on?
- switch(i) {
- case 2:
- return (z * .3); //take the zombie count we calculated earlier, and multiply by .3/.5/.7/.9, then send it back.
- case 3:
- return (z * .5);
- case 4:
- return (z * .7);
- case 5:
- return (z * .9);
- default: //round was none of the numbers before, just return it.
- return z;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement