-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
38 lines (34 loc) · 1.55 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
exports.NetworkMod = function(mod) {
const warnTimeout = 15;
let lastReset = { time: null, icon: null };
let iconsData = new Map();
function getSkillBase(skill) {
return Math.floor(skill / 10000);
}
mod.game.on("enter_game", () => {
iconsData.clear();
mod.queryData("/SkillIconData/Icon@class=?/", [mod.game.me.class], true, false, ["skillId", "iconName"]).then(res => {
res.forEach(icon => {
iconsData.set(icon.attributes.skillId, icon.attributes.iconName);
iconsData.set(getSkillBase(icon.attributes.skillId), icon.attributes.iconName);
});
});
});
mod.hook("S_CREST_MESSAGE", 2, ({ type, skill }) => {
if (type === 6) {
let icon = iconsData.get(skill) || iconsData.get(getSkillBase(skill));
if (lastReset.icon !== icon || (lastReset.icon === icon && (Date.now() - lastReset.time > warnTimeout))) {
lastReset.icon = icon;
lastReset.time = Date.now();
mod.send("S_CUSTOM_STYLE_SYSTEM_MESSAGE", 1, {
message: `<img src="img://__${icon}" width="48" height="48" vspace="-20"/><font size="24" color="${mod.settings.reset_font_color}"> Reset</font>`,
style: mod.settings.resetStyle
});
}
if (mod.settings.sound)
mod.send("S_PLAY_SOUND", 1, { SoundID: mod.settings.soundId });
if (!mod.settings.show_system_reset_message)
return false;
}
});
};