Advertisement
captmicro

AngleToTarget and WithinPitchYaw

Jun 15th, 2013
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. local function AngleToTarget(pX,pY,pZ, tX,tY,tZ)
  2.     local deltaX = pX - tX
  3.     local deltaY = pY - tY
  4.     local deltaZ = pZ - tZ
  5.     local hyp = math.sqrt((deltaX*deltaX) + (deltaY*deltaY))
  6.     local angP = math.deg(math.asin(deltaZ / hyp))
  7.     local angY = math.deg(math.atan(deltaY / deltaX))
  8.     local angR = 0
  9.     if (deltaX >= 0) then angY = angY + 180 end
  10.     return angP,angY,angR
  11. end
  12.  
  13. local function WithinPitchYaw(pX,pY,pZ, tX,tY,tZ)
  14.     local p, y, r = AngleToTarget(pX,pY,pZ, tX,tY,tZ)
  15.     local currP = ReadFloat(procHandle, o_EyeP)
  16.     local currY = ReadFloat(procHandle, o_EyeY)
  17.     p = math.NormalizeAngle(p)
  18.     y = math.NormalizeAngle(y)
  19.     currP = math.NormalizeAngle(currP)
  20.     currY = math.NormalizeAngle(currY)
  21.     local diffP = math.abs(math.abs(currP) - math.abs(p))
  22.     local diffY = math.abs(math.abs(currY) - math.abs(y))
  23.     if (diffP > config.aimbot.FOV) or (diffY > config.aimbot.FOV) then return false end
  24.     return true
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement