saintcupids

wow

Oct 14th, 2022 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.30 KB | None | 0 0
  1. if getgenv().Aiming then return getgenv().Aiming end
  2.  
  3. -- // Services
  4. local Players = game:GetService("Players")
  5. local Workspace = game:GetService("Workspace")
  6. local GuiService = game:GetService("GuiService")
  7. local RunService = game:GetService("RunService")
  8. local UserInputService = game:GetService("UserInputService")
  9.  
  10. -- // Vars
  11. local Heartbeat = RunService.Heartbeat
  12. local LocalPlayer = Players.LocalPlayer
  13. local CurrentCamera = Workspace.CurrentCamera
  14. local Mouse = LocalPlayer:GetMouse()
  15.  
  16. -- // Optimisation Vars (ugly)
  17. local Drawingnew = Drawing.new
  18. local Color3fromRGB = Color3.fromRGB
  19. local Vector2new = Vector2.new
  20. local GetGuiInset = GuiService.GetGuiInset
  21. local Randomnew = Random.new
  22. local mathfloor = math.floor
  23. local CharacterAdded = LocalPlayer.CharacterAdded
  24. local CharacterAddedWait = CharacterAdded.Wait
  25. local WorldToViewportPoint = CurrentCamera.WorldToViewportPoint
  26. local RaycastParamsnew = RaycastParams.new
  27. local EnumRaycastFilterTypeBlacklist = Enum.RaycastFilterType.Blacklist
  28. local Raycast = Workspace.Raycast
  29. local GetPlayers = Players.GetPlayers
  30. local Instancenew = Instance.new
  31. local IsDescendantOf = Instancenew("Part").IsDescendantOf
  32. local FindFirstChildWhichIsA = Instancenew("Part").FindFirstChildWhichIsA
  33. local FindFirstChild = Instancenew("Part").FindFirstChild
  34. local tableremove = table.remove
  35. local tableinsert = table.insert
  36. local RenderStepped = RunService.RenderStepped
  37. local RenderSteppedWait = RenderStepped.Wait
  38. local GetMouseLocation = UserInputService.GetMouseLocation
  39.  
  40. -- // Silent Aim Vars
  41. local Aiming = {
  42. Enabled = true,
  43.  
  44. ShowFOV = true,
  45. FOV = 60,
  46. FOVSides = 12,
  47. FOVColour = Color3fromRGB(231, 84, 128),
  48.  
  49. VisibleCheck = true,
  50.  
  51. HitChance = 100,
  52.  
  53. Selected = nil,
  54. SelectedPart = nil,
  55. SelectedPosition = nil,
  56. SelectedPositionOnScreen = nil,
  57.  
  58. TargetPart = {"Head", "UpperTorso", "LowerTorso", "HumanoidRootPart"}
  59.  
  60. Ignored = {
  61. Teams = {
  62. {
  63. Team = LocalPlayer.Team,
  64. TeamColor = LocalPlayer.TeamColor,
  65. },
  66. },
  67. Players = {
  68. LocalPlayer,
  69. 91318356
  70. }
  71. },
  72.  
  73. RaycastIgnore = nil,
  74. }
  75. getgenv().Aiming = Aiming
  76.  
  77. -- // Create circle
  78. local circle = Drawingnew("Circle")
  79. circle.Transparency = 1
  80. circle.Thickness = 2
  81. circle.Color = Aiming.FOVColour
  82. circle.Filled = false
  83. Aiming.FOVCircle = circle
  84.  
  85. -- // Update
  86. function Aiming.UpdateFOV()
  87. -- // Make sure the circle exists
  88. if not (circle) then
  89. return
  90. end
  91.  
  92. -- // Set Circle Properties
  93. circle.Visible = Aiming.ShowFOV
  94. circle.Radius = (Aiming.FOV * 3)
  95. circle.Position = Vector2new(Mouse.X, Mouse.Y + GetGuiInset(GuiService).Y)
  96. circle.NumSides = Aiming.FOVSides
  97. circle.Color = Aiming.FOVColour
  98.  
  99. -- // Return circle
  100. return circle
  101. end
  102.  
  103. -- // Custom Functions
  104. local CalcChance = function(percentage)
  105. -- // Floor the percentage
  106. percentage = mathfloor(percentage)
  107.  
  108. -- // Get the chance
  109. local chance = mathfloor(Randomnew().NextNumber(Randomnew(), 0, 1) * 100) / 100
  110.  
  111. -- // Return
  112. return chance <= percentage / 100
  113. end
  114.  
  115. -- // Customisable Checking Functions: Is a part visible
  116. function Aiming.IsPartVisible(Part, PartDescendant)
  117. -- // Vars
  118. local Character = LocalPlayer.Character or CharacterAddedWait(CharacterAdded)
  119. local Origin = CurrentCamera.CFrame.Position
  120. local _, OnScreen = WorldToViewportPoint(CurrentCamera, Part.Position)
  121.  
  122. -- //
  123. if (OnScreen) then
  124. -- // Vars
  125. local raycastParams = RaycastParamsnew()
  126. raycastParams.FilterType = EnumRaycastFilterTypeBlacklist
  127. raycastParams.FilterDescendantsInstances = Aiming.RaycastIgnore or {Character, CurrentCamera}
  128.  
  129. -- // Cast ray
  130. local Result = Raycast(Workspace, Origin, Part.Position - Origin, raycastParams)
  131.  
  132. -- // Make sure we get a result
  133. if (Result) then
  134. -- // Vars
  135. local PartHit = Result.Instance
  136. local Visible = (not PartHit or IsDescendantOf(PartHit, PartDescendant))
  137.  
  138. -- // Return
  139. return Visible
  140. end
  141. end
  142.  
  143. -- // Return
  144. return false
  145. end
  146.  
  147. -- // Ignore player
  148. function Aiming.IgnorePlayer(Player)
  149. -- // Vars
  150. local Ignored = Aiming.Ignored
  151. local IgnoredPlayers = Ignored.Players
  152.  
  153. -- // Find player in table
  154. for _, IgnoredPlayer in ipairs(IgnoredPlayers) do
  155. -- // Make sure player matches
  156. if (IgnoredPlayer == Player) then
  157. return false
  158. end
  159. end
  160.  
  161. -- // Blacklist player
  162. tableinsert(IgnoredPlayers, Player)
  163. return true
  164. end
  165.  
  166. -- // Unignore Player
  167. function Aiming.UnIgnorePlayer(Player)
  168. -- // Vars
  169. local Ignored = Aiming.Ignored
  170. local IgnoredPlayers = Ignored.Players
  171.  
  172. -- // Find player in table
  173. for i, IgnoredPlayer in ipairs(IgnoredPlayers) do
  174. -- // Make sure player matches
  175. if (IgnoredPlayer == Player) then
  176. -- // Remove from ignored
  177. tableremove(IgnoredPlayers, i)
  178. return true
  179. end
  180. end
  181.  
  182. -- //
  183. return false
  184. end
  185.  
  186. -- // Ignore team
  187. function Aiming.IgnoreTeam(Team, TeamColor)
  188. -- // Vars
  189. local Ignored = Aiming.Ignored
  190. local IgnoredTeams = Ignored.Teams
  191.  
  192. -- // Find team in table
  193. for _, IgnoredTeam in ipairs(IgnoredTeams) do
  194. -- // Make sure team matches
  195. if (IgnoredTeam.Team == Team and IgnoredTeam.TeamColor == TeamColor) then
  196. return false
  197. end
  198. end
  199.  
  200. -- // Ignore team
  201. tableinsert(IgnoredTeams, {Team, TeamColor})
  202. return true
  203. end
  204.  
  205. -- // Unignore team
  206. function Aiming.UnIgnoreTeam(Team, TeamColor)
  207. -- // Vars
  208. local Ignored = Aiming.Ignored
  209. local IgnoredTeams = Ignored.Teams
  210.  
  211. -- // Find team in table
  212. for i, IgnoredTeam in ipairs(IgnoredTeams) do
  213. -- // Make sure team matches
  214. if (IgnoredTeam.Team == Team and IgnoredTeam.TeamColor == TeamColor) then
  215. -- // Remove
  216. tableremove(IgnoredTeams, i)
  217. return true
  218. end
  219. end
  220.  
  221. -- // Return
  222. return false
  223. end
  224.  
  225. -- // Toggle team check
  226. function Aiming.TeamCheck(Toggle)
  227. if (Toggle) then
  228. return Aiming.IgnoreTeam(LocalPlayer.Team, LocalPlayer.TeamColor)
  229. end
  230.  
  231. return Aiming.UnIgnoreTeam(LocalPlayer.Team, LocalPlayer.TeamColor)
  232. end
  233.  
  234. -- // Check teams
  235. function Aiming.IsIgnoredTeam(Player)
  236. -- // Vars
  237. local Ignored = Aiming.Ignored
  238. local IgnoredTeams = Ignored.Teams
  239.  
  240. -- // Check if team is ignored
  241. for _, IgnoredTeam in ipairs(IgnoredTeams) do
  242. -- // Make sure team matches
  243. if (Player.Team == IgnoredTeam.Team and Player.TeamColor == IgnoredTeam.TeamColor) then
  244. return true
  245. end
  246. end
  247.  
  248. -- // Return
  249. return false
  250. end
  251.  
  252. -- // Check if player (and team) is ignored
  253. function Aiming.IsIgnored(Player)
  254. -- // Vars
  255. local Ignored = Aiming.Ignored
  256. local IgnoredPlayers = Ignored.Players
  257.  
  258. -- // Loop
  259. for _, IgnoredPlayer in ipairs(IgnoredPlayers) do
  260. -- // Check if Player Id
  261. if (typeof(IgnoredPlayer) == "number" and Player.UserId == IgnoredPlayer) then
  262. return true
  263. end
  264.  
  265. -- // Normal Player Instance
  266. if (IgnoredPlayer == Player) then
  267. return true
  268. end
  269. end
  270.  
  271. -- // Team check
  272. return Aiming.IsIgnoredTeam(Player)
  273. end
  274.  
  275. -- // Get the Direction, Normal and Material
  276. function Aiming.Raycast(Origin, Destination, UnitMultiplier)
  277. if (typeof(Origin) == "Vector3" and typeof(Destination) == "Vector3") then
  278. -- // Handling
  279. if (not UnitMultiplier) then UnitMultiplier = 1 end
  280.  
  281. -- // Vars
  282. local Direction = (Destination - Origin).Unit * UnitMultiplier
  283. local Result = Raycast(Workspace, Origin, Direction)
  284.  
  285. -- // Make sure we have a result
  286. if (Result) then
  287. local Normal = Result.Normal
  288. local Material = Result.Material
  289.  
  290. return Direction, Normal, Material
  291. end
  292. end
  293.  
  294. -- // Return
  295. return nil
  296. end
  297.  
  298. -- // Get Character
  299. function Aiming.Character(Player)
  300. return Player.Character
  301. end
  302.  
  303. -- // Check Health
  304. function Aiming.CheckHealth(Player)
  305. -- // Get Humanoid
  306. local Character = Aiming.Character(Player)
  307. local Humanoid = FindFirstChildWhichIsA(Character, "Humanoid")
  308.  
  309. -- // Get Health
  310. local Health = (Humanoid and Humanoid.Health or 0)
  311.  
  312. -- //
  313. return Health > 0
  314. end
  315.  
  316. -- // Custom Check Function
  317. function Aiming.CheckCustom(Player)
  318. return true
  319. end
  320.  
  321. -- // Check if silent aim can used
  322. function Aiming.Check()
  323. return (Aiming.Enabled == true and Aiming.Selected ~= LocalPlayer and Aiming.SelectedPart ~= nil)
  324. end
  325. Aiming.checkSilentAim = Aiming.Check
  326.  
  327. -- // Get Closest Target Part
  328. function Aiming.GetClosestTargetPartToCursor(Character)
  329. local TargetParts = Aiming.TargetPart
  330.  
  331. -- // Vars
  332. local ClosestPart = nil
  333. local ClosestPartPosition = nil
  334. local ClosestPartOnScreen = false
  335. local ClosestPartMagnitudeFromMouse = nil
  336. local ShortestDistance = 1/0
  337.  
  338. -- //
  339. local function CheckTargetPart(TargetPart)
  340. -- // Convert string -> Instance
  341. if (typeof(TargetPart) == "string") then
  342. TargetPart = FindFirstChild(Character, TargetPart)
  343. end
  344.  
  345. -- // Make sure we have a target
  346. if not (TargetPart) then
  347. return
  348. end
  349.  
  350. -- // Get the length between Mouse and Target Part (on screen)
  351. local PartPos, onScreen = WorldToViewportPoint(CurrentCamera, TargetPart.Position)
  352. local GuiInset = GetGuiInset(GuiService)
  353. local Magnitude = (Vector2new(PartPos.X, PartPos.Y - GuiInset.Y) - Vector2new(Mouse.X, Mouse.Y)).Magnitude
  354.  
  355. -- //
  356. if (Magnitude < ShortestDistance) then
  357. ClosestPart = TargetPart
  358. ClosestPartPosition = PartPos
  359. ClosestPartOnScreen = onScreen
  360. ClosestPartMagnitudeFromMouse = Magnitude
  361. ShortestDistance = Magnitude
  362. end
  363. end
  364.  
  365. -- // String check
  366. if (typeof(TargetParts) == "string") then
  367. -- // Check if it all
  368. if (TargetParts == "All") then
  369. -- // Loop through character children
  370. for _, v in ipairs(Character:GetChildren()) do
  371. -- // See if it a part
  372. if not (v:IsA("BasePart")) then
  373. continue
  374. end
  375.  
  376. -- // Check it
  377. CheckTargetPart(v)
  378. end
  379. else
  380. -- // Individual
  381. CheckTargetPart(TargetParts)
  382. end
  383. end
  384.  
  385. -- //
  386. if (typeof(TargetParts) == "table") then
  387. -- // Loop through all target parts and check them
  388. for _, TargetPartName in ipairs(TargetParts) do
  389. CheckTargetPart(TargetPartName)
  390. end
  391. end
  392.  
  393. -- //
  394. return ClosestPart, ClosestPartPosition, ClosestPartOnScreen, ClosestPartMagnitudeFromMouse
  395. end
  396.  
  397. -- // Silent Aim Function
  398. function Aiming.GetClosestPlayerToCursor()
  399. -- // Vars
  400. local TargetPart = nil
  401. local ClosestPlayer = nil
  402. local PartPosition = nil
  403. local PartPositionOnScreen = nil
  404. local Chance = CalcChance(Aiming.HitChance)
  405. local ShortestDistance = 1/0
  406.  
  407. -- // Chance
  408. if (not Chance) then
  409. Aiming.Selected = LocalPlayer
  410. Aiming.SelectedPart = nil
  411. Aiming.SelectedPosition = nil
  412. Aiming.SelectedPositionOnScreen = nil
  413.  
  414. return LocalPlayer
  415. end
  416.  
  417. -- // Loop through all players
  418. for _, Player in ipairs(GetPlayers(Players)) do
  419. -- // Get Character
  420. local Character = Aiming.Character(Player)
  421.  
  422. -- // Make sure isn't ignored and Character exists
  423. if (Aiming.IsIgnored(Player) == false and Character) then
  424. -- // Vars
  425. local TargetPartTemp, PartPositionTemp, PartPositionOnScreenTemp, Magnitude = Aiming.GetClosestTargetPartToCursor(Character)
  426.  
  427. -- // Check if part exists, health and custom
  428. if (TargetPartTemp and Aiming.CheckHealth(Player) and Aiming.CheckCustom(Player)) then
  429. -- // Check if is in FOV
  430. if (circle.Radius > Magnitude and Magnitude < ShortestDistance) then
  431. -- // Check if Visible
  432. if (Aiming.VisibleCheck and not Aiming.IsPartVisible(TargetPartTemp, Character)) then continue end
  433.  
  434. -- // Set vars
  435. ClosestPlayer = Player
  436. ShortestDistance = Magnitude
  437. TargetPart = TargetPartTemp
  438. PartPosition = PartPositionTemp
  439. PartPositionOnScreen = PartPositionOnScreenTemp
  440. end
  441. end
  442. end
  443. end
  444.  
  445. -- // End
  446. Aiming.Selected = ClosestPlayer
  447. Aiming.SelectedPart = TargetPart
  448. Aiming.SelectedPosition = PartPosition
  449. Aiming.SelectedPositionOnScreen = PartPositionOnScreen
  450. end
  451.  
  452. -- // Beizer Aim Curves
  453. Aiming.BeizerCurve = {}
  454. do
  455. -- // Vars
  456. local AimingBeizerCurve = Aiming.BeizerCurve
  457.  
  458. -- // Functions
  459. function Aiming.BeizerCurve.Cubic(t, StartPoint, EndPoint, ControlPointA, ControlPointB)
  460. local t1 = (1 - t)
  461.  
  462. local A = t1^3 * StartPoint
  463. local B = 3 * t1^2 * t * ControlPointA
  464. local C = 3 * t1 * t^2 * ControlPointB
  465. local D = t^3 * EndPoint
  466.  
  467. return A + B + C + D
  468. end
  469. local function DoControlPoint(StartPoint, EndPoint, ControlPointA, ControlPointB)
  470. -- //
  471. local Change = (EndPoint - StartPoint)
  472.  
  473. -- // Calculate the control points - relative to the start and end points
  474. local A = StartPoint + (Change * ControlPointA)
  475. local B = StartPoint + (Change * ControlPointB)
  476.  
  477. -- //
  478. return A, B
  479. end
  480.  
  481. -- // Vars
  482. local t = 0
  483. local tThreshold = 0.99995
  484. local StartPoint = Vector2new()
  485. local EndPoint = Vector2new()
  486. local CurvePoints = {
  487. Vector2.new(0.83, 0),
  488. Vector2.new(0.17, 1)
  489. }
  490. local IsActive = false
  491. local Smoothness = 0.0025
  492. local DrawPath = false
  493.  
  494. -- // AimTo with Beizer Curves
  495. function Aiming.BeizerCurve.AimTo(Data)
  496. -- // Vars
  497. local MousePosition = GetMouseLocation(UserInputService)
  498. StartPoint = MousePosition
  499. EndPoint = Data.TargetPosition
  500. Smoothness = Data.Smoothness or Smoothness
  501. CurvePoints = Data.CurvePoints or CurvePoints
  502. DrawPath = Data.DrawPath or DrawPath
  503.  
  504. -- // Set Active
  505. t = 0
  506. IsActive = true
  507. end
  508.  
  509. -- //
  510. RunService:BindToRenderStep("AimLockBeizer", 0, function()
  511. -- // Make sure is active
  512. if (not IsActive) then
  513. return
  514. end
  515.  
  516. -- // Vars
  517. local BeizerCurve = AimingBeizerCurve.Cubic
  518.  
  519. -- // I have to do it this way because a for loop stops before hand
  520. while (t <= 1 and IsActive) do RenderSteppedWait(RenderStepped)
  521. -- // Increment
  522. t = t + Smoothness
  523.  
  524. -- // If past threshold, then do regular smoothing
  525. if (t >= tThreshold) then
  526. -- // Regular smoothing
  527. local clampedT = math.clamp(t, 0, 1)
  528. local New = StartPoint:Lerp(EndPoint, clampedT)
  529.  
  530. -- // Move mouse
  531. mousemoveabs(New.X, New.Y)
  532. else
  533. -- // Work out X, Y based upon the curve
  534. local A, B = DoControlPoint(StartPoint, EndPoint, unpack(CurvePoints))
  535. local Position = BeizerCurve(t, StartPoint, EndPoint, A, B)
  536.  
  537. -- // Create Circle [Debugging]
  538. if (DrawPath) then
  539. local Path = Drawingnew("Circle")
  540. Path.Radius = 2
  541. Path.Color = Color3fromRGB(255, 150, 150)
  542. Path.Visible = true
  543. Path.Position = Position
  544. task.delay(1, function()
  545. Path:Remove()
  546. end)
  547.  
  548. local ControlPointA = Drawingnew("Circle")
  549. ControlPointA.Radius = 5
  550. ControlPointA.Color = Color3fromRGB(225, 150, 255)
  551. ControlPointA.Visible = true
  552. ControlPointA.Position = A
  553. task.delay(1, function()
  554. ControlPointA:Remove()
  555. end)
  556.  
  557. local ControlPointB = Drawingnew("Circle")
  558. ControlPointB.Radius = 5
  559. ControlPointB.Color = Color3fromRGB(225, 150, 255)
  560. ControlPointB.Visible = true
  561. ControlPointB.Position = B
  562. task.delay(1, function()
  563. ControlPointB:Remove()
  564. end)
  565. end
  566.  
  567. -- // Move mouse
  568. mousemoveabs(Position.X, Position.Y)
  569. end
  570. end
  571.  
  572. -- // Reset
  573. IsActive = false
  574. end)
  575. end
  576.  
  577. -- // Heartbeat Function
  578. Heartbeat:Connect(function()
  579. Aiming.UpdateFOV()
  580. Aiming.GetClosestPlayerToCursor()
  581. end)
  582.  
  583. -- //
  584. return Aiming
  585.  
  586. -- // If you want the examples, look at the docs.
Advertisement
Add Comment
Please, Sign In to add comment