forked from seraphinush-gaming/rk9-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
271 lines (248 loc) · 8.44 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
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
// OPCODE REQUIRED :
// - C_CHAT
// - S_ACTION_END
// - S_ACTION_STAGE
// - S_BOSS_GAGE_INFO
// - S_DUNGEON_EVENT_MESSAGE
// - S_LOAD_TOPO
// - S_LOGIN
// - S_QUEST_BALLOON
// - S_SPAWN_ME
// Version 1.3d r:00
const Command = require('command')
module.exports = function RK9Helper(d) {
const command = Command(d)
// general
let cid,
enable = false,
prevZone = null,
curZone = null
// guide
let channelNum = 0,
chatGuild = false,
chatNotice = false,
chatParty = false,
curBoss = 0,
guideEnable = true,
messageA = '',
messageB = 'O',
previousMechFirst = true,
temp = 'Self'
let MSG_STRING = []
// code
d.hook('S_LOGIN', (e) => {
({ cid } = e)
prevZone = null
})
d.hook('S_LOAD_TOPO', (e) => {
prevZone = curZone,
curZone = e.zone
})
d.hook('S_SPAWN_ME', (e) => {
if (!enable) return
if (!(RK9_ZONE.includes(curZone))) return
if (prevZone != SAVAGE_REACH) return
if (curZone == prevZone) return
e.x = RK9_LOBBY[0],
e.y = RK9_LOBBY[1],
e.z = RK9_LOBBY[2]
return true
})
// RK-9 Kennel (hard) last boss guide code
d.hook('S_BOSS_GAGE_INFO', (e) => {
if (!enable) return
if (!(RK9_ZONE.includes(curZone))) return
curBoss = e.templateId
})
d.hook('S_ACTION_STAGE', (e) => {
if (!guideEnable) return
if (curBoss != RK9_THIRD_BOSS) return
if (e.skill === 1202128153) {
setTimeout(mechOrder, 500)
}
})
d.hook('S_ACTION_END', (e) => {
if (!guideEnable) return
if (curBoss != RK9_THIRD_BOSS) return
switch (e.skill) {
case 1202128160:
case 1202128161:
case 1202128162:
messageA = messageB,
messageB = 'O'
break
default:
return
}
setTimeout(() => {
if (channelNum != 0) { sendChat(`Next : ` + messageA) }
else { send(`Next : ` + messageA) }
}, 8000)
})
// initial message hook
d.hook('S_DUNGEON_EVENT_MESSAGE', (e) => {
if (!guideEnable) return
if (curBoss != RK9_THIRD_BOSS) return
let messageId = parseInt(e.message.replace('@dungeon:', ''))
switch (messageId) {
case 9935302:
messageA = MSG_STRING[0]
break
case 9935303:
messageA = MSG_STRING[1]
break
case 9935304:
messageA = MSG_STRING[2]
break
case 9935311:
previousMechFirst = true
break
case 9935312:
previousMechFirst = false
break
default:
return
}
setTimeout(mechOrder, 2000)
})
d.hook('S_QUEST_BALLOON', (e) => {
if (!guideEnable) return
if (curBoss != RK9_THIRD_BOSS) return
let balloonId = parseInt(e.message.replace('@monsterBehavior:', ''))
switch (balloonId) {
case 935301:
messageB = MSG_STRING[0]
break
case 935302:
messageB = MSG_STRING[1]
break
case 935303:
messageB = MSG_STRING[2]
break
}
})
// helper
function mechOrder() {
if (previousMechFirst) {
if (channelNum != 0) { sendChat(messageA + ` -> ` + messageB) }
else { send(messageA + ` -> ` + messageB) }
} else {
if (channelNum != 0) { sendChat(messageB + ` -> ` + messageA) }
else { send(messageB + ` -> ` + messageA) }
}
}
function sendChat(msg) {
d.toServer('C_CHAT', {
channel: channelNum, // 1 = party, 2 = guild, 21 = party notice
message: msg
})
}
function setMessage() {
if (d.base.protocolVersion.toString() == 323767) {
send(`<font color="#56B4E9">KR support detected</font>`)
MSG_STRING = ['근', '원', '터']
} else {
send(`<font color="#56B4E9">NA support detected</font>`)
MSG_STRING = ['get OUT', 'get IN', 'WAVE']
}
}
// command
try {
command.add('rk', (p1, p2) => {
if (p1 === undefined) {
enable = !enable
send(`RK-9 Hangar module ${enable ? '<font color="#56B4E9">enabled</font>' : '<font color="#E69F00">disabled</font>'}<font>.</font>`)
if (enable) setMessage()
send(`Status :
<br> - Guide : ${guideEnable}
<br> - Message to : ${temp}`)
return
}
if (p1 == 'status') {
send(`Status : ${enable ? 'On' : 'Off'}
<br> - Guide : ${guideEnable}
<br> - Message to : ${temp}`)
return
}
if (!enable) {
send(`<font color="#FF0000">Offline.</font>`)
return
}
if (p1 == 'guide') {
guideEnable = !guideEnable
send(`Guide ${guideEnable ? '<font color="#56B4E9">enabled</font>' : '<font color="#E69F00">disabled</font>'}<font>.</font>`)
return
}
if (p1 == 'guild') {
if (!guideEnable) {
send(`<font color="#FF0000">Guide is disabled.</font>`)
return
}
chatGuild = !chatGuild
chatGuild ? (channelNum = 2, chatNotice = false, chatParty = false, temp = 'Guild') : (channelNum = 0, temp = 'Self')
send(`Message to guild chat ${chatGuild ? '<font color="#56B4E9">enabled</font>' : '<font color="#E69F00">disabled</font>'}<font>.</font>`)
return
}
if (p1 == 'notice') {
if (!guideEnable) {
send(`<font color="#FF0000">Guide is disabled.</font>`)
return
}
chatNotice = !chatNotice
chatNotice ? (channelNum = 21, chatGuild = false, chatParty = false, temp = 'Notice') : (channelNum = 0, temp = 'Self')
send(`Message to notice chat ${chatNotice ? '<font color="#56B4E9">enabled</font>' : '<font color="#E69F00">disabled</font>'}<font>.</font>`)
return
}
if (p1 == 'party') {
if (!guideEnable) {
send(`<font color="#FF0000">Guide is disabled.</font>`)
return
}
chatParty = !chatParty
chatParty ? (channelNum = 1, chatGuild = false, chatNotice = false, temp = 'Party') : (channelNum = 0, temp = 'Self')
send(`Message to party chat ${chatParty ? '<font color="#56B4E9">enabled</font>' : '<font color="#E69F00">disabled</font>'}<font>.</font>`)
return
}
if (p1 == 'test') {
send(`Test :
<br> - ${MSG_STRING[0]}
<br> - ${MSG_STRING[1]}
<br> - ${MSG_STRING[2]}`)
return
}
if (!(RK9_ZONE.includes(curZone))) {
send(`<font color="#FF0000">Invalid zone.</font>`)
return
} else {
send(`<font color="#FF0000">Invalid argument.</font>`)
}
})
function send(msg) { command.message(`[rk9-helper] : ` + msg) }
} catch (e) { console.log(`[ERROR] -- rk9-helper module --`) }
}
// constants
const RK9_DEVICE_LOCATION = {
1: [-44591.781, 49384.055, 0.25],
2: [-44584, 48114.629, 0.25],
3: [-43328.5, 48118.527, 0.25],
4: [-43328, 49370.785, 0.25]
}
const RK9_BOSS_LOCATION = {
1: [-38366, 54391, 0.25],
2: [-32878.3632, 58849.367, 0.25],
3: [-33766, 40637, 22.25]
}
const RK9_LOBBY = [-41429.887, 40626.555, -950.874]
const RK9_ZONE = [9735, 9935]
const SAVAGE_REACH = 7031
const RK9_THIRD_BOSS = 3000
const START = 1202128153 // 패턴 시작
const FIRST_IN = 1202128156 // first_근
const FIRST_OUT = 1202128157 // first_원
const FIRST_SPD = 1202128158 // first_전
const SECOND_IN = 1202128160 // second_근
const SECOND_OUT = 1202128161 // second_원
const SECOND_SPD = 1202128162 // second_전
const QUEST_IN = 935301 // 근
const QUEST_OUT = 935302 // 전
const QUEST_SPD = 935303 // 원