Advertisement
Ultranite

Untitled

Dec 9th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.17 KB | None | 0 0
  1. /* Global Variables */
  2. var local = Entity.GetLocalPlayer();
  3. var targetIndex = -1;
  4. var target = -1;
  5. var distance;
  6. var rageTarget = 0;
  7. var rbotShots = 0;
  8. var target = -1;
  9. var lastShot;
  10. var waiting;
  11. var wepList = {
  12. 0: "Auto",
  13. 1: "AWP",
  14. 2: "Scout",
  15. 3: "Rifle",
  16. 4: "SMG",
  17. 5: "Heavy Pistol",
  18. 6: "Pistol"
  19. };
  20. var binlib = {};
  21. /* ---------------- */
  22. setup();
  23. /* Functions */
  24. function calcDist(local, target) {
  25. lx = local[0];
  26. ly = local[1];
  27. lz = local[2];
  28. tx = target[0];
  29. ty = target[1];
  30. tz = target[2];
  31. dx = lx - tx;
  32. dy = ly - ty;
  33. dz = lz - tz;
  34. return Math.sqrt(dx * dx + dy * dy + dz * dz);
  35. }
  36.  
  37. function pickTarget() {
  38. if (!UI.GetValue("Script Items", "[AHC] Enable Adaptive Hitchance") || !Entity.IsAlive(local))
  39. return;
  40. if (target == undefined || target == -1 || !Entity.IsValid(target) || !Entity.IsAlive(target)) {
  41. if (rageTarget == 1) {
  42. waiting = 1;
  43. }
  44. }
  45. if (secondsElapsed >= 5) {
  46. rageTarget = 0;
  47. secondsElapsed = 0;
  48. waiting = 0;
  49. }
  50. var enemies = Entity.GetEnemies();
  51. var tempGuess = -1;
  52. var localPos = Entity.GetHitboxPosition(local, 5);
  53. for (var i = 0; i < enemies.length; i++) {
  54. if (!Entity.IsValid(enemies[i]) || !Entity.IsAlive(enemies[i])) {
  55. continue;
  56. }
  57. if (tempGuess == undefined || !Entity.IsValid(tempGuess) || !Entity.IsAlive(tempGuess) || Entity.IsDormant(
  58. tempGuess)) {
  59. tempGuess = enemies[i];
  60. continue;
  61. }
  62. targetPos = Entity.GetHitboxPosition(tempGuess, 5);
  63. enemyPos = Entity.GetHitboxPosition(enemies[i], 5);
  64. if (calcDist(localPos, enemyPos) < calcDist(localPos, targetPos)) {
  65. tempGuess = enemies[i];
  66. continue;
  67. }
  68. }
  69. targetIndex = tempGuess;
  70. targetPos = Entity.GetHitboxPosition(targetIndex, 5);
  71. if (rageTarget == 0)
  72. adjustHitchance(calcDist(localPos, targetPos));
  73. }
  74.  
  75. function onShot() {
  76. if (!UI.GetValue("Script Items", "[AHC] Enable Adaptive Hitchance"))
  77. return;
  78. target = Event.GetInt("target_index");
  79. if (!Entity.IsValid(targetIndex) || !Entity.IsAlive(targetIndex) || !Entity.IsDormant(targetIndex)) {
  80. waiting = 1;
  81. target = -1;
  82. return;
  83. }
  84. targetIndex = target;
  85. rageTarget = 1;
  86. secondsElapsed = 0;
  87. targetPos = Entity.GetHitboxPosition(targetIndex, 5);
  88. localPos = Entity.GetHitboxPosition(local, 5);
  89. adjustHitchance(calcDist(localPos, targetPos));
  90. }
  91.  
  92. function drawIndicator() {
  93. if (!UI.GetValue("Script items", "[AHC] Show Indicators"))
  94. return;
  95. if (!Entity.IsAlive(local))
  96. return;
  97. if (targetIndex == -1 || targetIndex == undefined) {
  98. return;
  99. }
  100. if (!Entity.IsValid(targetIndex) || !Entity.IsAlive(targetIndex)) {
  101. return;
  102. }
  103. targetPos = Entity.GetHitboxPosition(targetIndex, 5);
  104. localPos = Entity.GetHitboxPosition(local, 5);
  105. if (calcDist(localPos, targetPos) >= 2000)
  106. return;
  107. var worldPos = Entity.GetRenderOrigin(targetIndex);
  108. var loc = Render.WorldToScreen(worldPos);
  109. var color = UI.GetColor("Script items", "[AHC] Target Indicator");
  110. Render.Circle(loc[0], loc[1] - 142, 20, color);
  111. Render.String(loc[0] - 7, loc[1] - 160, 0, "!", color, 24);
  112.  
  113. if(!UI.GetValue("Script items", "[AHC] Hitchance Indicator"))
  114. return;
  115.  
  116. screenSize = Render.GetScreenSize();
  117. position = UI.GetString("Script items", "[AHC] Hitchance Indicator Position");
  118. color = [0,255,0,255];
  119. hitchance = UI.GetValue("Rage", weaponType().toUpperCase, "Accuracy", "Hitchance");
  120. if(hitchance > 65)
  121. color = [0,255,0,255];
  122. else
  123. if(hitchance > 45)
  124. color = [255,255,0,255];
  125. else
  126. color = [255,0,0,255];
  127.  
  128. x = 0;
  129. y = 0;
  130.  
  131. switch(position) {
  132. case "Top Left":
  133. x = (screenSize[0] - (screenSize[0]-50));
  134. y = (screenSize[1] - (screenSize[1]-50));
  135. break;
  136. case "Bottom Left":
  137. x = (screenSize[0] - (screenSize[0]-50));
  138. y = (screenSize[1] - 50);
  139. break;
  140. case "Top Right":
  141. x = (screenSize[0] - 50);
  142. y = (screenSize[1] - 50);
  143. break;
  144. case "Bottom Right":
  145. x = (screenSize[0] - 50);
  146. y = (screenSize[1] - (screenSize[1]-50));
  147. break;
  148. }
  149.  
  150. Render.String(x,y,0,"HC:"+hitchance, color, 30);
  151. }
  152.  
  153. function drawInMenu() {
  154. var opts = UI.GetString("[AHC] Weapon Config");
  155. var dt = UI.GetValue("[AHC] Adaptive Doubletap");
  156. var inAir = UI.GetValue("[AHC] In-Air HC");
  157. for (var weapon in wepList) {
  158. UI.SetEnabled("Script items", wepList[weapon] + " Max HC", opts == wepList[weapon]);
  159. UI.SetEnabled("Script items", wepList[weapon] + " Min HC", opts == wepList[weapon]);
  160. UI.SetEnabled("Script items", wepList[weapon] + " Playstyle", opts == wepList[weapon]);
  161. }
  162. UI.SetEnabled("Script items", "SMG In-Air HC", opts == "SMG" && inAir);
  163. UI.SetEnabled("Script items", "Scout In-Air HC", opts == "Scout" && inAir);
  164. UI.SetEnabled("Script items", "Heavy Pistol In-Air HC", opts == "Heavy Pistol" && inAir);
  165. UI.SetEnabled("Script items", "Doubletap Max HC", dt);
  166. UI.SetEnabled("Script items", "Doubletap Min HC", dt);
  167. }
  168.  
  169. function weaponType() {
  170. var weapon = Entity.GetName(Entity.GetWeapon(local));
  171. var weapons = {
  172. "usp s": "Pistol",
  173. "glock 18": "Pistol",
  174. "p2000": "Pistol",
  175. "dual berettas": "Pistol",
  176. "r8 revolver": "Heavy Pistol",
  177. "desert eagle": "Heavy Pistol",
  178. "p250": "Pistol",
  179. "tec9": "Pistol",
  180. "mp9": "SMG",
  181. "mac 10": "SMG",
  182. "ump 45": "SMG",
  183. "ak 47": "Rifle",
  184. "sg 553": "Rifle",
  185. "aug": "Rifle",
  186. "m4a1 s": "Rifle",
  187. "m4a4": "Rifle",
  188. "ssg 08": "Scout",
  189. "awp": "AWP",
  190. "g3sg1": "Auto",
  191. "scar 20": "Auto"
  192. };
  193. return weapons[weapon];
  194. }
  195.  
  196. function adjustHitchance(distance) {
  197.  
  198. if (weaponType() == undefined)
  199. return;
  200. var enabledWeps = fetchDropdown("[AHC] Enabled Weapons");
  201. if (enabledWeps.indexOf(weaponType()) == -1)
  202. return;
  203.  
  204. maxHC = UI.GetValue("Script items", weaponType() + " Max HC", "Integer");
  205. minHC = UI.GetValue("Script items", weaponType() + " Min HC", "Integer");
  206. dtMaxHC = UI.GetValue("Script items", "Doubletap Max HC");
  207. dtMinHC = UI.GetValue("Script items", "Doubletap Min HC");
  208. fv = Entity.GetProp(local, "CBasePlayer", "m_flFallVelocity");
  209. inAir = false;
  210. playstyle = UI.GetString("Script items", weaponType() + " Playstyle");
  211. mode = UI.GetString("Script items", "[AHC] Mode");
  212. inacc = Local.GetInaccuracy();
  213.  
  214. if (fv < -1 || fv > 1)
  215. inAir = true;
  216. else
  217. inAir = false;
  218.  
  219. if (UI.GetValue("[AHC] Adaptive Doubletap")) {
  220. dtVal = playstyle == "Agressive" ? dtEquation(dtMinHC, dtMaxHC) - 30 : dtEquation(dtMinHC, dtMaxHC);
  221. if (isNaN(dtVal))
  222. dtVal = dtMinHC;
  223. UI.SetValue("Rage", "GENERAL", "Exploits", "Doubletap hitchance", dtVal);
  224. }
  225. if (weaponType() == "Heavy Pistol" || weaponType() == "Scout" || weaponType() == "SMG")
  226. inAirVal = UI.GetValue("Script items", weaponType() + " In-Air HC", "Integer");
  227. else
  228. inAirVal = minHC;
  229.  
  230. hcVal = playstyle == "Agressive" ? hcEquation(minHC, maxHC) - 15 : hcEquation(minHC, maxHC);
  231. if (hcVal == undefined || hcVal < 0 || isNaN(hcVal)) {
  232. hcVal = minHC;
  233. }
  234.  
  235. if(inacc > .04 && UI.GetValue("Script items", "[AHC] Account for inaccuracy")) {
  236. hcVal-=inacc*55;
  237. inAirVal-=inacc*15;
  238. }
  239.  
  240. if (weaponType() == "SMG" || weaponType() == "Rifle")
  241. UI.SetValue("Rage", "GENERAL", "Accuracy", "Hitchance", inAir ? inAirVal : hcVal);
  242. else
  243. UI.SetValue("Rage", weaponType().toUpperCase(), "Accuracy", "Hitchance", inAir ? inAirVal : hcVal);
  244.  
  245. function hcEquation(min, max) {
  246. if (mode == "Decreasing")
  247. return Math.round(Math.min(Math.max((1 / 250) * (100 * (distance / 20)) + min, min), max));
  248. else
  249. if (mode == "Increasing")
  250. return Math.round(Math.min(Math.max((-1 / 250) * (100 * (distance / 20)) + max, min), max));
  251. }
  252.  
  253. function dtEquation(min, max) {
  254. if (mode == "Decreasing")
  255. return Math.round(Math.min(Math.max((1 / 125) * (100 * (distance / 20)) + min, min), max));
  256. else
  257. if (mode == "Increasing")
  258. return Math.round(Math.min(Math.max((-1 / 125) * (100 * (distance / 20)) + max, min), max));
  259. }
  260. }
  261.  
  262. function setup() {
  263. UI.AddCheckbox("[AHC] Enable Adaptive Hitchance");
  264. UI.AddCheckbox("[AHC] Show Indicators");
  265. UI.AddColorPicker("[AHC] Target Indicator");
  266. UI.AddCheckbox("[AHC] Hitchance Indicator");
  267. UI.AddDropdown("[AHC] Hitchance Indicator Position", ["Top Left", "Bottom Left", "Top Right", "Bottom Right"]);
  268. UI.SetColor("Script items", "[AHC] Target Indicator", [255, 0, 255, 255]);
  269. UI.AddCheckbox("[AHC] Use Config Settings");
  270. UI.AddDropdown("[AHC] Mode", ["Increasing", "Decreasing"]);
  271. UI.AddCheckbox("[AHC] In-Air HC");
  272. UI.AddCheckbox("[AHC] Account for inaccuracy")
  273. createDropdown("[AHC] Enabled Weapons", ["Auto", "Scout", "AWP", "Rifle", "SMG", "Pistol", "Heavy Pistol"], true);
  274. UI.AddCheckbox("[AHC] Adaptive Doubletap");
  275. UI.AddSliderInt("Doubletap Max HC", 0, 100);
  276. UI.AddSliderInt("Doubletap Min HC", 0, 100);
  277. UI.AddDropdown("[AHC] Weapon Config", ["Auto", "Scout", "AWP", "Rifle", "SMG", "Pistol", "Heavy Pistol"]);
  278. for (weapon in wepList) {
  279. UI.AddDropdown(wepList[weapon] + " Playstyle", ["Agressive", "Passive"]);
  280. UI.AddSliderInt(wepList[weapon] + " Max HC", 0, 100);
  281. UI.AddSliderInt(wepList[weapon] + " Min HC", 0, 100);
  282. }
  283. UI.AddSliderInt("Scout In-Air HC", 0, 100);
  284. UI.AddSliderInt("SMG In-Air HC", 0, 100);
  285. UI.AddSliderInt("Heavy Pistol In-Air HC", 0, 100);
  286. Cheat.PrintColor([255, 75, 100, 25],
  287. "\n------------------------\n[AHC] v1.3 by Ultranite\n------------------------\n");
  288. /*
  289. * HOW TO CONFIG SETTINGS
  290. * Enable the config button and reload the script, all settings will be set
  291. * to the values below.
  292. *
  293. * You can set a default value by doing the following:
  294. * UI.SetValue("Script items", "name of option/slider", value);
  295. *
  296. * In order to pick a mode or playstyle, simply set 0 for increasing/agressive (accordingly)
  297. * and 1 for decreasing/passive.
  298. *
  299. * In order to config the enabled weapons, you need to think of it as binary value.
  300. * For example: If you want to enabled Auto, Scout, and AWP, the total you'd need to
  301. * set the dropdown to would be 7.
  302. *
  303. * Bits go in this order:
  304. * 1, 2, 4, 8, 16, 32, 64, 128
  305. *
  306. * All you have to do is find the position of the gun(s) you want enabled and
  307. * add the values of the list above that are in the same position.
  308. *
  309. * Checkboxes are set as true/false.
  310. *
  311. * Colors can be set in the format of [r,g,b,alpha]
  312. *
  313. * If you ever wonder how to use something, check the forums:
  314. * https://onetap.su/resources/
  315. *
  316. * Add me on discord @Ultranite#9259 for help.
  317. *
  318. */
  319. if (!UI.GetValue("[AHC] Use Config Settings"))
  320. return;
  321. UI.SetValue("Script items", "[AHC] Enable Adaptive Hitchance", true);
  322. UI.SetValue("Script items", "[AHC] Show Indicators", true);
  323. UI.SetValue("Script items", "[AHC] Mode", 1);
  324. UI.SetValue("Script items", "[AHC] In-Air HC", true);
  325. UI.SetValue("Script items", "[AHC] Account for inaccuracy", true);
  326. UI.SetValue("Script items", "[AHC] Adaptive Doubletap", true);
  327. UI.SetValue("Script items", "Doubletap Max HC", 45);
  328. UI.SetValue("Script items", "Doubletap Min HC", 0);
  329. UI.SetValue("Script items", "[AHC] Enabled Weapons", 127);
  330. // PER WEAPON
  331. UI.SetValue("Script items", "Auto Playstyle", 0);
  332. UI.SetValue("Script items", "Auto Max HC", 86);
  333. UI.SetValue("Script items", "Auto Min HC", 63);
  334. UI.SetValue("Script items", "AWP Playstyle", 0);
  335. UI.SetValue("Script items", "AWP Max HC", 87);
  336. UI.SetValue("Script items", "AWP Min HC", 60);
  337. UI.SetValue("Script items", "Scout Playstyle", 0);
  338. UI.SetValue("Script items", "Scout Max HC", 91);
  339. UI.SetValue("Script items", "Scout Min HC", 63);
  340. UI.SetValue("Script items", "Scout In-Air HC", 55);
  341. UI.SetValue("Script items", "Rifle Playstyle", 0);
  342. UI.SetValue("Script items", "Rifle Max HC", 65);
  343. UI.SetValue("Script items", "Rifle Min HC", 35);
  344. UI.SetValue("Script items", "SMG Playstyle", 0);
  345. UI.SetValue("Script items", "SMG Max HC", 29);
  346. UI.SetValue("Script items", "SMG Min HC", 12);
  347. UI.SetValue("Script items", "SMG In-Air HC", 12);
  348. UI.SetValue("Script items", "Pistol Playstyle", 0);
  349. UI.SetValue("Script items", "Pistol Max HC", 40);
  350. UI.SetValue("Script items", "Pistol Min HC", 15);
  351. UI.SetValue("Script items", "Heavy Pistol Playstyle", 0);
  352. UI.SetValue("Script items", "Heavy Pistol Max HC", 89);
  353. UI.SetValue("Script items", "Heavy Pistol Min HC", 62);
  354. UI.SetValue("Script items", "Heavy Pistol In-Air HC", 0);
  355. }
  356. runTime = Global.Curtime();
  357. var secondsElapsed = 0;
  358.  
  359. function check() {
  360. if (waiting == 1) {
  361. if (Global.Curtime() - runTime > .1) {
  362. runTime = Global.Curtime();
  363. secondsElapsed+=1;
  364. waiting = 0;
  365. }
  366. }
  367. }
  368.  
  369. function dictLength(dict) {
  370. var count = 0;
  371. for (_ in dict) {
  372. count++;
  373. }
  374. return count;
  375. }
  376.  
  377. function createDropdown(name, values, multi) {
  378. UI[multi ? "AddMultiDropdown" : "AddDropdown"](name, values);
  379. binlib[name] = {
  380. "multi": multi,
  381. "values": {}
  382. };
  383. multi && values.reverse();
  384. var i = 0;
  385. for (value in values) {
  386. var index = multi ? (1 << (values.length - (i + 1))) : i;
  387. binlib[name].values[index] = values[value];
  388. i++;
  389. }
  390. }
  391.  
  392. function fetchDropdown(name) {
  393. var selection = (name ? [] : {})
  394. var bin = UI.GetValue("Misc", name);
  395. !name && function() {
  396. for (dropdown in binlib) selection[dropdown] =
  397. fetchDropdown(dropdown)
  398. }();
  399. if (name) {
  400. !binlib[name].multi && bin == 0 && selection.push(binlib[name]
  401. .values[0]) && function() {
  402. return selection;
  403. }();
  404. for (var i = dictLength(binlib[name].values) - 1; i >=
  405. 0; i--) {
  406. if (!binlib[name].multi && i == 0) continue;
  407. var index = binlib[name].multi ? (1 << i) : i;
  408. if (bin - index >= 0) {
  409. bin -= (index);
  410. selection.push(binlib[name].values[index]);
  411. }
  412. }
  413. }
  414. return selection;
  415. }
  416. /* --------- */
  417. /* Callbacks */
  418. Cheat.RegisterCallback("Draw", "pickTarget");
  419. Cheat.RegisterCallback('Draw', 'check');
  420. Cheat.RegisterCallback("Draw", "drawIndicator");
  421. Cheat.RegisterCallback("Draw", "drawInMenu");
  422. Global.RegisterCallback("ragebot_fire", "onShot");
  423. /* --------- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement