Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import "API" for IEvent, IEntity, IGraphicsListener, Engine, EventType, Graphics, Vec3, Vec2, OS
- import "CoreTargetResolver" for ITargetResolver, TargetResolver
- class AimSettings {
- construct new() {
- _projectileSpeed = {
- 41: 75,
- 5: 110,
- 32: 110,
- 4: 60,
- 6: 70,
- 121: 60,
- 318: 120,
- 122: 60,
- 221: 120
- }
- _projectileGravity = {
- 41: 0,
- 5: 9.8,
- 32: 0,
- 4: 0,
- 6: 9.8,
- 121: 0,
- 318: 0,
- 122: 0,
- 221: 0
- }
- }
- projectileSpeed { _projectileSpeed }
- projectileGravity { _projectileGravity }
- }
- class FPSCounter {
- construct new() {
- _lastTick = 0
- _fps = 300
- _fps_temp = 0
- }
- fps { _fps }
- handle(time) {
- var currentTick = time * 0.001
- _fps_temp = _fps_temp + 1
- if ((currentTick - _lastTick) > 1) {
- _lastTick = currentTick
- _fps = _fps_temp
- _fps_temp = 0
- }
- }
- }
- class Global {
- static init() {
- if (!__PositionCache) {
- __PositionCache = {}
- }
- if (!__PredictedCache) {
- __PredictedCache = {}
- }
- if(!__AimSettings) {
- __AimSettings = AimSettings.new()
- }
- if (!__FPSCounter) {
- __FPSCounter = FPSCounter.new()
- }
- }
- static HeadPositionCache { __HeadPositionCache }
- static PositionCache { __PositionCache }
- static PredictedCache { __PredictedCache }
- static AimSettings { __AimSettings }
- static FPSCounter { __FPSCounter }
- }
- class AimbotStuff {
- static CalcGravityZ(z, projGravity, projTravelTime) {
- return z + (projGravity * projTravelTime.pow(2) * 0.5)
- }
- static CalcStaticTarget(entAimVec, projectileTravelTime, projectileGravity) {
- entAimVec.z = this.CalcGravityZ(entAimVec.z, projectileGravity, projectileTravelTime)
- return entAimVec
- }
- static CalcMovingTarget(uid, entBasePos, entAimVec, projectileTravelTime, projectileGravity) {
- var targetVelocityVec3 = entBasePos.sub(Global.PositionCache[uid])
- var targetSpeed = Global.PositionCache[uid].distTo(entBasePos) * Global.FPSCounter.fps
- var predictionScale = projectileTravelTime * targetSpeed
- var predictedPos = (entAimVec.add(targetVelocityVec3.normalized().scale(predictionScale)))
- predictedPos.z = this.CalcGravityZ(predictedPos.z, projectileGravity, projectileTravelTime)
- return predictedPos
- }
- }
- class GraphicsEvent is IGraphicsListener {
- static onDraw() {
- Global.FPSCounter.handle(OS.time)
- }
- }
- class PositionsUpdate implements IEvent {
- construct init() {
- this.registerAs(EventType.CoreLogic)
- }
- tick(d){
- var localPlayer = Engine.getLocalPlayer()
- if (localPlayer && Global.AimSettings.projectileSpeed.containsKey(localPlayer.heroId)) {
- var enemies = Engine.getEnemies()
- if (enemies) {
- for(ent in enemies) {
- var uid = ent.uid
- if (ent.health > 0) {
- var localPlayerPos = localPlayer.basePosition
- var basePos = ent.basePosition
- var headPos = ent.headPosition
- if (!Global.PositionCache[uid]) { Global.PositionCache[uid] = basePos }
- var distance = basePos.distTo(localPlayerPos)
- var projectileTravelTime = distance / Global.AimSettings.projectileSpeed[localPlayer.heroId]
- var aimPos = null
- if (Global.PositionCache[uid].x == basePos.x && Global.PositionCache[uid].y == basePos.y && Global.PositionCache[uid].z == basePos.z) {
- aimPos = AimbotStuff.CalcStaticTarget(headPos, projectileTravelTime, Global.AimSettings.projectileGravity[localPlayer.heroId])
- } else {
- aimPos = AimbotStuff.CalcMovingTarget(uid, basePos, headPos, projectileTravelTime, Global.AimSettings.projectileGravity[localPlayer.heroId])
- }
- Global.PredictedCache[uid] = aimPos
- Global.PositionCache[uid] = basePos
- }
- }
- }
- }
- }
- }
- class AimTargetResolver is ITargetResolver {
- static resolve(i, target) {
- var localPlayer = Engine.getLocalPlayer()
- if (!Global.AimSettings.projectileSpeed.containsKey(localPlayer.heroId) || !Global.PredictedCache[target.uid] || (localPlayer.heroId == 122 && localPlayer.healthMax >= 400)) {
- return target.headPosition
- }
- return Global.PredictedCache[target.uid]
- }
- }
- Global.init()
- PositionsUpdate.init()
- Graphics.registerListener(GraphicsEvent)
- TargetResolver.override(AimTargetResolver)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement