Advertisement
captmicro

Unknown

Oct 16th, 2010
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.85 KB | None | 0 0
  1. lolwut = {}
  2. lolwut.AimKey = function() return input.IsKeyDown(KEY_B) end
  3. lolwut.ShootKey = function() return input.IsMouseDown(MOUSE_5) end
  4. lolwut.SpinKey = function() return input.IsKeyDown(KEY_N) end
  5.  
  6. lolwut.lp = LocalPlayer()
  7. lolwut.lastangle = Angle(0,0,0)
  8. lolwut.fakeview = false
  9. lolwut.prefbone = "ValveBiped.Bip01_Head1"
  10.  
  11. lolwut.bpos = function(ent, bone) return ent:GetBonePosition(ent:LookupBone(bone)) end
  12. lolwut.bdist = function(ent, bone) return lolwut.lp:GetShootPos():Distance(lolwut.bpos(bone)) end
  13. lolwut.dist = function(ply) return lolwut.lp:GetShootPos():Distance(ply:GetShootPos()) end
  14. lolwut.closest = function(a, b) return lolwut.dist(a) < lolwut.dist(b) end
  15. lolwut.visible = function(pos,_) return util.QuickTrace(lolwut.lp:GetShootPos(), (pos - lolwut.lp:GetShootPos()), lolwut.lp).HitNonWorld end
  16. lolwut.pvalid = function(ply) return IsValid(ply) and ply:Alive() and ply ~= lolwut.lp end
  17. lolwut.fakeshot = function(func) func("+attack") timer.Simple(0.1, func, "-attack") end
  18. lolwut.keysnotdown = function(keys) for k,v in pairs(keys) do if input.IsKeyDown(v) then return false end end return true end
  19. lolwut.mousesnotdown = function(keys) for k,v in pairs(keys) do if input.IsMouseDown(v) then return false end end return true end
  20. lolwut.notmoving = function() return lolwut.keysnotdown({KEY_W,KEY_A,KEY_S,KEY_D,KEY_SPACE,KEY_LCONTROL,KEY_LSHIFT,KEY_LALT}) and
  21.     lolwut.mousesnotdown({MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE, MOUSE_4, MOUSE_5}) end
  22.  
  23. lolwut.calcview = function(ply, pos, ang, fov)
  24.     if lolwut.AimKey() then
  25.         if input.IsKeyDown(KEY_DELETE) then
  26.             hook.Remove("CalcView", "lolwut1")
  27.         end
  28.        
  29.         local possible = {} for k,v in pairs(player.GetAll()) do
  30.             if lolwut.pvalid(v) --[[and lolwut.visible(lolwut.bpos(v, lolwut.prefbone))]] then table.insert(possible, v) end
  31.         end
  32.         table.sort(possible, lolwut.closest)
  33.         local closest = possible[1]
  34.        
  35.         if IsValid(closest) then
  36.             if (lolwut.lastangle == nil) then lolwut.lastangle = lolwut.lp:EyeAngles() end
  37.             local ang = (lolwut.bpos(closest, lolwut.prefbone) - lolwut.lp:GetShootPos()):Angle()
  38.             lolwut.lp:SetEyeAngles(ang)
  39.             if lolwut.ShootKey() then
  40.                 local x = {origin = pos, angles = lolwut.lastangle, fov = fov}
  41.                 lolwut.fakeshot(RunConsoleCommand)
  42.                 return x
  43.             end lolwut.lastangle = nil
  44.         else lolwut.lastangle = nil end
  45.     elseif lolwut.SpinKey() and lolwut.notmoving() then
  46.         lolwut.fakeview = true
  47.         if (lolwut.lastangle == nil) then lolwut.lastangle = lolwut.lp:EyeAngles() end
  48.         local x = {origin = pos, angles = lolwut.lastangle, fov = fov}
  49.         lolwut.lp:SetEyeAngles(Angle(math.random(-180,180), math.random(-180,180), math.random(-180,180)))
  50.         return x
  51.     else
  52.         if (lolwut.fakeview == true) then
  53.             lolwut.lp:SetEyeAngles(lolwut.lastangle)
  54.             lolwut.fakeview = false
  55.         end
  56.         lolwut.lastangle = nil
  57.     end
  58. end
  59. hook.Add("CalcView", "lolwut1", lolwut.calcview)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement