function OnFuto01AttackLanded(keys)
	local caster = EntIndexToHScript(keys.caster_entindex)
	local target = keys.target

	if caster.thtd_futo_01_effct_index == nil then
		caster.thtd_futo_01_effct_index = 1
	end

	if caster.thtd_futo_01_effct_index == 1 then
		local damage = caster:THTD_GetStarDamage() * keys.damage1 * (1 + GetFuto02Buff(caster))
		local targets = 
			FindUnitsInLine(
				caster:GetTeamNumber(), 
				target:GetOrigin(), 
				target:GetOrigin() + 800 * -target:GetForwardVector(), 
				nil, 
				200,
				keys.ability:GetAbilityTargetTeam(), 
				keys.ability:GetAbilityTargetType(), 
				keys.ability:GetAbilityTargetFlags()
			)
		for k,v in pairs(targets) do
			local DamageTable = {
	   			ability = keys.ability,
	            victim = v, 
	            attacker = caster, 
	            damage = damage, 
	            damage_type = keys.ability:GetAbilityDamageType(), 
	            damage_flags = DOTA_DAMAGE_FLAG_NONE
		   	}
		   	UnitDamageTarget(DamageTable)
		end
	elseif caster.thtd_futo_01_effct_index == 2 then
		if caster.__foto_lock ~= true then 
			caster.__foto_lock = true
			local targets = THTD_FindUnitsInRadius(caster,caster:GetOrigin(),1200)
			local damage = caster:THTD_GetStarDamage() * keys.damage2 * (1 + GetFuto02Buff(caster))
			for i=1,#targets do
				local unit = targets[i]
				if unit~=nil and unit:IsNull()==false and unit~=target and unit:IsAlive() then
					caster:PerformAttack(unit,false,false,false,false,true,false,false)
					local DamageTable = {
				   			ability = keys.ability,
				            victim = unit, 
				            attacker = caster, 
				            damage = damage, 
				            damage_type = keys.ability:GetAbilityDamageType(), 
				            damage_flags = DOTA_DAMAGE_FLAG_NONE
				   	}
				   	UnitDamageTarget(DamageTable)
				end
			end
			caster.__foto_lock = false
		end
	elseif caster.thtd_futo_01_effct_index == 3 then
		local targets = THTD_FindUnitsInRadius(caster,target:GetOrigin(),keys.range)
		local damage = caster:THTD_GetStarDamage() * keys.damage3 * 0.3 * (1 + GetFuto02Buff(caster))
		for k,v in pairs(targets) do
			local time = keys.duration_time
			v:AddPoison(1, caster)
			v:SetContextThink(DoUniqueString("thtd_futo_01_damage_think"), 
				function()
					if GameRules:IsGamePaused() then return 0.03 end
					if time <= 0 then 
						v:AddPoison(-1)
						return nil 
					end					
					local DamageTable = {
				   			ability = keys.ability,
				            victim = v, 
				            attacker = caster, 
				            damage = damage, 
				            damage_type = keys.ability:GetAbilityDamageType(), 
				            damage_flags = DOTA_DAMAGE_FLAG_NONE
				   	}
					UnitDamageTarget(DamageTable)
					time = time - 0.3
					return 0.3
				end, 
			0.3)
		end
	elseif caster.thtd_futo_01_effct_index == 4 then
		local targets = THTD_FindUnitsInRadius(caster,target:GetOrigin(),keys.range)
		local damage = caster:THTD_GetStarDamage() * keys.damage4 * (1 + GetFuto02Buff(caster))
		for k,v in pairs(targets) do
			local DamageTable = {
		   			ability = keys.ability,
		            victim = v, 
		            attacker = caster, 
		            damage = damage, 
		            damage_type = keys.ability:GetAbilityDamageType(), 
		            damage_flags = DOTA_DAMAGE_FLAG_NONE
		   	}
		   	UnitDamageTarget(DamageTable)
		end

	   	local effectIndex = ParticleManager:CreateParticle("particles/heroes/thtd_futo/ability_thtd_futo_01_fire.vpcf", PATTACH_CUSTOMORIGIN, target)
		ParticleManager:SetParticleControl(effectIndex, 0, target:GetOrigin())
		ParticleManager:DestroyParticleSystem(effectIndex,false)
	elseif caster.thtd_futo_01_effct_index == 5 then
		local targets = THTD_FindUnitsInRadius(caster,target:GetOrigin(),keys.range)
		for k,v in pairs(targets) do
			if not v:HasModifier("modifier_futo_01_lock") then 
				keys.ability:ApplyDataDrivenModifier(caster, v, "modifier_futo_01_lock", {Duration = 1.0})				
				UnitStunTarget(caster,v,keys.stun_time)	   			
	   		end
		end
	elseif caster.thtd_futo_01_effct_index == 6 then
		local targets = THTD_FindUnitsInRadius(caster,target:GetOrigin(),keys.range)
		local damage = keys.attack_damage * keys.crit * (1 + GetFuto02Buff(caster))	   	
		for k,v in pairs(targets) do
			local DamageTable = {
	   			ability = keys.ability,
	            victim = v, 
	            attacker = caster, 
	            damage = damage, 
	            damage_type = keys.ability:GetAbilityDamageType(), 
	            damage_flags = DOTA_DAMAGE_FLAG_NONE
		   	}
		   	UnitDamageTarget(DamageTable)
			SendOverheadEventMessage(caster:GetPlayerOwner(), OVERHEAD_ALERT_CRITICAL, v, damage, caster:GetPlayerOwner() )
		end
	end

	caster.thtd_futo_01_effct_index = RandomInt(1,6)
	caster:SetRangedProjectileName("particles/heroes/thtd_futo/ability_futo_base_attack_"..caster.thtd_futo_01_effct_index..".vpcf")
end

function OnFuto02Kill(keys)
	local caster = EntIndexToHScript(keys.caster_entindex)
	local modifier = caster:FindModifierByName("modifier_futo_02_buff")
	if modifier==nil then
		modifier = keys.ability:ApplyDataDrivenModifier(caster, caster, "modifier_futo_02_buff", {Duration = keys.duration_time})
		modifier:SetStackCount(1)
	else
		if modifier:GetStackCount() < keys.max_count then
			modifier:SetStackCount(modifier:GetStackCount()+1)
		end
		modifier:SetDuration(keys.duration_time,false)
	end
end

function GetFuto02Buff(caster)
	local modifier = caster:FindModifierByName("modifier_futo_02_buff")
	if modifier~=nil then
		return modifier:GetStackCount() * caster:GetAbilityValue("thtd_futo_02", "damage_up", true)
	end
	return 0
end

function OnFuto03SpellStart(keys)
	local caster = EntIndexToHScript(keys.caster_entindex)
	local targetPoint = keys.target_points[1]

	local effectIndex = ParticleManager:CreateParticle("particles/heroes/thtd_futo/ability_thtd_futo_03.vpcf", PATTACH_CUSTOMORIGIN, caster)
	ParticleManager:SetParticleControl(effectIndex, 0, targetPoint)
	ParticleManager:DestroyParticleSystem(effectIndex,false)

	local time = keys.duration_time
	caster:SetContextThink(DoUniqueString("thtd_futo_03_spell_think"), 
		function()
			if GameRules:IsGamePaused() then return 0.03 end
			if time <= 0 then return nil end			
			local targets = THTD_FindUnitsInRadius(caster,targetPoint,keys.range)
			local damage = caster:THTD_GetAbilityPowerDamage(keys.ability) * 0.2 * (1 + GetFuto02Buff(caster))
			if caster:HasModifier("modifier_miko_02_buff") and caster.thtd_miko_buff_futo03 ~= nil then				
				damage = damage * (1 + caster.thtd_miko_buff_futo03/100)
			end		
			for k,v in pairs(targets) do				
				local DamageTable = {
			   			ability = keys.ability,
			            victim = v, 
			            attacker = caster, 
			            damage = damage, 
			            damage_type = keys.ability:GetAbilityDamageType(), 
			            damage_flags = DOTA_DAMAGE_FLAG_NONE
			   	}
			   	UnitDamageTarget(DamageTable)
			end
			time = time - 0.2
			return 0.2
		end, 
	0)
end