forked from Xertyn/anti-cc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (41 loc) · 1.31 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
module.exports = function antiCC(mod) {
let location = null;
let locationTime = 0;
mod.command.add("cc", () => {
mod.settings.enabled = !mod.settings.enabled;
mod.command.message(`Module ${mod.settings.enabled ? "<font color='#00ff00'>enabled</font>" : "<font color='#ff0000'>disabled</font>"}`);
});
mod.game.me.on("change_zone", () => {
if (!mod.game.me.inOpenWorld) {
mod.command.message(`Module ${mod.settings.enabled ? "<font color='#00ff00'>enabled</font>" : "<font color='#ff0000'>disabled</font>"}`);
}
});
mod.hook("C_PLAYER_LOCATION", 5, { "order": Infinity }, event => {
location = event;
locationTime = Date.now();
});
mod.hook("S_EACH_SKILL_RESULT", mod.majorPatchVersion >= 110 ? 15 : 14, { "order": -Infinity }, event => {
if (!mod.settings.enabled) return;
if (mod.game.me.is(event.target) && event.reaction.enable) {
if (!event.reaction.push) {
mod.send("C_PLAYER_LOCATION", 5, {
...location,
"type": 2,
"time": location.time - locationTime + Date.now() - 50
});
mod.send("C_PLAYER_LOCATION", 5, {
...location,
"type": 7,
"time": location.time - locationTime + Date.now() + 50
});
}
Object.assign(event.reaction, {
"enable": false,
"push": false,
"air": false,
"airChain": false
});
return true;
}
});
};