function init(hero) {
    hero.setName("Iron Spider");
    hero.setTier(8);

    hero.setChestplate("Backpack");

    hero.addPowers("nh:iron_spider_backpack");
    hero.addAttribute("FALL_RESISTANCE", 10.0, 0);
    hero.addAttribute("JUMP_HEIGHT", 2.5, 0);
    hero.addAttribute("PUNCH_DAMAGE", 5.5, 0);
    hero.addAttribute("SPRINT_SPEED", 0.45, 1);
    hero.addAttribute("STEP_HEIGHT", 0.5, 0);
    hero.addAttribute("IMPACT_DAMAGE", 0.45, 1);
    hero.addAttributeProfile("INACTIVE", inactiveProfile);

    hero.addKeyBind("AIM", "key.aim", 1);
    hero.addKeyBind("HOVER", "key.hover", 2);
    hero.addKeyBind("FLIGHT_ACTIVATE", "Activate Boosters", 3);

    hero.addKeyBind("UTILITY_BELT", "key.webShooters", 1);
    hero.addKeyBind("WEB_ZIP", "key.webZip", 2);
    hero.addKeyBindFunc("func_WEB_SWINGING", webSwingingKey, "key.webSwinging", 3);
    hero.addKeyBind("WEB_ACTIVATE", "Activate Webshooters", 4);

    hero.addKeyBind("TENTACLE_JAB", "Waldo Jab", 1);
    hero.addKeyBind("TENTACLES", "Toggle Waldos", 2);

    hero.addKeyBind("BACKPACK_TRANSFORM", "Backpack Transform", 5);

    hero.setModifierEnabled(isModifierEnabled);
    hero.setKeyBindEnabled(isKeyBindEnabled);
    hero.setHasProperty(hasProperty);
    hero.setAttributeProfile(getProfile);
    hero.setDamageProfile(getProfile);
    hero.setTierOverride(getTierOverride);
    hero.supplyFunction("canAim", canAim);

    hero.addSoundEvent("MASK_OPEN", "fiskheroes:iron_man_mask_open");
    hero.addSoundEvent("MASK_CLOSE", "fiskheroes:iron_man_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 getProfile(entity) {
    if (!entity.getData("fiskheroes:dyn/nanites")) {
        return "INACTIVE";
    }
}

function isModifierEnabled(entity, modifier) {
    if (modifier.name() != "fiskheroes:transformation" && modifier.name() != "fiskheroes:cooldown" && (!entity.getData("fiskheroes:dyn/nanites") || modifier.name() == "fiskheroes:propelled_flight" && entity.getData("fiskheroes:dyn/nanite_timer") < 1)) {
        return false;
    }

    switch (modifier.name()) {
        case "fiskheroes:repulsor_blast":
            return entity.getData("fiskheroes:aimed_timer") >= 1 && entity.getData("nh:dyn/flight") && !entity.getData("nh:dyn/web");
        case "fiskheroes:propelled_flight":
            return entity.getData("nh:dyn/flight") && !entity.getData("nh:dyn/web");
        case "fiskheroes:water_breathing":
            return !entity.getData("fiskheroes:mask_open") && entity.getData("fiskheroes:dyn/nanites");
        case "fiskheroes:web_swinging":
            return entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:utility_belt_type") == -1 && entity.getData("nh:dyn/web");
        case "fiskheroes:leaping":
            return modifier.id() == "springboard" == (entity.getData("fiskheroes:ticks_since_swinging") < 5) && entity.getData("nh:dyn/web");
        case "fiskheroes:hover":
            return entity.getData("nh:dyn/flight");
        case "fiskheroes:equipment":
            return entity.getData("nh:dyn/web");
        case "fiskheroes:tentacles":
            return !entity.getData("nh:dyn/web") && !entity.getData("nh:dyn/flight");
        default:
            return true;
    }
}

function isKeyBindEnabled(entity, keyBind) {
    if (keyBind == "BACKPACK_TRANSFORM") {
        return entity.getData("fiskheroes:mask_open_timer") == 0;
    } else if (!entity.getData("fiskheroes:dyn/nanites")) {
        return false;
    }

    switch (keyBind) {
        case "func_WEB_SWINGING":
            return entity.getHeldItem().isEmpty() && entity.getData('nh:dyn/web') && !entity.getData('nh:dyn/flight');
        case "UTILITY_BELT":
            return entity.getData('nh:dyn/web') && !entity.getData('nh:dyn/flight');
        case "WEB_ZIP":
            return entity.getData('fiskheroes:tentacles') == null && entity.getData('nh:dyn/web');
        case "TENTACLE_JAB":
            return entity.getData('fiskheroes:tentacles') != null;
        case "AIM":
            return entity.getHeldItem().isEmpty() && entity.getData('nh:dyn/flight');
        case "HOVER":
            return entity.getData('fiskheroes:jetpacking') && entity.getData('nh:dyn/flight') || !entity.isOnGround();
        case "TENTACLES":
            return !entity.getData('nh:dyn/flight') && !entity.getData('nh:dyn/web');
        case "FLIGHT_ACTIVATE":
            return entity.getData('fiskheroes:tentacles') == null && !entity.getData('nh:dyn/web');
        case "WEB_ACTIVATE":
            return entity.getData('fiskheroes:tentacles') == null && !entity.getData('nh:dyn/flight');
        case "PROPELLED_FLIGHT": 
            return entity.getData('fiskheroes:tentacles') == null && !entity.getData('nh:dyn/web') && entity.getData('nh:dyn/flight');
        case "REPULSOR_BLAST": 
            return entity.getData('fiskheroes:tentacles') == null && !entity.getData('nh:dyn/web'); 
        default:
            return true;
    }
}

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:jetpacking');
}

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;
}