Advertisement
Guest User

Untitled

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