This repository has been archived by the owner on May 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
73 lines (58 loc) · 2 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
// <3 Pinkie Pie :3
module.exports = function QuickLoad(mod) {
let maxDistance = 1000, // Distance at which quick-load will always ignore loading screens
longTele = false, // Enables quick-load for long teleports beyond maxDistance
longTeleHoldMs = 1000 // Hold duration to prevent falling through the map - Depends on your disk speed
let zone = -1,
serverQuick = false,
modifying = false,
myPos = null,
spawnLoc = null
mod.hook('S_LOGIN', 'raw', () => {
zone = -1
myPos = null
})
mod.hook('S_LOAD_TOPO', 3, {order: 100}, event => {
serverQuick = event.quick
if(event.zone === zone && (longTele || myPos.dist3D(event.loc) <= maxDistance))
return event.quick = modifying = true
myPos = event.loc
zone = event.zone
modifying = false
})
mod.hook('S_SPAWN_ME', 3, {order: 100}, event => {
if(!serverQuick) spawnLoc = event
if(modifying) {
if(!myPos || myPos.dist3D(event.loc) > maxDistance)
process.nextTick(() => { mod.send('S_ADMIN_HOLD_CHARACTER', 2, {hold: true}) })
else modifying = false
mod.send('S_SPAWN_ME', 3, event) // Bring our character model back from the void
mod.send('C_PLAYER_LOCATION', 5, { // Update our position on the server
loc: event.loc,
dest: event.loc,
type: 7
})
}
})
mod.hook('S_ADMIN_HOLD_CHARACTER', 'raw', () => !modifying && undefined)
mod.hook('C_PLAYER_LOCATION', 5, event => {
if(spawnLoc) {
// Did we accidentally spawn under the map? Let's fix that!
if(event.loc.z !== spawnLoc.loc.z) {
mod.send('S_INSTANT_MOVE', 3, spawnLoc)
spawnLoc = null
return false
}
spawnLoc = null
}
})
mod.hook('C_PLAYER_LOCATION', 5, {order: 100, filter: {fake: null}}, event => { myPos = event.loc })
mod.hook('C_VISIT_NEW_SECTION', 'raw', () => {
// If our client doesn't send C_PLAYER_LOCATION before this packet, then it's most likely user input
spawnLoc = null
if(modifying) {
mod.setTimeout(() => { mod.send('S_ADMIN_HOLD_CHARACTER', 2, {hold: false}) }, longTeleHoldMs)
modifying = false
}
})
}