function OnSpellStartWriggle02(keys) local caster = EntIndexToHScript(keys.caster_entindex) local vecCaster = caster:GetOrigin() local vecForward = caster:GetForwardVector() local targetPoint = keys.target_points[1] + Vector(0, 0, 200) local range = keys.range local max_count = keys.max_count local effectIndex1 = ParticleManager:CreateParticle("particles/units/heroes/hero_keeper_of_the_light/keeper_dazzling.vpcf", PATTACH_CUSTOMORIGIN, caster) ParticleManager:SetParticleControl(effectIndex1, 0, targetPoint) ParticleManager:SetParticleControl(effectIndex1, 1, Vector(range, 1, 1)) local effectIndex2 = nil local count = 1 local startTime = GameRules:GetGameTime() caster:SetContextThink(DoUniqueString("thtd_wriggle_02"), function () if GameRules:IsGamePaused() then return 0.03 end if count/3 > max_count or THTD_IsValid(caster) == false then ParticleManager:DestroyParticleSystem(effectIndex1,true) if effectIndex2 ~= nil then ParticleManager:DestroyParticleSystem(effectIndex2,true) end -- print("---- duration time : ", GameRules:GetGameTime() - startTime) return nil end if count%3 == 1 then effectIndex2 = ParticleManager:CreateParticle("particles/units/heroes/hero_keeper_of_the_light/keeper_dazzling_on.vpcf", PATTACH_CUSTOMORIGIN, caster) ParticleManager:SetParticleControl(effectIndex2, 0, targetPoint) ParticleManager:SetParticleControl(effectIndex2, 1, Vector(range, 0, 0)) local targets = THTD_FindUnitsInRadius(caster,targetPoint,range) for k,v in pairs(targets) do if v.thtd_is_fearing ~= true then v.thtd_is_fearing = true local current_next_move_point = v.next_move_point v.next_move_point = targetPoint keys.ability:ApplyDataDrivenModifier(caster, v, "modifier_wriggle02_speed", {}) local fearCount = 0.5 * 2 * 10 -- local startTime = GameRules:GetGameTime() v:SetContextThink(DoUniqueString("modifier_thtd_wriggle_02"), function() if GameRules:IsGamePaused() then return 0.03 end if not IsValidAlive(target) then return nil end fearCount = fearCount - 1 if fearCount <= 0 or THTD_IsValid(caster) == false then target.next_move_point = current_next_move_point target.thtd_is_fearing = false return nil end return 0.1 end, 0) end end elseif count%3 == 0 then ParticleManager:DestroyParticleSystem(effectIndex2,true) effectIndex2 = nil end count = count + 1 return 0.5 end, 0) end