function init(hero) {
    hero.setName("Toxin");
	hero.setVersion("P. Mulligan");
    hero.setTier(8);
	

    hero.setChestplate("Symbiote");


    hero.addPowers("pack:symbiot_toxin")
	
	hero.addAttribute("PUNCH_DAMAGE", 11.0, 0);
    hero.addAttribute("JUMP_HEIGHT", 3.0, 0);
    hero.addAttribute("FALL_RESISTANCE", 20.0, 0);
	hero.addAttribute("KNOCKBACK", 3.0, 0);
	hero.addAttribute("BASE_SPEED", 0.3, 1);
	hero.addAttribute("MAX_HEALTH", 9.0, 0);
	hero.addAttribute("SPRINT_SPEED", 0.15, 0);
	hero.addAttribute("STEP_HEIGHT", 0.5, 0);
	
	
	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("TENTACLE_JAB", "key.tentacleJab", 1);
    hero.addKeyBind("TENTACLE_GRAB", "key.tentacleGrab", 2);
    hero.addKeyBind("TENTACLES", "key.tentacles", 5);
	
	hero.addKeyBind("BLADE", "key.blade", 4);
	
	hero.addKeyBindFunc("func_GIANT_MODE", giantModeKey, "Symbiote", 5);
	
	hero.setAttributeProfile(getAttributeProfile);
		hero.addAttributeProfile("INACTIVE", inactiveProfile);
		hero.addAttributeProfile("RAGE_NOBLADE", ragenobladeProfile);
		hero.addAttributeProfile("RAGE_BLADE", ragebladeProfile);
		hero.addAttributeProfile("BLADE", bladeProfile);
		
	hero.setDamageProfile(getDamageProfile);
		hero.addDamageProfile("CLAWS", {
			"types": {
				"SHARP": 0.7,
				"BLUNT": 0.3
			}
		});
	
	hero.setModifierEnabled(isModifierEnabled);
	hero.setTierOverride(getTierOverride);
	hero.setKeyBindEnabled(isKeyBindEnabled);	
	hero.setHasProperty(hasProperty);
	

}

function getDamageProfile(entity) {
    return entity.getData("fiskheroes:blade") && entity.getHeldItem().isEmpty() ? "CLAWS" : 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 ragenobladeProfile(profile) {
	profile.inheritDefaults();
	profile.addAttribute("PUNCH_DAMAGE", 12.5, 0);
	profile.addAttribute("JUMP_HEIGHT", 4.0, 0);
	profile.addAttribute("BASE_SPEED", 0.5, 1);
}

function ragebladeProfile(profile) {
	profile.inheritDefaults();
	profile.addAttribute("PUNCH_DAMAGE", 13.5, 0);
	profile.addAttribute("JUMP_HEIGHT", 4.0, 0);
	profile.addAttribute("BASE_SPEED", 0.5, 1);
	profile.addAttribute("REACH_DISTANCE", 0.1, 0);
}

function bladeProfile(profile) {
	profile.inheritDefaults();
	profile.addAttribute("PUNCH_DAMAGE", 12.0, 0);
	profile.addAttribute("REACH_DISTANCE", 0.1, 0);
}

function getAttributeProfile(entity) {
	if (!entity.getData("pack:dyn/symbiot") ) {
        return "INACTIVE";
    }
	else if (entity.getData("pack:dyn/symbiot") && entity.getHealth() > 10 && entity.getData('fiskheroes:blade')) {
        return "BLADE";
    }
	else if (entity.getData("pack:dyn/symbiot") && entity.getHealth() <= 10 && !entity.getData('fiskheroes:blade')) {
        return "RAGE_NOBLADE";
    }
	else if (entity.getData("pack:dyn/symbiot") &&entity.getHealth() <= 10 && entity.getData('fiskheroes:blade')) {
        return "RAGE_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 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:tentacles_retracting", !flag);
    manager.setDataWithNotify(player, "fiskheroes:web_swinging", !flag);
    return true;
}

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


	switch (modifier.name()) {
	case "fiskheroes:web_swinging":
        return entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:utility_belt_type") == -1 && entity.getData("pack:dyn/symbiot");
    case "fiskheroes:leaping":
        return modifier.id() == "springboard" == (entity.getData("fiskheroes:ticks_since_swinging") < 5) && entity.getData("pack:dyn/symbiot");
	case "fiskheroes:equipment":
        return entity.getData("pack:dyn/symbiot") && entity.getData("fiskheroes:tentacles") == null;
	case "fiskheroes:tentacles":
        return entity.getData("pack:dyn/symbiot");
	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:blade":
        return entity.getData("pack:dyn/symbiot");

    default:
        return true;
    }
    return true;
}

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

	case "TENTACLES":
        return entity.getData("pack:dyn/symbiot") && entity.isSneaking()  && !entity.getData("fiskheroes:web_swinging") ||  entity.isBookPlayer();
	case "WEB_ZIP":
        return entity.getData("fiskheroes:tentacles") == null ;
	case "UTILITY_BELT":
        return entity.getData("fiskheroes:tentacles") == null ;
    case "func_WEB_SWINGING":
        return entity.getHeldItem().isEmpty();

    default:
        return true;
    }
}

