function init(hero) {
    hero.setName("Sandman/William Baker");
    hero.setTier(4);
    
    hero.setHelmet("Hair");
    hero.setChestplate("Chestpiece");
    hero.setLeggings("Leggings");
    hero.setBoots("Boots");
	
    hero.addPowers("tgheroes:sand_physiology"); 
    hero.addAttribute("PUNCH_DAMAGE", 4.0, 0);
    hero.addAttribute("WEAPON_DAMAGE", 1.5, 0);
    hero.addAttribute("JUMP_HEIGHT", 2.0, 0);
    hero.addAttribute("FALL_RESISTANCE", 1.0, 1);
    hero.addAttribute("SPRINT_SPEED", 0.2, 1);
    
	hero.addKeyBind("BLADE", "Sand Mace", 1);
	hero.addKeyBind("SHADOWFORM", "Sand Cloud Form", 2);
    hero.addKeyBindFunc("func_GIANT_MODE", giantModeKey, "Sand Giant", 3);
	
    hero.addAttributeProfile("BLADE", maceProfile);
    hero.setAttributeProfile(getProfile);
    hero.setDamageProfile(getProfile);
    hero.addDamageProfile("BLADE", {"types": {"BLUNT": 3.0}});	
    hero.addAttributeProfile("GIANT_MODE", giantProfile);
	hero.setTierOverride(getTierOverride);
    hero.setKeyBindEnabled(isKeyBindEnabled);
    hero.setModifierEnabled(isModifierEnabled);
}

function isKeyBindEnabled(entity, keyBind) {
    switch (keyBind) {
    case "func_GIANT_MODE":
        var timer = entity.getData("fiskheroes:dyn/giant_mode_timer");
        return timer == 0 || timer == 1;
	case "BLADE":
		return entity.getData("fiskheroes:scale") <= 1.0;
	case "SHADOWFORM":
		return entity.getData("fiskheroes:scale") <= 1.0;
    default:
        return true;
    }
}

function getTierOverride(entity) {
    return entity.getData("fiskheroes:dyn/giant_mode") ? 6 : 4;
}

function maceProfile(profile) {
    profile.inheritDefaults();
    profile.addAttribute("PUNCH_DAMAGE", 10, 0);
}

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

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 giantProfile(profile) {
    profile.inheritDefaults();
    profile.addAttribute("PUNCH_DAMAGE", 7.0, 0);
    profile.addAttribute("JUMP_HEIGHT", 1.0, 0);
    profile.addAttribute("FALL_RESISTANCE", 1.0, 1);
	profile.addAttribute("WEAPON_DAMAGE", 2.0, 0);
    profile.addAttribute("SPRINT_SPEED", 0.1, 1);
}

function isModifierEnabled(entity, modifier) {
    switch (modifier.name()) {
    case "fiskheroes:flight":
        return entity.getData("fiskheroes:shadowform");
	case "fiskheroes:shadowform":
		return !entity.getData("fiskheroes:dyn/giant_mode");
	case "fiskheroes:blade":
		return !entity.getData("fiskheroes:dyn/giant_mode");
    default:
        return true;
    }
}