teeworlds 2.5.3 → 2.5.5

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.
@@ -1,143 +1,103 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Game = void 0;
4
- var MsgPacker_1 = require("../MsgPacker");
5
- var NETMSGTYPE;
6
- (function (NETMSGTYPE) {
7
- NETMSGTYPE[NETMSGTYPE["EX"] = 0] = "EX";
8
- NETMSGTYPE[NETMSGTYPE["SV_MOTD"] = 1] = "SV_MOTD";
9
- NETMSGTYPE[NETMSGTYPE["SV_BROADCAST"] = 2] = "SV_BROADCAST";
10
- NETMSGTYPE[NETMSGTYPE["SV_CHAT"] = 3] = "SV_CHAT";
11
- NETMSGTYPE[NETMSGTYPE["SV_KILLMSG"] = 4] = "SV_KILLMSG";
12
- NETMSGTYPE[NETMSGTYPE["SV_SOUNDGLOBAL"] = 5] = "SV_SOUNDGLOBAL";
13
- NETMSGTYPE[NETMSGTYPE["SV_TUNEPARAMS"] = 6] = "SV_TUNEPARAMS";
14
- NETMSGTYPE[NETMSGTYPE["SV_EXTRAPROJECTILE"] = 7] = "SV_EXTRAPROJECTILE";
15
- NETMSGTYPE[NETMSGTYPE["SV_READYTOENTER"] = 8] = "SV_READYTOENTER";
16
- NETMSGTYPE[NETMSGTYPE["SV_WEAPONPICKUP"] = 9] = "SV_WEAPONPICKUP";
17
- NETMSGTYPE[NETMSGTYPE["SV_EMOTICON"] = 10] = "SV_EMOTICON";
18
- NETMSGTYPE[NETMSGTYPE["SV_VOTECLEAROPTIONS"] = 11] = "SV_VOTECLEAROPTIONS";
19
- NETMSGTYPE[NETMSGTYPE["SV_VOTEOPTIONLISTADD"] = 12] = "SV_VOTEOPTIONLISTADD";
20
- NETMSGTYPE[NETMSGTYPE["SV_VOTEOPTIONADD"] = 13] = "SV_VOTEOPTIONADD";
21
- NETMSGTYPE[NETMSGTYPE["SV_VOTEOPTIONREMOVE"] = 14] = "SV_VOTEOPTIONREMOVE";
22
- NETMSGTYPE[NETMSGTYPE["SV_VOTESET"] = 15] = "SV_VOTESET";
23
- NETMSGTYPE[NETMSGTYPE["SV_VOTESTATUS"] = 16] = "SV_VOTESTATUS";
24
- NETMSGTYPE[NETMSGTYPE["CL_SAY"] = 17] = "CL_SAY";
25
- NETMSGTYPE[NETMSGTYPE["CL_SETTEAM"] = 18] = "CL_SETTEAM";
26
- NETMSGTYPE[NETMSGTYPE["CL_SETSPECTATORMODE"] = 19] = "CL_SETSPECTATORMODE";
27
- NETMSGTYPE[NETMSGTYPE["CL_STARTINFO"] = 20] = "CL_STARTINFO";
28
- NETMSGTYPE[NETMSGTYPE["CL_CHANGEINFO"] = 21] = "CL_CHANGEINFO";
29
- NETMSGTYPE[NETMSGTYPE["CL_KILL"] = 22] = "CL_KILL";
30
- NETMSGTYPE[NETMSGTYPE["CL_EMOTICON"] = 23] = "CL_EMOTICON";
31
- NETMSGTYPE[NETMSGTYPE["CL_VOTE"] = 24] = "CL_VOTE";
32
- NETMSGTYPE[NETMSGTYPE["CL_CALLVOTE"] = 25] = "CL_CALLVOTE";
33
- NETMSGTYPE[NETMSGTYPE["CL_ISDDNETLEGACY"] = 26] = "CL_ISDDNETLEGACY";
34
- NETMSGTYPE[NETMSGTYPE["SV_DDRACETIMELEGACY"] = 27] = "SV_DDRACETIMELEGACY";
35
- NETMSGTYPE[NETMSGTYPE["SV_RECORDLEGACY"] = 28] = "SV_RECORDLEGACY";
36
- NETMSGTYPE[NETMSGTYPE["UNUSED"] = 29] = "UNUSED";
37
- NETMSGTYPE[NETMSGTYPE["SV_TEAMSSTATELEGACY"] = 30] = "SV_TEAMSSTATELEGACY";
38
- NETMSGTYPE[NETMSGTYPE["CL_SHOWOTHERSLEGACY"] = 31] = "CL_SHOWOTHERSLEGACY";
39
- NETMSGTYPE[NETMSGTYPE["NUM"] = 32] = "NUM";
40
- })(NETMSGTYPE || (NETMSGTYPE = {}));
41
- ;
42
- var Game = /** @class */ (function () {
43
- function Game(_client) {
44
- // this.SendMsgEx = callback;
45
- this._client = _client;
46
- this._ping_resolve = function () { };
47
- }
48
- Game.prototype.send = function (packer) {
49
- var _a;
50
- if (!((_a = this._client.options) === null || _a === void 0 ? void 0 : _a.lightweight))
51
- this._client.QueueChunkEx(packer);
52
- else
53
- this._client.SendMsgEx(packer);
54
- };
55
- Game.prototype.Say = function (message, team) {
56
- if (team === void 0) { team = false; }
57
- var packer = new MsgPacker_1.MsgPacker(NETMSGTYPE.CL_SAY, false, 1);
58
- packer.AddInt(team ? 1 : 0); // team
59
- packer.AddString(message);
60
- this.send(packer);
61
- };
62
- /** Set the team of an bot. (-1 spectator team, 0 team red/normal team, 1 team blue) */
63
- Game.prototype.SetTeam = function (team) {
64
- var packer = new MsgPacker_1.MsgPacker(NETMSGTYPE.CL_SETTEAM, false, 1);
65
- packer.AddInt(team);
66
- this.send(packer);
67
- };
68
- /** Spectate an player, taking their id as parameter. pretty useless */
69
- Game.prototype.SpectatorMode = function (SpectatorID) {
70
- var packer = new MsgPacker_1.MsgPacker(NETMSGTYPE.CL_SETSPECTATORMODE, false, 1);
71
- packer.AddInt(SpectatorID);
72
- this.send(packer);
73
- };
74
- /** Change the player info */
75
- Game.prototype.ChangePlayerInfo = function (playerInfo) {
76
- var packer = new MsgPacker_1.MsgPacker(NETMSGTYPE.CL_CHANGEINFO, false, 1);
77
- packer.AddString(playerInfo.name);
78
- packer.AddString(playerInfo.clan);
79
- packer.AddInt(playerInfo.country);
80
- packer.AddString(playerInfo.skin);
81
- packer.AddInt(playerInfo.use_custom_color ? 1 : 0);
82
- packer.AddInt(playerInfo.color_body);
83
- packer.AddInt(playerInfo.color_feet);
84
- this.send(packer);
85
- };
86
- /** Kill */
87
- Game.prototype.Kill = function () {
88
- var packer = new MsgPacker_1.MsgPacker(NETMSGTYPE.CL_KILL, false, 1);
89
- this.send(packer);
90
- };
91
- /** Send emote */
92
- Game.prototype.Emote = function (emote) {
93
- var packer = new MsgPacker_1.MsgPacker(NETMSGTYPE.CL_EMOTICON, false, 1);
94
- packer.AddInt(emote);
95
- this.send(packer);
96
- };
97
- /** Vote for an already running vote (true = f3 / false = f4) */
98
- Game.prototype.Vote = function (vote) {
99
- var packer = new MsgPacker_1.MsgPacker(NETMSGTYPE.CL_VOTE, false, 1);
100
- packer.AddInt(vote ? 1 : -1);
101
- this.send(packer);
102
- };
103
- Game.prototype.CallVote = function (Type, Value, Reason) {
104
- var packer = new MsgPacker_1.MsgPacker(NETMSGTYPE.CL_CALLVOTE, false, 1);
105
- packer.AddString(Type);
106
- packer.AddString(String(Value));
107
- packer.AddString(Reason);
108
- this.send(packer);
109
- };
110
- /** Call a vote for an server option (for example ddnet maps) */
111
- Game.prototype.CallVoteOption = function (Value, Reason) {
112
- this.CallVote("option", Value, Reason);
113
- };
114
- /** Call a vote to kick a player. Requires the player id */
115
- Game.prototype.CallVoteKick = function (PlayerID, Reason) {
116
- this.CallVote("kick", PlayerID, Reason);
117
- };
118
- /** Call a vote to set a player in spectator mode. Requires the player id */
119
- Game.prototype.CallVoteSpectate = function (PlayerID, Reason) {
120
- this.CallVote("spectate", PlayerID, Reason);
121
- };
122
- /** probably some verification of using ddnet client. */
123
- Game.prototype.IsDDNetLegacy = function () {
124
- var packer = new MsgPacker_1.MsgPacker(NETMSGTYPE.CL_ISDDNETLEGACY, false, 1);
125
- this.send(packer);
126
- };
127
- /** returns the ping in ms (as a promise) */
128
- Game.prototype.Ping = function () {
129
- var _this = this;
130
- return new Promise(function (resolve, reject) {
131
- var packer = new MsgPacker_1.MsgPacker(22, true, 0);
132
- var startTime = new Date().getTime();
133
- _this.send(packer);
134
- var callback = function (_time) {
135
- resolve(_time - startTime);
136
- _this._ping_resolve = function () { };
137
- };
138
- _this._ping_resolve = callback;
139
- });
140
- };
141
- return Game;
142
- }());
143
- exports.Game = Game;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Game = void 0;
4
+ const MsgPacker_1 = require("../MsgPacker");
5
+ class Game {
6
+ constructor(_client) {
7
+ // this.SendMsgEx = callback;
8
+ this._client = _client;
9
+ this._ping_resolve = () => { };
10
+ }
11
+ send(packer) {
12
+ var _a;
13
+ if (!((_a = this._client.options) === null || _a === void 0 ? void 0 : _a.lightweight))
14
+ this._client.QueueChunkEx(packer);
15
+ else
16
+ this._client.SendMsgEx(packer);
17
+ }
18
+ Say(message, team = false) {
19
+ var packer = new MsgPacker_1.MsgPacker(17 /* NETMSG.Game.CL_SAY */, false, 1);
20
+ packer.AddInt(team ? 1 : 0); // team
21
+ packer.AddString(message);
22
+ this.send(packer);
23
+ }
24
+ /** Set the team of an bot. (-1 spectator team, 0 team red/normal team, 1 team blue) */
25
+ SetTeam(team) {
26
+ var packer = new MsgPacker_1.MsgPacker(18 /* NETMSG.Game.CL_SETTEAM */, false, 1);
27
+ packer.AddInt(team);
28
+ this.send(packer);
29
+ }
30
+ /** Spectate an player, taking their id as parameter. pretty useless */
31
+ SpectatorMode(SpectatorID) {
32
+ var packer = new MsgPacker_1.MsgPacker(19 /* NETMSG.Game.CL_SETSPECTATORMODE */, false, 1);
33
+ packer.AddInt(SpectatorID);
34
+ this.send(packer);
35
+ }
36
+ /** Change the player info */
37
+ ChangePlayerInfo(playerInfo) {
38
+ var packer = new MsgPacker_1.MsgPacker(21 /* NETMSG.Game.CL_CHANGEINFO */, false, 1);
39
+ packer.AddString(playerInfo.name);
40
+ packer.AddString(playerInfo.clan);
41
+ packer.AddInt(playerInfo.country);
42
+ packer.AddString(playerInfo.skin);
43
+ packer.AddInt(playerInfo.use_custom_color ? 1 : 0);
44
+ packer.AddInt(playerInfo.color_body);
45
+ packer.AddInt(playerInfo.color_feet);
46
+ this.send(packer);
47
+ }
48
+ /** Kill */
49
+ Kill() {
50
+ var packer = new MsgPacker_1.MsgPacker(22 /* NETMSG.Game.CL_KILL */, false, 1);
51
+ this.send(packer);
52
+ }
53
+ /** Send emote */
54
+ Emote(emote) {
55
+ var packer = new MsgPacker_1.MsgPacker(23 /* NETMSG.Game.CL_EMOTICON */, false, 1);
56
+ packer.AddInt(emote);
57
+ this.send(packer);
58
+ }
59
+ /** Vote for an already running vote (true = f3 / false = f4) */
60
+ Vote(vote) {
61
+ var packer = new MsgPacker_1.MsgPacker(24 /* NETMSG.Game.CL_VOTE */, false, 1);
62
+ packer.AddInt(vote ? 1 : -1);
63
+ this.send(packer);
64
+ }
65
+ CallVote(Type, Value, Reason) {
66
+ var packer = new MsgPacker_1.MsgPacker(25 /* NETMSG.Game.CL_CALLVOTE */, false, 1);
67
+ packer.AddString(Type);
68
+ packer.AddString(String(Value));
69
+ packer.AddString(Reason);
70
+ this.send(packer);
71
+ }
72
+ /** Call a vote for an server option (for example ddnet maps) */
73
+ CallVoteOption(Value, Reason) {
74
+ this.CallVote("option", Value, Reason);
75
+ }
76
+ /** Call a vote to kick a player. Requires the player id */
77
+ CallVoteKick(PlayerID, Reason) {
78
+ this.CallVote("kick", PlayerID, Reason);
79
+ }
80
+ /** Call a vote to set a player in spectator mode. Requires the player id */
81
+ CallVoteSpectate(PlayerID, Reason) {
82
+ this.CallVote("spectate", PlayerID, Reason);
83
+ }
84
+ /** probably some verification of using ddnet client. */
85
+ IsDDNetLegacy() {
86
+ var packer = new MsgPacker_1.MsgPacker(26 /* NETMSG.Game.CL_ISDDNETLEGACY */, false, 1);
87
+ this.send(packer);
88
+ }
89
+ /** returns the ping in ms (as a promise) */
90
+ Ping() {
91
+ return new Promise((resolve, reject) => {
92
+ var packer = new MsgPacker_1.MsgPacker(22, true, 0);
93
+ let startTime = new Date().getTime();
94
+ this.send(packer);
95
+ let callback = (_time) => {
96
+ resolve(_time - startTime);
97
+ this._ping_resolve = () => { };
98
+ };
99
+ this._ping_resolve = callback;
100
+ });
101
+ }
102
+ }
103
+ exports.Game = Game;
@@ -1,9 +1,8 @@
1
1
 
2
2
  import { MsgPacker } from "../MsgPacker";
3
- import { PlayerInput, PlayerInfo, Projectile, Laser, Pickup, Flag, GameInfo, GameData, CharacterCore, Character, ClientInfo, SpectatorInfo, Common, Explosion, Spawn, HammerHit, Death, SoundGlobal, SoundWorld, DamageInd } from "../snapshots";
4
-
3
+ import { SnapshotItemTypes } from "../enums_types/types";
5
4
  import { Client } from "../client";
6
- enum NETMSGTYPE { EX, SV_MOTD, SV_BROADCAST, SV_CHAT, SV_KILLMSG, SV_SOUNDGLOBAL, SV_TUNEPARAMS, SV_EXTRAPROJECTILE, SV_READYTOENTER, SV_WEAPONPICKUP, SV_EMOTICON, SV_VOTECLEAROPTIONS, SV_VOTEOPTIONLISTADD, SV_VOTEOPTIONADD, SV_VOTEOPTIONREMOVE, SV_VOTESET, SV_VOTESTATUS, CL_SAY, CL_SETTEAM, CL_SETSPECTATORMODE, CL_STARTINFO, CL_CHANGEINFO, CL_KILL, CL_EMOTICON, CL_VOTE, CL_CALLVOTE, CL_ISDDNETLEGACY, SV_DDRACETIMELEGACY, SV_RECORDLEGACY, UNUSED, SV_TEAMSSTATELEGACY, CL_SHOWOTHERSLEGACY, NUM };
5
+ import { NETMSG } from "../enums_types/protocol";
7
6
 
8
7
  export class Game {
9
8
  // SendMsgEx: (Msgs: MsgPacker[] | MsgPacker) => void;
@@ -24,7 +23,7 @@ export class Game {
24
23
  }
25
24
 
26
25
  Say(message: string, team = false) {
27
- var packer = new MsgPacker(NETMSGTYPE.CL_SAY, false, 1);
26
+ var packer = new MsgPacker(NETMSG.Game.CL_SAY, false, 1);
28
27
  packer.AddInt(team ? 1 : 0); // team
29
28
  packer.AddString(message);
30
29
  this.send(packer);
@@ -33,7 +32,7 @@ export class Game {
33
32
 
34
33
  /** Set the team of an bot. (-1 spectator team, 0 team red/normal team, 1 team blue) */
35
34
  SetTeam(team: number) {
36
- var packer = new MsgPacker(NETMSGTYPE.CL_SETTEAM, false, 1);
35
+ var packer = new MsgPacker(NETMSG.Game.CL_SETTEAM, false, 1);
37
36
  packer.AddInt(team);
38
37
  this.send(packer);
39
38
  }
@@ -41,7 +40,7 @@ export class Game {
41
40
 
42
41
  /** Spectate an player, taking their id as parameter. pretty useless */
43
42
  SpectatorMode(SpectatorID: number) {
44
- var packer = new MsgPacker(NETMSGTYPE.CL_SETSPECTATORMODE, false, 1);
43
+ var packer = new MsgPacker(NETMSG.Game.CL_SETSPECTATORMODE, false, 1);
45
44
  packer.AddInt(SpectatorID);
46
45
  this.send(packer);
47
46
  }
@@ -49,8 +48,8 @@ export class Game {
49
48
 
50
49
 
51
50
  /** Change the player info */
52
- ChangePlayerInfo(playerInfo: ClientInfo) {
53
- var packer = new MsgPacker(NETMSGTYPE.CL_CHANGEINFO, false, 1);
51
+ ChangePlayerInfo(playerInfo: SnapshotItemTypes.ClientInfo) {
52
+ var packer = new MsgPacker(NETMSG.Game.CL_CHANGEINFO, false, 1);
54
53
  packer.AddString(playerInfo.name);
55
54
  packer.AddString(playerInfo.clan);
56
55
  packer.AddInt(playerInfo.country);
@@ -64,14 +63,14 @@ export class Game {
64
63
 
65
64
  /** Kill */
66
65
  Kill() {
67
- var packer = new MsgPacker(NETMSGTYPE.CL_KILL, false, 1);
66
+ var packer = new MsgPacker(NETMSG.Game.CL_KILL, false, 1);
68
67
  this.send(packer);
69
68
  }
70
69
 
71
70
 
72
71
  /** Send emote */
73
72
  Emote(emote: number) {
74
- var packer = new MsgPacker(NETMSGTYPE.CL_EMOTICON, false, 1);
73
+ var packer = new MsgPacker(NETMSG.Game.CL_EMOTICON, false, 1);
75
74
  packer.AddInt(emote);
76
75
  this.send(packer);
77
76
  }
@@ -79,13 +78,13 @@ export class Game {
79
78
 
80
79
  /** Vote for an already running vote (true = f3 / false = f4) */
81
80
  Vote(vote: boolean) {
82
- var packer = new MsgPacker(NETMSGTYPE.CL_VOTE, false, 1);
81
+ var packer = new MsgPacker(NETMSG.Game.CL_VOTE, false, 1);
83
82
  packer.AddInt(vote ? 1 : -1);
84
83
  this.send(packer);
85
84
  }
86
85
 
87
86
  private CallVote(Type: "option" | "kick" | "spectate", Value: string|number, Reason: string) {
88
- var packer = new MsgPacker(NETMSGTYPE.CL_CALLVOTE, false, 1);
87
+ var packer = new MsgPacker(NETMSG.Game.CL_CALLVOTE, false, 1);
89
88
  packer.AddString(Type);
90
89
  packer.AddString(String(Value));
91
90
  packer.AddString(Reason);
@@ -111,7 +110,7 @@ export class Game {
111
110
 
112
111
  /** probably some verification of using ddnet client. */
113
112
  IsDDNetLegacy() {
114
- var packer = new MsgPacker(NETMSGTYPE.CL_ISDDNETLEGACY, false, 1);
113
+ var packer = new MsgPacker(NETMSG.Game.CL_ISDDNETLEGACY, false, 1);
115
114
  this.send(packer);
116
115
  }
117
116
 
@@ -1,82 +1,74 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- ;
4
- var Movement = /** @class */ (function () {
5
- function Movement() {
6
- 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 };
7
- }
8
- Movement.prototype.RunLeft = function () {
9
- this.input.m_Direction = -1;
10
- };
11
- Movement.prototype.RunRight = function () {
12
- this.input.m_Direction = 1;
13
- };
14
- Movement.prototype.RunStop = function () {
15
- this.input.m_Direction = 0;
16
- };
17
- Movement.prototype.Jump = function (state) {
18
- if (state === void 0) { state = true; }
19
- this.input.m_Jump = state ? 1 : 0;
20
- };
21
- Movement.prototype.Fire = function () {
22
- this.input.m_Fire++;
23
- };
24
- Movement.prototype.Hook = function (state) {
25
- if (state === void 0) { state = true; }
26
- this.input.m_Hook = state ? 1 : 0;
27
- };
28
- Movement.prototype.NextWeapon = function () {
29
- this.input.m_NextWeapon = 1;
30
- this.WantedWeapon(0);
31
- };
32
- Movement.prototype.PrevWeapon = function () {
33
- this.input.m_PrevWeapon = 1;
34
- this.WantedWeapon(0);
35
- };
36
- Movement.prototype.WantedWeapon = function (weapon) {
37
- this.input.m_WantedWeapon = weapon;
38
- };
39
- Movement.prototype.SetAim = function (x, y) {
40
- this.input.m_TargetX = x;
41
- this.input.m_TargetY = y;
42
- };
43
- Movement.prototype.Flag = function (toggle, num) {
44
- if (toggle) {
45
- this.input.m_PlayerFlags |= num;
46
- }
47
- else {
48
- this.input.m_PlayerFlags &= ~num;
49
- }
50
- };
51
- Movement.prototype.FlagPlaying = function (toggle) {
52
- if (toggle === void 0) { toggle = true; }
53
- this.Flag(toggle, 1);
54
- };
55
- Movement.prototype.FlagInMenu = function (toggle) {
56
- if (toggle === void 0) { toggle = true; }
57
- this.Flag(toggle, 2);
58
- };
59
- Movement.prototype.FlagChatting = function (toggle) {
60
- if (toggle === void 0) { toggle = true; }
61
- this.Flag(toggle, 4);
62
- };
63
- Movement.prototype.FlagScoreboard = function (toggle) {
64
- if (toggle === void 0) { toggle = true; }
65
- this.Flag(toggle, 8);
66
- };
67
- Movement.prototype.FlagHookline = function (toggle) {
68
- if (toggle === void 0) { toggle = true; }
69
- this.Flag(toggle, 16);
70
- };
71
- Movement.prototype.Reset = function () {
72
- this.input.m_Direction = 0;
73
- this.input.m_Jump = 0;
74
- this.input.m_Fire = 0;
75
- this.input.m_Hook = 0;
76
- this.input.m_PlayerFlags = 0;
77
- this.input.m_NextWeapon = 0;
78
- this.input.m_PrevWeapon = 0;
79
- };
80
- return Movement;
81
- }());
82
- exports.default = Movement;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ;
4
+ class Movement {
5
+ constructor() {
6
+ 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 };
7
+ }
8
+ RunLeft() {
9
+ this.input.m_Direction = -1;
10
+ }
11
+ RunRight() {
12
+ this.input.m_Direction = 1;
13
+ }
14
+ RunStop() {
15
+ this.input.m_Direction = 0;
16
+ }
17
+ Jump(state = true) {
18
+ this.input.m_Jump = state ? 1 : 0;
19
+ }
20
+ Fire() {
21
+ this.input.m_Fire++;
22
+ }
23
+ Hook(state = true) {
24
+ this.input.m_Hook = state ? 1 : 0;
25
+ }
26
+ NextWeapon() {
27
+ this.input.m_NextWeapon = 1;
28
+ this.WantedWeapon(0);
29
+ }
30
+ PrevWeapon() {
31
+ this.input.m_PrevWeapon = 1;
32
+ this.WantedWeapon(0);
33
+ }
34
+ WantedWeapon(weapon) {
35
+ this.input.m_WantedWeapon = weapon;
36
+ }
37
+ SetAim(x, y) {
38
+ this.input.m_TargetX = x;
39
+ this.input.m_TargetY = y;
40
+ }
41
+ Flag(toggle, num) {
42
+ if (toggle) {
43
+ this.input.m_PlayerFlags |= num;
44
+ }
45
+ else {
46
+ this.input.m_PlayerFlags &= ~num;
47
+ }
48
+ }
49
+ FlagPlaying(toggle = true) {
50
+ this.Flag(toggle, 1);
51
+ }
52
+ FlagInMenu(toggle = true) {
53
+ this.Flag(toggle, 2);
54
+ }
55
+ FlagChatting(toggle = true) {
56
+ this.Flag(toggle, 4);
57
+ }
58
+ FlagScoreboard(toggle = true) {
59
+ this.Flag(toggle, 8);
60
+ }
61
+ FlagHookline(toggle = true) {
62
+ this.Flag(toggle, 16);
63
+ }
64
+ Reset() {
65
+ this.input.m_Direction = 0;
66
+ this.input.m_Jump = 0;
67
+ this.input.m_Fire = 0;
68
+ this.input.m_Hook = 0;
69
+ this.input.m_PlayerFlags = 0;
70
+ this.input.m_NextWeapon = 0;
71
+ this.input.m_PrevWeapon = 0;
72
+ }
73
+ }
74
+ exports.default = Movement;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Rcon = void 0;
4
+ const stream_1 = require("stream");
5
+ const MsgPacker_1 = require("../MsgPacker");
6
+ const MsgUnpacker_1 = require("../MsgUnpacker");
7
+ class Rcon extends stream_1.EventEmitter {
8
+ on(event, listener) {
9
+ return super.on(event, listener);
10
+ }
11
+ emit(event, ...args) {
12
+ return super.emit(event, ...args);
13
+ }
14
+ constructor(_client) {
15
+ super();
16
+ this.CommandList = [];
17
+ this._client = _client;
18
+ }
19
+ // SendMsgEx: (Msgs: MsgPacker[] | MsgPacker) => void;
20
+ send(packer) {
21
+ var _a;
22
+ if (!((_a = this._client.options) === null || _a === void 0 ? void 0 : _a.lightweight))
23
+ this._client.QueueChunkEx(packer);
24
+ else
25
+ this._client.SendMsgEx(packer);
26
+ }
27
+ /** Rcon auth, set the `username` to empty string for authentication w/o username **/
28
+ auth(usernameOrPassword, password) {
29
+ const rconAuthMsg = new MsgPacker_1.MsgPacker(18 /* NETMSG.System.NETMSG_RCON_AUTH */, true, 1);
30
+ if (password == undefined) {
31
+ rconAuthMsg.AddString("");
32
+ rconAuthMsg.AddString(usernameOrPassword);
33
+ }
34
+ else {
35
+ rconAuthMsg.AddString(usernameOrPassword);
36
+ rconAuthMsg.AddString(password);
37
+ }
38
+ rconAuthMsg.AddInt(1);
39
+ this.send(rconAuthMsg);
40
+ }
41
+ /** Send rcon command **/
42
+ rcon(cmds) {
43
+ let _cmds;
44
+ if (cmds instanceof Array)
45
+ _cmds = cmds;
46
+ else
47
+ _cmds = [cmds];
48
+ const msgs = [];
49
+ _cmds.forEach((cmd) => {
50
+ const rconCmdMsg = new MsgPacker_1.MsgPacker(17 /* NETMSG.System.NETMSG_RCON_CMD */, true, 1);
51
+ rconCmdMsg.AddString(cmd);
52
+ msgs.push(rconCmdMsg);
53
+ });
54
+ this.send(msgs);
55
+ }
56
+ /** This method is called by the Client to handle the chunks. It should not be called directly. */
57
+ _checkChunks(chunk) {
58
+ if (chunk.msgid == 11 /* NETMSG.System.NETMSG_RCON_LINE */) {
59
+ const unpacker = new MsgUnpacker_1.MsgUnpacker(chunk.raw);
60
+ const msg = unpacker.unpackString();
61
+ this.emit('rcon_line', msg);
62
+ }
63
+ else if (chunk.msgid == 10 /* NETMSG.System.NETMSG_RCON_AUTH_STATUS */) {
64
+ const unpacker = new MsgUnpacker_1.MsgUnpacker(chunk.raw);
65
+ const AuthLevel = unpacker.unpackInt();
66
+ const ReceiveCommands = unpacker.unpackInt();
67
+ this.emit('rcon_auth_status', { AuthLevel, ReceiveCommands });
68
+ }
69
+ else if (chunk.msgid == 25 /* NETMSG.System.NETMSG_RCON_CMD_ADD */) {
70
+ const unpacker = new MsgUnpacker_1.MsgUnpacker(chunk.raw);
71
+ const command = unpacker.unpackString();
72
+ const description = unpacker.unpackString();
73
+ const params = unpacker.unpackString();
74
+ this.CommandList.push({ command, description, params });
75
+ this.emit('rcon_cmd_add', { command, description, params });
76
+ }
77
+ else if (chunk.msgid == 26 /* NETMSG.System.NETMSG_RCON_CMD_REM */) {
78
+ const unpacker = new MsgUnpacker_1.MsgUnpacker(chunk.raw);
79
+ const command = unpacker.unpackString();
80
+ this.emit('rcon_cmd_rem', { command });
81
+ let index = this.CommandList.findIndex(a => a.command == command);
82
+ if (index - 1 >= 0)
83
+ this.CommandList.splice(index, 1);
84
+ }
85
+ else {
86
+ return false;
87
+ }
88
+ return true;
89
+ }
90
+ }
91
+ exports.Rcon = Rcon;