function init(hero) {
    hero.addKeyBind("CHARGED_BEAM3", "Thunder-Clap", 1);
    hero.addKeyBind("HEAT_VISION_FOURARMS_1", "Spinjitzu", 1); 
    
    hero.addKeyBind("CHARGED_BEAM", "key.mantaRays", 1);
    hero.addKeyBind("HEAT_VISION", "Aim", 1); 
    hero.addKeyBind("GROUND_SMASH", "key.groundSmash", 2);

    hero.addAttributeProfile("FOUR_ARMS", profile => {
        profile.addAttribute("PUNCH_DAMAGE", 10.0, 0);
        profile.addAttribute("WEAPON_DAMAGE", -1.5, 0);
        profile.addAttribute("JUMP_HEIGHT", 2.5, 0);
        profile.addAttribute("FALL_RESISTANCE", 1.0, 1);
        profile.addAttribute("SPRINT_SPEED", 0.55, 1);
        profile.addAttribute("KNOCKBACK", 1, 0);
        profile.addAttribute("STEP_HEIGHT", 0.5, 0);
        profile.addAttribute("MAX_HEALTH", -2, 0);
    });
    hero.addAttributeProfile("FOUR_ARMS_SHOOTING", profile => {
        profile.addAttribute("PUNCH_DAMAGE", -10.0, 0);
        profile.addAttribute("WEAPON_DAMAGE", -10.5, 0);
        profile.addAttribute("JUMP_HEIGHT", 1.5, 0);
        profile.addAttribute("FALL_RESISTANCE", 1.0, 1);
        profile.addAttribute("SPRINT_SPEED", 0.55, 1);
        profile.addAttribute("STEP_HEIGHT", 0.5, 0);
        profile.addAttribute("MAX_HEALTH", -2, 0);
    });
    hero.addAttributeProfile("FOUR_ARMS_SHOOTING_SPIN", profile => {
        profile.addAttribute("PUNCH_DAMAGE", -10.0, 0);
        profile.addAttribute("WEAPON_DAMAGE", -10.5, 0);
        profile.addAttribute("JUMP_HEIGHT", 2.0, 0);
        profile.addAttribute("FALL_RESISTANCE", 1.0, 1);
        profile.addAttribute("BASE_SPEED", -10.25, 1);
        profile.addAttribute("MAX_HEALTH", -2, 0);
    });

}

function getAttributeProfile(entity) {
    return entity.getData('fiskheroes:heat_vision') ? "FOUR_ARMS_SHOOTING_SPIN" : (entity.getData('fiskheroes:beam_charging') ? "FOUR_ARMS_SHOOTING" : "FOUR_ARMS");
}

function tick(entity, manager, isCurrent) {
    if (!isCurrent) {
        return;
    }

    var nbt = entity.getWornChestplate().nbt();    
    var SL = nbt.getByte("four_arms");
    var PT1 = entity.getInterpolatedData('tmf:dyn/pt_1');
    var PC1 = entity.getData('tmf:dyn/pc_1');
    var PT2 = entity.getInterpolatedData('tmf:dyn/pt_2');
    var PC2 = entity.getInterpolatedData('tmf:dyn/pc_2');
    var PT3 = entity.getInterpolatedData('tmf:dyn/pt_3');
    var PC3 = entity.getInterpolatedData('tmf:dyn/pc_3');
    var punchTimer = entity.getPunchTimerInterpolated();
    //Random arm is picked
    var outcomes = [1, 2, 3, 4, 5, 6, 7, 8, 9];
    var randomOutcome = outcomes[Math.floor(Math.random() * outcomes.length)];

    if (PC1 == 0 && ((PT2 == 0 && PC2 == 0 && PT3 == 0 && PC3 == 0)) && punchTimer != 0 && punchTimer <= 0.2) {
        manager.setDataWithNotify(entity, 'tmf:dyn/pc_1', randomOutcome);
    }
    if (PC1 != 0) {
        manager.setData(entity, 'tmf:dyn/pc_1', 0); 
    }

    if (PT2 >= 0.89) {
        manager.setInterpolatedData(entity, 'tmf:dyn/pt_2', 0); 
    }
    if (PC2 == 1) {
        manager.setInterpolatedData(entity, 'tmf:dyn/pc_2', 0); 
    }
    if (PT3 == 1) {
        manager.setInterpolatedData(entity, 'tmf:dyn/pt_3', 0); 
    }
    if (PC3 == 1) {
        manager.setInterpolatedData(entity, 'tmf:dyn/pc_3', 0); 
    }

    //Charged Jump
    manager.incrementData(entity, "tmf:dyn/pt_4", 500, SL >= 15 && !entity.getData('fiskheroes:heat_vision') && entity.getData('fiskheroes:beam_shooting_timer') == 0 && (entity.isSprinting() || entity.isSneaking()) ? 1 : 0);

}

function rockThrowKey(player, manager) {
	
    manager.setData(player, "fiskheroes:beam_charging", true);
    manager.setData(player, "tmf:dyn/p_1", true);

    return true;
}

function isModifierEnabled(entity, modifier) {
    var nbt = entity.getWornChestplate().nbt();	
    var SL = nbt.getByte("four_arms");

    if (modifier.id() == "four_arms_6") {
        return  entity.getData('tmf:dyn/pt_4') <= 0.85;
    }
    if (modifier.id() == "four_arms_12") {
        return  entity.getData('tmf:dyn/pt_4') >= 0.85;
    }

    return true;
}

function isKeyBindEnabled(entity, keyBind) {
    var nbt = entity.getWornChestplate().nbt();	
    var SL = nbt.getByte("four_arms");
    var punchTimer = entity.getPunchTimer();
    var isSneaking = entity.isSneaking();

    if (keyBind == "CHARGED_BEAM3") {
        return SL >= 15 && !isSneaking;
    }
    if (keyBind == "HEAT_VISION_FOURARMS_1") {
        return SL == 60 && isSneaking;
    }

    if (keyBind == "CHARGED_BEAM") {
        return SL >= 15 && !isSneaking;
    }
    if (keyBind == "HEAT_VISION") {
        return SL == 60 && isSneaking;
    }
    if (keyBind == "GROUND_SMASH") {
        return !entity.getData('fiskheroes:heat_vision') && entity.getData('fiskheroes:beam_charge') == 0;
    }
    return false;
}

function getDefaultScale(entity) {
    return 1.3;
}

function getTierOverride(entity) {
    return 8;
}
