@modlock/modlock 0.1.81 → 0.1.83
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/host.gen.d.ts +116 -0
- package/index.d.ts +54 -22
- package/index.js +366 -26
- package/package.json +6 -6
- package/players.d.ts +6 -4
package/host.gen.d.ts
CHANGED
|
@@ -101,6 +101,18 @@ export interface AbilityOptions {
|
|
|
101
101
|
* are not removed; set them with charges.
|
|
102
102
|
*/
|
|
103
103
|
maxCharges?: number;
|
|
104
|
+
/**
|
|
105
|
+
* cooldown makes every cooldown the ability starts from now on last this
|
|
106
|
+
* many seconds, in place of the game's own length. An ability that holds
|
|
107
|
+
* charges waits this long between casts. 0 leaves the ability always
|
|
108
|
+
* ready, and a negative value returns it to the game's own. The game asks
|
|
109
|
+
* for the length as it starts each cooldown and applies the hero's cooldown
|
|
110
|
+
* reduction to it, so it holds for every later cast and the hero's screen
|
|
111
|
+
* shows it; a cooldown already running keeps its end, which cooldown_end
|
|
112
|
+
* moves. It holds for this ability of this hero until the mod stops, so
|
|
113
|
+
* set it again after a hero change or a replaced ability.
|
|
114
|
+
*/
|
|
115
|
+
cooldown?: number;
|
|
104
116
|
}
|
|
105
117
|
/** Modifier is one modifier an entity holds, as the game keeps it. */
|
|
106
118
|
export interface Modifier {
|
|
@@ -159,6 +171,31 @@ export interface BuildItem {
|
|
|
159
171
|
/** annotation is the author's note on the item. */
|
|
160
172
|
readonly annotation: string;
|
|
161
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* AbilityCastEvent reports one ability the game executed: the moment the
|
|
176
|
+
* cast takes effect, after any cast time, for a hero's abilities and the
|
|
177
|
+
* items a player activates.
|
|
178
|
+
*/
|
|
179
|
+
export interface AbilityCastEvent {
|
|
180
|
+
/** caster is the entity that cast it, a hero for a player's cast. */
|
|
181
|
+
readonly caster: number;
|
|
182
|
+
/** player is the slot of the player whose hero cast it, or -1. */
|
|
183
|
+
readonly player: Player;
|
|
184
|
+
/** ability is the ability's entity handle, as ability.entity reports it. */
|
|
185
|
+
readonly ability: number;
|
|
186
|
+
/**
|
|
187
|
+
* name is the ability's name, such as citadel_ability_hornet_snipe, when
|
|
188
|
+
* a player's hero cast it.
|
|
189
|
+
*/
|
|
190
|
+
readonly name: string;
|
|
191
|
+
/**
|
|
192
|
+
* slot is the ability's place on the hero, as ability.slot reports it, or
|
|
193
|
+
* -1 when the caster is not a player's hero.
|
|
194
|
+
*/
|
|
195
|
+
readonly slot: number;
|
|
196
|
+
/** target is the entity the cast was aimed at, or zero without one. */
|
|
197
|
+
readonly target: number;
|
|
198
|
+
}
|
|
162
199
|
/**
|
|
163
200
|
* DamageEvent is one hit before the game applies it. Handles are zero when
|
|
164
201
|
* the game names no such entity.
|
|
@@ -213,6 +250,27 @@ export interface DamagedEvent {
|
|
|
213
250
|
*/
|
|
214
251
|
readonly dealt: number;
|
|
215
252
|
}
|
|
253
|
+
/** KillEvent reports one hero or unit that a hit killed. */
|
|
254
|
+
export interface KillEvent {
|
|
255
|
+
/** victim is the entity that died. */
|
|
256
|
+
readonly victim: number;
|
|
257
|
+
/**
|
|
258
|
+
* victimPlayer is the slot of the player whose hero died, or -1 for a unit.
|
|
259
|
+
*/
|
|
260
|
+
readonly victimPlayer: Player;
|
|
261
|
+
/**
|
|
262
|
+
* attacker is the entity credited with the killing hit, or zero for a
|
|
263
|
+
* hazard.
|
|
264
|
+
*/
|
|
265
|
+
readonly attacker: number;
|
|
266
|
+
/**
|
|
267
|
+
* attackerPlayer is the slot of the player whose hero is the attacker, or
|
|
268
|
+
* -1. It is the victim's own slot when a hero killed itself.
|
|
269
|
+
*/
|
|
270
|
+
readonly attackerPlayer: Player;
|
|
271
|
+
/** ability is the ability that dealt the killing hit, or zero. */
|
|
272
|
+
readonly ability: number;
|
|
273
|
+
}
|
|
216
274
|
/** LaunchEvent is a watched projectile's first frame. */
|
|
217
275
|
export interface LaunchEvent {
|
|
218
276
|
/** entity is the projectile's entity handle. */
|
|
@@ -338,6 +396,32 @@ export interface TraceHit {
|
|
|
338
396
|
/** entity is the entity hit, or zero for the world. */
|
|
339
397
|
readonly entity: number;
|
|
340
398
|
}
|
|
399
|
+
/**
|
|
400
|
+
* ModifierFiredEvent reports one of the game's modifier events the mod
|
|
401
|
+
* watches, with the entities the game fired it with. Which of them an event
|
|
402
|
+
* fills depends on the event.
|
|
403
|
+
*/
|
|
404
|
+
export interface ModifierFiredEvent {
|
|
405
|
+
/** name is the event as the mod named it in StartResult.modifier_events. */
|
|
406
|
+
readonly name: string;
|
|
407
|
+
/**
|
|
408
|
+
* caster is the entity the event is about, such as the hero that parried
|
|
409
|
+
* or respawned, or zero.
|
|
410
|
+
*/
|
|
411
|
+
readonly caster: number;
|
|
412
|
+
/** player is the slot of the player whose hero the caster is, or -1. */
|
|
413
|
+
readonly player: Player;
|
|
414
|
+
/**
|
|
415
|
+
* target is the other entity of the event, such as the victim of a kill,
|
|
416
|
+
* or zero.
|
|
417
|
+
*/
|
|
418
|
+
readonly target: number;
|
|
419
|
+
/**
|
|
420
|
+
* ability is the ability or other entity the event names as its source, or
|
|
421
|
+
* zero.
|
|
422
|
+
*/
|
|
423
|
+
readonly ability: number;
|
|
424
|
+
}
|
|
341
425
|
/**
|
|
342
426
|
* SoundOptions shape one sound; the zero value plays it to every player as
|
|
343
427
|
* the game made it.
|
|
@@ -1300,6 +1384,23 @@ export interface StartResult {
|
|
|
1300
1384
|
* and a PlayerLeft event as each leaves.
|
|
1301
1385
|
*/
|
|
1302
1386
|
joins: boolean;
|
|
1387
|
+
/**
|
|
1388
|
+
* casts asks for an AbilityCast event after each ability the game
|
|
1389
|
+
* executes.
|
|
1390
|
+
*/
|
|
1391
|
+
casts: boolean;
|
|
1392
|
+
/**
|
|
1393
|
+
* modifierEvents asks for a ModifierFired event for each of the game's
|
|
1394
|
+
* modifier events with these EModifierEvent names, such as
|
|
1395
|
+
* MODIFIER_EVENT_ABILITY_CAST_STARTED or, without the prefix,
|
|
1396
|
+
* ABILITY_CAST_STARTED. A name the running game lacks is logged and never
|
|
1397
|
+
* fires.
|
|
1398
|
+
*/
|
|
1399
|
+
modifierEvents?: readonly string[];
|
|
1400
|
+
/**
|
|
1401
|
+
* kills asks for a Killed event after each hit that kills a hero or unit.
|
|
1402
|
+
*/
|
|
1403
|
+
kills: boolean;
|
|
1303
1404
|
}
|
|
1304
1405
|
/** FrameEvent identifies one server frame. */
|
|
1305
1406
|
export interface FrameEvent {
|
|
@@ -2214,6 +2315,21 @@ export interface ModHandlers {
|
|
|
2214
2315
|
* damage reports. Hits arrive before the next frame.
|
|
2215
2316
|
*/
|
|
2216
2317
|
damaged(event: DamagedEvent): void;
|
|
2318
|
+
/**
|
|
2319
|
+
* killed reports one hero or unit a hit killed, while the mod asked for
|
|
2320
|
+
* kills, after the hit's Damaged event and before the next frame.
|
|
2321
|
+
*/
|
|
2322
|
+
killed(event: KillEvent): void;
|
|
2323
|
+
/**
|
|
2324
|
+
* abilityCast reports one ability the game executed, while the mod asked
|
|
2325
|
+
* for casts, before the next frame.
|
|
2326
|
+
*/
|
|
2327
|
+
abilityCast(event: AbilityCastEvent): void;
|
|
2328
|
+
/**
|
|
2329
|
+
* modifierFired reports one modifier event the mod watches, before the
|
|
2330
|
+
* next frame.
|
|
2331
|
+
*/
|
|
2332
|
+
modifierFired(event: ModifierFiredEvent): void;
|
|
2217
2333
|
/**
|
|
2218
2334
|
* input reports one player's presses of watched buttons, before the next
|
|
2219
2335
|
* frame. A block in place still withholds them from the hero.
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference path="./globals.d.ts" />
|
|
2
|
-
import { type
|
|
3
|
-
import { Cast } from './cast.js';
|
|
2
|
+
import { type AbilityCastEvent, type KillEvent, type DamageEvent, type ChatEvent, type DamagedEvent, type DamageResult, type FrameEvent, type ImpactEvent, type LandedEvent, type LaunchEvent, type ModifierFiredEvent, 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
|
/**
|
|
@@ -146,6 +159,25 @@ export declare function onNpcsRestored(handler: (error: string | undefined) => v
|
|
|
146
159
|
export declare function onDamage(handler: (hit: DamageEvent) => DamageResult | void): void;
|
|
147
160
|
/** onDamaged calls handler on the frame after each hit lands. */
|
|
148
161
|
export declare function onDamaged(handler: (hit: DamagedEvent) => void): void;
|
|
162
|
+
/**
|
|
163
|
+
* onKill calls handler after each hit that kills a hero or a unit, before the
|
|
164
|
+
* next frame. The kill names both entities and the player of each: a slot of
|
|
165
|
+
* -1 is a unit's, or a hazard's for the attacker.
|
|
166
|
+
*/
|
|
167
|
+
export declare function onKill(handler: (kill: KillEvent) => void): void;
|
|
168
|
+
/**
|
|
169
|
+
* onAbilityCast calls handler after each ability the game executes, before
|
|
170
|
+
* the next frame: a hero's abilities and the items a player activates, at
|
|
171
|
+
* the moment the cast takes effect.
|
|
172
|
+
*/
|
|
173
|
+
export declare function onAbilityCast(handler: (cast: AbilityCastEvent) => void): void;
|
|
174
|
+
/**
|
|
175
|
+
* onModifierEvent calls handler each time the game fires the modifier event
|
|
176
|
+
* with this EModifierEvent name, such as ABILITY_CAST_STARTED, PARRY_SUCCESS
|
|
177
|
+
* or PLAYER_RESPAWNED, before the next frame. Register before the mod starts.
|
|
178
|
+
* A name the running game lacks is logged once and never fires.
|
|
179
|
+
*/
|
|
180
|
+
export declare function onModifierEvent(name: string, handler: (event: ModifierFiredEvent) => void): void;
|
|
149
181
|
/**
|
|
150
182
|
* onLaunch calls handler with each watched projectile's first frame, before
|
|
151
183
|
* the next frame. watchProjectiles names the projectiles.
|
package/index.js
CHANGED
|
@@ -2815,7 +2815,10 @@ var StartResult = /* @__PURE__ */ createMessageType(
|
|
|
2815
2815
|
[2, "damage", 8],
|
|
2816
2816
|
[3, "damaged", 8],
|
|
2817
2817
|
[4, "chat", 8],
|
|
2818
|
-
[5, "joins", 8]
|
|
2818
|
+
[5, "joins", 8],
|
|
2819
|
+
[6, "casts", 8],
|
|
2820
|
+
[7, "modifier_events", 9, 1],
|
|
2821
|
+
[8, "kills", 8]
|
|
2819
2822
|
],
|
|
2820
2823
|
{
|
|
2821
2824
|
decode: (r, end, m) => {
|
|
@@ -2838,6 +2841,16 @@ var StartResult = /* @__PURE__ */ createMessageType(
|
|
|
2838
2841
|
case 5:
|
|
2839
2842
|
m.joins = r.bool();
|
|
2840
2843
|
break;
|
|
2844
|
+
case 6:
|
|
2845
|
+
m.casts = r.bool();
|
|
2846
|
+
break;
|
|
2847
|
+
case 7:
|
|
2848
|
+
;
|
|
2849
|
+
(m.modifierEvents ??= []).push(r.string());
|
|
2850
|
+
break;
|
|
2851
|
+
case 8:
|
|
2852
|
+
m.kills = r.bool();
|
|
2853
|
+
break;
|
|
2841
2854
|
default:
|
|
2842
2855
|
r.skip(t);
|
|
2843
2856
|
}
|
|
@@ -2865,6 +2878,18 @@ var StartResult = /* @__PURE__ */ createMessageType(
|
|
|
2865
2878
|
const v = m.joins;
|
|
2866
2879
|
if (v) w.uint32(40).bool(v);
|
|
2867
2880
|
}
|
|
2881
|
+
{
|
|
2882
|
+
const v = m.casts;
|
|
2883
|
+
if (v) w.uint32(48).bool(v);
|
|
2884
|
+
}
|
|
2885
|
+
{
|
|
2886
|
+
const a = m.modifierEvents;
|
|
2887
|
+
if (a != null) for (const e of a) w.uint32(58).string(e);
|
|
2888
|
+
}
|
|
2889
|
+
{
|
|
2890
|
+
const v = m.kills;
|
|
2891
|
+
if (v) w.uint32(64).bool(v);
|
|
2892
|
+
}
|
|
2868
2893
|
}
|
|
2869
2894
|
}
|
|
2870
2895
|
);
|
|
@@ -3532,7 +3557,8 @@ var AbilityOptions = /* @__PURE__ */ createMessageType(
|
|
|
3532
3557
|
[4, "charges", 5, 4],
|
|
3533
3558
|
[5, "cooldown_end", 2, 4],
|
|
3534
3559
|
[6, "recharge_end", 2, 4],
|
|
3535
|
-
[7, "max_charges", 5, 4]
|
|
3560
|
+
[7, "max_charges", 5, 4],
|
|
3561
|
+
[8, "cooldown", 2, 4]
|
|
3536
3562
|
],
|
|
3537
3563
|
{
|
|
3538
3564
|
decode: (r, end, m) => {
|
|
@@ -3561,6 +3587,9 @@ var AbilityOptions = /* @__PURE__ */ createMessageType(
|
|
|
3561
3587
|
case 7:
|
|
3562
3588
|
m.maxCharges = r.int32();
|
|
3563
3589
|
break;
|
|
3590
|
+
case 8:
|
|
3591
|
+
m.cooldown = r.float();
|
|
3592
|
+
break;
|
|
3564
3593
|
default:
|
|
3565
3594
|
r.skip(t);
|
|
3566
3595
|
}
|
|
@@ -3596,6 +3625,10 @@ var AbilityOptions = /* @__PURE__ */ createMessageType(
|
|
|
3596
3625
|
const v = m.maxCharges;
|
|
3597
3626
|
if (v != null) w.uint32(56).int32(v);
|
|
3598
3627
|
}
|
|
3628
|
+
{
|
|
3629
|
+
const v = m.cooldown;
|
|
3630
|
+
if (v != null) w.uint32(69).float(v);
|
|
3631
|
+
}
|
|
3599
3632
|
}
|
|
3600
3633
|
}
|
|
3601
3634
|
);
|
|
@@ -4328,6 +4361,74 @@ var GiveEntityModifierRequest = /* @__PURE__ */ createMessageType(
|
|
|
4328
4361
|
}
|
|
4329
4362
|
}
|
|
4330
4363
|
);
|
|
4364
|
+
var AbilityCastEvent = /* @__PURE__ */ createMessageType(
|
|
4365
|
+
"modlock.wasm.abilities.AbilityCastEvent",
|
|
4366
|
+
() => [
|
|
4367
|
+
[1, "caster", 13],
|
|
4368
|
+
[2, "player", 5],
|
|
4369
|
+
[3, "ability", 13],
|
|
4370
|
+
[4, "name", 9],
|
|
4371
|
+
[5, "slot", 5],
|
|
4372
|
+
[6, "target", 13]
|
|
4373
|
+
],
|
|
4374
|
+
{
|
|
4375
|
+
decode: (r, end, m) => {
|
|
4376
|
+
while (r.pos < end) {
|
|
4377
|
+
const t = r.tag();
|
|
4378
|
+
if ((t & 7) === 4) return m;
|
|
4379
|
+
switch (t >>> 3) {
|
|
4380
|
+
case 1:
|
|
4381
|
+
m.caster = r.uint32();
|
|
4382
|
+
break;
|
|
4383
|
+
case 2:
|
|
4384
|
+
m.player = r.int32();
|
|
4385
|
+
break;
|
|
4386
|
+
case 3:
|
|
4387
|
+
m.ability = r.uint32();
|
|
4388
|
+
break;
|
|
4389
|
+
case 4:
|
|
4390
|
+
m.name = r.string();
|
|
4391
|
+
break;
|
|
4392
|
+
case 5:
|
|
4393
|
+
m.slot = r.int32();
|
|
4394
|
+
break;
|
|
4395
|
+
case 6:
|
|
4396
|
+
m.target = r.uint32();
|
|
4397
|
+
break;
|
|
4398
|
+
default:
|
|
4399
|
+
r.skip(t);
|
|
4400
|
+
}
|
|
4401
|
+
}
|
|
4402
|
+
return m;
|
|
4403
|
+
},
|
|
4404
|
+
encode: (m, w) => {
|
|
4405
|
+
{
|
|
4406
|
+
const v = m.caster;
|
|
4407
|
+
if (v) w.uint32(8).uint32(v);
|
|
4408
|
+
}
|
|
4409
|
+
{
|
|
4410
|
+
const v = m.player;
|
|
4411
|
+
if (v) w.uint32(16).int32(v);
|
|
4412
|
+
}
|
|
4413
|
+
{
|
|
4414
|
+
const v = m.ability;
|
|
4415
|
+
if (v) w.uint32(24).uint32(v);
|
|
4416
|
+
}
|
|
4417
|
+
{
|
|
4418
|
+
const v = m.name;
|
|
4419
|
+
if (v) w.uint32(34).string(v);
|
|
4420
|
+
}
|
|
4421
|
+
{
|
|
4422
|
+
const v = m.slot;
|
|
4423
|
+
if (v) w.uint32(40).int32(v);
|
|
4424
|
+
}
|
|
4425
|
+
{
|
|
4426
|
+
const v = m.target;
|
|
4427
|
+
if (v) w.uint32(48).uint32(v);
|
|
4428
|
+
}
|
|
4429
|
+
}
|
|
4430
|
+
}
|
|
4431
|
+
);
|
|
4331
4432
|
|
|
4332
4433
|
// src/wasm/combat/combat.pb.ts
|
|
4333
4434
|
var DamageEvent = /* @__PURE__ */ createMessageType(
|
|
@@ -4510,6 +4611,66 @@ var DamagedEvent = /* @__PURE__ */ createMessageType(
|
|
|
4510
4611
|
}
|
|
4511
4612
|
}
|
|
4512
4613
|
);
|
|
4614
|
+
var KillEvent = /* @__PURE__ */ createMessageType(
|
|
4615
|
+
"modlock.wasm.combat.KillEvent",
|
|
4616
|
+
() => [
|
|
4617
|
+
[1, "victim", 13],
|
|
4618
|
+
[2, "victim_player", 5],
|
|
4619
|
+
[3, "attacker", 13],
|
|
4620
|
+
[4, "attacker_player", 5],
|
|
4621
|
+
[5, "ability", 13]
|
|
4622
|
+
],
|
|
4623
|
+
{
|
|
4624
|
+
decode: (r, end, m) => {
|
|
4625
|
+
while (r.pos < end) {
|
|
4626
|
+
const t = r.tag();
|
|
4627
|
+
if ((t & 7) === 4) return m;
|
|
4628
|
+
switch (t >>> 3) {
|
|
4629
|
+
case 1:
|
|
4630
|
+
m.victim = r.uint32();
|
|
4631
|
+
break;
|
|
4632
|
+
case 2:
|
|
4633
|
+
m.victimPlayer = r.int32();
|
|
4634
|
+
break;
|
|
4635
|
+
case 3:
|
|
4636
|
+
m.attacker = r.uint32();
|
|
4637
|
+
break;
|
|
4638
|
+
case 4:
|
|
4639
|
+
m.attackerPlayer = r.int32();
|
|
4640
|
+
break;
|
|
4641
|
+
case 5:
|
|
4642
|
+
m.ability = r.uint32();
|
|
4643
|
+
break;
|
|
4644
|
+
default:
|
|
4645
|
+
r.skip(t);
|
|
4646
|
+
}
|
|
4647
|
+
}
|
|
4648
|
+
return m;
|
|
4649
|
+
},
|
|
4650
|
+
encode: (m, w) => {
|
|
4651
|
+
{
|
|
4652
|
+
const v = m.victim;
|
|
4653
|
+
if (v) w.uint32(8).uint32(v);
|
|
4654
|
+
}
|
|
4655
|
+
{
|
|
4656
|
+
const v = m.victimPlayer;
|
|
4657
|
+
if (v) w.uint32(16).int32(v);
|
|
4658
|
+
}
|
|
4659
|
+
{
|
|
4660
|
+
const v = m.attacker;
|
|
4661
|
+
if (v) w.uint32(24).uint32(v);
|
|
4662
|
+
}
|
|
4663
|
+
{
|
|
4664
|
+
const v = m.attackerPlayer;
|
|
4665
|
+
if (v) w.uint32(32).int32(v);
|
|
4666
|
+
}
|
|
4667
|
+
{
|
|
4668
|
+
const v = m.ability;
|
|
4669
|
+
if (v) w.uint32(40).uint32(v);
|
|
4670
|
+
}
|
|
4671
|
+
}
|
|
4672
|
+
}
|
|
4673
|
+
);
|
|
4513
4674
|
var LaunchEvent = /* @__PURE__ */ createMessageType(
|
|
4514
4675
|
"modlock.wasm.combat.LaunchEvent",
|
|
4515
4676
|
() => [
|
|
@@ -4954,6 +5115,66 @@ var TraceHit = /* @__PURE__ */ createMessageType(
|
|
|
4954
5115
|
}
|
|
4955
5116
|
}
|
|
4956
5117
|
);
|
|
5118
|
+
var ModifierFiredEvent = /* @__PURE__ */ createMessageType(
|
|
5119
|
+
"modlock.wasm.combat.ModifierFiredEvent",
|
|
5120
|
+
() => [
|
|
5121
|
+
[1, "name", 9],
|
|
5122
|
+
[2, "caster", 13],
|
|
5123
|
+
[3, "player", 5],
|
|
5124
|
+
[4, "target", 13],
|
|
5125
|
+
[5, "ability", 13]
|
|
5126
|
+
],
|
|
5127
|
+
{
|
|
5128
|
+
decode: (r, end, m) => {
|
|
5129
|
+
while (r.pos < end) {
|
|
5130
|
+
const t = r.tag();
|
|
5131
|
+
if ((t & 7) === 4) return m;
|
|
5132
|
+
switch (t >>> 3) {
|
|
5133
|
+
case 1:
|
|
5134
|
+
m.name = r.string();
|
|
5135
|
+
break;
|
|
5136
|
+
case 2:
|
|
5137
|
+
m.caster = r.uint32();
|
|
5138
|
+
break;
|
|
5139
|
+
case 3:
|
|
5140
|
+
m.player = r.int32();
|
|
5141
|
+
break;
|
|
5142
|
+
case 4:
|
|
5143
|
+
m.target = r.uint32();
|
|
5144
|
+
break;
|
|
5145
|
+
case 5:
|
|
5146
|
+
m.ability = r.uint32();
|
|
5147
|
+
break;
|
|
5148
|
+
default:
|
|
5149
|
+
r.skip(t);
|
|
5150
|
+
}
|
|
5151
|
+
}
|
|
5152
|
+
return m;
|
|
5153
|
+
},
|
|
5154
|
+
encode: (m, w) => {
|
|
5155
|
+
{
|
|
5156
|
+
const v = m.name;
|
|
5157
|
+
if (v) w.uint32(10).string(v);
|
|
5158
|
+
}
|
|
5159
|
+
{
|
|
5160
|
+
const v = m.caster;
|
|
5161
|
+
if (v) w.uint32(16).uint32(v);
|
|
5162
|
+
}
|
|
5163
|
+
{
|
|
5164
|
+
const v = m.player;
|
|
5165
|
+
if (v) w.uint32(24).int32(v);
|
|
5166
|
+
}
|
|
5167
|
+
{
|
|
5168
|
+
const v = m.target;
|
|
5169
|
+
if (v) w.uint32(32).uint32(v);
|
|
5170
|
+
}
|
|
5171
|
+
{
|
|
5172
|
+
const v = m.ability;
|
|
5173
|
+
if (v) w.uint32(40).uint32(v);
|
|
5174
|
+
}
|
|
5175
|
+
}
|
|
5176
|
+
}
|
|
5177
|
+
);
|
|
4957
5178
|
|
|
4958
5179
|
// src/wasm/effects/effects.pb.ts
|
|
4959
5180
|
var ScreenEffect_Enum = /* @__PURE__ */ createEnumType(
|
|
@@ -13252,7 +13473,8 @@ function toAbilityOptions(value) {
|
|
|
13252
13473
|
charges: value.charges === void 0 ? void 0 : int32(value.charges),
|
|
13253
13474
|
cooldownEnd: value.cooldownEnd,
|
|
13254
13475
|
rechargeEnd: value.rechargeEnd,
|
|
13255
|
-
maxCharges: value.maxCharges === void 0 ? void 0 : int32(value.maxCharges)
|
|
13476
|
+
maxCharges: value.maxCharges === void 0 ? void 0 : int32(value.maxCharges),
|
|
13477
|
+
cooldown: value.cooldown
|
|
13256
13478
|
};
|
|
13257
13479
|
}
|
|
13258
13480
|
function fromModifier(message) {
|
|
@@ -13282,6 +13504,16 @@ function fromBuildItem(message) {
|
|
|
13282
13504
|
annotation: message.annotation ?? ""
|
|
13283
13505
|
};
|
|
13284
13506
|
}
|
|
13507
|
+
function fromAbilityCastEvent(message) {
|
|
13508
|
+
return {
|
|
13509
|
+
caster: message.caster ?? 0,
|
|
13510
|
+
player: Player.of(message.player ?? 0),
|
|
13511
|
+
ability: message.ability ?? 0,
|
|
13512
|
+
name: message.name ?? "",
|
|
13513
|
+
slot: message.slot ?? 0,
|
|
13514
|
+
target: message.target ?? 0
|
|
13515
|
+
};
|
|
13516
|
+
}
|
|
13285
13517
|
function fromDamageEvent(message) {
|
|
13286
13518
|
return {
|
|
13287
13519
|
victim: message.victim ?? 0,
|
|
@@ -13303,6 +13535,15 @@ function fromDamagedEvent(message) {
|
|
|
13303
13535
|
dealt: message.dealt ?? 0
|
|
13304
13536
|
};
|
|
13305
13537
|
}
|
|
13538
|
+
function fromKillEvent(message) {
|
|
13539
|
+
return {
|
|
13540
|
+
victim: message.victim ?? 0,
|
|
13541
|
+
victimPlayer: Player.of(message.victimPlayer ?? 0),
|
|
13542
|
+
attacker: message.attacker ?? 0,
|
|
13543
|
+
attackerPlayer: Player.of(message.attackerPlayer ?? 0),
|
|
13544
|
+
ability: message.ability ?? 0
|
|
13545
|
+
};
|
|
13546
|
+
}
|
|
13306
13547
|
function fromLaunchEvent(message) {
|
|
13307
13548
|
return {
|
|
13308
13549
|
entity: message.entity ?? 0,
|
|
@@ -13357,6 +13598,15 @@ function fromTraceHit(message) {
|
|
|
13357
13598
|
entity: message.entity ?? 0
|
|
13358
13599
|
};
|
|
13359
13600
|
}
|
|
13601
|
+
function fromModifierFiredEvent(message) {
|
|
13602
|
+
return {
|
|
13603
|
+
name: message.name ?? "",
|
|
13604
|
+
caster: message.caster ?? 0,
|
|
13605
|
+
player: Player.of(message.player ?? 0),
|
|
13606
|
+
target: message.target ?? 0,
|
|
13607
|
+
ability: message.ability ?? 0
|
|
13608
|
+
};
|
|
13609
|
+
}
|
|
13360
13610
|
function toSoundOptions(value) {
|
|
13361
13611
|
return {
|
|
13362
13612
|
volume: value.volume,
|
|
@@ -13765,6 +14015,18 @@ function fromStartEvent(message) {
|
|
|
13765
14015
|
source: message.source ?? new Uint8Array()
|
|
13766
14016
|
};
|
|
13767
14017
|
}
|
|
14018
|
+
function toStartResult(value) {
|
|
14019
|
+
return {
|
|
14020
|
+
frames: value.frames,
|
|
14021
|
+
damage: value.damage,
|
|
14022
|
+
damaged: value.damaged,
|
|
14023
|
+
chat: value.chat,
|
|
14024
|
+
joins: value.joins,
|
|
14025
|
+
casts: value.casts,
|
|
14026
|
+
modifierEvents: value.modifierEvents?.slice(),
|
|
14027
|
+
kills: value.kills
|
|
14028
|
+
};
|
|
14029
|
+
}
|
|
13768
14030
|
function fromFrameEvent(message) {
|
|
13769
14031
|
return {
|
|
13770
14032
|
tick: message.tick ?? 0n,
|
|
@@ -14672,7 +14934,7 @@ function serveMod(handlers2, bytes) {
|
|
|
14672
14934
|
try {
|
|
14673
14935
|
switch (request.method) {
|
|
14674
14936
|
case "Start":
|
|
14675
|
-
return reply(StartResult.toBinary(handlers2.start(fromStartEvent(StartEvent.fromBinary(input2)))));
|
|
14937
|
+
return reply(StartResult.toBinary(toStartResult(handlers2.start(fromStartEvent(StartEvent.fromBinary(input2))))));
|
|
14676
14938
|
case "Frame":
|
|
14677
14939
|
handlers2.frame(fromFrameEvent(FrameEvent.fromBinary(input2)));
|
|
14678
14940
|
return reply();
|
|
@@ -14697,6 +14959,15 @@ function serveMod(handlers2, bytes) {
|
|
|
14697
14959
|
case "Damaged":
|
|
14698
14960
|
handlers2.damaged(fromDamagedEvent(DamagedEvent.fromBinary(input2)));
|
|
14699
14961
|
return reply();
|
|
14962
|
+
case "Killed":
|
|
14963
|
+
handlers2.killed(fromKillEvent(KillEvent.fromBinary(input2)));
|
|
14964
|
+
return reply();
|
|
14965
|
+
case "AbilityCast":
|
|
14966
|
+
handlers2.abilityCast(fromAbilityCastEvent(AbilityCastEvent.fromBinary(input2)));
|
|
14967
|
+
return reply();
|
|
14968
|
+
case "ModifierFired":
|
|
14969
|
+
handlers2.modifierFired(fromModifierFiredEvent(ModifierFiredEvent.fromBinary(input2)));
|
|
14970
|
+
return reply();
|
|
14700
14971
|
case "Input":
|
|
14701
14972
|
handlers2.input(fromInputEvent(InputEvent.fromBinary(input2)));
|
|
14702
14973
|
return reply();
|
|
@@ -14761,8 +15032,12 @@ function watchPlayers(watcher) {
|
|
|
14761
15032
|
if (roster !== void 0) watcher(roster);
|
|
14762
15033
|
}
|
|
14763
15034
|
function connection(player) {
|
|
15035
|
+
const held = roster ?? players();
|
|
15036
|
+
if (typeof player === "bigint") {
|
|
15037
|
+
return held.find((c) => c.steamId === player);
|
|
15038
|
+
}
|
|
14764
15039
|
const slot = typeof player === "number" ? player : player.slot;
|
|
14765
|
-
return
|
|
15040
|
+
return held.find((c) => c.player.slot === slot);
|
|
14766
15041
|
}
|
|
14767
15042
|
function players() {
|
|
14768
15043
|
if (roster !== void 0) return roster.slice();
|
|
@@ -17564,11 +17839,11 @@ function fewestPlayed(standings) {
|
|
|
17564
17839
|
return least === Infinity ? 0 : least;
|
|
17565
17840
|
}
|
|
17566
17841
|
function nextMatch(line2, size, standing) {
|
|
17567
|
-
const
|
|
17568
|
-
if (size < 1 ||
|
|
17842
|
+
const seated2 = [...line2].sort((a, b) => standing(a).played - standing(b).played).slice(0, 2 * size);
|
|
17843
|
+
if (size < 1 || seated2.length < 2 * size) {
|
|
17569
17844
|
return void 0;
|
|
17570
17845
|
}
|
|
17571
|
-
const ranked =
|
|
17846
|
+
const ranked = seated2.sort((a, b) => standing(b).rating - standing(a).rating);
|
|
17572
17847
|
const sides = [[], []];
|
|
17573
17848
|
for (const [i, player] of ranked.entries()) {
|
|
17574
17849
|
const round = Math.floor(i / 2);
|
|
@@ -19032,27 +19307,57 @@ function onSpawn(handler) {
|
|
|
19032
19307
|
spawns.push(handler);
|
|
19033
19308
|
}
|
|
19034
19309
|
var spawned = /* @__PURE__ */ new Map();
|
|
19035
|
-
|
|
19036
|
-
|
|
19037
|
-
|
|
19038
|
-
|
|
19310
|
+
var seated = /* @__PURE__ */ new Map();
|
|
19311
|
+
var respawnDelay;
|
|
19312
|
+
var unseated = {};
|
|
19313
|
+
var seating;
|
|
19314
|
+
function startSeating() {
|
|
19315
|
+
if (seating) {
|
|
19316
|
+
return;
|
|
19317
|
+
}
|
|
19039
19318
|
const cast = new Cast({
|
|
19040
|
-
join(connection2)
|
|
19041
|
-
|
|
19042
|
-
|
|
19043
|
-
|
|
19044
|
-
|
|
19045
|
-
...respawn === void 0 ? {} : { respawn }
|
|
19046
|
-
});
|
|
19047
|
-
return connection2;
|
|
19319
|
+
join: (connection2) => connection2,
|
|
19320
|
+
leave(member) {
|
|
19321
|
+
if (seated.get(member.player.slot)?.generation === member.generation) {
|
|
19322
|
+
seated.delete(member.player.slot);
|
|
19323
|
+
}
|
|
19048
19324
|
},
|
|
19049
|
-
|
|
19050
|
-
|
|
19325
|
+
want(member) {
|
|
19326
|
+
const held = seated.get(member.player.slot);
|
|
19327
|
+
return held?.generation === member.generation ? held.want : unseated;
|
|
19051
19328
|
},
|
|
19052
|
-
|
|
19329
|
+
bots: "join"
|
|
19053
19330
|
});
|
|
19331
|
+
seating = cast;
|
|
19054
19332
|
onFrame(({ timeSeconds }) => cast.frame(timeSeconds));
|
|
19055
|
-
|
|
19333
|
+
}
|
|
19334
|
+
function wantOf(seating2) {
|
|
19335
|
+
return {
|
|
19336
|
+
hero: seating2.hero ?? "any",
|
|
19337
|
+
...seating2.team === void 0 ? {} : { team: seating2.team },
|
|
19338
|
+
...respawnDelay === void 0 ? {} : { respawn: respawnDelay }
|
|
19339
|
+
};
|
|
19340
|
+
}
|
|
19341
|
+
Player.prototype.connection = function() {
|
|
19342
|
+
return connection(this);
|
|
19343
|
+
};
|
|
19344
|
+
Player.prototype.seat = function(seating2 = {}) {
|
|
19345
|
+
const held = connection(this);
|
|
19346
|
+
if (!held) {
|
|
19347
|
+
return false;
|
|
19348
|
+
}
|
|
19349
|
+
seated.set(this.slot, { generation: held.generation, want: wantOf(seating2) });
|
|
19350
|
+
startSeating();
|
|
19351
|
+
return true;
|
|
19352
|
+
};
|
|
19353
|
+
function setRespawnDelay(seconds) {
|
|
19354
|
+
respawnDelay = seconds;
|
|
19355
|
+
unseated = seconds === void 0 ? {} : { respawn: seconds };
|
|
19356
|
+
for (const held of seated.values()) {
|
|
19357
|
+
const { respawn: _, ...want } = held.want;
|
|
19358
|
+
held.want = { ...want, ...unseated };
|
|
19359
|
+
}
|
|
19360
|
+
startSeating();
|
|
19056
19361
|
}
|
|
19057
19362
|
function watchSpawns() {
|
|
19058
19363
|
const present = /* @__PURE__ */ new Map();
|
|
@@ -19091,6 +19396,17 @@ function onDamage(handler) {
|
|
|
19091
19396
|
function onDamaged(handler) {
|
|
19092
19397
|
damageds.push(handler);
|
|
19093
19398
|
}
|
|
19399
|
+
function onKill(handler) {
|
|
19400
|
+
kills.push(handler);
|
|
19401
|
+
}
|
|
19402
|
+
function onAbilityCast(handler) {
|
|
19403
|
+
abilityCasts.push(handler);
|
|
19404
|
+
}
|
|
19405
|
+
function onModifierEvent(name, handler) {
|
|
19406
|
+
const handlers2 = modifierEvents.get(name) ?? [];
|
|
19407
|
+
handlers2.push(handler);
|
|
19408
|
+
modifierEvents.set(name, handlers2);
|
|
19409
|
+
}
|
|
19094
19410
|
function onLaunch(handler) {
|
|
19095
19411
|
launches.push(handler);
|
|
19096
19412
|
}
|
|
@@ -19125,6 +19441,9 @@ var restoreds = [];
|
|
|
19125
19441
|
var npcsRestoreds = [];
|
|
19126
19442
|
var damages = [];
|
|
19127
19443
|
var damageds = [];
|
|
19444
|
+
var kills = [];
|
|
19445
|
+
var abilityCasts = [];
|
|
19446
|
+
var modifierEvents = /* @__PURE__ */ new Map();
|
|
19128
19447
|
var launches = [];
|
|
19129
19448
|
var impacts = [];
|
|
19130
19449
|
var landeds = [];
|
|
@@ -19139,7 +19458,10 @@ var handlers = {
|
|
|
19139
19458
|
damage: damages.length !== 0,
|
|
19140
19459
|
damaged: damageds.length !== 0,
|
|
19141
19460
|
chat: chats.length !== 0,
|
|
19142
|
-
joins: joins.length !== 0 || leaves.length !== 0
|
|
19461
|
+
joins: joins.length !== 0 || leaves.length !== 0,
|
|
19462
|
+
casts: abilityCasts.length !== 0,
|
|
19463
|
+
kills: kills.length !== 0,
|
|
19464
|
+
modifierEvents: [...modifierEvents.keys()]
|
|
19143
19465
|
};
|
|
19144
19466
|
},
|
|
19145
19467
|
frame(event) {
|
|
@@ -19207,6 +19529,21 @@ var handlers = {
|
|
|
19207
19529
|
handler(event);
|
|
19208
19530
|
}
|
|
19209
19531
|
},
|
|
19532
|
+
killed(event) {
|
|
19533
|
+
for (const handler of kills) {
|
|
19534
|
+
handler(event);
|
|
19535
|
+
}
|
|
19536
|
+
},
|
|
19537
|
+
abilityCast(event) {
|
|
19538
|
+
for (const handler of abilityCasts) {
|
|
19539
|
+
handler(event);
|
|
19540
|
+
}
|
|
19541
|
+
},
|
|
19542
|
+
modifierFired(event) {
|
|
19543
|
+
for (const handler of modifierEvents.get(event.name) ?? []) {
|
|
19544
|
+
handler(event);
|
|
19545
|
+
}
|
|
19546
|
+
},
|
|
19210
19547
|
input(event) {
|
|
19211
19548
|
for (const handler of inputs) {
|
|
19212
19549
|
handler(event.player, event.pressed, event.released);
|
|
@@ -19368,14 +19705,17 @@ export {
|
|
|
19368
19705
|
modifiers,
|
|
19369
19706
|
moveEntity,
|
|
19370
19707
|
nextMatch,
|
|
19708
|
+
onAbilityCast,
|
|
19371
19709
|
onChat,
|
|
19372
19710
|
onDamage,
|
|
19373
19711
|
onDamaged,
|
|
19374
19712
|
onFrame,
|
|
19375
19713
|
onImpact,
|
|
19376
19714
|
onInput,
|
|
19715
|
+
onKill,
|
|
19377
19716
|
onLanded,
|
|
19378
19717
|
onLaunch,
|
|
19718
|
+
onModifierEvent,
|
|
19379
19719
|
onNpcsRestored,
|
|
19380
19720
|
onPlayerJoin,
|
|
19381
19721
|
onPlayerLeave,
|
|
@@ -19410,13 +19750,13 @@ export {
|
|
|
19410
19750
|
rosterKey,
|
|
19411
19751
|
rosterRows,
|
|
19412
19752
|
route,
|
|
19413
|
-
seatPlayers,
|
|
19414
19753
|
sequence,
|
|
19415
19754
|
serve,
|
|
19416
19755
|
serveMod,
|
|
19417
19756
|
serverCommand,
|
|
19418
19757
|
setFreeForAll,
|
|
19419
19758
|
setOrbitCamera,
|
|
19759
|
+
setRespawnDelay,
|
|
19420
19760
|
setTeamSeating,
|
|
19421
19761
|
settingNumber,
|
|
19422
19762
|
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.83",
|
|
11
|
+
"@modlock/darwin-x64": "0.1.83",
|
|
12
|
+
"@modlock/linux-arm64": "0.1.83",
|
|
13
|
+
"@modlock/linux-x64": "0.1.83",
|
|
14
|
+
"@modlock/win32-x64": "0.1.83"
|
|
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.83"
|
|
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.
|