Guest User

Untitled

a guest
Dec 7th, 2019
107
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. inAir = false;
  165. if (fv < -1 || fv > 1)
  166. inAir = true;
  167. else
  168. inAir = false;
  169. if (weaponType() == undefined)
  170. return;
  171. playstyle = UI.GetString("Script items", weaponType() + " Playstyle");
  172. mode = UI.GetString("Script items", "[AHC] Mode");
  173. if (UI.GetValue("[AHC] Adaptive Doubletap")) {
  174. dtVal = playstyle == "Agressive" ? dtEquation(dtMinHC, dtMaxHC) - 30 : dtEquation(dtMinHC, dtMaxHC);
  175. UI.SetValue("Rage", "GENERAL", "Exploits", "Doubletap hitchance", dtVal);
  176. }
  177. inAirHC = UI.GetValue("Script items", weaponType() + " In-Air HC", "Integer");
  178. hcVal = playstyle == "Agressive" ? hcEquation(minHC, maxHC) - 15 : hcEquation(minHC, maxHC);
  179. inAirVal = playstyle == "Agressive" ? inAirHC - 15 : inAirHC;
  180. Global.Print(hcVal + "\n");
  181. if (weaponType() == "SMG" || weaponType() == "Rifle")
  182. UI.SetValue("Rage", "GENERAL", "Accuracy", "Hitchance", inAir ? inAirVal : hcVal);
  183. else
  184. UI.SetValue("Rage", weaponType().toUpperCase(), "Accuracy", "Hitchance", inAir ? inAirVal : hcVal);
  185.  
  186. function hcEquation(min, max) {
  187. if (mode == "Low to High")
  188. return Math.round(Math.min(Math.max((1 / 250) * (100 * (distance / 20)) + min, min), max));
  189. else
  190. if (mode == "High to Low")
  191. return Math.round(Math.min(Math.max((-1 / 250) * (100 * (distance / 20)) + max, min), max));
  192. }
  193.  
  194. function dtEquation(min, max) {
  195. if (mode == "Low to High")
  196. return Math.round(Math.min(Math.max((1 / 125) * (100 * (distance / 20)) + min, min), max));
  197. else
  198. if (mode == "High to Low")
  199. return Math.round(Math.min(Math.max((-1 / 125) * (100 * (distance / 20)) + max, min), max));
  200. }
  201. }
  202.  
  203. function setup() {
  204. UI.AddCheckbox("[AHC] Enable Adaptive Hitchance");
  205. UI.AddCheckbox("[AHC] Show Indicators");
  206. UI.AddColorPicker("[AHC] Target Indicator");
  207. UI.SetColor("Script items", "[AHC] Target Indicator", [255, 0, 255, 255]);
  208. UI.AddDropdown("[AHC] Mode", ["Low to High", "High to Low"]);
  209. UI.AddCheckbox("[AHC] In-Air HC");
  210. UI.AddCheckbox("[AHC] Adaptive Doubletap");
  211. UI.AddSliderInt("Doubletap Max HC", 0, 100);
  212. UI.AddSliderInt("Doubletap Min HC", 0, 100);
  213. UI.AddDropdown("[AHC] Weapon Config", ["Auto", "Scout", "AWP", "Rifle", "SMG", "Pistol", "Heavy Pistol"]);
  214. for (weapon in wepList) {
  215. UI.AddDropdown(wepList[weapon] + " Playstyle", ["Agressive", "Passive"]);
  216. UI.AddSliderInt(wepList[weapon] + " Max HC", 0, 100);
  217. UI.AddSliderInt(wepList[weapon] + " Min HC", 0, 100);
  218. }
  219. UI.AddSliderInt("Scout In-Air HC", 0, 100);
  220. UI.AddSliderInt("SMG In-Air HC", 0, 100);
  221. UI.AddSliderInt("Heavy Pistol In-Air HC", 0, 100);
  222. Global.PrintColor([255, 75, 100, 25],
  223. "\n------------------------\n[AHC] v1.0 by Ultranite\n------------------------\n");
  224. }
  225. runTime = Global.Curtime();
  226. var secondsElapsed = 0;
  227.  
  228. function check() {
  229. if (waiting == 1) {
  230. if (Global.Curtime() - runTime > 1) {
  231. secondsElapsed += 1;
  232. runTime = Global.Curtime();
  233. }
  234. }
  235. }
  236. Global.RegisterCallback('Draw', 'check');
  237. /* --------- */
  238. /* Callbacks */
  239. Global.RegisterCallback("Draw", "pickTarget");
  240. Global.RegisterCallback("Draw", "drawIndicator");
  241. Global.RegisterCallback("Draw", "drawInMenu");
  242. Global.RegisterCallback("ragebot_fire", "onShot");
  243. /* --------- */
RAW Paste Data