码迷,mamicode.com
首页 > 其他好文 > 详细

【资源分享】Gmod子弹跟踪脚本(适用于小型服务器)

时间:2020-05-31 15:47:29      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:opacity   ide   down   city   func   ntc   distance   透明度   bsp   

*----------------------------------------------[下载区]----------------------------------------------*

技术图片
  1 local ply = LocalPlayer()
  2 
  3 local aimbotcvar = CreateClientConVar( "psilent_aimbot", 1, true, false )
  4 local crosshaircvar = CreateClientConVar( "psilent_crosshair", 1, true, false )
  5 local fovcirclecvar = CreateClientConVar( "psilent_fovcircle", 1, true, false )
  6 local fovcircleopacity = CreateClientConVar( "psilent_fovcircle_opacity", 50, true, false )
  7 
  8 local aimkey = CreateClientConVar( "psilent_aimkey", 0, true, false )
  9 local aimfov = CreateClientConVar( "psilent_fov", 2, true, false )
 10 
 11 local function getpos( v )
 12 
 13     if ( v:GetAttachment( v:LookupAttachment( "eyes" ) ) ) then
 14     
 15         return ( v:GetAttachment( v:LookupAttachment( "eyes" ) ).Pos )
 16     
 17     end
 18     
 19     return v:LocalToWorld( v:OBBCenter() )
 20 
 21 end
 22 
 23 local function isvisible( v )
 24 
 25     local tr = {
 26     
 27         start = ply:GetShootPos(),
 28         endpos = getpos( v ),
 29         filter = { ply, v },
 30         mask = MASK_SHOT
 31     
 32     }
 33     
 34     return ( util.TraceLine( tr ).Fraction == 1 )
 35 
 36 end
 37 
 38 local midx, midy = ScrW() / 2, ScrH() / 2
 39 
 40 local function dist( pos )
 41 
 42     local spos = pos:ToScreen()
 43 
 44     return ( math.Distance( spos.x, spos.y, midx, midy ) )
 45 
 46 end
 47 
 48 local function gettarget()
 49 
 50     local _players = player.GetAll()
 51     
 52     table.sort( _players, function( a, b )
 53 
 54         return ( dist( getpos( a ) ) < dist( getpos( b ) ) )
 55 
 56     end )
 57     
 58     for k, v in pairs( _players ) do
 59     
 60         if ( v == ply or v:IsDormant() or v:Health() <= 0 or !v:Alive() or !isvisible( v ) ) then continue end
 61         
 62         local ang = ( getpos( v ) - ply:GetShootPos() ):Angle()
 63         local angdiffy = math.abs( math.NormalizeAngle( ply:EyeAngles().y - ang.y ) )
 64         local angdiffp = math.abs( math.NormalizeAngle( ply:EyeAngles().p - ang.p ) )
 65         if ( angdiffy > aimfov:GetInt() or angdiffp > aimfov:GetInt() ) then continue end
 66         
 67         return v
 68     
 69     end
 70 
 71 end
 72 
 73 local function aimbot( cmd )
 74 
 75     if ( !aimbotcvar:GetBool() or cmd:CommandNumber() == 0 ) then return end
 76 
 77     local target = gettarget()
 78     if ( target == nil ) then return end
 79     
 80     local ang = ( getpos( target ) - ply:GetShootPos() ):Angle()
 81     ang:Normalize()
 82     
 83     if ( !input.IsKeyDown( KEY_F ) and aimkey:GetBool() ) then return end
 84     
 85     if ( cmd:KeyDown( IN_ATTACK ) ) then
 86         
 87         cmd:SetViewAngles( ang )
 88         
 89     end
 90 
 91 end
 92 
 93 local fakeview = ply:EyeAngles()
 94 
 95 local function fixmovement( cmd, old, aaaaa )
 96     
 97     local move = Vector( cmd:GetForwardMove(), cmd:GetSideMove(), 0)
 98     local speed = math.sqrt( move.x * move.x + move.y * move.y )
 99     local ang = move:Angle()
100     local yaw = math.rad( cmd:GetViewAngles().y - old.y + ang.y )
101     
102     cmd:SetForwardMove( ( math.cos( yaw ) * speed ) * ( aaaaa and -1 or 1 ) )
103     cmd:SetSideMove( math.sin( yaw ) * speed )
104     
105 end
106 
107 local function fakeangle( cmd )
108 
109     fakeview = ( fakeview + Angle( cmd:GetMouseY() * 0.022, cmd:GetMouseX() * -0.022, 0 ) )
110     fakeview:Normalize()
111     fakeview.x = math.Clamp( fakeview.x, -89, 89 )
112     
113     cmd:SetViewAngles( fakeview )
114     
115     if ( cmd:CommandNumber() == 0 ) then return end
116     
117     local oview = cmd:GetViewAngles()
118     
119     aimbot( cmd )
120     
121     local x = cmd:GetViewAngles().p
122     
123     fixmovement( cmd, oview, x > 89 and true or x < -89 and true or false )
124 
125 end
126 
127 local function createmove( cmd )
128 
129     aimbot( cmd )
130     fakeangle( cmd )
131 
132 end
133 
134 hook.Add( "CreateMove", "createmove", createmove )
135 
136 local function crosshair()
137 
138     if ( !crosshaircvar:GetBool() ) then return end
139 
140     surface.SetDrawColor( 0, 0, 0 )
141     
142     surface.DrawLine( ScrW() / 2 - 6, ScrH() / 2 - 1, ScrW() / 2 + 7, ScrH() / 2 - 1 ) 
143     surface.DrawLine( ScrW() / 2 - 6, ScrH() / 2, ScrW() / 2 + 7, ScrH() / 2 ) 
144     surface.DrawLine( ScrW() / 2 - 6, ScrH() / 2 + 1, ScrW() / 2 + 7, ScrH() / 2 + 1 )
145     
146     surface.DrawLine( ScrW() / 2 - 1, ScrH() / 2 + 6, ScrW() / 2 - 1, ScrH() / 2 - 6 ) 
147     surface.DrawLine( ScrW() / 2, ScrH() / 2 - 6, ScrW() / 2, ScrH() / 2 + 7 )
148     surface.DrawLine( ScrW() / 2 + 1, ScrH() / 2 - 6, ScrW() / 2 + 1, ScrH() / 2 + 7 ) 
149     
150     surface.SetDrawColor( 255, 255, 255 )
151     surface.DrawLine( ScrW() / 2 - 5, ScrH() / 2, ScrW() / 2 + 6, ScrH() / 2 )
152     surface.DrawLine( ScrW() / 2 , ScrH() / 2 - 5, ScrW() / 2, ScrH() / 2 + 6 ) 
153     
154 end
155 
156 hook.Add( "HUDPaint", "crosshair", crosshair )
157 
158 local function fovcircle()
159 
160     if ( !fovcirclecvar:GetBool() ) then return end
161     
162     surface.DrawCircle( midx, midy, aimfov:GetInt() * 13, Color( 255, 255, 255, fovcircleopacity:GetInt() ) )
163 
164 end
165 
166 hook.Add( "HUDPaint", "fovcircle", fovcircle )
167 
168 local function calcview()
169 
170     return ( { angles = ply:EyeAngles() } )
171 
172 end
173 
174 hook.Add( "CalcView", "calcview", calcview )
175 
176 MsgC( Color( 0, 255, 150 ), "[子弹跟踪] ", Color( 255, 255, 255 ), "脚本加载成功" )
查看脚本

*----------------------------------------------[下载区]----------------------------------------------*

*----------------------------------------------[介绍区]----------------------------------------------*

子弹跟踪型自瞄脚本,适用于人数较少的小型服务器

控制台指令:

psilent_aimbot 1/0   -脚本开关

psilent_crosshair 1/0   -准星显示

psilent_fovcircle 1/0   -有效范围显示

psilent_fovcircle_opacity x   -有效范围显示透明度

psilent_aimkey 1/0   -按键模式(默认F键)

psilent_fov x   -有效范围设置

*----------------------------------------------[介绍区]----------------------------------------------*

 

游戏截图:暂无

 

【资源分享】Gmod子弹跟踪脚本(适用于小型服务器)

标签:opacity   ide   down   city   func   ntc   distance   透明度   bsp   

原文地址:https://www.cnblogs.com/fBuX/p/13019063.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!