-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExchange.js
More file actions
80 lines (58 loc) · 1.34 KB
/
Exchange.js
File metadata and controls
80 lines (58 loc) · 1.34 KB
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
const NPC_RANGE = 400;
// Quests
let QUEST_EXCHANGE_WHITELIST = [
"seashell",
"leather",
];
function exchangeQuestItems()
{
if (character.q.exchange)
return;
for (let questItemName of QUEST_EXCHANGE_WHITELIST)
{
let quest = G.quests[questItemName];
// Handles wrong map etc.
if (simple_distance(character, quest) > NPC_RANGE)
continue;
let itemSlot = locate_item(questItemName);
if (itemSlot < 0)
continue;
let exchangeAmount = G.items[questItemName].e;
let haveAmount = character.items[itemSlot].q;
if (haveAmount < exchangeAmount)
continue;
if (haveEmptySlot() || haveAmount == exchangeAmount) {
flog("Handing in " + exchangeAmount + " " + questItemName);
return exchange(itemSlot);
}
}
}
// TODO: Boxes?
let XYN = find_npc("exchange");
let XYN_EXCHANGE_WHITELIST = [
"gem0",
"candy0",
"candy1",
];
function exchangeWithXyn()
{
if (character.q.exchange)
return;
if (!haveEmptySlot())
return;
if (simple_distance(character, XYN) > NPC_RANGE)
return;
for (let itemId of XYN_EXCHANGE_WHITELIST)
{
let itemSlot = locate_item(itemId);
if (itemSlot < 0)
continue;
flog("[Exchange] Handing in " + itemId);
exchange(itemSlot);
return;
}
}
setInterval(function() {
exchangeQuestItems();
exchangeWithXyn();
}, 500);