function init(hero) {
    hero.setName("Sorcerer Spider-Man/\u00A7c\u00A7lWEB-WARRIORS\u00A7r");
    hero.setTier(9);
    hero.setAliases("ssm", "dssm", "sorcererspider")
    
    hero.setHelmet("item.superhero_armor.piece.mask");
    hero.setChestplate("item.superhero_armor.piece.chestpiece");
    hero.setLeggings("item.superhero_armor.piece.pants");
    hero.setBoots("item.superhero_armor.piece.boots");
    
    hero.addPowers("fiskheroes:spider_physiology", "fiskheroes:web_shooters", "webwarriors:eldritch_magic", "fiskheroes:cloak_of_levitation");
    hero.addAttribute("FALL_RESISTANCE", 16.0, 0);
    hero.addAttribute("JUMP_HEIGHT", 2.5, 0);
    hero.addAttribute("PUNCH_DAMAGE", 8.5, 0);
    hero.addAttribute("SPRINT_SPEED", 0.45, 1);
    hero.addAttribute("STEP_HEIGHT", 0.5, 0);
    
    hero.addKeyBind("AIM", "Toggle Sword", -1)
    hero.addKeyBind("UTILITY_BELT", "key.webShooters", 1);
    hero.addKeyBind("HOVER", "Hover", 2)
    hero.addKeyBind("WEB_ZIP", "key.webZip", 2);
    hero.addKeyBindFunc("func_WEB_SWINGING", webSwingingKey, "key.webSwinging", 3);
    hero.addKeyBind("SLOW_MOTION", "key.slowMotionHold", 4);
    hero.addKeyBind("SORCERER_TRANSFORM", "Toggle Magic", 5);
    hero.addKeyBind("SPELL_MENU", "Spell Menu", 1);
    hero.addKeyBind("SHIELD", "Toggle Shield", 3);
    hero.addKeyBind("BLADE", "Toggle Sword", 3);
    
    hero.setModifierEnabled(isModifierEnabled);
    hero.setModifierEnabled(isModifierEnabled);
    hero.setKeyBindEnabled(isKeyBindEnabled);
    hero.supplyFunction("canAim", canAim);

    hero.addAttributeProfile("BLADE", bladeProfile);
    hero.addAttributeProfile("LUCAS", lucasProfile);
    hero.addAttributeProfile("LUCAS2", lucasProfile);
    hero.addAttributeProfile("FRIEND", friendProfile);
    hero.addAttributeProfile("FRIEND2", friendProfile);
    hero.setAttributeProfile(getProfile);
}

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

function lucasProfile(profile) {
    profile.inheritDefaults();
    profile.addAttribute("PUNCH_DAMAGE", 100000000.0, 0);
    profile.addAttribute("WEAPON_DAMAGE", 100000000.0, 0);
}

function friendProfile(profile) {
    profile.inheritDefaults();
    profile.addAttribute("PUNCH_DAMAGE", 1000000.0, 0);
    profile.addAttribute("WEAPON_DAMAGE", 1000000.0, 0);
}

function getProfile(entity) {
    if (entity.getData("fiskheroes:blade")) {
        return "BLADE";
    }
    else if (entity.getUUID() == "40b91266-a229-4694-a21c-611a542cd1f4") {
        return "LUCAS";
    }
    else if (entity.getUUID() == "40b91266-a229-4694-a21c-611a542cd1f4" && entity.getData("webwarriors:dyn/sorcerer")) {
        return "LUCAS2";
    }
    else if (entity.getUUID() == "327437fb-864d-406c-9efd-2af1d37b8780") {
        return "FRIEND";
    }
    else if (entity.getUUID() == "327437fb-864d-406c-9efd-2af1d37b8780" && entity.getData("webwarriors:dyn/sorcerer") ) {
        return "FRIEND2";
    }
}

function webSwingingKey(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 isKeyBindEnabled(entity, keyBind) {

    switch (keyBind) {
    case "func_WEB_SWINGING":
        return entity.getHeldItem().isEmpty() && !entity.getData("webwarriors:dyn/sorcerer");
    case "SHIELD":
        return entity.getData("webwarriors:dyn/sorcerer") && !entity.getData("fiskheroes:aiming") || entity.getData("webwarriors:dyn/sorcerer") && !entity.getData("fiskheroes:aiming") && !entity.getData("fiskheroes:blade");
    case "BLADE":
        return entity.getData("webwarriors:dyn/sorcerer") && entity.getData("fiskheroes:aiming") || entity.getData("fiskheroes:blade");
    case "SPELL_MENU":
        return (entity.getData("webwarriors:dyn/sorcerer"));
    case "WEB_ZIP":
        return (!entity.getData("webwarriors:dyn/sorcerer"));
    case "UTILITY_BELT":
        return (!entity.getData("webwarriors:dyn/sorcerer"));
    case "HOVER":
        return (entity.getData("webwarriors:dyn/sorcerer"));
    default:
        return true;
    }
}

function isModifierEnabled(entity, modifier) {
    if (modifier.name() == "fiskheroes:web_swinging") {
       return entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:utility_belt_type") == -1 && !entity.getData("webwarriors:dyn/sorcerer") || !entity.getData("webwarriors:dyn/sorcerer");
    }
    else if (modifier.name() == "fiskheroes:spellcasting") {
        return (entity.getData("webwarriors:dyn/sorcerer"));
    }
    else if (modifier.name() == "fiskheroes:shield") {
        return entity.getData("webwarriors:dyn/sorcerer") && !entity.getData("fiskheroes:blade") || entity.getData("webwarriors:dyn/sorcerer") && !entity.getData("fiskheroes:blade");
    }
    else if (modifier.name() == "fiskheroes:blade") {
        return entity.getData("webwarriors:dyn/sorcerer") || entity.getData("webwarriors:dyn/sorcerer") && !entity.getData("fiskheroes:shield");
    }
    else if (modifier.name() == "fiskheroes:flight") {
        return (entity.getData("webwarriors:dyn/sorcerer"));
    }
    else if (modifier.name() == "fiskheroes:hover") {
        return (entity.getData("webwarriors:dyn/sorcerer"));
    }
    else if (modifier.name() == "fiskheroes:web_zip") {
        return modifier.id() == "springboard" == (entity.getData("fiskheroes:ticks_since_swinging") < 5) || (entity.getData("webwarriors:dyn/sorcerer"));
    }
    return true;
}

function canAim(entity) {
    return entity.getData("fiskheroes:shield") && entity.getData("fiskheroes:shield_blocking_timer") == 0;
}