--[[

캇,솔,파,데,헤 검수완
엔,메,스나,스파이 미검수

]]
MenuCapacity = 3 --3
TotalUpgradePoints = 1 --1
TotalRerollPoints = 1--1


AllShops =
{
	[1] = --Scout Shop
	{
		CommonAttribute = --8
		{
			{"Max Health +10", "max health additive bonus",0,10,30},
			{"Weapon Switch Speed +30%", "deploy time decreased",1,-0.3,0.1},
			{"Credit Collect Range +50%", "mult credit collect range",1,0.5,3},
			{"Push Force -20%", "damage force reduction",1,-0.2,0.05},
			{"Melee Resistance +25%", "dmg from melee increased",1,-0.25,0.25},
			{"Consumable Recharge Rate +10%", "charge recharge rate increased",1,0.1,1.6},
			{"Meter Effect/Debuff Duration +10%", "mult effect duration",1,0.1,1.5},
			{"+20% damage vs buildings", "dmg bonus vs buildings",1,0.2,2},
		},
		RareAttribute =
		{
			{"(RARE) Speed Boost On Hit +5", "speed_boost_on_hit",0,5,5},
			{"(RARE) Recall On Death +100% chance", "teleport instead of die",0,1,1},
			{"(RARE) Milk hit 6s", "custom",0,1,1},
			{"(RARE) Wet Immune", "wet immunity",0,1,1},
			{"(RARE) Afterburn Immune", "afterburn immunity",0,1,1},
		},
		EpicAttribute =
		{
			{"[EPIC] Mark for Death On Hit", "mark for death",0,1,1},
			{"[EPIC] Passive Reload", "passive reload",0,1,1},
			{"[EPIC] Ignored by Enemy Sentries", "ignored by enemy sentries",0,1,1},
			{"[EPIC] Stun Immune", "mult stun resistance",1,-1,0},
			{"[EPIC] Invulnerable On Taking Damage +30% Chance", "uber on damage taken",0,0.3,0.3},
		},
		LegendaryAttribute =
		{
			{"【LEGENDARY】 Bullets Per Shot +250% / Firing Speed -150%", "custom",0,1,1},
			{"【LEGENDARY】 Reload Full Clip At Once", "reload full clip at once",0,1,1}, --[[재장전 한번에]]
			{"【LEGENDARY】 Move speed +100% / Infinite Jump", "custom",0,1,1},
		},
		--[[
			{"Damage Bonus +25%", "damage bonus",1,0.25},
			{"Clip Size +50%", "clip size bonus",1,0.5},
			{"Firing Speed +10%", "fire rate bonus",1,-0.1,0.1},
 			{"Reload Speed +20%", "faster reload rate",1,-0.2,0.2},
			{"Heal On Kill +25 health", "heal on kill",0,25},
			{"Max Ammo +50%", "custom",1,0.5},
			{"Weapon Switch Speed +45%", "deploy time decreased",1,-0.45,0.1},
			{"Movement Speed +10%", "move speed bonus",1,0.1},
			{"Jump Height +20%", "increased jump height",1,0.2},
			{"Fire Resistance +25%", "dmg taken from fire reduced",1,-0.25,0.25},
			{"Bullet Resistance +25%", "dmg taken from bullets reduced",1,-0.25,0.25},
			{"Blast Resistance +25%", "dmg taken from blast reduced",1,-0.25,0.25},
			{"Crit Resistance +30%", "dmg taken from crit reduced",1,-0.3,0.1},
			{"Health Regen +2 every second", "health regen",0,2},
			{"Ammo Regen +20% every 5 seconds", "ammo regen",0,0.2,1},
			{"Heal On Hit +15 health", "heal on hit for rapidfire",0,15},
			{"Drop On Kill: Small Health Pack", "drop health pack on kill",0,1,1},
			{"(RARE) Projectile Penetration", "projectile penetration",0,1,1},
			{"(RARE) Mad Milk Slows Targets", "applies snare effect",1,-0.35,0.65},
			{"(RARE) Extra Jump +1", "air dash count",0,1},
			{"[EPIC] Bullets Per Shot +30%", "bullets per shot bonus",1,0.3},
			{"[EPIC] Tank Damage Bonus +50%", "mult dmg vs tanks",1,0.5,2},
			{"[EPIC] Meter Effect/Debuff Duration +50%", "mult effect duration",1,0.5},
			{"[EPIC] All Healing Received +100%", "healing received bonus",1,1},
			{"【LEGENDARY】 Crit On Kill +3 seconds", "critboost on kill",0,3},
			{"【LEGENDARY】 Mini-crits become Crits", "minicrits become crits",0,1,1},
		]]
	},
	[3] = --Soldier Shop
	{
		CommonAttribute = --8
		{
			{"Health +20 / -20% OverHealed", "custom",0,1,3},
			{"Banners: Buff Radius +10%", "mod soldier buff range",1,0.1,1.5},
			{"Banners: Rage Gained +10%", "rage giving scale",1,0.1,1.5},
			{"Projectile Speed +15%", "Projectile speed increased",1,0.15,1.9},
			{"Self Blast -20%", "blast dmg to self increased",1,-0.2,0.2},
			{"Weapon Switch Speed +30%", "deploy time decreased",1,-0.3,0.1},
			{"Mini-crit Airborne Targets", "mod mini-crit airborne",0,1,1},
			{"B.A.S.E. Jumper: Infinite Redeploy", "parachute redeploy",0,1,1},
		},
		RareAttribute = --4
		{
			{"(RARE) Projectiles Cannot Be Deflected", "projectile no deflect",0,1,1},
			{"(RARE) Fall Damage Immune", "cancel falling damage",0,1,1},
			{"(RARE) Homing Rocket", "custom",0,1,1},
			{"(RARE) Speed Boost On Kill +8 seconds", "speed_boost_on_kill",0,8,8},
			{"(RARE) Heal On Hit +10 health", "heal on hit for rapidfire",0,10,20},
		},
		EpicAttribute = --4
		{
			{"[EPIC] Damage Bonus +40% / Explosion Radius -40%", "custom",0,1,1},
			{"[EPIC] Gravity Rocket / Explosion Radius +20%", "custom",0,1,1},
			{"[EPIC] Buildings Damage +100%", "dmg bonus vs buildings",1,2,3},
			{"[EPIC] Clip size +100% / Fire/Reload rate +50% / Damage Penalty -50%", "custom",0,1,1},
		},
		LegendaryAttribute = --4
		{
			{"【LEGENDARY】 Reload Full Clip At Once", "reload full clip at once",0,1,1}, --[[재장전 한번에]]
			{"【LEGENDARY】 Tank/Giant Damage +150% / Firing Speed -40%", "custom",0,1,1},
			{"【LEGENDARY】 Two Shot / Primary: Clip Size -2", "custom",0,1,1},
			--{"【LEGENDARY】 Nuker", "custom",0,1,1},
		}
		--[[
			{"Damage Bonus +25%", "damage bonus",1,0.25},
			{"Primary: Clip Size +2", "clip size upgrade atomic",1,2},
			{"Clip Size +50%", "clip size bonus",1,0.5},
			{"Firing Speed +10%", "fire rate bonus",1,-0.1,0.1},
			{"Reload Speed +20%", "faster reload rate",1,-0.2,0.1},
			{"Heal On Kill +25 health", "heal on kill",0,25},
			{"Max Health +25", "max health additive bonus",0,25},
			{"Max Ammo +50%", "custom",1,0.5},
			{"Weapon Switch Speed +30%", "deploy time decreased",1,-0.3,0.1},
			{"Health Regen +2 every second", "health regen",0,2},
			{"Ammo Regen +20% every 5 seconds", "ammo regen",0,0.2,1},
			{"Heal On Hit +15 health", "heal on hit for rapidfire",0,15},
			{"Projectile Speed +25%", "Projectile speed increased",1,0.25},
			{"Banners: Buff Duration +25%", "increase buff duration",1,0.25},
			{"Banners: Rage Gained +25%", "rage giving scale",1,0.25},
			{"Recall On Death +50% chance", "teleport instead of die",0,0.5,1},
			{"Mini-crit Airborne Targets", "mod mini-crit airborne",0,1,1},
			{"Movement Speed +10%", "move speed bonus",1,0.1},
			{"Jump Height +20%", "increased jump height",1,0.2},
			{"Fire Resistance +25%", "dmg taken from fire reduced",1,-0.25,0.25},
			{"Bullet Resistance +25%", "dmg taken from bullets reduced",1,-0.25,0.25},
			{"Blast Resistance +25%", "dmg taken from blast reduced",1,-0.25,0.25},
			{"Crit Resistance +30%", "dmg taken from crit reduced",1,-0.3,0.1},
			{"Melee Resistance +25%", "dmg from melee increased",1,-0.25,0.25},
			{"(RARE) Explosion Radius +30% / ", "Blast radius increased",1,0.3},
			{"(RARE) Drop On Kill: Small Health Pack", "drop health pack on kill",0,1,1},
			{"(RARE) Rocket Specialist", "rocket specialist",0,1,1},
			{"(RARE) Extra Jump +1", "air dash count",0,1},
			{"(RARE) Explosion Radius +30%", "Blast radius increased",1,0.3},
			{"【LEGENDARY】 Crit On Kill +3 seconds", "critboost on kill",0,3},
			{"【LEGENDARY】 Mini-crits become Crits", "minicrits become crits",0,1,1},
			{"【LEGENDARY】 All Healing Received +100%", "healing received bonus",1,1},
			{"【LEGENDARY】 Mark for Death On Hit", "mark for death",0,1,1},
		]]
	},
	[7] = --Pyro Shop
	{
		CommonAttribute =
		{
			{"Melee Resistance +30%", "dmg from melee increased",1,-0.3,0.1},
			{"Push Force -25%", "damage force reduction",1,-0.2,0.05},
			{"Reload Speed +25% / Clip Size +50%", "custom",0,1,5},
			{"Secondary Fire Rate +15%", "fire rate bonus",1,-0.15,0.3},
			{"Health +25 / -20% OverHealed", "custom",0,1,4},
			{"Weapon Switch Speed +25%", "deploy time decreased",1,-0.25,0},
			{"Flares: Projectile Speed +25%", "Projectile speed increased",1,0.25,2.5},
			{"Reflected Projectile Speed +100%", "mult reflect velocity",1,1,4},
		},
		RareAttribute =
		{
			{"(RARE) Airblasting Teammates Gives Speed Boost", "airblast_give_teammate_speed_boost",0,1,1},
			{"(RARE) Wet Immune", "wet immunity",0,1,1},
			{"(RARE) Stun Immune", "mult stun resistance",1,-1,0},
			{"(RARE) Ignored by Enemy Sentries", "ignored by enemy sentries",0,1,1},
			{"(RARE) Slow On Hit", "slow enemy on hit",0,1,1},
		},
		EpicAttribute =
		{
			{"[EPIC] Recall On Death +100% chance", "teleport instead of die",0,1,1},
			{"[EPIC] Extra Jump +2", "air dash count",0,2,2},
			{"[EPIC] Airblast Size +100% / Can't Airblast Airborne", "custom",0,1,1},
			{"[EPIC] Airblast Refire Speed +50% / Airblast Cost +100%", "custom",0,1,1},
			{"[EPIC] Airblast Dash", "airblast dashes",0,1,1},
		},
		LegendaryAttribute =
		{
		    
			{"【LEGENDARY】 Damage Bonus +50% / Flame Range/Projectiles Speed/Clip size -50% / Flame Ammopersec x2", "custom",0,1,1}, --딜1.5배 화방사거리 -50%, 화방소모량 +100%
			{"【LEGENDARY】 Ground Flame / Flame life +500% / burn dmg +800% / Damage/Max ammo -70%", "custom",0,1,1}, --화염 수명 5배, 오래있을수록 화염크기 증가, 딜 -50%, 화상딜 2배
			{"【LEGENDARY】 Health on Hit 3 / Flame Ammopersec x4 / Airblast Disabled", "custom",0,1,1}, --적중시 3최복, 화방 탄소모량 4배, 붕붕 불가
		},
		--[[
			{"Movement Speed +20%", "move speed bonus",1,0.2,1.2},
			{"All Max Ammo +25%", "custom",1,0.25,2},
			{"Health Regen +8 every second", "health regen",0,8,8},
			{"All Resistance +15", "custom",0,1,5},
			{"Ammo Regen +20% every 5 seconds", "ammo regen",0,0.2,0.4},
			{"Heal On Kill +35 health", "heal on kill",0,35,105},
			{"Health +50 / -50% OverHealed", "custom",0,1,2},
			{"Melee Resistance +25%", "dmg from melee increased",1,-0.25,0.25},
			{"Max Health +25", "max health additive bonus",0,25},
			{"Jump Height +20%", "increased jump height",1,0.2},
			{"Clip Size +50% / Faster Reload + 25%", "custom",0,1,4},
			{"Weapon Ammo -20%/+50%/Secondary Fire Rate +25%", "custom",0,1,3},
			{"Secondary Fire Rate +35%", "fire rate bonus",1,-0.35,0.3},
			{"Flame Ammo Consumption -25%", "flame ammopersec decreased",1,-0.25,0},
			{"Weapon Switch Speed +35%", "deploy time decreased",1,-0.45,0.1},
			{"Afterburn Damage +100%", "weapon burn dmg increased",1,1},
			{"Flares: Projectile Speed +25%", "Projectile speed increased",1,0.25},
			{"Thermal Thruster: Mid-Air Relaunch", "thermal_thruster_air_launch",0,1,1},
			{"Thermal Thruster: Stun Targets On Landing", "falling_impact_radius_stun",0,1,1},
			{"Airblasting Teammates Gives Speed Boost", "airblast_give_teammate_speed_boost",0,1,1},
			{"Reflected Projectile Speed +100%", "mult reflect velocity",1,1,2},
			{"(RARE) Crit Damage +100% / No Medic Healing", "custom",0,1,2},
			{"(RARE) All Thermal Thruster Mod/Stompy", "custom",0,1,1},
		    {"(RARE) Damage Bonus +25%", "damage bonus",1,0.25},
			{"(RARE) Gas Passer: Explode On Ignite", "explode_on_ignite",0,1,1},
			{"(RARE) Afterburn Damage + 300%", "weapon burn dmg increased",1,2,7},
			{"(RARE) Damage Mult +35%/Primary Ammo -30%/Switch +40%", "custom",0,1,3},
			{"(RARE) Bullet Per Shot +50%", "bullets per shot bonus",1,0.5,3},
			{"(FREE) Airblast Override Mod : Efficiency", "custom",0,1,1},
			{"(FREE) Airblast Override Mod : Power", "custom",0,1,1},
			{"(FREE) Airblast Override Mod : Repressure", "custom",0,1,1},
			{"(RARE) Drop On Kill: Small Health Pack", "drop health pack on kill",0,1,1},
			{"(RARE) Recall On Death +100% chance", "teleport instead of die",0,1,1},
			{"(RARE) Extra Jump +1", "air dash count",0,1},
			{"(RARE) Flame Size +50%", "flame size bonus",1,0.50},	--wrong attribute
			{"(RARE) Flame Distance +50%", "flame life bonus",1,0.50},	--wrong attribute
			{"(RARE) Airblast Ammo Consumption -75%", "airblast cost decreased",1,-0.75,0.25},	--buffing it will bring damnation
			{"(RARE) Slow On Hit", "slow enemy on hit",0,1,1},
			{"(RARE) Speed Boost On Kill +5 seconds", "speed_boost_on_kill",0,5,5},
			{"[EPIC] Heal On Hit +4 health", "health on radius damage",0,4,4},
			{"[EPIC] Flame Life x4/Gravity", "custom",0,1,1},
			{"[EPIC] Flame Speed x1.3", "custom",0,1,1},
			{"[EPIC] Flame Speed x0.2 / Damage mult x2", "custom",0,1,1},
			{"[EPIC] Burn Time x20", "weapon burn time increased",0,20,20},
			{"[EPIC] Mini-crits to Crits", "minicrits become crits",0,1,1},
			{"[EPIC] Tank Damage Bonus +50%", "mult dmg vs tanks",1,0.5,2},
			{"[EPIC] Primary: Crits From Behind", "mod flamethrower back crit",0,1,1},
			{"[EPIC] Airblast Refire Speed +50%", "mult airblast refire time",1,-0.5,0},	--buffing it will bring damnation
			{"【LEGENDARY】 Crit On Kill +1s", "critboost on kill",0,1},
			{"【LEGENDARY】 Damage Mult x1.5", "dmg penalty vs players",1,0.5,1.5},
			{"【LEGENDARY】 Extra Upgrade", "custom",0,1,2},
			{"【LEGENDARY】 Dragon's Fury", "mult_item_meter_charge_rate",1,-0.3,0.7},
			{"【LEGENDARY】 Very Big Pyro", "custom",0,1,1},
			{"【LEGENDARY】 Double Healing", "healing received bonus",0,1,1},
			{"【LEGENDARY】 Mark for Death On Hit", "mark for death",0,1,1},
			{"【LEGENDARY】 300% Damage On Burning", "damage bonus vs burning",1,2,3},	--wat is dis
		]]
	},
	[4] = --Demoman Shop
	{
		CommonAttribute = --8
		{
			{"Max Health +10", "max health additive bonus",0,10,30},
			{"Shield Control x5 / Push Force -25%", "custom",0,1,3},
			{"Melee Attack Width / Range +30%", "custom",0,1,4},
			{"Stickybombs: Deto Time -0.05 seconds", "sticky arm time bonus",0,-0.05,-0.2},
			{"Projectile Speed +15%", "Projectile speed increased",1,0.15,1.9},
			{"Self Blast -30%", "blast dmg to self increased",1,-0.3,0.1},
			{"B.A.S.E. Jumper: Infinite Redeploy", "parachute redeploy",0,1,1},
			{"Max Stickybombs +1", "max pipebombs increased",1,1,3},
		},
		RareAttribute = --5
		{
			{"(RARE) Fall Damage Immune", "cancel falling damage",0,1,1},
			{"(RARE) Projectiles Cannot Be Deflected", "projectile no deflect",0,1,1},
			{"(RARE) Explosion Radius +25% / Reload Speed -15%", "custom",0,1,2},
			{"(RARE) Pipebombs: Explode On Impact", "grenade explode on impact",0,1,1},
			{"(RARE) Melee Hit Refill Charge +100% / Attack Not Cancel Charge", "custom",0,1,1}
		},
		EpicAttribute = --5
		{
			{"[EPIC] Passive Reload", "passive reload",0,1,1},
			{"[EPIC] Grenade Fuse x0.3 / Detonation DMG x1.5", "custom",0,1,1},
			{"[EPIC] Charge impact damage +1500% / charge time +5s", "custom",0,1,1},
			{"[EPIC] Cleave Attack / Melee Hit 0.4s Dodge", "custom",0,1,1},
			{"[EPIC] Tank Damage Bonus +75%", "mult dmg vs tanks",1,0.75,1.75},
		},
		LegendaryAttribute = --4
		{
			{"【LEGENDARY】 Nuke", "custom",0,1,1},
			{"【LEGENDARY】 Reload Full Clip At Once", "reload full clip at once",0,1,1}, --[[재장전 한번에]]
			{"【LEGENDARY】 Health +400 / Hit on heal +25 / Max Ammo -95%", "custom",0,1,1},
			{"【LEGENDARY】 Bazooka/Fire Rate x2/No Melee", "custom",0,1,1},
		}
		--[[
		
			{"All Resistance +15", "custom",0,1},
			{"Heal On Kill +35 health", "heal on kill",0,35,105},
			{"Melee Resistance +50%", "dmg from melee increased",1,-0.5,0.5},
			{"Health Regen +4 every second", "health regen",0,4,8},
			{"All Max Ammo +25%", "custom",1,0.25},
			{"Self Blast -50%", "blast dmg to self increased",1,-0.5,0.01},
			{"Fire Resistance +30%", "dmg taken from fire reduced",1,-0.3,0.1},
			{"Crit Resistance +30%", "dmg taken from crit reduced",1,-0.3,0.1},
			{"Bullet Resistance +25%", "dmg taken from bullets reduced",1,-0.25,0.25},
			{"Blast Resistance +25%", "dmg taken from blast reduced",1,-0.25,0.25},
			{"Firing Speed +20%", "fire rate bonus",1,-0.2,0.2},
			{"Reload Speed +25%", "faster reload rate",1,-0.2,0.25},
			{"Damage +10%/Charge Recharge +75%/Time +1", "custom",0,1,5},
			{"Primary: Clip Size +2", "clip size upgrade atomic",0,2,12},
			{"Blast Radius -35%/Damage mult +25%", "custom",0,1,4},
			{"Fire Rate +25% / Secondary Ammo -50%", "custom",0,1,4},
			{"Health +50 / -25% OverHealed", "custom",0,1},
			{"Clip Size +50%", "clip size bonus",1,0.5},
			{"Weapon Switch Speed +35%", "deploy time decreased",1,-0.35,0},
			{"Shields: Charge Recharge Rate +100%", "charge recharge rate increased",1,1},
			{"Shields: Charge Duration +2 second", "charge time increased",1,2},
			{"Faster Move Speed On Shield +20%", "move speed bonus shield required",0,0.2,2},
			{"Ammo Regen +20% every 5 seconds", "ammo regen",0,0.2,1},
			{"Push Force -35%", "damage force reduction",1,-0.35,0},
			{"Max Stickybombs +2", "max pipebombs increased",1,2},
			{"Drop On Kill: Small Health Pack", "drop health pack on kill",0,1,1},
			{"(FREE) Health +50 / Weapon Ammo -10%/-20%", "custom",0,1,8},
			{"(RARE) Damage Bonus +25%", "damage bonus",1,0.25,2},
			{"(RARE) Heal On Hit +15 health", "heal on hit for rapidfire",0,15},
			{"(FREE) Movement Speed +10%", "custom",1,0.1,1.4},
			{"(RARE) Speed Boost On Kill +5 seconds", "speed_boost_on_kill",0,5,5},
			{"(RARE) Extra Jump +1", "air dash count",0,1},
			{"(RARE) Clip Size +50% / Spread Angle -2", "custom",0,1,3},
			{"(RARE) Crit On Kill +5s / -100% Clip Size", "custom",0,1,1},
			{"[EPIC] Fire Rate x2 / Sticky Slower Detonate 0.4", "custom",0,1,1},
			{"[EPIC] Ranged Resistance +25% / Jump x2.5", "custom",0,1,1},
			{"[EPIC] Rolling Grenade Damage x4/Damage x0.8", "custom",0,1,1},
			{"[EPIC] Tank Damage Bonus +50%", "mult dmg vs tanks",1,0.5},
			{"[EPIC] Recall On Death +50% chance", "teleport instead of die",0,0.5,1},
			{"[EPIC] Stickybombs: Charging Increases Damage +35%", "stickybomb_charge_damage_increase",1,0.35},
			{"【LEGENDARY】 Mini-crits become Crits", "minicrits become crits",0,1,1},
			{"【LEGENDARY】 Heal on Kill", "restore health on kill",0,1,1},
			{"【LEGENDARY】 Mark for Death On Hit", "mark for death",0,1,1},
			{"【LEGENDARY】 Nuke", "custom",0,1,1},
			{"【LEGENDARY】 Train", "charge impact damage increased",0,20,20},
			{"【LEGENDARY】 Extra Upgrade", "custom",0,1,2},
		]]
	},
     [6] = --Heavy Shop
	{
		CommonAttribute = --9
		{
			{"Health +25 / -20% OverHealed", "custom",0,1,4},
			{"Push Force -20%", "damage force reduction",1,-0.2,0.2},
			{"Melee Resistance +20%", "dmg from melee increased",1,-0.2,0.2},
			{"Stun Resistance +25%", "mult stun resistance",1,-0.25,0},
			{"Spin up Time +10%", "minigun spinup time increased",1,0.1,1.6},
			{"Reload Speed +25% / Clip Size +50%", "custom",0,1,5},
			{"Consume / Recharge and Switch Faster +20%","custom",0,1,2},
			{"Accuracy +5%", "weapon spread bonus",1,0.05,1.3},
			{"Wet Immune", "wet immunity",0,1,1},
		},
		RareAttribute = --5
		{
			{"(RARE) Ammo Regen +10% every 5 seconds", "ammo regen",0,0.1,0.2},
			{"(RARE) Spun Up Protection 50% Below 50% Health", "spunup_damage_resistance",1,-0.5,0.5},
			{"(RARE) Speed Boost On Kill +8 seconds", "speed_boost_on_kill",0,8,8},
			{"(RARE) Switch Weapons While Spinning", "mod minigun can holster while spinning",0,1,1},
			{"(RARE) Ring Of Fire", "ring of fire while aiming",0,1,1},
			{"(RARE) Afterburn Immune", "afterburn immunity",0,1,1},
		},
		EpicAttribute = --5
		{
			{"[EPIC] No Spin up", "custom",0,1,1},
			{"[EPIC] Override Firing Mod : Spread", "custom",0,1,1}, -- Bullet Per Shot +50% / Damage Mult x0.5 / Spread =1.3
			{"[EPIC] All Healing Received +75%", "healing received bonus",1,0.75,2.5},
			{"[EPIC] Recall On Death +100% chance", "teleport instead of die",0,1,1},
			{"[EPIC] Mini-crits to Crits/No Dispenser for Minigun", "custom",0,1,1},
			{"[EPIC] Explosive Ammo", "explosive bullets",0,100,100},
		},
		LegendaryAttribute = --4
		{
			{"【LEGENDARY】 Size x1.5 / +250 Health / Move Speed -20%", "custom",0,1,1},
			{"【LEGENDARY】 Crit on kill 2s", "critboost on kill",0,2,2},
			{"【LEGENDARY】 Rocket Minigun", "custom",0,1,1},
		}
		--[[
		
			
			{"All Resistance +15", "custom",0,1},
			{"Blast Resistance +20%", "dmg taken from blast increased",1,-0.2,0.8},
			{"Bullet Resistance +20%", "dmg taken from bullets increased",1,-0.2,0.8},
			{"Fire Resistance +20%", "dmg taken from fire increased",1,-0.2,0.8},
			{"Movement Speed +20%", "move speed bonus",1,0.2,1.6},
			{"Jump Height +20%", "increased jump height",1,0.2},
			{"Weapon Switch Speed +35%", "deploy time decreased",1,-0.35,0},
			{"All Max Ammo +25%", "custom",1,0.25,2},
			{"Secondary: Reload Speed +20%", "faster reload rate",1,-0.2,0.1},
			{"Heal On Hit +2 health", "heal on hit for rapidfire",0,2},
			{"Health Regen +4 every second", "health regen",0,4,12},
			{"Consume / Recharge and Switch Faster +40%","custom",0,1,2},
			{"(RARE) Tank Damage Bonus +60%", "mult dmg vs tanks",1,0.6,0.6},
			{"(RARE) Extra Jump +1 Jump Height +20%","custom",0,1,1},
			{"(FREE) Heal On Kill +25 health", "custom",0,1,4},
		    {"(FREE) Fire Rate +25% / Primary Ammo -50%", "custom",0,1,4},
			{"(RARE) Damage Mult +25%/Spread -40%/Primary Ammo -25%", "custom",0,1,2},
			{"(RARE) Projectile Penetration +1", "projectile penetration heavy",0,1,3},
			{"(RARE) Destroy Projectiles", "attack projectiles",0,1,2},
			{"(RARE) Rage Knockback", "generate rage on damage",0,2,2},
			{"(RARE) Firing Rate +15%", "fire rate bonus",1,-0.15,0.55},
			{"(RARE) Weapon Switch On-Spin / Faster Switch", "custom",0,2,1},
			{"(RARE) Ranged Resistance -5%", "dmg from ranged reduced",1,-0.80,0.2},
			{"(RARE) Minigun Destroy Projectiles", "attack projectiles",0,2,2},
			{"(RARE) Damage Mult +25% / Slower Spun up +75%", "custom",0,1,3},
			{"(RARE) Slow On Hit", "slow enemy on hit",0,1,1},
			{"(RARE) Drop On Kill: Small Health Pack", "drop health pack on kill",0,1,1},
			{"(RARE) Extra Jump +1", "air dash count",0,1},
			{"[EPIC] Override Firing Mod : Single", "custom",0,1,1},	-- Bullet Per Shot -75% / Damage Mult x2.5 / Spread =0.3
			{"[EPIC] Override Firing Mod : Focus", "custom",0,1,1},
			{"[EPIC] Override Firing Mod : Burst", "custom",0,1,1},
			{"[EPIC] Damage x1.5 Below 50% Health / -50% Healed", "custom",0,1,2},
			{"[EPIC] Damage x2 / Above 50% Health x0.8", "custom",1,0.2,1.2},
			{"[EPIC] Fire Rate + on Reduced Health", "custom",0,1,1},
			{"[EPIC] Damage Bonus +25%", "damage bonus",1,0.25,1.5},
			{"【LEGENDARY】 Crit vs Burning", "crit vs burning players",0,1,1},
			{"【LEGENDARY】 No Reload", "faster reload rate",1,-1,0},
			{"【LEGENDARY】 Punch to Rage", "custom",1,-1,0},
			{"【LEGENDARY】 Extra Upgrade", "custom",0,1,2},
			{"【LEGENDARY】 Double Speed", "major move speed bonus",1,1,2},
			{"【LEGENDARY】 Mini-crits become Crits", "minicrits become crits",0,1,1},
			{"【LEGENDARY】 Crit On Kill +3 seconds", "critboost on kill",0,3},
			{"【LEGENDARY】 Mark for Death On Hit", "mark for death",0,1,1},
		]]
	},
	[9] = --Engineer Shop
	{
		CommonAttribute = --9
		{
			{"Melee Resistance +25%", "dmg from melee increased",1,-0.25,0.25},
			{"Health +30 / -20% OverHealed", "custom",0,1,3},
			{"Weapon Switch Speed +45%", "deploy time decreased",1,-0.45,0.1},
			{"Recall On Death +50% chance", "teleport instead of die",0,0.5,1},
			{"Dispenser Heal/Resupply +25%", "mult dispenser rate",1,0.25,2},
			{"Increased Metal From Ammo +25%", "metal_pickup_decreased",1,0.25,2},
			{"Wrench Repair/Construction Speed +20%", "custom",0,1,4},
			{"Sentry Max Ammo +15%", "mvm sentry ammo",1,0.15,1.9},
			{"Dispenser Range +100%", "engy dispenser radius increased",1,1,3},
		},
		RareAttribute = --5
		{
			{"(RARE) Extra Jump +1", "air dash count",0,1},
			{"(RARE) Building Max Health +20% / Sentry Damage -15%","custom",0,1,2},
			{"(RARE) Teleporter Mastery (Speed Boost / Fast Recharge)","custom",0,1,1},
			{"(RARE) Max Metal +150% / Move Speed -20%","custom",0,1,1},
			{"(RARE) Reload Speed +40% / Clip Size +40% / Accuracy +80%","custom",0,1,1},
		},
		EpicAttribute = --5
		{
			{"[EPIC] 100 Metal to pick up your targeted building from long range", "engineer building teleporting pickup",0,100,100},
			{"[EPIC] Construction Cost -100%", "building cost reduction",1,-1,0},
			{"[EPIC] Build Speed +100%", "build rate bonus",1,-1,0},
			{"[EPIC] Upgrade Speed +300%", "upgrade rate decrease",1,3,7},
			{"[EPIC] On Hit: damage dealt is returned as ammo", "add onhit addammo",0,1,1},
		},
		LegendaryAttribute = --3
		{
			{"【LEGENDARY】 Friendly Enemy Sentry / Disposable Sentry +7 / 1 lvl Build Only", "custom",0,1,1},
			{"【LEGENDARY】 Sentry Overcharge (rapid fire mod)", "sentry rapid fire",0,1,1},
			{"【LEGENDARY】 Rocket Sentry (Rocket fire rate +75%/Specialist / Sentry fire rate -50%)", "custom",0,1,1},
			--{"【LEGENDARY】 Extra Upgrade", "custom",0,1,1},
		}
		
		--[[
			--{"(RARE) Metal Regen +50 every 5 seconds", "metal regen",0,50,50},
			{"Heal On Hit +5 health", "heal on hit for rapidfire",0,5,15},
            {"Weapons: Damage Bonus +25%", "damage bonus",1,0.25},
			{"Weapons: Clip Size +50%", "clip size bonus",1,0.5},
			{"Weapons: Firing Speed +15%", "fire rate bonus",1,-0.15,0.1},
			{"Weapons: Reload Speed +20%", "faster reload rate",1,-0.2,0.1},
			{"Weapons: Max Ammo +50%", "custom",1,0.5},
			{"Heal On Kill +25 health", "heal on kill",0,25},
			{"Heal On Hit +15 health", "heal on hit for rapidfire",0,15,45},
			{"Max Metal Capacity +50%", "maxammo metal increased",1,0.50},
			{"Building Max Health +100%", "engy building health bonus",1,1},
			{"Sentry Firing Speed +10%", "engy sentry fire rate increased",1,-0.1,0.8},
			{"Sentry Damage Bonus +10%", "engy sentry damage bonus",1,0.1,1.3},
			{"Projectile Penetration", "projectile penetration",0,1,1},
			{"Sentry Range +50%", "engy sentry radius increased",1,0.5,5},
			{"Sentry Rocket Firing Speed +25%", "mult firerocket rate",1,-0.25,0},
			{"Sentry Rocket Specialist", "rocket specialist",0,2,4},
			{"Damage Bonus vs Sentry's Target +30%", "damage bonus bullet vs sentry target",1,0.3},
			{"Tank Damage Bonus +50%", "mult dmg vs tanks",1,0.5},
			{"Weapons Accuracy +100%", "weapon spread bonus",1,-1,0},
			{"Crit On Kill +6 seconds", "critboost on kill",0,6,6},
			{"Mini-crits become Crits", "minicrits become crits",0,1,1},
			{"All Healing Received +200%", "healing received bonus",1,2,2},
			{"Mark for Death On Hit", "mark for death",0,1,1},
		]]
	},
	[5] = --Medic Shop
	{
		CommonAttribute = --9
		{
			{"Health +10 / -15% OverHealed", "custom",0,1,3},
			{"Melee Resistance +25%", "dmg from melee increased",1,-0.25,0.25},
			{"Weapon Switch Speed +25%", "deploy time decreased",1,-0.25,0.25},
			{"Push Force -20%", "damage force reduction",1,-0.2,0.2},
			{"Overheal Speed +20%", "overheal fill rate reduced",1,0.2,1.8},
			--{"Overheal Not Decay", "overheal decay disabled",0,1,1},
			{"Medigun Range +25%", "mult medigun range",1,0.25,2},
			{"All Healing Received +25%", "healing received bonus",1,0.25,2},
			{"Wet Immune", "wet immunity",0,1,1},
		},
		RareAttribute = --5
		{
			{"(RARE) Extra Jump +1", "air dash count",0,1,2},
			{"(RARE) Heal Buildings +50% healing", "medic machinery beam",0,5,10},
			--{"(RARE) Heal Buildings +50% healing", "medigun passive attributes",0,5,10},
			{"(RARE) Melee Attacks Cleave All Targets", "melee cleave attack",0,1,1},
			{"(RARE) Mixed Concoction On Hit", "custom",0,1,1},
			{"(RARE) Backstabbed/Afterburn Immune", "custom",0,1,1},
			--{"(RARE) Canteen Specialist", "canteen specialist",0,1,3},
		},
		EpicAttribute = --4
		{
			{"[EPIC] Shield Duration +30% / Canteen Specialist -1", "custom",0,1,2},
			{"[EPIC] Recall On Death +100% chance", "teleport instead of die",0,1,1},
			{"[EPIC] Revive Speed +200%", "revive rate",1,2,3},
			{"[EPIC] Vaccinator Selected Type 100% Resist / UberCharge Rate -100%", "custom",0,1,1},
			{"[EPIC] Invulnerable On Taking Damage +30% Chance", "uber on damage taken",0,0.3,0.3},
		},
		LegendaryAttribute = --4
		{
			{"【LEGENDARY】 Heal Rate +500% / Can't Overheal", "custom",0,1,1},
			{"【LEGENDARY】 Max Overheal +300% / Heal Rate -75%", "custom",0,1,1},
			{"【LEGENDARY】 UberCharge Rate +500% / Uber Duration -6 seconds", "custom",0,1,1},
			--{"【LEGENDARY】 3 Type re / Can't Overheal", "custom",0,1,1}, --치료시 올저항 100%, 치료량 -80%
		}
		--[[
			{"Heal Rate +15%", "heal rate bonus",1,0.15,1.75},
			{"Max Overheal +15%", "overheal bonus",1,0.15,1.75},
			{"Damage Bonus +25%", "damage bonus",1,0.25},
			{"Clip Size +50%", "clip size bonus",1,0.5},
			{"Clip Size +2", "clip size upgrade atomic",1,2},
			{"Firing Speed +10%", "fire rate bonus",1,-0.1,0.1},
			{"Reload Speed +20%", "faster reload rate",1,-0.2,0.1},
			{"Heal On Kill +25 health", "heal on kill",0,25},
			{"Max Health +25", "max health additive bonus",0,25},
			{"Max Ammo +50%", "custom",1,0.5},
			{"Heal On Hit +3 health", "heal on hit for rapidfire",0,3},
			{"ÜberCharge Rate +25%", "ubercharge rate bonus",1,0.25},
			{"Healing Mastery", "healing mastery",0,1},
			{"Heal Rate +25%", "heal rate bonus",1,0.25},
			{"Overheal Expert", "overheal expert",0,1},
			{"Max Overheal +25%", "overheal bonus",1,0.25},
			{"Overheal Duration +50%", "overheal bonus",1,0.25},
			{"Push Force -30%", "damage force reduction",1,-0.3,0.1},
			{"Movement Speed +10%", "move speed bonus",1,0.1},
			{"Jump Height +20%", "increased jump height",1,0.2},
			{"Weapon Switch Speed +70%", "deploy time decreased",1,-0.7,0.3},
			{"Fire Resistance +25%", "dmg taken from fire reduced",1,-0.25,0.25},
			{"Crit Resistance +30%", "dmg taken from crit reduced",1,-0.3,0.1},
			{"Bullet Resistance +25%", "dmg taken from bullets reduced",1,-0.25,0.25},
			{"Blast Resistance +25%", "dmg taken from blast reduced",1,-0.25,0.25},
			{"Melee Resistance +25%", "dmg from melee increased",1,-0.25,0.25},
			{"Health Regen +2 every second", "health regen",0,2},
			{"Ammo Regen +20% every 5 seconds", "ammo regen",0,0.2,1},
			{"(RARE) Melee Attacks Cleave All Targets", "melee cleave attack",0,1,1},
			{"(RARE) Projectile Shield", "generate rage on heal",0,1,2},
			{"(RARE) Extra Jump +1", "air dash count",0,1},
			{"(RARE) Mad Milk Syringes", "mad milk syringes",0,1,1},
			{"(RARE) Medigun Range +25%", "mult medigun range",1,0.25},
			{"(RARE) Revive Speed +40%", "revive rate",1,0.4},
			{"(RARE) Speed Boost On Kill +5 seconds", "speed_boost_on_kill",0,5,5},
			{"【LEGENDARY】 Mini-crits become Crits", "minicrits become crits",0,1,1},
			{"【LEGENDARY】 Gain Über On Hit +1%", "add uber charge on hit",0,0.01,0.01},
		]]
	},
	[2] = --Sniper Shop
	{
		CommonAttribute = --8
		{
			{"Weapon Switch Speed +25%", "deploy time decreased",1,-0.25,0.25},
			{"Recall On Death +50% chance", "teleport instead of die",0,0.5,1},
			{"Tank Damage Bonus +20%", "mult dmg vs tanks",1,0.2,2},
			{"Building Damage Bonus +20%", "dmg bonus vs buildings",1,0.2,2},
			{"No move speed penalty from zoom", "zoom speed mod disabled",0,1,1},
			{"Meter Effect/Debuff Duration +15%", "mult effect duration",1,0.15,1.9},
			{"Consumable Recharge Rate +15%", "charge recharge rate increased",1,0.15,1.9},
			{"Afterburn Immune", "afterburn immunity",0,1,1},
		},
		RareAttribute = --5
		{
			{"(RARE) SMGs: Headshots Enabled", "can headshot",0,1,1},
			{"(RARE) Extra Jump +1", "air dash count",0,1},
			{"(RARE) Secondary Maxammo +50% / Clip Size +50% / Accuracy +100%","custom",0,1,1},
			{"(RARE) Backstabbed Immune", "cannot be backstabbed",0,1,1},
			{"(RARE) Bows: Arrow Mastery", "arrow mastery",0,1,3},
		},
		EpicAttribute = --5
		{
			{"[EPIC] Explosive Munitions", "explosive bullets",0,147,147},
			{"[EPIC] No Fliching When Scoped", "no damage view flinch",0,1,1},
			{"[EPIC] Explosive Headshot +2 / Damage Penalty -30%", "custom",0,1,1},
			{"[EPIC] Ammo Regen +15% every 5 seconds", "ammo regen",0,0.15,0.3},
			{"[EPIC] Damage All Targets Connected By Medigun", "damage all connected",0,1,1},
		},
		LegendaryAttribute = --3
		{
			{"【LEGENDARY】 Full Charge Damage +350% / Charge rate -75% / No headshots when not fully charged", "custom",0,1,1},
			{"【LEGENDARY】 Reload Speed +80% / Damage -70%", "custom",0,1,1},
			{"【LEGENDARY】 SMGs: Never Reload", "mod max primary clip override",0,-1,-1},
			
		}
		--[[
			{"Damage Bonus +25%", "damage bonus",1,0.25},
			{"Secondary: Clip Size +50%", "clip size bonus",1,0.5},
			{"Firing Speed +10%", "fire rate bonus",1,-0.1,0.1},
			{"Reload Speed +20%", "faster reload rate",1,-0.2,0.1},
			{"Heal On Kill +25 health", "heal on kill",0,25},
			{"Max Health +25", "max health additive bonus",0,25},
			{"Max Ammo +50%", "custom",1,0.5},
			{"Movement Speed +10%", "move speed bonus",1,0.1},
			{"Jump Height +20%", "increased jump height",1,0.2},
			{"Health Regen +2 every second", "health regen",0,2},
			{"Ammo Regen +10% every 5 seconds", "ammo regen",0,0.1,1},
			{"Heal On Hit +15 health", "heal on hit for rapidfire",0,3},
			{"Bleed On Hit +5 seconds", "bleeding duration",0,5},
			{"Consumable Recharge Rate +25%", "charge recharge rate increased",1,0.25},
			{"Fire Resistance +25%", "dmg taken from fire reduced",1,-0.25,0.25},
			{"Crit Resistance +30%", "dmg taken from crit reduced",1,-0.3,0.1},
			{"Bullet Resistance +25%", "dmg taken from bullets reduced",1,-0.25,0.25},
			{"Blast Resistance +25%", "dmg taken from blast reduced",1,-0.25,0.25},
			{"Melee Resistance +25%", "dmg from melee increased",1,-0.25,0.25},
			{"(RARE) Projectile Penetration", "projectile penetration",0,1,1},
			{"(RARE) Jarate Slows Targets", "applies snare effect",1,-0.35,0.65},
			{"(RARE) SMGs: Accuracy +100%", "weapon spread bonus",1,-1,0},
			{"(RARE) Recall On Death +50% chance", "teleport instead of die",0,0.5,1},
			{"(RARE) Faster Charge +40%", "SRifle Charge rate increased",1,0.4},
			{"【LEGENDARY】 Mini-crits become Crits", "minicrits become crits",0,1,1},
			{"【LEGENDARY】 Mark for Death On Hit", "mark for death",0,1,1},
		]]
	},
	[8] = --Spy Shop
	{
		CommonAttribute = --8
		{
			{"Health +10 / -15% OverHealed", "custom",0,1,4},
			{"Drop On Kill: Small Health Pack / Health Pack healing +15%", "custom",0,1,5},
			{"Weapon Switch Speed +30%", "deploy time decreased",1,-0.3,0.1},
			{"Credit Collect Range +50%", "mult credit collect range",1,0.5,4},
			{"Health From Credits", "health from credits",0,30,60},
			{"Sapper Damage +50%", "sapper damage bonus",1,0.5,3},
			{"Add Cloak On Kill +10%", "add cloak on kill",0,10,50},
			{"Decloak Speed +20%", "mult decloak rate",1,-0.2,0.2},
			{"Speed Boost On Kill +1s", "speed_boost_on_kill",0,1,5},
		},
		RareAttribute = --6
		{
			{"(RARE) Extra Jump +1", "air dash count",0,1,2},
			{"(RARE) Wet Immune", "wet immunity",0,1,1},
			{"(RARE) Afterburn Immune", "afterburn immunity",0,1,1},
			{"(RARE) Fall Damage Immune", "cancel falling damage",0,1,1},
			{"(RARE) Recall On Death +100% chance", "teleport instead of die",0,1,1},
			--{"(RARE) Sapper Recharge Rate +30% / Cloak Duration -75%", "custom",0,1,2},
			{"(RARE) Reload Speed +40% / Clip Size +40% / Accuracy +80%", "custom",0,1,1},
		},
		EpicAttribute = --4
		{
			{"[EPIC] Disguise On Backstab / disguise speed penalty -1.5s", "custom",0,1,1},
			{"[EPIC] Melee Hit Grants Protection 1s / Fire Rate Penalty -15%", "custom",0,1,1},
			{"[EPIC] Damage All Targets Connected By Medigun", "damage all connected",0,1,1},
			{"[EPIC] Disable Buildings On Hit 8s", "disable buildings on hit",0,8,8},
		},
		LegendaryAttribute = --3
		{
			{"【LEGENDARY】 Headshots Enabled / Explosive Headshot +3", "custom",0,1,1},
			{"【LEGENDARY】 Cloak Duration +200% / Cloak Recharge Rate -100%", "custom",0,1,1},
			{"【LEGENDARY】 Revolver Retains Disguise / ", "keep disguise on attack",0,1,1},
		}
		
		--[[
			{"Damage Bonus +25%", "damage bonus",1,0.25},
			{"Clip Size +50%", "clip size bonus",1,0.5},
			{"Firing Speed +10%", "fire rate bonus",1,-0.1,0.1},
			{"Reload Speed +20%", "faster reload rate",1,-0.2,0.1},
			{"Heal On Kill +25 health", "heal on kill",0,25},
			{"Max Ammo +50%", "custom",1,0.5},
			{"Movement Speed +10%", "move speed bonus",1,0.1},
			{"Jump Height +20%", "increased jump height",1,0.2},
			{"Health Regen +2 every second", "health regen",0,2},
			{"Ammo Regen +20% every 5 seconds", "ammo regen",0,0.2,1},
			{"Heal On Hit +15 health", "heal on hit for rapidfire",0,3},
			{"Robot Sapper Power", "robo sapper",0,1,3},
			{"Armor Penetration", "armor piercing",0,25,100},
			{"Cloak Duration +20%", "cloak consume rate decreased",1,-0.2},
			{"Cloak Recharge Rate +50%", "mult cloak meter regen rate",1,0.5},
			{"Add Cloak On Hit +20%", "add cloak on hit",0,20},
			{"Add Cloak On Kill +30%", "add cloak on kill",0,30},
			{"Fire Resistance +30%", "dmg taken from fire reduced",1,-0.3,0.1},
			{"Crit Resistance +30%", "dmg taken from crit reduced",1,-0.3,0.1},
			{"Bullet Resistance +30%", "dmg taken from bullets reduced",1,-0.3,0.1},
			{"Blast Resistance +30%", "dmg taken from blast reduced",1,-0.3,0.1},
			{"Melee Resistance +30%", "dmg from melee increased",1,-0.3,0.1},
			{"(RARE) Projectile Penetration", "projectile penetration",0,1,1},
			{"(RARE) Revolvers: Accuracy +100%", "weapon spread bonus",1,-1,0},
			{"(RARE) Headshots Enabled", "can headshot",0,1,1},
			{"(RARE) Decloak Speed +50%", "mult decloak rate",1,-0.5,0.01},
			{"(RARE) Backstabs and Saps Store Crits", "sapper kills collect crits",0,1,1},
			{"(RARE) Wet Immune", "wet immunity",0,1,1},
			{"[EPIC] Secondary: Buff/Debuff Duration +50%", "mult effect duration",1,0.5},
			{"[EPIC] Speed Boost On Kill", "speed_boost_on_kill",0,1,1},
			{"[EPIC] Last Bullet Is A Crit", "last shot crits",0,1,1},
			{"[EPIC] Damage Bonus While Disguised +20%", "damage bonus while disguised",1,0.2},
			{"[EPIC] Tank Buster Damage Bonus +300%", "mult dmg vs tanks",1,3},
 			{"【LEGENDARY】 All Healing Received +100%", "healing received bonus",1,1},
		]]
	}
}

--Used for returning the class name
classIndices_Internal = {
    [1] = "Scout",
    [3] = "Soldier",
    [7] = "Pyro",
    [4] = "Demoman",
    [6] = "Heavy",
    [9] = "Engineer",
    [5] = "Medic",
    [2] = "Sniper",
    [8] = "Spy",
}


--[[This table is essential, it will store the SteamID3 of a player and act as a "save file" for the player,
		Things that are stored in here for each player:
			UpgradePoints - how many upgrade points the player has, persists between classes
			RerollPoints - how many rerolls the player has, persists between classes

			An index from [1] to [9] which will represent the player's class
			Inside the index, each class has its own
				hasRolled - boolean, used as a flag if the player has rolled for upgrades on that class
				PurchasedUpgrades - table, which upgrades have been purchased for that player on that class
				MaxedUpgrades - table, which upgrades are maxed for that player on that class
				UpgradeMenu - table, show a unique upgrade menu for that player on that class
			]]
UniqueAccountIDs = {}

--[[Also very important, this table is akin to an emulator's "save state" where it will copy everything from
	UniqueAccountIDs, TotalUpgradePoints, and TotalRerollPoints. In the case that players lose a wave, this table is used
	to store save states]]
WaveState = {}

--[[Finds all func_upgradestation's on the map and lets the player interact with them for bringing up the menu]]
function EnableUpgradeStations()
	for _, v in pairs(ents.FindAllByClass("func_upgradestation")) do
		v:AddCallback(ON_START_TOUCH,
		function(_,player)
		    if player:IsRealPlayer() then
				RollUpgrades(player)
				ShowUpgradeMenu(player)
				player:Print(2, "Weclome to the Randomizer Upgrade Station!")
			end
		end)
		v:AddCallback(ON_END_TOUCH,
		function(_,player)
		    if player:IsRealPlayer() then
				CloseUpgradeMenu(player) --probably redundnant
				player:Print(2, "You have left the Randomizer Upgrade Station.")
			end
		end)
	end
end

--[[Adds the OnSpawn callback so that everytime a player spawns their upgrades are reapplied]]
function OnPlayerConnected(player)
    if player:IsRealPlayer() then
        player:AddCallback(ON_SPAWN, function(player)
			InitUserId(player)
			ReAddPurchasedUpgrades(player)
		end)
    end
end

--[[If the player joins the server for the first time, their SteamID3 is added to UniqueAccountIDs
	Note that the function for pruchasing upgrades is stored here]]
function InitUserId(activator)
	local player = (ents.FindByClass("tf_player_manager", nil)):DumpProperties().m_iAccountID[activator:GetNetIndex()+1]
	if UniqueAccountIDs[player] == nil then
		UniqueAccountIDs[player] =
		{
			UpgradePoints = TotalUpgradePoints,
			RerollPoints = TotalRerollPoints,
		}
	end

	local class = activator:DumpProperties().m_iClass
	if UniqueAccountIDs[player][class] == nil then
		UniqueAccountIDs[player][class] =
		{
			hasRolled = false,
			PurchasedUpgrades = {}, --Stored as key [Upgrade name] with value equal to how many times it was purchased
			MaxedUpgrades = {}, --Used a temporary table, similar to PurchasedUpgrades, probably not needed in style2
			UpgradeMenu =
			{
				timeout = 0,
				title = "Select an upgrade - ",
				itemsPerPage = nil,
				flags = MENUFLAG_BUTTON_EXIT,
				onSelect = function(activator, index, value) --Responsible for subtracting upgrade/reroll points, disabling purchased upgrades
					local player = UniqueAccountIDs[(ents.FindByClass("tf_player_manager", nil)):DumpProperties().m_iAccountID[activator:GetNetIndex()+1]]
					local class = activator:DumpProperties().m_iClass
					local purchased = player[class].PurchasedUpgrades
					local menu = player[class].UpgradeMenu
					local playername = activator:DumpProperties().m_szNetname[1]

					if value ~= "reroll" then
						if purchased[value] == nil then
							purchased[value] = 1
						else
							purchased[value] = purchased[value] + 1
						end

						menu[index].disabled = true
						AddUpgrade(activator, value)

						local upgradetable = {}
						for i in (string.gmatch(value, "[^,]+")) do
							upgradetable[#upgradetable + 1] = i
						end
						local upgrade = upgradetable[1]

						if string.find(upgrade, "(RARE)",1,true) then
							util.PrintToChatAll("\x07ff3d3d"  .. playername .. "\x07fbeccb has purchased: " .. "\x074B69FF".. string.sub(upgrade,1,6) .. "\x07FFD700".. string.sub(upgrade,7,#upgrade) .. "\x07fbeccb Level " .. purchased[value])
						elseif string.find(upgrade, "[EPIC]",1,true) then
							util.PrintToChatAll("\x07ff3d3d"  .. playername .. "\x07fbeccb has purchased: " .. "\x078847FF".. string.sub(upgrade,1,6) .. "\x07FFD700".. string.sub(upgrade,7,#upgrade) .. "\x07fbeccb Level " .. purchased[value])
						elseif string.find(upgrade, "【LEGENDARY】",1,true) then
							util.PrintToChatAll("\x07ff3d3d"  .. playername .. "\x07fbeccb has purchased: " .. "\x07EB4B4B".. string.sub(upgrade,1,15) .. "\x07FFD700".. string.sub(upgrade,16,#upgrade) .. "\x07fbeccb Level " .. purchased[value])
						else
						util.PrintToChatAll("\x07ff3d3d"  .. playername .. "\x07fbeccb has purchased: " .. "\x07FFD700" .. upgrade .. "\x07fbeccb Level " .. purchased[value])
						end

						player.UpgradePoints = player.UpgradePoints - 1

						player[class].hasRolled = false
						RollUpgrades(activator) --after purchasing an upgrade, reroll for new set of upgrades

					else
						RerollUpgrades(activator)
					end

					ShowUpgradeMenu(activator)
				end,
				onCancel = nil
			}
		}
	end
end

--[[Your random number generator, returns a float to allow for decimal probabilities
	In this example, it rolls for rarity first, then rolls a second time to pick an upgrade
	So the probability of a specific upgrade is based on two rng rolls]]
function UpgradeRoulette(activator)
	local number = math.random() --returns float from 0 to 1
	local class = activator:DumpProperties().m_iClass
	local shop = AllShops[class]
	local pool = {}

	if number < 0.81 then
	pool = shop.CommonAttribute
	elseif (number >= 0.81 and number < 0.91) then
		pool = shop.RareAttribute
	elseif (number >= 0.91 and number < 0.96) then
		pool = shop.EpicAttribute
	elseif number >= 0.96 then --probably should be less than 1%
		pool = shop.LegendaryAttribute
	end

	local index = math.random(1,(#pool)) --returns integer from 1 to number of upgrades in pool
	local upgrade = pool[index]

	return upgrade
end

--[[This function calls UpgradeRoulette and sends the chosen upgrades to the upgrade menu]]
function RollUpgrades(activator)
	local player = UniqueAccountIDs[(ents.FindByClass("tf_player_manager", nil)):DumpProperties().m_iAccountID[activator:GetNetIndex()+1]]
	local class = activator:DumpProperties().m_iClass
	local menu = player[class].UpgradeMenu
	local purchased = player[class].PurchasedUpgrades
	local maxed = player[class].MaxedUpgrades

	if player[class].hasRolled ~= true then
		for index = 1, MenuCapacity, 1 do
			menu[index] = {}
			maxed = {}
		end

		for index = 1, MenuCapacity, 1 do
			local upgrade = UpgradeRoulette(activator)
			local upgradestring = table.concat(upgrade,",")

			--[[Used to prevent maxed out upgrades from reappearing in the shop
				Note that this is possibly bugged in style2, will fix later]]
			function CheckMaxed(upgrade)
				local min = upgrade[3]
				local increment = upgrade[4]
				local max = upgrade[5]
				if max ~= nil then
					if maxed[upgradestring] == nil then
						if purchased[upgradestring] == nil then
							maxed[upgradestring] = 0
						else
							maxed[upgradestring] = purchased[upgradestring]
						end
					else
						maxed[upgradestring] = maxed[upgradestring] + 1
					end
					local value = min + maxed[upgradestring] * increment
					if increment > 0 then
						return (tostring(value) >= tostring(max))  --floating point issue
					else
						return (tostring(value) <= tostring(max))
					end
				end
			end

			if CheckMaxed(upgrade) == true then --If upgrade is maxed, reroll
				while CheckMaxed(upgrade) == true do
					upgrade = UpgradeRoulette(activator)
				end
			end

			for i = 1, MenuCapacity, 1 do --If upgrade is duplicate, reroll
				if menu[i].text == upgrade[1] then
					while menu[i].text == upgrade[1] do
						upgrade = UpgradeRoulette(activator)
					end
				end
			end

			menu[index] = {text = upgrade[1], value = table.concat(upgrade,","), disabled = false} --value can't accept tables, only strings/numbers
		end
		player[class].hasRolled = true
	end
end

--Called when the reroll option is selected, subtracts a reroll point
function RerollUpgrades(activator)
	local player = UniqueAccountIDs[(ents.FindByClass("tf_player_manager", nil)):DumpProperties().m_iAccountID[activator:GetNetIndex()+1]]
	local class = activator:DumpProperties().m_iClass

	player.RerollPoints = player.RerollPoints - 1
	player[class].hasRolled = false
	RollUpgrades(activator)
end

--Sets hasRolled to false for all players in the game, usually called on wave end
function ResetRolls()
	for _, v in pairs(UniqueAccountIDs) do
		for i = 1, 9, 1 do
			if v[i] ~= nil then
				v[i].hasRolled = false
			end
		end
	end
end

--[[Apply upgrades to players
	using "custom" allows you do anything you define in the function as an upgrade
	meaning PointTemplate upgrades are possible]]
function AddUpgrade(activator, value)
	local player = UniqueAccountIDs[(ents.FindByClass("tf_player_manager", nil)):DumpProperties().m_iAccountID[activator:GetNetIndex()+1]]
	local class = activator:DumpProperties().m_iClass
	local purchased = player[class].PurchasedUpgrades
	local upgradetable = {}

	for i in string.gmatch(value, "[^,]+") do
		upgradetable[#upgradetable + 1] = i
	end
	local upgrade = upgradetable[1]
	local attributename = upgradetable[2]
	local min = tonumber(upgradetable[3])
	local increment = tonumber(upgradetable[4])
	local max = tonumber(upgradetable[5])

	if attributename == "custom" then
		if upgrade == "Max Ammo +50%" then
			activator:SetAttributeValue("maxammo primary increased",min+increment*purchased[value])
			activator:SetAttributeValue("maxammo secondary increased",min+increment*purchased[value])
			activator:SetAttributeValue("maxammo grenades1 increased",min+increment*2*purchased[value])
		
		--scout
		
		elseif upgrade == "(RARE) Milk hit 6s" then
			activator:SetAttributeValue("add cond on hit",27)
			activator:SetAttributeValue("add cond on hit duration",6)
		elseif upgrade == "【LEGENDARY】 Bullets Per Shot +250% / Firing Speed -150%" then
			activator:SetAttributeValue("bullets per shot bonus",3.5)
			activator:SetAttributeValue("fire rate penalty",2.5)
		elseif upgrade == "【LEGENDARY】 Move speed +100% / Infinite Jump" then
			activator:SetAttributeValue("move speed penalty",0)
			activator:SetAttributeValue("air dash count",50)
		elseif upgrade == "【 SSR 】 은폐 지속 시간 +200% / 은폐 즉시 해제" then
			activator:SetAttributeValue("cloak consume rate decreased",-1)
			activator:SetAttributeValue("mult decloak rate",0.01)
			
			
		--soldier
		
		elseif upgrade == "(RARE) Homing Rocket" then
			activator:SetAttributeValue("mod projectile heat seek power",90)
			activator:SetAttributeValue("mod projectile heat aim error",120)
		elseif upgrade == "[EPIC] Damage Bonus +40% / Explosion Radius -40%" then
			activator:SetAttributeValue("damage bonus",1.4)
			activator:SetAttributeValue("Blast radius decreased",0.6)
		elseif upgrade == "[EPIC] Gravity Rocket / Explosion Radius +20%" then
			activator:SetAttributeValue("projectile gravity",1700)
			activator:SetAttributeValue("Blast radius increased",1.2)
		elseif upgrade == "[EPIC] Clip size +100% / Fire/Reload rate +50% / Damage Penalty -50%" then
			activator:SetAttributeValue("clip size bonus",2)
			activator:SetAttributeValue("fire rate bonus",0.5)
			activator:SetAttributeValue("faster reload rate",0.5)
			activator:SetAttributeValue("damage penalty",0.5)
		elseif upgrade == "【LEGENDARY】 Tank/Giant Damage +150% / Firing Speed -40%" then
			activator:SetAttributeValue("mult dmg vs giants",1.5)
			activator:SetAttributeValue("mult dmg vs tanks",1.5)
			activator:SetAttributeValue("fire rate penalty",1.4)
		elseif upgrade == "【LEGENDARY】 Two Shot / Primary: Clip Size -2" then
			activator:SetAttributeValue("burst fire count",2)
			activator:SetAttributeValue("burst fire rate mult",18)
			activator:SetAttributeValue("fire rate penalty HIDDEN",0.05)
			activator:SetAttributeValue("clip size penalty",0.5)
		elseif upgrade == "【LEGENDARY】 Nuker" then
			activator:SetAttributeValue("clip size penalty",0.01)
			activator:SetAttributeValue("dmg penalty vs players",3)
			activator:SetAttributeValue("fire rate bonus HIDDEN",7)
			activator:SetAttributeValue("Blast radius increased",2)
			activator:SetAttributeValue("clip size upgrade atomic",1)
			activator:SetAttributeValue("use large smoke explosion",1)
			
		--pyro
		
		elseif upgrade == "Health +25 / -20% OverHealed" then
			activator:SetAttributeValue("hidden maxhealth non buffed",25*purchased[value])
			activator:SetAttributeValue("patient overheal penalty",math.max(1+(-0.2*purchased[value]),0.01))
		elseif upgrade == "[EPIC] Airblast Size +100% / Can't Airblast Airborne" then
			activator:SetAttributeValue("mult airblast cone scale",2)
			activator:SetAttributeValue("airblast vertical pushback scale",-1)
		elseif upgrade == "[EPIC] Airblast Refire Speed +50% / Airblast Cost +100%" then
			activator:SetAttributeValue("mult airblast refire time",0.5)
			activator:SetAttributeValue("airblast cost increased",2)
		elseif upgrade == "【LEGENDARY】 Ground Flame / Flame life +500% / burn dmg +800% / Damage/Max ammo -70%" then
			activator:SetAttributeValue("flame_lifetime",6)
			--activator:SetAttributeValue("mult_end_flame_size",6)
			activator:SetAttributeValue("weapon burn dmg increased",9)
			activator:SetAttributeValue("flame_up_speed",-100)
			activator:SetAttributeValue("flame_ignore_player_velocity",1)
			activator:SetAttributeValue("damage penalty",0.3)
			activator:SetAttributeValue("maxammo primary reduced",0.3)
		elseif upgrade == "【LEGENDARY】 Damage Bonus +50% / Flame Range/Projectiles Speed/Clip size -50% / Flame Ammopersec x2" then
			activator:SetAttributeValue("damage bonus",1.5)
			activator:SetAttributeValue("flame_drag",1.8)
			activator:SetAttributeValue("flame ammopersec increased",2)
			activator:SetAttributeValue("mult_item_meter_charge_rate",1.5)
			activator:SetAttributeValue("clip size penalty",0.5)
			activator:SetAttributeValue("Projectile speed decreased",0.5)
		elseif upgrade == "【LEGENDARY】 Health on Hit 3 / Flame Ammopersec x4 / Airblast Disabled" then
			activator:SetAttributeValue("heal on hit for slowfire",3)
			activator:SetAttributeValue("flame ammopersec decreased",5)
			activator:SetAttributeValue("airblast disabled",1)
		
		--demoman

		elseif upgrade == "Melee Attack Width / Range +30%" then
			activator:SetAttributeValue("melee bounds multiplier",1+(0.3*purchased[value]))
			activator:SetAttributeValue("melee range multiplier",1+(0.3*purchased[value]))
		elseif upgrade == "Shield Control x5 / Push Force -25%" then
			activator:SetAttributeValue("mult charge turn control",math.min(5*purchased[value],10))
			activator:SetAttributeValue("damage force reduction",math.max(1+(-0.25*purchased[value]),0.01))
		elseif upgrade == "(RARE) Melee Hit Refill Charge +100% / Attack Not Cancel Charge" then
			activator:SetAttributeValue("charge meter on hit",1)
			activator:SetAttributeValue("Attack not cancel charge",1)
		elseif upgrade == "(RARE) Explosion Radius +25% / Reload Speed -15%" then
			activator:SetAttributeValue("Blast radius increased",1-(0.25*purchased[value]))
			activator:SetAttributeValue("Reload time increased",1+(0.15*purchased[value]))
		elseif upgrade == "[EPIC] Grenade Fuse x0.3 / Detonation DMG x1.5" then
			activator:SetAttributeValue("fuse bonus",0.3)
			activator:SetAttributeValue("grenade detonation damage penalty",3)
		elseif upgrade == "[EPIC] Charge impact damage +1500% / charge time +5s" then
			activator:SetAttributeValue("charge impact damage increased",16)
			activator:SetAttributeValue("charge time increased",5)
		elseif upgrade == "[EPIC] Cleave Attack / Melee Hit 0.4s Dodge" then
			activator:SetAttributeValue("melee grants protection",0.4)
			activator:SetAttributeValue("melee cleave attack",1)
		elseif upgrade == "【LEGENDARY】 Health +400 / Hit on heal +25 / Max Ammo -95%" then
			activator:SetAttributeValue("max health additive penalty",400)
			activator:SetAttributeValue("heal on hit for rapidfire",25)
			activator:SetAttributeValue("maxammo primary reduced",0.05)
			activator:SetAttributeValue("maxammo secondary reduced",0.05)
		elseif upgrade == "【LEGENDARY】 Nuke" then
			activator:SetAttributeValue("clip size penalty",0.01)
			activator:SetAttributeValue("dmg penalty vs players",3)
			activator:SetAttributeValue("fire rate bonus HIDDEN",4)
			activator:SetAttributeValue("Blast radius increased",2)
			activator:SetAttributeValue("clip size upgrade atomic",1)
			activator:SetAttributeValue("override projectile type",17)
			activator:SetAttributeValue("grenade damage reduction on world contact",2)
			activator:SetAttributeValue("use large smoke explosion",1)
		elseif upgrade == "【LEGENDARY】 Bazooka/Fire Rate x2/No Melee" then
			activator:SetAttributeValue("auto fires full clip",1)
			activator:SetAttributeValue("stickybomb charge rate",0.01)
			activator:SetAttributeValue("fire rate penalty HIDDEN",0.5)
			
		--heavy
			
		elseif upgrade == "Health +25 / -20% OverHealed" then
			activator:SetAttributeValue("hidden maxhealth non buffed",25*purchased[value])
			activator:SetAttributeValue("patient overheal penalty",math.max(1+(-0.2*purchased[value]),0.01))
		elseif upgrade == "Consume / Recharge and Switch Faster +20%" then
			activator:SetAttributeValue("charge recharge rate increased",math.max(1-(0.2*purchased[value]),0.2))
			activator:SetAttributeValue("gesture speed increase",math.max(1-(0.2*purchased[value]),0.2))
			activator:SetAttributeValue("deploy time decreased",1-(0.2*purchased[value]))
		elseif upgrade == "Reload Speed +25% / Clip Size +50%" then
			activator:SetAttributeValue("faster reload rate",1-(0.25*purchased[value]))
			activator:SetAttributeValue("clip size bonus",1+(0.5*purchased[value]))
		elseif upgrade == "[EPIC] Mini-crits to Crits/No Dispenser for Minigun" then
			activator:SetAttributeValue("minicrits become crits",1)
			activator:SetAttributeValue("no primary ammo from dispensers while active",1)
		elseif upgrade == "[EPIC] No Spin up" then
			activator:SetAttributeValue("minigun spinup time decreased",0)
			activator:SetAttributeValue("aiming movespeed increased",2.1)
		elseif upgrade == "[EPIC] Override Firing Mod : Spread" then --bamboozle
			activator:SetAttributeValue("bullets per shot bonus",1.5)
			activator:SetAttributeValue("damage bonus HIDDEN",0.8)
			activator:SetAttributeValue("weapon spread bonus",1.3)
			activator:SetAttributeValue("fire rate penalty",1.2)
		elseif upgrade == "【LEGENDARY】 Size x1.5 / +200 Health / Move Speed -20%" then
			activator:SetAttributeValue("model scale",1.5)
			activator:SetAttributeValue("max health additive bonus",250)
			activator:SetAttributeValue("damage force increase",0.5)
			activator:SetAttributeValue("move speed penalty",0.8)
		elseif upgrade == "【LEGENDARY】 Rocket Minigun" then
			activator:SetAttributeValue("override projectile type",2)
			activator:SetAttributeValue("dmg penalty vs players",4)
			activator:SetAttributeValue("projectile spread angle penalty",2)
			activator:SetAttributeValue("fire rate bonus HIDDEN",2)
			
		--engineer
		
		elseif upgrade == "Health +30 / -20% OverHealed" then
			activator:SetAttributeValue("max health additive bonus",30*purchased[value])
			activator:SetAttributeValue("patient overheal penalty",math.max(1+(-0.2*purchased[value]),0.01))
		elseif upgrade == "Wrench Repair,Construction Speed +20%" then
			activator:SetAttributeValue("Construction rate increased",0.2*purchased[value])
			activator:SetAttributeValue("Repair rate increased",0.2*purchased[value])
		elseif upgrade == "(RARE) Reload Speed +40% / Clip Size +40% / Accuracy +80%" then
			activator:SetAttributeValue("faster reload rate",0.6)
			activator:SetAttributeValue("clip size bonus",1.4)
			activator:SetAttributeValue("weapon spread bonus",0.2)
		elseif upgrade == "(RARE) Teleporter Mastery (Speed Boost / Fast Recharge)" then
			activator:SetAttributeValue("mod teleporter speed boost",1)
			activator:SetAttributeValue("mult teleporter recharge rate",0.03)
		elseif upgrade == "(RARE) Building Max Health +20% / Sentry Damage -15%" then
			activator:SetAttributeValue("engy building health bonus",1+(0.2*purchased[value]))
			activator:SetAttributeValue("engy sentry damage bonus",1-(0.15*purchased[value]))
		elseif upgrade == "(RARE) Max Metal +150% / Move Speed -20%" then
			activator:SetAttributeValue("maxammo metal increased",1.5)
			activator:SetAttributeValue("move speed penalty",0.8)
		elseif upgrade == "【LEGENDARY】 Friendly Enemy Sentry / Disposable Sentry +7 / 1 lvl Build Only" then
			activator:SetAttributeValue("ignored by enemy sentries",1)
			activator:SetAttributeValue("engy disposable sentries",5)
			activator:SetAttributeValue("mod wrench builds minisentry",2)
			activator:SetAttributeValue("building max level",1)
		elseif upgrade == "【LEGENDARY】 Rocket Sentry (Rocket fire rate +77%/Specialist / Sentry fire rate -50%)" then
			activator:SetAttributeValue("mult firerocket rate",0.25)
			activator:SetAttributeValue("engy sentry fire rate increased",1.5)
			activator:SetAttributeValue("rocket specialist",1)
		--elseif upgrade == "【LEGENDARY】 Rocket Sentry (Rocket fire rate +70%/Specialist / Sentry fire rate -50%)" then
		--	activator:SetAttributeValue("mult firerocket rate",0.3)
		--	activator:SetAttributeValue("engy sentry fire rate increased",1.5)
		--	activator:SetAttributeValue("rocket specialist",1)
			
		--medic
		
		elseif upgrade == "Health +10 / -15% OverHealed" then
			activator:SetAttributeValue("max health additive bonus",10*purchased[value])
			activator:SetAttributeValue("patient overheal penalty",math.max(1+(-0.15*purchased[value]),0.01))
		elseif upgrade == "(RARE) Backstabbed/Afterburn Immune" then
			activator:SetAttributeValue("cannot be backstabbed",1)
			activator:SetAttributeValue("afterburn immunity",1)
		elseif upgrade == "[EPIC] Vaccinator Selected Type 100% Resist / UberCharge Rate -100%" then
			activator:SetAttributeValue("medigun bullet resist passive",1)
			activator:SetAttributeValue("medigun blast resist passive",1)
			activator:SetAttributeValue("medigun fire resist passive",1)
			activator:SetAttributeValue("ubercharge rate penalty",2)
		elseif upgrade == "[EPIC] Shield Duration +30% / Canteen Specialist -1" then
			activator:SetAttributeValue("increase buff duration",1+(0.3*purchased[value]))
			activator:SetAttributeValue("canteen specialist",-1*purchased[value])
		elseif upgrade == "【LEGENDARY】 UberCharge Rate +500% / Uber Duration -6 seconds" then
			activator:SetAttributeValue("ubercharge rate bonus",6)
			activator:SetAttributeValue("uber duration bonus",-6)
		elseif upgrade == "【LEGENDARY】 Heal Rate +500% / Can't Overheal" then
			activator:SetAttributeValue("heal rate bonus",5)
			activator:SetAttributeValue("overheal penalty",0)
		elseif upgrade == "【LEGENDARY】 Max Overheal +300% / Heal Rate -75%" then
			activator:SetAttributeValue("overheal bonus",4)
			activator:SetAttributeValue("heal rate penalty",0.25)
			
		--sniper
		elseif upgrade == "(RARE) Secondary Maxammo +50% / Clip Size +50% / Accuracy +100%" then
			activator:SetAttributeValue("maxammo secondary increased",1.5)
			activator:SetAttributeValue("clip size bonus",1.5)
			activator:SetAttributeValue("weapon spread bonus",0)
		elseif upgrade == "[EPIC] Explosive Headshot +2 / Damage Penalty -30%" then
			activator:SetAttributeValue("explosive sniper shot",2)
			activator:SetAttributeValue("damage bonus",0.7)
		elseif upgrade == "【LEGENDARY】 Full Charge Damage +350% / Charge rate -75% / No headshots when not fully charged" then
			activator:SetAttributeValue("sniper full charge damage bonus",4.5)
			activator:SetAttributeValue("SRifle Charge rate decreased",0.25)
			activator:SetAttributeValue("sniper no headshot without full charge",1)
		elseif upgrade == "【LEGENDARY】 Reload Speed +80% / Damage -70%" then
			activator:SetAttributeValue("faster reload rate",0.2)
			activator:SetAttributeValue("damage penalty",0.3)
			
		--spy
		elseif upgrade == "Drop On Kill: Small Health Pack / Health Pack healing +15%" then
			activator:SetAttributeValue("drop health pack on kill",1)
			activator:SetAttributeValue("health from packs increased",1+(0.15*purchased[value]))
		elseif upgrade == "(RARE) Sapper Recharge Rate +30% / Cloak Duration -75%" then --75두번
			activator:SetAttributeValue("charge recharge rate increased",1+(0.3*purchased[value]))
			activator:SetAttributeValue("cloak consume rate increased",1-(0.75*purchased[value]))
		elseif upgrade == "[EPIC] Disguise On Backstab / disguise speed penalty -1.5s" then
			activator:SetAttributeValue("disguise on backstab",1)
			activator:SetAttributeValue("disguise speed penalty",-1.5)
		elseif upgrade == "[EPIC] Melee Hit Grants Protection 1s / Fire Rate Penalty -15%" then
			activator:SetAttributeValue("melee grants protection",1)
			activator:SetAttributeValue("fire rate penalty",1.15)
		elseif upgrade == "【LEGENDARY】 Headshots Enabled / Explosive Headshot +3" then
			activator:SetAttributeValue("can headshot",1)
			activator:SetAttributeValue("explosive sniper shot",3)
		elseif upgrade == "【LEGENDARY】 Cloak Duration +200% / Cloak Recharge Rate -100%" then
			activator:SetAttributeValue("cloak consume rate decreased",-1)
			activator:SetAttributeValue("cloak regen rate decreased",0)
			
		end
	elseif attributename ~= "custom" then
		if max ~= nil then
			if increment > 0 then
				activator:SetAttributeValue(attributename,math.min(min+increment*purchased[value],max))
			else
				activator:SetAttributeValue(attributename,math.max(min+increment*purchased[value],max))
			end
		else
			activator:SetAttributeValue(attributename,min+increment*purchased[value])
		end
	end
end

--Give all players specified amount of upgrade points, adds running total to TotalUpgradePoints for late joiners
function AddUpgradePoints(number)
	for _, v in pairs(UniqueAccountIDs) do
		v.UpgradePoints = v.UpgradePoints + number
	end
	TotalUpgradePoints = TotalUpgradePoints + number
end

--Give all players specified amount of rerolls, adds running total to TotalRerollPoints for late joiners
function AddRerollPoints(number)
	for _, v in pairs(UniqueAccountIDs) do
		v.RerollPoints = v.RerollPoints + number
	end
	TotalRerollPoints = TotalRerollPoints + number
end

--Set all players's upgrade points to specified value without adding or subtracting to TotalUpgradePoints
function SetUpgradePoints(number)
	for _, v in pairs(UniqueAccountIDs) do
		v.UpgradePoints = number
	end
end

--Set all players's rerolls to specified value without adding or subtracting to TotalRerollPoints
function SetRerollPoints(number)
	for _, v in pairs(UniqueAccountIDs) do
		v.RerollPoints = number
	end
end

--Iterates upon PurchasedUpgrades table and calls AddUpgrade for each upgrade, called OnSpawn of every player
function ReAddPurchasedUpgrades(activator)
	local player = UniqueAccountIDs[(ents.FindByClass("tf_player_manager", nil)):DumpProperties().m_iAccountID[activator:GetNetIndex()+1]]
	local class = activator:DumpProperties().m_iClass
	local purchased = player[class].PurchasedUpgrades

	for k, _ in pairs(purchased) do
		AddUpgrade(activator, k)
	end
	activator:RefillAmmo()
end

--[[This function will display the shop menu
	It shows how many upgrade levels were purchased and the max if it exists
	It will also show the corresponding class you are playing as in the title
	Shows how many upgrade points are remaining
	Always adds the reroll option to the bottom of the list
	Will disable the shop if the player has no more upgrade points]]
function ShowUpgradeMenu(activator)
	local player = UniqueAccountIDs[(ents.FindByClass("tf_player_manager", nil)):DumpProperties().m_iAccountID[activator:GetNetIndex()+1]]
	local class = activator:DumpProperties().m_iClass
	local menu = player[class].UpgradeMenu
	local purchased = player[class].PurchasedUpgrades

	menu[MenuCapacity+1] = {text="Reroll " .. classIndices_Internal[class] .. " Shop\n    "  .. player.RerollPoints .. " rerolls remaining", value="reroll"}
	if player.RerollPoints == 1 then
		menu[MenuCapacity+1] = {text="Reroll " .. classIndices_Internal[class] .. " Shop\n    "  .. player.RerollPoints .. " reroll remaining", value="reroll"}
	elseif player.RerollPoints <= 0 then
		menu[MenuCapacity+1] = {text="Reroll " .. classIndices_Internal[class] .. " Shop\n    "  .. player.RerollPoints .. " rerolls remaining", value="reroll", disabled = true}
	end

	menu.title = classIndices_Internal[class] .. " Shop\nSelect an upgrade\n" ..  player.UpgradePoints .. " upgrade points remaining\n "
	if player.UpgradePoints == 1 then
		menu.title = classIndices_Internal[class] .. " Shop\nSelect an upgrade\n" .. player.UpgradePoints .. " upgrade point remaining\n "
	elseif player.UpgradePoints <= 0 then
		for i = 1, MenuCapacity+1, 1 do
			menu[i].disabled = true
		end
	end

	for i = 1, MenuCapacity, 1 do
		local value = menu[i].value
		local upgradetable = {}
		for k in string.gmatch(value, "[^,]+") do
			upgradetable[#upgradetable + 1] = k
		end
		local min = upgradetable[3]
		local increment = upgradetable[4]
		local max = upgradetable[5]

		if purchased[value] ~= nil then
			menu[i].text = menu[i].text .. "\n    #: " .. purchased[value]
		else
			menu[i].text = menu[i].text .. "\n    #: 0"
		end
		if max ~= nil then
			menu[i].text = menu[i].text .. "          Max: " .. math.ceil((max-min)/increment) --big brain math
		end
	end

	activator:DisplayMenu(menu)

	for i = 1, MenuCapacity, 1 do
		local value = menu[i].value
		local upgradetable = {}
		for k in string.gmatch(value, "[^,]+") do
			upgradetable[#upgradetable + 1] = k
		end
		upgrade = upgradetable[1]

		menu[i].text = upgrade
	end
end

function CloseUpgradeMenu(activator) --probably redundnant
	activator:HideMenu()
end

function deepCopy(original) --special thx to https://developer.roblox.com
	local copy = {}
	for k, v in pairs(original) do
		if type(v) == "table" then
			v = deepCopy(v)
		end
		copy[k] = v
	end
	return copy
end

function OnWaveSuccess(wave) --업글포인트 설정
	AddUpgradePoints(1)
	AddRerollPoints(1)
end

function OnWaveReset(wave) --on wave reset, load save state from WaveState
	if WaveState[wave] ~= nil then
		TotalUpgradePoints = WaveState[wave].TotalUpgradePoints
		TotalRerollPoints = WaveState[wave].TotalRerollPoints
		UniqueAccountIDs = deepCopy(WaveState[wave].UniqueAccountIDs)
	end
end

function OnWaveInit(wave) --on wave init, create save state in WaveState, reset rolls
	EnableUpgradeStations() --for wave 1
	if WaveState[wave] == nil then
		WaveState[wave] =
		{
			TotalUpgradePoints = TotalUpgradePoints,
			TotalRerollPoints = TotalRerollPoints,
			UniqueAccountIDs = deepCopy(UniqueAccountIDs)
		}
	end
	ResetRolls()
end