modifier_hanadayousei_01 = class({})

local public = modifier_hanadayousei_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_hanadayousei_01"
end

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

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

function public:OnAttack( 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			

		if caster.__hanadayousei_lock ~= true then 
			caster.__hanadayousei_lock = true
			local targets = THTD_FindUnitsInRadius(caster,caster:GetOrigin(),800)
			local count = 1
			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,true,false,true,false,true,false,true)
					count = count + 1
				end
				if count > 3 then
					break
				end
			end
			caster.__hanadayousei_lock = false
		end
	end
end