function init(hero) {
    hero.setName("symbiote");
    hero.setTier(7);

    hero.setChestplate("jar");

    hero.addPowers("symbiotes:symbiote");
    hero.addAttribute("FALL_RESISTANCE", 13.0, 0);
    hero.addAttribute("JUMP_HEIGHT", 2.5, 0);
    hero.addAttribute("PUNCH_DAMAGE", 7.5, 0);
    hero.addAttribute("SPRINT_SPEED", 0.5, 1);
    hero.addAttribute("STEP_HEIGHT", 0.5, 0);
    hero.addAttribute("IMPACT_DAMAGE", 0.5, 1);

    hero.addKeyBind("UTILITY_BELT", "Symbiote Menu", 1);
    hero.addKeyBind("TENTACLE_JAB", "Tentacle Jab", 1);
    hero.addKeyBind("WEB_ZIP", "Tentacle Zip", 2);
    hero.addKeyBind("TENTACLE_GRAB", "Tentacle Grab", 2);
    hero.addKeyBindFunc("func_SWINGING", FuncSwingingKey, "Tentacle Swing", 3);
    hero.addKeyBind("SHIELD", "Tentacle Shield", 3);
    hero.addKeyBind("SHADOWDOME", "Tentacle Shield", 3);
    hero.addKeyBind("SLOW_MOTION", "Slow Motion", 4);
    hero.addKeyBind("BLADE", "Blades Toggle", 4);
    hero.addKeyBind("TENTACLES", "Back Tentacles", 5);
    hero.addKeyBind("SUIT", "Suit", 5);

    hero.setModifierEnabled(isModifierEnabled);
    hero.setKeyBindEnabled(isKeyBindEnabled);
    hero.setHasProperty(hasProperty);
    hero.setTierOverride(tierOverride);
    hero.addAttributeProfile("SHIELD", shieldProfile);
    hero.addAttributeProfile("BLADE", bladeProfile);
    hero.setAttributeProfile(getAttributeProfile);
    hero.setDamageProfile(getDamageProfile);
    hero.addDamageProfile("BLADE", {
        "types": {
            "SHARP": 1.0
        }
    });

}

function bladeProfile(profile) {
    profile.inheritDefaults();
    profile.addAttribute("PUNCH_DAMAGE", 16, 0);
}

function shieldProfile(profile) {
    profile.inheritDefaults();
    profile.addAttribute("BASE_SPEED", -100, 1);
    profile.addAttribute("JUMP_HEIGHT", -100.0, 1);
}

function getAttributeProfile(entity) {
    if (entity.getData("fiskheroes:shield_blocking")) {
        return "SHIELD";
    } else if (entity.getData("fiskheroes:blade")) {
        return "BLADE";
    }
    return null;
}

function tierOverride(entity) {
    return entity.getData("symbiotes:dyn/symbiote") ? 1 : 7;
}

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

function FuncSwingingKey(player, manager) {
    var flag = player.getData("fiskheroes:web_swinging");

    if (!flag) {
        manager.setDataWithNotify(player, "fiskheroes:prev_utility_belt_type", player.getData("fiskheroes:utility_belt_type"));
        manager.setDataWithNotify(player, "fiskheroes:utility_belt_type", -1);
    }

    manager.setDataWithNotify(player, "fiskheroes:web_swinging", !flag);
    return true;
}
function isModifierEnabled(entity, modifier) {
    switch (modifier.name()) {
    case "fiskheroes:web_swinging":
        return entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:utility_belt_type") == -1 && entity.getData("fiskheroes:tentacles") == null && !entity.getData("fiskheroes:shield_blocking");
    case "fiskheroes:arrow_catching":
        return entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:utility_belt_type") == -1 && entity.getData("fiskheroes:tentacles") == null && !entity.getData("fiskheroes:shield_blocking");
    case "fiskheroes:leaping":
        return modifier.id() == "springboard" == (entity.getData("fiskheroes:ticks_since_swinging") < 5) && !entity.getData("fiskheroes:shield_blocking");
    case "fiskheroes:equipment":
        return entity.getData("fiskheroes:tentacles") == null;
    case "fiskheroes:tentacles":
        if (entity.getData("fiskheroes:shield_blocking")) {
            return (modifier.id() == "notclimbing") == entity.getData("fiskheroes:shield_blocking");
        } else {
            return (modifier.id() == "notclimbing") == false;
        }
    case "fiskheroes:teleknesis":
        return !entity.getData("fiskheroes:shield_blocking") && !entity.getData("fiskheroes:blade");
    case "fiskheroes:blade":
        return !entity.getData("fiskheroes:shield_blocking") && entity.getData("fiskheroes:tentacles") != null && entity.getData("fiskheroes:grab_id") == -1;
    case "fiskheroes:shield":
        return !entity.getData("fiskheroes:blade") && entity.getData("fiskheroes:tentacles") != null && entity.getData("fiskheroes:grab_id") == -1;
    case "fiskheroes:shadowdome":
        return entity.getData("fiskheroes:shield");
    default:
        return true;
    }
}

function isKeyBindEnabled(entity, keyBind) {
    switch (keyBind) {
    case "func_SWINGING":
        return entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:tentacles") == null && !entity.getData("fiskheroes:shield");
    case "UTILITY_BELT":
        return entity.getData("fiskheroes:tentacles") == null;
    case "WEB_ZIP":
        return entity.getData("fiskheroes:tentacles") == null;
    case "SHIELD":
        return entity.getData("fiskheroes:tentacles") != null && !entity.getData("fiskheroes:blade") && entity.getData("fiskheroes:grab_id") == -1 && entity.isOnGround() && entity.isSneaking();
    case "BLADE":
        return entity.getData("fiskheroes:tentacles") != null && !entity.getData("fiskheroes:shield_blocking") && entity.getData("fiskheroes:grab_id") == -1;
    case "SLOW_MOTION":
        return entity.getData("fiskheroes:tentacles") == null;
    case "TENTACLE_JAB":
        return entity.getData("fiskheroes:tentacles") != null && !entity.getData("fiskheroes:shield_blocking") && !entity.getData("fiskheroes:blade");
    case "TENTACLE_GRAB":
        return entity.getData("fiskheroes:tentacles") != null && !entity.getData("fiskheroes:shield_blocking") && !entity.getData("fiskheroes:blade");
    case "TENTACLES":
        return !entity.getData("fiskheroes:shield_blocking") && !entity.getData("fiskheroes:blade") && !entity.isSneaking();
    case "SUIT":
        return entity.isSneaking() && !entity.getData("fiskheroes:shield_blocking") && !entity.getData("fiskheroes:mask_open");
    case "SHADOWDOME":
        return entity.getData("fiskheroes:shield");
    default:
        return true;
    }
}

function hasProperty(entity, property) {
    return property == "MASK_TOGGLE" && !entity.getData("symbiotes:dyn/symbiote") || property == "BREATHE_SPACE" && !entity.getData("symbiotes:dyn/symbiote") && !entity.getData("fiskheroes:mask_open");
}
