-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsamochod-tp.js
95 lines (93 loc) · 3.4 KB
/
samochod-tp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
(newOther => {
g.loadQueue.push({ fun () {
if (!localStorage.getItem(`uciekanko-${window.hero.nick}`)) {
localStorage.setItem(`uciekanko-${window.hero.nick}`, JSON.stringify({
nicks: {
escape: [],
stay: []
},
lvlTp: -window.hero.lvl,
escape: true,
escapeAll: false,
escapeFriends: false,
leaveAfterTp: false,
tp: "Kamień teleportujący do Ithan",
emergencyTp: "Zwój teleportacji na Kwieciste Przejście"
}))
};
}});
const sendToDiszkort = (title, description, webhook_url) => {
fetch(webhook_url, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
embeds: [{
title: title,
description: description,
}],
})
})
};
const uciekanko = (tp, emergency) => {
const teleport = findTp(tp) || findTp(emergency);
if (teleport) {
const [tpId, tpMapId] = teleport;
return tepaj(tpId, tpMapId);
}
};
const tepaj = (id, mapId) => {
if (window.g.battle) {
return setTimeout(tepaj, 5, id, mapId);
}
if (window.map.id !== parseInt(mapId)) {
if (!window.g.item[id]) {
return uciekanko();
}
return window._g(`moveitem&id=${id}&st=1`, setTimeout(tepaj, 5, id, mapId));
}
};
const findTp = itemName => {
if (window.g.item.length > 0) {
for (const [id, {name, loc}] of Object.entries(window.g.item)) if (loc === "g" && name === itemName) return checkTpAvailability(id);
} else {
setTimeout(uciekanko, 50, itemName);
}
};
const checkTpAvailability = id => {
const staty = window.parseItemStat(window.g.item[id].stat);
if (staty.teleport) {
const mapId = staty.teleport.split(",")[0];
if (staty.timelimit) {
let ts = window.unix_time();
let min = staty.timelimit.split(",")[1];
if (min && ts > min) return [id, mapId];
} else {
return [id, mapId];
}
} else {
return;
}
};
window.newOther = (players = {}) => {
const uciekanie = JSON.parse(localStorage.getItem(`uciekanko-${window.hero.nick}`));
for (const [id, {
del,
nick,
lvl,
relation
}] of Object.entries(players)) {
if (!del && nick && lvl && relation) {
if (uciekanie.escape && window.map.pvp === 2 &&
(lvl >= window.hero.lvl + uciekanie.lvlTp &&
!uciekanie.nicks.stay.includes(nick) || uciekanie.nicks.escape.inludes(nick) || uciekanie.escapeAll)) {
window.g.delays.limit = 100;
uciekanko(uciekanie.tp, uciekanie.emergencyTp);
sendToDiszkort("Uciekańsko", `Próbowałem uciec przed ${nick} ${lvl} na mapie ${window.map.name}`, "https://discordapp.com/api/webhooks/643534103928373269/7ehFTBULCEQq73fuV6bkXiEpSD_QCHLyuO8PcF8kbkoiuas_E4XR5wffta7wrSP-xYo-");
}
}
}
newOther(players);
}
})(window.newOther);