@modlock/modlock 0.1.81 → 0.1.82
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.d.ts +35 -22
- package/index.js +55 -21
- package/package.json +6 -6
- package/players.d.ts +6 -4
package/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference path="./globals.d.ts" />
|
|
2
|
-
import { type DamageEvent, type ChatEvent, type
|
|
3
|
-
import { Cast } from './cast.js';
|
|
2
|
+
import { type DamageEvent, type ChatEvent, type DamagedEvent, type DamageResult, type FrameEvent, type ImpactEvent, type LandedEvent, type LaunchEvent, type Pawn, Player, type PlayerJoinedEvent, type PlayerLeftEvent } from './host.gen.js';
|
|
4
3
|
export * as vector from './vector.js';
|
|
5
4
|
export { Buttons, Layers } from './bits.js';
|
|
6
5
|
export { after, every, sequence, type Timer } from './timer.js';
|
|
@@ -86,35 +85,49 @@ export declare function onPlayerLeave(handler: (left: PlayerLeftEvent) => void):
|
|
|
86
85
|
* handler is registered.
|
|
87
86
|
*/
|
|
88
87
|
export declare function onSpawn(handler: (player: Player, pawn: Pawn) => void): void;
|
|
89
|
-
/** Seating is
|
|
88
|
+
/** Seating is the hero and team seat gives one player. */
|
|
90
89
|
export interface Seating {
|
|
91
90
|
/**
|
|
92
|
-
* hero is
|
|
93
|
-
*
|
|
94
|
-
*
|
|
91
|
+
* hero is the hero's name as players know it or as the game does, such as
|
|
92
|
+
* 'haze' or 'hero_haze', its id, or 'any' for the hero the player has or
|
|
93
|
+
* else a random one. 'any' is the default.
|
|
95
94
|
*/
|
|
96
95
|
readonly hero?: string | number;
|
|
97
96
|
/**
|
|
98
|
-
* team is the team, 2 or 3
|
|
99
|
-
*
|
|
100
|
-
* side with fewer heroes.
|
|
97
|
+
* team is the team, 2 or 3. Without one the player keeps their hero's team
|
|
98
|
+
* or joins the side with fewer heroes.
|
|
101
99
|
*/
|
|
102
|
-
readonly team?: number
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
100
|
+
readonly team?: number;
|
|
101
|
+
}
|
|
102
|
+
declare module './host.gen.js' {
|
|
103
|
+
interface Player {
|
|
104
|
+
/**
|
|
105
|
+
* connection returns the player's connection: their name, Steam ID,
|
|
106
|
+
* whether they are a bot and whether they finished joining. It returns
|
|
107
|
+
* undefined when nobody holds the slot.
|
|
108
|
+
*/
|
|
109
|
+
connection(): Connection | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* seat gives the player a hero on a team, skipping the game's team and
|
|
112
|
+
* hero screens. Call it as the player joins:
|
|
113
|
+
*
|
|
114
|
+
* onPlayerJoin(({ connection }) => connection.player.seat({ hero: 'haze', team: 2 }))
|
|
115
|
+
*
|
|
116
|
+
* The hero appears on a later frame, and onSpawn hears of it. The library
|
|
117
|
+
* asks the game again until the player has the seat, and once more after
|
|
118
|
+
* the player changes hero, so a call before the game is ready is not
|
|
119
|
+
* lost. Seating the player again replaces the seat, and it ends when they
|
|
120
|
+
* leave. It returns false when nobody holds the player's slot.
|
|
121
|
+
*/
|
|
122
|
+
seat(seating?: Seating): boolean;
|
|
123
|
+
}
|
|
108
124
|
}
|
|
109
125
|
/**
|
|
110
|
-
*
|
|
111
|
-
* game's
|
|
112
|
-
* game
|
|
113
|
-
* player again after a hero change. It returns the Cast that does the
|
|
114
|
-
* seating, whose members are the players' connections, and runs it each
|
|
115
|
-
* frame itself.
|
|
126
|
+
* setRespawnDelay brings every fallen hero back after seconds, in place of
|
|
127
|
+
* the game's own respawn time. Without seconds it leaves fallen heroes to the
|
|
128
|
+
* game again.
|
|
116
129
|
*/
|
|
117
|
-
export declare function
|
|
130
|
+
export declare function setRespawnDelay(seconds?: number): void;
|
|
118
131
|
/** onFrame calls handler once per server frame. */
|
|
119
132
|
export declare function onFrame(handler: (frame: FrameEvent) => void): void;
|
|
120
133
|
/**
|
package/index.js
CHANGED
|
@@ -14761,8 +14761,12 @@ function watchPlayers(watcher) {
|
|
|
14761
14761
|
if (roster !== void 0) watcher(roster);
|
|
14762
14762
|
}
|
|
14763
14763
|
function connection(player) {
|
|
14764
|
+
const held = roster ?? players();
|
|
14765
|
+
if (typeof player === "bigint") {
|
|
14766
|
+
return held.find((c) => c.steamId === player);
|
|
14767
|
+
}
|
|
14764
14768
|
const slot = typeof player === "number" ? player : player.slot;
|
|
14765
|
-
return
|
|
14769
|
+
return held.find((c) => c.player.slot === slot);
|
|
14766
14770
|
}
|
|
14767
14771
|
function players() {
|
|
14768
14772
|
if (roster !== void 0) return roster.slice();
|
|
@@ -17564,11 +17568,11 @@ function fewestPlayed(standings) {
|
|
|
17564
17568
|
return least === Infinity ? 0 : least;
|
|
17565
17569
|
}
|
|
17566
17570
|
function nextMatch(line2, size, standing) {
|
|
17567
|
-
const
|
|
17568
|
-
if (size < 1 ||
|
|
17571
|
+
const seated2 = [...line2].sort((a, b) => standing(a).played - standing(b).played).slice(0, 2 * size);
|
|
17572
|
+
if (size < 1 || seated2.length < 2 * size) {
|
|
17569
17573
|
return void 0;
|
|
17570
17574
|
}
|
|
17571
|
-
const ranked =
|
|
17575
|
+
const ranked = seated2.sort((a, b) => standing(b).rating - standing(a).rating);
|
|
17572
17576
|
const sides = [[], []];
|
|
17573
17577
|
for (const [i, player] of ranked.entries()) {
|
|
17574
17578
|
const round = Math.floor(i / 2);
|
|
@@ -19032,27 +19036,57 @@ function onSpawn(handler) {
|
|
|
19032
19036
|
spawns.push(handler);
|
|
19033
19037
|
}
|
|
19034
19038
|
var spawned = /* @__PURE__ */ new Map();
|
|
19035
|
-
|
|
19036
|
-
|
|
19037
|
-
|
|
19038
|
-
|
|
19039
|
+
var seated = /* @__PURE__ */ new Map();
|
|
19040
|
+
var respawnDelay;
|
|
19041
|
+
var unseated = {};
|
|
19042
|
+
var seating;
|
|
19043
|
+
function startSeating() {
|
|
19044
|
+
if (seating) {
|
|
19045
|
+
return;
|
|
19046
|
+
}
|
|
19039
19047
|
const cast = new Cast({
|
|
19040
|
-
join(connection2)
|
|
19041
|
-
|
|
19042
|
-
|
|
19043
|
-
|
|
19044
|
-
|
|
19045
|
-
...respawn === void 0 ? {} : { respawn }
|
|
19046
|
-
});
|
|
19047
|
-
return connection2;
|
|
19048
|
+
join: (connection2) => connection2,
|
|
19049
|
+
leave(member) {
|
|
19050
|
+
if (seated.get(member.player.slot)?.generation === member.generation) {
|
|
19051
|
+
seated.delete(member.player.slot);
|
|
19052
|
+
}
|
|
19048
19053
|
},
|
|
19049
|
-
|
|
19050
|
-
|
|
19054
|
+
want(member) {
|
|
19055
|
+
const held = seated.get(member.player.slot);
|
|
19056
|
+
return held?.generation === member.generation ? held.want : unseated;
|
|
19051
19057
|
},
|
|
19052
|
-
|
|
19058
|
+
bots: "join"
|
|
19053
19059
|
});
|
|
19060
|
+
seating = cast;
|
|
19054
19061
|
onFrame(({ timeSeconds }) => cast.frame(timeSeconds));
|
|
19055
|
-
|
|
19062
|
+
}
|
|
19063
|
+
function wantOf(seating2) {
|
|
19064
|
+
return {
|
|
19065
|
+
hero: seating2.hero ?? "any",
|
|
19066
|
+
...seating2.team === void 0 ? {} : { team: seating2.team },
|
|
19067
|
+
...respawnDelay === void 0 ? {} : { respawn: respawnDelay }
|
|
19068
|
+
};
|
|
19069
|
+
}
|
|
19070
|
+
Player.prototype.connection = function() {
|
|
19071
|
+
return connection(this);
|
|
19072
|
+
};
|
|
19073
|
+
Player.prototype.seat = function(seating2 = {}) {
|
|
19074
|
+
const held = connection(this);
|
|
19075
|
+
if (!held) {
|
|
19076
|
+
return false;
|
|
19077
|
+
}
|
|
19078
|
+
seated.set(this.slot, { generation: held.generation, want: wantOf(seating2) });
|
|
19079
|
+
startSeating();
|
|
19080
|
+
return true;
|
|
19081
|
+
};
|
|
19082
|
+
function setRespawnDelay(seconds) {
|
|
19083
|
+
respawnDelay = seconds;
|
|
19084
|
+
unseated = seconds === void 0 ? {} : { respawn: seconds };
|
|
19085
|
+
for (const held of seated.values()) {
|
|
19086
|
+
const { respawn: _, ...want } = held.want;
|
|
19087
|
+
held.want = { ...want, ...unseated };
|
|
19088
|
+
}
|
|
19089
|
+
startSeating();
|
|
19056
19090
|
}
|
|
19057
19091
|
function watchSpawns() {
|
|
19058
19092
|
const present = /* @__PURE__ */ new Map();
|
|
@@ -19410,13 +19444,13 @@ export {
|
|
|
19410
19444
|
rosterKey,
|
|
19411
19445
|
rosterRows,
|
|
19412
19446
|
route,
|
|
19413
|
-
seatPlayers,
|
|
19414
19447
|
sequence,
|
|
19415
19448
|
serve,
|
|
19416
19449
|
serveMod,
|
|
19417
19450
|
serverCommand,
|
|
19418
19451
|
setFreeForAll,
|
|
19419
19452
|
setOrbitCamera,
|
|
19453
|
+
setRespawnDelay,
|
|
19420
19454
|
setTeamSeating,
|
|
19421
19455
|
settingNumber,
|
|
19422
19456
|
settingOn,
|
package/package.json
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"name": "@modlock/modlock",
|
|
9
9
|
"optionalDependencies": {
|
|
10
|
-
"@modlock/darwin-arm64": "0.1.
|
|
11
|
-
"@modlock/darwin-x64": "0.1.
|
|
12
|
-
"@modlock/linux-arm64": "0.1.
|
|
13
|
-
"@modlock/linux-x64": "0.1.
|
|
14
|
-
"@modlock/win32-x64": "0.1.
|
|
10
|
+
"@modlock/darwin-arm64": "0.1.82",
|
|
11
|
+
"@modlock/darwin-x64": "0.1.82",
|
|
12
|
+
"@modlock/linux-arm64": "0.1.82",
|
|
13
|
+
"@modlock/linux-x64": "0.1.82",
|
|
14
|
+
"@modlock/win32-x64": "0.1.82"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"type": "module",
|
|
22
22
|
"types": "index.d.ts",
|
|
23
|
-
"version": "0.1.
|
|
23
|
+
"version": "0.1.82"
|
|
24
24
|
}
|
package/players.d.ts
CHANGED
|
@@ -7,11 +7,13 @@ export declare function keepPlayers(players: Connection[]): void;
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function watchPlayers(watcher: (players: readonly Connection[]) => void): void;
|
|
9
9
|
/**
|
|
10
|
-
* connection returns the connection of one player, given the player
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* connection returns the connection of one player, given the player, their
|
|
11
|
+
* slot as a number or their Steam ID as a bigint: their name, Steam ID,
|
|
12
|
+
* whether they are a bot and whether they finished joining. It returns
|
|
13
|
+
* undefined when nobody holds the slot or the account is not connected. Its
|
|
14
|
+
* player field is the Player to call.
|
|
13
15
|
*/
|
|
14
|
-
export declare function connection(player: Player | number): Connection | undefined;
|
|
16
|
+
export declare function connection(player: Player | number | bigint): Connection | undefined;
|
|
15
17
|
/**
|
|
16
18
|
* players lists the occupied player slots in slot order. It answers from the
|
|
17
19
|
* roster the host last reported, and asks the host until a report arrives.
|