Advertisement
captmicro

Unknown

Oct 16th, 2010
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.13 KB | None | 0 0
  1. local SetMaterialOverride = SetMaterialOverride
  2. local RunConsoleCommand = RunConsoleCommand
  3. local IsValid = IsValid
  4. local render = render
  5. local Angle = Angle
  6. local input = input
  7. local timer = timer
  8. local table = table
  9. local pairs = pairs
  10. local util = util
  11. local hook = hook
  12. local team = team
  13. local math = math
  14. local cam = cam
  15.  
  16. lolwut = {}
  17. lolwut.LightKey = function() return input.IsKeyDown(KEY_V) end
  18. lolwut.AimKey = function() return input.IsKeyDown(KEY_B) end
  19. lolwut.SpinKey = function() return input.IsKeyDown(KEY_N) end
  20. lolwut.ShootKey = function() return input.IsMouseDown(MOUSE_4) end
  21. lolwut.prefbone = "ValveBiped.Bip01_Head1"
  22. lolwut.maxdist = 65535
  23.  
  24. lolwut.lp = LocalPlayer()
  25. lolwut.lastangle = nil
  26. lolwut.fakeview = false
  27. lolwut.lighton = false
  28. lolwut.trignore = {lolwut.lp,lolwut.lp:GetActiveWeapon()}
  29.  
  30. lolwut.bpos = function(ent, bone) return ent:GetBonePosition(ent:LookupBone(bone)) end
  31. lolwut.bdist = function(ent, bone) return lolwut.lp:GetShootPos():Distance(lolwut.bpos(ent,bone)) end
  32. lolwut.dist = function(ply) return lolwut.lp:GetShootPos():Distance(ply:GetShootPos()) end
  33. lolwut.etre = function(ply) return ply:GetEyeTrace().Entity end
  34.  
  35. lolwut.closest = function(a, b) return lolwut.bdist(a, lolwut.prefbone) < lolwut.bdist(b, lolwut.prefbone) end
  36. lolwut.quickest = function(a, b) return (a.Health and a:Health() or 0) < (b.Health and b:Health() or 0) end
  37. lolwut.looking = function(a, b)
  38.     if (lolwut.etre(a) == lolwut.lp and lolwut.etre(b) ~= lolwut.lp) then return a
  39.     elseif (lolwut.etre(a) ~= lolwut.lp and lolwut.etre(b) == lolwut.lp) then return b
  40.     else return table.Random({a,b}) end
  41. end
  42.  
  43. lolwut.visible = function(pos,ent)
  44.     local tr = util.TraceLine({start=lolwut.lp:GetShootPos(),
  45.         endpos=lolwut.lp:GetShootPos()+((pos - lolwut.lp:GetShootPos())*lolwut.maxdist),
  46.         ilter=lolwut.trignore, mask=MASK_SHOT})
  47.     return tr.HitNonWorld and tr.Hit and IsValid(tr.Entity) and ((ent ~= nil) and (tr.Entity == ent) or true)
  48. end
  49. lolwut.pvalid = function(ply) return IsValid(ply) and ply:Alive() and ply ~= lolwut.lp and ply:Team() ~= lolwut.lp:Team() end
  50. lolwut.esppvalid = function(ply) return IsValid(ply) and ply:Alive() and ply ~= lolwut.lp end
  51. lolwut.keysnotdown = function(keys) for k,v in pairs(keys) do if input.IsKeyDown(v) then return false end end return true end
  52. lolwut.mousesnotdown = function(keys) for k,v in pairs(keys) do if input.IsMouseDown(v) then return false end end return true end
  53. lolwut.notmoving = function() return lolwut.keysnotdown({KEY_W,KEY_A,KEY_S,KEY_D,KEY_SPACE,KEY_LCONTROL,KEY_LSHIFT,KEY_LALT}) and
  54.     lolwut.mousesnotdown({MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE, MOUSE_4, MOUSE_5}) end
  55. lolwut.fakeshot = function(func)
  56.     func("+attack")
  57.     local delay = lolwut.lp:GetActiveWeapon().PrimaryDelay or nil
  58.     if (delay == nil) then delay = (lolwut.lp:GetActiveWeapon().Primary and lolwut.lp:GetActiveWeapon().Primary.Delay or 0.1) end
  59.     timer.Simple(delay, func, "-attack")
  60. end
  61. lolwut.CrossbowFix = function(aimpos, target)
  62.     if (lolwut.lp:GetActiveWeapon().GetPrintName ~= nil) then
  63.         if (lolwut.lp:GetActiveWeapon():GetPrintName() == "#HL2_Crossbow") then
  64.             local angp = math.sin((aimpos - lolwut.lp:GetShootPos()):Angle().p)
  65.             aimpos = aimpos + Vector(0,0, (lolwut.dist(target) / 244.286) + angp)
  66.             return aimpos
  67.         end
  68.     end
  69.     return aimpos
  70. end
  71. lolwut.fakelight = function(ent, pos, color, size, brightness)
  72.     local l = DynamicLight(ent:EntIndex())
  73.     if l then
  74.         l.Pos = pos
  75.         l.r = color.r
  76.         l.g = color.g
  77.         l.b = color.b
  78.         l.Brightness = brightness
  79.         l.Decay = size * 5
  80.         l.Size = size
  81.         l.DieTime = CurTime() + 1
  82.     end
  83. end
  84.  
  85. lolwut.calcview = function(ply, pos, ang, fov)
  86.     if lolwut.LightKey() then lolwut.lighton = not lolwut.lighton end
  87.     if lolwut.lighton then
  88.         local lpos = lolwut.lp:GetEyeTrace().HitPos
  89.         lolwut.fakelight(lolwut.lp, lpos, Color(255,255,255), 64*2, 6)
  90.     end
  91.    
  92.     if lolwut.AimKey() then
  93.         if input.IsKeyDown(KEY_DELETE) then
  94.             hook.Remove("CalcView", "lolwut1")
  95.             hook.Remove("PostDrawOpaqueRenderables", "lolwut2")
  96.         end
  97.        
  98.         local possible = {} for k,v in pairs(player.GetAll()) do
  99.             if lolwut.pvalid(v) and lolwut.visible(lolwut.GetAimPos(v),v) then table.insert(possible, v) end
  100.         end
  101.         table.sort(possible, lolwut.closest)
  102.         if input.IsMouseDown(MOUSE_5) then
  103.             table.sort(possible, lolwut.quickest)
  104.         end
  105.         local closest = possible[1]
  106.        
  107.         if IsValid(closest) then
  108.             if (lolwut.lastangle == nil) then lolwut.lastangle = lolwut.lp:EyeAngles() end
  109.             local aimpos = lolwut.CrossbowFix(lolwut.GetAimPos(closest), closest)
  110.             local ang = (aimpos - lolwut.lp:GetShootPos()):Angle()
  111.             lolwut.lp:SetEyeAngles(ang)
  112.             if lolwut.ShootKey() then
  113.                 local x = {origin = pos, angles = lolwut.lastangle, fov = fov}
  114.                 lolwut.fakeshot(RunConsoleCommand)
  115.                 return x
  116.             else lolwut.lastangle = nil end
  117.         else lolwut.lastangle = nil end
  118.     elseif lolwut.SpinKey() and lolwut.notmoving() then
  119.         lolwut.fakeview = true
  120.         if (lolwut.lastangle == nil) then lolwut.lastangle = lolwut.lp:EyeAngles() end
  121.         local x = {origin = pos, angles = lolwut.lastangle, fov = fov}
  122.         lolwut.lp:SetEyeAngles(Angle(math.random(-180,180), math.random(-180,180), math.random(-180,180)))
  123.         return x
  124.     else
  125.         if (lolwut.fakeview == true) then
  126.             lolwut.lp:SetEyeAngles(lolwut.lastangle)
  127.             lolwut.fakeview = false
  128.         end
  129.         lolwut.lastangle = nil
  130.     end
  131. end
  132. hook.Add("CalcView", "lolwut1", lolwut.calcview)
  133.  
  134. lolwut.getcm = function(ent)
  135.     if ent:IsPlayer() then
  136.         local tc = team.GetColor(ent:Team())
  137.         if (tc.a < 50) then return 1, 1, 1 end
  138.         return tc.r/255, tc.g/255, tc.b/222
  139.     else return 1, 0, 0 end
  140. end
  141.  
  142. lolwut.matwhite = CreateMaterial("WhiteMaterial", "VertexLitGeneric", {
  143.     ['$basetexture'] = 'color/white', ['$vertexalpha'] = '1', ['$model'] = '1'
  144. });
  145.  
  146. lolwut.pdor = function()
  147.     render.ClearStencil()
  148.     render.SetStencilEnable(true)
  149.     render.SetStencilFailOperation(STENCILOPERATION_KEEP)
  150.     render.SetStencilPassOperation(STENCILOPERATION_KEEP)
  151.     render.SetStencilZFailOperation(STENCILOPERATION_REPLACE)
  152.     render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_ALWAYS)
  153.    
  154.     render.SetStencilReferenceValue(1)
  155.     render.SetBlend(0.9) --CLOSE ENOUGH
  156.         for k,v in pairs(player.GetAll()) do
  157.             if lolwut.esppvalid(v) then
  158.                 local r,g,b = lolwut.getcm(v)
  159.                 render.SetColorModulation(r or 1,g or 0,b or 0)
  160.                     SetMaterialOverride(lolwut.matwhite)
  161.                         v:DrawModel()
  162.                     SetMaterialOverride()
  163.                 render.SetColorModulation(1,1,1)
  164.             end
  165.         end
  166.     render.SetBlend(1)
  167.    
  168.     render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_EQUAL)
  169.     render.SuppressEngineLighting(true)
  170.         cam.IgnoreZ(true)
  171.             for k,v in pairs(player.GetAll()) do
  172.                 if lolwut.esppvalid(v) then
  173.                     local r,g,b = lolwut.getcm(v)
  174.                     render.SetColorModulation(r or 1,g or 0,b or 0)
  175.                         SetMaterialOverride(lolwut.matwhite)
  176.                             v:DrawModel()
  177.                         SetMaterialOverride()
  178.                     render.SetColorModulation(1,1,1)
  179.                 end
  180.             end
  181.         cam.IgnoreZ(false)
  182.     render.SuppressEngineLighting(false)
  183.     render.SetStencilEnable(false)
  184. end
  185. hook.Add("PostDrawOpaqueRenderables", "lolwut2", lolwut.pdor)
  186.  
  187. lolwut.GetAimPos = function(ent)
  188.     local exp = string.Explode('/', string.lower(ent:GetModel()))
  189.     if (#exp ~= 3) then
  190.         if ent:IsPlayer() or ent:IsNPC() then
  191.             return lolwut.bpos(ent, lolwut.bones['default'])
  192.         else
  193.             return ent:LocalToWorld(ent:OBBCenter())
  194.         end
  195.     end
  196.     if (lolwut.bones['mdl:'..exp[3]] ~= nil) then
  197.         return lolwut.bpos(ent, lolwut.bones['mdl:'..exp[3]])
  198.     elseif (lolwut.bones['folder:'..exp[2]] ~= nil) then
  199.         return lolwut.bpos(ent, lolwut.bones['folder:'..exp[2]])
  200.     else
  201.         return lolwut.bpos(ent, lolwut.bones['default'])
  202.     end
  203. end
  204.  
  205. lolwut.bones = {
  206.     ['default'] = "ValveBiped.Bip01_Head1",
  207.     ['folder:zombie'] = "ValveBiped.HC_Body_Bone",
  208.     ['mdl:fast.mdl'] = "ValveBiped.HC_BodyCube",
  209.     ['mdl:poison.mdl'] = "ValveBiped.Headcrab_Cube1",
  210.     ['mdl:manhack.mdl'] = "Manhack.MH_Control",
  211.     ['mdl:combine_scanner.mdl'] = "Scanner.Body",
  212.     ['mdl:barnacle.mdl'] = "Barnacle.innards",
  213.     ['mdl:combine_helicopter.mdl'] = "Chopper.Body",
  214.     ['mdl:combine_strider.mdl'] = "Combine_Strider.Body_Bone",
  215.     ['mdl:combine_dropship.mdl'] = "D_ship.Pelvis",
  216.     ['mdl:gunship.mdl'] = "Gunship.Body",
  217.     ['mdl:pigeon.mdl'] = "Crow.Head"
  218. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement