function init(hero) {
    hero.setName("Advanced Flight");

    hero.setTier(10);
    
	
    hero.setChestplate("item.superhero_armor.piece.chestpiece");
    hero.setLeggings("item.superhero_armor.piece.pants");
    hero.setBoots("item.superhero_armor.piece.boots");
    
    hero.addPowers("pack:advanced_flight");
	
	hero.addAttribute("BASE_SPEED_LEVELS", 1.0, 0);
	hero.addAttribute("KNOCKBACK", 2.0, 0);
    hero.addAttribute("PUNCH_DAMAGE", 9.5, 0);
	hero.addAttribute("JUMP_HEIGHT", 2.5, 0);
	hero.addAttribute("FALL_RESISTANCE", 10, 1);
	hero.addAttribute("SPRINT_SPEED", 0.75, 1);
	hero.addAttribute("STEP_HEIGHT", 0.5, 0);
	hero.addAttribute("IMPACT_DAMAGE", 0.7, 1);
    
    
    
	hero.addKeyBind("GROUND_SMASH", "Power punch", 2);
	hero.addKeyBindFunc("BOOST", boost, "Super-Sonic Speed Boost", 3);
	hero.addKeyBind("JUMP", "Launch", 3);
	hero.addKeyBind("SLOW_MOTION", "Slow Motion", 4);
	hero.addKeyBind("SUPER_SPEED", "Super-Speed", 5);


	hero.setHasProperty(hasProperty);
	hero.setModifierEnabled(isModifierEnabled);
	hero.setKeyBindEnabled(isKeyBindEnabled);
	hero.setAttributeProfile(getProfile);
	hero.addAttributeProfile("JUMP", jumpProfile);
	hero.addAttributeProfile("JUMP_PREP", jumpprepProfile);


}

function hasProperty(entity, property) {
    return property == "BREATHE_SPACE";
}

function boost(player, manager) {

    manager.setData(player, "fiskheroes:jetpacking", true);
	
    return true;
}

function getProfile(entity) {
	if (entity.getData("pack:dyn/jump_cooldown") > 0.0 && entity.getData("pack:dyn/jump_cooldown") < 0.9 && entity.isOnGround() ) {
        return "JUMP_PREP";
    }
	
	else if (entity.getData("pack:dyn/jump_cooldown") >= 0.9 && entity.isOnGround()) {
        return "JUMP";
    }

    return null;
}

function jumpprepProfile(profile) {
	profile.inheritDefaults()
	profile.addAttribute("JUMP_HEIGHT", -5.0, 1);
	profile.addAttribute("BASE_SPEED", -25.0, 1);
	

}

function jumpProfile(profile) {
	profile.inheritDefaults()
	profile.addAttribute("BASE_SPEED", -25.0, 1);
	profile.addAttribute("JUMP_HEIGHT", 20.0, 1);


}


function isKeyBindEnabled(entity, keyBind) {
	var glide = (entity.getData("fiskheroes:glide_flying") || entity.getData("fiskheroes:jetpacking"));
    switch (keyBind) {
		
    case "BOOST":
        return glide && !entity.isOnGround();
	case "JUMP":
        return !glide && entity.isOnGround() && (!entity.getData("pack:dyn/jump") && entity.getData("pack:dyn/jump_cooldown") < 0.8 || (entity.getData("pack:dyn/jump") && entity.getData("pack:dyn/jump_cooldown") < 1)) ;

    default:
        return true;
    }
}



function isModifierEnabled(entity, modifier) {
	switch (modifier.name()) {
		case "fiskheroes:leaping":
			return modifier.id() == "springboard" == (entity.getData("fiskheroes:ticks_since_gliding") < 7);
		case "fiskheroes:flight":
			return entity.getData("fiskheroes:glide_flying") && (entity.motionY() > -0.05 && entity.motion().length() < 1);
		case "fiskheroes:gliding":
			return modifier.id() == 'super_sonic_boost' == (entity.getData('pack:dyn/ability_timer') > 0) ;

	
		default:
			return true;
    }
}

