-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmod.js
121 lines (109 loc) · 2.75 KB
/
mod.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const paths = require('path');
const DiscordRPC = require(paths.join(
process.cwd(),
decodeURIComponent(new URL('./node_modules/discord-rpc', import.meta.url).pathname),
));
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
rpc.on('ready', () => {
// activity can only be set every 15 seconds
setActivity();
setInterval(setActivity, 15e3);
});
rpc.login({ clientId: '823908584974450718' }).catch();
function setActivity() {
if (!rpc) return;
if (sc.model.isTitle() || !ig.ready) {
rpc.setActivity({
state: 'Menu',
details: 'In the menu',
largeImageKey: 'ducklea',
largeImageText: 'Menu',
instance: false,
});
return;
}
try {
const area = getArea();
const areaName = sc.map.getCurrentAreaName().value
const elem = getCurrentElementName();
const timeStamp = new Date().getTime() - sc.stats.get('player', 'playtime') * 1000;
var partySize = sc.party.getPartySize() + 1;
var partyMax = sc.PARTY_MAX_MEMBERS + 1;
var rpcData = {
details: getChapterText(),
state: getState(areaName),
startTimestamp: timeStamp,
partySize: partySize,
partyMax: partyMax,
smallImageKey: 'e-' + elem.toLowerCase(),
smallImageText: elem,
largeImageKey: getArtKey(area),
largeImageText: areaName,
instance: false,
};
rpc.setActivity(rpcData);
} catch (e) { }
}
function getState(areaName) {
var state;
if (sc.model.isPaused()) {
state = '(Paused)';
} else {
if (sc.pvp.isActive()) state = 'In a PvP';
else if (sc.combat.isInCombat(ig.game.playerEntity)) state = 'In combat ';
else state = 'Exploring';
}
state += ' ' + areaName;
return state;
}
function getArea() {
return (ig.game.mapName || '???').split('.')[0];
}
function getChapterText() {
var chapter = sc.model.player.chapter;
var chapterData = ig.database.get('chapters')[chapter];
var chapterRet;
if (chapterData.prefix) {
chapterRet = chapterData.prefix[ig.currentLang];
} else {
chapter = chapter.toString().padStart(2, '0');
chapterRet = `Chapter ${chapter}`;
}
chapterRet += ': ' + chapterData.name[ig.currentLang];
return chapterRet;
}
const ART_LIST = [
'cargo-ship',
'rhombus-dng',
'arid',
'arid-dng',
'autumn',
'autumn-fall',
'beach',
'bergen',
'bergen-trail',
'cold-dng',
'evo-village',
'final-dng',
'forest',
'heat',
'heat-dng',
'heat-village',
'hideout',
'jungle',
'jungle-city',
'rhombus-sqr',
'rookie-harbor',
'shock-dng',
'wave-dng',
'tree-dng',
];
function getArtKey(area) {
if (ART_LIST.indexOf(area) < 0) {
return 'ducklea';
}
return area;
}
function getCurrentElementName() {
return ['Neutral', 'Heat', 'Cold', 'Shock', 'Wave'][sc.model.player.currentElementMode];
}