Advertisement
Guest User

Untitled

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