teeworlds 2.5.5 → 2.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{index.ts → index.d.ts} +6 -6
- package/index.js +1 -0
- package/index.js.map +1 -0
- package/lib/MsgPacker.d.ts +11 -0
- package/lib/MsgPacker.js +1 -0
- package/lib/MsgPacker.js.map +1 -0
- package/lib/MsgUnpacker.d.ts +16 -0
- package/lib/MsgUnpacker.js +1 -0
- package/lib/MsgUnpacker.js.map +1 -0
- package/lib/UUIDManager.d.ts +27 -0
- package/lib/UUIDManager.js +1 -0
- package/lib/UUIDManager.js.map +1 -0
- package/lib/client.d.ts +135 -0
- package/lib/client.js +5 -4
- package/lib/client.js.map +1 -0
- package/lib/components/game.d.ts +32 -0
- package/lib/components/game.js +1 -0
- package/lib/components/game.js.map +1 -0
- package/lib/components/movement.d.ts +34 -0
- package/lib/components/movement.js +1 -0
- package/lib/components/movement.js.map +1 -0
- package/lib/components/rcon.d.ts +33 -0
- package/lib/components/rcon.js +1 -0
- package/lib/components/rcon.js.map +1 -0
- package/lib/components/snapshot.d.ts +59 -0
- package/lib/components/snapshot.js +1 -0
- package/lib/components/snapshot.js.map +1 -0
- package/lib/enums_types/protocol.d.ts +120 -0
- package/lib/enums_types/protocol.js +1 -0
- package/lib/enums_types/protocol.js.map +1 -0
- package/lib/huffman.d.ts +24 -0
- package/lib/huffman.js +1 -0
- package/lib/huffman.js.map +1 -0
- package/lib/snapshot.d.ts +49 -0
- package/lib/snapshot.js +1 -0
- package/lib/snapshot.js.map +1 -0
- package/package.json +21 -25
- package/docs/documentation.md +0 -371
- package/docs/examples/chat_bot.js +0 -25
- package/docs/examples/kill_on_freeze.js +0 -20
- package/lib/MsgPacker.ts +0 -45
- package/lib/MsgUnpacker.ts +0 -58
- package/lib/UUIDManager.ts +0 -45
- package/lib/client.ts +0 -947
- package/lib/components/game.ts +0 -133
- package/lib/components/movement.ts +0 -88
- package/lib/components/rcon.ts +0 -114
- package/lib/components/snapshot.ts +0 -187
- package/lib/enums_types/protocol.ts +0 -145
- package/lib/enums_types/types.d.ts +0 -236
- package/lib/huffman.ts +0 -226
- package/lib/snapshot.ts +0 -632
- package/tsconfig.json +0 -69
package/lib/components/game.ts
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { MsgPacker } from "../MsgPacker";
|
|
3
|
-
import { SnapshotItemTypes } from "../enums_types/types";
|
|
4
|
-
import { Client } from "../client";
|
|
5
|
-
import { NETMSG } from "../enums_types/protocol";
|
|
6
|
-
|
|
7
|
-
export class Game {
|
|
8
|
-
// SendMsgEx: (Msgs: MsgPacker[] | MsgPacker) => void;
|
|
9
|
-
private _client: Client;
|
|
10
|
-
_ping_resolve: (_time: number) => void;
|
|
11
|
-
constructor(_client: Client) {
|
|
12
|
-
// this.SendMsgEx = callback;
|
|
13
|
-
this._client = _client;
|
|
14
|
-
this._ping_resolve = () => {};
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
private send(packer: MsgPacker) {
|
|
18
|
-
if (!this._client.options?.lightweight)
|
|
19
|
-
this._client.QueueChunkEx(packer);
|
|
20
|
-
else
|
|
21
|
-
this._client.SendMsgEx(packer);
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
Say(message: string, team = false) {
|
|
26
|
-
var packer = new MsgPacker(NETMSG.Game.CL_SAY, false, 1);
|
|
27
|
-
packer.AddInt(team ? 1 : 0); // team
|
|
28
|
-
packer.AddString(message);
|
|
29
|
-
this.send(packer);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
/** Set the team of an bot. (-1 spectator team, 0 team red/normal team, 1 team blue) */
|
|
34
|
-
SetTeam(team: number) {
|
|
35
|
-
var packer = new MsgPacker(NETMSG.Game.CL_SETTEAM, false, 1);
|
|
36
|
-
packer.AddInt(team);
|
|
37
|
-
this.send(packer);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/** Spectate an player, taking their id as parameter. pretty useless */
|
|
42
|
-
SpectatorMode(SpectatorID: number) {
|
|
43
|
-
var packer = new MsgPacker(NETMSG.Game.CL_SETSPECTATORMODE, false, 1);
|
|
44
|
-
packer.AddInt(SpectatorID);
|
|
45
|
-
this.send(packer);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
/** Change the player info */
|
|
51
|
-
ChangePlayerInfo(playerInfo: SnapshotItemTypes.ClientInfo) {
|
|
52
|
-
var packer = new MsgPacker(NETMSG.Game.CL_CHANGEINFO, false, 1);
|
|
53
|
-
packer.AddString(playerInfo.name);
|
|
54
|
-
packer.AddString(playerInfo.clan);
|
|
55
|
-
packer.AddInt(playerInfo.country);
|
|
56
|
-
packer.AddString(playerInfo.skin);
|
|
57
|
-
packer.AddInt(playerInfo.use_custom_color ? 1 : 0);
|
|
58
|
-
packer.AddInt(playerInfo.color_body);
|
|
59
|
-
packer.AddInt(playerInfo.color_feet);
|
|
60
|
-
this.send(packer);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
/** Kill */
|
|
65
|
-
Kill() {
|
|
66
|
-
var packer = new MsgPacker(NETMSG.Game.CL_KILL, false, 1);
|
|
67
|
-
this.send(packer);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
/** Send emote */
|
|
72
|
-
Emote(emote: number) {
|
|
73
|
-
var packer = new MsgPacker(NETMSG.Game.CL_EMOTICON, false, 1);
|
|
74
|
-
packer.AddInt(emote);
|
|
75
|
-
this.send(packer);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
/** Vote for an already running vote (true = f3 / false = f4) */
|
|
80
|
-
Vote(vote: boolean) {
|
|
81
|
-
var packer = new MsgPacker(NETMSG.Game.CL_VOTE, false, 1);
|
|
82
|
-
packer.AddInt(vote ? 1 : -1);
|
|
83
|
-
this.send(packer);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
private CallVote(Type: "option" | "kick" | "spectate", Value: string|number, Reason: string) {
|
|
87
|
-
var packer = new MsgPacker(NETMSG.Game.CL_CALLVOTE, false, 1);
|
|
88
|
-
packer.AddString(Type);
|
|
89
|
-
packer.AddString(String(Value));
|
|
90
|
-
packer.AddString(Reason);
|
|
91
|
-
this.send(packer);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/** Call a vote for an server option (for example ddnet maps) */
|
|
95
|
-
CallVoteOption(Value: string, Reason: string) {
|
|
96
|
-
this.CallVote("option", Value, Reason)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/** Call a vote to kick a player. Requires the player id */
|
|
100
|
-
CallVoteKick(PlayerID: string|number, Reason: string) {
|
|
101
|
-
this.CallVote("kick", PlayerID, Reason)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** Call a vote to set a player in spectator mode. Requires the player id */
|
|
105
|
-
CallVoteSpectate(PlayerID: string|number, Reason: string) {
|
|
106
|
-
this.CallVote("spectate", PlayerID, Reason)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
/** probably some verification of using ddnet client. */
|
|
112
|
-
IsDDNetLegacy() {
|
|
113
|
-
var packer = new MsgPacker(NETMSG.Game.CL_ISDDNETLEGACY, false, 1);
|
|
114
|
-
this.send(packer);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/** returns the ping in ms (as a promise) */
|
|
118
|
-
Ping(): Promise<number> {
|
|
119
|
-
return new Promise((resolve, reject) => {
|
|
120
|
-
var packer = new MsgPacker(22, true, 0);
|
|
121
|
-
let startTime = new Date().getTime();
|
|
122
|
-
this.send(packer);
|
|
123
|
-
|
|
124
|
-
let callback = (_time: number) => {
|
|
125
|
-
resolve(_time - startTime);
|
|
126
|
-
this._ping_resolve = () => {};
|
|
127
|
-
}
|
|
128
|
-
this._ping_resolve = callback;
|
|
129
|
-
})
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
interface NetObj_PlayerInput {
|
|
2
|
-
m_Direction: number,
|
|
3
|
-
m_TargetX: number,
|
|
4
|
-
m_TargetY: number,
|
|
5
|
-
m_Jump: number,
|
|
6
|
-
m_Fire: number,
|
|
7
|
-
m_Hook: number,
|
|
8
|
-
m_PlayerFlags: number,
|
|
9
|
-
m_WantedWeapon: number,
|
|
10
|
-
m_NextWeapon: number,
|
|
11
|
-
m_PrevWeapon: number
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
class Movement {
|
|
15
|
-
input: NetObj_PlayerInput;
|
|
16
|
-
constructor() {
|
|
17
|
-
this.input = {m_Direction: 0, m_Fire: 0, m_Hook: 0, m_Jump: 0, m_NextWeapon: 0, m_PlayerFlags: 1, m_PrevWeapon: 0, m_TargetX: 0, m_TargetY: 0, m_WantedWeapon: 1} as NetObj_PlayerInput;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
RunLeft() {
|
|
21
|
-
this.input.m_Direction = -1;
|
|
22
|
-
}
|
|
23
|
-
RunRight() {
|
|
24
|
-
this.input.m_Direction = 1;
|
|
25
|
-
}
|
|
26
|
-
RunStop() {
|
|
27
|
-
this.input.m_Direction = 0;
|
|
28
|
-
}
|
|
29
|
-
Jump(state = true) {
|
|
30
|
-
this.input.m_Jump = state ? 1 : 0;
|
|
31
|
-
}
|
|
32
|
-
Fire() {
|
|
33
|
-
this.input.m_Fire++;
|
|
34
|
-
}
|
|
35
|
-
Hook(state = true) {
|
|
36
|
-
this.input.m_Hook = state ? 1 : 0;
|
|
37
|
-
}
|
|
38
|
-
NextWeapon() {
|
|
39
|
-
this.input.m_NextWeapon = 1;
|
|
40
|
-
this.WantedWeapon(0);
|
|
41
|
-
}
|
|
42
|
-
PrevWeapon() {
|
|
43
|
-
this.input.m_PrevWeapon = 1;
|
|
44
|
-
this.WantedWeapon(0);
|
|
45
|
-
}
|
|
46
|
-
WantedWeapon(weapon: number) {
|
|
47
|
-
this.input.m_WantedWeapon = weapon;
|
|
48
|
-
}
|
|
49
|
-
SetAim(x: number, y: number) {
|
|
50
|
-
this.input.m_TargetX = x;
|
|
51
|
-
this.input.m_TargetY = y;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private Flag(toggle: boolean, num: number) {
|
|
55
|
-
if (toggle) {
|
|
56
|
-
this.input.m_PlayerFlags |= num;
|
|
57
|
-
} else {
|
|
58
|
-
this.input.m_PlayerFlags &= ~num;
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
FlagPlaying(toggle = true) {
|
|
63
|
-
this.Flag(toggle, 1);
|
|
64
|
-
}
|
|
65
|
-
FlagInMenu(toggle = true) {
|
|
66
|
-
this.Flag(toggle, 2);
|
|
67
|
-
}
|
|
68
|
-
FlagChatting(toggle = true) {
|
|
69
|
-
this.Flag(toggle, 4);
|
|
70
|
-
}
|
|
71
|
-
FlagScoreboard(toggle = true) {
|
|
72
|
-
this.Flag(toggle, 8);
|
|
73
|
-
}
|
|
74
|
-
FlagHookline(toggle = true) {
|
|
75
|
-
this.Flag(toggle, 16);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
Reset() {
|
|
79
|
-
this.input.m_Direction = 0;
|
|
80
|
-
this.input.m_Jump = 0;
|
|
81
|
-
this.input.m_Fire = 0;
|
|
82
|
-
this.input.m_Hook = 0;
|
|
83
|
-
this.input.m_PlayerFlags = 0;
|
|
84
|
-
this.input.m_NextWeapon = 0;
|
|
85
|
-
this.input.m_PrevWeapon = 0;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
export default Movement;
|
package/lib/components/rcon.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { EventEmitter } from "stream";
|
|
3
|
-
import { MsgPacker } from "../MsgPacker";
|
|
4
|
-
import { MsgUnpacker } from "../MsgUnpacker";
|
|
5
|
-
import { Client } from "../client";
|
|
6
|
-
import { NETMSG } from "../enums_types/protocol";
|
|
7
|
-
import { Chunk, RconCommand } from "../enums_types/types";
|
|
8
|
-
|
|
9
|
-
interface RconEvents {
|
|
10
|
-
rcon_line: (line: string) => void;
|
|
11
|
-
rcon_auth_status: (info: {AuthLevel: number, ReceiveCommands: number}) => void;
|
|
12
|
-
rcon_cmd_add: (info: {command: string, description: string, params: string}) => void;
|
|
13
|
-
rcon_cmd_rem: (info: {command: string}) => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export class Rcon extends EventEmitter {
|
|
18
|
-
on<K extends keyof RconEvents>(event: K, listener: RconEvents[K]): this {
|
|
19
|
-
return super.on(event, listener);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
emit<K extends keyof RconEvents>(event: K, ...args: Parameters<RconEvents[K]>): boolean {
|
|
23
|
-
return super.emit(event, ...args);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
CommandList: RconCommand[] = [];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
private _client: Client;
|
|
30
|
-
constructor(_client: Client) {
|
|
31
|
-
super();
|
|
32
|
-
this._client = _client;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// SendMsgEx: (Msgs: MsgPacker[] | MsgPacker) => void;
|
|
36
|
-
private send(packer: MsgPacker | MsgPacker[]) {
|
|
37
|
-
if (!this._client.options?.lightweight)
|
|
38
|
-
this._client.QueueChunkEx(packer);
|
|
39
|
-
else
|
|
40
|
-
this._client.SendMsgEx(packer);
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
public auth(username: string, password: string): void;
|
|
44
|
-
public auth(password: string): void;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/** Rcon auth, set the `username` to empty string for authentication w/o username **/
|
|
48
|
-
auth(usernameOrPassword: string, password?: string) {
|
|
49
|
-
const rconAuthMsg = new MsgPacker(NETMSG.System.NETMSG_RCON_AUTH, true, 1);
|
|
50
|
-
if (password == undefined) {
|
|
51
|
-
rconAuthMsg.AddString("");
|
|
52
|
-
rconAuthMsg.AddString(usernameOrPassword);
|
|
53
|
-
|
|
54
|
-
} else {
|
|
55
|
-
rconAuthMsg.AddString(usernameOrPassword);
|
|
56
|
-
rconAuthMsg.AddString(password);
|
|
57
|
-
}
|
|
58
|
-
rconAuthMsg.AddInt(1);
|
|
59
|
-
this.send(rconAuthMsg);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** Send rcon command **/
|
|
63
|
-
rcon(cmds: string[] | string) {
|
|
64
|
-
let _cmds: string[];
|
|
65
|
-
if (cmds instanceof Array) _cmds = cmds
|
|
66
|
-
else _cmds = [cmds];
|
|
67
|
-
const msgs: MsgPacker[] = [];
|
|
68
|
-
_cmds.forEach((cmd) => {
|
|
69
|
-
const rconCmdMsg = new MsgPacker(NETMSG.System.NETMSG_RCON_CMD, true, 1);
|
|
70
|
-
rconCmdMsg.AddString(cmd);
|
|
71
|
-
msgs.push(rconCmdMsg);
|
|
72
|
-
})
|
|
73
|
-
this.send(msgs);
|
|
74
|
-
}
|
|
75
|
-
/** This method is called by the Client to handle the chunks. It should not be called directly. */
|
|
76
|
-
_checkChunks(chunk: Chunk): boolean {
|
|
77
|
-
if (chunk.msgid == NETMSG.System.NETMSG_RCON_LINE) {
|
|
78
|
-
const unpacker = new MsgUnpacker(chunk.raw);
|
|
79
|
-
const msg = unpacker.unpackString();
|
|
80
|
-
this.emit('rcon_line', msg);
|
|
81
|
-
|
|
82
|
-
} else if (chunk.msgid == NETMSG.System.NETMSG_RCON_AUTH_STATUS) {
|
|
83
|
-
const unpacker = new MsgUnpacker(chunk.raw);
|
|
84
|
-
const AuthLevel = unpacker.unpackInt();
|
|
85
|
-
const ReceiveCommands = unpacker.unpackInt();
|
|
86
|
-
this.emit('rcon_auth_status', {AuthLevel, ReceiveCommands});
|
|
87
|
-
} else if (chunk.msgid == NETMSG.System.NETMSG_RCON_CMD_ADD) {
|
|
88
|
-
const unpacker = new MsgUnpacker(chunk.raw);
|
|
89
|
-
const command = unpacker.unpackString();
|
|
90
|
-
const description = unpacker.unpackString();
|
|
91
|
-
const params = unpacker.unpackString();
|
|
92
|
-
|
|
93
|
-
this.CommandList.push({command, description, params});
|
|
94
|
-
|
|
95
|
-
this.emit('rcon_cmd_add', {command, description, params});
|
|
96
|
-
} else if (chunk.msgid == NETMSG.System.NETMSG_RCON_CMD_REM) {
|
|
97
|
-
const unpacker = new MsgUnpacker(chunk.raw);
|
|
98
|
-
const command = unpacker.unpackString();
|
|
99
|
-
this.emit('rcon_cmd_rem', {command});
|
|
100
|
-
|
|
101
|
-
let index = this.CommandList.findIndex(a => a.command == command);
|
|
102
|
-
if (index -1 >= 0)
|
|
103
|
-
this.CommandList.splice(index, 1);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Client } from "../client";
|
|
3
|
-
import { EventEmitter } from "stream";
|
|
4
|
-
import { SnapshotItemTypes } from "../enums_types/types";
|
|
5
|
-
import { SnapshotItemIDs } from "../enums_types/protocol";
|
|
6
|
-
export declare interface SnapshotWrapper {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
on(event: 'common', listener: (common: SnapshotItemTypes.Common) => void): this;
|
|
10
|
-
on(event: 'explosion', listener: (explosion: SnapshotItemTypes.Explosion) => void): this;
|
|
11
|
-
on(event: 'spawn', listener: (spawn: SnapshotItemTypes.Spawn) => void): this;
|
|
12
|
-
on(event: 'hammerhit', listener: (hammerhit: SnapshotItemTypes.HammerHit) => void): this;
|
|
13
|
-
on(event: 'death', listener: (death: SnapshotItemTypes.Death) => void): this;
|
|
14
|
-
on(event: 'sound_global', listener: (sound_global: SnapshotItemTypes.SoundGlobal) => void): this;
|
|
15
|
-
on(event: 'sound_world', listener: (sound_world: SnapshotItemTypes.SoundWorld) => void): this;
|
|
16
|
-
on(event: 'damage_indicator', listener: (damage_indicator: SnapshotItemTypes.DamageInd) => void): this;
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class SnapshotWrapper extends EventEmitter {
|
|
21
|
-
private _client: Client;
|
|
22
|
-
constructor(_client: Client) {
|
|
23
|
-
// this.SendMsgEx = callback;
|
|
24
|
-
super();
|
|
25
|
-
this._client = _client;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
private getParsed<T>(type_id: number, id: number) {
|
|
29
|
-
if (type_id == -1)
|
|
30
|
-
return undefined;
|
|
31
|
-
return this._client.rawSnapUnpacker.deltas.find(delta => delta.type_id == type_id && delta.id == id)?.parsed as unknown as T;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
private getAll<T>(type_id: number): T[] {
|
|
35
|
-
let _all: T[] = [];
|
|
36
|
-
if (type_id == -1)
|
|
37
|
-
return _all;
|
|
38
|
-
this._client.rawSnapUnpacker.deltas.forEach(delta => {
|
|
39
|
-
if (delta.type_id == type_id)
|
|
40
|
-
_all.push(delta.parsed as T);
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return _all;
|
|
45
|
-
// return this._client.rawSnapUnpacker.deltas.filter(delta => delta.type_id == type_id && delta.id == id).map(a => a.parsed);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
getObjPlayerInput(player_id: number): SnapshotItemTypes.PlayerInput | undefined {
|
|
49
|
-
return this.getParsed(SnapshotItemIDs.OBJ_PLAYER_INPUT, player_id);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
get AllObjPlayerInput(): SnapshotItemTypes.PlayerInput[] {
|
|
53
|
-
return this.getAll(SnapshotItemIDs.OBJ_PLAYER_INPUT);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
getObjProjectile(id: number): SnapshotItemTypes.Projectile | undefined {
|
|
57
|
-
return this.getParsed(SnapshotItemIDs.OBJ_PROJECTILE, id);
|
|
58
|
-
}
|
|
59
|
-
get AllProjectiles(): SnapshotItemTypes.Projectile[] {
|
|
60
|
-
return this.getAll(SnapshotItemIDs.OBJ_PROJECTILE);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
getObjLaser(id: number): SnapshotItemTypes.Laser | undefined {
|
|
64
|
-
return this.getParsed(SnapshotItemIDs.OBJ_LASER, id);
|
|
65
|
-
}
|
|
66
|
-
get AllObjLaser(): SnapshotItemTypes.Laser[] {
|
|
67
|
-
return this.getAll(SnapshotItemIDs.OBJ_LASER);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
getObjPickup(id: number): SnapshotItemTypes.Pickup | undefined {
|
|
71
|
-
return this.getParsed(SnapshotItemIDs.OBJ_PICKUP, id);
|
|
72
|
-
}
|
|
73
|
-
get AllObjPickup(): SnapshotItemTypes.Pickup[] {
|
|
74
|
-
return this.getAll(SnapshotItemIDs.OBJ_PICKUP);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
getObjFlag(id: number): SnapshotItemTypes.Flag | undefined {
|
|
78
|
-
return this.getParsed(SnapshotItemIDs.OBJ_FLAG, id);
|
|
79
|
-
}
|
|
80
|
-
get AllObjFlag(): SnapshotItemTypes.Flag[] {
|
|
81
|
-
return this.getAll(SnapshotItemIDs.OBJ_FLAG);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
getObjGameInfo(id: number): SnapshotItemTypes.GameInfo | undefined {
|
|
85
|
-
return this.getParsed(SnapshotItemIDs.OBJ_GAME_INFO, id);
|
|
86
|
-
}
|
|
87
|
-
get AllObjGameInfo(): SnapshotItemTypes.GameInfo[] {
|
|
88
|
-
return this.getAll(SnapshotItemIDs.OBJ_GAME_INFO);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
getObjGameData(id: number): SnapshotItemTypes.GameData | undefined {
|
|
92
|
-
return this.getParsed(SnapshotItemIDs.OBJ_GAME_DATA, id);
|
|
93
|
-
}
|
|
94
|
-
get AllObjGameData(): SnapshotItemTypes.GameData[] {
|
|
95
|
-
return this.getAll(SnapshotItemIDs.OBJ_GAME_DATA);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/** NOTICE: x & y positions always differ from the positions in the ingame debug menu. If you want the debug menu positions, you can calculate them like this: Math.round((myChar.character_core.x / 32) * 100)/100 */
|
|
99
|
-
getObjCharacterCore(player_id: number): SnapshotItemTypes.CharacterCore | undefined {
|
|
100
|
-
return this.getParsed(SnapshotItemIDs.OBJ_CHARACTER_CORE, player_id);
|
|
101
|
-
}
|
|
102
|
-
/** NOTICE: x & y positions always differ from the positions in the ingame debug menu. If you want the debug menu positions, you can calculate them like this: Math.round((myChar.character_core.x / 32) * 100)/100 */
|
|
103
|
-
get AllObjCharacterCore(): SnapshotItemTypes.CharacterCore[] {
|
|
104
|
-
return this.getAll(SnapshotItemIDs.OBJ_CHARACTER_CORE);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** NOTICE: x & y positions always differ from the positions in the ingame debug menu. If you want the debug menu positions, you can calculate them like this: Math.round((myChar.character_core.x / 32) * 100)/100 */
|
|
108
|
-
getObjCharacter(player_id: number): SnapshotItemTypes.Character | undefined {
|
|
109
|
-
return this.getParsed(SnapshotItemIDs.OBJ_CHARACTER, player_id);
|
|
110
|
-
}
|
|
111
|
-
/** NOTICE: x & y positions always differ from the positions in the ingame debug menu. If you want the debug menu positions, you can calculate them like this: Math.round((myChar.character_core.x / 32) * 100)/100 */
|
|
112
|
-
get AllObjCharacter(): SnapshotItemTypes.Character[] {
|
|
113
|
-
|
|
114
|
-
return this.getAll(SnapshotItemIDs.OBJ_CHARACTER);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
getObjPlayerInfo(player_id: number): SnapshotItemTypes.PlayerInfo | undefined {
|
|
118
|
-
return this.getParsed(SnapshotItemIDs.OBJ_PLAYER_INFO, player_id);
|
|
119
|
-
}
|
|
120
|
-
get AllObjPlayerInfo(): SnapshotItemTypes.PlayerInfo[] {
|
|
121
|
-
return this.getAll(SnapshotItemIDs.OBJ_PLAYER_INFO);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
getObjClientInfo(player_id: number): SnapshotItemTypes.ClientInfo | undefined {
|
|
125
|
-
return this.getParsed(SnapshotItemIDs.OBJ_CLIENT_INFO, player_id);
|
|
126
|
-
}
|
|
127
|
-
get AllObjClientInfo(): SnapshotItemTypes.ClientInfo[] {
|
|
128
|
-
return this.getAll(SnapshotItemIDs.OBJ_CLIENT_INFO);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
getObjSpectatorInfo(player_id: number): SnapshotItemTypes.SpectatorInfo | undefined {
|
|
132
|
-
return this.getParsed(SnapshotItemIDs.OBJ_SPECTATOR_INFO, player_id);
|
|
133
|
-
}
|
|
134
|
-
get AllObjSpectatorInfo(): SnapshotItemTypes.SpectatorInfo[] {
|
|
135
|
-
return this.getAll(SnapshotItemIDs.OBJ_SPECTATOR_INFO);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
private getTypeId(name: string) {
|
|
139
|
-
return this._client.rawSnapUnpacker.uuid_manager.LookupName(name)?.type_id || -1;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
getObjExMyOwnObject(id: number): SnapshotItemTypes.MyOwnObject | undefined {
|
|
143
|
-
return this.getParsed(this.getTypeId("my-own-object@heinrich5991.de"), id);
|
|
144
|
-
}
|
|
145
|
-
get AllObjExMyOwnObject(): SnapshotItemTypes.MyOwnObject[] {
|
|
146
|
-
return this.getAll(this.getTypeId("my-own-object@heinrich5991.de"));
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
getObjExDDNetCharacter(id: number): SnapshotItemTypes.DDNetCharacter | undefined {
|
|
150
|
-
return this.getParsed(this.getTypeId("character@netobj.ddnet.tw"), id);
|
|
151
|
-
}
|
|
152
|
-
get AllObjExDDNetCharacter(): SnapshotItemTypes.DDNetCharacter[] {
|
|
153
|
-
return this.getAll(this.getTypeId("character@netobj.ddnet.tw"));
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
getObjExGameInfo(id: number): SnapshotItemTypes.GameInfoEx | undefined {
|
|
157
|
-
return this.getParsed(this.getTypeId("gameinfo@netobj.ddnet.tw"), id);
|
|
158
|
-
}
|
|
159
|
-
get AllObjExGameInfo(): SnapshotItemTypes.GameInfoEx[] {
|
|
160
|
-
return this.getAll(this.getTypeId("gameinfo@netobj.ddnet.tw"));
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
getObjExDDNetProjectile(id: number): SnapshotItemTypes.DDNetProjectile | undefined {
|
|
164
|
-
return this.getParsed(this.getTypeId("projectile@netobj.ddnet.tw"), id);
|
|
165
|
-
}
|
|
166
|
-
get AllObjExDDNetProjectile(): SnapshotItemTypes.DDNetProjectile[] {
|
|
167
|
-
return this.getAll(this.getTypeId("projectile@netobj.ddnet.tw"));
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
getObjExLaser(id: number): SnapshotItemTypes.DDNetLaser | undefined {
|
|
171
|
-
return this.getParsed(this.getTypeId("laser@netobj.ddnet.tw"), id);
|
|
172
|
-
}
|
|
173
|
-
get AllObjExLaser(): SnapshotItemTypes.DDNetLaser[] {
|
|
174
|
-
return this.getAll(this.getTypeId("laser@netobj.ddnet.tw"));
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
get OwnID(): number | undefined {
|
|
182
|
-
return this.AllObjPlayerInfo.find(parsed => parsed.local)?.client_id;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
export enum States {
|
|
2
|
-
STATE_OFFLINE = 0,
|
|
3
|
-
STATE_CONNECTING,
|
|
4
|
-
STATE_LOADING,
|
|
5
|
-
STATE_ONLINE,
|
|
6
|
-
STATE_DEMOPLAYBACK,
|
|
7
|
-
STATE_QUITTING,
|
|
8
|
-
STATE_RESTARTING
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export namespace NETMSG {
|
|
12
|
-
|
|
13
|
-
export const enum Game {
|
|
14
|
-
EX,
|
|
15
|
-
SV_MOTD,
|
|
16
|
-
SV_BROADCAST,
|
|
17
|
-
SV_CHAT,
|
|
18
|
-
SV_KILLMSG,
|
|
19
|
-
SV_SOUNDGLOBAL,
|
|
20
|
-
SV_TUNEPARAMS,
|
|
21
|
-
SV_EXTRAPROJECTILE,
|
|
22
|
-
SV_READYTOENTER,
|
|
23
|
-
SV_WEAPONPICKUP,
|
|
24
|
-
SV_EMOTICON,
|
|
25
|
-
SV_VOTECLEAROPTIONS,
|
|
26
|
-
SV_VOTEOPTIONLISTADD,
|
|
27
|
-
SV_VOTEOPTIONADD,
|
|
28
|
-
SV_VOTEOPTIONREMOVE,
|
|
29
|
-
SV_VOTESET,
|
|
30
|
-
SV_VOTESTATUS,
|
|
31
|
-
CL_SAY,
|
|
32
|
-
CL_SETTEAM,
|
|
33
|
-
CL_SETSPECTATORMODE,
|
|
34
|
-
CL_STARTINFO,
|
|
35
|
-
CL_CHANGEINFO,
|
|
36
|
-
CL_KILL,
|
|
37
|
-
CL_EMOTICON,
|
|
38
|
-
CL_VOTE,
|
|
39
|
-
CL_CALLVOTE,
|
|
40
|
-
CL_ISDDNETLEGACY,
|
|
41
|
-
SV_DDRACETIMELEGACY,
|
|
42
|
-
SV_RECORDLEGACY,
|
|
43
|
-
UNUSED,
|
|
44
|
-
SV_TEAMSSTATELEGACY,
|
|
45
|
-
CL_SHOWOTHERSLEGACY,
|
|
46
|
-
NUM
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const enum System {
|
|
50
|
-
NETMSG_EX = 0,
|
|
51
|
-
|
|
52
|
-
// the first thing sent by the client
|
|
53
|
-
// contains the version info for the client
|
|
54
|
-
NETMSG_INFO = 1,
|
|
55
|
-
|
|
56
|
-
// sent by server
|
|
57
|
-
NETMSG_MAP_CHANGE, // sent when client should switch map
|
|
58
|
-
NETMSG_MAP_DATA, // map transfer, contains a chunk of the map file
|
|
59
|
-
NETMSG_CON_READY, // connection is ready, client should send start info
|
|
60
|
-
NETMSG_SNAP, // normal snapshot, multiple parts
|
|
61
|
-
NETMSG_SNAPEMPTY, // empty snapshot
|
|
62
|
-
NETMSG_SNAPSINGLE, // ?
|
|
63
|
-
NETMSG_SNAPSMALL, //
|
|
64
|
-
NETMSG_INPUTTIMING, // reports how off the input was
|
|
65
|
-
NETMSG_RCON_AUTH_STATUS, // result of the authentication
|
|
66
|
-
NETMSG_RCON_LINE, // line that should be printed to the remote console
|
|
67
|
-
|
|
68
|
-
NETMSG_AUTH_CHALLANGE, //
|
|
69
|
-
NETMSG_AUTH_RESULT, //
|
|
70
|
-
|
|
71
|
-
// sent by client
|
|
72
|
-
NETMSG_READY, //
|
|
73
|
-
NETMSG_ENTERGAME,
|
|
74
|
-
NETMSG_INPUT, // contains the inputdata from the client
|
|
75
|
-
NETMSG_RCON_CMD, //
|
|
76
|
-
NETMSG_RCON_AUTH, //
|
|
77
|
-
NETMSG_REQUEST_MAP_DATA, //
|
|
78
|
-
|
|
79
|
-
NETMSG_AUTH_START, //
|
|
80
|
-
NETMSG_AUTH_RESPONSE, //
|
|
81
|
-
|
|
82
|
-
// sent by both
|
|
83
|
-
NETMSG_PING,
|
|
84
|
-
NETMSG_PING_REPLY,
|
|
85
|
-
NETMSG_ERROR,
|
|
86
|
-
|
|
87
|
-
// sent by server (todo: move it up)
|
|
88
|
-
NETMSG_RCON_CMD_ADD,
|
|
89
|
-
NETMSG_RCON_CMD_REM,
|
|
90
|
-
|
|
91
|
-
NUM_NETMSGS,
|
|
92
|
-
|
|
93
|
-
NETMSG_WHATIS = 65536,
|
|
94
|
-
NETMSG_ITIS,
|
|
95
|
-
NETMSG_IDONTKNOW,
|
|
96
|
-
|
|
97
|
-
NETMSG_RCONTYPE,
|
|
98
|
-
NETMSG_MAP_DETAILS,
|
|
99
|
-
NETMSG_CAPABILITIES,
|
|
100
|
-
NETMSG_CLIENTVER,
|
|
101
|
-
NETMSG_PINGEX,
|
|
102
|
-
NETMSG_PONGEX,
|
|
103
|
-
NETMSG_CHECKSUM_REQUEST,
|
|
104
|
-
NETMSG_CHECKSUM_RESPONSE,
|
|
105
|
-
NETMSG_CHECKSUM_ERROR,
|
|
106
|
-
|
|
107
|
-
NETMSG_REDIRECT,
|
|
108
|
-
|
|
109
|
-
NETMSG_RCON_CMD_GROUP_START,
|
|
110
|
-
NETMSG_RCON_CMD_GROUP_END,
|
|
111
|
-
NETMSG_MAP_RELOAD,
|
|
112
|
-
NETMSG_RECONNECT,
|
|
113
|
-
NETMSG_MAPLIST_ADD,
|
|
114
|
-
NETMSG_MAPLIST_GROUP_START,
|
|
115
|
-
NETMSG_MAPLIST_GROUP_END,
|
|
116
|
-
|
|
117
|
-
NETMSG_I_AM_NPM_PACKAGE
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export const enum SnapshotItemIDs {
|
|
124
|
-
OBJ_EX,
|
|
125
|
-
OBJ_PLAYER_INPUT,
|
|
126
|
-
OBJ_PROJECTILE,
|
|
127
|
-
OBJ_LASER,
|
|
128
|
-
OBJ_PICKUP,
|
|
129
|
-
OBJ_FLAG,
|
|
130
|
-
OBJ_GAME_INFO,
|
|
131
|
-
OBJ_GAME_DATA,
|
|
132
|
-
OBJ_CHARACTER_CORE,
|
|
133
|
-
OBJ_CHARACTER,
|
|
134
|
-
OBJ_PLAYER_INFO,
|
|
135
|
-
OBJ_CLIENT_INFO,
|
|
136
|
-
OBJ_SPECTATOR_INFO,
|
|
137
|
-
EVENT_COMMON,
|
|
138
|
-
EVENT_EXPLOSION,
|
|
139
|
-
EVENT_SPAWN,
|
|
140
|
-
EVENT_HAMMERHIT,
|
|
141
|
-
EVENT_DEATH,
|
|
142
|
-
EVENT_SOUND_GLOBAL,
|
|
143
|
-
EVENT_SOUND_WORLD,
|
|
144
|
-
EVENT_DAMAGE_INDICATOR
|
|
145
|
-
}
|