local units = FindUnitsInRadius(caster:GetTeamNumber(), target_location, nil, radius, target_teams, target_types, target_flags, 0, false)
-- Calculate the position of each found unit in relation to the center
for i,unit in ipairs(units) do
local unit_location = unit:GetAbsOrigin()
local vector_distance = target_location - unit_location
local distance = (vector_distance):Length2D()
local direction = (vector_distance):Normalized()
-- If the target is greater than 40 units from the center, we move them 40 units towards it, otherwise we move them directly to the center
if distance >= 40 then
unit:SetAbsOrigin(unit_location + direction * speed)
else
unit:SetAbsOrigin(unit_location + direction * distance)
end
unit:AddNewModifier(caster, ability, "modifier_infinity_black_hole", {duration = 0.2})
local primary_damage = ability:GetSpecialValueFor("damage")
local damage_percent = ability:GetSpecialValueFor("damage_perc")/100
local damage = ((unit:GetMaxHealth()*damage_percent) + primary_damage)/10
if caster:HasScepter() and caster:HasAbility("enigma_midnight_pulse_new") then
damage = ((unit:GetMaxHealth()*damage_percent) + primary_damage + (unit:GetMaxHealth()*midnightpulse_damage))/10
end
ApplyDamage({victim = unit, attacker = caster, ability = ability, damage = damage, damage_type = DAMAGE_TYPE_PURE, damage_flags = DOTA_DAMAGE_FLAG_BYPASSES_INVULNERABILITY + DOTA_DAMAGE_FLAG_HPLOSS})
end