Advertisement
Guest User

Untitled

a guest
May 24th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.00 KB | None | 0 0
  1. /**
  2. * @filename boChantCS.js
  3. * @author darjamalos von keelinstein
  4. * @desc Bo and enchant other players, add/remove helper(s) to clear
  5. **/
  6. function boChantCS() {
  7. var chSorc = "Erwin_Rommel", // CHAR name of enchant sorc
  8. boBarb = "BYOB", // CHAR name of BO barbarian
  9. chCommands = ["chant"], // list of commands to chant player, use only lowercase letters
  10. boCommands = ["bo"], // list of commands to BO the player, use only lowercase letters
  11. helpChars = ["geothermal" , "skynyrd"], // CHAR name(s) of helper(s) e.g. ["char"], or ["char1", "char2"], 2 chars max
  12. helpProfs = ["agility." ,"hillbilly"], // PROFILE name(s) of helper(s) e.g. ["profile"] or ["profile1", "profile2"]
  13. helpStartCommands = [""], // list of commands to start a helper, use only lowercase letters
  14. helpStopCommands = ["asdfghjkl"], // 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 = 9, // maximum game length, in minutes. leave = 0 for infinite
  17. teleMessage = "get ready!", // message from barb while sorc teleporting to star
  18. starMessage = "Star TP up", // 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 = "ok guys lets start over!", // message at the end of the game
  21. needGoldMsg = "bring me gold please! drop close in front of me!", // message used when low on gold to ask players for more
  22. checkShrineBo = true, // check for bo shrines in the immediate area when bo'ing
  23. openSeisSeal = true, // 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(100);
  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. Pather.moveToPreset(108, 2, id, 4);
  140. var seal = getUnit(2, id);
  141. if (!seal) return false;
  142. i = 0;
  143. while (!seal.mode) {
  144. if (!Skill.cast(43, 0, seal)) seal.interact();
  145. delay(100);
  146. if (seal.mode == 0) {
  147. delay(400);
  148. i++
  149. }
  150. if (i > 30) return false;
  151. }
  152. return true;
  153. }
  154. this.getLayout = function(seal, value) {
  155. var sealPreset = getPresetUnit(108, 2, seal);
  156. if (!seal) {
  157. throw new Error("Seal preset not found.");
  158. }
  159. if (sealPreset.roomy * 5 + sealPreset.y === value || sealPreset.roomx * 5 + sealPreset.x === value) {
  160. return 1;
  161. }
  162. return 2;
  163. }
  164. this.initLayout = function() {
  165. vizLayout = getLayout(396, 5275); // 1 = "Y", 2 = "L"
  166. seisLayout = getLayout(394, 7773); // 1 = "2", 2 = "5"
  167. infLayout = getLayout(392, 7893); // 1 = "I", 2 = "J"
  168. }
  169. this.helperChaos = function() {
  170. for (i = 1; i < 121; i++) {
  171. delay(1000);
  172. if (i%10 == 0 && !Misc.inMyParty(chSorc)) quit();
  173. if (Pather.usePortal(108, chSorc) || me.area == 108) break;
  174. }
  175. for (i = 1; !me.getState(32); i++) {
  176. delay(1000);
  177. if (i%3 == 0) {
  178. say("bo");
  179. if (!Misc.inMyParty(boBarb)) quit();
  180. }
  181. }
  182. Precast.doPrecast(false);
  183. initLayout();
  184. Attack.clear(15);
  185. Pather.moveTo(7825, 5294);
  186. Attack.clear(30, clearMode);
  187. Pather.moveTo(7843, 5294);
  188. Attack.clear(30, clearMode);
  189. Pather.moveTo(7861, 5294);
  190. Attack.clear(30, clearMode);
  191. if (infLayout == 1) { // "I"
  192. Pather.moveTo(7890, 5295);
  193. Attack.clear(30, clearMode);
  194. Pather.moveTo(7915, 5290);
  195. Attack.clear(30, clearMode);
  196. this.openSeal(392);
  197. delay(500);
  198. Pather.moveTo(7890, 5295);
  199. if (getUnit(1, getLocaleString(2853))) Attack.clear(30, clearMode, getLocaleString(2853))
  200. else {
  201. Attack.clear(30, clearMode);
  202. Pather.moveTo(7915, 5290);
  203. (getUnit(1, getLocaleString(2853))) ? Attack.clear(30, clearMode, getLocaleString(2853)) : Attack.clear(30, clearMode);
  204. }
  205. this.openSeal(393);
  206. }
  207. if (infLayout == 2) { // "J"
  208. Pather.moveTo(7900, 5275);
  209. Attack.clear(30, clearMode);
  210. Pather.moveTo(7930, 5280);
  211. Attack.clear(30, clearMode);
  212. Pather.moveTo(7930, 5310);
  213. Attack.clear(30, clearMode);
  214. this.openSeal(392);
  215. delay(1000);
  216. Pather.moveTo(7930, 5280);
  217. if (getUnit(1, getLocaleString(2853))) Attack.clear(30, clearMode, getLocaleString(2853))
  218. else {
  219. Attack.clear(30, clearMode);
  220. Pather.moveTo(7900, 5275);
  221. (getUnit(1, getLocaleString(2853))) ? Attack.clear(30, clearMode, getLocaleString(2853)) : Attack.clear(30, clearMode);
  222. }
  223. this.openSeal(393);
  224. }
  225. Pather.moveTo(7794, 5265);
  226. Attack.clear(30, clearMode);
  227. Pather.moveTo(7794, 5244);
  228. Attack.clear(30, clearMode);
  229. Pather.moveTo(7794, 5215);
  230. Attack.clear(30, clearMode);
  231. if (seisLayout == 1) { // "2"
  232. Pather.moveTo(7775, 5195);
  233. Attack.clear(30, clearMode);
  234. if (!openSeisSeal) {
  235. Pather.moveTo(7810, 5190);
  236. Attack.clear(30, clearMode);
  237. Pather.moveTo(7810, 5155);
  238. Attack.clear(30, clearMode);
  239. Pather.moveTo(7785, 5155);
  240. Attack.clear(30, clearMode);
  241. this.openSeal(394);
  242. Pather.moveTo(7775, 5195);
  243. if (getUnit(1, getLocaleString(2852))) Attack.clear(30, clearMode, getLocaleString(2852))
  244. else {
  245. Attack.clear(30, clearMode);
  246. Pather.moveTo(7794, 5215);
  247. (getUnit(1, getLocaleString(2852))) ? Attack.clear(30, clearMode, getLocaleString(2852)) : Attack.clear(30, clearMode);
  248. }
  249. }
  250. }
  251. if (seisLayout == 2) { // "5"
  252. Pather.moveTo(7810, 5195);
  253. Attack.clear(30, clearMode);
  254. Pather.moveTo(7780, 5190);
  255. Attack.clear(30, clearMode);
  256. Pather.moveTo(7775, 5155);
  257. Attack.clear(30, clearMode);
  258. if (!openSeisSeal) {
  259. Pather.moveTo(7805, 5155);
  260. Attack.clear(30, clearMode);
  261. this.openSeal(394);
  262. Pather.moveTo(7775, 5155);
  263. if (getUnit(1, getLocaleString(2852))) Attack.clear(30, clearMode, getLocaleString(2852))
  264. else {
  265. Attack.clear(30, clearMode);
  266. Pather.moveTo(7780, 5190);
  267. (getUnit(1, getLocaleString(2852))) ? Attack.clear(30, clearMode, getLocaleString(2852)) : Attack.clear(30, clearMode);
  268. }
  269. }
  270. Pather.moveTo(7780, 5190);
  271. Pather.moveTo(7810, 5195);
  272. }
  273. Pather.moveTo(7765, 5294);
  274. Attack.clear(30, clearMode);
  275. Pather.moveTo(7736, 5294);
  276. Attack.clear(30, clearMode);
  277. Pather.moveTo(7700, 5294);
  278. Attack.clear(30, clearMode);
  279. if (vizLayout == 1) { // "Y"
  280. Pather.moveTo(7680, 5290);
  281. Attack.clear(30, clearMode);
  282. Pather.moveTo(7665, 5275);
  283. Attack.clear(30, clearMode);
  284. this.openSeal(396);
  285. delay(1000);
  286. Pather.moveTo(7680, 5290);
  287. if (getUnit(1, getLocaleString(2851))) Attack.clear(30, clearMode, getLocaleString(2851))
  288. else {
  289. Attack.clear(30, clearMode);
  290. Pather.moveTo(7665, 5310);
  291. (getUnit(1, getLocaleString(2851))) ? Attack.clear(30, clearMode, getLocaleString(2851)) : Attack.clear(30, clearMode);
  292. }
  293. this.openSeal(395);
  294. }
  295. if (vizLayout == 2) { // "L"
  296. Pather.moveTo(7700, 5315);
  297. Attack.clear(30, clearMode);
  298. Pather.moveTo(7670, 5315);
  299. Attack.clear(30, clearMode);
  300. this.openSeal(396);
  301. delay(1000);
  302. if (getUnit(1, getLocaleString(2851))) Attack.clear(30, clearMode, getLocaleString(2851))
  303. else {
  304. Attack.clear(30, clearMode);
  305. Pather.moveTo(7700, 5315);
  306. if (getUnit(1, getLocaleString(2851))) Attack.clear(30, clearMode, getLocaleString(2851))
  307. else {
  308. Attack.clear(30, clearMode);
  309. Pather.moveTo(7700, 5294);
  310. (getUnit(1, getLocaleString(2851))) ? Attack.clear(30, clearMode, getLocaleString(2851)) : Attack.clear(30, clearMode);
  311. }
  312. }
  313. this.openSeal(395);
  314. }
  315. Pather.moveTo(7794, 5294);
  316. for (i = 0; i < 40; i++) {
  317. if (!getUnit(1, 243)) {
  318. delay(500);
  319. }
  320. }
  321. if (getUnit(1, 243)) Attack.kill(243);
  322. if (pickitDiablo) Pickit.pickItems();
  323. }
  324. this.comeCloser = function(i) {
  325. if (i >= 0 && i < 50) Pather.moveTo(5085, 5045);
  326. if (i >= 50 && i < 80) Pather.moveTo(5079, 5044);
  327. if (i >= 80 && i < 130) Pather.moveTo(5067, 5042);
  328. if (i >= 130 && i < 150) Pather.moveTo(5061, 5041);
  329. if (i >= 150 && i < 180) Pather.moveTo(5055, 5040);
  330. if (moveJamella && i%10 == 0) Packet.moveNPC(getUnit(1, "Jamella"), me.x, me.y + 3);
  331. if (moveHalbu && i%10 == 0) Packet.moveNPC(getUnit(1, "Halbu"), me.x, me.y - 2);
  332. }
  333. this.needGold = function() {
  334. if (me.getStat(14) + me.getStat(15) <= 10000) {
  335. for (i = 0; me.getStat(14) + me.getStat(15) <= 10000; i++) {
  336. if (i%150 == 0) {
  337. var goldMsg = (needGoldMsg) ? needGoldMsg : "i need some gold";
  338. say(goldMsg)
  339. }
  340. var gold = getUnit(4, 523, 3);
  341. if (gold) Pickit.pickItem(gold);
  342. delay(100);
  343. }
  344. Town.stash();
  345. }
  346. return true;
  347. }
  348. function GameEvent(mode, param1, param2, name1, name2) {
  349. switch (mode) {
  350. case 0x00:
  351. if (name1 == boBarb || name1 == chSorc) {
  352. quit();
  353. break;
  354. }
  355. case 0x01:
  356. if (name1 == boBarb || name1 == chSorc) {
  357. quit();
  358. break;
  359. }
  360. case 0x03:
  361. if (name1 == boBarb || name1 == chSorc) {
  362. quit();
  363. break;
  364. }
  365. }
  366. }
  367. function ChatEvent(nick, msg) {
  368. command = [msg, nick];
  369. }
  370. Town.goToTown(4);
  371. Town.doChores();
  372. Town.move("portalspot");
  373. if (helpChars.indexOf(me.name) > -1) {
  374. this.helperChaos();
  375. }
  376. if (me.name == boBarb) {
  377. for (i = 0; i < 200; i++) {
  378. if (Misc.inMyParty(chSorc)) break;
  379. delay(100);
  380. }
  381. if (!Misc.inMyParty(chSorc)) quit();
  382. addEventListener("gameevent", GameEvent);
  383. this.needGold();
  384. while (me.area != 107) {
  385. Pather.usePortal(107, chSorc);
  386. delay(100);
  387. }
  388. while (this.find(chSorc) != 108) {
  389. this.bo();
  390. delay(100);
  391. }
  392. say(teleMessage);
  393. Pather.useWaypoint(103);
  394. Town.move("portalspot");
  395. while (me.area != 108) {
  396. Pather.usePortal(108, chSorc);
  397. delay(100);
  398. }
  399. for (i = 0; i < 150; i++) {
  400. this.bo();
  401. delay(100);
  402. }
  403. Pather.usePortal(103, chSorc);
  404. addEventListener("chatmsg", ChatEvent);
  405. var check = 1;
  406. while (true) {
  407. if (command) {
  408. var cmd = command[0].toLowerCase();
  409. if (boCommands.indexOf(cmd) > -1) {
  410. this.checkHostiles();
  411. if (shitList.indexOf(command[1]) == -1) {
  412. this.bo(command[1]);
  413. }
  414. else if (shitList.indexOf(command[1]) > -1) say("Sorry, " + command[1] + " you're on my shitList.");
  415. }
  416. if (helpStartCommands.indexOf(cmd) > -1) {
  417. this.checkHostiles();
  418. if (shitList.indexOf(command[1]) == -1) {
  419. if (helpChars[0] && !this.find(helpChars[0])) {
  420. D2Bot.start(helpProfs[0]);
  421. say("Calling helper " + helpChars[0]);
  422. }
  423. else if (helpChars[1] && !this.find(helpChars[1])) {
  424. D2Bot.start(helpProfs[1]);
  425. say("Calling helper " + helpChars[1]);
  426. }
  427. else say("All the help is here.");
  428. }
  429. else if (shitList.indexOf(command[1]) > -1) say("Sorry, " + command[1] + " you're on my shitList.");
  430. }
  431. if (helpStopCommands.indexOf(cmd) > -1) {
  432. this.checkHostiles();
  433. if (shitList.indexOf(command[1]) == -1) {
  434. if (Misc.inMyParty(helpChars[0])) {
  435. D2Bot.stop(helpProfs[0]);
  436. say("Dismissed helper " + helpChars[0]);
  437. }
  438. else if (Misc.inMyParty(helpChars[1])) {
  439. D2Bot.stop(helpProfs[1]);
  440. say("Dismissed helper " + helpChars[1]);
  441. }
  442. else say("What help?");
  443. }
  444. else if (shitList.indexOf(command[1]) > -1) say("Sorry, " + command[1] + " you're on my shitList.");
  445. }
  446. command = false;
  447. }
  448. if (!Misc.inMyParty(chSorc)) break;
  449. if (gameLength > 0) {
  450. if (getTickCount() - me.gamestarttime >= gameLength * 6e4) break;
  451. }
  452. if (check%30 == 0) {
  453. Pather.usePortal(108, chSorc);
  454. var diablo;
  455. if (getUnit(1, 243)) {
  456. while (true) {
  457. diablo = getUnit(1, 243);
  458. if (diablo.hp < 0 || diablo.mode == 0 || diablo.mode == 12) break;
  459. delay(5);
  460. }
  461. if (pickitDiablo) Pickit.pickItems();
  462. if (endGameMessage) say(endGameMessage);
  463. delay(100);
  464. break;
  465. }
  466. else Pather.usePortal(103, chSorc);
  467. }
  468. delay(100);
  469. check++;
  470. }
  471. }
  472. if (me.name == chSorc) {
  473. for (i = 0; i < 200; i++) {
  474. if (Misc.inMyParty(boBarb)) break;
  475. delay(100);
  476. }
  477. if (!Misc.inMyParty(boBarb)) quit();
  478. addEventListener("gameevent", GameEvent);
  479. this.needGold();
  480. Town.move("waypoint");
  481. me.cancel();
  482. Pather.useWaypoint(107);
  483. Pather.moveTo(me.x+3, me.y+3);
  484. Pather.makePortal();
  485. while (!me.getState(32)) delay(100);
  486. Precast.doPrecast(true);
  487. Pather.moveTo(7792, 5291);
  488. if (openSeisSeal) {
  489. this.openSeal(394);
  490. Pather.moveTo(7792, 5291);
  491. }
  492. Pather.makePortal();
  493. say(starMessage);
  494. for (i = 0; i < 150; i++) {
  495. this.chant();
  496. delay(100);
  497. }
  498. Pather.usePortal(103, me.name);
  499. say(homeMessage);
  500. addEventListener("chatmsg", ChatEvent);
  501. var moveStage = 0;
  502. while (true) {
  503. if (command) {
  504. var cmd = command[0].toLowerCase();
  505. if (chCommands.indexOf(cmd) > -1) {
  506. this.checkHostiles();
  507. if (shitList.indexOf(command[1]) == -1) {
  508. this.chant(command[1]);
  509. }
  510. else if (shitList.indexOf(command[1]) > -1) say("Sorry, " + command[1] + " you're on my shitList.");
  511. }
  512. if (cmd == "help") {
  513. this.checkHostiles();
  514. if (shitList.indexOf(command[1]) > -1) say("No help for the shitListed.");
  515. else {
  516. if (chCommands) say("Chant command(s): " + chCommands);
  517. if (boCommands) say("BO command(s): " + boCommands);
  518. if (helpChars && helpProfs && helpStartCommands) say("To start a helper: " + helpStartCommands);
  519. if (helpChars && helpProfs && helpStopCommands) say("To stop a helper: " + helpStopCommands);
  520. }
  521. }
  522. command = false;
  523. }
  524. if (!Misc.inMyParty(boBarb)) break;
  525. if (gameLength > 0) {
  526. if (getTickCount() - me.gamestarttime >= gameLength * 6e4) break;
  527. }
  528. this.chant();
  529. if (moveJamella || moveHalbu) this.comeCloser(moveStage);
  530. delay(100);
  531. moveStage++;
  532. }
  533. }
  534. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement