function init(hero) {
    hero.setName("Legacy Mysterio");
    hero.setTier(4);
    
    hero.setHelmet("item.superhero_armor.piece.helmet");
    hero.setChestplate("item.superhero_armor.piece.chestplate");
    hero.setLeggings("item.superhero_armor.piece.leggings");
    hero.setBoots("item.superhero_armor.piece.boots");
    
    hero.addPowers("legacyheroes:legacy_mysterio_powers");
    hero.addAttribute("PUNCH_DAMAGE", 4.0, 0);
    
    hero.addKeyBind("CHARGED_BEAM", "key.chargedBeam", 1);
    hero.addKeyBind("AIM", "key.aim", 2);
    hero.addKeyBind("ENERGY_PROJECTION", "key.aim", 2);
    hero.addKeyBind("SPELL_MENU", "key.spellMenu", 3);
    hero.addKeyBind("HOVER", "key.levitate", 4);
    hero.addKeyBind("INTANGIBILITY", "key.intangibility", 5);
    
    hero.setRuleValueModifier(ruleModifier);
    hero.setKeyBindEnabled(isKeyBindEnabled);
    hero.setHasProperty(hasProperty);
    hero.supplyFunction("canAim", canAim);
}

function ruleModifier(entity, rule) {
    switch (rule.name()) {
    case "fiskheroes:range_energyproj":
        return 24.0;
    case "fiskheroes:dmg_energyproj":
        return rule.value() / 1.5;
    default:
        return null;
    }
}

function isKeyBindEnabled(entity, keyBind) {
    return keyBind != "ENERGY_PROJECTION" || entity.getData("fiskheroes:beam_charge") == 0 && entity.getData("fiskheroes:aimed_timer") == 1;
}

function hasProperty(entity, property) {
    return property == "MASK_TOGGLE";
}

function canAim(entity) {
    return entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:beam_charge") == 0 && entity.getData('fiskheroes:time_since_damaged') > 10;
}
