This repository has been archived by the owner on Oct 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
88 lines (74 loc) · 2.27 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
'use strict'
const CATEGORY_GLOBAL = 9999,
SKILL_FLYING_DISMOUNT = 65000001
module.exports = function FlyMore(mod) {
let gameId = null,
location = null,
outOfEnergy = false,
dismountByUser = false,
mountDisabled = false,
inCombat = false,
mountSkill = -1,
serverMounted = false,
remountTimer = null
mod.hook('S_LOGIN', 10, event => { ({gameId} = event) })
mod.hook('S_CANT_FLY_ANYMORE', 'raw', () => false)
mod.hook('S_PLAYER_CHANGE_FLIGHT_ENERGY', 1, event => { outOfEnergy = event.energy === 0 })
mod.hook('C_PLAYER_LOCATION', 5, event => { location = {flying: false, pos: event.loc, dir: event.w} })
mod.hook('C_PLAYER_FLYING_LOCATION', 4, event => {
location = {flying: true, pos: event.loc, dir: event.w}
if(outOfEnergy && event.type !== 7 && event.type !== 8) {
event.type = 7
return true
}
})
mod.hook('S_SKILL_CATEGORY', 3, event => { if(event.category === CATEGORY_GLOBAL) mountDisabled = !event.enabled })
mod.hook('S_USER_STATUS', 2, event => { if(event.gameId.equals(gameId)) inCombat = event.status === 1 })
mod.hook('C_START_SKILL', mod.base.majorPatchVersion < 74 ? 6 : 7, event => {
if(event.skill.id === mountSkill || event.skill.id === SKILL_FLYING_DISMOUNT) {
dismountByUser = true
mountSkill = -1
}
})
mod.hook('S_MOUNT_VEHICLE', 2, {order: 10}, event => {
if(event.gameId.equals(gameId)) {
const fakeMounted = mountSkill !== -1
serverMounted = true
mountSkill = event.skill
if(fakeMounted) return false
}
})
mod.hook('S_UNMOUNT_VEHICLE', 2, {order: 10}, event => {
if(!event.gameId.equals(gameId)) return
serverMounted = false
if(!location.flying || dismountByUser) {
dismountByUser = false
mountSkill = -1
}
else {
clearTimeout(remountTimer)
remountTimer = setTimeout(tryRemount, 50)
return false
}
})
function tryRemount() {
if(!mountDisabled && !inCombat) {
mod.send('C_START_SKILL', mod.base.majorPatchVersion < 74 ? 6 : 7, {
skill: mountSkill,
w: location.dir,
loc: location.pos,
unk: true
})
remountTimer = setTimeout(() => {
if(!serverMounted) {
mod.send('S_UNMOUNT_VEHICLE', 2, {gameId, skill: mountSkill})
mountSkill = -1
}
}, 1000)
}
else {
mod.send('S_UNMOUNT_VEHICLE', 2, {gameId, skill: mountSkill})
mountSkill = -1
}
}
}