Advertisement
Ultranite

Untitled

Dec 8th, 2019
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.06 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.  
  120. x = UI.GetValue("Script items", "[AHC] Indicator Location X");
  121. y = UI.GetValue("Script items", "[AHC] Indicator Location Y");
  122.  
  123. if(weaponType() == undefined || calcDist(local, targetIndex) >= 500 || targetIndex == undefined || targetIndex == -1) {
  124. Render.String(x,y,0,"HC:-", [255,255,255,255], 30);
  125. return;
  126. }
  127.  
  128. hitchance = UI.GetValue("Rage", weaponType().toUpperCase(), "Accuracy", "Hitchance");
  129.  
  130. if(weaponType() == "Rifle" || weaponType() == "SMG")
  131. hitchance = UI.GetValue("Rage", "GENERAL", "Accuracy", "Hitchance");
  132. if(hitchance < 0)
  133. hitchance = 0;
  134.  
  135. if(hitchance > 65)
  136. color = [0,255,0,255];
  137. else
  138. if(hitchance > 45)
  139. color = [255,255,0,255];
  140. else
  141. color = [255,0,0,255];
  142.  
  143. Render.String(x,y,0,"HC:"+hitchance, color, 30);
  144. }
  145.  
  146. function drawInMenu() {
  147. var opts = UI.GetString("[AHC] Weapon Config");
  148. var dt = UI.GetValue("[AHC] Adaptive Doubletap");
  149. var inAir = UI.GetValue("[AHC] In-Air HC");
  150. for (var weapon in wepList) {
  151. UI.SetEnabled("Script items", wepList[weapon] + " Max HC", opts == wepList[weapon]);
  152. UI.SetEnabled("Script items", wepList[weapon] + " Min HC", opts == wepList[weapon]);
  153. UI.SetEnabled("Script items", wepList[weapon] + " Playstyle", opts == wepList[weapon]);
  154. }
  155. UI.SetEnabled("Script items", "SMG In-Air HC", opts == "SMG" && inAir);
  156. UI.SetEnabled("Script items", "Scout In-Air HC", opts == "Scout" && inAir);
  157. UI.SetEnabled("Script items", "Heavy Pistol In-Air HC", opts == "Heavy Pistol" && inAir);
  158. UI.SetEnabled("Script items", "Doubletap Max HC", dt);
  159. UI.SetEnabled("Script items", "Doubletap Min HC", dt);
  160. if(!UI.GetValue("Script items", "[AHC] Hitchance Indicator")) {
  161. UI.SetEnabled("Script items", "[AHC] Indicator Location X", false);
  162. UI.SetEnabled("Script items", "[AHC] Indicator Location Y", false);
  163. } else {
  164. UI.SetEnabled("Script items", "[AHC] Indicator Location X", true);
  165. UI.SetEnabled("Script items", "[AHC] Indicator Location Y", true);
  166. }
  167.  
  168. if(!UI.GetValue("Script items", "[AHC] Account for inaccuracy")) {
  169. UI.SetEnabled("Script items", "Normal Inaccuracy Sensitivty", false);
  170. UI.SetEnabled("Script items", "In-Air Inaccuracy Sensitivty", false);
  171. } else {
  172. UI.SetEnabled("Script items", "Normal Inaccuracy Sensitivty", true);
  173. UI.SetEnabled("Script items", "In-Air Inaccuracy Sensitivty", true);
  174. }
  175. }
  176.  
  177. function weaponType() {
  178. var weapon = Entity.GetName(Entity.GetWeapon(local));
  179. var weapons = {
  180. "usp s": "Pistol",
  181. "glock 18": "Pistol",
  182. "p2000": "Pistol",
  183. "dual berettas": "Pistol",
  184. "r8 revolver": "Heavy Pistol",
  185. "desert eagle": "Heavy Pistol",
  186. "p250": "Pistol",
  187. "tec9": "Pistol",
  188. "mp9": "SMG",
  189. "mac 10": "SMG",
  190. "ump 45": "SMG",
  191. "ak 47": "Rifle",
  192. "sg 553": "Rifle",
  193. "aug": "Rifle",
  194. "m4a1 s": "Rifle",
  195. "m4a4": "Rifle",
  196. "ssg 08": "Scout",
  197. "awp": "AWP",
  198. "g3sg1": "Auto",
  199. "scar 20": "Auto"
  200. };
  201. return weapons[weapon];
  202. }
  203.  
  204. function adjustHitchance(distance) {
  205.  
  206. if (weaponType() == undefined)
  207. return;
  208. var enabledWeps = fetchDropdown("[AHC] Enabled Weapons");
  209. if (enabledWeps.indexOf(weaponType()) == -1)
  210. return;
  211.  
  212. maxHC = UI.GetValue("Script items", weaponType() + " Max HC", "Integer");
  213. minHC = UI.GetValue("Script items", weaponType() + " Min HC", "Integer");
  214. dtMaxHC = UI.GetValue("Script items", "Doubletap Max HC");
  215. dtMinHC = UI.GetValue("Script items", "Doubletap Min HC");
  216. fv = Entity.GetProp(local, "CBasePlayer", "m_flFallVelocity");
  217. inAir = false;
  218. playstyle = UI.GetString("Script items", weaponType() + " Playstyle");
  219. mode = UI.GetString("Script items", "[AHC] Mode");
  220. inacc = Local.GetInaccuracy();
  221.  
  222. if (fv < -1 || fv > 1)
  223. inAir = true;
  224. else
  225. inAir = false;
  226.  
  227. if (UI.GetValue("[AHC] Adaptive Doubletap")) {
  228. dtVal = playstyle == "Agressive" ? dtEquation(dtMinHC, dtMaxHC) - 30 : dtEquation(dtMinHC, dtMaxHC);
  229. if (isNaN(dtVal))
  230. dtVal = dtMinHC;
  231. UI.SetValue("Rage", "GENERAL", "Exploits", "Doubletap hitchance", dtVal);
  232. }
  233. if (weaponType() == "Heavy Pistol" || weaponType() == "Scout" || weaponType() == "SMG")
  234. inAirVal = UI.GetValue("Script items", weaponType() + " In-Air HC", "Integer");
  235. else
  236. inAirVal = minHC;
  237.  
  238. hcVal = playstyle == "Agressive" ? hcEquation(minHC, maxHC) - 15 : hcEquation(minHC, maxHC);
  239. if (hcVal == undefined || hcVal < 0 || isNaN(hcVal)) {
  240. hcVal = minHC;
  241. }
  242. hcInacc = UI.GetValue("Script items", "Normal Inaccuracy Sensitivity");
  243. inAirInacc = UI.GetValue("Script items", "In-Air Inaccuracy Sensitivity");
  244.  
  245. if(inacc > .04 && UI.GetValue("Script items", "[AHC] Account for inaccuracy")) {
  246. hcVal-=inacc*hcInacc;
  247. inAirVal-=inacc*inAirInacc;
  248. }
  249.  
  250. if (weaponType() == "SMG" || weaponType() == "Rifle")
  251. UI.SetValue("Rage", "GENERAL", "Accuracy", "Hitchance", inAir ? inAirVal : hcVal);
  252. else
  253. UI.SetValue("Rage", weaponType().toUpperCase(), "Accuracy", "Hitchance", inAir ? inAirVal : hcVal);
  254.  
  255. function hcEquation(min, max) {
  256. if (mode == "Decreasing")
  257. return Math.round(Math.min(Math.max((1 / 250) * (100 * (distance / 20)) + min, min), max));
  258. else
  259. if (mode == "Increasing")
  260. return Math.round(Math.min(Math.max((-1 / 250) * (100 * (distance / 20)) + max, min), max));
  261. }
  262.  
  263. function dtEquation(min, max) {
  264. if (mode == "Decreasing")
  265. return Math.round(Math.min(Math.max((1 / 125) * (100 * (distance / 20)) + min, min), max));
  266. else
  267. if (mode == "Increasing")
  268. return Math.round(Math.min(Math.max((-1 / 125) * (100 * (distance / 20)) + max, min), max));
  269. }
  270. }
  271.  
  272. function setup() {
  273. UI.AddCheckbox("[AHC] Enable Adaptive Hitchance");
  274. UI.AddCheckbox("[AHC] Show Indicators");
  275. UI.AddColorPicker("[AHC] Target Indicator");
  276. UI.AddCheckbox("[AHC] Hitchance Indicator");
  277. UI.AddSliderInt("[AHC] Indicator Location X", 0, Render.GetScreenSize()[0]-125);
  278. UI.AddSliderInt("[AHC] Indicator Location Y", 0, Render.GetScreenSize()[1]-25);
  279. UI.SetColor("Script items", "[AHC] Target Indicator", [255, 0, 255, 255]);
  280. UI.AddDropdown("[AHC] Mode", ["Increasing", "Decreasing"]);
  281. UI.AddCheckbox("[AHC] In-Air HC");
  282. UI.AddCheckbox("[AHC] Account for inaccuracy");
  283. UI.AddSliderInt("Normal Inaccuracy Sensitivity", 0,100);
  284. UI.AddSliderInt("In-Air Inaccuracy Sensitivity", 0,100);
  285. createDropdown("[AHC] Enabled Weapons", ["Auto", "Scout", "AWP", "Rifle", "SMG", "Pistol", "Heavy Pistol"], true);
  286. UI.AddCheckbox("[AHC] Adaptive Doubletap");
  287. UI.AddSliderInt("Doubletap Max HC", 0, 100);
  288. UI.AddSliderInt("Doubletap Min HC", 0, 100);
  289. UI.AddDropdown("[AHC] Weapon Config", ["Auto", "Scout", "AWP", "Rifle", "SMG", "Pistol", "Heavy Pistol"]);
  290. for (weapon in wepList) {
  291. UI.AddDropdown(wepList[weapon] + " Playstyle", ["Agressive", "Passive"]);
  292. UI.AddSliderInt(wepList[weapon] + " Max HC", 0, 100);
  293. UI.AddSliderInt(wepList[weapon] + " Min HC", 0, 100);
  294. }
  295. UI.AddSliderInt("Scout In-Air HC", 0, 100);
  296. UI.AddSliderInt("SMG In-Air HC", 0, 100);
  297. UI.AddSliderInt("Heavy Pistol In-Air HC", 0, 100);
  298. Cheat.PrintColor([255, 75, 100, 25],
  299. "\n------------------------\n[AHC] v1.5 BETA by Ultranite\n------------------------\n");
  300. }
  301. runTime = Global.Curtime();
  302. var secondsElapsed = 0;
  303.  
  304. function check() {
  305. if (waiting == 1) {
  306. if (Global.Curtime() - runTime > .1) {
  307. runTime = Global.Curtime();
  308. secondsElapsed+=1;
  309. waiting = 0;
  310. }
  311. }
  312. }
  313.  
  314. function dictLength(dict) {
  315. var count = 0;
  316. for (_ in dict) {
  317. count++;
  318. }
  319. return count;
  320. }
  321.  
  322. function createDropdown(name, values, multi) {
  323. UI[multi ? "AddMultiDropdown" : "AddDropdown"](name, values);
  324. binlib[name] = {
  325. "multi": multi,
  326. "values": {}
  327. };
  328. multi && values.reverse();
  329. var i = 0;
  330. for (value in values) {
  331. var index = multi ? (1 << (values.length - (i + 1))) : i;
  332. binlib[name].values[index] = values[value];
  333. i++;
  334. }
  335. }
  336.  
  337. function fetchDropdown(name) {
  338. var selection = (name ? [] : {})
  339. var bin = UI.GetValue("Misc", name);
  340. !name && function() {
  341. for (dropdown in binlib) selection[dropdown] =
  342. fetchDropdown(dropdown)
  343. }();
  344. if (name) {
  345. !binlib[name].multi && bin == 0 && selection.push(binlib[name]
  346. .values[0]) && function() {
  347. return selection;
  348. }();
  349. for (var i = dictLength(binlib[name].values) - 1; i >=
  350. 0; i--) {
  351. if (!binlib[name].multi && i == 0) continue;
  352. var index = binlib[name].multi ? (1 << i) : i;
  353. if (bin - index >= 0) {
  354. bin -= (index);
  355. selection.push(binlib[name].values[index]);
  356. }
  357. }
  358. }
  359. return selection;
  360. }
  361. /* --------- */
  362. /* Callbacks */
  363. Cheat.RegisterCallback("Draw", "pickTarget");
  364. Cheat.RegisterCallback('Draw', 'check');
  365. Cheat.RegisterCallback("Draw", "drawIndicator");
  366. Cheat.RegisterCallback("Draw", "drawInMenu");
  367. Global.RegisterCallback("ragebot_fire", "onShot");
  368. /* --------- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement