function init(hero) {
    hero.setName("Blue Beetle");
    hero.setVersion("\u00A7l\u00A7o\u00A74Skarred \u00A7r\u00A7l\u00A76Heroes\u00A7r");
    hero.setTier(5);
    
    hero.setChestplate("Scarab");
    
    hero.addPowers("sfiskpack:scarab");
    hero.addAttribute("PUNCH_DAMAGE", 9.5, 0);
    hero.addAttribute("WEAPON_DAMAGE", 1.5, 0);
    hero.addAttribute("FALL_RESISTANCE", 8.0, 0);
    hero.addAttribute("SPRINT_SPEED", 0.2, 1);
    
    hero.addKeyBind("AIM", "key.aim", 1);
    hero.addKeyBind("BLADE", "key.blade", 2);
    hero.addKeyBind("SHIELD", "key.shield", 2);
    hero.addKeyBind("TRANSFORM", "Scarab Transformation", 5);
    
    hero.addAttributeProfile("INACTIVE", inactiveProfile);
    hero.addAttributeProfile("BLADE", bladeProfile);
    hero.setAttributeProfile(getAttributeProfile);
    hero.setModifierEnabled(isModifierEnabled);
    hero.setKeyBindEnabled(isKeyBindEnabled);
    hero.setHasProperty(hasProperty);
    hero.setTierOverride(getTierOverride);
    hero.supplyFunction("canAim", canAim);
}

function getTierOverride(entity) {
    return entity.getData("sfiskpack:dyn/scarab") ? 5 : 0;
}

function inactiveProfile(profile) {
    profile.revokeAugments();
}

function bladeProfile(profile) {
    profile.inheritDefaults();
    profile.addAttribute("PUNCH_DAMAGE", 10.5, 0);
    profile.addAttribute("JUMP_HEIGHT", 1.5, 0);
    profile.addAttribute("FALL_RESISTANCE", 9.5, 0);
}

function getAttributeProfile(entity) {
    if (!entity.getData("sfiskpack:dyn/scarab")) {
        return "INACTIVE";
    }
    
    return entity.getData("fiskheroes:blade") ? "BLADE" : null;
}

function isModifierEnabled(entity, modifier) {
    if (modifier.name() != "fiskheroes:transformation" && modifier.name() != "fiskheroes:cooldown" && (!entity.getData("sfiskpack:dyn/scarab") || modifier.name() == "fiskheroes:gliding" && entity.getData("sfiskpack:dyn/scarab_timer") < 1)) {
        return false;
    }
  
    switch (modifier.name()) {
    case "fiskheroes:energy_blast":
        return entity.getData("fiskheroes:aimed_timer") >= 1;
    case "fiskheroes:blade":
        return !entity.getData("fiskheroes:aiming") && !entity.getData("fiskheroes:shield");
    case "fiskheroes:regeneration":
        return !entity.getData("fiskheroes:blade");
    case "fiskheroes:gliding_flight":
        return !entity.getData("shield_blocking");
    case "fiskheroes:water_breathing":
        return !entity.getData("fiskheroes:mask_open") && entity.getData("sfiskpack:dyn/scarab");
    default:
        return true;
    }
}

function isKeyBindEnabled(entity, keyBind) {
    if (keyBind == "TRANSFORM") {
        return entity.getData("fiskheroes:mask_open_timer") == 0;
    }
    else if (!entity.getData("sfiskpack:dyn/scarab")) {
        return false;
    }
    
    switch (keyBind) {
    case "SHIELD":
        return entity.isSneaking() || entity.isBookPlayer();
    case "BLADE":
        return !entity.isSneaking() && !entity.getData("fiskheroes:shield");
    default:
        return true;
    }
}

function hasProperty(entity, property) {
    switch (property) {
    case "MASK_TOGGLE":
        return entity.getData("sfiskpack:dyn/scarab_timer") == 1;
    case "BREATHE_SPACE":
        return !entity.getData("fiskheroes:mask_open") && entity.getData("sfiskpack:dyn/scarab");
    default:
        return false;
    }
}

function canAim(entity) {
    return entity.getHeldItem().isEmpty() && entity.getData("sfiskpack:dyn/scarab");
}
