-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.js
More file actions
73 lines (63 loc) · 2.03 KB
/
index.js
File metadata and controls
73 lines (63 loc) · 2.03 KB
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
const INTERVAL = 2000
const JOB_WARRIOR = 0
const JOB_ARCHER = 5
const ASSAULT_STANCE = [ 100150, 67189264 ] // [0] = Skill ID, [1] = Abrnomality ID
const SNIPERS_EYE = [ 601133, 67319064 ] // [0] = Skill ID, [1] = Abrnomality ID
module.exports = function AutoStance(dispatch) {
let re = null,
on = false,
cid = null,
job = null,
skill = null,
model = null,
mounted = false,
interval = null,
location = null
dispatch.hook('C_PLAYER_LOCATION', 1, (event) => { location = event })
dispatch.hook('S_MOUNT_VEHICLE', 1, (event) => { if (event.target.equals(cid)) mounted = true })
dispatch.hook('S_UNMOUNT_VEHICLE', 1, (event) => { if (event.target.equals(cid)) mounted = false })
dispatch.hook('S_LOGIN', 2, (event) => {
({cid, model} = event)
job = (model - 10101) % 100
skill = (job == JOB_ARCHER) ? SNIPERS_EYE[1] : ASSAULT_STANCE[1]
})
dispatch.hook('S_PLAYER_CHANGE_STAMINA', 1, (event) => {
if (job !== JOB_WARRIOR) return
re = event.current
})
dispatch.hook('S_ABNORMALITY_BEGIN', 2, (event) => {
if (event.source.equals(cid)) {
if (ASSAULT_STANCE.includes(event.id) || SNIPERS_EYE.includes(event.id)) on = true
}
})
dispatch.hook('S_ABNORMALITY_END', 1, (event) => {
if (event.target.equals(cid)) {
if (ASSAULT_STANCE.includes(event.id) || SNIPERS_EYE.includes(event.id)) {
on = false
tryActivateStance()
}
}
})
function tryActivateStance() {
if (interval) clearInterval(interval)
interval = setInterval(() => {
if (!on) {
if (job == JOB_WARRIOR && re <= 1000 || mounted) return
dispatch.toServer('C_START_SKILL', 2, {
skill: skill,
w: location.w,
x1: location.x1,
y1: location.y1,
z1: location.z1,
x2: location.x2,
y2: location.y2,
z2: location.z2,
unk1: 0,
movementkey: 0,
unk3: 0,
target: cid
})
} else clearInterval(interval)
}, INTERVAL)
}
}