Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Sekcja konfiguracji
- const config = {
- putAuction: {
- // Czy wystawianie na aukcje ma być włączone
- enabled: true,
- // Za ile można licytować
- // Wpisz '', jeśli ma nie wystawiać na licytację
- bidPrice: '',
- // Za ile ma wystawić
- // Wpisz '', jeśli ma nie wystawiać na kup teraz
- buyPrice: '1,45m',
- // Na ile wystawić (czas w godzinach, maks. 168h)
- time: 168,
- // Minimalny poziom przemiotu do wystawienia
- minLvl: 10,
- // Maksymalny poziom przedmiotu do wystawienia
- maxLvl: 270,
- },
- sendGold: {
- // Czy wysyłanie golda ma być włączone
- enabled: true,
- // Minimalna ilość złota, od której ma wysyłać
- minAmount: '5m',
- // Ilość złota, którą ma zostawiać
- saveGold: '4m',
- // Na jaki nick ma wysyłać
- target: 'palis jr'
- },
- getMails: {
- // Czy ma odbierać przedmioty z poczty
- enabled: true
- }
- };
- let opened = false, lastClick = 0, lastTalk = 0, stayCounter = 0;
- function sleep(ms) {
- return new Promise(resolve => setTimeout(resolve, ms));
- }
- function calcFreeSpace() {
- return [0, 1, 2].reduce((total, curr) => total + g.bags[curr][0] - g.bags[curr][1], 0);
- }
- function isProperToSell(item) {
- const stat = parseItemStat(item.stat);
- if (item.loc !== 'g' || item.st !== 0 || item.cl >= 15) {
- return false;
- }
- if (item.own !== hero.id || stat.soulbound === null || stat.permbound === null || stat.rarity !== 'unique') {
- return false;
- }
- if (stat.lvl && (stat.lvl < config.putAuction.minLvl || stat.lvl > config.putAuction.maxLvl)) {
- return false;
- }
- return true;
- }
- function getItemsToSell() {
- return Object.values(g.item).filter(item => isProperToSell(item));
- }
- function waitFor(condition, interval = 100, attempts = Infinity) {
- let times = 0;
- const promise = (resolve, reject) => {
- if (condition()) {
- resolve();
- } else if (attempts === -1 || times < attempts) {
- times++;
- setTimeout(() => promise(resolve, reject), interval);
- } else {
- reject();
- }
- };
- return new Promise(promise);
- }
- const main = async () => {
- await sleep(250);
- if (map.name === 'Eder') {
- // Disable menogram if player has unique items, gold to send or mails to get
- if (
- (config.putAuction.enabled && getItemsToSell().length >= 1) ||
- (config.sendGold.enabled && hero.gold >= parsePrice(config.sendGold.minAmount) + 100) ||
- (config.getMails.enabled && hero.mails >= 1)
- )
- // Check if player has mails to get or gold to send
- if (
- (config.getMails.enabled && hero.mails >= 1) ||
- (config.sendGold.enabled && hero.gold > parsePrice(config.sendGold.minAmount) + 100)
- ) {
- // Go to mailbox
- if (!(hero.x === 36 && hero.y === 43)) {
- goTo(36, 43);
- return;
- }
- // Talk with mailbox
- if (!g.mails && Date.now() - lastTalk >= 350) {
- _g(`talk&id=17634`, () => lastTalk = Date.now());
- return;
- }
- }
- // Check if mailbox is opened and player has mails or gold to send
- if (g.mails) {
- if (config.getMails.enabled && $('.getdel').length >= 1 && calcFreeSpace() > 0) {
- if (Date.now() - lastClick >= 350) {
- $('.getdel')[0].click();
- lastClick = Date.now();
- }
- return;
- }
- if (config.sendGold.enabled && hero.gold >= parsePrice(config.sendGold.minAmount) + 100) {
- if (Date.now() - lastTalk >= 350) {
- const amount = hero.gold - 100 - parsePrice(config.sendGold.saveGold);
- _g('mail&a=send&r=' + esc(config.sendGold.target) + '&gold=' + amount + '&iid=&msg=', () => lastTalk = Date.now());
- }
- return;
- }
- window.hideMails();
- return;
- }
- // Go to auctioneer if player has unique items
- // Otherwise enable menogram and go to start map
- if (config.putAuction.enabled && getItemsToSell().length >= 1) {
- goTo(31, 50);
- } else {
- // Enable menogram
- // Go to 'Gildia Magów' gateway if current map is not a part of setup
- goTo(29, 0);
- }
- }
- if (map.name === 'Eder') {
- // Go to 'Thuzal' gatewa
- // Go to auctioneer
- // if (!(hero.x === 31 && hero.y === 50)) {
- // goTo(31, 50);
- // return;
- // }
- if (!g.auctions && g.talk.id === 0) {
- _g('talk&id=44142');
- } else {
- if (!$('#auction-window .auction-window').length) {
- document.querySelector('#replies > li:nth-child(1)').click();
- return;
- }
- if (!opened) {
- opened = true;
- for (const item of getItemsToSell()) {
- let bidPrice = parsePrice(config.putAuction.bidPrice), buyPrice = parsePrice(config.putAuction.buyPrice);
- _g('ah&action=sell&item=' + item.id + '&price=' + bidPrice + '&buy_out=' + buyPrice + '&time=' + config.putAuction.time + '&is_featured=0');
- await sleep(950);
- }
- g.auctions.close();
- }
- await sleep(800);
- goTo(29, 0)
- }
- }
- }
- // Wait for game load
- waitFor(() => {
- return window.g && window.g.init > 4;
- }).then(() => {
- const old = window.parseInput;
- window.parseInput = (d, callback, xhr) => {
- old(d, callback, xhr);
- main();
- }
- });
Add Comment
Please, Sign In to add comment