function init(hero) {
    hero.setName("Spider-Man");
	hero.setVersion("Symbiote Suit");
    hero.setTier(8);
	

    hero.setHelmet("item.superhero_armor.piece.mask");
    hero.setChestplate("item.superhero_armor.piece.chestpiece");
    hero.setLeggings("item.superhero_armor.piece.pants");
    hero.setBoots("item.superhero_armor.piece.boots");


    hero.addPowers("fiskheroes:spider_physiology", "fiskheroes:web_shooters_ps4", "pack:symbiot_venom_spider_man")
	
	hero.addAttribute("FALL_RESISTANCE", 15.0, 0);
    hero.addAttribute("JUMP_HEIGHT", 2.3, 0);
    hero.addAttribute("PUNCH_DAMAGE", 9.0, 0);
    hero.addAttribute("SPRINT_SPEED", 0.55, 1);
    hero.addAttribute("STEP_HEIGHT", 0.5, 0);
    hero.addAttribute("IMPACT_DAMAGE", 0.6, 1);
	
	
	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_STRIKE", "key.tentacleStrike", 2);
	hero.addKeyBind("TENTACLES", "Tentacles", 5);
	
	
	hero.addKeyBind("SLOW_MOTION", "key.slowMotion", 4);
	
	
	hero.addKeyBindFunc("func_GIANT_MODE", giantModeKey, "Symbiote", 5);
	hero.addKeyBindFunc("ABILITY", symbioteModeKey, "Lose Control", 5);
	
	
	
	hero.setAttributeProfile(getAttributeProfile);
		hero.addAttributeProfile("INACTIVE", inactiveProfile);
		hero.addAttributeProfile("ABILITY", abilityProfile);
		
	hero.setModifierEnabled(isModifierEnabled);
	hero.setTierOverride(getTierOverride);
	hero.setKeyBindEnabled(isKeyBindEnabled);	
	hero.setHasProperty(hasProperty);
	

}



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.addAttribute("FALL_RESISTANCE", 13.0, 0);
    profile.addAttribute("JUMP_HEIGHT", 2.0, 0);
    profile.addAttribute("PUNCH_DAMAGE", 8.0, 0);
    profile.addAttribute("SPRINT_SPEED", 0.45, 1);
    profile.addAttribute("STEP_HEIGHT", 0.5, 0);
    profile.addAttribute("IMPACT_DAMAGE", 0.5, 1);
}

function abilityProfile(profile) {
	profile.inheritDefaults();

    profile.addAttribute("JUMP_HEIGHT", 2.6, 0);
    profile.addAttribute("PUNCH_DAMAGE", 9.5, 0);
    profile.addAttribute("SPRINT_SPEED", 0.6, 1);


}



function getAttributeProfile(entity) {
	if (!entity.getData("pack:dyn/symbiot") ) {
        return "INACTIVE";
    }
	else if (entity.getData("pack:dyn/symbiot") && entity.getData("pack:dyn/ability")) {
        return "ABILITY";
    }
    return null;
}




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

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 symbioteModeKey(player, manager) {
    var flag = player.getData("pack:dyn/symbiot");
	manager.setData(player, "pack:dyn/symbiot", true);
	manager.setData(player, "pack:dyn/symbiot_cooldown", 0.999);
	manager.setDataWithNotify(player, "fiskheroes:tentacles_retracting", true);
    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);
    }
	
	 if (modifier.name() == "fiskheroes:cooldown" ) {
        var giant = entity.getData("pack:dyn/symbiot_timer") > 0;
		var base = entity.getHealth() > 10;
		var rage = entity.getHealth() <= 10;
		
		if (modifier.id() == "symbiot_cooldown" ) {

			return  !entity.getData("pack:dyn/ability");
		}
		else if (modifier.id() == "ability_cooldown" ) {

			return entity.getData("pack:dyn/ability") || true;
		}
        return true;
    }


	switch (modifier.name()) {
	case "fiskheroes:web_swinging":
        return entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:utility_belt_type") == -1  && (modifier.id() == "symbiot_swing" == (entity.getData("pack:dyn/symbiot")));
    case "fiskheroes:leaping":
        return modifier.id() == "springboard" == (entity.getData("fiskheroes:ticks_since_swinging") < 5) ;
	
	case "fiskheroes:tentacles":
        return entity.getData("pack:dyn/ability");
	case "fiskheroes:water_breathing":
        return entity.getData("pack:dyn/symbiot");
	
	case "fiskheroes:equipment":
        return entity.getData("fiskheroes:tentacles") == null && (modifier.id() == "symbiot_equipment" == (entity.getData("pack:dyn/symbiot")));
	case "fiskheroes:web_zip":
        return modifier.id() == "symbiot_zip" == (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 && !entity.getData("pack:dyn/ability");
    }
	if (keyBind == "SIZE_MANIPULATION") {
        return !entity.getData("pack:dyn/symbiot");
    }

	
    switch (keyBind) {

	case "TENTACLES":
        return entity.getData("pack:dyn/ability") && !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() && entity.getData("fiskheroes:tentacles") == null ;
		
	case "TENTACLE_JAB":
        return entity.getData("pack:dyn/ability") && entity.getData("fiskheroes:tentacle_extend_timer") > 0;
	case "TENTACLE_STRIKE":
        return entity.getData("pack:dyn/ability") && entity.getData("fiskheroes:tentacle_extend_timer") > 0;
		
	case "ABILITY":
        return (entity.isSneaking()  && !entity.getData("pack:dyn/ability")) || false;
		
    

    default:
        return true;
    }
}

