Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var block;
- var intrade;
- var rolled;
- var gate;
- function ActFiveTravel() {
- var i, activeAction, wpgid, result, item, items, player,
- hooks = [];
- addEventListener("chatmsg",
- function onMsg(nick, msg) {
- if (msg)
- wpgid = msg.split("A5WP ")[1];
- }
- );
- function hookHandler(click, x, y) {
- // Get the hook closest to the clicked location
- function sortHooks(h1, h2) {
- return Math.abs(h1.y - y) - Math.abs(h2.y - y);
- }
- if (click === 0) { // Left click
- // Sort hooks
- hooks.sort(sortHooks);
- switch (hooks[0].text) {
- case "Act Five Travel:":
- return true; // Do nothing
- default:
- // Don't start new action until the current one finishes
- if (activeAction && activeAction !== hooks[0].text) {
- return true;
- }
- // Toggle current action on/off
- activeAction = activeAction ? false : hooks[0].text;
- break;
- }
- hooks[0].color = hooks[0].color === 2 ? 1 : 2;
- return true; // Block click
- }
- return false;
- }
- // Storage override
- Storage.Stash.MoveTo = function (item) {
- var i, spot, tick;
- if (Packet.itemToCursor(item)) {
- for (i = 0; i < 15; i += 1) {
- spot = Storage.Stash.FindSpot(item); // Returns inverted coords...
- if (spot) {
- // 18 [DWORD id] [DWORD xpos] [DWORD ypos] [DWORD buffer]
- sendPacket(1, 0x18, 4, item.gid, 4, spot.y, 4, spot.x, 4, 0x4);
- }
- tick = getTickCount();
- while (getTickCount() - tick < Math.max(1000, me.ping * 2 + 200)) {
- if (!me.itemoncursor) {
- return true;
- }
- delay(10);
- }
- }
- }
- return false;
- };
- function sortPickList(a, b) { // Sort items by size to pick biggest first
- if (b.sizex === a.sizex && b.sizey === a.sizey) { // Same size - sort by distance
- return getDistance(me, a) - getDistance(me, b);
- }
- return b.sizex * b.sizey - a.sizex * a.sizey;
- }
- var PacketSent = function (pByte) {
- switch (pByte[0]) {
- case 0x30:
- if (block)
- return true;
- else
- return false;
- default:
- return false;
- }
- };
- var PacketGet = function (pByte) {
- switch (pByte[0]) {
- case 0x78:
- intrade = true;
- return false;
- case 0x92:
- rolled = true;
- return false;
- default:
- return false;
- }
- };
- this.playerIn = function (area) {
- if (!area) {
- area = me.area;
- }
- var party = getParty();
- if (party) {
- do {
- if (party.name !== me.name && party.area === area) {
- return true;
- }
- } while (party.getNext());
- }
- return false;
- };
- //var infoBG = new Box (10, 380, 170, 100, 0, 0.2),
- // infoFrame = new Frame (10, 380, 170, 100);
- //hooks.push(new Text("Act Five Travel:", 785, 92, 4, 1, 1, false, hookHandler));
- hooks.push(new Text("Share A5", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- hooks.push(new Text("Get A5", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- hooks.push(new Text("Harrogath", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- hooks.push(new Text("Frigid", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- //hooks.push(new Text("Arreat Plateau", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- //hooks.push(new Text("Crystalline Passage", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- //hooks.push(new Text("Glacial Trail", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- //hooks.push(new Text("Halls Of Pain", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- //hooks.push(new Text("Frozen Tundra", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- hooks.push(new Text("Ancients", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- hooks.push(new Text("Worldstone", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- hooks.push(new Text("", 785, 92, 8, 1, 1, false, hookHandler));
- hooks.push(new Text("Empty Inventory", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- hooks.push(new Text("Empty Stash", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- hooks.push(new Text("Empty Cube", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- hooks.push(new Text("Inventory to Stash", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- hooks.push(new Text("Pick Items", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- hooks.push(new Text("", 785, 92, 8, 1, 1, false, hookHandler));
- hooks.push(new Text("Socket Q", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- hooks.push(new Text("A5 Dupe", 785, 92 + hooks.length * 15, 2, 1, 1, false, hookHandler));
- while (true) {
- switch (activeAction) {
- case "Share A5":
- Town.doChores();
- Pather.journeyTo(4);
- try {
- result = getCollision(4, 5114, 5069);
- } catch (e) {
- activeAction = false;
- break;
- }
- // Avoid non-walkable spots, objects
- if (result === undefined || (result & 0x1) || (result & 0x400)) {
- activeAction = false;
- break;
- }
- Pather.moveTo(5114,5069,5);
- Pather.makePortal();
- Attack.securePosition(me.x, me.y, 30, 3000);
- Pather.usePortal (1, null);
- Pather.useWaypoint (109);
- while (!me.area) delay (100);
- if (me.act === 5) {
- say("A5WP " + getUnit(2, "Waypoint").gid);
- }
- activeAction = false;
- break;
- case "Get A5":
- if (!wpgid) {
- print("we dont have wp GID. Can't access A5");
- activeAction = false;
- break;
- }
- Town.move("portalspot");
- while (!Pather.usePortal (4, null)) {
- delay (1);
- }
- // Waypoint UI
- while (!getUIFlag (0x14)) {
- Pather.moveTo (5116,5067,5);
- sendPacket (1, 0x13, 4, 0x02, 4, wpgid);
- delay (100);
- }
- while (getUIFlag (0x14)) {
- me.cancel ();
- }
- Pather.usePortal (1, null);
- Pather.useWaypoint (109);
- if (me.area == 109)
- say("Welcome to A5");
- activeAction = false;
- break;
- case "Socket Q":
- Town.doChores();
- say("starting socket quest");
- Pather.useWaypoint (111);
- Precast.doPrecast(false);
- Pather.moveTo(3846, 5120);
- Attack.securePosition(me.x, me.y, 30, 3000);
- Pather.makePortal();
- say("tp up for socket quest");
- while (!this.playerIn()) {
- delay(200);
- }
- Attack.kill(getLocaleString(22435));
- Pather.moveTo(3846, 5120);
- say("socket quest completed");
- Pather.usePortal (109, null);
- activeAction = false;
- break;
- case "A5 Dupe":
- Town.goToTown(5);
- Town.move("nihlathak");
- var nith = getUnit (1, "nihlathak");
- while (!nith.openMenu())
- delay(1);
- me.cancel();
- addEventListener("gamepacketsent", PacketSent);
- addEventListener("gamepacket", PacketGet);
- Town.move("nihlathak");
- var gate = getUnit(2, 449);
- block = true;
- var nith = getUnit (1, "nihlathak");
- while (!nith.openMenu())
- delay(1);
- me.cancel();
- block = false;
- Pather.moveTo(5052, 5098);
- say("put any crap item on cursor. the item will disappear");
- while (!getUnit(100))
- delay(1);
- var cursor = getUnit(100);
- sendPacket(1, 0x44, 4, 0, 4, gate.gid, 4, cursor.gid, 4, 3);
- me.cancel();
- Pather.moveTo(5113,5064);
- say("start trade");
- while(!intrade)
- delay(1);
- getPacket(1, 0x77, 1, 0x0C);
- sendPacket (1, 0x31, 4, me.gid, 4, 0x4EA3);
- Town.move("waypoint");
- Pather.useWaypoint(1);
- Town.move("stash");
- delay(1);
- // drop items to dupe
- var dupes = me.findItems(-1, 0, 3);
- if (dupes) {
- while (dupes.length) {
- var drop = dupes.shift();
- if (drop.classid !== 549)
- Packet.dropItem(drop);
- }
- }
- say ("now cancel trade on second char");
- while(!rolled)
- delay(1);
- // drop all items to avoid lost in case of corrupted char
- var dupes = me.findItems(-1, 0, 3);
- if (dupes) {
- while (dupes.length) {
- var drop = dupes.shift();
- if (drop.classid !== 549)
- Packet.dropItem(drop);
- }
- }
- activeAction = false;
- break;
- case "Harrogath":
- Town.goToTown();
- if(!Pather.useWaypoint(109))
- me.overhead("Use Waypoint failed");
- activeAction = false;
- break;
- case "Frigid":
- Town.goToTown();
- if(!Pather.useWaypoint(111))
- me.overhead("Use Waypoint failed");
- activeAction = false;
- break;
- case "Arreat Plateau":
- Town.goToTown();
- if(!Pather.useWaypoint(112))
- me.overhead("Use Waypoint failed");
- activeAction = false;
- break;
- case "Crystalline Passage":
- Town.goToTown();
- if(!Pather.useWaypoint(113))
- me.overhead("Use Waypoint failed");
- activeAction = false;
- break;
- case "Glacial Trail":
- Town.goToTown();
- if(!Pather.useWaypoint(115))
- me.overhead("Use Waypoint failed");
- activeAction = false;
- break;
- /*
- case "Halls Of Pain":
- Town.goToTown();
- if(!Pather.useWaypoint(123))
- me.overhead("Use Waypoint failed");
- activeAction = false;
- break;
- */
- case "Frozen Tundra":
- Town.goToTown();
- if(!Pather.useWaypoint(117))
- me.overhead("Use Waypoint failed");
- activeAction = false;
- break;
- case "Ancients":
- Town.goToTown();
- if(!Pather.useWaypoint(118))
- me.overhead("Use Waypoint failed");
- activeAction = false;
- break;
- case "Worldstone":
- Town.goToTown();
- if(!Pather.useWaypoint(129))
- me.overhead("Use Waypoint failed");
- activeAction = false;
- break;
- case "Empty Inventory":
- items = me.findItems(-1, 0, 3);
- if (items) {
- while (activeAction && items.length > 0) {
- Packet.dropItem(items.shift());
- }
- }
- activeAction = false;
- break;
- case "Empty Stash":
- case "Empty Cube":
- if (!me.inTown || !Town.openStash()) {
- me.overhear("Failed to open stash");
- activeAction = false;
- break;
- }
- items = me.findItems(-1, 0, activeAction === "Empty Stash" ? 7 : 6);
- if (items) {
- while (activeAction && items.length > 0) {
- item = items.shift();
- if (item.classid !== 549) { // Don't drop the cube
- Packet.dropItem(item);
- }
- }
- }
- me.cancel();
- activeAction = false;
- break;
- case "Inventory to Stash":
- items = me.findItems(-1, 0, 3);
- if (items) {
- while (activeAction && items.length > 0) {
- item = items.shift();
- if (Storage.Stash.CanFit(item)) {
- Storage.Stash.MoveTo(item);
- }
- }
- }
- activeAction = false;
- break;
- case "Pick Items":
- item = getUnit(4, -1, 3);
- items = [];
- if (item) {
- do {
- items.push(copyUnit(item));
- } while (item.getNext());
- }
- while (activeAction && items.length > 0) {
- items.sort(sortPickList);
- item = items.shift();
- if (Town.ignoredItemTypes.indexOf(item.itemType) === -1 && Storage.Inventory.CanFit(item)) {
- Pickit.pickItem(item);
- }
- }
- activeAction = false;
- break;
- default:
- for (i = 0; i < hooks.length; i += 1) {
- if (hooks[i].color === 1) {
- hooks[i].color = 2;
- }
- }
- break;
- }
- delay(100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement