function init(hero) {
    hero.setName("Ghost Rider");
    hero.setTier(9);
    
    hero.setChestplate("item.superhero_armor.piece.jacket");
    hero.setLeggings("item.superhero_armor.piece.leggings");
    hero.setBoots("item.superhero_armor.piece.boots");

    hero.addPowers("jmctheroes:spirit_of_vengeance", "jmctheroes:hell_king");
    
    hero.addKeyBind("BLADE", "Toggle Chains", 1);
    hero.addKeyBind("AIM", "Hell Fire Beam", 2);
    hero.addKeyBind("CHARGED_BEAM", "Penance Stare", 3);
    hero.addKeyBind("HELL_KING", "King of Hell", 4);
    hero.addKeyBind("GHOST_RIDER", "Spirit Of Vengeance", 5);

    hero.addAttributeProfile("GHOST", ghostProfile);
    hero.addAttributeProfile("KING", kingProfile);
    hero.setModifierEnabled(isModifierEnabled);
    hero.setKeyBindEnabled(isKeyBindEnabled);
    hero.supplyFunction("canAim", canAim);
    hero.setAttributeProfile(getProfile);

}
function getProfile(entity) {
    if (entity.getData("jmctheroes:dyn/rider")) {
        return "GHOST";
    }
    else if (entity.getData("jmctheroes:dyn/king")) {
        return "KING";
    }
}

function ghostProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", 7.5, 0);
    profile.addAttribute("WEAPON_DAMAGE", -2.5, 0);
    profile.addAttribute("JUMP_HEIGHT", 1.0, 0);
    profile.addAttribute("FALL_RESISTANCE", 12.0, 0);
    profile.addAttribute("SPRINT_SPEED", 0.75, 1);
}

function kingProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", 7.5, 0);
    profile.addAttribute("WEAPON_DAMAGE", -2.5, 0);
    profile.addAttribute("JUMP_HEIGHT", 1.0, 0);
    profile.addAttribute("FALL_RESISTANCE", 12.0, 0);
    profile.addAttribute("SPRINT_SPEED", 0.75, 1);
} 
function isKeyBindEnabled(entity, keyBind) {
    
    switch (keyBind) {
    case "BLADE":
        return (entity.getData("jmctheroes:dyn/rider"));
    case "AIM":
        return (entity.getData("jmctheroes:dyn/rider"));
    case "CHARGED_BEAM":
        return (entity.getData("jmctheroes:dyn/rider"));
    case "HELL_KING":
        return (entity.getData("jmctheroes:dyn/rider"));
    case "GHOST_RIDER":
        return (!entity.getData("jmctheroes:dyn/king"));
    case "AIM":
        return entity.getData("jmctheroes:dyn/rider") && !entity.getData("fiskheroes:blade");
    default:
        return true;
    }    
}

function isModifierEnabled(entity, modifier) {
    if (modifier.name() == "fiskheroes:flame_blast") {
        return (entity.getData("jmctheroes:dyn/rider"));
    }
    else if (modifier.name() == "fiskheroes:leaping") {
        return (entity.getData("jmctheroes:dyn/rider"));
    }
    else if (modifier.name() == "fiskheroes:fire_immunity") {
        return (entity.getData("jmctheroes:dyn/rider"));
    }
    else if (modifier.name() == "fiskheroes:damage_weakness") {
        return (entity.getData("jmctheroes:dyn/rider"));
    }
    else if (modifier.name() == "fiskheroes:charged_beam") {
        return (entity.getData("jmctheroes:dyn/rider"));
    }
    else if (modifier.name() == "fiskheroes:blade") {
        return (entity.getData("jmctheroes:dyn/rider"));
    }
    else if (modifier.name() == "jmctheroes:dyn/king") {
        return (entity.getData("jmctheroes:dyn/rider"));
    }
    else if (modifier.name() == "fiskheroes:propelled_flight") {
        return (entity.getData("jmctheroes:dyn/king"));
    }
    return true;
}

function canAim(entity) {
    return entity.getHeldItem().isEmpty() && entity.getData("jmctheroes:dyn/rider") && !entity.getData("fiskheroes:jetpacking") && !entity.getData("fiskheroes:blade");
}
