-- Переменные для координат спавна крипов local radiantSpawnPoint = Vector3.new(133.165,…
- User
-- Переменные для координат спавна крипов local radiantSpawnPoint = Vector3.new(133.165, 0.5, 47.051) local direSpawnPoint = Vector3.new(-132.107, 0.5, 43.742) local creepsattackrange = 8 local radiantModels = {} local direModels = {} local middle = Vector3.new(0,10,0) local pathfindingService = game:GetService("PathfindingService")
function startFight(creep, targetCreep, enemyThrone) local distanceToMiddle = (middle - creep.PrimaryPart.Position).Magnitude if distanceToMiddle > 40 then local pathToThrone = pathfindingService:CreatePath() pathToThrone:ComputeAsync(creep.PrimaryPart.Position, enemyThrone.Position) local waypointsToThrone = pathToThrone:GetWaypoints()
codefor i = 1, #waypointsToThrone do creep.Humanoid:MoveTo(waypointsToThrone[i].Position) creep.Humanoid.MoveToFinished:Wait() -- Проверка расстояния до enemyThrone после каждого подхода к нему local distanceToThrone = (enemyThrone.Position - creep.PrimaryPart.Position).Magnitude if distanceToThrone <= creepsattackrange then targetCreep = nil break end end end if targetCreep.Name ~= creep.Name then local initialPos = middle while creep.Humanoid.Health > 0 and targetCreep.Humanoid.Health > 0 do -- Проверка расстояния между крипами local distance = (targetCreep.PrimaryPart.Position - creep.PrimaryPart.Position).Magnitude if distance <= creepsattackrange then coroutine.wrap(function() local cd = false if cd == false then cd = true targetCreep.Humanoid:TakeDamage(math.random(0,5)) wait(0.5) cd = false end end)() creep.Humanoid:MoveTo(targetCreep.PrimaryPart.Position) creep.Humanoid.MoveToFinished:Wait() else -- Если враждебный крип убежал далеко, двигаться к нему local path = pathfindingService:CreatePath() path:ComputeAsync(creep.PrimaryPart.Position, targetCreep.PrimaryPart.Position) local waypoints = path:GetWaypoints() for i = 1, #waypoints do creep.Humanoid:MoveTo(waypoints[i].Position) creep.Humanoid.MoveToFinished:Wait() -- Проверка на расстояние после каждого подхода к враждебному крипу distance = (targetCreep.PrimaryPart.Position - creep.PrimaryPart.Position).Magnitude if distance <= creepsattackrange then return end -- Проверка на удаление от координаты "middle" local distanceToMiddle = (middle - creep.PrimaryPart.Position).Magnitude if distanceToMiddle > 40 then creep.Humanoid:MoveTo(middle) -- Возвращаемся к позиции "middle" creep.Humanoid.MoveToFinished:Wait() return end end end end -- Возвращаемся к начальной позиции перед завершением creep.Humanoid:MoveTo(initialPos) creep.Humanoid.MoveToFinished:Wait() end - Assistant