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

    hero.setChestplate("Symbiote");


    hero.addPowers("pack:symbiot_phage")
	
	hero.addAttribute("PUNCH_DAMAGE", 8.5, 0);
    hero.addAttribute("JUMP_HEIGHT", 2.0, 0);
    hero.addAttribute("FALL_RESISTANCE", 20.0, 0);
	hero.addAttribute("KNOCKBACK", 1.0, 0);
	hero.addAttribute("BASE_SPEED", 0.3, 1);
	hero.addAttribute("SPRINT_SPEED", 0.15, 0);
	hero.addAttribute("STEP_HEIGHT", 0.5, 0);
	hero.addAttribute("IMPACT_DAMAGE", 0.6, 1);
	
	
	
	hero.addKeyBind("BLADE", "Blade", 1);
	hero.addKeyBind("WEB_ZIP", "Tentacle Zip", 2);
	hero.addKeyBind("TENTACLES", "Thorns", 5);
	hero.addKeyBindFunc("func_GIANT_MODE", giantModeKey, "Symbiote", 5);
	
	hero.addAttributeProfile("INACTIVE", inactiveProfile);
	hero.addAttributeProfile("THORNS", thornsProfile);
	hero.addAttributeProfile("THORNS_BLADE", thornsbladeProfile);
	hero.addAttributeProfile("BLADE", bladeProfile);
    hero.setAttributeProfile(getAttributeProfile);
	hero.setModifierEnabled(isModifierEnabled);
	hero.setTierOverride(getTierOverride);
	hero.setKeyBindEnabled(isKeyBindEnabled);	
	hero.setHasProperty(hasProperty);
	hero.setDamageProfile(getDamageProfile);
    hero.addDamageProfile("PUNCH", {
        "types": {
            "BLUNT": 1.0,
            "SHARP": 0.7
        }
    });

}

function getDamageProfile(entity) {
    return (!entity.getHeldItem().isWeapon() && entity.getData("fiskheroes:blade"))? "PUNCH" : null;
}


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


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

function thornsProfile(profile) {
	profile.inheritDefaults();
	profile.addAttribute("PUNCH_DAMAGE", 9.0, 0);
	profile.addAttribute("BASE_SPEED", 0.2, 1);
	profile.addAttribute("KNOCKBACK", 0.0, 0);
	profile.addAttribute("IMPACT_DAMAGE", 0.7, 1);
}

function thornsbladeProfile(profile) {
	profile.inheritDefaults();
	profile.addAttribute("PUNCH_DAMAGE", 12.0, 0);
	profile.addAttribute("BASE_SPEED", 0.2, 1);
	profile.addAttribute("KNOCKBACK", 1.0, 0);

}

function bladeProfile(profile) {
	profile.inheritDefaults();
	profile.addAttribute("PUNCH_DAMAGE", 11.0, 0);
	profile.addAttribute("BASE_SPEED", 0.3, 1);
	profile.addAttribute("KNOCKBACK", 1.0, 0);

}

function getAttributeProfile(entity) {
	if (!entity.getData("pack:dyn/symbiot") ) {
        return "INACTIVE";
    }
	else if (entity.getData("pack:dyn/symbiot") && entity.getData("fiskheroes:tentacle_extend_timer") > 0 && !entity.getData("fiskheroes:blade")) {
        return "THORNS";
    }
	else if (entity.getData("pack:dyn/symbiot") && entity.getData("fiskheroes:tentacle_extend_timer") > 0 && entity.getData("fiskheroes:blade")) {
        return "THORNS_BLADE";
    }
	else if (entity.getData("pack:dyn/symbiot") && entity.getData("fiskheroes:tentacle_extend_timer") == 0 && entity.getData("fiskheroes:blade")) {
        return "BLADE";
    }
    return null;
}




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

function giantModeKey(player, manager) {
    var flag = player.getData("pack:dyn/symbiot");
    manager.setData(player, "pack:dyn/symbiot", !flag);
    manager.setData(player, "fiskheroes:size_state", flag ? -1 : 1);


	
    return true;
}

function isModifierEnabled(entity, modifier) {
    if (modifier.name() == "fiskheroes:size_manipulation") {
        var giant = entity.getData("pack:dyn/symbiot_timer") > 0;
        return modifier.id() == "giant" ? giant : !giant;
    }
	

	

	switch (modifier.name()) {
	case "fiskheroes:thorns":
        return entity.getData("fiskheroes:tentacle_extend_timer") > 0;
	case "fiskheroes:blade":
        return entity.getData("pack:dyn/symbiot");
	case "fiskheroes:spike_burst":
        return entity.getData("fiskheroes:tentacle_extend_timer") > 0;
	case "fiskheroes:water_breathing":
        return entity.getData("pack:dyn/symbiot");
	case "fiskheroes:wall_crawling":
        return entity.getData("pack:dyn/symbiot");
	case "fiskheroes:potion_immunity":
        return entity.getData("pack:dyn/symbiot");
	case "fiskheroes:arrow_catching":
        return entity.getData("pack:dyn/symbiot");
	case "fiskheroes:leaping":
        return entity.getData("pack:dyn/symbiot");
	case "fiskheroes:tentacles":
        return entity.getData("pack:dyn/symbiot");

	default:
	
		return true;
    }
	

    return true;
}

function isKeyBindEnabled(entity, keyBind) {
	 if (keyBind == "func_GIANT_MODE") {
        return entity.getData("fiskheroes:mask_open_timer") == 0 && (entity.getData("pack:dyn/symbiot") || entity.getData("pack:dyn/symbiot_cooldown") >= 0) && !entity.isSneaking() ;;
    }
    else if (!entity.getData("pack:dyn/symbiot")) {
        return false;
    }
    switch (keyBind) {
    case "func_GIANT_MODE":
        return (entity.getData("pack:dyn/symbiot") || entity.getData("pack:dyn/symbiot_cooldown") >= 0) && !entity.isSneaking() ;
    case "SIZE_MANIPULATION":
        return !entity.getData("pack:dyn/symbiot");
	case "BLADE":
        return entity.getData("pack:dyn/symbiot") || entity.isBookPlayer();
	case "WEB_ZIP":
        return entity.getData("pack:dyn/symbiot") && !entity.getData("fiskheroes:blade") || entity.isBookPlayer();
	case "TENTACLES":
        return entity.getData("pack:dyn/symbiot") && entity.isSneaking() ||  entity.isBookPlayer();

    default:
        return true;
    }
}

