modifier_hourainingyou_01 = class({})

local public = modifier_hourainingyou_01

--------------------------------------------------------------------------------

function public:IsDebuff()
	return false
end

--------------------------------------------------------------------------------

function public:IsHidden()
	return true
end

--------------------------------------------------------------------------------

function public:IsPurgable()
	return false
end

function public:GetTexture()
	return "touhoutd/thtd_hourainingyou_01"
end

--------------------------------------------------------------------------------

function public:DeclareFunctions()
	local funcs = {
			MODIFIER_EVENT_ON_ATTACK_LANDED,
	}
	return funcs
end

function public:OnAttackLanded( params )
	if IsServer() then
		if params.attacker ~= self:GetParent() or self:GetParent():IsIllusion() then return end
		if self:GetParent():PassivesDisabled() then	return	end	

		local caster = params.attacker
		local target = params.target
		local ability = self:GetAbility()	

		if RollPercentage(ability:GetSpecialValueFor("chance")) then			
			if not target:HasModifier("modifier_hourainingyou_01_stun_lock") then 			
				target:AddNewModifier(caster, ability, "modifier_hourainingyou_01_stun_lock", {Duration = ability:GetSpecialValueFor("lock_time")})	
				UnitStunTarget(caster,target,ability:GetSpecialValueFor("stun_time"))	   
			end
			local DamageTable = {
					ability = ability,
					victim = target, 
					attacker = caster, 
					damage = caster:THTD_GetAbilityPowerDamage(ability), 
					damage_type = ability:GetAbilityDamageType(), 
					damage_flags = DOTA_DAMAGE_FLAG_NONE
			}
			UnitDamageTarget(DamageTable)
		end
	end
end