Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.52 KB | None | 0 0
  1. /**
  2. * @filename Wakka.js
  3. * @author kolton
  4. * @desc walking Chaos Sanctuary leecher
  5. */
  6.  
  7. var stopLvl = 99;
  8.  
  9. function Wakka() {
  10. var i, safeTP, portal, vizClear, seisClear, infClear, tick, diablo,
  11. timeout = 1, // minutes
  12. minDist = 50,
  13. maxDist = 80,
  14. leaderUnit = null,
  15. leaderPartyUnit = null,
  16. leader = "";
  17.  
  18. function autoLeaderDetect(destination) { // autoleader by Ethic
  19. var solofail, suspect;
  20.  
  21. do {
  22. solofail = 0;
  23. suspect = getParty(); // get party object (players in game)
  24.  
  25. do {
  26. if (suspect.name !== me.name) { // player isn't alone
  27. solofail += 1;
  28. }
  29.  
  30. if (suspect.area === destination) { // first player in our party found in destination area...
  31. leader = suspect.name; // ... is our leader
  32.  
  33. if (suspect.area === 131) {
  34. return false;
  35. }
  36.  
  37. print("ÿc4Wakka: ÿc0Autodetected " + leader);
  38.  
  39. return true;
  40. }
  41. } while (suspect.getNext());
  42.  
  43. if (solofail === 0) { // empty game, nothing left to do
  44. return false;
  45. }
  46.  
  47. delay(500);
  48.  
  49. if (getTickCount() - me.gamestarttime >= timeout * 6e4) {
  50. throw new Error("No leader found");
  51. }
  52. } while (!leader); // repeat until leader is found (or until game is empty)
  53.  
  54. return false;
  55. }
  56.  
  57. this.checkMonsters = function (range, dodge) {
  58. var monList = [],
  59. monster = getUnit(1);
  60.  
  61. if (monster) {
  62. do {
  63. if (monster.y < 5565 && Attack.checkMonster(monster) && getDistance(me, monster) <= range) {
  64. if (!dodge) {
  65. return true;
  66. }
  67.  
  68. monList.push(copyUnit(monster));
  69. }
  70. } while (monster.getNext());
  71. }
  72.  
  73. if (!monList.length) {
  74. return false;
  75. }
  76.  
  77. monList.sort(Sort.units);
  78.  
  79. if (getDistance(me, monList[0]) < 25 && !checkCollision(me, monList[0], 0x4)) {
  80. Attack.deploy(monList[0], 25, 5, 15);
  81. }
  82.  
  83. return true;
  84. };
  85.  
  86. this.getLayout = function (seal, value) {
  87. var sealPreset = getPresetUnit(108, 2, seal);
  88.  
  89. if (!seal) {
  90. throw new Error("Seal preset not found. Can't continue.");
  91. }
  92.  
  93. switch (seal) {
  94. case 396:
  95. if (sealPreset.roomy * 5 + sealPreset.y === value) {
  96. return 1;
  97. }
  98.  
  99. break;
  100. case 394:
  101. case 392:
  102. if (sealPreset.roomx * 5 + sealPreset.x === value) {
  103. return 1;
  104. }
  105.  
  106. break;
  107. }
  108.  
  109. return 2;
  110. };
  111.  
  112. this.getCoords = function () {
  113. this.vizCoords = this.getLayout(396, 5275) === 1 ? [7707, 5274] : [7708, 5298];
  114. this.seisCoords = this.getLayout(394, 7773) === 1 ? [7812, 5223] : [7809, 5193];
  115. this.infCoords = this.getLayout(392, 7893) === 1 ? [7868, 5294] : [7882, 5306];
  116. };
  117.  
  118. this.checkBoss = function (name) {
  119. var i, boss,
  120. glow = getUnit(2, 131);
  121.  
  122. if (glow) {
  123. for (i = 0; i < 10; i += 1) {
  124. if (me.getStat(12) >= stopLvl) {
  125. D2Bot.stop();
  126. }
  127.  
  128. boss = getUnit(1, name);
  129.  
  130. if (boss && boss.mode === 12) {
  131. return true;
  132. }
  133.  
  134. delay(500);
  135. }
  136.  
  137. return true;
  138. }
  139.  
  140. return false;
  141. };
  142.  
  143. this.getCorpse = function () {
  144. if (me.mode === 17) {
  145. me.revive();
  146. }
  147.  
  148. var corpse,
  149. rval = false;
  150.  
  151. corpse = getUnit(0, me.name, 17);
  152.  
  153. if (corpse) {
  154. do {
  155. if (getDistance(me, corpse) <= 15) {
  156. Pather.moveToUnit(corpse);
  157. corpse.interact();
  158. delay(500);
  159.  
  160. rval = true;
  161. }
  162. } while (corpse.getNext());
  163. }
  164.  
  165. return rval;
  166. };
  167.  
  168. this.followPath = function (dest) {
  169. var path = getPath(me.area, me.x, me.y, dest[0], dest[1], 0, 10);
  170.  
  171. if (!path) {
  172. throw new Error("Failed go get path");
  173. }
  174.  
  175. while (path.length > 0) {
  176. if (me.getStat(12) >= stopLvl) {
  177. D2Bot.stop();
  178. }
  179.  
  180. if (me.mode === 17 || me.inTown) {
  181. return false;
  182. }
  183.  
  184. if (!leaderUnit || !copyUnit(leaderUnit).x) {
  185. leaderUnit = getUnit(0, leader);
  186. }
  187.  
  188. if (leaderUnit) {
  189. if (this.checkMonsters(45, true) && getDistance(me, leaderUnit) <= maxDist) { // monsters nearby - don't move
  190. path = getPath(me.area, me.x, me.y, dest[0], dest[1], 0, 15);
  191. Pickit.pickItems();
  192. delay(200);
  193.  
  194. continue;
  195. }
  196.  
  197. if (getDistance(me, leaderUnit) <= minDist) { // leader within minDist range - don't move
  198. delay(200);
  199.  
  200. continue;
  201. }
  202. } else {
  203. // leaderUnit out of getUnit range but leader is still within reasonable distance - check party unit's coords!
  204. leaderPartyUnit = getParty(leader);
  205.  
  206. if (leaderPartyUnit) {
  207. if (leaderPartyUnit.area !== me.area) { // leader went to town - don't move
  208. delay(200);
  209.  
  210. continue;
  211. }
  212.  
  213. // if there's monsters between the leecher and leader, wait until monsters are dead or leader is out of maxDist range
  214. if (this.checkMonsters(45, true) && getDistance(me, leaderPartyUnit.x, leaderPartyUnit.y) <= maxDist) {
  215. path = getPath(me.area, me.x, me.y, dest[0], dest[1], 0, 15);
  216. Pickit.pickItems();
  217. delay(200);
  218.  
  219. continue;
  220. }
  221. }
  222. }
  223.  
  224. if (Pather.moveTo(path[0].x, path[0].y)) {
  225. path.shift();
  226. }
  227.  
  228. this.getCorpse();
  229. }
  230.  
  231. return true;
  232. };
  233.  
  234. // start
  235. Town.goToTown(4);
  236. Town.move("portalspot");
  237.  
  238. if (Config.Leader) {
  239. leader = Config.Leader;
  240.  
  241. for (i = 0; i < 30; i += 1) {
  242. if (Misc.inMyParty(leader)) {
  243. break;
  244. }
  245.  
  246. delay(1000);
  247. }
  248.  
  249. if (i === 30) {
  250. throw new Error("Wakka: Leader not partied");
  251. }
  252. }
  253.  
  254. autoLeaderDetect(108);
  255. Town.doChores();
  256.  
  257. if (leader) {
  258. while (Misc.inMyParty(leader)) {
  259. if (me.getStat(12) >= stopLvl) {
  260. D2Bot.stop();
  261. }
  262.  
  263. switch (me.area) {
  264. case 103:
  265. //portal = Pather.getPortal(108, leader);
  266. portal = Pather.getPortal(108, null);
  267.  
  268. if (portal) {
  269. if (!safeTP) {
  270. delay(5000);
  271. }
  272.  
  273. //Pather.usePortal(108, leader);
  274. Pather.usePortal(108, null);
  275. }
  276.  
  277. break;
  278. case 108:
  279. if (!safeTP) {
  280. if (this.checkMonsters(25, false)) {
  281. me.overhead("hot tp");
  282. //Pather.usePortal(103, leader);
  283. Pather.usePortal(103, null);
  284. this.getCorpse();
  285.  
  286. break;
  287. } else {
  288. this.getCoords();
  289.  
  290. safeTP = true;
  291. }
  292. }
  293.  
  294. if (!vizClear) {
  295. if (!this.followPath(this.vizCoords)) {
  296. break;
  297. }
  298.  
  299. if (tick && getTickCount() - tick >= 5000) {
  300. vizClear = true;
  301. tick = false;
  302.  
  303. break;
  304. }
  305.  
  306. if (this.checkBoss(getLocaleString(2851))) {
  307. if (!tick) {
  308. tick = getTickCount();
  309. }
  310. Pickit.pickItems();
  311. me.overhead("vizier dead");
  312. }
  313.  
  314. break;
  315. }
  316.  
  317. if (!seisClear) {
  318. if (!this.followPath(this.seisCoords)) {
  319. break;
  320. }
  321.  
  322. if (tick && getTickCount() - tick >= 7000) {
  323. seisClear = true;
  324. tick = false;
  325.  
  326. break;
  327. }
  328.  
  329. if (this.checkBoss(getLocaleString(2852))) {
  330. if (!tick) {
  331. tick = getTickCount();
  332. }
  333. Pickit.pickItems();
  334. me.overhead("seis dead");
  335. }
  336.  
  337. break;
  338. }
  339.  
  340. if (!infClear) {
  341. if (!this.followPath(this.infCoords)) {
  342. break;
  343. }
  344.  
  345. if (tick && getTickCount() - tick >= 2000) {
  346. infClear = true;
  347. tick = false;
  348.  
  349. break;
  350. }
  351.  
  352. if (this.checkBoss(getLocaleString(2853))) {
  353. if (!tick) {
  354. tick = getTickCount();
  355. }
  356. Pickit.pickItems();
  357. me.overhead("infector dead");
  358. }
  359.  
  360. break;
  361. }
  362.  
  363. Pather.moveTo(7767, 5263);
  364.  
  365. diablo = getUnit(1, 243);
  366.  
  367. if (diablo && (diablo.mode === 0 || diablo.mode === 12)) {
  368. return true;
  369. }
  370.  
  371. break;
  372. }
  373.  
  374. if (me.mode === 17) {
  375. me.revive();
  376. }
  377.  
  378. delay(200);
  379. }
  380. } else {
  381. throw new Error("Empty game.");
  382. }
  383.  
  384. return true;
  385. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement