function getRandomInt(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.round(Math.random() * (max - min) + min); // The maximum is exclusive and the minimum is inclusive
}
    StartupEvents.registry('palladium:abilities', (event) => {
        event.create('heroes:ability_randomizer')
            .icon(palladium.createItemIcon('palladium:vibranium_circuit'))

            .tick((entity, entry, holder, enabled) => {
                if (enabled) {
                    let username = entity.getGameProfile().getName();
					let username_true = username.toLowerCase();
                    let scoreboard = Utils.server.scoreboard;
					
					let chance_1 = (getRandomInt(1, 100));
					let chance_2 = (getRandomInt(1, 100));
					let chance = Math.round(chance_1 + chance_2 / 2)
					
					let power_max = global.power_amount;
					for (let power_list = 0; power_list <= power_max; power_list++) {
						let power = global['ability_' + power_list];
						let scoreboard_obj_temp = scoreboard.getObjective('Powers.' + power);
						if (scoreboard_obj_temp == null) {
							entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard objectives add Powers." + power + " dummy");
							entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard objectives add Powers.Intuitive." + power + " dummy");
						}
							}
					// F Tier
					if (chance >= 1 && chance <= 15) {
					let random_power = (getRandomInt(1, 7));
					if (random_power == 1) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.NightVision 1");
					}
					if (random_power == 2) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.WaterWalk 1");
					}
					if (random_power == 3) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Luminescent 1");
					}
					if (random_power == 4) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.String_Generation 1");
					}
					if (random_power == 5) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Suffocation_Immunity 1");
					}
					if (random_power == 6) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Wall_Climbing 1");
					}
					if (random_power == 7) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Chromatic_Synthesis 1");
					}
						}
					
					// C Tier
					if (chance >= 16 && chance <= 35) {
						let random_power = (getRandomInt(1, 7));
					if (random_power == 1) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Attraction_Of_Small_Objects 1");
					}
					if (random_power == 2) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Water_Breathing 1");
					}
					if (random_power == 3) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Bone_Protrusion 1");
					}
					if (random_power == 4) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Age_Shifting 1");
					}
					if (random_power == 5) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Gold_Mimicry 1");
					}
					if (random_power == 6) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Stockpile 1");
					}
					if (random_power == 7) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Danger_Sense 1");
						}
					}
					// B Tier 
					if (chance >= 36 && chance <= 86) {
						let random_power = (getRandomInt(1, 8));
					if (random_power == 1) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Augmented_Movement_Potential 1");
					}
					if (random_power == 2) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Geokinetic_Armor 1");
					}
					if (random_power == 3) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Muscle_Inducement 1");
					}
					if (random_power == 4) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Levitation 1");
					}
					if (random_power == 5) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Pocket_Reality 1");
					}
					if (random_power == 6) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Parallel_Processing 1");
					}
					if (random_power == 7) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Ability_Replication 1");
						}
					if (random_power == 8) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Spatial_Armaments 1");
						}						
					}
					
					// A Tier
					if (chance >= 87 && chance <= 94) {
						let random_power = (getRandomInt(1, 5));
					if (random_power == 1) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.PyroKinesis 1");
					}
					if (random_power == 2) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.CryoKinetic_Armoury 1");
					}
					if (random_power == 3) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Catalyst 1");
						}
						if (random_power == 4) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Super_Strength 1");
						}
						if (random_power == 5) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Clairvoyance 1");
						}
					}
					
					// S Tier
					if (chance >= 95 && chance <= 98) {
						let random_power = (getRandomInt(1, 5));
					if (random_power == 1) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Ability_Absorption 1");
					}
					if (random_power == 2) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Rapid_Cellular_Regeneration 1");
					}
					if (random_power == 3) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Kitsune_Mimicry 1");
						}
					if (random_power == 4) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Space_Time_Manipulation 1");
						}
					if (random_power == 5) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Ocular_Psychogenesis_Control 1");
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Ocular_Psychogenesis_Emission 1");
						}
					}
					
					// SS Tier
					if (chance >= 99 && chance <= 100) {
						let random_power = (getRandomInt(1, 3));
					if (random_power == 1) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Ability_Transferal 1");
					}
					if (random_power == 2) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Empathic_Mimicry 1");
					}
					if (random_power == 3) {
					entity.server.runCommandSilent("execute as " + username + " at @s run scoreboard players set @s Powers.Intuitive_Aptitude 1");
						}
					}
					
						entity.server.runCommandSilent("execute as " + username + " at @s run tag @s remove Heroes.Power.Randomize");
					
				}
            });
    });