function init(hero) {
    hero.setName("The Human Torch");
	hero.setVersion ("Movies");
    hero.setTier(6);

    hero.setChestplate("item.superhero_armor.piece.chestpiece");
    hero.setLeggings("item.superhero_armor.piece.pants");
    hero.setBoots("item.superhero_armor.piece.boots");
	
	
    hero.addPowers("soulhp:human_torch");
	
    hero.addKeyBind("AIM", "Flame Blast", 1);
    hero.addKeyBind("FLAME_ON", "Flame On!", 2);

    hero.addAttribute("FALL_RESISTANCE", 8.0, 0);
    hero.addAttribute("JUMP_HEIGHT", 2.0, 0);
    hero.addAttribute("PUNCH_DAMAGE", 3.0, 0);
    hero.addAttribute("SPRINT_SPEED", 0.30, 1);

    hero.addAttributeProfile("INACTIVE", inactiveProfile);
    hero.addAttributeProfile("ACTIVE", activeProfile);
    hero.setAttributeProfile(getAttributeProfile);
    hero.setModifierEnabled(isModifierEnabled);
	hero.setTierOverride(getTierOverride);
    hero.setKeyBindEnabled(isKeyBindEnabled);
	
	hero.supplyFunction("canAim", canAim);

    hero.setTickHandler((entity, manager) => {
        var flying = entity.getData("fiskheroes:flying");
        manager.incrementData(entity, "fiskheroes:dyn/booster_timer", 2, flying);

        var item = entity.getHeldItem();
        flying &= !entity.as("PLAYER").isUsingItem();
        manager.incrementData(entity, "fiskheroes:dyn/booster_r_timer", 2, flying && item.isEmpty() && !entity.isPunching() && entity.getData("fiskheroes:aiming_timer") == 0);
        manager.incrementData(entity, "fiskheroes:dyn/booster_l_timer", 2, flying && !item.doesNeedTwoHands());

        var t = entity.getData("fiskheroes:dyn/superhero_landing_ticks");

        if (t == 0 && !entity.isSprinting() && !entity.isOnGround() && entity.motionY() < -1.25 && entity.getData("fiskheroes:flight_boost_timer") > 0 && entity.world().blockAt(entity.pos().add(0, -2, 0)).isSolid()) {
            manager.setData(entity, "fiskheroes:dyn/superhero_landing_ticks", t = 12);
            entity.playSound("fiskheroes:mob.ironman.hurt", 1, 0.8 + Math.random() * 0.2);
        }
        else if (t > 0) {
            manager.setData(entity, "fiskheroes:dyn/superhero_landing_ticks", --t);
        }

        manager.incrementData(entity, "fiskheroes:dyn/superhero_landing_timer", 2, 8, t > 0);
    });
}



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

function activeProfile(profile) {
    profile.addAttribute("PUNCH_DAMAGE", 7.5, 0);
    profile.addAttribute("SPRINT_SPEED", 0.9, 1);
    profile.inheritDefaults();
}

function getAttributeProfile(entity) {
    if (!entity.getData("soulhp:dyn/torch")) {
        return "INACTIVE";
    }
    else if (entity.getData("soulhp:dyn/torch")) {
        return "ACTIVE";
    }
    return true;
}

function isModifierEnabled(entity, modifier) {
	
	if (modifier.name() == "fiskheroes:regeneration") {
        return (entity.getData("soulhp:dyn/torch"));
    }
	else if (modifier.name() == "fiskheroes:controlled_flight") {
        return (entity.getData("soulhp:dyn/torch"));
    }
	else if (modifier.name() == "fiskheroes:fire_immunity") {
        return (entity.getData("soulhp:dyn/torch"));
    }
    else if (modifier.name() == "fiskheroes:flame_blast") {
        return (entity.getData("soulhp:dyn/torch"));
    }
    else if (modifier.name() == "fiskheroes:damage_weakness") {
        return (entity.getData("soulhp:dyn/torch"));
    }
    else if (modifier.name() == "fiskheroes:fireball") {
        return (entity.getData("soulhp:dyn/torch"));
    }
	return true;
}

function getTierOverride(entity) {
    return entity.getData("soulhp:dyn/torch") ? 6 : 0;
}

function isKeyBindEnabled(entity, keyBind) {

    switch (keyBind) {
    case "AIM":
        return (entity.getData("soulhp:dyn/torch"));
    default:
        return true;
    }
}

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