Advertisement
Guest User

Untitled

a guest
May 19th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.62 KB | None | 0 0
  1. import "API" for IEvent, IEntity, IGraphicsListener, Engine, EventType, Graphics, Vec3, Vec2, OS
  2. import "CoreTargetResolver" for ITargetResolver, TargetResolver
  3. import "CoreAimbot" for CoreAimbot
  4. import "CoreSmoothing" for ISmoothingSource
  5.  
  6. class QuaternionSlerpSmoothingSource implements ISmoothingSource {
  7. construct new(speed) {_speed = speed / 100}
  8. smoothAngles(t, v1, v2) {
  9. return v1.qslerp(v2, _speed)
  10. }
  11. }
  12.  
  13. var primaryAimbot = CoreAimbot.getPrimaryInstance()
  14. if(primaryAimbot) {
  15. primaryAimbot.smoothingSource = QuaternionSlerpSmoothingSource.new(10)
  16. }
  17.  
  18. class AimSettings {
  19. construct new() {
  20. _projectileSpeed = {
  21. 41: 75,
  22. 5: 110,
  23. 32: 110,
  24. 4: 60,
  25. 6: 70,
  26. 121: 60,
  27. 318: 120,
  28. 122: 60,
  29. 221: 120
  30. }
  31. _projectileGravity = {
  32. 41: 0,
  33. 5: 9.8,
  34. 32: 0,
  35. 4: 0,
  36. 6: 9.8,
  37. 121: 0,
  38. 318: 0,
  39. 122: 0,
  40. 221: 0
  41. }
  42. }
  43. projectileSpeed { _projectileSpeed }
  44. projectileGravity { _projectileGravity }
  45. }
  46.  
  47. class FPSCounter {
  48. construct new() {
  49. _lastTick = 0
  50. _fps = 300
  51. _fps_temp = 0
  52. }
  53. fps { _fps }
  54. handle(time) {
  55. var currentTick = time * 0.001
  56. _fps_temp = _fps_temp + 1
  57. if ((currentTick - _lastTick) > 1) {
  58. _lastTick = currentTick
  59. _fps = _fps_temp
  60. _fps_temp = 0
  61. }
  62.  
  63. }
  64. }
  65.  
  66. class Global {
  67. static init() {
  68. if (!__PositionCache) {
  69. __PositionCache = {}
  70. }
  71. if (!__PredictedCache) {
  72. __PredictedCache = {}
  73. }
  74. if(!__AimSettings) {
  75. __AimSettings = AimSettings.new()
  76. }
  77. if (!__FPSCounter) {
  78. __FPSCounter = FPSCounter.new()
  79. }
  80. }
  81. static HeadPositionCache { __HeadPositionCache }
  82. static PositionCache { __PositionCache }
  83. static PredictedCache { __PredictedCache }
  84. static AimSettings { __AimSettings }
  85. static FPSCounter { __FPSCounter }
  86. }
  87.  
  88. class AimbotStuff {
  89. static CalcGravityZ(z, projGravity, projTravelTime) {
  90. return z + (projGravity * projTravelTime.pow(2) * 0.5)
  91. }
  92. static CalcStaticTarget(entAimVec, projectileTravelTime, projectileGravity) {
  93. entAimVec.z = this.CalcGravityZ(entAimVec.z, projectileGravity, projectileTravelTime)
  94. return entAimVec
  95. }
  96. static CalcMovingTarget(uid, entBasePos, entAimVec, projectileTravelTime, projectileGravity) {
  97. var targetVelocityVec3 = entBasePos.sub(Global.PositionCache[uid])
  98. var targetSpeed = Global.PositionCache[uid].distTo(entBasePos) * Global.FPSCounter.fps
  99. var predictionScale = projectileTravelTime * targetSpeed
  100. var predictedPos = (entAimVec.add(targetVelocityVec3.normalized().scale(predictionScale)))
  101. predictedPos.z = this.CalcGravityZ(predictedPos.z, projectileGravity, projectileTravelTime)
  102. return predictedPos
  103. }
  104.  
  105. }
  106.  
  107. class GraphicsEvent is IGraphicsListener {
  108. static onDraw() {
  109. Global.FPSCounter.handle(OS.time)
  110. }
  111. }
  112.  
  113. class PositionsUpdate implements IEvent {
  114. construct init() {
  115. this.registerAs(EventType.CoreLogic)
  116. }
  117. tick(d){
  118.  
  119. var localPlayer = Engine.getLocalPlayer()
  120. if (localPlayer && Global.AimSettings.projectileSpeed.containsKey(localPlayer.heroId)) {
  121.  
  122. var enemies = Engine.getEnemies()
  123. if (enemies) {
  124. for(ent in enemies) {
  125. var uid = ent.uid
  126. if (ent.health > 0) {
  127. var localPlayerPos = localPlayer.basePosition
  128. var basePos = ent.basePosition
  129. var headPos = ent.headPosition
  130. if (!Global.PositionCache[uid]) { Global.PositionCache[uid] = basePos }
  131.  
  132. var distance = basePos.distTo(localPlayerPos)
  133. var projectileTravelTime = distance / Global.AimSettings.projectileSpeed[localPlayer.heroId]
  134. var aimPos = null
  135. if (Global.PositionCache[uid].x == basePos.x && Global.PositionCache[uid].y == basePos.y && Global.PositionCache[uid].z == basePos.z) {
  136. aimPos = AimbotStuff.CalcStaticTarget(headPos, projectileTravelTime, Global.AimSettings.projectileGravity[localPlayer.heroId])
  137. } else {
  138. aimPos = AimbotStuff.CalcMovingTarget(uid, basePos, headPos, projectileTravelTime, Global.AimSettings.projectileGravity[localPlayer.heroId])
  139. }
  140. Global.PredictedCache[uid] = aimPos
  141. Global.PositionCache[uid] = basePos
  142. }
  143. }
  144. }
  145. }
  146. }
  147. }
  148.  
  149. class AimTargetResolver is ITargetResolver {
  150. static resolve(i, target) {
  151. var localPlayer = Engine.getLocalPlayer()
  152.  
  153. if (!Global.AimSettings.projectileSpeed.containsKey(localPlayer.heroId) || !Global.PredictedCache[target.uid] || (localPlayer.heroId == 122 && localPlayer.healthMax >= 400)) {
  154.  
  155. return target.headPosition
  156. }
  157.  
  158. return Global.PredictedCache[target.uid]
  159.  
  160. }
  161.  
  162. }
  163.  
  164. Global.init()
  165. PositionsUpdate.init()
  166. Graphics.registerListener(GraphicsEvent)
  167. TargetResolver.override(AimTargetResolver)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement