//options to be done
//select personality. bit 5
//drunk missiles
//homing missiles
//double projectiles
//triple projectiles
//exploding nails/bullets
//regenerating health/ammo/armor

float(float a, float b) mathlib_fast_pow =
{
	local float fb, n, bit, factor;
	
	fb = fabs(b);
	bit = 1;
	n = 1;
	factor = a;
	while (bit <= fb)
	{
		if (fb&bit)
			n = n * factor;
		factor = factor * factor;
		bit = bit * 2;
	}
	if (b < 0)
		return 1/n;
	else
		return n;
};

/*

	upgrade progression
	
	weapons
	axe												= axe
	shotgun/super shotgun						= shotgun
	nailgun/super nailgun						= super shotgun level 1
	grenade launcher/rocket launcher			= nailgun level 2
	energy weapons									= super nailgun level 3
	anti personnel 								= grenade launcher level 4
		MMAW/deathshead/doomsday/vortex
		napalm/orbital
	turrets											= rocket launcher level 6
	akimbo											= lightning level 8
	god weapons										= extra weapon level 10

	health:
	each level increases health by 100, up to 999
	
	armor
	each level increases armor by 100, up to 999
	
	ammo
	each level increases armor by 100, up to 999
	
	double projectiles, level 5
	
	triple projectiles, powerup
	
	go kart powerup
	
	robot powerup
	
	fire/ice powerups
	
	increase length of super damage, level 6
	
	increase length of invincibility, level 8
*/

//put this in killed
//if (attacker.classname == "player") then CheckUpgrades()

void (entity boob) CheckUpgrades =
{

	local float baselvl;

//	if (coop & 4)
		baselvl = (skill+1)*1;
//	else
//		baselvl = (skill+1)*10;
	

//	float lvl;
//	if (self.frags >= 10) self.lvl = self.frags / 10;
//	self.level = self.lvl;
		local string plvl;
		
		local float n;
		n = baselvl;
	//if (self.frags >= l1 && (self.max_health == 100))
	if (boob.frags >= baselvl && boob.level == 0)
	{
		boob.level = 1;
		boob.levelup = TRUE;
		boob.inmenu = TRUE;
		boob.menuchoice1 = selectshotgun;
		boob.menuchoice2 = selectnailgun;
/*
		boob.menuchoice3 = selectgrenade;
		boob.menuchoice4 = selectrocket;
		boob.menuchoice5 = selectenergy;
		boob.menuchoice6 = selectturret;
*/
//		while (boob.time < boob.menutime)
		{
			centerprint(boob,"level 1\nselect primary weapon\n1: super shotgun\n2: super nailgun\n");
//			boob.menutime = boob.time + 0.4;
		}
	}

	n = baselvl*(mathlib_fast_pow(1.1,2)) + n;
	n = ceil(n);
	//1.1^2 = 1.21 * 20 = 24.2. ceil = 25
	//lvl 1 = 20 frags, lvl 2 = 20 +25 = 45
	if (boob.frags >= n && boob.level == 1)
	{
		boob.level = 2;
		boob.levelup = TRUE;
		boob.inmenu = TRUE;
		boob.menuchoice1 = HealthBoost1;
		boob.menuchoice2 = DamageBoost1;
//		while (boob.inmenu == TRUE)
		{
			centerprint(boob,"level 2\nselect upgrade\n1: increase max health\n2: increase damage\n");
		}
	}
	

	//ten percent increase in required frags from level to level (1 + .1 = 110%)
	n = baselvl*(mathlib_fast_pow(1.1,3)) + n;
	n = ceil(n);

	if (boob.frags >= n && (boob.level == 2))
	{
		boob.level = 3;
		boob.levelup = TRUE;
		boob.inmenu = TRUE;
		boob.bit5 = boob.bit5 | CRIT1;
		boob.menuchoice1 = selectshotgun;
		boob.menuchoice2 = selectnailgun;
		boob.menuchoice3 = selectgrenade;
		/*
		boob.menuchoice4 = selectrocket;
		boob.menuchoice5 = selectenergy;
		boob.menuchoice6 = selectturret;
		*/
//		while (boob.inmenu == TRUE)
		{
			centerprint(boob,"level 3\nselect secondary weapon\n1: shotgun\n2: nailgun\n3: grenade launcher\ncrit hit chance 5%\ncrit damage 125%\n");
		}
	}

	//1.1^3 = 1.331 *20 ~ 27
	//45 + 27 = 72
	n = baselvl*(mathlib_fast_pow(1.1,3)) + n;
	n = ceil(n);
	if (boob.frags >= n && (boob.level == 3))
	{
		boob.level = 4;
		boob.levelup = TRUE;
		boob.inmenu = TRUE;
		boob.menuchoice1 = noupgrade;
		boob.menuchoice2 = selectchainsaw;
		centerprint(boob,"level 8\nselect melee upgrade\n1: keep current weapon\n2: upgrade to chainsaw\n");
	}
	
	n = baselvl*(mathlib_fast_pow(1.1,3)) + n;
	n = ceil(n);

	if (boob.frags >= n && (boob.level == 4))
	{
		boob.level = 5;
		boob.levelup = TRUE;
		boob.inmenu = TRUE;
		boob.menuchoice1 = ArmorBoost1;
		boob.menuchoice2 = DamageBoost2;
		centerprint(boob,"level 4\nselect upgrade\n1: increase max armor\n2: increase damage\n");
	}

	n = baselvl*(mathlib_fast_pow(1.1,3)) + n;
	n = ceil(n);
	if (boob.frags >= n && (boob.level == 5))
	{
		boob.level = 6;
		boob.levelup = TRUE;
		boob.inmenu = TRUE;
		boob.bit5 = boob.bit5 | CRIT2;
		centerprint(boob,"level 4\ncritical hit chance 10%\ncritical damage 150%\n");
	}

	n = baselvl*(mathlib_fast_pow(1.1,3)) + n;
	n = ceil(n);
	if (boob.frags >= n && (boob.level == 6))
	{
		boob.level = 7;
		boob.levelup = TRUE;
		boob.inmenu = TRUE;
		boob.menuchoice1 = selectshotgun;
		boob.menuchoice2 = selectnailgun;
		boob.menuchoice3 = selectgrenade;
		boob.menuchoice4 = selectrocket;
		boob.menuchoice5 = selectenergy;
//		boob.menuchoice6 = selectturret;
		centerprint(boob,"level 5\nselect tertiary weapon\n1: shotgun\n2: nailgun\n3: grenade launcher\n4: rocket launcher\n5: energy weapons\n");
	}

	n = baselvl*(mathlib_fast_pow(1.1,4)) + n;
	n = ceil(n);

	if (boob.frags >= n && (boob.level == 7))
	{
		boob.level = 8;
		boob.levelup = TRUE;
		boob.inmenu = TRUE;
		boob.menuchoice1 = HealthBoost2;
		boob.menuchoice2 = DamageBoost3;
		centerprint(boob,"level 6\nselect upgrade\n1: increase max health\n2: increase damage\n");
	}

	n = baselvl*(mathlib_fast_pow(1.1,4)) + n;
	n = ceil(n);

	if (boob.frags >= n && (boob.level == 8))
	{
		boob.level = 9;
		boob.levelup = TRUE;
		boob.inmenu = TRUE;
		boob.menuchoice1 = selectshotgun;
		boob.menuchoice2 = selectnailgun;
		boob.menuchoice3 = selectgrenade;
		boob.menuchoice4 = selectrocket;
		boob.menuchoice5 = selectenergy;
		boob.menuchoice6 = selectturret;
		centerprint(boob,"level 7\nselect quaternary weapon\n1: shotgun\n2: nailgun\n3: grenade launcher\n4: rocket launcher\n5: energy weapons\n6: turret\n");
	}

	n = baselvl*(mathlib_fast_pow(1.1,4)) + n;
	n = ceil(n);

	if (boob.frags >= n && (boob.level == 7))
	{
		boob.level = 8;
		boob.levelup = TRUE;
		boob.inmenu = TRUE;
		boob.menuchoice1 = noupgrade;
		boob.menuchoice2 = selectchainsaw;
		centerprint(boob,"level 8\nselect melee upgrade\n1: keep current weapon\n2: upgrade to chainsaw\n");
	}
	n = baselvl*(mathlib_fast_pow(1.1,7)) + n;
	n = ceil(n);

	if (boob.frags >= n && (boob.level < 8))
	{
		centerprint(boob,"Maximum Armor Increased\nShotgun Weapons Upgraded");
		boob.level = 8;

	}
	n = baselvl*(mathlib_fast_pow(1.1,8)) + n;
	n = ceil(n);

	if (boob.frags >= n && boob.level < 9)
	{
		centerprint(boob,"God Powers Available\nNailgun Weapons Upgraded\nMaximum Health Increased");	//you can now grab the powerup
		boob.level = 9;
	}

	n = baselvl*(mathlib_fast_pow(1.1,9)) + n;
	n = ceil(n);

	if (boob.frags >= n && boob.level < 10)
	{
		centerprint(boob,"Explosive Weapons Upgraded\nMaximum Armor Increased\nRegenerating Nails Acquired");
		boob.level = 10;

	}

	n = baselvl*(mathlib_fast_pow(1.2,10)) + n;
	n = ceil(n);

	if (boob.frags >= n && boob.level < 11)
	{
		centerprint(boob,"Energy Weapons Upgraded\nMaximum Health Increased");	
		boob.level = 11;

	}

	n = baselvl*(mathlib_fast_pow(1.2,11)) + n;
	n = ceil(n);

	if (boob.frags >= n && boob.level < 12)
	{
		centerprint(boob,"Anti-Personnel\nWeapons Upgraded\nMaximum Armor Increased");
		boob.level = 12;

	}

	n = baselvl*(mathlib_fast_pow(1.2,12)) + n;
	n = ceil(n);

	if (boob.frags >= n && boob.level < 13)
	{
		centerprint(boob,"Turret Weapons Upgraded\nMaximum Health Increased");
		boob.level = 13;

	}

	n = baselvl*(mathlib_fast_pow(1.3,13)) + n;
	n = ceil(n);

	if (boob.frags >= n && boob.level < 14)
	{
		centerprint(boob,"Akimbo Weapons Acquired\nMaximum Armor Increased");
		boob.level = 14;

		plvl = ftos(boob.level);
		sprint(boob,"you are now level ");
		sprint(boob,plvl);
		sprint(boob,"\n");
	}

	n = baselvl*(mathlib_fast_pow(1.3,14)) + n;
	n = ceil(n);

	if (boob.frags >= n && boob.level < 15)
	{
		centerprint(boob,"Maximum Health Increased\nRegenerating Rockets Acquired");
		boob.level = 15;

		plvl = ftos(boob.level);
		sprint(boob,"you are now level ");
		sprint(boob,plvl);
		sprint(boob,"\n");
	}
	n = baselvl*(mathlib_fast_pow(1.3,15)) + n;
	n = ceil(n);

	if (boob.frags >= n && boob.level < 16)
	{
		centerprint(boob,"Maximum Armor Increased");
		boob.level = 16;

		plvl = ftos(boob.level);
		sprint(boob,"you are now level ");
		sprint(boob,plvl);
		sprint(boob,"\n");
	}
	
	n = baselvl*(mathlib_fast_pow(1.4,16)) + n;
	n = ceil(n);
//700
	if (boob.frags >= n && boob.level < 17)
	{
		centerprint(boob,"Maximum Health Increased");

		boob.level = 17;

		plvl = ftos(boob.level);
		sprint(boob,"you are now level ");
		sprint(boob,plvl);
		sprint(boob,"\n");
	}

//800
	n = baselvl*(mathlib_fast_pow(1.4,17)) + n;
	n = ceil(n);

	if (boob.frags >= n && boob.level < 18)
	{
		centerprint(boob,"Maximum Health Increased");

		boob.level = 18;

		plvl = ftos(boob.level);
		sprint(boob,"you are now level ");
		sprint(boob,plvl);
		sprint(boob,"\n");
	}
	
	n = baselvl*(mathlib_fast_pow(1.5,18)) + n;
	n = ceil(n);

//900
	if (boob.frags >= n && boob.level < 19)
	{
		centerprint(boob,"Akimbo Weapons Upgraded\nMaximum Health Increased\nMaximum Armor Increased");
		boob.level = 19;

		plvl = ftos(boob.level);
		sprint(boob,"you are now level ");
		sprint(boob,plvl);
		sprint(boob,"\n");
	}

//999
	n = baselvl*(mathlib_fast_pow(1.5,19)) + n;
	n = ceil(n);

	if (boob.frags >= n && boob.level < 20)
	{
		centerprint(boob,"Maximum Health Increased\nMaximum Armor Increased\nRegenerating Cells Acquired");
		boob.level = 20;

		plvl = ftos(boob.level);
		sprint(boob,"you are now level ");
		sprint(boob,plvl);
		sprint(boob,"\n");
	}
};

