Advertisement
Guest User

gearv1

a guest
Mar 31st, 2015
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 57.17 KB | None | 0 0
  1. ________ .__ .__ ____ ________
  2. / _____/ ____ _____ __________ _|__| _____|__| ____ ____ \ \ / /_ |
  3. / \ ____/ __ \\__ \\_ __ \ \/ / |/ ___/ |/ _ \ / \ \ Y / | | 4
  4. \ \_\ \ ___/ / __ \| | \/\ /| |\___ \| ( <_> ) | \ \ / | |
  5. \______ /\___ >____ /__| \_/ |__/____ >__|\____/|___| / \___/ |___|
  6. \/ \/ \/ \/ \/
  7. */
  8. -- Notes
  9. /*
  10.  
  11. */
  12.  
  13.  
  14.  
  15. if SERVER then return end
  16.  
  17. local GB = {}
  18.  
  19. local concommand = concommand
  20. local cvars = cvars
  21. local debug = debug
  22. local ents = ents
  23. local file = file
  24. local hook = hook
  25. local math = math
  26. local spawnmenu = spawnmenu
  27. local string = string
  28. local surface = surface
  29. local table = table
  30. local timer = timer
  31. local util = util
  32. local vgui = vgui
  33.  
  34. local Angle = Angle
  35. local CreateClientConVar = CreateClientConVar
  36. local CurTime = CurTime
  37. local ErrorNoHalt = ErrorNoHalt
  38. local FrameTime = FrameTime
  39. local GetConVarString = GetConVarString
  40. local GetViewEntity = GetViewEntity
  41. local include = include
  42. local ipairs = ipairs
  43. local pairs = pairs
  44. local pcall = pcall
  45. local print = print
  46. local RunConsoleCommand = RunConsoleCommand
  47. local ScrH = ScrH
  48. local ScrW = ScrW
  49. local tonumber = tonumber
  50. local type = type
  51. local unpack = unpack
  52. local ValidEntity = IsValid
  53. local Vector = Vector
  54.  
  55.  
  56.  
  57. local ply = LocalPlayer()
  58. CreateClientConVar( "gear_config_threshold", 0, true, false )
  59. CreateClientConVar( "gear_config_godmode", 0, true, false )
  60. CreateClientConVar( "gear_config_ESP_Misc", 0, true, false )
  61. CreateClientConVar( "gear_config_ESP_Consumables", 0, true, false )
  62. CreateClientConVar( "gear_config_ESP_Weapons", 0, true, false )
  63. CreateClientConVar( "gear_config_ESP_Ammo", 0, true, false )
  64.  
  65. CreateClientConVar( "gear_config_ESP_Salesman", 0, true, false )
  66. CreateClientConVar( "gear_config_ESP_Generator", 0, true, false )
  67. CreateClientConVar( "gear_config_ESP_Shipment", 0, true, false )
  68. CreateClientConVar( "gear_config_ESP_Cash", 0, true, false )
  69. CreateClientConVar( "gear_config_ESP_Legacy", 0, true, false )
  70. CreateClientConVar( "gear_config_ESP_Player", 0, true, false )
  71. CreateClientConVar( "gear_config_ESP_Player_Skeleton", 0, true, false )
  72. CreateClientConVar( "gear_config_ESP_Player_Cham", 0, true, false )
  73. CreateClientConVar( "gear_config_ESP_Holy_Gear", 0, true, false )
  74. CreateClientConVar( "gear_config_ESP_Player_Distance", 0, true, false )
  75. --tells the script when a screenshot is being taken
  76. CreateClientConVar( "gear_screenshot", 0, true, false )
  77.  
  78.  
  79. local colors = {}
  80. red = Color(255,0,0,255);
  81. black = Color(0,0,0,255);
  82. yellow = Color(255,255,0,255);
  83. green = Color(0,255,0,255);
  84. white = Color(255,255,255,255);
  85. blue = Color(0,0,255,255);
  86. cyan = Color(0,255,255,255);
  87. pink = Color(255,0,255,255);
  88. blue = Color(0,0,255,255);
  89. grey = Color(100,100,100,255);
  90. gold = Color(255,228,0,255);
  91. lblue = Color(155,205,248);
  92. lgreen = Color(174,255,0);
  93. iceblue = Color(116,187,251,255);
  94.  
  95.  
  96. function GearPrintMessage(msg)
  97.  
  98. print("[GEAR]: "..msg)
  99.  
  100. end
  101.  
  102. concommand.Add('Gear_PrintEnts', function()
  103.  
  104. for k, v in pairs(ents.GetAll()) do
  105.  
  106. GearPrintMessage(v:GetClass()) end end)
  107.  
  108. hook.Add("CreateMove","gearbhop",function(cmd)
  109.  
  110. if bit.band( cmd:GetButtons(), IN_JUMP ) ~= 0 then
  111. if !LocalPlayer():IsOnGround() then
  112. cmd:SetButtons( bit.band( cmd:GetButtons(), bit.bnot( IN_JUMP ) ) )
  113.  
  114. end
  115. end
  116. end)
  117.  
  118.  
  119. GearPrintMessage("Loading successful.")
  120. GearPrintMessage("Welcome to GearVision, Sarge.")
  121. GearPrintMessage("To undo the ESP suddenly disappearing type 'gear_screenshot 0' into console.")
  122. GearPrintMessage("Enjoy using GearVision. The bestest private cheat.")
  123.  
  124.  
  125. surface.CreateFont("DefaultSmallDropShadow", {
  126. font = "Tahoma",
  127. size = 16,
  128. weight = 500,
  129. shadow = true,
  130. }
  131. )
  132.  
  133. -- Gearwalk aka clientside noclip
  134. local GW = {}
  135.  
  136. GW.Enabled = false
  137. GW.ViewOrigin = Vector( 0, 0, 0 )
  138. GW.ViewAngle = Angle( 0, 0, 0 )
  139. GW.Velocity = Vector( 0, 0, 0 )
  140.  
  141. function GW.CalcView( ply, origin, angles, fov )
  142. if ( !GW.Enabled ) then return end
  143. if ( GW.SetView ) then
  144. GW.ViewOrigin = origin
  145. GW.ViewAngle = angles
  146.  
  147. GW.SetView = false
  148. end
  149. return { origin = GW.ViewOrigin, angles = GW.ViewAngle }
  150. end
  151. hook.Add( "CalcView", "GearWalk", GW.CalcView )
  152.  
  153. function GW.CreateMove( cmd )
  154. if ( !GW.Enabled ) then return end
  155.  
  156. local time = FrameTime()
  157. GW.ViewOrigin = GW.ViewOrigin + ( GW.Velocity * time )
  158. GW.Velocity = GW.Velocity * 0.95
  159.  
  160. local sensitivity = 0.022
  161. GW.ViewAngle.p = math.Clamp( GW.ViewAngle.p + ( cmd:GetMouseY() * sensitivity ), -89, 89 )
  162. GW.ViewAngle.y = GW.ViewAngle.y + ( cmd:GetMouseX() * -1 * sensitivity )
  163.  
  164. local add = Vector( 0, 0, 0 )
  165. local ang = GW.ViewAngle
  166. if ( cmd:KeyDown( IN_FORWARD ) ) then add = add + ang:Forward() end
  167. if ( cmd:KeyDown( IN_BACK ) ) then add = add - ang:Forward() end
  168. if ( cmd:KeyDown( IN_MOVERIGHT ) ) then add = add + ang:Right() end
  169. if ( cmd:KeyDown( IN_MOVELEFT ) ) then add = add - ang:Right() end
  170. if ( cmd:KeyDown( IN_JUMP ) ) then add = add + ang:Up() end
  171. if ( cmd:KeyDown( IN_DUCK ) ) then add = add - ang:Up() end
  172.  
  173. add = add:GetNormal() * time * 500
  174. if ( cmd:KeyDown( IN_SPEED ) ) then add = add * 2 end
  175.  
  176. GW.Velocity = GW.Velocity + add
  177.  
  178. if ( GW.LockView == true ) then
  179. GW.LockView = cmd:GetViewAngles()
  180. end
  181. if ( GW.LockView ) then
  182. cmd:SetViewAngles( GW.LockView )
  183. end
  184.  
  185. cmd:SetForwardMove( 0 )
  186. cmd:SetSideMove( 0 )
  187. cmd:SetUpMove( 0 )
  188. end
  189. hook.Add( "CreateMove", "GearWalk", GW.CreateMove )
  190.  
  191. function GW.Toggle()
  192. GW.Enabled = !GW.Enabled
  193. GW.LockView = GW.Enabled
  194. GW.SetView = true
  195.  
  196. local status = { [ true ] = "ON", [ false ] = "OFF" }
  197. print( "GearWalk " .. status[ GW.Enabled ] )
  198. end
  199. concommand.Add( "GW_toggle", GW.Toggle )
  200.  
  201. concommand.Add( "GW_pos", function() print( GW.ViewOrigin ) end )
  202.  
  203. function gearMenu()
  204.  
  205. local gearMenuFrame = vgui.Create("DFrame")
  206. local PropertySheet = vgui.Create( "DPropertySheet" )
  207. PropertySheet:SetParent( gearMenuFrame )
  208. PropertySheet:SetPos( 0, 25 )
  209. PropertySheet:SetSize( 600, 575 )
  210.  
  211.  
  212. gearMenuFrame:SetPos((surface.ScreenWidth()/2) - 300,(surface.ScreenHeight()/2) - 300)
  213. gearMenuFrame:SetSize(600,600)
  214. gearMenuFrame:SetTitle("GearVision")
  215. gearMenuFrame:MakePopup()
  216.  
  217. local SheetItemTwo = vgui.Create( "DPanel" )
  218. SheetItemTwo:SetPos( 25, 50 )
  219. SheetItemTwo:SetSize( 250, 250 )
  220. SheetItemTwo.Paint = function() -- Paint function
  221. surface.SetDrawColor( 50, 50, 50, 255 ) -- Set our rect color below us; we do this so you can see items added to this panel
  222. surface.DrawRect( 0, 0, SheetItemTwo:GetWide(), SheetItemTwo:GetTall() ) -- Draw the rect
  223. end
  224.  
  225. local SheetItemOne = vgui.Create( "DPanel" )
  226. SheetItemOne:SetPos( 25, 50 )
  227. SheetItemOne:SetSize( 250, 250 )
  228. SheetItemOne.Paint = function() -- Paint function
  229. surface.SetDrawColor( 50, 50, 50, 255 ) -- Set our rect color below us; we do this so you can see items added to this panel
  230. surface.DrawRect( 0, 0, SheetItemOne:GetWide(), SheetItemOne:GetTall() ) -- Draw the rect
  231. end
  232.  
  233. local GearGodmodeToggle = vgui.Create( "DCheckBoxLabel", SheetItemOne )
  234. GearGodmodeToggle:SetPos( 15,15 )
  235. GearGodmodeToggle:SetText( "Enable Godmode" )
  236. GearGodmodeToggle:SetConVar( "gear_config_godmode" )
  237. GearGodmodeToggle:SizeToContents()
  238.  
  239. local GearGodmodeSlider = vgui.Create( "DNumSlider", SheetItemOne )
  240. GearGodmodeSlider:SetPos( 15,35 )
  241. GearGodmodeSlider:SetSize( 250, 25 )
  242. GearGodmodeSlider:SetText( "Godmode HP Threshold" )
  243. GearGodmodeSlider:SetMin( 10 )
  244. GearGodmodeSlider:SetMax( 99 )
  245. GearGodmodeSlider:SetDecimals( 0 )
  246. GearGodmodeSlider:SetConVar( "gear_config_threshold" )
  247.  
  248. local GearESPToggle = vgui.Create( "DCheckBoxLabel", SheetItemTwo )
  249. GearESPToggle:SetPos( 15,15 )
  250. GearESPToggle:SetText( "Enable Misc Item ESP" )
  251. GearESPToggle:SetConVar( "gear_config_ESP_Misc" )
  252. GearESPToggle:SizeToContents()
  253.  
  254. local GearESPConsumables = vgui.Create( "DCheckBoxLabel", SheetItemTwo )
  255. GearESPConsumables:SetPos( 15,30 )
  256. GearESPConsumables:SetText( "Enable Medical ESP" )
  257. GearESPConsumables:SetConVar( "gear_config_ESP_Consumables" )
  258. GearESPConsumables:SizeToContents()
  259.  
  260. local GearESPWeapons = vgui.Create( "DCheckBoxLabel", SheetItemTwo )
  261. GearESPWeapons:SetPos( 15,45 )
  262. GearESPWeapons:SetText( "Enable Weapon ESP" )
  263. GearESPWeapons:SetConVar( "gear_config_ESP_Weapons" )
  264. GearESPWeapons:SizeToContents()
  265.  
  266. local GearESPWeapons = vgui.Create( "DCheckBoxLabel", SheetItemTwo )
  267. GearESPWeapons:SetPos( 15,60 )
  268. GearESPWeapons:SetText( "Enable Ammo ESP" )
  269. GearESPWeapons:SetConVar( "gear_config_ESP_Ammo" )
  270. GearESPWeapons:SizeToContents()
  271.  
  272. local GearESPSalesman = vgui.Create( "DCheckBoxLabel", SheetItemTwo )
  273. GearESPSalesman:SetPos( 15,75 )
  274. GearESPSalesman:SetText( "Enable Salesman ESP" )
  275. GearESPSalesman:SetConVar( "gear_config_ESP_Salesman" )
  276. GearESPSalesman:SizeToContents()
  277.  
  278. local GearESPGenerator = vgui.Create( "DCheckBoxLabel", SheetItemTwo )
  279. GearESPGenerator:SetPos( 15,90 )
  280. GearESPGenerator:SetText( "Enable Generator ESP" )
  281. GearESPGenerator:SetConVar( "gear_config_ESP_Generator" )
  282. GearESPGenerator:SizeToContents()
  283.  
  284. local GearESPShipment = vgui.Create( "DCheckBoxLabel", SheetItemTwo )
  285. GearESPShipment:SetPos( 15,105 )
  286. GearESPShipment:SetText( "Enable Shipment ESP" )
  287. GearESPShipment:SetConVar( "gear_config_ESP_Shipment" )
  288. GearESPShipment:SizeToContents()
  289.  
  290. local GearESPCash = vgui.Create( "DCheckBoxLabel", SheetItemTwo )
  291. GearESPCash:SetPos( 15,120 )
  292. GearESPCash:SetText( "Enable Cash ESP" )
  293. GearESPCash:SetConVar( "gear_config_ESP_Cash" )
  294. GearESPCash:SizeToContents()
  295.  
  296. local GearESPPlayer = vgui.Create( "DCheckBoxLabel", SheetItemTwo )
  297. GearESPPlayer:SetPos( 15,200 )
  298. GearESPPlayer:SetText( "Enable Player ESP" )
  299. GearESPPlayer:SetConVar( "gear_config_ESP_Player" )
  300. GearESPPlayer:SizeToContents()
  301.  
  302. local GearESPSkeleton = vgui.Create( "DCheckBoxLabel", SheetItemTwo )
  303. GearESPSkeleton:SetPos( 15,215 )
  304. GearESPSkeleton:SetText( "Enable Player Skeletons" )
  305. GearESPSkeleton:SetConVar( "gear_config_ESP_Player_Skeleton" )
  306. GearESPSkeleton:SizeToContents()
  307.  
  308. local GearESPCham = vgui.Create( "DCheckBoxLabel", SheetItemTwo )
  309. GearESPCham:SetPos( 15,230 )
  310. GearESPCham:SetText( "Enable Player Cham" )
  311. GearESPCham:SetConVar( "gear_config_ESP_Player_Cham" )
  312. GearESPCham:SizeToContents()
  313.  
  314. local GearESPBox = vgui.Create( "DCheckBoxLabel", SheetItemTwo )
  315. GearESPBox:SetPos( 15,245 )
  316. GearESPBox:SetText( "Enable Player Box" )
  317. GearESPBox:SetConVar( "gear_config_ESP_Player_Box" )
  318. GearESPBox:SizeToContents()
  319.  
  320. local GearDistanceModifier = vgui.Create( "DNumSlider", SheetItemTwo )
  321. GearDistanceModifier:SetPos( 15,260 )
  322. GearDistanceModifier:SetSize( 250, 25 )
  323. GearDistanceModifier:SetText( "Player Distance Modifier" )
  324. GearDistanceModifier:SetMin( 256 )
  325. GearDistanceModifier:SetMax( 10000 )
  326. GearDistanceModifier:SetDecimals( 0 )
  327. GearDistanceModifier:SetConVar( "gear_config_ESP_Player_Distance" )
  328.  
  329. local GearESPBox = vgui.Create( "DCheckBoxLabel", SheetItemTwo )
  330. GearESPBox:SetPos( 15,290 )
  331. GearESPBox:SetText( "Enable Consumable ESP" )
  332. GearESPBox:SetConVar( "gear_config_ESP_Holy_Gear" )
  333. GearESPBox:SizeToContents()
  334.  
  335. local GearESPLegacy = vgui.Create( "DCheckBoxLabel", SheetItemTwo )
  336. GearESPLegacy:SetPos( 15,305 )
  337. GearESPLegacy:SetText( "Enable Reusables ESP" )
  338. GearESPLegacy:SetConVar( "gear_config_ESP_Legacy" )
  339. GearESPLegacy:SizeToContents()
  340.  
  341. PropertySheet:AddSheet( "Gear Config", SheetItemOne, "gui/silkicons/user", false, false, "Configure General Settings for GearVision" )
  342. PropertySheet:AddSheet( "Gear ESP", SheetItemTwo, "gui/silkicons/group", false, false, "Configure the ESP for GearVision" )
  343.  
  344. end
  345. concommand.Add("gearmenu", gearMenu)
  346.  
  347. function GearDebug()
  348.  
  349. if GetConVar("gear_screenshot"):GetInt() == 0 then
  350.  
  351. draw.SimpleText("GearVision Loaded", 'DefaultSmallDropShadow', 80, 50, Color(255, 150, 0, 255), 1, 1, 1)
  352.  
  353. end
  354.  
  355.  
  356. end
  357. hook.Add("HUDPaint","Debug",GearDebug)
  358.  
  359. --[[
  360. hook.Add( "HUDPaint", "WallhackItem", function()
  361. for k,v in pairs (ents.FindByClass("cw_item")) do
  362. if LocalPlayer():Alive() then
  363. local Position = ( v:GetPos() + Vector( 0,0,0 ) ):ToScreen()
  364. local Dist = v:GetPos():Distance(LocalPlayer():GetPos());
  365. draw.DrawText( v:GetClass( ), "DefaultSmallDropShadow", Position.x, Position.y, Color( 255, 51, 204, 255 ), 1 )
  366. draw.DrawText( "D: " .. math.floor(Dist), "DefaultSmallDropShadow", Position.x, Position.y + 10, Color( 255, 255, 255, 255 ), 1 )
  367. else
  368. end
  369. end
  370. end)
  371. --]] --I honestly dont even know how to toggle this, time for coffee and gmod lua wiki
  372.  
  373. function GearGodmode()
  374.  
  375. local dmg = ply:Health()
  376. local threshold = GetConVar("gear_config_threshold"):GetInt()
  377.  
  378. if ConVarExists( "gear_config_godmode" ) and GetConVar("gear_config_godmode"):GetInt() == 1 and GetConVar("gear_screenshot"):GetInt() == 0 then
  379.  
  380. if dmg <= threshold then
  381. GearPrintMessage("Warning, damage taken has fallen below threshold. Disconnecting.")
  382. --GearPrintMessage("Warning, damage taken has fallen below threshold. Buying HP")
  383. --RunConsoleCommand("say", "/buyhealth");
  384. RunConsoleCommand("disconnect");
  385. end
  386.  
  387. else
  388. return nil;
  389. end
  390. end
  391. hook.Add("Think","SlothGodmode",GearGodmode)
  392.  
  393.  
  394. hook.Add( "HUDPaint", "WallhackCash", function()
  395.  
  396. if ConVarExists( "gear_config_ESP_Cash" ) and GetConVar("gear_config_ESP_Cash"):GetInt() == 1 and GetConVar("gear_screenshot"):GetInt() == 0 then
  397.  
  398.  
  399. for k,v in pairs (ents.FindByClass("cw_cash")) do
  400. if LocalPlayer():Alive() then
  401. local Position = ( v:GetPos() + Vector( 0,0,0 ) ):ToScreen()
  402. local Dist = v:GetPos():Distance(LocalPlayer():GetPos());
  403. draw.DrawText( "$Cash$", "DefaultSmallDropShadow", Position.x, Position.y, lgreen, 1 )
  404. draw.DrawText( "D: " .. math.floor(Dist), "DefaultSmallDropShadow", Position.x, Position.y + 10, lgreen, 1 )
  405. else return nil;
  406. end
  407. end
  408. end
  409. end)
  410.  
  411. hook.Add( "HUDPaint", "WallhackShipment", function()
  412.  
  413. if ConVarExists( "gear_config_ESP_Shipment" ) and GetConVar("gear_config_ESP_Shipment"):GetInt() == 1 and GetConVar("gear_screenshot"):GetInt() == 0 then
  414.  
  415.  
  416. for k,v in pairs (ents.FindByClass("cw_shipment")) do
  417. if LocalPlayer():Alive() then
  418. local Position = ( v:GetPos() + Vector( 0,0,0 ) ):ToScreen()
  419. local Dist = v:GetPos():Distance(LocalPlayer():GetPos());
  420. draw.DrawText( v:GetClass( ), "DefaultSmallDropShadow", Position.x, Position.y, Color( 0, 255, 0, 255 ), 1 )
  421. draw.DrawText( "D: " .. math.floor(Dist), "DefaultSmallDropShadow", Position.x, Position.y + 10, Color( 0, 255, 0, 255 ), 1 )
  422.  
  423. else return nil;
  424. end
  425. end
  426. end
  427. end)
  428.  
  429. hook.Add( "HUDPaint", "WallhackGenerator", function()
  430.  
  431. if ConVarExists( "gear_config_ESP_Generator" ) and GetConVar("gear_config_ESP_Generator"):GetInt() == 1 and GetConVar("gear_screenshot"):GetInt() == 0 then
  432.  
  433.  
  434. for k,v in pairs (ents.FindByClass("cw_generator")) do
  435. if LocalPlayer():Alive() then
  436. local Position = ( v:GetPos() + Vector( 0,0,0 ) ):ToScreen()
  437. local Dist = v:GetPos():Distance(LocalPlayer():GetPos());
  438. draw.DrawText( v:GetClass( ), "DefaultSmallDropShadow", Position.x, Position.y, Color( 0, 0, 255, 255 ), 1 )
  439. draw.DrawText( "D: " .. math.floor(Dist), "DefaultSmallDropShadow", Position.x, Position.y + 10, Color( 0, 0, 255, 255 ), 1 )
  440. else return nil;
  441. end
  442. end
  443. end
  444. end)
  445.  
  446. hook.Add( "HUDPaint", "WallhackSalesman", function()
  447.  
  448. if ConVarExists( "gear_config_ESP_Salesman" ) and GetConVar("gear_config_ESP_Salesman"):GetInt() == 1 and GetConVar("gear_screenshot"):GetInt() == 0 then
  449.  
  450. for k,v in pairs (ents.FindByClass("cw_salesman")) do
  451. if LocalPlayer():Alive() then
  452. local Position = ( v:GetPos() + Vector( 0,0,0 ) ):ToScreen()
  453. draw.DrawText( v:GetClass( ), "DefaultSmallDropShadow", Position.x, Position.y, Color( 255, 0, 0, 255 ), 1 )
  454. else return nil;
  455. end
  456. end
  457. end
  458. end)
  459.  
  460. function CreatePos(v)
  461. local ply = LocalPlayer()
  462. local center = v:LocalToWorld( v:OBBCenter() )
  463. local min, max = v:OBBMins(), v:OBBMaxs()
  464. local dim = max - min local z = max + min
  465. local frt = ( v:GetForward() ) * ( dim.y / 2 )
  466. local rgt = ( v:GetRight() ) * ( dim.x / 2 )
  467. local top = ( v:GetUp() ) * ( dim.z / 2 )
  468. local bak = ( v:GetForward() * -1 ) * ( dim.y / 2 )
  469. local lft = ( v:GetRight() * -1 ) * ( dim.x / 2 )
  470. local btm = ( v:GetUp() * -1 ) * ( dim.z / 2 )
  471. local s = 1
  472. local FRT = center + frt / s + rgt / s + top / s; FRT = FRT:ToScreen()
  473. local BLB = center + bak / s + lft / s + btm / s; BLB = BLB:ToScreen()
  474. local FLT = center + frt / s + lft / s + top / s; FLT = FLT:ToScreen()
  475. local BRT = center + bak / s + rgt / s + top / s; BRT = BRT:ToScreen()
  476. local BLT = center + bak / s + lft / s + top / s; BLT = BLT:ToScreen()
  477. local FRB = center + frt / s + rgt / s + btm / s; FRB = FRB:ToScreen()
  478. local FLB = center + frt / s + lft / s + btm / s; FLB = FLB:ToScreen()
  479. local BRB = center + bak / s + rgt / s + btm / s; BRB = BRB:ToScreen()
  480. local z = 100
  481. if ( v:Health() <= 50 ) then z = 100 end
  482. local x, y = ( ( v:Health() / 100 ) ), 1
  483. if ( v:Health() <= 0 ) then x = 1 end
  484. local FRT3 = center + frt + rgt + top / x; FRT3 = FRT3; FRT3 = FRT3:ToScreen()
  485. local BLB3 = center + bak + lft + btm / x; BLB3 = BLB3; BLB3 = BLB3:ToScreen()
  486. local FLT3 = center + frt + lft + top / x; FLT3 = FLT3; FLT3 = FLT3:ToScreen()
  487. local BRT3 = center + bak + rgt + top / x; BRT3 = BRT3; BRT3 = BRT3:ToScreen()
  488. local BLT3 = center + bak + lft + top / x; BLT3 = BLT3; BLT3 = BLT3:ToScreen()
  489. local FRB3 = center + frt + rgt + btm / x; FRB3 = FRB3; FRB3 = FRB3:ToScreen()
  490. local FLB3 = center + frt + lft + btm / x; FLB3 = FLB3; FLB3 = FLB3:ToScreen()
  491. local BRB3 = center + bak + rgt + btm / x; BRB3 = BRB3; BRB3 = BRB3:ToScreen()
  492. local x, y, z = 1.1, 0.9, 1
  493. local FRT2 = center + frt / y + rgt / z + top / x; FRT2 = FRT2:ToScreen()
  494. local BLB2 = center + bak / y + lft / z + btm / x; BLB2 = BLB2:ToScreen()
  495. local FLT2 = center + frt / y + lft / z + top / x; FLT2 = FLT2:ToScreen()
  496. local BRT2 = center + bak / y + rgt / z + top / x; BRT2 = BRT2:ToScreen()
  497. local BLT2 = center + bak / y + lft / z + top / x; BLT2 = BLT2:ToScreen()
  498. local FRB2 = center + frt / y + rgt / z + btm / x; FRB2 = FRB2:ToScreen()
  499. local FLB2 = center + frt / y + lft / z + btm / x; FLB2 = FLB2:ToScreen()
  500. local BRB2 = center + bak / y + rgt / z + btm / x; BRB2 = BRB2:ToScreen()
  501. local maxX = math.max( FRT.x,BLB.x,FLT.x,BRT.x,BLT.x,FRB.x,FLB.x,BRB.x )
  502. local minX = math.min( FRT.x,BLB.x,FLT.x,BRT.x,BLT.x,FRB.x,FLB.x,BRB.x )
  503. local maxY = math.max( FRT.y,BLB.y,FLT.y,BRT.y,BLT.y,FRB.y,FLB.y,BRB.y )
  504. local minY = math.min( FRT.y,BLB.y,FLT.y,BRT.y,BLT.y,FRB.y,FLB.y,BRB.y )
  505. local minYhp2 = math.min( FRT.y,BLB.y,FLT.y,BRT.y,BLT.y,FRB.y,FLB.y,BRB.y )
  506. local maxXhp = math.max( FRT3.x,BLB3.x,FLT3.x,BRT3.x,BLT3.x,FRB3.x,FLB3.x,BRB3.x )
  507. local minXhp = math.min( FRT3.x,BLB3.x,FLT3.x,BRT3.x,BLT3.x,FRB3.x,FLB3.x,BRB3.x )
  508. local maxYhp = math.max( FRT3.y,BLB3.y,FLT3.y,BRT3.y,BLT3.y,FRB3.y,FLB3.y,BRB3.y )
  509. local minYhp = math.min( FRT3.y,BLB3.y,FLT3.y,BRT3.y,BLT3.y,FRB3.y,FLB3.y,BRB3.y )
  510. local maxX2 = math.max( FRT2.x,BLB2.x,FLT2.x,BRT2.x,BLT2.x,FRB2.x,FLB2.x,BRB2.x )
  511. local minX2 = math.min( FRT2.x,BLB2.x,FLT2.x,BRT2.x,BLT2.x,FRB2.x,FLB2.x,BRB2.x )
  512. local maxY2 = math.max( FRT2.y,BLB2.y,FLT2.y,BRT2.y,BLT2.y,FRB2.y,FLB2.y,BRB2.y )
  513. local minY2 = math.min( FRT2.y,BLB2.y,FLT2.y,BRT2.y,BLT2.y,FRB2.y,FLB2.y,BRB2.y )
  514. return maxX, minX, maxY, minY, maxX2, minX2, maxY2, minY2, minYhp, maxYhp
  515. end
  516.  
  517. function IsCloseEnough(ent)
  518. local dist = ent:GetPos():Distance( LocalPlayer():GetPos() )
  519. if( dist <= GetConVarNumber("gear_config_ESP_Player_Distance") and ent:GetPos() != Vector( 0, 0, 0 ) ) then
  520. return true
  521. end
  522. return false
  523. end
  524.  
  525. local mat = CreateMaterial("Cham_Texture","VertexLitGeneric",{ ["$basetexture"] = "models/debug/debugwhite", ["$model"] = 1, ["$translucent"] = 1, ["$alpha"] = 1, ["$nocull"] = 1, ["$ignorez"] = 1 } );
  526.  
  527. function Chams()
  528. if GetConVarNumber("gear_config_ESP_Player_Cham") == 1 and GetConVar("gear_screenshot"):GetInt() == 0 then
  529. for k,v in pairs(player.GetAll()) do
  530.  
  531. local TCol = team.GetColor(v:Team())
  532. if IsValid(v) and v:Health() > 0 and v:Team() != TEAM_SPECTATOR and IsCloseEnough(v) then
  533.  
  534. cam.Start3D(EyePos(),EyeAngles())
  535. render.SuppressEngineLighting( true )
  536. render.SetColorModulation( ( TCol.r * ( 1 / 255 ) ), ( TCol.g * ( 1 / 255 ) ), ( TCol.b * ( 1 / 255 ) ) )
  537. render.MaterialOverride( mat )
  538.  
  539. v:DrawModel()
  540. render.SuppressEngineLighting( false )
  541. render.SetColorModulation(1,1,1)
  542. render.MaterialOverride( )
  543. v:DrawModel()
  544. cam.End3D()
  545. end
  546. end
  547. end
  548. end
  549. hook.Add( "RenderScreenspaceEffects", "Chams", Chams )
  550.  
  551. hook.Add( "HUDPaint", "PlayerESP", function()
  552.  
  553. if ConVarExists( "gear_config_ESP_Player" ) and GetConVar("gear_config_ESP_Player"):GetInt() == 1 and GetConVar("gear_screenshot"):GetInt() == 0 then
  554.  
  555. for k,e in pairs ( player.GetAll() ) do
  556.  
  557. if ( e:IsPlayer() and e:Alive() and e != LocalPlayer() and IsCloseEnough(e) ) then
  558. if e:GetActiveWeapon() != nil then
  559. if type(e:GetActiveWeapon()) == "Weapon" then
  560. if e:GetActiveWeapon() and e:GetActiveWeapon():IsValid() then
  561. local weapon = e:GetActiveWeapon():GetPrintName()
  562.  
  563. local Position = ( e:GetPos() + Vector( 0,0,80 ) ):ToScreen()
  564. local Dist = e:GetPos():Distance(LocalPlayer():GetPos());
  565. local Health = e:Health()
  566. local Name = e:Nick()
  567.  
  568. if e:Health() >= 90 then HPColor = Color(0,255,0,255)
  569. elseif e:Health() >= 70 then HPColor = Color(255,255,0,255)
  570. elseif e:Health() >= 50 then HPColor = Color(255,165,0,255)
  571. elseif e:Health() >= 30 then HPColor = Color(255,140,0,255)
  572. elseif e:Health() >= 20 then HPCOlor = Color(255,69,0,255)
  573. elseif e:Health() >= 10 then HPColor = Color(255,0,0,255)
  574. else HPColor = Color(255,0,0,255)
  575. end
  576.  
  577.  
  578. draw.DrawText( Name, "DefaultSmallDropShadow", Position.x, Position.y, team.GetColor(e:Team()), 1 )
  579. draw.DrawText( "D: " .. math.floor(Dist), "DefaultSmallDropShadow", Position.x, Position.y + 10, team.GetColor(e:Team()), 1 )
  580. draw.DrawText( "H: " .. math.floor(Health), "DefaultSmallDropShadow", Position.x, Position.y + 20, HPColor, 1 )
  581. draw.DrawText( "W: " ..weapon, "DefaultSmallDropShadow", Position.x, Position.y + 30, team.GetColor(e:Team()), 1 )
  582. if e:GetFriendStatus() == "friend" then
  583. draw.DrawText( "[FRIEND]", "DefaultSmallDropShadow", Position.x, Position.y + 40, Color(0, 255, 0, 255), 1 )
  584. end
  585. if e:IsAdmin() then
  586. draw.DrawText( "[ADMIN]", "DefaultSmallDropShadow", Position.x, Position.y + 50, Color(255, 0, 0, 255), 1 )
  587. end
  588.  
  589. local bones = {
  590. { S = "ValveBiped.Bip01_Head1", E = "ValveBiped.Bip01_Neck1" },
  591. { S = "ValveBiped.Bip01_Neck1", E = "ValveBiped.Bip01_Spine4" },
  592. { S = "ValveBiped.Bip01_Spine4", E = "ValveBiped.Bip01_Spine2" },
  593. { S = "ValveBiped.Bip01_Spine2", E = "ValveBiped.Bip01_Spine1" },
  594. { S = "ValveBiped.Bip01_Spine1", E = "ValveBiped.Bip01_Spine" },
  595. { S = "ValveBiped.Bip01_Spine", E = "ValveBiped.Bip01_Pelvis" },
  596.  
  597. { S = "ValveBiped.Bip01_Spine4", E = "ValveBiped.Bip01_L_UpperArm" },
  598. { S = "ValveBiped.Bip01_L_UpperArm", E = "ValveBiped.Bip01_L_Forearm" },
  599. { S = "ValveBiped.Bip01_L_Forearm", E = "ValveBiped.Bip01_L_Hand" },
  600.  
  601. { S = "ValveBiped.Bip01_Spine4", E = "ValveBiped.Bip01_R_UpperArm" },
  602. { S = "ValveBiped.Bip01_R_UpperArm", E = "ValveBiped.Bip01_R_Forearm" },
  603. { S = "ValveBiped.Bip01_R_Forearm", E = "ValveBiped.Bip01_R_Hand" },
  604.  
  605. { S = "ValveBiped.Bip01_Pelvis", E = "ValveBiped.Bip01_L_Thigh" },
  606. { S = "ValveBiped.Bip01_L_Thigh", E = "ValveBiped.Bip01_L_Calf" },
  607. { S = "ValveBiped.Bip01_L_Calf", E = "ValveBiped.Bip01_L_Foot" },
  608. { S = "ValveBiped.Bip01_L_Foot", E = "ValveBiped.Bip01_L_Toe0" },
  609.  
  610. { S = "ValveBiped.Bip01_Pelvis", E = "ValveBiped.Bip01_R_Thigh" },
  611. { S = "ValveBiped.Bip01_R_Thigh", E = "ValveBiped.Bip01_R_Calf" },
  612. { S = "ValveBiped.Bip01_R_Calf", E = "ValveBiped.Bip01_R_Foot" },
  613. { S = "ValveBiped.Bip01_R_Foot", E = "ValveBiped.Bip01_R_Toe0" },
  614. }
  615. if GetConVarNumber("gear_config_ESP_Player_Skeleton") == 1 and GetConVar("gear_screenshot"):GetInt() == 0 then
  616.  
  617.  
  618. for k, v in pairs( bones ) do
  619. local sPos, ePos = e:GetBonePosition( e:LookupBone( v.S ) ):ToScreen(), e:GetBonePosition( e:LookupBone( v.E ) ):ToScreen()
  620. if e:IsPlayer() and !e:IsNPC() then
  621. surface.SetDrawColor(team.GetColor(e:Team()))
  622. end
  623. surface.DrawLine(sPos.x,sPos.y,ePos.x,ePos.y)
  624. end
  625.  
  626. end
  627. end
  628. end
  629. end
  630. end
  631. end
  632. end
  633. end)
  634.  
  635.  
  636. hook.Add( "HUDPaint", "WallhackCW", function()
  637. for k,ent in pairs (ents.FindByClass("cw_item")) do
  638. if LocalPlayer():Alive() and (Clockwork.entity:HasFetchedItemData(ent)) then
  639.  
  640. local itemTable = ent:GetItemTable()
  641. local Position = ( ent:GetPos() + Vector( 0,0,0 ) ):ToScreen()
  642. local Dist = ent:GetPos():Distance(LocalPlayer():GetPos());
  643.  
  644. if itemTable("category") == "Weapons" then
  645.  
  646. if ConVarExists( "gear_config_ESP_Weapons" ) and GetConVar("gear_config_ESP_Weapons"):GetInt() == 1 and GetConVar("gear_screenshot"):GetInt() == 0 then
  647.  
  648. draw.DrawText( itemTable("name").." - "..itemTable("weight").."kg", "DefaultSmallDropShadow", Position.x, Position.y, red, 1 )
  649. draw.DrawText( "D: " .. math.floor(Dist), "DefaultSmallDropShadow", Position.x, Position.y + 10, red, 1 )
  650.  
  651. end
  652.  
  653. elseif itemTable("category") == "Ammunition" then
  654.  
  655. if ConVarExists( "gear_config_ESP_Ammo" ) and GetConVar("gear_config_ESP_Ammo"):GetInt() == 1 and GetConVar("gear_screenshot"):GetInt() == 0 then
  656.  
  657. draw.DrawText( itemTable("name").." - "..itemTable("weight").."kg", "DefaultSmallDropShadow", Position.x, Position.y, yellow, 1 )
  658. draw.DrawText( "D: " .. math.floor(Dist), "DefaultSmallDropShadow", Position.x, Position.y + 10, yellow, 1 )
  659. end
  660.  
  661. elseif itemTable("category") == "Medical" then
  662.  
  663. if ConVarExists( "gear_config_ESP_Consumables" ) and GetConVar("gear_config_ESP_Consumables"):GetInt() == 1 and GetConVar("gear_screenshot"):GetInt() == 0 then
  664.  
  665. draw.DrawText( itemTable("name").." - "..itemTable("weight").."kg", "DefaultSmallDropShadow", Position.x, Position.y, green, 1 )
  666. draw.DrawText( "D: " .. math.floor(Dist), "DefaultSmallDropShadow", Position.x, Position.y + 10, green, 1 )
  667.  
  668. end
  669.  
  670. elseif itemTable("category") == "Consumables" then
  671.  
  672. if ConVarExists( "gear_config_ESP_Holy_Gear" ) and GetConVar("gear_config_ESP_Holy_Gear"):GetInt() == 1 and GetConVar("gear_screenshot"):GetInt() == 0 then
  673.  
  674. draw.DrawText( itemTable("name").." - "..itemTable("weight").."kg", "DefaultSmallDropShadow", Position.x, Position.y, lgreen, 1 )
  675. draw.DrawText( "D: " .. math.floor(Dist), "DefaultSmallDropShadow", Position.x, Position.y + 10, lgreen, 1 )
  676.  
  677. end
  678.  
  679. elseif itemTable("category") == "Reusables" then
  680.  
  681. if ConVarExists( "gear_config_ESP_Legacy" ) and GetConVar("gear_config_ESP_Legacy"):GetInt() == 1 and GetConVar("gear_screenshot"):GetInt() == 0 then
  682.  
  683. draw.DrawText( itemTable("name").." - "..itemTable("weight").."kg", "DefaultSmallDropShadow", Position.x, Position.y, lblue, 1 )
  684. draw.DrawText( "D: " .. math.floor(Dist), "DefaultSmallDropShadow", Position.x, Position.y + 10, lblue, 1 )
  685.  
  686. end
  687.  
  688. else
  689.  
  690. if ConVarExists( "gear_config_ESP_Misc" ) and GetConVar("gear_config_ESP_Misc"):GetInt() == 1 and GetConVar("gear_screenshot"):GetInt() == 0 then
  691.  
  692. draw.DrawText( itemTable("name").." - "..itemTable("weight").."kg", "DefaultSmallDropShadow", Position.x, Position.y, grey, 1 )
  693. draw.DrawText( "D: " .. math.floor(Dist), "DefaultSmallDropShadow", Position.x, Position.y + 10, grey, 1 )
  694.  
  695. end
  696.  
  697. end
  698.  
  699. end
  700. end
  701. end)
  702.  
  703. _G.render.Capture = function( data )
  704.  
  705. if ( data.format == "jpeg" ) then
  706.  
  707. RunConsoleCommand("gear_screenshot", "1");
  708. GearPrintMessage("Possible Detection, ESP hidden for your own safety")
  709.  
  710. elseif ( data.format == "png" ) then
  711.  
  712. RunConsoleCommand("gear_screenshot", "1");
  713. GearPrintMessage("Possible Detection, ESP hidden for your own safety")
  714.  
  715. else
  716.  
  717. RunConsoleCommand("gear_screenshot", "1");
  718. GearPrintMessage("Possible Detection, ESP hidden for your own safety")
  719.  
  720. end
  721.  
  722. end
  723.  
  724.  
  725. --[[
  726.  
  727. GEARBOT
  728.  
  729. CREDITS TO FAG FOR FINDING IT ON THE INTERNET CONGRATS UR GAY
  730.  
  731. notes:
  732. i haven't hooked it up to gear menu, but it will have its own tab when i decide to stop being a laz-e nigger
  733.  
  734.  
  735. --]]
  736.  
  737. local LocalPlayer = LocalPlayer
  738.  
  739. do
  740. local hooks = {}
  741. local created = {}
  742. local function CallHook(self, name, args)
  743. if !hooks[name] then return end
  744. for funcName, _ in pairs(hooks[name]) do
  745. local func = self[funcName]
  746. if func then
  747. local ok, err = pcall(func, self, unpack(args or {}))
  748. if !ok then
  749. ErrorNoHalt(err .. "\n")
  750. elseif err then
  751. return err
  752. end
  753. end
  754. end
  755. end
  756. local function RandomName()
  757. local random = ""
  758. for i = 1, math.random(4, 10) do
  759. local c = math.random(65, 116)
  760. if c >= 91 && c <= 96 then c = c + 6 end
  761. random = random .. string.char(c)
  762. end
  763. return random
  764. end
  765. local function AddHook(self, name, funcName)
  766. // If we haven't got a hook for this yet, make one with a random name and store it.
  767. // This is so anti-cheats can't detect by hook name, and so we can remove them later.
  768. if !created[name] then
  769. local random = RandomName()
  770. hook.Add(name, random, function(...) return CallHook(self, name, {...}) end)
  771. created[name] = random
  772. end
  773.  
  774. hooks[name] = hooks[name] or {}
  775. hooks[name][funcName] = true
  776. end
  777.  
  778. local cvarhooks = {}
  779. local function GetCallbackTable(convar)
  780. local callbacks = cvars.GetConVarCallbacks(convar)
  781. if !callbacks then
  782. cvars.AddChangeCallback(convar, function() end)
  783. callbacks = cvars.GetConVarCallbacks(convar)
  784. end
  785. return callbacks
  786. end
  787.  
  788. local function AddCVarHook(self, convar, funcName, ...)
  789. local hookName = "CVar_" .. convar
  790. if !cvarhooks[convar] then
  791. local random = RandomName()
  792.  
  793. local callbacks = GetCallbackTable(convar)
  794. callbacks[random] = function(...)
  795. CallHook(self, hookName, {...})
  796. end
  797.  
  798. cvarhooks[convar] = random
  799. end
  800. AddHook(self, hookName, funcName)
  801. end
  802.  
  803. // Don't let other scripts remove our hooks.
  804. local oldRemove = hook.Remove
  805. function hook.Remove(name, unique)
  806. if created[name] == unique then return end
  807. oldRemove(name, unique)
  808. end
  809.  
  810. // Removes all hooks, useful if reloading the script.
  811. local function RemoveHooks()
  812. for hookName, unique in pairs(created) do
  813. oldRemove(hookName, unique)
  814. end
  815. for convar, unique in pairs(cvarhooks) do
  816. local callbacks = GetCallbackTable(convar)
  817. callbacks[unique] = nil
  818. end
  819. end
  820.  
  821. // Add copies the script can access.
  822. GB.AddHook = AddHook
  823. GB.AddCVarHook = AddCVarHook
  824. GB.CallHook = CallHook
  825. GB.RemoveHooks = RemoveHooks
  826. end
  827.  
  828. concommand.Add("gb_reload", function()
  829. GB:CallHook("Shutdown")
  830. print("Removing hooks...")
  831. GB:RemoveHooks()
  832.  
  833. GB = nil
  834. local info = debug.getinfo(1, "S")
  835. if info && info.short_src then
  836. if string.Left(info.short_src, 3) == "lua" then
  837. info.short_src = string.sub(info.short_src, 5)
  838. end
  839. print("Reloading (" .. info.short_src .. ")...")
  840. include(info.short_src)
  841. else
  842. print("Cannot find AutoAim file, reload manually.")
  843. end
  844. end)
  845. print("AutoAim loaded.")
  846.  
  847. // ##################################################
  848. // MetaTables
  849. // ##################################################
  850.  
  851. local function GetMeta(name)
  852. return table.Copy(FindMetaTable(name) or {})
  853. end
  854.  
  855. local AngM = GetMeta("Angle")
  856. local CmdM = GetMeta("CUserCmd")
  857. local EntM = GetMeta("Entity")
  858. local PlyM = GetMeta("Player")
  859. local VecM = GetMeta("Vector")
  860.  
  861. // ##################################################
  862. // Settings
  863. // ##################################################
  864.  
  865. do
  866. local settings = {}
  867. local function SettingVar(self, name)
  868. return (self.SettingPrefix or "") .. string.lower(name)
  869. end
  870.  
  871. local function RandomName()
  872. local random = ""
  873. for i = 1, math.random(4, 10) do
  874. local c = math.random(65, 116)
  875. if c >= 91 && c <= 96 then c = c + 6 end
  876. random = random .. string.char(c)
  877. end
  878. return random
  879. end
  880.  
  881. local function SetSetting(name, _, new)
  882. if !settings[name] then return end
  883. local info = settings[name]
  884.  
  885. if info.Type == "number" then
  886. new = tonumber(new)
  887. elseif info.Type == "boolean" then
  888. new = (tonumber(new) or 0) > 0
  889. end
  890.  
  891. info.Value = new
  892. end
  893.  
  894. local function CreateSetting(self, name, desc, default, misc)
  895. local cvar = SettingVar(self, name)
  896. local info = {Name = name, Desc = desc, CVar = cvar, Type = type(default), Value = default}
  897.  
  898. for k, v in pairs(misc or {}) do
  899. if !info[k] then info[k] = v end
  900. end
  901.  
  902. // Convert default from boolean to number.
  903. if type(default) == "boolean" then
  904. default = default and 1 or 0
  905. end
  906.  
  907. if !settings[cvar] then
  908. local tab = cvars.GetConVarCallbacks(cvar)
  909. if !tab then
  910. cvars.AddChangeCallback(cvar, function() end)
  911. tab = cvars.GetConVarCallbacks(cvar)
  912. end
  913.  
  914. while true do
  915. local name = RandomName()
  916. if !tab[name] then
  917. tab[name] = SetSetting
  918. info.Callback = name
  919. break
  920. end
  921. end
  922. end
  923.  
  924. settings[cvar] = info
  925. settings[#settings + 1] = info
  926.  
  927. // Create the convar.
  928. CreateClientConVar(cvar, default, (info.Save != false), false)
  929. SetSetting(cvar, _, GetConVarString(cvar))
  930. end
  931. local function GetSetting(self, name)
  932. local cvar = SettingVar(self, name)
  933. if !settings[cvar] then return end
  934. return settings[cvar].Value
  935. end
  936. local function Shutdown()
  937. print("Removing settings callbacks...")
  938. for _, info in ipairs(settings) do
  939. if info.CVar && info.Callback then
  940. local tab = cvars.GetConVarCallbacks(info.CVar)
  941. if tab then
  942. tab[info.Callback] = nil
  943. end
  944. end
  945. end
  946. end
  947. local function SettingsList()
  948. return table.Copy(settings)
  949. end
  950. local function BuildMenu(self, panel)
  951. for _, info in ipairs(settings) do
  952. if info.Show != false then
  953. if info.MultiChoice then
  954. local m = panel:MultiChoice(info.Desc or info.CVar, info.CVar)
  955. for k, v in pairs(info.MultiChoice) do
  956. m:AddChoice(k, v)
  957. end
  958. elseif info.Type == "number" then
  959. panel:NumSlider(info.Desc or info.CVar, info.CVar, info.Min or -1, info.Max or -1, info.Places or 0)
  960. elseif info.Type == "boolean" then
  961. panel:CheckBox(info.Desc or info.CVar, info.CVar)
  962. elseif info.Type == "string" then
  963. panel:TextEntry(info.Desc or info.CVar, info.CVar)
  964. end
  965. end
  966. end
  967. end
  968.  
  969. GB.SettingPrefix = "gb_"
  970. GB.CreateSetting = CreateSetting
  971. GB.Setting = GetSetting
  972. GB.SettingsList = SettingsList
  973. GB.BuildMenu = BuildMenu
  974.  
  975. GB.SettingsShutdown = Shutdown
  976. GB:AddHook("Shutdown", "SettingsShutdown")
  977. end
  978.  
  979.  
  980. // ##################################################
  981. // Targetting - Positions
  982. // ##################################################
  983.  
  984. GB.ModelTarget = {}
  985. function GB:SetModelTarget(model, targ)
  986. self.ModelTarget[model] = targ
  987. end
  988. function GB:BaseTargetPosition(ent)
  989. // The eye attachment is a lot more stable than bones for players.
  990. if type(ent) == "Player" then
  991. local head = EntM["LookupAttachment"](ent, "eyes")
  992. if head then
  993. local pos = EntM["GetAttachment"](ent, head)
  994. if pos then
  995. return pos.Pos - (AngM["Forward"](pos.Ang) * 2)
  996. end
  997. end
  998. end
  999.  
  1000. // Check if the model has a special target assigned to it.
  1001. local special = self.ModelTarget[string.lower(EntM["GetModel"](ent) or "")]
  1002. if special then
  1003. // It's a string - look for a bone.
  1004. if type(special) == "string" then
  1005. local bone = EntM["LookupBone"](ent, special)
  1006. if bone then
  1007. local pos = EntM["GetBonePosition"](ent, bone)
  1008. if pos then
  1009. return pos
  1010. end
  1011. end
  1012. // It's a Vector - return a relative position.
  1013. elseif type(special) == "Vector" then
  1014. return EntM["LocalToWorld"](ent, special)
  1015. // It's a function - do something fancy!
  1016. elseif type(special) == "function" then
  1017. local pos = pcall(special, ent)
  1018. if pos then return pos end
  1019. end
  1020. end
  1021.  
  1022. // Try and use the head bone, found on all of the player + human models.
  1023. local bone = "ValveBiped.Bip01_Head1"
  1024. local head = EntM["LookupBone"](ent, bone)
  1025. if head then
  1026. local pos = EntM["GetBonePosition"](ent, head)
  1027. if pos then
  1028. return pos
  1029. end
  1030. end
  1031.  
  1032. // Give up and return the center of the entity.
  1033. return EntM["LocalToWorld"](ent, EntM["OBBCenter"](ent))
  1034. end
  1035. function GB:TargetPosition(ent)
  1036. local targetPos = self:BaseTargetPosition(ent)
  1037.  
  1038. local ply = LocalPlayer()
  1039. if ValidEntity(ply) then
  1040. targetPos = self:CallHook("TargetPrediction", {ply, ent, targetPos}) or targetPos
  1041. end
  1042.  
  1043. return targetPos
  1044. end
  1045.  
  1046. GB:SetModelTarget("models/crow.mdl", Vector(0, 0, 5)) // Crow.
  1047. GB:SetModelTarget("models/pigeon.mdl", Vector(0, 0, 5)) // Pigeon.
  1048. GB:SetModelTarget("models/seagull.mdl", Vector(0, 0, 6)) // Seagull.
  1049. GB:SetModelTarget("models/combine_scanner.mdl", "Scanner.Body") // Scanner.
  1050. GB:SetModelTarget("models/hunter.mdl", "MiniStrider.body_joint") // Hunter.
  1051. GB:SetModelTarget("models/combine_turrets/floor_turret.mdl", "Barrel") // Turret.
  1052. GB:SetModelTarget("models/dog.mdl", "Dog_Model.Eye") // Dog.
  1053. GB:SetModelTarget("models/vortigaunt.mdl", "ValveBiped.Head") // Vortigaunt.
  1054. GB:SetModelTarget("models/antlion.mdl", "Antlion.Body_Bone") // Antlion.
  1055. GB:SetModelTarget("models/antlion_guard.mdl", "Antlion_Guard.Body") // Antlion guard.
  1056. GB:SetModelTarget("models/antlion_worker.mdl", "Antlion.Head_Bone") // Antlion worker.
  1057. GB:SetModelTarget("models/zombie/fast_torso.mdl", "ValveBiped.HC_BodyCube") // Fast zombie torso.
  1058. GB:SetModelTarget("models/zombie/fast.mdl", "ValveBiped.HC_BodyCube") // Fast zombie.
  1059. GB:SetModelTarget("models/headcrabclassic.mdl", "HeadcrabClassic.SpineControl") // Normal headcrab.
  1060. GB:SetModelTarget("models/headcrabblack.mdl", "HCBlack.body") // Poison headcrab.
  1061. GB:SetModelTarget("models/headcrab.mdl", "HCFast.body") // Fast headcrab.
  1062. GB:SetModelTarget("models/zombie/poison.mdl", "ValveBiped.Headcrab_Cube1") // Poison zombie.
  1063. GB:SetModelTarget("models/zombie/classic.mdl", "ValveBiped.HC_Body_Bone") // Zombie.
  1064. GB:SetModelTarget("models/zombie/classic_torso.mdl", "ValveBiped.HC_Body_Bone") // Zombie torso.
  1065. GB:SetModelTarget("models/zombie/zombie_soldier.mdl", "ValveBiped.HC_Body_Bone") // Zombine.
  1066. GB:SetModelTarget("models/combine_strider.mdl", "Combine_Strider.Body_Bone") // Strider.
  1067. GB:SetModelTarget("models/combine_dropship.mdl", "D_ship.Spine1") // Combine dropship.
  1068. GB:SetModelTarget("models/combine_helicopter.mdl", "Chopper.Body") // Combine helicopter.
  1069. GB:SetModelTarget("models/gunship.mdl", "Gunship.Body") // Combine gunship.
  1070. GB:SetModelTarget("models/lamarr.mdl", "HeadcrabClassic.SpineControl") // Lamarr!
  1071. GB:SetModelTarget("models/mortarsynth.mdl", "Root Bone") // Mortar synth.
  1072. GB:SetModelTarget("models/synth.mdl", "Bip02 Spine1") // Synth.
  1073. GB:SetModelTarget("models/vortigaunt_slave.mdl", "ValveBiped.Head") // Vortigaunt slave.
  1074.  
  1075.  
  1076. // ##################################################
  1077. // Targetting - General
  1078. // ##################################################
  1079.  
  1080. GB.NPCDeathSequences = {}
  1081. function GB:AddNPCDeathSequence(model, sequence)
  1082. self.NPCDeathSequences = self.NPCDeathSequences or {}
  1083. self.NPCDeathSequences[model] = self.NPCDeathSequences[model] or {}
  1084. if !table.HasValue(self.NPCDeathSequences[model]) then
  1085. table.insert(self.NPCDeathSequences[model], sequence)
  1086. end
  1087. end
  1088.  
  1089. GB:AddNPCDeathSequence("models/barnacle.mdl", 4)
  1090. GB:AddNPCDeathSequence("models/barnacle.mdl", 15)
  1091. GB:AddNPCDeathSequence("models/antlion_guard.mdl", 44)
  1092. GB:AddNPCDeathSequence("models/hunter.mdl", 124)
  1093. GB:AddNPCDeathSequence("models/hunter.mdl", 125)
  1094. GB:AddNPCDeathSequence("models/hunter.mdl", 126)
  1095. GB:AddNPCDeathSequence("models/hunter.mdl", 127)
  1096. GB:AddNPCDeathSequence("models/hunter.mdl", 128)
  1097.  
  1098. GB:CreateSetting("friendlyfire", "Target teammates", false)
  1099. function GB:IsValidTarget(ent)
  1100. // We only want players/NPCs.
  1101. local typename = type(ent)
  1102. if typename != "NPC" && typename != "Player" then return false end
  1103.  
  1104. // No invalid entities.
  1105. if !ValidEntity(ent) then return false end
  1106.  
  1107. // Go shoot yourself, emo kid.
  1108. local ply = LocalPlayer()
  1109. if ent == ply then return false end
  1110.  
  1111. if typename == "Player" then
  1112. if !PlyM["Alive"](ent) then return false end // Dead players FTL.
  1113. if !self:Setting("friendlyfire") && PlyM["Team"](ent) == PlyM["Team"](ply) then return false end
  1114. if EntM["GetMoveType"](ent) == MOVETYPE_OBSERVER then return false end // No spectators.
  1115. if EntM["GetMoveType"](ent) == MOVETYPE_NONE then return false end
  1116. //if pl["Team"](ent) == 1001 then return false end
  1117. end
  1118.  
  1119. if typename == "NPC" then
  1120. if EntM["GetMoveType"](ent) == MOVETYPE_NONE then return false end // No dead NPCs.
  1121.  
  1122. // No dying NPCs.
  1123. local model = string.lower(EntM["GetModel"](ent) or "")
  1124. if table.HasValue(self.NPCDeathSequences[model] or {}, EntM["GetSequence"](ent)) then return false end
  1125. end
  1126. end
  1127.  
  1128. GB:CreateSetting("predictblocked", "Predict blocked (time)", 0.4, {Min = 0, Max = 1})
  1129. function GB:BaseBlocked(target, offset)
  1130. local ply = LocalPlayer()
  1131. if !ValidEntity(ply) then return end
  1132.  
  1133. // Trace from the players shootpos to the position.
  1134. local shootPos = PlyM["GetShootPos"](ply)
  1135. local targetPos = self:TargetPosition(target)
  1136.  
  1137. if offset then targetPos = targetPos + offset end
  1138.  
  1139. local trace = util.TraceLine({start = shootPos, endpos = targetPos, filter = {ply, target}, mask = MASK_SHOT})
  1140. local wrongAim = self:AngleBetween(PlyM["GetAimVector"](ply), VecM["GetNormal"](targetPos - shootPos)) > 2
  1141.  
  1142. // If we hit something, we're "blocked".
  1143. if trace.Hit && trace.Entity != target then
  1144. return true, wrongAim
  1145. end
  1146.  
  1147. // It is not blocked.
  1148. return false, wrongAim
  1149. end
  1150. function GB:TargetBlocked(target)
  1151. if !target then target = self:GetTarget() end
  1152. if !target then return end
  1153.  
  1154. local blocked, wrongAim = self:BaseBlocked(target)
  1155. if self:Setting("predictblocked") > 0 && blocked then
  1156. blocked = self:BaseBlocked(target, EntM["GetVelocity"](target) * self:Setting("predictblocked"))
  1157. end
  1158. return blocked, wrongAim
  1159. end
  1160.  
  1161.  
  1162. function GB:SetTarget(ent)
  1163. if self.Target && !ent then
  1164. self:CallHook("TargetLost")
  1165. elseif !self.Target && ent then
  1166. self:CallHook("TargetGained")
  1167. elseif self.Target && ent && self.Target != ent then
  1168. self:CallHook("TargetChanged")
  1169. end
  1170.  
  1171. self.Target = ent
  1172. end
  1173. function GB:GetTarget()
  1174. if ValidEntity(self.Target) != false then
  1175. return self.Target
  1176. else
  1177. return false
  1178. end
  1179. end
  1180.  
  1181. GB:CreateSetting("maxangle", "Max angle", 30, {Min = 5, Max = 90})
  1182. GB:CreateSetting("targetblocked", "Don't check LOS", false)
  1183. GB:CreateSetting("holdtarget", "Hold targets", false)
  1184. function GB:FindTarget()
  1185. if !self:Enabled() then return end
  1186.  
  1187. local ply = LocalPlayer()
  1188. if !ValidEntity(ply) then return end
  1189.  
  1190. local maxAng = self:Setting("maxangle")
  1191. local aimVec, shootPos = PlyM["GetAimVector"](ply), PlyM["GetShootPos"](ply)
  1192. local targetBlocked = self:Setting("targetblocked")
  1193.  
  1194. if self:Setting("holdtarget") then
  1195. local target = self:GetTarget()
  1196. if target then
  1197. local targetPos = self:TargetPosition(target)
  1198. local angle = self:AngleBetween(AngM["Forward"](self:GetView()), VecM["GetNormal"](targetPos - shootPos))
  1199. local blocked = self:TargetBlocked(target)
  1200. if angle <= maxAng && (!blocked || targetBlocked) then return end
  1201. end
  1202. end
  1203.  
  1204. // Filter out targets.
  1205. local targets = ents.GetAll()
  1206. for i, ent in pairs(targets) do
  1207. if self:IsValidTarget(ent) == false then
  1208. targets[i] = nil
  1209. end
  1210. end
  1211.  
  1212. local closestTarget, lowestAngle = _, maxAng
  1213. for _, target in pairs(targets) do
  1214. if targetBlocked || !self:TargetBlocked(target) then
  1215. local targetPos = self:TargetPosition(target)
  1216. local angle = self:AngleBetween(AngM["Forward"](self:GetView()), VecM["GetNormal"](targetPos - shootPos))
  1217.  
  1218. if angle < lowestAngle then
  1219. lowestAngle = angle
  1220. closestTarget = target
  1221. end
  1222. end
  1223. end
  1224.  
  1225. self:SetTarget(closestTarget)
  1226. end
  1227. GB:AddHook("Think", "FindTarget")
  1228.  
  1229.  
  1230. // ##################################################
  1231. // Fake view
  1232. // ##################################################
  1233.  
  1234. GB.View = Angle(0, 0, 0)
  1235. function GB:GetView()
  1236. return self.View * 1
  1237. end
  1238. function GB:KeepView()
  1239. if !self:Enabled() then return end
  1240.  
  1241. local ply = LocalPlayer()
  1242. if !ValidEntity(ply) then return end
  1243.  
  1244. self.View = EntM["EyeAngles"](ply)
  1245. end
  1246. GB:AddHook("OnToggled", "KeepView")
  1247.  
  1248. local sensitivity = 0.022
  1249. function GB:RotateView(cmd)
  1250. self.View.p = math.Clamp(self.View.p + (CmdM["GetMouseY"](cmd) * sensitivity), -89, 89)
  1251. self.View.y = math.NormalizeAngle(self.View.y + (CmdM["GetMouseX"](cmd) * sensitivity * -1))
  1252. end
  1253.  
  1254. GB:CreateSetting("debug", "Debug", false, {Show = false})
  1255. function GB:FakeView(ply, origin, angles, FOV)
  1256. if !self:Enabled() && !self.SetAngleTo then return end
  1257. if GetViewEntity() != LocalPlayer() then return end
  1258. if self:Setting("debug") then return end
  1259.  
  1260. local base = GAMEMODE:CalcView(ply, origin, self.SetAngleTo or self.View, FOV) or {}
  1261. base.angles = base.angles or (self.AngleTo or self.View)
  1262. base.angles.r = 0 // No crappy screen tilting in ZS.
  1263. return base
  1264. end
  1265. GB:AddHook("CalcView", "FakeView")
  1266.  
  1267.  
  1268. function GB:TargetPrediction(ply, target, targetPos)
  1269. local weap = PlyM["GetActiveWeapon"](ply)
  1270. if ValidEntity(weap) then
  1271. local class = EntM["GetClass"](weap)
  1272. if class == "weapon_crossbow" then
  1273. local dist = VecM["Length"](targetPos - PlyM["GetShootPos"](ply))
  1274. local time = (dist / 3500) + 0.05 // About crossbow bolt speed.
  1275. targetPos = targetPos + (EntM["GetVelocity"](target) * time)
  1276. end
  1277.  
  1278. local mul = 0.0075
  1279. //targetPos = targetPos - (e["GetVelocity"](ply) * mul)
  1280. end
  1281.  
  1282. return targetPos
  1283. end
  1284. GB:AddHook("TargetPrediction", "TargetPrediction")
  1285.  
  1286. // ##################################################
  1287. // Aim
  1288. // ##################################################
  1289.  
  1290. function GB:SetAngle(ang)
  1291. self.SetAngleTo = ang
  1292. end
  1293.  
  1294. GB:CreateSetting("smoothspeed", "Smooth aim speed (0 to disable)", 120, {Min = 0, Max = 360})
  1295. GB:CreateSetting("snaponfire", "Snap on fire", true)
  1296. GB:CreateSetting("snapgrace", "Snap on fire grace", 0.5, {Min = 0, Max = 3, Places = 1})
  1297. GB.LastAttack = 0
  1298. function GB:SetAimAngles(cmd)
  1299. self:RotateView(cmd)
  1300.  
  1301. if !self:Enabled() && !self.SetAngleTo then return end
  1302.  
  1303. local ply = LocalPlayer()
  1304. if !ValidEntity(ply) then return end
  1305.  
  1306. // We're aiming with the view, normally.
  1307. local targetAim = self:GetView()
  1308.  
  1309. // If we have a target, aim at them!
  1310. local target = self:GetTarget()
  1311. if target then
  1312. local targetPos = self:TargetPosition(target)
  1313. targetAim = VecM["Angle"](targetPos - ply:GetShootPos())
  1314. end
  1315.  
  1316. // We're following the view, until we fire.
  1317. if self:Setting("snaponfire") then
  1318. local time = CurTime()
  1319. if PlyM["KeyDown"](ply, IN_ATTACK) || PlyM["KeyDown"](ply, IN_ATTACK2) || self:Setting("autoshoot") != 0 then
  1320. self.LastAttack = time
  1321. end
  1322. if CurTime() - self.LastAttack > self:Setting("snapgrace") then
  1323. targetAim = self:GetView()
  1324. end
  1325. end
  1326.  
  1327. // We want to change to whatever was SetAngle'd.
  1328. if self.SetAngleTo then
  1329. targetAim = self.SetAngleTo
  1330. end
  1331.  
  1332. // Smooth aiming.
  1333. local smooth = self:Setting("smoothspeed")
  1334. if smooth > 0 then
  1335. local current = CmdM["GetViewAngles"](cmd)
  1336.  
  1337. // Approach the target angle.
  1338. current = self:ApproachAngle(current, targetAim, smooth * FrameTime())
  1339. current.r = 0
  1340.  
  1341. // If we're just following the view, we don't need to smooth it.
  1342. if self.RevertingAim then
  1343. local diff = self:NormalizeAngle(current - self:GetView())
  1344. if math.abs(diff.p) < 1 && math.abs(diff.y) < 1 then self.RevertingAim = false end
  1345. elseif targetAim == self:GetView() then
  1346. current = targetAim
  1347. end
  1348.  
  1349. // Check if the angles are the same...
  1350. if self.SetAngleTo then
  1351. local diff = self:NormalizeAngle(current - self.SetAngleTo)
  1352. if math.abs(diff.p) < 1 && math.abs(diff.y) < 1 then self.SetAngleTo = nil end
  1353. end
  1354.  
  1355. aim = current
  1356. else
  1357. aim = targetAim
  1358. self.SetAngleTo = nil
  1359. end
  1360.  
  1361. // Set the angles.
  1362. CmdM["SetViewAngles"](cmd, aim)
  1363. local sensitivity = 0.22
  1364. local diff = aim - CmdM["GetViewAngles"](cmd)
  1365. CmdM["SetMouseX"](cmd, diff.y / sensitivity)
  1366. CmdM["SetMouseY"](cmd, diff.p / sensitivity)
  1367.  
  1368.  
  1369. // Change the players movement to be relative to their view instead of their aim.
  1370. local move = Vector(CmdM["GetForwardMove"](cmd), CmdM["GetSideMove"](cmd), 0)
  1371. local norm = VecM["GetNormal"](move)
  1372. local set = AngM["Forward"](VecM["Angle"](norm) + (aim - self:GetView())) * VecM["Length"](move)
  1373. CmdM["SetForwardMove"](cmd, set.x)
  1374. CmdM["SetSideMove"](cmd, set.y)
  1375. end
  1376. GB:AddHook("CreateMove", "SetAimAngles")
  1377.  
  1378. function GB:RevertAim()
  1379. self.RevertingAim = true
  1380. end
  1381. GB:AddHook("TargetLost", "RevertAim")
  1382. function GB:StopRevertAim()
  1383. self.RevertingAim = false
  1384. end
  1385. GB:AddHook("TargetGained", "RevertAim")
  1386.  
  1387. // When we turn off the bot, we want our aim to go back to our view.
  1388. function GB:ViewToAim()
  1389. if self:Enabled() then return end
  1390. self:SetAngle(self:GetView())
  1391. end
  1392. GB:AddHook("OnToggled", "ViewToAim")
  1393.  
  1394.  
  1395. // ##################################################
  1396. // HUD
  1397. // ##################################################
  1398.  
  1399. GB:CreateSetting("crosshair", "Crosshair size (0 to disable)", 18, {Min = 0, Max = 20})
  1400. function GB:DrawTarget()
  1401. if !self:Enabled() then return end
  1402.  
  1403. local target = self:GetTarget()
  1404. if !target then return end
  1405.  
  1406. local size = self:Setting("crosshair")
  1407. if size <= 0 then return end
  1408.  
  1409. // Change colour on the block status.
  1410. local blocked, aimOff = self:TargetBlocked()
  1411. if blocked then
  1412.  
  1413. if GetConVar("gear_screenshot"):GetInt() == 0 then
  1414.  
  1415. surface.SetDrawColor(255, 0, 0, 255) // Red.
  1416.  
  1417. end
  1418.  
  1419. elseif aimOff then
  1420.  
  1421. if GetConVar("gear_screenshot"):GetInt() == 0 then
  1422.  
  1423. surface.SetDrawColor(255, 255, 0, 255) // Yellow.
  1424. else
  1425. surface.SetDrawColor(0, 255, 0, 255) // Green.
  1426. end
  1427. end
  1428.  
  1429. // Get the onscreen coordinates for the target.
  1430. local pos = self:TargetPosition(target)
  1431.  
  1432. local screen = VecM["ToScreen"](pos)
  1433. local x, y = screen.x, screen.y
  1434.  
  1435. // Work out sizes.
  1436. local a, b = size / 2, size / 6
  1437.  
  1438. if GetConVar("gear_screenshot"):GetInt() == 0 then
  1439.  
  1440. // Top left.
  1441. surface.DrawLine(x - a, y - a, x - b, y - a)
  1442. surface.DrawLine(x - a, y - a, x - a, y - b)
  1443.  
  1444. // Bottom right.
  1445. surface.DrawLine(x + a, y + a, x + b, y + a)
  1446. surface.DrawLine(x + a, y + a, x + a, y + b)
  1447.  
  1448. // Top right.
  1449. surface.DrawLine(x + a, y - a, x + b, y - a)
  1450. surface.DrawLine(x + a, y - a, x + a, y - b)
  1451.  
  1452. // Bottom left.
  1453. surface.DrawLine(x - a, y + a, x - b, y + a)
  1454. surface.DrawLine(x - a, y + a, x - a, y + b)
  1455.  
  1456. end
  1457.  
  1458. end
  1459. GB:AddHook("HUDPaint", "DrawTarget")
  1460.  
  1461.  
  1462. GB.ScreenMaxAngle = {
  1463. Length = 0,
  1464. FOV = 0,
  1465. MaxAngle = 0
  1466. }
  1467. GB:CreateSetting("draw_maxangle", "Draw Max Angle", true)
  1468. function GB:DrawMaxAngle()
  1469. if !self:Enabled() then return end
  1470.  
  1471. // Check that we want to be drawing this...
  1472. local show = GB:Setting("draw_maxangle")
  1473. if !show then return end
  1474.  
  1475. // We need a player for this to work...
  1476. local ply = LocalPlayer()
  1477. if !ValidEntity(ply) then return end
  1478.  
  1479. local info = self.ScreenMaxAngle
  1480. local maxang = GB:Setting("maxangle")
  1481.  
  1482. local fov = PlyM["GetFOV"](ply)
  1483. if GetViewEntity() == ply && (maxang != info.MaxAngle || fov != info.FOV) then
  1484. local view = self:GetView()
  1485. view.p = view.p + maxang
  1486.  
  1487. local screen = (PlyM["GetShootPos"](ply) + (AngM["Forward"](view) * 100))
  1488. screen = VecM["ToScreen"](screen)
  1489.  
  1490. info.Length = math.abs((ScrH() / 2) - screen.y)
  1491.  
  1492. info.MaxAngle = maxang
  1493. info.FOV = fov
  1494. end
  1495.  
  1496. local length = info.Length
  1497.  
  1498. local cx, cy = ScrW() / 2, ScrH() / 2
  1499. for x = -1, 1 do
  1500. for y = -1, 1 do
  1501. if x != 0 || y != 0 then
  1502.  
  1503. if GetConVar("gear_screenshot"):GetInt() == 0 then
  1504.  
  1505. local add = VecM["GetNormal"](Vector(x, y, 0)) * length
  1506. surface.SetDrawColor(0, 0, 0, 255)
  1507. surface.DrawRect((cx + add.x) - 2, (cy + add.y) - 2, 5, 5)
  1508. surface.SetDrawColor(255, 255, 255, 255)
  1509. surface.DrawRect((cx + add.x) - 1, (cy + add.y) - 1, 3, 3)
  1510.  
  1511. end
  1512. end
  1513. end
  1514. end
  1515.  
  1516. end
  1517. GB:AddHook("HUDPaint", "DrawMaxAngle")
  1518.  
  1519. // ##################################################
  1520. // Auto-shoot
  1521. // ##################################################
  1522.  
  1523. GB.AttackDown = false
  1524. function GB:SetShooting(bool)
  1525. if self.AttackDown == bool then return end
  1526. self.AttackDown = bool
  1527.  
  1528. local pre = {[true] = "+", [false] = "-"}
  1529. RunConsoleCommand(pre[bool] .. "attack")
  1530. end
  1531.  
  1532. GB.NextShot = 0
  1533. GB:CreateSetting("autoshoot", "Max auto-shoot distance (0 to disable)", 0, {Min = 0, Max = 16384})
  1534. function GB:Shoot()
  1535. if !self:Enabled() then
  1536. self:SetShooting(false)
  1537. return
  1538. end
  1539.  
  1540. // Get the maximum distance.
  1541. local maxDist = self:Setting("autoshoot")
  1542. if maxDist == 0 then return end
  1543.  
  1544. // Check we've got something to shoot at...
  1545. local target = self:GetTarget()
  1546. if !target then return end
  1547.  
  1548. // Don't shoot until we can hit, you idiot!
  1549. local blocked, wrongAim = self:TargetBlocked(target)
  1550. if blocked || wrongAim then return end
  1551.  
  1552. // We're gonna need the player object in a second.
  1553. local ply = LocalPlayer()
  1554. if !ValidEntity(ply) then return end
  1555.  
  1556. // Check we're within our maximum distance.
  1557. local targetPos = self:TargetPosition(target)
  1558. local distance = VecM["Length"](targetPos - ply:GetShootPos())
  1559. if distance > maxDist && maxDist != -1 then return end
  1560.  
  1561. // Check if it's time to shoot yet.
  1562. if CurTime() < self.NextShot then return end
  1563.  
  1564. // Check we got our weapon.
  1565. local weap = PlyM["GetActiveWeapon"](ply)
  1566. if !ValidEntity(weap) then return end
  1567.  
  1568. // Shoot!
  1569. self:SetShooting(true)
  1570. // If we're semi-auto, we want to stop holding down fire.
  1571. if self:IsSemiAuto(weap) then
  1572. timer.Simple(0.05, function() self:SetShooting(false) end)
  1573. end
  1574.  
  1575. // Set the next time to shoot.
  1576. self.NextShot = CurTime() + 0.1
  1577. end
  1578. GB:AddHook("Think", "Shoot")
  1579.  
  1580. // When we lose our target we stop shooting.
  1581. function GB:StopShooting()
  1582. self:SetShooting(false)
  1583. end
  1584. GB:AddHook("TargetLost", "StopShooting")
  1585.  
  1586. // ##################################################
  1587. // Toggle
  1588. // ##################################################
  1589.  
  1590. GB.IsEnabled = false
  1591. function GB:Enabled() return self.IsEnabled end
  1592.  
  1593. function GB:SetEnabled(bool)
  1594. if self.IsEnabled == bool then return end
  1595. self.IsEnabled = bool
  1596.  
  1597. local message = {[true] = "ON", [false] = "OFF"}
  1598. print("AutoAim " .. message[self.IsEnabled])
  1599.  
  1600. local e = {[true] = "1", [false] = "0"}
  1601. RunConsoleCommand("gb_enabled", e[self.IsEnabled])
  1602.  
  1603. self:CallHook("OnToggled")
  1604. end
  1605.  
  1606. function GB:Toggle()
  1607. self:SetEnabled(!self:Enabled())
  1608. end
  1609. concommand.Add("gb_toggle", function() GB:Toggle() end)
  1610.  
  1611. GB:CreateSetting("enabled", "Enabled", false, {Save = false})
  1612. function GB:ConVarEnabled(_, old, val)
  1613. if old == val then return end
  1614. val = tonumber(val) or 0
  1615. self:SetEnabled(val > 0)
  1616. end
  1617. GB:AddCVarHook("gb_enabled", "ConVarEnabled")
  1618.  
  1619. concommand.Add("+GB", function() GB:SetEnabled(true) end)
  1620. concommand.Add("-GB", function() GB:SetEnabled(false) end)
  1621.  
  1622. // ##################################################
  1623. // Menu
  1624. // ##################################################
  1625.  
  1626. function GB:OpenMenu()
  1627. local w, h = ScrW() / 3, ScrH() / 2
  1628.  
  1629. local menu = vgui.Create("DFrame")
  1630. menu:SetTitle("AutoAim")
  1631. menu:SetSize(w, h)
  1632. menu:Center()
  1633. menu:MakePopup()
  1634.  
  1635. local scroll = vgui.Create("DPanelList", menu)
  1636. scroll:SetPos(5, 25)
  1637. scroll:SetSize(w - 10, h - 30)
  1638. scroll:EnableVerticalScrollbar()
  1639.  
  1640. local form = vgui.Create("DForm", menu)
  1641. form:SetName("")
  1642. form.Paint = function() end
  1643. scroll:AddItem(form)
  1644.  
  1645. self:BuildMenu(form)
  1646.  
  1647. if GB.Menu then GB.Menu:Remove() end
  1648. GB.Menu = menu
  1649. end
  1650. concommand.Add("gb_menu", function() GB:OpenMenu() end)
  1651.  
  1652. function GB:RegisterMenu()
  1653. spawnmenu.AddToolMenuOption("Options", "Hacks", "AutoAim", "AutoAim", "", "", function(p) self:BuildMenu(p) end)
  1654. end
  1655. GB:AddHook("PopulateToolMenu", "RegisterMenu")
  1656.  
  1657. // ##################################################
  1658. // Useful functions
  1659. // ##################################################
  1660.  
  1661. function GB:AngleBetween(a, b)
  1662. return math.deg(math.acos(VecM["Dot"](a, b)))
  1663. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement