-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
59 lines (48 loc) · 1.36 KB
/
index.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
module.exports = function HideMotes(mod) {
const command = mod.command || mod.require.command;
let motes = {};
let enabled = false;
let gameId;
mod.hook('S_LOGIN', 15, (event) => {
({ gameId } = event);
});
mod.hook('S_LOAD_TOPO', 'raw', () => {
motes = {};
});
mod.hook('S_SPAWN_DROPITEM', 9, (event) => {
if(event.item >= 8008 && event.item <= 8023) {
motes[event.gameId] = Object.assign({}, event);
motes[event.gameId].explode = false;
if(enabled && event.source !== gameId) return false;
}
});
mod.hook('S_DESPAWN_DROPITEM', 4, (event) => {
if(motes[event.gameId]) {
if(enabled && motes[event.gameId].source !== gameId) {
delete motes[event.gameId];
return false;
}
delete motes[event.gameId];
}
});
function hideMotes() {
Object.keys(motes).forEach((mote) => {
if(motes[mote].source === gameId) return;
mod.send('S_DESPAWN_DROPITEM', 4, {
gameId: motes[mote].gameId
});
});
}
function showMotes() {
Object.keys(motes).forEach((mote) => {
if(motes[mote].source === gameId) return;
mod.send('S_SPAWN_DROPITEM', 9, motes[mote]);
});
}
command.add('hidemotes', () => {
if(!enabled) hideMotes();
else showMotes();
enabled = !enabled;
command.message(`All motes are now ${(enabled) ? 'hidden' : 'visible'}.`);
});
}