forked from salchy-tera/tera-advanced-sorc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
677 lines (622 loc) · 15.5 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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
module.exports = function supersorc(mod) {
//Variables
let cid
let myPosition
let myAngle
let enabled = true
let distance = 1000
let dolance = false
let stacks = 0
let replaced = false
let fusion_enabled = false
let implosion_enabled = false
let MB_active = false
let bs = false
let clientTime
//CDs
let isCD_prime = false
let isCD_iceberg = false
let isCD_arcane_fus = false
let isCD_fusion = false
let isCD_arcane = false
let isCD_fb = false
let isCD_hail = false
let isCD_void = false
let isCD_nova = false
let isCD_frost = false
let isCD_light = false
let isCD_barrage = false
let isCD_mb = false
let isCD_implosion = false
let isCD_lances = false
//TOs
let isCD_prime_To = null
let isCD_iceberg_To = null
let isCD_arcane_fus_To = null
let isCD_fusion_To = null
let isCD_arcane_To = null
let isCD_fb_To = null
let isCD_hail_To = null
let isCD_void_To = null
let isCD_nova_To = null
let isCD_frost_To = null
let isCD_light_To = null
let isCD_barrage_To = null
let isCD_mb_To = null
let isCD_implosion_To = null
let isCD_lances_To = null
//IDs
let paint_id = 160800
let mb_abnormality_id = 503061
let fire_buff = 502070
let ice_buff = 502071
let arcane_buff = 502072
let fire_enab = false
let ice_enab = false
let arcane_enab = false
let fusion_category = 5036
let implosion_category = 5039
let arcane_grant_id = 41212
let prime_id = 360200
let iceberg_id = 360400
let arcane_fus_id = 360300
let fusion_id = 360600
let arcane_press_id = 41200
let fusion_enab = 502050
let urgency_id = 9100100
let lances_id = 350100
let implosion_id = 390100
let stun_trap = 30300
let fb_id = 61000
let hail_id = 270900
let void_id = 120900
let nova_id = 300900
let frost_id = 21000
let light_id = 111100
let barrage_id = 200500
let mb_id = 340230
let super_arcane = 41213
//Boss
let bossid
let bossloc
let bossw
let monsters = []
let block_hit = false
mod.command.add('sorc', () => {
enabled = !enabled
mod.command.message(`Salchy's advanced sorc mod is now ${(enabled) ? 'en' : 'dis'}abled.`)
})
mod.hook('S_LOGIN', 14, (event) => {
cid = event.gameId
})
mod.hook('S_ABNORMALITY_BEGIN', 4, (event) => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
if(event.target==mod.game.me.gameId && event.id==mb_abnormality_id) {
MB_active = true
}
})
mod.hook('S_ABNORMALITY_END', 1, (event) => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
if(event.target==mod.game.me.gameId && event.id==mb_abnormality_id) {
MB_active = false
}
})
mod.hook('S_ABNORMALITY_REFRESH', 2, (event) => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
if(event.target==mod.game.me.gameId && event.id==mb_abnormality_id) {
MB_active = true
}
})
mod.hook('S_SKILL_CATEGORY', 3, event => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
if(event.category==fusion_category) {
fusion_enabled = event.enabled
}
if(event.category==implosion_category) {
implosion_enabled = event.enabled
}
})
mod.hook('S_START_COOLTIME_SKILL', 3, {order: -999999}, event => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
if(event.skill.id==lances_id) {
clearTimeout(isCD_lances_To)
isCD_lances = true
isCD_lances_To = setTimeout(function () {
isCD_lances = false
}, event.cooldown)
}
if(event.skill.id==mb_id) {
clearTimeout(isCD_mb_To)
isCD_mb = true
isCD_mb_To = setTimeout(function () {
isCD_mb = false
}, event.cooldown)
}
if(event.skill.id==implosion_id) {
clearTimeout(isCD_implosion_To)
isCD_implosion = true
isCD_implosion_To = setTimeout(function () {
isCD_implosion = false
}, event.cooldown)
}
if(event.skill.id==prime_id) {
clearTimeout(isCD_prime_To)
isCD_prime = true
isCD_prime_To = setTimeout(function () {
isCD_prime = false
}, event.cooldown)
return false
}
if(event.skill.id==iceberg_id) {
clearTimeout(isCD_iceberg_To)
isCD_iceberg = true
isCD_iceberg_To = setTimeout(function () {
isCD_iceberg = false
}, event.cooldown)
return false
}
if(event.skill.id==arcane_fus_id) {
clearTimeout(isCD_arcane_fus_To)
isCD_arcane_fus = true
isCD_arcane_fus_To = setTimeout(function () {
isCD_arcane_fus = false
}, event.cooldown)
return false
}
if(event.skill.id==fusion_id) {
clearTimeout(isCD_fusion_To)
isCD_fusion = true
isCD_fusion_To = setTimeout(function () {
isCD_fusion = false
}, event.cooldown)
}
if(event.skill.id==arcane_press_id) {
clearTimeout(isCD_arcane_To)
isCD_arcane = true
isCD_arcane_To = setTimeout(function () {
isCD_arcane = false
}, event.cooldown)
}
if(event.skill.id==fb_id) {
clearTimeout(isCD_fb_To)
isCD_fb = true
isCD_fb_To = setTimeout(function () {
isCD_fb = false
}, event.cooldown)
}
if(event.skill.id==hail_id) {
clearTimeout(isCD_hail_To)
isCD_hail = true
isCD_hail_To = setTimeout(function () {
isCD_hail = false
}, event.cooldown)
}
if(event.skill.id==void_id) {
clearTimeout(isCD_void_To)
isCD_void = true
isCD_void_To = setTimeout(function () {
isCD_void = false
}, event.cooldown)
}
if(event.skill.id==nova_id) {
clearTimeout(isCD_nova_To)
isCD_nova = true
isCD_nova_To = setTimeout(function () {
isCD_nova = false
}, event.cooldown)
}
if(event.skill.id==frost_id) {
clearTimeout(isCD_frost_To)
isCD_frost = true
isCD_frost_To = setTimeout(function () {
isCD_frost = false
}, event.cooldown)
}
if(event.skill.id==light_id) {
clearTimeout(isCD_light_To)
isCD_light = true
isCD_light_To = setTimeout(function () {
isCD_light = false
}, event.cooldown)
}
if(event.skill.id==barrage_id) {
clearTimeout(isCD_barrage_To)
isCD_barrage = true
isCD_barrage_To = setTimeout(function () {
isCD_barrage = false
}, event.cooldown)
}
})
mod.hook('S_SPAWN_NPC', 11, event => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
monsters.push({ gameId: event.gameId, loc: event.loc, w: event.w })
})
mod.hook('S_BOSS_GAGE_INFO', 3, event => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
if(bossid && bossid == event.id) return
bossid = event.id
mod.send("S_CUSTOM_STYLE_SYSTEM_MESSAGE", 1, {
message: "Boss detected",
style: 54
})
mod.send("S_PLAY_SOUND", 1, {
SoundID: 2023
})
let monster = monsters.find(m => m.gameId === event.id)
if (monster) {
bossloc = monster.loc
bossw = monster.w
}
})
mod.hook('S_NPC_LOCATION', 3, event => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
let monster = monsters.find(m => m.gameId === event.gameId)
if (monster) {
monster.loc = event.loc
monster.w = event.w
}
if(bossid == event.gameId) {
bossloc = event.loc
bossw = event.w
}
})
mod.hook('S_DESPAWN_NPC', 3, event => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
monsters = monsters.filter(m => m.gameId != event.gameId)
if(bossid == event.gameId) {
bossid = null
bossloc = null
bossw = null
}
})
mod.hook('S_START_USER_PROJECTILE', 9, event => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
block_hit = false
if(!bossid) return
if(!bs) return
let targets = []
targets.push({
gameId: bossid
})
if(!targets[0]) {
block_hit = false
return
} else {
block_hit = true
mod.send('S_START_USER_PROJECTILE', 9, event)
mod.send('C_HIT_USER_PROJECTILE', 4, {
id: event.id,
end: event.end,
loc: bossloc,
targets: targets
})
return false
}
})
mod.hook('C_HIT_USER_PROJECTILE', 4, event => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
if(block_hit) return false
})
mod.hook('S_EACH_SKILL_RESULT', 14, event => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
if(event.source!=mod.game.me.gameId && event.owner!=mod.game.me.gameId) return
})
mod.hook('S_ACTION_STAGE', 9, { order: -999999 }, event => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
if(bossid == event.gameId) {
bossloc = event.loc
bossw = event.w
}
if(event.gameId==mod.game.me.gameId && event.skill.id==arcane_press_id && event.stage==2) {
mod.send('C_PRESS_SKILL', 4, {
skill: {
reserved: 0,
npc: false,
type: 1,
huntingZoneId: 0,
id: arcane_press_id
},
press: false,
loc: myPosition,
w: myAngle
})
}
if(event.gameId==mod.game.me.gameId && ((Math.floor(event.skill.id / 10000))==39) && event.stage==2) {
mod.send('S_ACTION_END', 5, {
gameId: event.gameId,
loc: {
x: event.loc.x,
y: event.loc.y,
z: event.loc.z
},
w: event.w,
templateId: event.templateId,
skill: event.skill.id,
type: 999999,
id: event.id
})
return
}
if(event.gameId==mod.game.me.gameId && event.stage>0) {
mod.send('S_ACTION_END', 5, {
gameId: event.gameId,
loc: {
x: event.loc.x,
y: event.loc.y,
z: event.loc.z
},
w: event.w,
templateId: event.templateId,
skill: event.skill.id,
type: 999999,
id: event.id
})
}
})
mod.hook('S_ACTION_END', 5, event => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
if(bossid == event.gameId) {
bossloc = event.loc
bossw = event.w
}
})
mod.hook('S_CANNOT_START_SKILL', 4, { order: -999999 }, event => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
/*if(event.skill.id==fusion_id || event.skill.id==prime_id) {
stacks = 0
}
return false*/
})
mod.hook('S_PLAYER_STAT_UPDATE', 14, event => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
stacks = 0
if(!event.alive) MB_active = false
event.fireEdge = 4
event.iceEdge = 4
event.lightningEdge = 4
if(event.fireEdge > 0) stacks++
if(event.iceEdge > 0) stacks++
if(event.lightningEdge > 0) stacks++
return true
})
mod.hook('C_PLAYER_LOCATION', 5, (event) => {
myPosition = event.loc
myAngle = event.w
clientTime = event.time
})
mod.hook('C_START_SKILL', 7, { order: -Infinity }, (event) => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
myPosition = event.loc
myAngle = event.w
replaced = false
bs = false
if((event.skill.id===stun_trap || event.skill.id===paint_id)) {
if(event.skill.id===paint_id) bs = true
if(event.skill.id===stun_trap) bs = false
if(bs && !bossloc) return false
if(!isCD_lances) dolance = true
if(!isCD_mb && !replaced && bs) {
event.skill.id = mb_id
replaced = true
}
if(!isCD_implosion && !replaced && implosion_enabled && isCD_arcane && !isCD_fb) {
event.skill.id = implosion_id
replaced = true
}
if(!isCD_prime && (stacks>=2) && !replaced && fusion_enabled) {
event.skill.id = prime_id
replaced = true
if(bs) event.dest = bossloc
if(!bs) {
prime(distance,0)
return false
}
}
if(!isCD_fusion && (stacks>=2) && !replaced && fusion_enabled && MB_active) {
event.skill.id = fusion_id
replaced = true
if(bs) event.dest = bossloc
}
if(!isCD_hail && !replaced) {
event.skill.id = hail_id
replaced = true
if(bs) event.dest = bossloc
}
if(!isCD_arcane && !replaced) {
mod.send('C_PRESS_SKILL', 4, {
skill: {
reserved: 0,
npc: false,
type: 1,
huntingZoneId: 0,
id: arcane_press_id
},
press: true,
loc: myPosition,
w: myAngle
})
return false
}
if(!isCD_fb && !replaced) {
event.skill.id = fb_id
replaced = true
if(bs) event.dest = bossloc
}
if(!isCD_void && !replaced) {
event.skill.id = void_id
replaced = true
if(bs) event.dest = bossloc
}
if(!isCD_nova && !replaced) {
event.skill.id = nova_id
replaced = true
if(bs) event.dest = bossloc
}
if(!isCD_light && !replaced) {
event.skill.id = light_id
replaced = true
if(bs) event.dest = bossloc
}
if(!isCD_frost && !replaced) {
event.skill.id = frost_id
replaced = true
if(bs) event.dest = bossloc
}
if(!isCD_barrage && !replaced) {
event.skill.id = barrage_id
replaced = true
if(bs) event.target = bossid
}
if(bs && replaced) {
/*event.loc.x = (Math.cos(bossw) * -150) + bossloc.x
event.loc.y = (Math.sin(bossw) * -150) + bossloc.y
event.loc.z = bossloc.z
event.w = bossw
mod.send('S_INSTANT_MOVE', 3, {
gameId: mod.game.me.gameId,
loc: event.loc,
w: event.w
});*/
/*mod.send('C_PLAYER_LOCATION', 5, {
loc: event.loc,
w: event.w,
lookDirection: event.w,
dest: {x:0, y:0, z:0},
type: 0,
jumpDistance: 0,
inShuttle: false,
time: clientTime + 5
})*/
}
if(dolance) {
dolance = false
lances(distance,0)
}
if(replaced) return true
if(!replaced) return false
}
if((event.skill.id===stun_trap || event.skill.id===paint_id) && !bossloc) {
return false
}
let sInfo = getSkillInfo(event.skill.id)
switch(sInfo.group) {
case 4:
dolance = true
break
case 30:
dolance = true
break
case 33:
dolance = true
break
default:
return
break
}
if(dolance) {
dolance = false
lances(distance,0)
}
})
mod.hook('C_START_INSTANCE_SKILL', 7, (event) => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
myPosition = event.loc
myAngle = event.w
})
mod.hook('C_PRESS_SKILL', 4, { filter: { fake: false } }, (event) => {
if(!enabled) return
if(mod.game.me.class !== 'sorcerer') return
myPosition = event.loc
myAngle = event.w
if(event.skill.id==arcane_press_id && !event.press) {
return false
}
})
function getSkillInfo(id) {
let nid = id;
return {
id: nid,
group: Math.floor(nid / 10000),
level: Math.floor(nid / 100) % 100,
sub: nid % 100
};
}
function prime(d, n) {
CastPrime((Math.cos(myAngle) * d) + myPosition.x, (Math.sin(myAngle) * d) + myPosition.y, myPosition.z + n, myAngle);
}
function CastPrime(x, y, z, w = 0) {
mod.send('C_START_SKILL', 7, {
skill: {
reserved: 0,
npc: false,
type: 1,
huntingZoneId: 0,
id: isCD_prime ? fusion_id : prime_id
},
w: bs ? bossw : myAngle,
loc: {
x: bs ? (Math.cos(bossw) * -150) + bossloc.x : myPosition.x,
y: bs ? (Math.sin(bossw) * -150) + bossloc.y : myPosition.y,
z: bs ? bossloc.z : myPosition.z
},
dest: {
x: x,
y: y,
z: z
},
unk: true,
moving: false,
continue: false,
target: 0,
unk2: false
})
}
function lances(d, n) {
CastLances((Math.cos(myAngle) * d) + myPosition.x, (Math.sin(myAngle) * d) + myPosition.y, myPosition.z + n, myAngle);
}
function CastLances(x, y, z, w = 0) {
mod.send('C_START_SKILL', 7, {
skill: {
reserved: 0,
npc: false,
type: 1,
huntingZoneId: 0,
id: lances_id
},
w: bs ? bossw : myAngle,
loc: {
x: bs ? ((Math.cos(bossw) * -150) + bossloc.x) : myPosition.x,
y: bs ? ((Math.sin(bossw) * -150) + bossloc.y) : myPosition.y,
z: bs ? bossloc.z : myPosition.z
},
dest: {
x: x,
y: y,
z: z
},
unk: true,
moving: false,
continue: false,
target: 0,
unk2: false
})
}
}