Advertisement
captmicro

backup dat cheat in case i need it??!?!

Jan 12th, 2012
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.13 KB | None | 0 0
  1. disco = {}
  2. disco.lerp = 0.25
  3. disco.auto = false
  4.  
  5. local HAX = {}
  6. oldGM = oldGM or {}
  7.  
  8. local aimbotWhite = CreateMaterial( "aimbotWhiteMat", "UnlitGeneric", {
  9.     ["$basetexture"] = "color/white",
  10. } )
  11.  
  12. function VectorToLPCameraScreen( vDir, iScreenW, iScreenH, angCamRot, fFoV )
  13.     local d = 4 * iScreenH / ( 6 * math.tan( 0.5 * fFoV ) )
  14.     local fdp = angCamRot:Forward():Dot( vDir );
  15.  
  16.     if fdp == 0 then
  17.         return 0, 0, -1
  18.     end
  19.  
  20.     local vProj = ( d / fdp ) * vDir;
  21.  
  22.     local x = 0.5 * iScreenW + angCamRot:Right():Dot( vProj )
  23.     local y = 0.5 * iScreenH - angCamRot:Up():Dot( vProj )
  24.  
  25.     local iVisibility
  26.     if fdp < 0 then
  27.         iVisibility = -1
  28.     elseif x < 0 || x > iScreenW || y < 0 || y > iScreenH then
  29.         iVisibility = 0
  30.     else
  31.         iVisibility = 1
  32.     end
  33.  
  34.     return x, y, iVisibility
  35. end
  36.  
  37. local zoom = 0
  38. function ToScreen( Origin )
  39.     return VectorToLPCameraScreen( ( Origin - EyePos() ):GetNormal(), ScrW(), ScrH(), EyeAngles(), math.rad( LocalPlayer():GetFOV()-zoom ) )
  40. end
  41.  
  42. /*function HAX:CalcView( pl, pos, angles, fov )
  43.  
  44.     if HOOKING then return end
  45.     HOOKING = true
  46.     local view = hook.Call( "CalcView", GAMEMODE, pl, pos, angles, fov )
  47.     HOOKING = false
  48.  
  49.     view.fov = pl:GetFOV() - zoom
  50.    
  51.     return view
  52. end*/
  53.  
  54. function HAX:AdjustMouseSensitivity( default )
  55.     return math.Clamp( ((90-zoom)/60), 0.01, 1 )
  56. end
  57.  
  58. local GRENADE_TIMER = 3
  59. function HAX:OnEntityCreated( ent )
  60.     if not ValidEntity( ent ) then return end
  61.     if ent:GetClass() == "npc_grenade_frag" then
  62.         ent.Timer = CurTime() + GRENADE_TIMER
  63.     end
  64. end
  65.  
  66. local playersToDraw = {}
  67. local melons = {}
  68. function HAX:Think()
  69.  
  70.     --playersToDraw = ents.FindByClass( "npc_*" )
  71.    
  72.     for _,pl in pairs( playersToDraw ) do
  73.         if not ValidEntity( pl ) or pl:IsEffectActive( EF_NODRAW ) then continue end
  74.         melons[pl] = melons[pl] or ClientsideModel( "models/props_junk/watermelon01.mdl" )
  75.     end
  76.    
  77.     if input.IsKeyDown( KEY_LALT ) then
  78.         zoom = zoom + 300*FrameTime()
  79.         if zoom > 60 then zoom = 60 end
  80.     else
  81.         zoom = zoom - 300*FrameTime()
  82.         if zoom < 0 then zoom = 0 end
  83.     end
  84.    
  85. end
  86.  
  87. local tblNormalConeWepBases = {
  88.         ["weapon_cs_base"] = true
  89. }
  90.  
  91. local function GetCone(wep)
  92.         local cone = wep.Cone
  93.         if not cone and type(wep.Primary) == "table" and type(wep.Primary.Cone) == "number" then
  94.                 cone = wep.Primary.Cone
  95.         end
  96.         if not cone then cone = 0 end
  97.         --CHeck if wep is HL2 then return corresponding cone
  98.         if type(wep.Base) == "string" and tblNormalConeWepBases[wep.Base] then return cone end
  99.         if wep:GetClass() == "ose_turretcontroller" then return 0 end
  100.         --if ID_GAMETYPE ~= -1 then return GameTypes[ID_GAMETYPE].getcone(wep,cone) end
  101.         return cone or 0
  102. end
  103.  
  104. local closest
  105. local lastang = Angle(0,0,0)
  106. function HAX:CreateMove( cmd )
  107.  
  108.     if input.WasMousePressed( MOUSE_MIDDLE ) and not disco.auto then
  109.    
  110.         if not ValidEntity( closest ) or closest:IsEffectActive( EF_NODRAW ) then
  111.             local lastDistance = 1024
  112.             local lastPos = nil
  113.             for _,pl in pairs( playersToDraw ) do
  114.                 if not ValidEntity( pl ) or pl:IsEffectActive( EF_NODRAW ) then continue end
  115.                 local head = pl:LookupBone("ValveBiped.Bip01_Head1")
  116.                 local pos, ang = pl:GetBonePosition( head )
  117.                 local x, y = VectorToLPCameraScreen( ( pos - EyePos() ):GetNormal(), ScrW(), ScrH(), EyeAngles(), math.rad( LocalPlayer():GetFOV() ) )
  118.                 if x < 0 or y < 0 or x > ScrW() or y > ScrH() then continue end
  119.                 local dist = math.Distance( x, y, ScrW()/2, ScrH()/2 )
  120.                 if dist < lastDistance then
  121.                     closest = pl
  122.                     lastDistance = dist
  123.                     lastPos = pos
  124.                 end
  125.             end
  126.         end
  127.        
  128.     end
  129.    
  130.     if input.IsMouseDown( MOUSE_MIDDLE ) then
  131.        
  132.         if disco.auto and ( not ValidEntity( closest ) or closest:IsEffectActive( EF_NODRAW ) ) then
  133.             local lastDistance = 1024
  134.             local lastPos = nil
  135.             for _,pl in pairs( playersToDraw ) do
  136.                 if not ValidEntity( pl ) or pl:IsEffectActive( EF_NODRAW ) then continue end
  137.                 local head = pl:LookupBone("ValveBiped.Bip01_Head1")
  138.                 local pos, ang = pl:GetBonePosition( head )
  139.                 local x, y = VectorToLPCameraScreen( ( pos - EyePos() ):GetNormal(), ScrW(), ScrH(), EyeAngles(), math.rad( LocalPlayer():GetFOV() ) )
  140.                 if x < 0 or y < 0 or x > ScrW() or y > ScrH() then continue end
  141.                 local dist = math.Distance( x, y, ScrW()/2, ScrH()/2 )
  142.                 if dist < lastDistance then
  143.                     closest = pl
  144.                     lastDistance = dist
  145.                     lastPos = pos
  146.                 end
  147.             end
  148.         end
  149.        
  150.         if ValidEntity( closest ) and not closest:IsEffectActive( EF_NODRAW )  then
  151.             local head = closest:LookupBone("ValveBiped.Bip01_Head1")
  152.             local pos, ang = closest:GetBonePosition( head )
  153.             lastang = LerpAngle(disco.lerp,lastang,( pos - ( EyePos() + LocalPlayer():GetVelocity()*FrameTime() ) ):Angle() )
  154.             cmd:SetViewAngles( lastang )
  155.         end
  156.        
  157.     else
  158.         lastang = cmd:GetViewAngles()
  159.         closest = nil
  160.     end
  161.  
  162.     /*if cmd:GetButtons() & IN_ATTACK > 0 then
  163.         local cmd_id = sthp_command_number(cmd)
  164.         local seed = sthp_MD5_PseudoRandom(cmd_id)
  165.         if cmd_id ~= 0 then
  166.             MsgN( seed )
  167.             local wep = LocalPlayer():GetActiveWeapon()
  168.             local vecCone = Vector(0,0,0)
  169.             if wep and wep:IsValid() and type(wep.Initialize) == "function" then
  170.                 local valCone = GetCone( wep )
  171.                 if type(valCone) == "number" then
  172.                         vecCone = Vector(-valCone,-valCone,-valCone)
  173.                 elseif type(valCone) == "Vector" then
  174.                         vecCone = -1*valCone
  175.                 end
  176.             end
  177.             --local new_ang = sthp_manipulate_shot( seed or 0, LocalPlayer():GetAimVector(), vecCone ):Angle()
  178.             local new_ang = sthp_PredictSpread( seed or 0, vecCone, ( cmd:GetViewAngles():Right() ), ( cmd:GetViewAngles():Up() ) ):Angle()
  179.             new_ang.p = math.NormalizeAngle( new_ang.p )
  180.             new_ang.y = math.NormalizeAngle( new_ang.y )
  181.             cmd:SetViewAngles( new_ang )
  182.         end
  183.     end*/
  184.    
  185. end
  186.  
  187. local drawing = false
  188. function HAX:PreDrawOpaqueRenderables()
  189.  
  190.     if drawing then return nil end
  191.     playersToDraw = ents.FindByClass( "npc_*" )
  192.  
  193. end
  194.  
  195. function HAX:PrePlayerDraw( pl )
  196.  
  197.     if drawing then return nil end
  198.     table.insert( playersToDraw, pl )
  199.  
  200. end
  201.  
  202. function HAX:PostPlayerDraw( pl )
  203.  
  204.     if drawing then return nil end
  205.     table.insert( playersToDraw, pl )
  206.  
  207. end
  208.  
  209. local tooFar = {}
  210. function HAX:PostDrawTranslucentRenderables()
  211.  
  212.     if drawing then return end
  213.    
  214.     drawing = true
  215.     cam.Start3D( EyePos(), EyeAngles() )
  216.     render.ClearStencil()
  217.     render.SetStencilEnable( true )
  218.     render.SetStencilFailOperation( STENCILOPERATION_REPLACE )
  219.     render.SetStencilZFailOperation( STENCILOPERATION_REPLACE )
  220.     render.SetStencilPassOperation( STENCILOPERATION_KEEP )
  221.     render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_ALWAYS )
  222.     render.SetStencilReferenceValue( 1 )
  223.     for _,pl in pairs( playersToDraw ) do
  224.         if not ValidEntity( pl ) or pl:IsEffectActive( EF_NODRAW ) then continue end
  225.         render.SuppressEngineLighting( true )
  226.         render.SetBlend( 0.3 )
  227.         pl:DrawModel()
  228.         render.SetBlend( 1)
  229.         render.SuppressEngineLighting( false )
  230.     end
  231.     render.SetStencilFailOperation( STENCILOPERATION_KEEP )
  232.     render.SetStencilZFailOperation( STENCILOPERATION_REPLACE )
  233.     render.SetStencilPassOperation( STENCILOPERATION_REPLACE )
  234.     render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_ALWAYS )
  235.     render.SetStencilReferenceValue( 2 )
  236.     for _,pl in pairs( playersToDraw ) do
  237.         if not ValidEntity( pl ) or pl:IsEffectActive( EF_NODRAW ) then continue end
  238.         render.SuppressEngineLighting( true )
  239.         render.SetBlend( 0.3 )
  240.         melon = melons[ pl ]
  241.         if not melon then continue end
  242.         local head = pl:LookupBone("ValveBiped.Bip01_Head1")
  243.         local pos, ang = pl:GetBonePosition( head )
  244.         melon:SetPos( pos+ang:Forward()*2 )
  245.         melon:SetAngles( ang )
  246.         melon:SetColor( 0,0,0,0 )
  247.         melon:SetModelScale( Vector( 0.6, 0.6, 0.6 ) )
  248.         melon:DrawModel()
  249.         render.SetBlend( 1)
  250.         render.SuppressEngineLighting( false )
  251.     end
  252.    
  253.     render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_EQUAL )
  254.     render.SetStencilPassOperation( STENCILOPERATION_REPLACE )
  255.     render.SetStencilReferenceValue( 1 )
  256.  
  257.     render.SetBlend( 0.35 )
  258.     render.SetColorModulation( 1, 0, 0 )
  259.     cam.IgnoreZ( true )
  260.     SetMaterialOverride( aimbotWhite )
  261.     for _,pl in pairs( playersToDraw ) do
  262.         if not ValidEntity( pl ) or pl:IsEffectActive( EF_NODRAW ) then continue end
  263.         local pos = pl:LocalToWorld(Vector(0,0,pl:OBBMaxs().z))
  264.         local dist = pos:Distance( EyePos() )
  265.         render.SetBlend( dist/1500 )
  266.         pl:DrawModel()
  267.     end
  268.     render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_EQUAL )
  269.     render.SetStencilPassOperation( STENCILOPERATION_REPLACE )
  270.     render.SetStencilReferenceValue( 2 )
  271.     render.SetBlend( 0.25 )
  272.     render.SetColorModulation( 0, 1, 0 )
  273.     for _,pl in pairs( playersToDraw ) do
  274.         if not ValidEntity( pl ) or pl:IsEffectActive( EF_NODRAW ) then continue end
  275.         melon = melons[ pl ]
  276.         if not melon then continue end
  277.         melon:DrawModel()
  278.     end
  279.     render.SetColorModulation( 1, 1, 1 )
  280.     SetMaterialOverride( )
  281.     cam.IgnoreZ( false )
  282.     render.SetBlend( 1)
  283.  
  284.     render.SetStencilEnable( false )
  285.  
  286.     cam.End3D()
  287.    
  288.     tooFar = {}
  289.     for _,pl in pairs( playersToDraw ) do
  290.         if not ValidEntity( pl ) or pl:IsEffectActive( EF_NODRAW ) then continue end
  291.         local ang = EyeAngles()
  292.         ang:RotateAroundAxis( ang:Forward(), 90 )
  293.         ang:RotateAroundAxis( ang:Right(), 90 )
  294.        
  295.         cam.IgnoreZ( true )
  296.         local pos = pl:LocalToWorld(Vector(0,0,pl:OBBMaxs().z+10))
  297.         local dist = pos:Distance( EyePos() )
  298.         local text = pl:GetClass()
  299.         if pl:IsPlayer() then
  300.             if string.len( pl:Nick() ) > 10 then
  301.                 text = string.sub( pl:Nick(), 1, 10 ).."..".." ("..pl:Health()..")"
  302.             else
  303.                 text = pl:Nick().." ("..pl:Health()..")"
  304.             end
  305.         elseif pl.Timer then
  306.             text = text .. " (" .. tostring( math.floor(( pl.Timer - CurTime() )*10) ) .. ")"
  307.         end
  308.         if dist < 200 then
  309.             cam.Start3D2D( pos, ang, 0.5 )
  310.                 draw.DrawText( text, "DefaultFixedOutline", 2, 2, Color( 255, 255, 255, 200-(dist/10) ), TEXT_ALIGN_CENTER )
  311.             cam.End3D2D()
  312.         else
  313.             cam.Start3D2D( pos, ang, dist/350 )
  314.                 draw.DrawText( text, "DefaultFixedOutline", 2, 2, Color( 255, 255, 255, 200-(dist/10) ), TEXT_ALIGN_CENTER )
  315.             cam.End3D2D()
  316.         end
  317.         cam.IgnoreZ( false )
  318.     end
  319.     drawing = false
  320.    
  321. end
  322.  
  323. function HAX:HUDPaint()
  324.  
  325.     local i = 1
  326.     for _,pl in pairs( player.GetAll() ) do
  327.         if pl:GetObserverTarget() != LocalPlayer() then continue end
  328.         draw.DrawText( pl:Nick(), "DefaultFixedOutline", 5, 5+i*10, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
  329.         i = i + 1
  330.     end
  331.  
  332.     if ValidEntity( LocalPlayer() ) and ValidEntity( LocalPlayer():GetActiveWeapon() ) and LocalPlayer():GetActiveWeapon():GetClass() == "weapon_frag" then
  333.         local pos = EyePos()+EyeAngles():Forward()*18+EyeAngles():Right()*8
  334.         local forward = EyeAngles():Forward()
  335.         forward.z = forward.z + 0.1;
  336.         local lastPos = pos
  337.         local vel = LocalPlayer():GetVelocity() + forward * 1520
  338.         local accel = 9.8
  339.         for time=0,50 do
  340.             local cur_vel = vel - Vector( 0,0,600 )*(time/15)
  341.             local next_pos = pos + cur_vel*(time/15)
  342.             local trRes = util.TraceHull( { start = lastPos, endpos = next_pos, filter = LocalPlayer(), mins = -Vector( 2.8,2.8,2.8 ), maxs = Vector( 2.8,2.8,2.8 ) } )
  343.             local x, y = ToScreen( lastPos )
  344.             local x2, y2 = ToScreen( trRes.HitPos )
  345.             lastPos = next_pos
  346.             local wallTrace = util.TraceLine( { start = EyePos(), endpos = lastPos, filter = LocalPlayer() } )
  347.             local wallTrace2 = util.TraceLine( { start = EyePos(), endpos = trRes.HitPos, filter = LocalPlayer() } )
  348.             if wallTrace.Hit or wallTrace2.Hit then
  349.                 surface.SetDrawColor( 255, 0, 0, 255 - time*10 )
  350.             else
  351.                 surface.SetDrawColor( 255, 255, 255, 255 - time*10 )
  352.             end
  353.             surface.DrawLine( x, y, x2, y2 )
  354.             if trRes.Hit then break end
  355.         end
  356.        
  357.         local pos = EyePos()+EyeAngles():Forward()*18+EyeAngles():Right()*8-EyeAngles():Up()*8
  358.         local forward = EyeAngles():Forward()
  359.         forward.z = forward.z + 0.1;
  360.         local lastPos = pos
  361.         local vel = LocalPlayer():GetVelocity() + forward * 400 + Vector( 0,0,50 )
  362.         local accel = 9.8
  363.         for time=0,50 do
  364.             local cur_vel = vel - Vector( 0,0,600 )*(time/15)
  365.             local next_pos = pos + cur_vel*(time/15)
  366.             local trRes = util.TraceHull( { start = lastPos, endpos = next_pos, filter = LocalPlayer(), mins = -Vector( 2.8,2.8,2.8 ), maxs = Vector( 2.8,2.8,2.8 ) } )
  367.             local x, y = ToScreen( lastPos )
  368.             local x2, y2 = ToScreen( trRes.HitPos )
  369.             lastPos = next_pos
  370.             local wallTrace = util.TraceLine( { start = EyePos(), endpos = lastPos, filter = LocalPlayer() } )
  371.             local wallTrace2 = util.TraceLine( { start = EyePos(), endpos = trRes.HitPos, filter = LocalPlayer() } )
  372.             if wallTrace.Hit or wallTrace2.Hit then
  373.                 surface.SetDrawColor( 255, 0, 0, 255 - time*10 )
  374.             else
  375.                 surface.SetDrawColor( 255, 255, 255, 255 - time*10 )
  376.             end
  377.             surface.DrawLine( x, y, x2, y2 )
  378.             if trRes.Hit then break end
  379.         end
  380.     end
  381.  
  382. end
  383.  
  384. /* The core of the hack is below here: */
  385.  
  386. if not GM and GAMEMODE then
  387.     for name,func in pairs( HAX ) do
  388.         oldGM[name] = oldGM[name] or GAMEMODE[name]
  389.         GAMEMODE[name] = function(...) local ret = func(...) if ret != nil then return ret end return oldGM[name](...) end
  390.     end
  391. elseif GM and not GAMEMODE then
  392.     for name,func in pairs( HAX ) do
  393.         oldGM[name] = oldGM[name] or GM[name]
  394.         GM[name] = function(...) local ret = func(...) if ret != nil then return ret end return oldGM[name](...) end
  395.     end
  396. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement