Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2015
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.10 KB | None | 0 0
  1. var block;
  2. var intrade;
  3. var rolled;
  4. var gate;
  5. function ActFiveTravel() {
  6. var i, activeAction, wpgid, result, item, items, player,
  7. hooks = [];
  8.  
  9. addEventListener("chatmsg",
  10. function onMsg(nick, msg) {
  11. if (msg)
  12. wpgid = msg.split("A5WP ")[1];
  13. }
  14. );
  15.  
  16. function hookHandler(click, x, y) {
  17. // Get the hook closest to the clicked location
  18. function sortHooks(h1, h2) {
  19. return Math.abs(h1.y - y) - Math.abs(h2.y - y);
  20. }
  21.  
  22.  
  23. if (click === 0) { // Left click
  24. // Sort hooks
  25. hooks.sort(sortHooks);
  26.  
  27.  
  28. switch (hooks[0].text) {
  29. case "Act Five Travel:":
  30. return true; // Do nothing
  31. default:
  32. // Don't start new action until the current one finishes
  33. if (activeAction && activeAction !== hooks[0].text) {
  34. return true;
  35. }
  36.  
  37.  
  38. // Toggle current action on/off
  39. activeAction = activeAction ? false : hooks[0].text;
  40.  
  41.  
  42. break;
  43. }
  44.  
  45.  
  46. hooks[0].color = hooks[0].color === 2 ? 1 : 2;
  47.  
  48.  
  49. return true; // Block click
  50. }
  51.  
  52.  
  53. return false;
  54. }
  55.  
  56. // Storage override
  57. Storage.Stash.MoveTo = function (item) {
  58. var i, spot, tick;
  59.  
  60. if (Packet.itemToCursor(item)) {
  61. for (i = 0; i < 15; i += 1) {
  62. spot = Storage.Stash.FindSpot(item); // Returns inverted coords...
  63.  
  64. if (spot) {
  65. // 18 [DWORD id] [DWORD xpos] [DWORD ypos] [DWORD buffer]
  66. sendPacket(1, 0x18, 4, item.gid, 4, spot.y, 4, spot.x, 4, 0x4);
  67. }
  68.  
  69. tick = getTickCount();
  70.  
  71. while (getTickCount() - tick < Math.max(1000, me.ping * 2 + 200)) {
  72. if (!me.itemoncursor) {
  73. return true;
  74. }
  75.  
  76. delay(10);
  77. }
  78. }
  79. }
  80.  
  81. return false;
  82. };
  83.  
  84. function sortPickList(a, b) { // Sort items by size to pick biggest first
  85. if (b.sizex === a.sizex && b.sizey === a.sizey) { // Same size - sort by distance
  86. return getDistance(me, a) - getDistance(me, b);
  87. }
  88.  
  89. return b.sizex * b.sizey - a.sizex * a.sizey;
  90. }
  91.  
  92. var PacketSent = function (pByte) {
  93. switch (pByte[0]) {
  94. case 0x30:
  95. if (block)
  96. return true;
  97. else
  98. return false;
  99.  
  100. default:
  101. return false;
  102. }
  103. };
  104.  
  105. var PacketGet = function (pByte) {
  106. switch (pByte[0]) {
  107. case 0x78:
  108. intrade = true;
  109.  
  110. return false;
  111. case 0x92:
  112. rolled = true;
  113.  
  114. return false;
  115. default:
  116.  
  117. return false;
  118. }
  119. };
  120.  
  121.  
  122. this.playerIn = function (area) {
  123. if (!area) {
  124. area = me.area;
  125. }
  126.  
  127.  
  128. var party = getParty();
  129.  
  130.  
  131. if (party) {
  132. do {
  133. if (party.name !== me.name && party.area === area) {
  134. return true;
  135. }
  136. } while (party.getNext());
  137. }
  138.  
  139.  
  140. return false;
  141. };
  142.  
  143.  
  144. //var infoBG = new Box (10, 380, 170, 100, 0, 0.2),
  145. // infoFrame = new Frame (10, 380, 170, 100);
  146.  
  147.  
  148. //hooks.push(new Text("Act Five Travel:", 785, 92, 4, 1, 1, false, hookHandler));
  149. hooks.push(new Text("Share A5", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  150. hooks.push(new Text("Get A5", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  151. hooks.push(new Text("Harrogath", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  152. hooks.push(new Text("Frigid", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  153. //hooks.push(new Text("Arreat Plateau", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  154. //hooks.push(new Text("Crystalline Passage", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  155. //hooks.push(new Text("Glacial Trail", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  156. //hooks.push(new Text("Halls Of Pain", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  157. //hooks.push(new Text("Frozen Tundra", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  158. hooks.push(new Text("Ancients", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  159. hooks.push(new Text("Worldstone", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  160. hooks.push(new Text("", 785, 92, 8, 1, 1, false, hookHandler));
  161. hooks.push(new Text("Empty Inventory", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  162. hooks.push(new Text("Empty Stash", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  163. hooks.push(new Text("Empty Cube", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  164. hooks.push(new Text("Inventory to Stash", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  165. hooks.push(new Text("Pick Items", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  166. hooks.push(new Text("", 785, 92, 8, 1, 1, false, hookHandler));
  167. hooks.push(new Text("Socket Q", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  168. hooks.push(new Text("A5 Dupe", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
  169.  
  170.  
  171. while (true) {
  172. switch (activeAction) {
  173. case "Share A5":
  174. Town.doChores();
  175. Pather.journeyTo(4);
  176.  
  177. try {
  178. result = getCollision(4, 5114, 5069);
  179.  
  180. } catch (e) {
  181. activeAction = false;
  182. break;
  183.  
  184. }
  185.  
  186.  
  187. // Avoid non-walkable spots, objects
  188. if (result === undefined || (result & 0x1) || (result & 0x400)) {
  189. activeAction = false;
  190. break;
  191.  
  192. }
  193.  
  194. Pather.moveTo(5114,5069,5);
  195.  
  196. Pather.makePortal();
  197.  
  198.  
  199. Attack.securePosition(me.x, me.y, 30, 3000);
  200.  
  201.  
  202. Pather.usePortal (1, null);
  203.  
  204.  
  205. Pather.useWaypoint (109);
  206.  
  207. while (!me.area) delay (100);
  208.  
  209. if (me.act === 5) {
  210. say("A5WP " + getUnit(2, "Waypoint").gid);
  211. }
  212.  
  213. activeAction = false;
  214.  
  215. break;
  216.  
  217. case "Get A5":
  218. if (!wpgid) {
  219. print("we dont have wp GID. Can't access A5");
  220. activeAction = false;
  221. break;
  222. }
  223.  
  224. Town.move("portalspot");
  225.  
  226. while (!Pather.usePortal (4, null)) {
  227. delay (1);
  228.  
  229. }
  230.  
  231. // Waypoint UI
  232. while (!getUIFlag (0x14)) {
  233. Pather.moveTo (5116,5067,5);
  234. sendPacket (1, 0x13, 4, 0x02, 4, wpgid);
  235. delay (100);
  236.  
  237. }
  238.  
  239. while (getUIFlag (0x14)) {
  240. me.cancel ();
  241.  
  242. }
  243.  
  244. Pather.usePortal (1, null);
  245.  
  246. Pather.useWaypoint (109);
  247.  
  248. if (me.area == 109)
  249. say("Welcome to A5");
  250.  
  251. activeAction = false;
  252.  
  253.  
  254. break;
  255.  
  256.  
  257. case "Socket Q":
  258. Town.doChores();
  259. say("starting socket quest");
  260. Pather.useWaypoint (111);
  261. Precast.doPrecast(false);
  262. Pather.moveTo(3846, 5120);
  263. Attack.securePosition(me.x, me.y, 30, 3000);
  264. Pather.makePortal();
  265. say("tp up for socket quest");
  266.  
  267.  
  268. while (!this.playerIn()) {
  269. delay(200);
  270. }
  271. Attack.kill(getLocaleString(22435));
  272. Pather.moveTo(3846, 5120);
  273. say("socket quest completed");
  274.  
  275.  
  276. Pather.usePortal (109, null);
  277.  
  278.  
  279. activeAction = false;
  280.  
  281.  
  282. break;
  283.  
  284.  
  285. case "A5 Dupe":
  286. Town.goToTown(5);
  287. Town.move("nihlathak");
  288.  
  289.  
  290. var nith = getUnit (1, "nihlathak");
  291.  
  292. while (!nith.openMenu())
  293. delay(1);
  294.  
  295. me.cancel();
  296.  
  297.  
  298. addEventListener("gamepacketsent", PacketSent);
  299. addEventListener("gamepacket", PacketGet);
  300.  
  301. Town.move("nihlathak");
  302.  
  303.  
  304. var gate = getUnit(2, 449);
  305.  
  306. block = true;
  307.  
  308. var nith = getUnit (1, "nihlathak");
  309.  
  310. while (!nith.openMenu())
  311. delay(1);
  312.  
  313. me.cancel();
  314.  
  315. block = false;
  316.  
  317.  
  318. Pather.moveTo(5052, 5098);
  319.  
  320.  
  321. say("put any crap item on cursor. the item will disappear");
  322.  
  323. while (!getUnit(100))
  324. delay(1);
  325.  
  326.  
  327. var cursor = getUnit(100);
  328.  
  329.  
  330. sendPacket(1, 0x44, 4, 0, 4, gate.gid, 4, cursor.gid, 4, 3);
  331.  
  332. me.cancel();
  333.  
  334.  
  335. Pather.moveTo(5113,5064);
  336.  
  337.  
  338. say("start trade");
  339.  
  340. while(!intrade)
  341. delay(1);
  342.  
  343.  
  344. getPacket(1, 0x77, 1, 0x0C);
  345.  
  346. sendPacket (1, 0x31, 4, me.gid, 4, 0x4EA3);
  347.  
  348.  
  349. Town.move("waypoint");
  350. Pather.useWaypoint(1);
  351. Town.move("stash");
  352. delay(1);
  353.  
  354.  
  355. // drop items to dupe
  356. var dupes = me.findItems(-1, 0, 3);
  357.  
  358. if (dupes) {
  359. while (dupes.length) {
  360. var drop = dupes.shift();
  361.  
  362. if (drop.classid !== 549)
  363. Packet.dropItem(drop);
  364. }
  365. }
  366.  
  367. say ("now cancel trade on second char");
  368.  
  369. while(!rolled)
  370. delay(1);
  371.  
  372. // drop all items to avoid lost in case of corrupted char
  373. var dupes = me.findItems(-1, 0, 3);
  374.  
  375. if (dupes) {
  376. while (dupes.length) {
  377. var drop = dupes.shift();
  378.  
  379. if (drop.classid !== 549)
  380. Packet.dropItem(drop);
  381. }
  382. }
  383.  
  384.  
  385. activeAction = false;
  386.  
  387.  
  388. break;
  389.  
  390.  
  391. case "Harrogath":
  392. Town.goToTown();
  393. if(!Pather.useWaypoint(109))
  394. me.overhead("Use Waypoint failed");
  395.  
  396. activeAction = false;
  397.  
  398.  
  399. break;
  400.  
  401. case "Frigid":
  402. Town.goToTown();
  403. if(!Pather.useWaypoint(111))
  404. me.overhead("Use Waypoint failed");
  405.  
  406. activeAction = false;
  407.  
  408.  
  409. break;
  410.  
  411. case "Arreat Plateau":
  412. Town.goToTown();
  413. if(!Pather.useWaypoint(112))
  414. me.overhead("Use Waypoint failed");
  415.  
  416. activeAction = false;
  417.  
  418.  
  419. break;
  420.  
  421. case "Crystalline Passage":
  422. Town.goToTown();
  423. if(!Pather.useWaypoint(113))
  424. me.overhead("Use Waypoint failed");
  425.  
  426. activeAction = false;
  427.  
  428.  
  429. break;
  430.  
  431. case "Glacial Trail":
  432. Town.goToTown();
  433. if(!Pather.useWaypoint(115))
  434. me.overhead("Use Waypoint failed");
  435.  
  436. activeAction = false;
  437.  
  438.  
  439. break;
  440. /*
  441. case "Halls Of Pain":
  442. Town.goToTown();
  443. if(!Pather.useWaypoint(123))
  444. me.overhead("Use Waypoint failed");
  445.  
  446. activeAction = false;
  447.  
  448.  
  449. break;
  450. */
  451. case "Frozen Tundra":
  452. Town.goToTown();
  453. if(!Pather.useWaypoint(117))
  454. me.overhead("Use Waypoint failed");
  455.  
  456. activeAction = false;
  457.  
  458.  
  459. break;
  460.  
  461. case "Ancients":
  462. Town.goToTown();
  463. if(!Pather.useWaypoint(118))
  464. me.overhead("Use Waypoint failed");
  465.  
  466. activeAction = false;
  467.  
  468.  
  469. break;
  470.  
  471. case "Worldstone":
  472. Town.goToTown();
  473. if(!Pather.useWaypoint(129))
  474. me.overhead("Use Waypoint failed");
  475.  
  476. activeAction = false;
  477.  
  478.  
  479. break;
  480.  
  481.  
  482. case "Empty Inventory":
  483. items = me.findItems(-1, 0, 3);
  484.  
  485.  
  486. if (items) {
  487. while (activeAction && items.length > 0) {
  488. Packet.dropItem(items.shift());
  489. }
  490. }
  491.  
  492.  
  493. activeAction = false;
  494.  
  495.  
  496. break;
  497. case "Empty Stash":
  498. case "Empty Cube":
  499. if (!me.inTown || !Town.openStash()) {
  500. me.overhear("Failed to open stash");
  501.  
  502.  
  503. activeAction = false;
  504.  
  505.  
  506. break;
  507. }
  508.  
  509.  
  510. items = me.findItems(-1, 0, activeAction === "Empty Stash" ? 7 : 6);
  511.  
  512.  
  513. if (items) {
  514. while (activeAction && items.length > 0) {
  515. item = items.shift();
  516.  
  517.  
  518. if (item.classid !== 549) { // Don't drop the cube
  519. Packet.dropItem(item);
  520. }
  521. }
  522. }
  523.  
  524.  
  525. me.cancel();
  526.  
  527.  
  528. activeAction = false;
  529.  
  530.  
  531. break;
  532. case "Inventory to Stash":
  533. items = me.findItems(-1, 0, 3);
  534.  
  535.  
  536. if (items) {
  537. while (activeAction && items.length > 0) {
  538. item = items.shift();
  539.  
  540.  
  541. if (Storage.Stash.CanFit(item)) {
  542. Storage.Stash.MoveTo(item);
  543. }
  544. }
  545. }
  546.  
  547.  
  548. activeAction = false;
  549.  
  550.  
  551. break;
  552. case "Pick Items":
  553. item = getUnit(4, -1, 3);
  554. items = [];
  555.  
  556.  
  557. if (item) {
  558. do {
  559. items.push(copyUnit(item));
  560. } while (item.getNext());
  561. }
  562.  
  563.  
  564. while (activeAction && items.length > 0) {
  565. items.sort(sortPickList);
  566.  
  567.  
  568. item = items.shift();
  569.  
  570.  
  571. if (Town.ignoredItemTypes.indexOf(item.itemType) === -1 && Storage.Inventory.CanFit(item)) {
  572. Pickit.pickItem(item);
  573. }
  574. }
  575.  
  576.  
  577. activeAction = false;
  578.  
  579.  
  580. break;
  581. default:
  582. for (i = 0; i < hooks.length; i += 1) {
  583. if (hooks[i].color === 1) {
  584. hooks[i].color = 2;
  585. }
  586. }
  587.  
  588.  
  589. break;
  590. }
  591.  
  592.  
  593. delay(100);
  594. }
  595. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement