This repository has been archived by the owner on Apr 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathrework.js
222 lines (190 loc) · 6.31 KB
/
rework.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/*
// FpsUtils3 indev-0.1 currently not functional.
// Written by Saegusa with love<3 and memes
//
// This is a development structral version of
// FpsUtils' new version, which will be the
// third iteration of this mod, which includes
// the same features as before but in a better
// code structure to make it more understandable
// and easier to work on for people other than gooses.
//
// FpsUtils3 currently includes the new command
// system i thought up for "masterwork" and is beastin
// Pls forward any future requests to my Patreon page:
// https://www.patreon.com/saegusa
//
// Original code repository is placed at:
// https://github.com/Saegusae/fps-utils
*/
let config = require('./config.json');
const format = require('./format'),
fs = require('fs');
module.exports = function FpsUtils3(dispatch) {
const CLASSES = config.classes;
let debug = config.debug || false;
let player,
cid,
model,
clss;
let state = config.state || 0,
lastState = state || 0,
hiddenPlayers = {},
hiddenIndividual = {};
let flags = {
fireworks: false,
hide: {
tanks: false,
healers: false,
dps: false
}
}
function getClass(mdl) {
return (m % 100);
}
const commands = {
state: {
alias: ["0", "1", "2", "3"],
help: "Changes fps state to given argument.",
run: function(args) {
lastState = state;
state = parseInt(args[0]);
config.state = state;
switch(state) {
// State 0: Disable fps-utils optimization.
case 0:
if(lastState > 2) {
// Display all hidden players.
}
break;
// State 1: Hide skill particles and projectiles.
case 1:
if(lastState > 2) {
// Display all hidden players, except individuals.
}
break;
// State 2: Hide skill animations.
case 2:
if(lastState > 2) {
// Display all hidden players, except individuals.
}
break;
// State 3: Hide all players.
case 3:
if(lastState < 3) {
// Hide all players.
}
break;
default:
break;
}
}
},
save: {
alias: ['save', 'config'],
help: "Saves current settings to config file for next launch.",
run: function(args) {
save((err) => {
if(err) {
log('Save to config failed.');
} else {
log('Settings successfully saved to config');
}
});
}
},
fireworks: {
alias: ['firework', 'fireworks', 'fw'],
help: "Hide fireworks, and their pesky animations. (true = show | false = hide)",
run: function(args) {
flags.fireworks = !flags.fireworks;
log(`toggled fireworks: ${flags.fireworks}`);
}
},
hide: {
alias: ['hide', 'h', 'delete'],
help: "",
run: function(args) {
if(args.length < 2) {
// Missing argument, throw help function.
} else {
if(state < 3)
switch(args[1]) {
case "dps":
case "healers":
case "tanks":
// Hide all characters of said class.
break;
default:
// Hide individuals by username.
break;
}
}
}
},
show: {
alias: ['show', 's'],
help: "",
run: function(args) {
if(args.length < 2) {
// Missing argument, throw help.
} else {
if(state < 3)
switch(args[1]) {
case "dps":
case "healers":
case "tanks":
// Show chosen class.
break;
default:
// Show individual by name.
break;
}
}
}
},
list: {
alias: ['list', 'l'],
help: "Show a list of players hidden by 'hide' command.",
run: function(args) {
let hiddenArray = [];
for(let pl in hiddenIndividual) hiddenArray.push(hiddenIndividual[pl].name);
log(`Hidden Players: ${hiddenArray}`);
}
}
}
dispatch.hook('C_CHAT', 1, (event) => {
if(!event.message.includes('!fps'))
return;
let command = format.stripTags(event.message).split(' ');
if(command.length > 1) {
command = command.splice(1, 1);
for(let cmd in commands) {
if(commands[cmd].alias.indexOf(command[0])) {
commands[cmd].run(command);
}
}
}
return false;
});
function help(cmd) {
}
function log(msg) {
if(debug) console.log('[fps-utils3] ' + msg);
dispatch.toClient('S_CHAT', 1, {
channel: 24,
authorID: 0,
unk1: 0,
gm: 0,
unk2: 0,
authorName: '',
message: ' (fps-utils3) ' + msg
});
}
function save(callback) {
fs.writeFile('./config.json', config, 'utf8', (err) => {
if(!err) log("config file overwritten successfully");
else callback(err);
});
}
}