function getRandomInt(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.floor(Math.random() * (max - min) + min); // The maximum is exclusive and the minimum is inclusive
}

	EntityEvents.death("minecraft:player",event =>{
		
	
	if (event.entity.isPlayer() && abilityUtil.isEnabled(event.player, 'heroes:space_time_manipulation', 'Low_Hp_Teleport')) {
		let damage = event.damage
		let entity = event.entity;
		let entry = event.entity.entry
		let server = event.server;
		let health = entity.health;
		let username = entity.getGameProfile().getName();
		entity.health = 1
		server.runCommandSilent(`execute as ${username} at @s run playsound heroes:heroes.space_time_sfx player @a[distance=..10]`);
		server.runCommandSilent(`execute as ${username} at @s run tag @s add Heroes.Space_Time_Manipulation.Random.CD`);
		server.runCommandSilent(`execute as ${username} at @s run spreadplayers ~ ~ 100 50 false @s`);
		server.runCommandSilent(`scoreboard players add ${username} Heroes.Stamina.Remove 33`);
		event.cancel()
	}	
	
	
	 if (event.entity.isPlayer() && abilityUtil.isUnlocked(event.player, 'heroes:rapid_cellular_regeneration', 'genetic_marker')) {
		let entity = event.entity;
		let entry = event.entity.entry
		let server = event.server;
		let username = entity.getGameProfile().getName();
		
		let scoreboard = Utils.server.scoreboard;
        let scoreboard_obj = scoreboard.getObjective("Heroes.Regen.Death.Amount");
        let score = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj);
        let value = score.getScore();
		
		let scoreboard_2 = Utils.server.scoreboard;
        let scoreboard_obj_2 = scoreboard_2.getObjective("Heroes.Regen.Death.Amount.Max");
        let score_2 = scoreboard.getOrCreatePlayerScore(username, scoreboard_obj_2);
        let value_2 = score_2.getScore();
		if (value < value_2) {
		entity.health = 1
		server.runCommandSilent(`scoreboard players add ${username} Heroes.Regen.Death.Amount 1`);
		server.runCommandSilent(`tag ${username} add Heroes.Regen.Death.State`);
		server.runCommandSilent(`tag ${username} add Heroes.Regen.Death.Brain`);
		event.cancel()

		}
    }
})



