Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.88 KB | None | 0 0
  1. /**
  2. * @filename boChantCS.js
  3. * @author darjkeel
  4. * @desc Bo and enchant other players, add/remove helper(s) to clear
  5. **/
  6. function XPboChantCS() {
  7. var chSorc = "HydroPKEAST", // CHAR name of enchant sorc
  8. boBarb = "WWHxC", // CHAR name of BO barbarian
  9. chCommands = ["enchant", "chant"], // list of commands to chant player, use only lowercase letters
  10. boCommands = ["battle orders", "bo"], // list of commands to BO the player, use only lowercase letters
  11. helpChars = ["HydroPKing",""], // CHAR name(s) of helper(s) e.g. ["char"], or ["char1", "char2"], 2 chars max
  12. helpProfs = ["",""], // PROFILE name(s) of helper(s) e.g. ["profile"] or ["profile1", "profile2"]
  13. helpStartCommands = ["request help"], // list of commands to start a helper, use only lowercase letters
  14. helpStopCommands = [""], // list of commands to stop a helper, use only lowercase letters
  15. clearMode = 0, // helper clear mode: 0 = all, 0xF = skip normal, 0x7 = just champion/uniques (no minions)
  16. gameLength = 7, // maximum game length, in minutes. leave = 0 for infinite
  17. teleMessage = "", // message from barb while sorc teleports to star
  18. starMessage = "", // message from sorc after opening portal at star
  19. homeMessage = "", // message from sorc after returning to pandy fort; this is when command listeners start
  20. endGameMessage = "", // message at the end of the game
  21. needGoldMsg = "", // message used when low on gold to ask players for more
  22. checkShrineBo = false, // check for bo shrines in the immediate area when bo'ing
  23. openSeisSeal = false, // open seis seal when teleporting to star
  24. pickitDiablo = true, // to pick or not to pick, that is the question
  25. moveJamella = true, // whether or not sorc should drag jamella closer to portals
  26. moveHalbu = true, // whether or not sorc should drag halbu closer to portals
  27. shitList = ShitList.read(),
  28. vizLayout, seisLayout, infLayout, command, i;
  29.  
  30. this.find = function(nick) {
  31. var unit = getUnit(0, nick);
  32. if (unit) return unit.area;
  33. var party = getParty();
  34. if (!party) return false;
  35. do {
  36. if (party.name == nick) {
  37. return (party.area > 0) ? party.area : true;
  38. }
  39. } while (party.getNext());
  40. return false;
  41. }
  42. this.chant = function(nick) {
  43. var chanted = [];
  44. if (nick) {
  45. if (!Misc.inMyParty(nick)) {
  46. say("Accept party invite.");
  47. return false;
  48. }
  49. var unit = getUnit(0, nick);
  50. if (!unit || getDistance(me, unit) > 40) {
  51. say("Get closer.");
  52. return false;
  53. }
  54. }
  55. if (!nick) var unit = getUnit(0);
  56. if (unit) {
  57. do {
  58. if (unit.name !== me.name && !unit.dead && shitList.indexOf(unit.name) === -1 && Misc.inMyParty(unit.name) && (!unit.getState(16) || nick) && getDistance(me, unit) <= 40) {
  59. Skill.setSkill(52, 0);
  60. sendPacket(1, 0x11, 4, unit.type, 4, unit.gid);
  61. delay(500);
  62. chanted.push(unit.name);
  63. }
  64. } while (unit.getNext());
  65. }
  66. unit = getUnit(1);
  67. if (unit) {
  68. do {
  69. if (unit.getParent() && chanted.indexOf(unit.getParent().name) > -1 && (!unit.getState(16) || nick) && getDistance(me, unit) <= 40) {
  70. Skill.setSkill(52, 0);
  71. sendPacket(1, 0x11, 4, unit.type, 4, unit.gid);
  72. delay(500);
  73. }
  74. } while (unit.getNext());
  75. }
  76. return true;
  77. }
  78. this.grabBoShrine = function() {
  79. if (me.area == 107) {
  80. if (!me.getState(134)) {
  81. var spot = [me.x, me.y],
  82. shrine = getUnit(2, "shrine");
  83. if (shrine && shrine.objtype === 12) {
  84. Misc.getShrine(shrine);
  85. Pather.moveTo(spot[0], spot[1]);
  86. if (me.getState(134)) return true;
  87. }
  88. }
  89. }
  90. return false;
  91. }
  92. this.bo = function(nick) {
  93. while (me.area < 107) {
  94. Pather.usePortal(108, chSorc);
  95. delay(777777777);
  96. }
  97. if (nick) {
  98. if (!Misc.inMyParty(nick)) {
  99. say("Accept party invite.");
  100. return false;
  101. }
  102. if (this.find(nick) != 108) {
  103. say("Ask for bo again when you're at the star.");
  104. return false;
  105. }
  106. var unit = getUnit(0, nick);
  107. if (getDistance(me, unit) > 20) {
  108. say("Get closer.");
  109. return false;
  110. }
  111. }
  112. if (!nick) var unit = getUnit(0);
  113. if (unit) {
  114. do {
  115. if (unit.name !== me.name && !unit.dead && shitList.indexOf(unit.name) === -1 && Misc.inMyParty(unit.name) && ((!unit.getState(26) || !unit.getState(32) || !unit.getState(51)) || nick) && getDistance(me, unit) <= 20) {
  116. if (checkShrineBo) {
  117. if (this.grabBoShrine()) say("Bo shrine activated");
  118. }
  119. Precast.doPrecast(true);
  120. }
  121. } while (unit.getNext());
  122. }
  123. return true;
  124. }
  125. this.checkHostiles = function() {
  126. var rval = false,
  127. party = getParty();
  128. if (party) {
  129. do {
  130. if (party.name !== me.name && getPlayerFlag(me.gid, party.gid, 8)) {
  131. rval = true;
  132. if (Config.ShitList && shitList.indexOf(party.name) === -1) shitList.push(party.name);
  133. }
  134. } while (party.getNext());
  135. }
  136. return rval;
  137. }
  138. this.openSeal = function(id) {
  139. var seal = getUnit(2, id);
  140. if (seal && seal.mode != 0) return false;
  141. Pather.moveToPreset(108, 2, id, 4);
  142. var seal = getUnit(2, id);
  143. if (!seal) return false;
  144. i = 0;
  145. while (!seal.mode) {
  146. if (!Skill.cast(43, 0, seal)) seal.interact();
  147. delay(100);
  148. if (seal.mode == 0) {
  149. delay(400);
  150. i++
  151. }
  152. if (i > 30) return false;
  153. }
  154. return true;
  155. }
  156. this.getLayout = function(seal, value) {
  157. var sealPreset = getPresetUnit(108, 2, seal);
  158. if (!seal) {
  159. throw new Error("Seal preset not found.");
  160. }
  161. if (sealPreset.roomy * 5 + sealPreset.y === value || sealPreset.roomx * 5 + sealPreset.x === value) {
  162. return 1;
  163. }
  164. return 2;
  165. }
  166. this.initLayout = function() {
  167. vizLayout = getLayout(396, 5275); // 1 = "Y", 2 = "L"
  168. seisLayout = getLayout(394, 7773); // 1 = "2", 2 = "5"
  169. infLayout = getLayout(392, 7893); // 1 = "I", 2 = "J"
  170. }
  171. this.helperChaos = function() {
  172. this.helpAct = function(act, x, y) {
  173. if (act == "move") {
  174. var xPath = (clearMode == 0) ? true : false;
  175. Pather.moveTo(x, y, 3, xPath);
  176. Attack.clear(30, clearMode);
  177. }
  178. else if (act == "seal") {
  179. if (openSeal(x) == true) {
  180. if (y >= 1) delay(1000 * y);
  181. }
  182. }
  183. else if (act == "Infector of Souls" || act == "Lord de Seis" || act == "Grand Vizier of Chaos") {
  184. var boss = getUnit(1, act);
  185. if (!boss) {
  186. Pather.moveTo(x, y, 3, xPath);
  187. Attack.clear(30, clearMode);
  188. }
  189. boss = getUnit(1, act);
  190. if (boss) {
  191. if (boss.hp <= 0 || boss.mode == 0 || boss.mode == 12) {}
  192. else Attack.clear(30, clearMode, act);
  193. }
  194.  
  195. }
  196. else if (act == "Diablo") {
  197. for (i = 0; i < 40; i++) {
  198. if (!getUnit(1, 243)) {
  199.  
  200. Town.goToTown()
  201. Town.move("waypoint");
  202. Pather.useWaypoint(4, true);
  203. Town.goToTown();
  204. Pather.usePortal(null, "HydroPKHB");
  205. delay(me.ping*2 + 100);
  206. Misc.getShrinesInArea(me.area, 15, true);
  207. Pather.usePortal(null, null);
  208. Pather.usePortal(null, me.name);
  209. Pather.useWaypoint(103, true);
  210. Town.move("portalspot");
  211. }
  212. Town.goToTown(4);
  213.  
  214. while(!Pather.usePortal(108, null)) {
  215. delay(100);
  216. }
  217. }
  218. while (Attack.kill(243));
  219. if (!pickitDiablo) delay(100);
  220. Pickit.pickItems();
  221. }
  222. else throw new Error("Invalid helpAct");
  223. }
  224. for (i = 1; i < 121; i++) {
  225. delay(1000);
  226. if (i%10 == 0 && !Misc.inMyParty(chSorc)) quit();
  227. if (Pather.usePortal(108, chSorc) || me.area == 108) break;
  228. }
  229. for (i = 1; !me.getState(32); i++) {
  230. delay(1000);
  231. if (i%3 == 0) {
  232. say("bo");
  233. if (!Misc.inMyParty(boBarb)) quit();
  234. }
  235. }
  236. Precast.doPrecast(false);
  237. Attack.clear(15);
  238. initLayout();
  239. var preFect = ["move", 7825, 5294, "move", 7843, 5294, "move", 7861, 5294];
  240. var Fect = (infLayout == 1) ? ["move", 7890, 5295, "move", 7915, 5290, "seal", 392, 1, "Infector of Souls", 7890, 5295, "Infector of Souls", 7915, 5290, "seal", 393, 0] : ["move", 7900, 5275, "move", 7930, 5280, "move", 7930, 5310, "seal", 392, 1, "move", 7930, 5310, "Infector of Souls", 7930, 5280, "Infector of Souls", 7900, 5275, "seal", 393, 0];
  241. var preSeis = ["move", 7794, 5265, "move", 7794, 5245, "move", 7794, 5225];
  242. var Seis2 = (openSeisSeal) ? ["move", 7775, 5210, "move", 7775, 5195, "Lord de Seis", 7775, 5195, "Lord de Seis", 7775, 5210] : ["move", 7775, 5210, "move", 7775, 5195, "move", 7810, 5190, "move", 7810, 5155, "move", 7785, 5155, "seal", 394, 1, "Lord de Seis", 7775, 5195, "Lord de Seis", 7775, 5210];
  243. var Seis5 = (openSeisSeal) ? ["move", 7810, 5195, "move", 7780, 5190, "move", 7775, 5155, "Lord de Seis", 7775, 5155, "Lord de Seis", 7780, 5190, "move", 7780, 5190, "move", 7810, 5195] : ["move", 7810, 5195, "move", 7780, 5190, "move", 7775, 5155, "move", 7805, 5155, "seal", 394, 1, "Lord de Seis", 7775, 5155, "Lord de Seis", 7780, 5190, "move", 7780, 5190, "move", 7810, 5195];
  244. var Seis = (seisLayout == 1) ? Seis2 : Seis5;
  245. var preVizi = ["move", 7765, 5294, "move", 7745, 5294, "move", 7715, 5294];
  246. var Vizi = (vizLayout == 1) ? ["move", 7680, 5290, "move", 7665, 5275, "seal", 396, 2, "Grand Vizier of Chaos", 7665, 5275, "Grand Vizier of Chaos", 7680, 5290, "seal", 395, 0] : ["move", 7700, 5315, "move", 7670, 5315, "seal", 396, 2, "Grand Vizier of Chaos", 7670, 5315, "Grand Vizier of Chaos", 7700, 5315, "seal", 395, 0];
  247. var preDia = ["move", 7765, 5294, "move", 7794, 5294, "Diablo", 666, 999];
  248. var helpActQueue = preFect;
  249. helpActQueue = helpActQueue.concat(Fect);
  250. helpActQueue = helpActQueue.concat(preSeis);
  251. helpActQueue = helpActQueue.concat(Seis);
  252. helpActQueue = helpActQueue.concat(preVizi);
  253. helpActQueue = helpActQueue.concat(Vizi);
  254. helpActQueue = helpActQueue.concat(preDia);
  255. for (var j = 1; helpActQueue.length > j; j += 3) {
  256. this.helpAct(helpActQueue[j - 1], helpActQueue[j], helpActQueue[j + 1]);
  257. delay(100);
  258. }
  259. }
  260. this.comeCloser = function(i) {
  261. if (i >= 0 && i < 50) Pather.moveTo(5085, 5045);
  262. if (i >= 50 && i < 80) Pather.moveTo(5079, 5044);
  263. if (i >= 80 && i < 130) Pather.moveTo(5067, 5042);
  264. if (i >= 130 && i < 150) Pather.moveTo(5061, 5041);
  265. if (i >= 150 && i < 180) Pather.moveTo(5055, 5040);
  266. if (moveJamella && i%10 == 0) Packet.moveNPC(getUnit(1, "Jamella"), me.x, me.y + 3);
  267. if (moveHalbu && i%10 == 0) Packet.moveNPC(getUnit(1, "Halbu"), me.x, me.y - 1);
  268. }
  269. this.needGold = function() {
  270. if (me.getStat(14) + me.getStat(15) <= 10000) {
  271. for (i = 0; me.getStat(14) + me.getStat(15) <= 10000; i++) {
  272. if (i%150 == 0) {
  273. var goldMsg = (needGoldMsg) ? needGoldMsg : "i need some gold";
  274. say(goldMsg)
  275. }
  276. var gold = getUnit(4, 523, 3);
  277. if (gold) Pickit.pickItem(gold);
  278. delay(100);
  279. }
  280. Town.stash();
  281. }
  282. return true;
  283. }
  284. function GameEvent(mode, param1, param2, name1, name2) {
  285. switch (mode) {
  286. case 0x00:
  287. if (name1 == boBarb || name1 == chSorc) {
  288. quit();
  289. break;
  290. }
  291. case 0x01:
  292. if (name1 == boBarb || name1 == chSorc) {
  293. quit();
  294. break;
  295. }
  296. case 0x03:
  297. if (name1 == boBarb || name1 == chSorc) {
  298. quit();
  299. break;
  300. }
  301. }
  302. }
  303. function ChatEvent(nick, msg) {
  304. command = [msg, nick];
  305. }
  306. Town.goToTown(4);
  307. Town.doChores();
  308. Town.move("portalspot");
  309. if (helpChars.indexOf(me.name) > -1) {
  310. this.helperChaos();
  311. }
  312. if (me.name == boBarb) {
  313. for (i = 0; i < 600; i++) {
  314. if (Misc.inMyParty(chSorc)) break;
  315. delay(100);
  316. }
  317. if (!Misc.inMyParty(chSorc)) quit();
  318. addEventListener("gameevent", GameEvent);
  319. this.needGold();
  320. for (i = 0; me.area != 107; i++) {
  321. Pather.usePortal(107, chSorc);
  322. if (i > 9) quit();
  323. delay(100);
  324. }
  325. while (this.find(chSorc) != 108) {
  326. this.bo();
  327. delay(100);
  328. }
  329. say(teleMessage);
  330. Pather.useWaypoint(103);
  331. Town.move("portalspot");
  332. for (i = 0; me.area != 108; i++) {
  333. Pather.usePortal(108, chSorc);
  334. if (i > 9) quit();
  335. delay(100);
  336. }
  337. for (i = 0; i < 150; i++) {
  338. this.bo();
  339. delay(100);
  340. }
  341. Pather.usePortal(103, chSorc);
  342. addEventListener("chatmsg", ChatEvent);
  343. var check = 1;
  344. while (true) {
  345. if (command) {
  346. var cmd = command[0].toLowerCase();
  347. if (boCommands.indexOf(cmd) > -1) {
  348. this.checkHostiles();
  349. if (shitList.indexOf(command[1]) == -1) {
  350. this.bo(command[1]);
  351. }
  352. else if (shitList.indexOf(command[1]) > -1) say("Sorry, " + command[1] + " you're on my shitList.");
  353. }
  354. if (helpStartCommands.indexOf(cmd) > -1) {
  355. this.checkHostiles();
  356. if (shitList.indexOf(command[1]) == -1) {
  357. if (helpChars[0] && !this.find(helpChars[0])) {
  358. D2Bot.start(helpProfs[0]);
  359. say("Calling helper " + helpChars[0]);
  360. }
  361. else if (helpChars[1] && !this.find(helpChars[1])) {
  362. D2Bot.start(helpProfs[1]);
  363. say("Calling helper " + helpChars[1]);
  364. }
  365. else say("All the help is here.");
  366. }
  367. else if (shitList.indexOf(command[1]) > -1) say("Sorry, " + command[1] + " you're on my shitList.");
  368. }
  369. if (helpStopCommands.indexOf(cmd) > -1) {
  370. this.checkHostiles();
  371. if (shitList.indexOf(command[1]) == -1) {
  372. if (Misc.inMyParty(helpChars[0])) {
  373. D2Bot.stop(helpProfs[0]);
  374. say("Dismissed helper " + helpChars[0]);
  375. }
  376. else if (Misc.inMyParty(helpChars[1])) {
  377. D2Bot.stop(helpProfs[1]);
  378. say("Dismissed helper " + helpChars[1]);
  379. }
  380. else say("What help?");
  381. }
  382. else if (shitList.indexOf(command[1]) > -1) say("Sorry, " + command[1] + " you're on my shitList.");
  383. }
  384. command = false;
  385. }
  386. if (!Misc.inMyParty(chSorc)) break;
  387. if (gameLength > 0) {
  388. if (getTickCount() - me.gamestarttime >= gameLength * 6e4) break;
  389. }
  390. if (check%30 == 0) {
  391. Pather.usePortal(108, chSorc);
  392. this.bo();
  393. var diablo;
  394. if (getUnit(1, 243)) {
  395. while (true) {
  396. diablo = getUnit(1, 243);
  397. if (diablo.hp < 0 || diablo.mode == 0 || diablo.mode == 12) break;
  398. delay(5);
  399. }
  400. if (pickitDiablo) Pickit.pickItems();
  401. if (endGameMessage) say(endGameMessage);
  402. delay(100);
  403. break;
  404. }
  405. else {
  406. Pather.usePortal(103, chSorc);
  407. }
  408. }
  409. delay(100);
  410. check++;
  411. }
  412. }
  413. if (me.name == chSorc) {
  414. for (i = 0; i < 200; i++) {
  415. if (Misc.inMyParty(boBarb)) break;
  416. delay(100);
  417. }
  418. if (!Misc.inMyParty(boBarb)) quit();
  419. addEventListener("gameevent", GameEvent);
  420. this.needGold();
  421. Town.move("waypoint");
  422. me.cancel();
  423. Pather.useWaypoint(107);
  424. Pather.moveTo(me.x+3, me.y+3);
  425. Pather.makePortal();
  426. while (!me.getState(32)) delay(100);
  427. Precast.doPrecast(true);
  428. Pather.moveTo(7792, 5291, 3);
  429. if (openSeisSeal) {
  430. this.openSeal(394);
  431. Pather.moveTo(7792, 5291);
  432. }
  433. Pather.makePortal();
  434. say(starMessage);
  435. for (i = 0; i < 150; i++) {
  436. this.chant();
  437. delay(100);
  438. }
  439. Pather.usePortal(103, me.name);
  440. say(homeMessage);
  441. addEventListener("chatmsg", ChatEvent);
  442. var moveStage = 0;
  443. while (true) {
  444. if (command) {
  445. var cmd = command[0].toLowerCase();
  446. if (chCommands.indexOf(cmd) > -1) {
  447. this.checkHostiles();
  448. if (shitList.indexOf(command[1]) == -1) {
  449. this.chant(command[1]);
  450. }
  451. else if (shitList.indexOf(command[1]) > -1) say("Sorry, " + command[1] + " you're on my shitList.");
  452. }
  453. if (cmd == "help") {
  454. this.checkHostiles();
  455. if (shitList.indexOf(command[1]) > -1) say("No help for the shitListed.");
  456. else {
  457. if (chCommands) say("Chant command(s): " + chCommands);
  458. if (boCommands) say("BO command(s): " + boCommands);
  459. if (helpChars && helpProfs && helpStartCommands) say("To start a helper: " + helpStartCommands);
  460. if (helpChars && helpProfs && helpStopCommands) say("To stop a helper: " + helpStopCommands);
  461. }
  462. }
  463. command = false;
  464. }
  465. if (!Misc.inMyParty(boBarb)) break;
  466. if (gameLength > 0) {
  467. if (getTickCount() - me.gamestarttime >= gameLength * 6e4) break;
  468. }
  469. this.chant();
  470. if (moveJamella || moveHalbu) this.comeCloser(moveStage);
  471. delay(100);
  472. moveStage++;
  473. }
  474. }
  475. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement