Advertisement
Ultranite

Untitled

Dec 8th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.97 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. /* ---------------- */
  21. setup();
  22. /* Functions */
  23. function calcDist(local, target) {
  24. lx = local[0];
  25. ly = local[1];
  26. lz = local[2];
  27. tx = target[0];
  28. ty = target[1];
  29. tz = target[2];
  30. dx = lx - tx;
  31. dy = ly - ty;
  32. dz = lz - tz;
  33. return Math.sqrt(dx * dx + dy * dy + dz * dz);
  34. }
  35.  
  36. function pickTarget() {
  37. if (!UI.GetValue("Script Items", "[AHC] Enable Adaptive Hitchance") || !Entity.IsAlive(local))
  38. return;
  39. if (target == undefined || target == -1 || !Entity.IsValid(target) || !Entity.IsAlive(target)) {
  40. if (rageTarget == 1) {
  41. waiting = 1;
  42. }
  43. }
  44. if (secondsElapsed >= 5) {
  45. rageTarget = 0;
  46. secondsElapsed = 0;
  47. waiting = 0;
  48. }
  49. var enemies = Entity.GetEnemies();
  50. var tempGuess = -1;
  51. var localPos = Entity.GetHitboxPosition(local, 5);
  52. for (var i = 0; i < enemies.length; i++) {
  53. if (!Entity.IsValid(enemies[i]) || !Entity.IsAlive(enemies[i])) {
  54. continue;
  55. }
  56. if (tempGuess == undefined || !Entity.IsValid(tempGuess) || !Entity.IsAlive(tempGuess) || Entity.IsDormant(
  57. tempGuess)) {
  58. tempGuess = enemies[i];
  59. continue;
  60. }
  61. targetPos = Entity.GetHitboxPosition(tempGuess, 5);
  62. enemyPos = Entity.GetHitboxPosition(enemies[i], 5);
  63. if (calcDist(localPos, enemyPos) < calcDist(localPos, targetPos)) {
  64. tempGuess = enemies[i];
  65. continue;
  66. }
  67. }
  68. targetIndex = tempGuess;
  69. targetPos = Entity.GetHitboxPosition(targetIndex, 5);
  70. if (rageTarget == 0)
  71. adjustHitchance(calcDist(localPos, targetPos));
  72. }
  73.  
  74. function onShot() {
  75. if (!UI.GetValue("Script Items", "[AHC] Enable Adaptive Hitchance"))
  76. return;
  77. target = Event.GetInt("target_index");
  78. if (!Entity.IsValid(targetIndex) || !Entity.IsAlive(targetIndex) || !Entity.IsDormant(targetIndex)) {
  79. waiting = 1;
  80. target = -1;
  81. return;
  82. }
  83. targetIndex = target;
  84. rageTarget = 1;
  85. secondsElapsed = 0;
  86. targetPos = Entity.GetHitboxPosition(targetIndex, 5);
  87. localPos = Entity.GetHitboxPosition(local, 5);
  88. adjustHitchance(calcDist(localPos, targetPos));
  89. }
  90.  
  91. function drawIndicator() {
  92. if (!UI.GetValue("Script items", "[AHC] Show Indicators"))
  93. return;
  94. if (!Entity.IsAlive(local))
  95. return;
  96. if (targetIndex == -1 || targetIndex == undefined) {
  97. return;
  98. }
  99. if (!Entity.IsValid(targetIndex) || !Entity.IsAlive(targetIndex)) {
  100. return;
  101. }
  102. targetPos = Entity.GetHitboxPosition(targetIndex, 5);
  103. localPos = Entity.GetHitboxPosition(local, 5);
  104. if (calcDist(localPos, targetPos) >= 2000)
  105. return;
  106. var worldPos = Entity.GetRenderOrigin(targetIndex);
  107. var loc = Render.WorldToScreen(worldPos);
  108. var color = UI.GetColor("Script items", "[AHC] Target Indicator");
  109. Render.Circle(loc[0], loc[1] - 142, 20, color);
  110. Render.String(loc[0] - 7, loc[1] - 160, 0, "!", color, 24);
  111. }
  112.  
  113. function drawInMenu() {
  114. var opts = UI.GetString("[AHC] Weapon Config");
  115. var dt = UI.GetValue("[AHC] Adaptive Doubletap");
  116. var inAir = UI.GetValue("[AHC] In-Air HC");
  117. for (var weapon in wepList) {
  118. UI.SetEnabled("Script items", wepList[weapon] + " Max HC", opts == wepList[weapon]);
  119. UI.SetEnabled("Script items", wepList[weapon] + " Min HC", opts == wepList[weapon]);
  120. UI.SetEnabled("Script items", wepList[weapon] + " Playstyle", opts == wepList[weapon]);
  121. }
  122. UI.SetEnabled("Script items", "SMG In-Air HC", opts == "SMG" && inAir);
  123. UI.SetEnabled("Script items", "Scout In-Air HC", opts == "Scout" && inAir);
  124. UI.SetEnabled("Script items", "Heavy Pistol In-Air HC", opts == "Heavy Pistol" && inAir);
  125. UI.SetEnabled("Script items", "Doubletap Max HC", dt);
  126. UI.SetEnabled("Script items", "Doubletap Min HC", dt);
  127. }
  128.  
  129. function weaponType() {
  130. var weapon = Entity.GetName(Entity.GetWeapon(local));
  131. var weapons = {
  132. "usp s": "Pistol",
  133. "glock 18": "Pistol",
  134. "p2000": "Pistol",
  135. "dual berettas": "Pistol",
  136. "r8 revolver": "Heavy Pistol",
  137. "desert eagle": "Heavy Pistol",
  138. "p250": "Pistol",
  139. "tec9": "Pistol",
  140. "mp9": "SMG",
  141. "mac 10": "SMG",
  142. "ump 45": "SMG",
  143. "ak 47": "Rifle",
  144. "sg 553": "Rifle",
  145. "aug": "Rifle",
  146. "m4a1 s": "Rifle",
  147. "m4a4": "Rifle",
  148. "ssg 08": "Scout",
  149. "awp": "AWP",
  150. "g3sg1": "Auto",
  151. "scar 20": "Auto"
  152. };
  153. return weapons[weapon];
  154. }
  155.  
  156. function adjustHitchance(distance) {
  157. if (weaponType() == undefined)
  158. return;
  159. maxHC = UI.GetValue("Script items", weaponType() + " Max HC", "Integer");
  160. minHC = UI.GetValue("Script items", weaponType() + " Min HC", "Integer");
  161. dtMaxHC = UI.GetValue("Script items", "Doubletap Max HC");
  162. dtMinHC = UI.GetValue("Script items", "Doubletap Min HC");
  163. fv = Entity.GetProp(local, "CBasePlayer", "m_flFallVelocity");
  164.  
  165. inAir = false;
  166. if (fv < -1 || fv > 1)
  167. inAir = true;
  168. else
  169. inAir = false;
  170. if (weaponType() == undefined)
  171. return;
  172. playstyle = UI.GetString("Script items", weaponType() + " Playstyle");
  173. mode = UI.GetString("Script items", "[AHC] Mode");
  174.  
  175. if (UI.GetValue("[AHC] Adaptive Doubletap")) {
  176. dtVal = playstyle == "Agressive" ? dtEquation(dtMinHC, dtMaxHC) - 30 : dtEquation(dtMinHC, dtMaxHC);
  177. UI.SetValue("Rage", "GENERAL", "Exploits", "Doubletap hitchance", dtVal);
  178. }
  179. inAirHC = UI.GetValue("Script items", weaponType() + " In-Air HC", "Integer");
  180. hcVal = playstyle == "Agressive" ? hcEquation(minHC, maxHC) - 15 : hcEquation(minHC, maxHC);
  181. inAirVal = playstyle == "Agressive" ? inAirHC - 15 : inAirHC;
  182.  
  183. if(hcVal == undefined || hcVal < 0)
  184. hcVal = minHC;
  185.  
  186. if (weaponType() == "SMG" || weaponType() == "Rifle")
  187. UI.SetValue("Rage", "GENERAL", "Accuracy", "Hitchance", inAir ? inAirVal : hcVal);
  188. else
  189. UI.SetValue("Rage", weaponType().toUpperCase(), "Accuracy", "Hitchance", inAir ? inAirVal : hcVal);
  190.  
  191. function hcEquation(min, max) {
  192. if (mode == "Decreasing")
  193. return Math.round(Math.min(Math.max((1 / 250) * (100 * (distance / 20)) + min, min), max));
  194. else
  195. if (mode == "Increasing")
  196. return Math.round(Math.min(Math.max((-1 / 250) * (100 * (distance / 20)) + max, min), max));
  197. }
  198.  
  199. function dtEquation(min, max) {
  200. if (mode == "Decreasing")
  201. return Math.round(Math.min(Math.max((1 / 125) * (100 * (distance / 20)) + min, min), max));
  202. else
  203. if (mode == "Increasing")
  204. return Math.round(Math.min(Math.max((-1 / 125) * (100 * (distance / 20)) + max, min), max));
  205. }
  206. }
  207.  
  208. function setup() {
  209. UI.AddCheckbox("[AHC] Enable Adaptive Hitchance");
  210. UI.AddCheckbox("[AHC] Show Indicators");
  211. UI.AddColorPicker("[AHC] Target Indicator");
  212. UI.SetColor("Script items", "[AHC] Target Indicator", [255, 0, 255, 255]);
  213. UI.AddDropdown("[AHC] Mode", ["Increasing", "Decreasing"]);
  214. UI.AddCheckbox("[AHC] In-Air HC");
  215. UI.AddCheckbox("[AHC] Adaptive Doubletap");
  216. UI.AddSliderInt("Doubletap Max HC", 0, 100);
  217. UI.AddSliderInt("Doubletap Min HC", 0, 100);
  218. UI.AddDropdown("[AHC] Weapon Config", ["Auto", "Scout", "AWP", "Rifle", "SMG", "Pistol", "Heavy Pistol"]);
  219. for (weapon in wepList) {
  220. UI.AddDropdown(wepList[weapon] + " Playstyle", ["Agressive", "Passive"]);
  221. UI.AddSliderInt(wepList[weapon] + " Max HC", 0, 100);
  222. UI.AddSliderInt(wepList[weapon] + " Min HC", 0, 100);
  223. }
  224. UI.AddSliderInt("Scout In-Air HC", 0, 100);
  225. UI.AddSliderInt("SMG In-Air HC", 0, 100);
  226. UI.AddSliderInt("Heavy Pistol In-Air HC", 0, 100);
  227. Global.PrintColor([255, 75, 100, 25],
  228. "\n------------------------\n[AHC] v1.0 by Ultranite\n------------------------\n");
  229.  
  230. /*
  231. * HOW TO CONFIG SETTINGS
  232. * You can set a default value by doing the following:
  233. * UI.SetValue("Script items", "name of option/slider", value);
  234. *
  235. * In order to pick a mode or playstyle, simply set 0 for increasing/agressive (accordingly)
  236. * and 1 for decreasing/passive.
  237. *
  238. * Checkboxes are set as true/false.
  239. *
  240. * Colors can be set in the format of [r,g,b,alpha]
  241. *
  242. * If you ever wonder how to use something, check the forums:
  243. * https://onetap.su/resources/
  244. *
  245. * Add me on discord @Ultranite#9259 for help.
  246. *
  247. */
  248.  
  249. UI.SetValue("Script items", "[AHC] Enable Adaptive Hitchance", true);
  250. UI.SetValue("Script items", "[AHC] Show Indicators", true);
  251. UI.SetValue("Script items", "[AHC] Mode", 1);
  252. UI.SetValue("Script items", "[AHC] In-Air HC", true);
  253. UI.SetValue("Script items", "[AHC] Adaptive Doubletap", true)
  254. UI.SetValue("Script items", "Doubletap Max HC", 45);
  255. UI.SetValue("Script items", "Doubletap Min HC", 0);
  256.  
  257. // PER WEAPON
  258. UI.SetValue("Script items", "Auto Playstyle", 0);
  259. UI.SetValue("Script items", "Auto Max HC", 80);
  260. UI.SetValue("Script items", "Auto Min HC", 45);
  261.  
  262. UI.SetValue("Script items", "Scout Playstyle", 0);
  263. UI.SetValue("Script items", "Scout Max HC", 90);
  264. UI.SetValue("Script items", "Scout Min HC", 55);
  265. UI.SetValue("Script items", "Scout In-Air HC", 65);
  266.  
  267. UI.SetValue("Script items", "Rifle Playstyle", 0);
  268. UI.SetValue("Script items", "Rifle Max HC", 65);
  269. UI.SetValue("Script items", "Rifle Min HC", 35);
  270.  
  271. UI.SetValue("Script items", "SMG Playstyle", 0);
  272. UI.SetValue("Script items", "SMG Max HC", 0);
  273. UI.SetValue("Script items", "SMG Min HC", 0);
  274. UI.SetValue("Script items", "SMG In-Air HC", 0);
  275.  
  276. UI.SetValue("Script items", "Pistol Playstyle", 0);
  277. UI.SetValue("Script items", "Pistol Max HC", 80);
  278. UI.SetValue("Script items", "Pistol Min HC", 50);
  279.  
  280. UI.SetValue("Script items", "Heavy Pistol Playstyle", 0);
  281. UI.SetValue("Script items", "Heavy Pistol Max HC", 85);
  282. UI.SetValue("Script items", "Heavy Pistol Min HC", 60);
  283. UI.SetValue("Script items", "Heavy Pistol In-Air HC", 45);
  284. }
  285. runTime = Global.Curtime();
  286. var secondsElapsed = 0;
  287.  
  288. function check() {
  289. if (waiting == 1) {
  290. if (Global.Curtime() - runTime > .1) {
  291. secondsElapsed += 1;
  292. runTime = Global.Curtime();
  293. }
  294. }
  295. }
  296.  
  297. /* --------- */
  298. /* Callbacks */
  299. Global.RegisterCallback("Draw", "pickTarget");
  300. Global.RegisterCallback('Draw', 'check');
  301. Global.RegisterCallback("Draw", "drawIndicator");
  302. Global.RegisterCallback("Draw", "drawInMenu");
  303. Global.RegisterCallback("ragebot_fire", "onShot");
  304. /* --------- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement