function init(hero) {
    hero.setName("Iron-Man/Model 51");
    hero.setVersion("Prime");
    hero.setTier(8);
    
    hero.setChestplate("item.superhero_armor.piece.arc_reactor");
    
    hero.addPowers("jmctheroes:prime_armor");
    hero.addAttribute("PUNCH_DAMAGE", 8.75, 0);
    hero.addAttribute("WEAPON_DAMAGE", -0.5, 1);
    hero.addAttribute("SPRINT_SPEED", 0.25, 1);
    hero.addAttribute("FALL_RESISTANCE", 1.0, 1);
    
    hero.addKeyBind("AIM", "key.aim", 1);
    hero.addKeyBind("CHARGED_BEAM", "Unibeam", 2);
    hero.addKeyBind("BLADE", "key.blade", 3);
    hero.addKeyBind("SHIELD", "key.shield", 3);
    hero.addKeyBind("HOVER", "key.hover", 4);
    hero.addKeyBind("NANITE_TRANSFORM", "Nanite Transformation", 5);
    
    hero.addAttributeProfile("INACTIVE", inactiveProfile);
    hero.addAttributeProfile("BLADE", bladeProfile);
    hero.setAttributeProfile(getAttributeProfile);
    hero.setModifierEnabled(isModifierEnabled);
    hero.setKeyBindEnabled(isKeyBindEnabled);
    hero.setHasProperty(hasProperty);
    hero.setTierOverride(getTierOverride);
    hero.supplyFunction("canAim", canAim);

    hero.addSoundEvent("MASK_OPEN", "fiskheroes:mk50_mask_open");
    hero.addSoundEvent("MASK_CLOSE", "fiskheroes:mk50_mask_close");
    hero.addSoundEvent("AIM_START", "fiskheroes:repulsor_charge");
    hero.addSoundEvent("AIM_STOP", "fiskheroes:repulsor_powerdown");
}

function getTierOverride(entity) {
    return entity.getData("fiskheroes:dyn/nanites") ? 8 : 0;
}

function inactiveProfile(profile) {
    profile.revokeAugments();
}

function bladeProfile(profile) {
    profile.addAttribute("JUMP_HEIGHT", 2.0, 0);
    profile.addAttribute("PUNCH_DAMAGE", 11.0, 0);
    profile.addAttribute("SPRINT_SPEED", 0.45, 1);
    profile.addAttribute("WEAPON_DAMAGE", -0.5, 1);
}

function getAttributeProfile(entity) {
    if (!entity.getData("fiskheroes:dyn/nanites")) {
        return "INACTIVE";
    }
    
    return entity.getData("fiskheroes:blade") ? "BLADE" : null;
}

function isModifierEnabled(entity, modifier) {

    if (modifier.name() == "fiskheroes:repulsor_blast") {
        return (entity.getData("fiskheroes:dyn/nanites"));
    }
    else if (modifier.name() == "fiskheroes:charged_beam") {
        return (entity.getData("fiskheroes:dyn/nanites"));
    }
    else if (modifier.name() == "fiskheroes:shield") {
        return (entity.getData("fiskheroes:dyn/nanites")) && (!entity.getData("fiskheroes:aiming"));
    }
    else if (modifier.name() == "fiskheroes:blade") {
        return (entity.getData("fiskheroes:dyn/nanites")) && (!entity.getData("fiskheroes:aiming"));
    }
    else if (modifier.name() == "fiskheroes:propelled_flight") {
        return (entity.getData("fiskheroes:dyn/nanite_timer") == 1);
    }
    else if (modifier.name() == "fiskheroes:hover") {
        return (entity.getData("fiskheroes:dyn/nanites"));
    }
    else if (modifier.name() == "fiskheroes:fire_immunity") {
        return (entity.getData("fiskheroes:dyn/nanites"));
    }
    else if (modifier.name() == "fiskheroes:metal_skin") {
        return (entity.getData("fiskheroes:dyn/nanites"));
    }
    else if (modifier.name() == "fiskheroes:regeneration") {
        return (entity.getData("fiskheroes:dyn/nanites"));
    }
    else if (modifier.name() == "fiskheroes:water_breathing") {
        return (entity.getData("fiskheroes:dyn/nanites")) && (!entity.getData("fiskheroes:mask_open"));
    }
    return true;
}

function isKeyBindEnabled(entity, keyBind) {
    switch (keyBind) {
    case "NANITE_TRANSFORM":
        return entity.getData("fiskheroes:mask_open_timer") == 0;
    case "SHIELD":
        return entity.getData("fiskheroes:dyn/nanites") && entity.getData("fiskheroes:blade_timer") == 0 || entity.isBookPlayer();
    case "BLADE":
        return entity.getData("fiskheroes:dyn/nanites") && entity.getData("fiskheroes:shield_timer") > 0 || entity.getData("fiskheroes:blade_timer") > 0 || entity.isBookPlayer();
    default:
        return entity.getData("fiskheroes:dyn/nanites");
    }
}

function hasProperty(entity, property) {
    switch (property) {
    case "MASK_TOGGLE":
        return entity.getData("fiskheroes:dyn/nanite_timer") == 1;
    case "BREATHE_SPACE":
        return !entity.getData("fiskheroes:mask_open") && entity.getData("fiskheroes:dyn/nanites");
    default:
        return false;
    }
}

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