@modlock/modlock 0.1.82 → 0.1.84

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 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,96 @@ 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
+ }
425
+ /**
426
+ * HealEvent reports health an ability, item or lifesteal restored at once to
427
+ * a hero or unit. Regeneration reports none, including what abilities such as
428
+ * Siphon Life restore as regeneration, and neither do Modlock's own heal and
429
+ * a heal at full health.
430
+ */
431
+ export interface HealEvent {
432
+ /** target is the entity healed. */
433
+ readonly target: number;
434
+ /**
435
+ * targetPlayer is the slot of the player whose hero was healed, or -1 for
436
+ * a unit.
437
+ */
438
+ readonly targetPlayer: Player;
439
+ /**
440
+ * healer is the entity the heal came from, or zero when the game names
441
+ * none.
442
+ */
443
+ readonly healer: number;
444
+ /**
445
+ * healerPlayer is the slot of the player whose hero the healer is, or -1.
446
+ */
447
+ readonly healerPlayer: Player;
448
+ /** ability is the ability or item that healed, or zero. */
449
+ readonly ability: number;
450
+ /** applied is the health the heal restored. */
451
+ readonly applied: number;
452
+ /**
453
+ * requested is the heal's whole amount; it exceeds applied when the target
454
+ * reached full health.
455
+ */
456
+ readonly requested: number;
457
+ }
458
+ /** LevelEvent reports a hero reaching a new level. */
459
+ export interface LevelEvent {
460
+ /** hero is the hero's entity. */
461
+ readonly hero: number;
462
+ /** player is the slot of the player whose hero it is, or -1. */
463
+ readonly player: Player;
464
+ /** level is the hero's new level. */
465
+ readonly level: number;
466
+ }
467
+ /** MeleeEvent reports one melee swing as the game resolves it. */
468
+ export interface MeleeEvent {
469
+ /** attacker is the hero or unit that swung. */
470
+ readonly attacker: number;
471
+ /** attackerPlayer is the slot of the player whose hero swung, or -1. */
472
+ readonly attackerPlayer: Player;
473
+ /** heavy is true for a charged swing and false for a light one. */
474
+ readonly heavy: boolean;
475
+ /** hits are the entities the swing struck, empty for a miss. */
476
+ readonly hits: number[];
477
+ }
478
+ /** ParryEvent reports a parry that caught a melee swing. */
479
+ export interface ParryEvent {
480
+ /** parrier is the hero that parried. */
481
+ readonly parrier: number;
482
+ /** player is the slot of the player whose hero parried, or -1. */
483
+ readonly player: Player;
484
+ /** attacker is the hero or unit whose swing was caught. */
485
+ readonly attacker: number;
486
+ /** attackerPlayer is the slot of the player whose hero swung, or -1. */
487
+ readonly attackerPlayer: Player;
488
+ }
341
489
  /**
342
490
  * SoundOptions shape one sound; the zero value plays it to every player as
343
491
  * the game made it.
@@ -1300,6 +1448,33 @@ export interface StartResult {
1300
1448
  * and a PlayerLeft event as each leaves.
1301
1449
  */
1302
1450
  joins: boolean;
1451
+ /**
1452
+ * casts asks for an AbilityCast event after each ability the game
1453
+ * executes.
1454
+ */
1455
+ casts: boolean;
1456
+ /**
1457
+ * modifierEvents asks for a ModifierFired event for each of the game's
1458
+ * modifier events with these EModifierEvent names, such as
1459
+ * MODIFIER_EVENT_ABILITY_CAST_STARTED or, without the prefix,
1460
+ * ABILITY_CAST_STARTED. A name the running game lacks is logged and never
1461
+ * fires.
1462
+ */
1463
+ modifierEvents?: readonly string[];
1464
+ /**
1465
+ * kills asks for a Killed event after each hit that kills a hero or unit.
1466
+ */
1467
+ kills: boolean;
1468
+ /** heals asks for a Healed event after each heal. */
1469
+ heals: boolean;
1470
+ /** levels asks for a LevelChanged event as each hero reaches a new level. */
1471
+ levels: boolean;
1472
+ /** melees asks for a Melee event after each melee swing. */
1473
+ melees: boolean;
1474
+ /**
1475
+ * parries asks for a Parried event after each parry that catches a swing.
1476
+ */
1477
+ parries: boolean;
1303
1478
  }
1304
1479
  /** FrameEvent identifies one server frame. */
1305
1480
  export interface FrameEvent {
@@ -2214,6 +2389,41 @@ export interface ModHandlers {
2214
2389
  * damage reports. Hits arrive before the next frame.
2215
2390
  */
2216
2391
  damaged(event: DamagedEvent): void;
2392
+ /**
2393
+ * killed reports one hero or unit a hit killed, while the mod asked for
2394
+ * kills, after the hit's Damaged event and before the next frame.
2395
+ */
2396
+ killed(event: KillEvent): void;
2397
+ /**
2398
+ * abilityCast reports one ability the game executed, while the mod asked
2399
+ * for casts, before the next frame.
2400
+ */
2401
+ abilityCast(event: AbilityCastEvent): void;
2402
+ /**
2403
+ * modifierFired reports one modifier event the mod watches, before the
2404
+ * next frame.
2405
+ */
2406
+ modifierFired(event: ModifierFiredEvent): void;
2407
+ /**
2408
+ * healed reports one heal, while the mod asked for heals, before the next
2409
+ * frame.
2410
+ */
2411
+ healed(event: HealEvent): void;
2412
+ /**
2413
+ * levelChanged reports one hero reaching a new level, while the mod asked
2414
+ * for levels, before the next frame.
2415
+ */
2416
+ levelChanged(event: LevelEvent): void;
2417
+ /**
2418
+ * melee reports one melee swing, while the mod asked for melees, before the
2419
+ * next frame.
2420
+ */
2421
+ melee(event: MeleeEvent): void;
2422
+ /**
2423
+ * parried reports one parry that caught a swing, while the mod asked for
2424
+ * parries, before the next frame.
2425
+ */
2426
+ parried(event: ParryEvent): void;
2217
2427
  /**
2218
2428
  * input reports one player's presses of watched buttons, before the next
2219
2429
  * frame. A block in place still withholds them from the hero.
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference path="./globals.d.ts" />
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';
2
+ import { type AbilityCastEvent, type KillEvent, type DamageEvent, type ChatEvent, type DamagedEvent, type DamageResult, type FrameEvent, type HealEvent, type ImpactEvent, type LandedEvent, type LaunchEvent, type LevelEvent, type MeleeEvent, type ModifierFiredEvent, type ParryEvent, type Pawn, Player, type PlayerJoinedEvent, type PlayerLeftEvent } from './host.gen.js';
3
3
  export * as vector from './vector.js';
4
4
  export { Buttons, Layers } from './bits.js';
5
5
  export { after, every, sequence, type Timer } from './timer.js';
@@ -81,8 +81,8 @@ export declare function onPlayerLeave(handler: (left: PlayerLeftEvent) => void):
81
81
  * onSpawn calls handler each time a player's hero enters play: their first
82
82
  * hero after joining, each respawn, and each new hero after a change. The
83
83
  * player has a hero to move, equip and read from then on, which onPlayerJoin
84
- * does not promise. The library reads each player's pawn once a frame while a
85
- * handler is registered.
84
+ * does not promise. The library hears it from the game's PLAYER_RESPAWNED
85
+ * event, before the frame handlers run.
86
86
  */
87
87
  export declare function onSpawn(handler: (player: Player, pawn: Pawn) => void): void;
88
88
  /** Seating is the hero and team seat gives one player. */
@@ -159,6 +159,49 @@ export declare function onNpcsRestored(handler: (error: string | undefined) => v
159
159
  export declare function onDamage(handler: (hit: DamageEvent) => DamageResult | void): void;
160
160
  /** onDamaged calls handler on the frame after each hit lands. */
161
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
+ * onHeal calls handler after each heal, before the next frame: health a hero
176
+ * or unit regained at once from an ability, an item or lifesteal. Regeneration
177
+ * calls nothing, including what abilities such as Siphon Life restore as
178
+ * regeneration, and neither do the mod's own heal and a heal at full health.
179
+ * The heal names the entity healed, the healer and ability when the game
180
+ * names them, and the player of each: a slot of -1 is a unit's, or no one's.
181
+ */
182
+ export declare function onHeal(handler: (heal: HealEvent) => void): void;
183
+ /**
184
+ * onLevelChange calls handler as each hero reaches a new level, before the
185
+ * next frame.
186
+ */
187
+ export declare function onLevelChange(handler: (change: LevelEvent) => void): void;
188
+ /**
189
+ * onMelee calls handler after each melee swing, before the next frame, with
190
+ * whether it was heavy and the entities it struck, none for a miss.
191
+ */
192
+ export declare function onMelee(handler: (swing: MeleeEvent) => void): void;
193
+ /**
194
+ * onParry calls handler after each parry that catches a melee swing, before
195
+ * the next frame, naming the hero that parried and the attacker it caught.
196
+ */
197
+ export declare function onParry(handler: (parry: ParryEvent) => void): void;
198
+ /**
199
+ * onModifierEvent calls handler each time the game fires the modifier event
200
+ * with this EModifierEvent name, such as ABILITY_CAST_STARTED, PARRY_SUCCESS
201
+ * or PLAYER_RESPAWNED, before the next frame. Register before the mod starts.
202
+ * A name the running game lacks is logged once and never fires.
203
+ */
204
+ export declare function onModifierEvent(name: string, handler: (event: ModifierFiredEvent) => void): void;
162
205
  /**
163
206
  * onLaunch calls handler with each watched projectile's first frame, before
164
207
  * the next frame. watchProjectiles names the projectiles.
package/index.js CHANGED
@@ -2815,7 +2815,14 @@ 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],
2822
+ [9, "heals", 8],
2823
+ [10, "levels", 8],
2824
+ [11, "melees", 8],
2825
+ [12, "parries", 8]
2819
2826
  ],
2820
2827
  {
2821
2828
  decode: (r, end, m) => {
@@ -2838,6 +2845,28 @@ var StartResult = /* @__PURE__ */ createMessageType(
2838
2845
  case 5:
2839
2846
  m.joins = r.bool();
2840
2847
  break;
2848
+ case 6:
2849
+ m.casts = r.bool();
2850
+ break;
2851
+ case 7:
2852
+ ;
2853
+ (m.modifierEvents ??= []).push(r.string());
2854
+ break;
2855
+ case 8:
2856
+ m.kills = r.bool();
2857
+ break;
2858
+ case 9:
2859
+ m.heals = r.bool();
2860
+ break;
2861
+ case 10:
2862
+ m.levels = r.bool();
2863
+ break;
2864
+ case 11:
2865
+ m.melees = r.bool();
2866
+ break;
2867
+ case 12:
2868
+ m.parries = r.bool();
2869
+ break;
2841
2870
  default:
2842
2871
  r.skip(t);
2843
2872
  }
@@ -2865,6 +2894,34 @@ var StartResult = /* @__PURE__ */ createMessageType(
2865
2894
  const v = m.joins;
2866
2895
  if (v) w.uint32(40).bool(v);
2867
2896
  }
2897
+ {
2898
+ const v = m.casts;
2899
+ if (v) w.uint32(48).bool(v);
2900
+ }
2901
+ {
2902
+ const a = m.modifierEvents;
2903
+ if (a != null) for (const e of a) w.uint32(58).string(e);
2904
+ }
2905
+ {
2906
+ const v = m.kills;
2907
+ if (v) w.uint32(64).bool(v);
2908
+ }
2909
+ {
2910
+ const v = m.heals;
2911
+ if (v) w.uint32(72).bool(v);
2912
+ }
2913
+ {
2914
+ const v = m.levels;
2915
+ if (v) w.uint32(80).bool(v);
2916
+ }
2917
+ {
2918
+ const v = m.melees;
2919
+ if (v) w.uint32(88).bool(v);
2920
+ }
2921
+ {
2922
+ const v = m.parries;
2923
+ if (v) w.uint32(96).bool(v);
2924
+ }
2868
2925
  }
2869
2926
  }
2870
2927
  );
@@ -3532,7 +3589,8 @@ var AbilityOptions = /* @__PURE__ */ createMessageType(
3532
3589
  [4, "charges", 5, 4],
3533
3590
  [5, "cooldown_end", 2, 4],
3534
3591
  [6, "recharge_end", 2, 4],
3535
- [7, "max_charges", 5, 4]
3592
+ [7, "max_charges", 5, 4],
3593
+ [8, "cooldown", 2, 4]
3536
3594
  ],
3537
3595
  {
3538
3596
  decode: (r, end, m) => {
@@ -3561,6 +3619,9 @@ var AbilityOptions = /* @__PURE__ */ createMessageType(
3561
3619
  case 7:
3562
3620
  m.maxCharges = r.int32();
3563
3621
  break;
3622
+ case 8:
3623
+ m.cooldown = r.float();
3624
+ break;
3564
3625
  default:
3565
3626
  r.skip(t);
3566
3627
  }
@@ -3596,6 +3657,10 @@ var AbilityOptions = /* @__PURE__ */ createMessageType(
3596
3657
  const v = m.maxCharges;
3597
3658
  if (v != null) w.uint32(56).int32(v);
3598
3659
  }
3660
+ {
3661
+ const v = m.cooldown;
3662
+ if (v != null) w.uint32(69).float(v);
3663
+ }
3599
3664
  }
3600
3665
  }
3601
3666
  );
@@ -4328,6 +4393,74 @@ var GiveEntityModifierRequest = /* @__PURE__ */ createMessageType(
4328
4393
  }
4329
4394
  }
4330
4395
  );
4396
+ var AbilityCastEvent = /* @__PURE__ */ createMessageType(
4397
+ "modlock.wasm.abilities.AbilityCastEvent",
4398
+ () => [
4399
+ [1, "caster", 13],
4400
+ [2, "player", 5],
4401
+ [3, "ability", 13],
4402
+ [4, "name", 9],
4403
+ [5, "slot", 5],
4404
+ [6, "target", 13]
4405
+ ],
4406
+ {
4407
+ decode: (r, end, m) => {
4408
+ while (r.pos < end) {
4409
+ const t = r.tag();
4410
+ if ((t & 7) === 4) return m;
4411
+ switch (t >>> 3) {
4412
+ case 1:
4413
+ m.caster = r.uint32();
4414
+ break;
4415
+ case 2:
4416
+ m.player = r.int32();
4417
+ break;
4418
+ case 3:
4419
+ m.ability = r.uint32();
4420
+ break;
4421
+ case 4:
4422
+ m.name = r.string();
4423
+ break;
4424
+ case 5:
4425
+ m.slot = r.int32();
4426
+ break;
4427
+ case 6:
4428
+ m.target = r.uint32();
4429
+ break;
4430
+ default:
4431
+ r.skip(t);
4432
+ }
4433
+ }
4434
+ return m;
4435
+ },
4436
+ encode: (m, w) => {
4437
+ {
4438
+ const v = m.caster;
4439
+ if (v) w.uint32(8).uint32(v);
4440
+ }
4441
+ {
4442
+ const v = m.player;
4443
+ if (v) w.uint32(16).int32(v);
4444
+ }
4445
+ {
4446
+ const v = m.ability;
4447
+ if (v) w.uint32(24).uint32(v);
4448
+ }
4449
+ {
4450
+ const v = m.name;
4451
+ if (v) w.uint32(34).string(v);
4452
+ }
4453
+ {
4454
+ const v = m.slot;
4455
+ if (v) w.uint32(40).int32(v);
4456
+ }
4457
+ {
4458
+ const v = m.target;
4459
+ if (v) w.uint32(48).uint32(v);
4460
+ }
4461
+ }
4462
+ }
4463
+ );
4331
4464
 
4332
4465
  // src/wasm/combat/combat.pb.ts
4333
4466
  var DamageEvent = /* @__PURE__ */ createMessageType(
@@ -4510,6 +4643,66 @@ var DamagedEvent = /* @__PURE__ */ createMessageType(
4510
4643
  }
4511
4644
  }
4512
4645
  );
4646
+ var KillEvent = /* @__PURE__ */ createMessageType(
4647
+ "modlock.wasm.combat.KillEvent",
4648
+ () => [
4649
+ [1, "victim", 13],
4650
+ [2, "victim_player", 5],
4651
+ [3, "attacker", 13],
4652
+ [4, "attacker_player", 5],
4653
+ [5, "ability", 13]
4654
+ ],
4655
+ {
4656
+ decode: (r, end, m) => {
4657
+ while (r.pos < end) {
4658
+ const t = r.tag();
4659
+ if ((t & 7) === 4) return m;
4660
+ switch (t >>> 3) {
4661
+ case 1:
4662
+ m.victim = r.uint32();
4663
+ break;
4664
+ case 2:
4665
+ m.victimPlayer = r.int32();
4666
+ break;
4667
+ case 3:
4668
+ m.attacker = r.uint32();
4669
+ break;
4670
+ case 4:
4671
+ m.attackerPlayer = r.int32();
4672
+ break;
4673
+ case 5:
4674
+ m.ability = r.uint32();
4675
+ break;
4676
+ default:
4677
+ r.skip(t);
4678
+ }
4679
+ }
4680
+ return m;
4681
+ },
4682
+ encode: (m, w) => {
4683
+ {
4684
+ const v = m.victim;
4685
+ if (v) w.uint32(8).uint32(v);
4686
+ }
4687
+ {
4688
+ const v = m.victimPlayer;
4689
+ if (v) w.uint32(16).int32(v);
4690
+ }
4691
+ {
4692
+ const v = m.attacker;
4693
+ if (v) w.uint32(24).uint32(v);
4694
+ }
4695
+ {
4696
+ const v = m.attackerPlayer;
4697
+ if (v) w.uint32(32).int32(v);
4698
+ }
4699
+ {
4700
+ const v = m.ability;
4701
+ if (v) w.uint32(40).uint32(v);
4702
+ }
4703
+ }
4704
+ }
4705
+ );
4513
4706
  var LaunchEvent = /* @__PURE__ */ createMessageType(
4514
4707
  "modlock.wasm.combat.LaunchEvent",
4515
4708
  () => [
@@ -4954,6 +5147,295 @@ var TraceHit = /* @__PURE__ */ createMessageType(
4954
5147
  }
4955
5148
  }
4956
5149
  );
5150
+ var ModifierFiredEvent = /* @__PURE__ */ createMessageType(
5151
+ "modlock.wasm.combat.ModifierFiredEvent",
5152
+ () => [
5153
+ [1, "name", 9],
5154
+ [2, "caster", 13],
5155
+ [3, "player", 5],
5156
+ [4, "target", 13],
5157
+ [5, "ability", 13]
5158
+ ],
5159
+ {
5160
+ decode: (r, end, m) => {
5161
+ while (r.pos < end) {
5162
+ const t = r.tag();
5163
+ if ((t & 7) === 4) return m;
5164
+ switch (t >>> 3) {
5165
+ case 1:
5166
+ m.name = r.string();
5167
+ break;
5168
+ case 2:
5169
+ m.caster = r.uint32();
5170
+ break;
5171
+ case 3:
5172
+ m.player = r.int32();
5173
+ break;
5174
+ case 4:
5175
+ m.target = r.uint32();
5176
+ break;
5177
+ case 5:
5178
+ m.ability = r.uint32();
5179
+ break;
5180
+ default:
5181
+ r.skip(t);
5182
+ }
5183
+ }
5184
+ return m;
5185
+ },
5186
+ encode: (m, w) => {
5187
+ {
5188
+ const v = m.name;
5189
+ if (v) w.uint32(10).string(v);
5190
+ }
5191
+ {
5192
+ const v = m.caster;
5193
+ if (v) w.uint32(16).uint32(v);
5194
+ }
5195
+ {
5196
+ const v = m.player;
5197
+ if (v) w.uint32(24).int32(v);
5198
+ }
5199
+ {
5200
+ const v = m.target;
5201
+ if (v) w.uint32(32).uint32(v);
5202
+ }
5203
+ {
5204
+ const v = m.ability;
5205
+ if (v) w.uint32(40).uint32(v);
5206
+ }
5207
+ }
5208
+ }
5209
+ );
5210
+ var HealEvent = /* @__PURE__ */ createMessageType(
5211
+ "modlock.wasm.combat.HealEvent",
5212
+ () => [
5213
+ [1, "target", 13],
5214
+ [2, "target_player", 5],
5215
+ [3, "healer", 13],
5216
+ [4, "healer_player", 5],
5217
+ [5, "ability", 13],
5218
+ [6, "applied", 5],
5219
+ [7, "requested", 5]
5220
+ ],
5221
+ {
5222
+ decode: (r, end, m) => {
5223
+ while (r.pos < end) {
5224
+ const t = r.tag();
5225
+ if ((t & 7) === 4) return m;
5226
+ switch (t >>> 3) {
5227
+ case 1:
5228
+ m.target = r.uint32();
5229
+ break;
5230
+ case 2:
5231
+ m.targetPlayer = r.int32();
5232
+ break;
5233
+ case 3:
5234
+ m.healer = r.uint32();
5235
+ break;
5236
+ case 4:
5237
+ m.healerPlayer = r.int32();
5238
+ break;
5239
+ case 5:
5240
+ m.ability = r.uint32();
5241
+ break;
5242
+ case 6:
5243
+ m.applied = r.int32();
5244
+ break;
5245
+ case 7:
5246
+ m.requested = r.int32();
5247
+ break;
5248
+ default:
5249
+ r.skip(t);
5250
+ }
5251
+ }
5252
+ return m;
5253
+ },
5254
+ encode: (m, w) => {
5255
+ {
5256
+ const v = m.target;
5257
+ if (v) w.uint32(8).uint32(v);
5258
+ }
5259
+ {
5260
+ const v = m.targetPlayer;
5261
+ if (v) w.uint32(16).int32(v);
5262
+ }
5263
+ {
5264
+ const v = m.healer;
5265
+ if (v) w.uint32(24).uint32(v);
5266
+ }
5267
+ {
5268
+ const v = m.healerPlayer;
5269
+ if (v) w.uint32(32).int32(v);
5270
+ }
5271
+ {
5272
+ const v = m.ability;
5273
+ if (v) w.uint32(40).uint32(v);
5274
+ }
5275
+ {
5276
+ const v = m.applied;
5277
+ if (v) w.uint32(48).int32(v);
5278
+ }
5279
+ {
5280
+ const v = m.requested;
5281
+ if (v) w.uint32(56).int32(v);
5282
+ }
5283
+ }
5284
+ }
5285
+ );
5286
+ var LevelEvent = /* @__PURE__ */ createMessageType(
5287
+ "modlock.wasm.combat.LevelEvent",
5288
+ () => [
5289
+ [1, "hero", 13],
5290
+ [2, "player", 5],
5291
+ [3, "level", 5]
5292
+ ],
5293
+ {
5294
+ decode: (r, end, m) => {
5295
+ while (r.pos < end) {
5296
+ const t = r.tag();
5297
+ if ((t & 7) === 4) return m;
5298
+ switch (t >>> 3) {
5299
+ case 1:
5300
+ m.hero = r.uint32();
5301
+ break;
5302
+ case 2:
5303
+ m.player = r.int32();
5304
+ break;
5305
+ case 3:
5306
+ m.level = r.int32();
5307
+ break;
5308
+ default:
5309
+ r.skip(t);
5310
+ }
5311
+ }
5312
+ return m;
5313
+ },
5314
+ encode: (m, w) => {
5315
+ {
5316
+ const v = m.hero;
5317
+ if (v) w.uint32(8).uint32(v);
5318
+ }
5319
+ {
5320
+ const v = m.player;
5321
+ if (v) w.uint32(16).int32(v);
5322
+ }
5323
+ {
5324
+ const v = m.level;
5325
+ if (v) w.uint32(24).int32(v);
5326
+ }
5327
+ }
5328
+ }
5329
+ );
5330
+ var MeleeEvent = /* @__PURE__ */ createMessageType(
5331
+ "modlock.wasm.combat.MeleeEvent",
5332
+ () => [
5333
+ [1, "attacker", 13],
5334
+ [2, "attacker_player", 5],
5335
+ [3, "heavy", 8],
5336
+ [4, "hits", 13, 3]
5337
+ ],
5338
+ {
5339
+ decode: (r, end, m) => {
5340
+ while (r.pos < end) {
5341
+ const t = r.tag();
5342
+ if ((t & 7) === 4) return m;
5343
+ switch (t >>> 3) {
5344
+ case 1:
5345
+ m.attacker = r.uint32();
5346
+ break;
5347
+ case 2:
5348
+ m.attackerPlayer = r.int32();
5349
+ break;
5350
+ case 3:
5351
+ m.heavy = r.bool();
5352
+ break;
5353
+ case 4:
5354
+ for (const e = r.run(t), a = m.hits ??= []; r.pos < e; )
5355
+ a.push(r.uint32());
5356
+ break;
5357
+ default:
5358
+ r.skip(t);
5359
+ }
5360
+ }
5361
+ return m;
5362
+ },
5363
+ encode: (m, w) => {
5364
+ {
5365
+ const v = m.attacker;
5366
+ if (v) w.uint32(8).uint32(v);
5367
+ }
5368
+ {
5369
+ const v = m.attackerPlayer;
5370
+ if (v) w.uint32(16).int32(v);
5371
+ }
5372
+ {
5373
+ const v = m.heavy;
5374
+ if (v) w.uint32(24).bool(v);
5375
+ }
5376
+ {
5377
+ const a = m.hits;
5378
+ if (a != null && a.length > 0) {
5379
+ const s = w.uint32(34).fork();
5380
+ for (const e of a) w.uint32(e);
5381
+ w.join(s);
5382
+ }
5383
+ }
5384
+ }
5385
+ }
5386
+ );
5387
+ var ParryEvent = /* @__PURE__ */ createMessageType(
5388
+ "modlock.wasm.combat.ParryEvent",
5389
+ () => [
5390
+ [1, "parrier", 13],
5391
+ [2, "player", 5],
5392
+ [3, "attacker", 13],
5393
+ [4, "attacker_player", 5]
5394
+ ],
5395
+ {
5396
+ decode: (r, end, m) => {
5397
+ while (r.pos < end) {
5398
+ const t = r.tag();
5399
+ if ((t & 7) === 4) return m;
5400
+ switch (t >>> 3) {
5401
+ case 1:
5402
+ m.parrier = r.uint32();
5403
+ break;
5404
+ case 2:
5405
+ m.player = r.int32();
5406
+ break;
5407
+ case 3:
5408
+ m.attacker = r.uint32();
5409
+ break;
5410
+ case 4:
5411
+ m.attackerPlayer = r.int32();
5412
+ break;
5413
+ default:
5414
+ r.skip(t);
5415
+ }
5416
+ }
5417
+ return m;
5418
+ },
5419
+ encode: (m, w) => {
5420
+ {
5421
+ const v = m.parrier;
5422
+ if (v) w.uint32(8).uint32(v);
5423
+ }
5424
+ {
5425
+ const v = m.player;
5426
+ if (v) w.uint32(16).int32(v);
5427
+ }
5428
+ {
5429
+ const v = m.attacker;
5430
+ if (v) w.uint32(24).uint32(v);
5431
+ }
5432
+ {
5433
+ const v = m.attackerPlayer;
5434
+ if (v) w.uint32(32).int32(v);
5435
+ }
5436
+ }
5437
+ }
5438
+ );
4957
5439
 
4958
5440
  // src/wasm/effects/effects.pb.ts
4959
5441
  var ScreenEffect_Enum = /* @__PURE__ */ createEnumType(
@@ -13252,7 +13734,8 @@ function toAbilityOptions(value) {
13252
13734
  charges: value.charges === void 0 ? void 0 : int32(value.charges),
13253
13735
  cooldownEnd: value.cooldownEnd,
13254
13736
  rechargeEnd: value.rechargeEnd,
13255
- maxCharges: value.maxCharges === void 0 ? void 0 : int32(value.maxCharges)
13737
+ maxCharges: value.maxCharges === void 0 ? void 0 : int32(value.maxCharges),
13738
+ cooldown: value.cooldown
13256
13739
  };
13257
13740
  }
13258
13741
  function fromModifier(message) {
@@ -13282,6 +13765,16 @@ function fromBuildItem(message) {
13282
13765
  annotation: message.annotation ?? ""
13283
13766
  };
13284
13767
  }
13768
+ function fromAbilityCastEvent(message) {
13769
+ return {
13770
+ caster: message.caster ?? 0,
13771
+ player: Player.of(message.player ?? 0),
13772
+ ability: message.ability ?? 0,
13773
+ name: message.name ?? "",
13774
+ slot: message.slot ?? 0,
13775
+ target: message.target ?? 0
13776
+ };
13777
+ }
13285
13778
  function fromDamageEvent(message) {
13286
13779
  return {
13287
13780
  victim: message.victim ?? 0,
@@ -13303,6 +13796,15 @@ function fromDamagedEvent(message) {
13303
13796
  dealt: message.dealt ?? 0
13304
13797
  };
13305
13798
  }
13799
+ function fromKillEvent(message) {
13800
+ return {
13801
+ victim: message.victim ?? 0,
13802
+ victimPlayer: Player.of(message.victimPlayer ?? 0),
13803
+ attacker: message.attacker ?? 0,
13804
+ attackerPlayer: Player.of(message.attackerPlayer ?? 0),
13805
+ ability: message.ability ?? 0
13806
+ };
13807
+ }
13306
13808
  function fromLaunchEvent(message) {
13307
13809
  return {
13308
13810
  entity: message.entity ?? 0,
@@ -13357,6 +13859,49 @@ function fromTraceHit(message) {
13357
13859
  entity: message.entity ?? 0
13358
13860
  };
13359
13861
  }
13862
+ function fromModifierFiredEvent(message) {
13863
+ return {
13864
+ name: message.name ?? "",
13865
+ caster: message.caster ?? 0,
13866
+ player: Player.of(message.player ?? 0),
13867
+ target: message.target ?? 0,
13868
+ ability: message.ability ?? 0
13869
+ };
13870
+ }
13871
+ function fromHealEvent(message) {
13872
+ return {
13873
+ target: message.target ?? 0,
13874
+ targetPlayer: Player.of(message.targetPlayer ?? 0),
13875
+ healer: message.healer ?? 0,
13876
+ healerPlayer: Player.of(message.healerPlayer ?? 0),
13877
+ ability: message.ability ?? 0,
13878
+ applied: message.applied ?? 0,
13879
+ requested: message.requested ?? 0
13880
+ };
13881
+ }
13882
+ function fromLevelEvent(message) {
13883
+ return {
13884
+ hero: message.hero ?? 0,
13885
+ player: Player.of(message.player ?? 0),
13886
+ level: message.level ?? 0
13887
+ };
13888
+ }
13889
+ function fromMeleeEvent(message) {
13890
+ return {
13891
+ attacker: message.attacker ?? 0,
13892
+ attackerPlayer: Player.of(message.attackerPlayer ?? 0),
13893
+ heavy: message.heavy ?? false,
13894
+ hits: message.hits ?? []
13895
+ };
13896
+ }
13897
+ function fromParryEvent(message) {
13898
+ return {
13899
+ parrier: message.parrier ?? 0,
13900
+ player: Player.of(message.player ?? 0),
13901
+ attacker: message.attacker ?? 0,
13902
+ attackerPlayer: Player.of(message.attackerPlayer ?? 0)
13903
+ };
13904
+ }
13360
13905
  function toSoundOptions(value) {
13361
13906
  return {
13362
13907
  volume: value.volume,
@@ -13765,6 +14310,22 @@ function fromStartEvent(message) {
13765
14310
  source: message.source ?? new Uint8Array()
13766
14311
  };
13767
14312
  }
14313
+ function toStartResult(value) {
14314
+ return {
14315
+ frames: value.frames,
14316
+ damage: value.damage,
14317
+ damaged: value.damaged,
14318
+ chat: value.chat,
14319
+ joins: value.joins,
14320
+ casts: value.casts,
14321
+ modifierEvents: value.modifierEvents?.slice(),
14322
+ kills: value.kills,
14323
+ heals: value.heals,
14324
+ levels: value.levels,
14325
+ melees: value.melees,
14326
+ parries: value.parries
14327
+ };
14328
+ }
13768
14329
  function fromFrameEvent(message) {
13769
14330
  return {
13770
14331
  tick: message.tick ?? 0n,
@@ -14672,7 +15233,7 @@ function serveMod(handlers2, bytes) {
14672
15233
  try {
14673
15234
  switch (request.method) {
14674
15235
  case "Start":
14675
- return reply(StartResult.toBinary(handlers2.start(fromStartEvent(StartEvent.fromBinary(input2)))));
15236
+ return reply(StartResult.toBinary(toStartResult(handlers2.start(fromStartEvent(StartEvent.fromBinary(input2))))));
14676
15237
  case "Frame":
14677
15238
  handlers2.frame(fromFrameEvent(FrameEvent.fromBinary(input2)));
14678
15239
  return reply();
@@ -14697,6 +15258,27 @@ function serveMod(handlers2, bytes) {
14697
15258
  case "Damaged":
14698
15259
  handlers2.damaged(fromDamagedEvent(DamagedEvent.fromBinary(input2)));
14699
15260
  return reply();
15261
+ case "Killed":
15262
+ handlers2.killed(fromKillEvent(KillEvent.fromBinary(input2)));
15263
+ return reply();
15264
+ case "AbilityCast":
15265
+ handlers2.abilityCast(fromAbilityCastEvent(AbilityCastEvent.fromBinary(input2)));
15266
+ return reply();
15267
+ case "ModifierFired":
15268
+ handlers2.modifierFired(fromModifierFiredEvent(ModifierFiredEvent.fromBinary(input2)));
15269
+ return reply();
15270
+ case "Healed":
15271
+ handlers2.healed(fromHealEvent(HealEvent.fromBinary(input2)));
15272
+ return reply();
15273
+ case "LevelChanged":
15274
+ handlers2.levelChanged(fromLevelEvent(LevelEvent.fromBinary(input2)));
15275
+ return reply();
15276
+ case "Melee":
15277
+ handlers2.melee(fromMeleeEvent(MeleeEvent.fromBinary(input2)));
15278
+ return reply();
15279
+ case "Parried":
15280
+ handlers2.parried(fromParryEvent(ParryEvent.fromBinary(input2)));
15281
+ return reply();
14700
15282
  case "Input":
14701
15283
  handlers2.input(fromInputEvent(InputEvent.fromBinary(input2)));
14702
15284
  return reply();
@@ -19035,7 +19617,9 @@ function onPlayerLeave(handler) {
19035
19617
  function onSpawn(handler) {
19036
19618
  spawns.push(handler);
19037
19619
  }
19038
- var spawned = /* @__PURE__ */ new Map();
19620
+ var respawnedEvent = "PLAYER_RESPAWNED";
19621
+ var frameCount = 0;
19622
+ var spawnedAt = /* @__PURE__ */ new Map();
19039
19623
  var seated = /* @__PURE__ */ new Map();
19040
19624
  var respawnDelay;
19041
19625
  var unseated = {};
@@ -19088,21 +19672,18 @@ function setRespawnDelay(seconds) {
19088
19672
  }
19089
19673
  startSeating();
19090
19674
  }
19091
- function watchSpawns() {
19092
- const present = /* @__PURE__ */ new Map();
19093
- for (const { player } of players()) {
19094
- const pawn = player.pawn();
19095
- if (pawn === void 0 || pawn.hero === 0 || pawn.health <= 0) {
19096
- continue;
19097
- }
19098
- present.set(player.slot, pawn.entity);
19099
- if (spawned.get(player.slot) !== pawn.entity) {
19100
- for (const handler of spawns) {
19101
- handler(player, pawn);
19102
- }
19103
- }
19675
+ function respawned(player) {
19676
+ const pawn = player.slot < 0 ? void 0 : player.pawn();
19677
+ if (pawn === void 0 || pawn.hero === 0 || pawn.health <= 0) {
19678
+ return;
19679
+ }
19680
+ if (spawnedAt.get(player.slot) === frameCount) {
19681
+ return;
19682
+ }
19683
+ spawnedAt.set(player.slot, frameCount);
19684
+ for (const handler of spawns) {
19685
+ handler(player, pawn);
19104
19686
  }
19105
- spawned = present;
19106
19687
  }
19107
19688
  function onFrame(handler) {
19108
19689
  frames.push(handler);
@@ -19125,6 +19706,29 @@ function onDamage(handler) {
19125
19706
  function onDamaged(handler) {
19126
19707
  damageds.push(handler);
19127
19708
  }
19709
+ function onKill(handler) {
19710
+ kills.push(handler);
19711
+ }
19712
+ function onAbilityCast(handler) {
19713
+ abilityCasts.push(handler);
19714
+ }
19715
+ function onHeal(handler) {
19716
+ heals.push(handler);
19717
+ }
19718
+ function onLevelChange(handler) {
19719
+ levels.push(handler);
19720
+ }
19721
+ function onMelee(handler) {
19722
+ melees.push(handler);
19723
+ }
19724
+ function onParry(handler) {
19725
+ parries.push(handler);
19726
+ }
19727
+ function onModifierEvent(name, handler) {
19728
+ const handlers2 = modifierEvents.get(name) ?? [];
19729
+ handlers2.push(handler);
19730
+ modifierEvents.set(name, handlers2);
19731
+ }
19128
19732
  function onLaunch(handler) {
19129
19733
  launches.push(handler);
19130
19734
  }
@@ -19159,6 +19763,13 @@ var restoreds = [];
19159
19763
  var npcsRestoreds = [];
19160
19764
  var damages = [];
19161
19765
  var damageds = [];
19766
+ var kills = [];
19767
+ var abilityCasts = [];
19768
+ var heals = [];
19769
+ var levels = [];
19770
+ var melees = [];
19771
+ var parries = [];
19772
+ var modifierEvents = /* @__PURE__ */ new Map();
19162
19773
  var launches = [];
19163
19774
  var impacts = [];
19164
19775
  var landeds = [];
@@ -19173,16 +19784,26 @@ var handlers = {
19173
19784
  damage: damages.length !== 0,
19174
19785
  damaged: damageds.length !== 0,
19175
19786
  chat: chats.length !== 0,
19176
- joins: joins.length !== 0 || leaves.length !== 0
19787
+ joins: joins.length !== 0 || leaves.length !== 0,
19788
+ casts: abilityCasts.length !== 0,
19789
+ kills: kills.length !== 0,
19790
+ heals: heals.length !== 0,
19791
+ levels: levels.length !== 0,
19792
+ melees: melees.length !== 0,
19793
+ parries: parries.length !== 0,
19794
+ modifierEvents: [
19795
+ .../* @__PURE__ */ new Set([
19796
+ ...modifierEvents.keys(),
19797
+ ...spawns.length !== 0 ? [respawnedEvent] : []
19798
+ ])
19799
+ ]
19177
19800
  };
19178
19801
  },
19179
19802
  frame(event) {
19180
19803
  tick(event.timeSeconds);
19181
19804
  advance(event.timeSeconds);
19182
19805
  advancePuppets(event.timeSeconds);
19183
- if (spawns.length !== 0) {
19184
- watchSpawns();
19185
- }
19806
+ frameCount++;
19186
19807
  for (const handler of frames) {
19187
19808
  handler(event);
19188
19809
  }
@@ -19241,6 +19862,44 @@ var handlers = {
19241
19862
  handler(event);
19242
19863
  }
19243
19864
  },
19865
+ killed(event) {
19866
+ for (const handler of kills) {
19867
+ handler(event);
19868
+ }
19869
+ },
19870
+ abilityCast(event) {
19871
+ for (const handler of abilityCasts) {
19872
+ handler(event);
19873
+ }
19874
+ },
19875
+ healed(event) {
19876
+ for (const handler of heals) {
19877
+ handler(event);
19878
+ }
19879
+ },
19880
+ levelChanged(event) {
19881
+ for (const handler of levels) {
19882
+ handler(event);
19883
+ }
19884
+ },
19885
+ melee(event) {
19886
+ for (const handler of melees) {
19887
+ handler(event);
19888
+ }
19889
+ },
19890
+ parried(event) {
19891
+ for (const handler of parries) {
19892
+ handler(event);
19893
+ }
19894
+ },
19895
+ modifierFired(event) {
19896
+ if (event.name === respawnedEvent && spawns.length !== 0) {
19897
+ respawned(event.player);
19898
+ }
19899
+ for (const handler of modifierEvents.get(event.name) ?? []) {
19900
+ handler(event);
19901
+ }
19902
+ },
19244
19903
  input(event) {
19245
19904
  for (const handler of inputs) {
19246
19905
  handler(event.player, event.pressed, event.released);
@@ -19402,15 +20061,22 @@ export {
19402
20061
  modifiers,
19403
20062
  moveEntity,
19404
20063
  nextMatch,
20064
+ onAbilityCast,
19405
20065
  onChat,
19406
20066
  onDamage,
19407
20067
  onDamaged,
19408
20068
  onFrame,
20069
+ onHeal,
19409
20070
  onImpact,
19410
20071
  onInput,
20072
+ onKill,
19411
20073
  onLanded,
19412
20074
  onLaunch,
20075
+ onLevelChange,
20076
+ onMelee,
20077
+ onModifierEvent,
19413
20078
  onNpcsRestored,
20079
+ onParry,
19414
20080
  onPlayerJoin,
19415
20081
  onPlayerLeave,
19416
20082
  onRestored,
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.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"
10
+ "@modlock/darwin-arm64": "0.1.84",
11
+ "@modlock/darwin-x64": "0.1.84",
12
+ "@modlock/linux-arm64": "0.1.84",
13
+ "@modlock/linux-x64": "0.1.84",
14
+ "@modlock/win32-x64": "0.1.84"
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.82"
23
+ "version": "0.1.84"
24
24
  }