function init(hero) {
    hero.setName("Sandman");
    hero.setTier(4);
    
    hero.setChestplate("item.superhero_armor.piece.chestplate");
    hero.setLeggings("item.superhero_armor.piece.pants");
    hero.setBoots("item.superhero_armor.piece.boots");
    
    hero.addPowers("dlheroes:sand_physiology");
    hero.addAttribute("PUNCH_DAMAGE", 6.5, 0);
    hero.addAttribute("JUMP_HEIGHT", 0.5, 0);
    hero.addAttribute("FALL_RESISTANCE", 3.0, 0);
    hero.addAttribute("SPRINT_SPEED", 0.15, 1);
    
    hero.addKeyBind("SHADOWFORM", "Sand Form", 1);
    hero.addKeyBind("BLADE", "Hammer", 2);
    hero.addKeyBind("EARTHQUAKE", "Sand Storm", 3);
    hero.addKeyBindFunc("func_GIANT_MODE", giantModeKey, "key.giantMode", 4);
    hero.addKeyBind("GROUND_SMASH", "Ground Smash", 5);

    hero.setDefaultScale(1);
    hero.setModifierEnabled(isModifierEnabled);
    hero.setKeyBindEnabled(isKeyBindEnabled);
    hero.addAttributeProfile("HAMMER", weaponProfile);
    hero.setAttributeProfile(getAttributeProfile);
}

function weaponProfile(profile) {
    profile.inheritDefaults();
    profile.addAttribute("PUNCH_DAMAGE", 8.5, 0);
}

function giantModeKey(player, manager) {
    var flag = player.getData("fiskheroes:dyn/giant_mode");
    manager.setData(player, "fiskheroes:dyn/giant_mode", !flag);
    manager.setData(player, "fiskheroes:size_state", flag ? -1 : 1);
    return true;
}

function isModifierEnabled(entity, modifier) {
    switch (modifier.name()) {
    case "fiskheroes:ground_smash":
        return entity.getData("fiskheroes:scale") > 1.11;
    case "fiskheroes:flight":
        return entity.getData("fiskheroes:shadowform");
    default:
        return true;
    }
}

function getAttributeProfile(entity) {
    return entity.getData("fiskheroes:blade") ? "HAMMER" : null;
}

function isKeyBindEnabled(entity, keyBind) {
    if (keyBind != "SHADOWFORM" && entity.getData("fiskheroes:shadowform")) {
        return false;
    }
    
    switch (keyBind) {
    case "func_GIANT_MODE":
        var timer = entity.getData("fiskheroes:dyn/giant_mode_timer");
        return timer == 0 || timer == 1;
    case "GROUND_SMASH":
        return entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:scale") > 1.11 && entity.getData("fiskheroes:size_state") == 0;
    case "EARTHQUAKE":
        return entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:size_state") == 0;
    case "BLADE":
        return entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:size_state") == 0;
    default:
        return entity.getData("fiskheroes:scale") <= 1.11;
    }
}
