@modlock/modlock 0.1.76 → 0.1.77

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
@@ -300,6 +300,21 @@ export interface TraceHit {
300
300
  /** entity is the entity hit, or zero for the world. */
301
301
  readonly entity: number;
302
302
  }
303
+ /**
304
+ * SoundOptions shape one sound; the zero value plays it to every player as
305
+ * the game made it.
306
+ */
307
+ export interface SoundOptions {
308
+ /** volume scales the sound's loudness; 1 plays it as the game made it. */
309
+ volume?: number;
310
+ /** pitch scales the sound's pitch; 1 plays it as the game made it. */
311
+ pitch?: number;
312
+ /**
313
+ * listeners are the player slots that hear the sound; empty means every
314
+ * player.
315
+ */
316
+ listeners?: readonly number[];
317
+ }
303
318
  /** ScreenTiming is a screen effect's timing in seconds. */
304
319
  export interface ScreenTiming {
305
320
  /** delay is the time before the effect starts. */
@@ -1606,9 +1621,10 @@ export declare class Player {
1606
1621
  heal(amount: number): boolean;
1607
1622
  /**
1608
1623
  * sound plays a game sound event, such as Damage.Send.Crit, on the
1609
- * player's hero.
1624
+ * player's hero, and returns its ID. It follows the hero as it moves.
1625
+ * Volume and pitch scale the sound, and listeners limit who hears it.
1610
1626
  */
1611
- sound(sound: string): boolean;
1627
+ sound(sound: string, options?: SoundOptions): number | undefined;
1612
1628
  /**
1613
1629
  * restoreHero gives the player's live hero target over the next few
1614
1630
  * seconds: the build first, then health, stamina and pose once it settles,
@@ -1628,6 +1644,11 @@ export declare class Player {
1628
1644
  * view.
1629
1645
  */
1630
1646
  clearScreenEffect(effect: ScreenEffect): boolean;
1647
+ /**
1648
+ * silenceVoice keeps the player's hero from speaking the named voice
1649
+ * concepts until called again, on top of those silenced for everyone.
1650
+ */
1651
+ silenceVoice(concepts?: readonly string[]): boolean;
1631
1652
  /** removeBot removes a bot the mod added. */
1632
1653
  removeBot(): boolean;
1633
1654
  /**
@@ -1798,6 +1819,13 @@ export declare function handedOff(): string | undefined;
1798
1819
  * world.
1799
1820
  */
1800
1821
  export declare function heroBuild(hero: string): BuildCategory[];
1822
+ /**
1823
+ * silenceVoice keeps every hero from speaking the named voice concepts,
1824
+ * until called again. A hero still hears the game's other sounds. Stopping
1825
+ * the mod lets them speak; a name the game does not know fails the call
1826
+ * and the known ones still apply.
1827
+ */
1828
+ export declare function silenceVoice(concepts?: readonly string[]): boolean;
1801
1829
  /**
1802
1830
  * readField reads one schema field of a live entity, such as the int32
1803
1831
  * m_iHealth of CBaseEntity. The host finds the field by name, so it
@@ -1831,7 +1859,9 @@ export declare function readModifierField(entity: number, modifier: string, clas
1831
1859
  * entity's panel only when it creates the entity, so a write to
1832
1860
  * m_DialogXMLName sends every client a full update on the next frame, which
1833
1861
  * creates every entity again; the players' game stalls briefly, so write a
1834
- * layout when it changes, not every frame.
1862
+ * layout when it changes, not every frame. It refuses the fields that
1863
+ * name a console line or a script, such as m_iszPrivateVScripts, here and
1864
+ * among the fields CreateEntity writes before spawn.
1835
1865
  */
1836
1866
  export declare function writeField(entity: number, className: string, field: string, type: FieldType, value: FieldValue): boolean;
1837
1867
  /**
@@ -1945,17 +1975,22 @@ export declare function remapInput(from: bigint, to: bigint, repeat?: boolean):
1945
1975
  */
1946
1976
  export declare function callService(service: string, method: string, payload: Uint8Array): Uint8Array | undefined;
1947
1977
  /**
1948
- * createEntity creates any entity the server knows by its designer name,
1978
+ * createEntity creates an entity the server knows by its designer name,
1949
1979
  * such as npc_trooper_boss or prop_dynamic, with spawn key values and fields
1950
1980
  * written before it spawns. The world removes it when the world ends;
1951
1981
  * stopping the mod removes it too. It refuses an ability, item or weapon,
1952
- * which only a hero holds: GiveItem and ReplaceAbility give one.
1982
+ * which only a hero holds: GiveItem and ReplaceAbility give one. It refuses
1983
+ * a class that runs console lines or loads scripts or entities past a mod's
1984
+ * checks, such as point_servercommand, and key values that name a console
1985
+ * line or a script, such as vscripts.
1953
1986
  */
1954
1987
  export declare function createEntity(options: EntityOptions): number | undefined;
1955
1988
  /**
1956
1989
  * fireInput sends an input to a live entity, as a map's output would, such
1957
1990
  * as Skin with the integer 1. The value must have the type the input reads.
1958
- * It reports false once the entity is gone.
1991
+ * It reports false once the entity is gone. It refuses AddOutput and the
1992
+ * script inputs on every entity, and any input to an entity of a class
1993
+ * CreateEntity refuses.
1959
1994
  */
1960
1995
  export declare function fireInput(entity: number, input: string, value?: EntityValue, activator?: number): boolean;
1961
1996
  /**
@@ -2064,8 +2099,22 @@ export declare function moveEntity(entity: number, position?: Vector, facing?: A
2064
2099
  * impulse that the simulation carries on.
2065
2100
  */
2066
2101
  export declare function pushEntity(entity: number, velocity: Vector, spin?: Vector): boolean;
2067
- /** emitSound plays one game sound on any entity, such as a projectile. */
2068
- export declare function emitSound(entity: number, sound: string): boolean;
2102
+ /**
2103
+ * emitSound plays one game sound on any entity, such as a projectile, and
2104
+ * returns its ID. Volume and pitch scale the sound, and listeners limit who
2105
+ * hears it.
2106
+ */
2107
+ export declare function emitSound(entity: number, sound: string, options?: SoundOptions): number | undefined;
2108
+ /**
2109
+ * adjustSound changes the volume or pitch of a sound Sound or EmitSound
2110
+ * started, while it plays.
2111
+ */
2112
+ export declare function adjustSound(id: number, volume?: number, pitch?: number): boolean;
2113
+ /**
2114
+ * stopSound stops a sound Sound or EmitSound started. A sound that already
2115
+ * ended is not an error.
2116
+ */
2117
+ export declare function stopSound(id: number): boolean;
2069
2118
  /**
2070
2119
  * watchProjectiles reports the projectiles with these designer names, such
2071
2120
  * as rocket_launcher_rocket_projectile, in Launch and Impact events. A new
package/index.d.ts CHANGED
@@ -16,6 +16,7 @@ export * from './host.gen.js';
16
16
  export { Cast, type CastOptions, type Want } from './cast.js';
17
17
  export { frameClock } from './frameclock.js';
18
18
  export { ground, type GroundOptions } from './ground.js';
19
+ export { RaceGate, type RaceGateOptions, raceGateResources, } from './racegate.js';
19
20
  export { players } from './players.js';
20
21
  export { afterMatch, fewestPlayed, leaderboard, leastUsed, nextMatch, ratingChange, ratingStep, settle, type Standing, Standings, startingRating, } from './rotation.js';
21
22
  export { bystanderStates, holdBystander } from './bystander.js';
package/index.js CHANGED
@@ -44,14 +44,14 @@ var BinaryWriter = class {
44
44
  this.reserve(size);
45
45
  this.buf.copyWithin(start + size, start, this.pos);
46
46
  this.pos += size;
47
- let at2 = start;
47
+ let at3 = start;
48
48
  let rest = length3;
49
49
  while (rest > 127) {
50
- this.buf[at2] = rest & 127 | 128;
51
- at2 += 1;
50
+ this.buf[at3] = rest & 127 | 128;
51
+ at3 += 1;
52
52
  rest >>>= 7;
53
53
  }
54
- this.buf[at2] = rest;
54
+ this.buf[at3] = rest;
55
55
  return this;
56
56
  }
57
57
  /** Write a field's tag: its number and wire type. */
@@ -3274,37 +3274,37 @@ function encodeCall(method, request) {
3274
3274
  prefix.length + 1 + varintSize(request.length) + request.length
3275
3275
  );
3276
3276
  out.set(prefix, 0);
3277
- let at2 = prefix.length;
3278
- out[at2++] = 18;
3277
+ let at3 = prefix.length;
3278
+ out[at3++] = 18;
3279
3279
  let size = request.length;
3280
- for (; size > 127; size >>>= 7) out[at2++] = size & 127 | 128;
3281
- out[at2++] = size;
3282
- out.set(request, at2);
3280
+ for (; size > 127; size >>>= 7) out[at3++] = size & 127 | 128;
3281
+ out[at3++] = size;
3282
+ out.set(request, at3);
3283
3283
  return out;
3284
3284
  }
3285
3285
  var empty = new Uint8Array();
3286
3286
  function decodeReply(reply2) {
3287
3287
  let response = empty;
3288
- let at2 = 0;
3289
- while (at2 < reply2.length) {
3290
- const tag = reply2[at2++] ?? 255;
3288
+ let at3 = 0;
3289
+ while (at3 < reply2.length) {
3290
+ const tag = reply2[at3++] ?? 255;
3291
3291
  if (tag > 127) return fallbackReply(reply2);
3292
3292
  let value = 0;
3293
3293
  let shift = 0;
3294
3294
  for (; ; ) {
3295
- if (at2 >= reply2.length || shift > 28) return fallbackReply(reply2);
3296
- const b = reply2[at2++] ?? 0;
3295
+ if (at3 >= reply2.length || shift > 28) return fallbackReply(reply2);
3296
+ const b = reply2[at3++] ?? 0;
3297
3297
  value += (b & 127) * 2 ** shift;
3298
3298
  shift += 7;
3299
3299
  if (b < 128) break;
3300
3300
  }
3301
3301
  const wire = tag & 7;
3302
3302
  if (wire === 0) continue;
3303
- if (wire !== 2 || at2 + value > reply2.length) return fallbackReply(reply2);
3303
+ if (wire !== 2 || at3 + value > reply2.length) return fallbackReply(reply2);
3304
3304
  const field = tag >>> 3;
3305
3305
  if (field === 1 && value > 0) return void 0;
3306
- if (field === 2) response = reply2.subarray(at2, at2 + value);
3307
- at2 += value;
3306
+ if (field === 2) response = reply2.subarray(at3, at3 + value);
3307
+ at3 += value;
3308
3308
  }
3309
3309
  return response;
3310
3310
  }
@@ -4867,11 +4867,61 @@ var AnnounceRequest = /* @__PURE__ */ createMessageType(
4867
4867
  }
4868
4868
  }
4869
4869
  );
4870
+ var SoundOptions = /* @__PURE__ */ createMessageType(
4871
+ "modlock.wasm.effects.SoundOptions",
4872
+ () => [
4873
+ [1, "volume", 2, 4],
4874
+ [2, "pitch", 2, 4],
4875
+ [3, "listeners", 5, 3]
4876
+ ],
4877
+ {
4878
+ decode: (r, end, m) => {
4879
+ while (r.pos < end) {
4880
+ const t = r.tag();
4881
+ if ((t & 7) === 4) return m;
4882
+ switch (t >>> 3) {
4883
+ case 1:
4884
+ m.volume = r.float();
4885
+ break;
4886
+ case 2:
4887
+ m.pitch = r.float();
4888
+ break;
4889
+ case 3:
4890
+ for (const e = r.run(t), a = m.listeners ??= []; r.pos < e; )
4891
+ a.push(r.int32());
4892
+ break;
4893
+ default:
4894
+ r.skip(t);
4895
+ }
4896
+ }
4897
+ return m;
4898
+ },
4899
+ encode: (m, w) => {
4900
+ {
4901
+ const v = m.volume;
4902
+ if (v != null) w.uint32(13).float(v);
4903
+ }
4904
+ {
4905
+ const v = m.pitch;
4906
+ if (v != null) w.uint32(21).float(v);
4907
+ }
4908
+ {
4909
+ const a = m.listeners;
4910
+ if (a != null && a.length > 0) {
4911
+ const s = w.uint32(26).fork();
4912
+ for (const e of a) w.int32(e);
4913
+ w.join(s);
4914
+ }
4915
+ }
4916
+ }
4917
+ }
4918
+ );
4870
4919
  var SoundRequest = /* @__PURE__ */ createMessageType(
4871
4920
  "modlock.wasm.effects.SoundRequest",
4872
4921
  () => [
4873
4922
  [1, "player", 5],
4874
- [2, "sound", 9]
4923
+ [2, "sound", 9],
4924
+ [3, "options", 11, 0, SoundOptions.codec]
4875
4925
  ],
4876
4926
  {
4877
4927
  decode: (r, end, m) => {
@@ -4885,6 +4935,9 @@ var SoundRequest = /* @__PURE__ */ createMessageType(
4885
4935
  case 2:
4886
4936
  m.sound = r.string();
4887
4937
  break;
4938
+ case 3:
4939
+ m.options = SoundOptions.decode(r, r.delimited(), m.options ?? {});
4940
+ break;
4888
4941
  default:
4889
4942
  r.skip(t);
4890
4943
  }
@@ -4900,6 +4953,10 @@ var SoundRequest = /* @__PURE__ */ createMessageType(
4900
4953
  const v = m.sound;
4901
4954
  if (v) w.uint32(18).string(v);
4902
4955
  }
4956
+ {
4957
+ const v = m.options;
4958
+ if (v != null) SoundOptions.writeField(w, 3, v);
4959
+ }
4903
4960
  }
4904
4961
  }
4905
4962
  );
@@ -4907,7 +4964,8 @@ var EmitSoundRequest = /* @__PURE__ */ createMessageType(
4907
4964
  "modlock.wasm.effects.EmitSoundRequest",
4908
4965
  () => [
4909
4966
  [1, "entity", 13],
4910
- [2, "sound", 9]
4967
+ [2, "sound", 9],
4968
+ [3, "options", 11, 0, SoundOptions.codec]
4911
4969
  ],
4912
4970
  {
4913
4971
  decode: (r, end, m) => {
@@ -4921,6 +4979,9 @@ var EmitSoundRequest = /* @__PURE__ */ createMessageType(
4921
4979
  case 2:
4922
4980
  m.sound = r.string();
4923
4981
  break;
4982
+ case 3:
4983
+ m.options = SoundOptions.decode(r, r.delimited(), m.options ?? {});
4984
+ break;
4924
4985
  default:
4925
4986
  r.skip(t);
4926
4987
  }
@@ -4936,6 +4997,106 @@ var EmitSoundRequest = /* @__PURE__ */ createMessageType(
4936
4997
  const v = m.sound;
4937
4998
  if (v) w.uint32(18).string(v);
4938
4999
  }
5000
+ {
5001
+ const v = m.options;
5002
+ if (v != null) SoundOptions.writeField(w, 3, v);
5003
+ }
5004
+ }
5005
+ }
5006
+ );
5007
+ var SoundResponse = /* @__PURE__ */ createMessageType(
5008
+ "modlock.wasm.effects.SoundResponse",
5009
+ () => [[1, "id", 13]],
5010
+ {
5011
+ decode: (r, end, m) => {
5012
+ while (r.pos < end) {
5013
+ const t = r.tag();
5014
+ if ((t & 7) === 4) return m;
5015
+ switch (t >>> 3) {
5016
+ case 1:
5017
+ m.id = r.uint32();
5018
+ break;
5019
+ default:
5020
+ r.skip(t);
5021
+ }
5022
+ }
5023
+ return m;
5024
+ },
5025
+ encode: (m, w) => {
5026
+ {
5027
+ const v = m.id;
5028
+ if (v) w.uint32(8).uint32(v);
5029
+ }
5030
+ }
5031
+ }
5032
+ );
5033
+ var AdjustSoundRequest = /* @__PURE__ */ createMessageType(
5034
+ "modlock.wasm.effects.AdjustSoundRequest",
5035
+ () => [
5036
+ [1, "id", 13],
5037
+ [2, "volume", 2, 4],
5038
+ [3, "pitch", 2, 4]
5039
+ ],
5040
+ {
5041
+ decode: (r, end, m) => {
5042
+ while (r.pos < end) {
5043
+ const t = r.tag();
5044
+ if ((t & 7) === 4) return m;
5045
+ switch (t >>> 3) {
5046
+ case 1:
5047
+ m.id = r.uint32();
5048
+ break;
5049
+ case 2:
5050
+ m.volume = r.float();
5051
+ break;
5052
+ case 3:
5053
+ m.pitch = r.float();
5054
+ break;
5055
+ default:
5056
+ r.skip(t);
5057
+ }
5058
+ }
5059
+ return m;
5060
+ },
5061
+ encode: (m, w) => {
5062
+ {
5063
+ const v = m.id;
5064
+ if (v) w.uint32(8).uint32(v);
5065
+ }
5066
+ {
5067
+ const v = m.volume;
5068
+ if (v != null) w.uint32(21).float(v);
5069
+ }
5070
+ {
5071
+ const v = m.pitch;
5072
+ if (v != null) w.uint32(29).float(v);
5073
+ }
5074
+ }
5075
+ }
5076
+ );
5077
+ var StopSoundRequest = /* @__PURE__ */ createMessageType(
5078
+ "modlock.wasm.effects.StopSoundRequest",
5079
+ () => [[1, "id", 13]],
5080
+ {
5081
+ decode: (r, end, m) => {
5082
+ while (r.pos < end) {
5083
+ const t = r.tag();
5084
+ if ((t & 7) === 4) return m;
5085
+ switch (t >>> 3) {
5086
+ case 1:
5087
+ m.id = r.uint32();
5088
+ break;
5089
+ default:
5090
+ r.skip(t);
5091
+ }
5092
+ }
5093
+ return m;
5094
+ },
5095
+ encode: (m, w) => {
5096
+ {
5097
+ const v = m.id;
5098
+ if (v) w.uint32(8).uint32(v);
5099
+ }
4939
5100
  }
4940
5101
  }
4941
5102
  );
@@ -5071,6 +5232,70 @@ var ClearScreenEffectRequest = /* @__PURE__ */ createMessageType(
5071
5232
  }
5072
5233
  }
5073
5234
  );
5235
+ var SilenceVoiceRequest = /* @__PURE__ */ createMessageType(
5236
+ "modlock.wasm.effects.SilenceVoiceRequest",
5237
+ () => [[1, "concepts", 9, 1]],
5238
+ {
5239
+ decode: (r, end, m) => {
5240
+ while (r.pos < end) {
5241
+ const t = r.tag();
5242
+ if ((t & 7) === 4) return m;
5243
+ switch (t >>> 3) {
5244
+ case 1:
5245
+ ;
5246
+ (m.concepts ??= []).push(r.string());
5247
+ break;
5248
+ default:
5249
+ r.skip(t);
5250
+ }
5251
+ }
5252
+ return m;
5253
+ },
5254
+ encode: (m, w) => {
5255
+ {
5256
+ const a = m.concepts;
5257
+ if (a != null) for (const e of a) w.uint32(10).string(e);
5258
+ }
5259
+ }
5260
+ }
5261
+ );
5262
+ var SilencePlayerVoiceRequest = /* @__PURE__ */ createMessageType(
5263
+ "modlock.wasm.effects.SilencePlayerVoiceRequest",
5264
+ () => [
5265
+ [1, "player", 5],
5266
+ [2, "concepts", 9, 1]
5267
+ ],
5268
+ {
5269
+ decode: (r, end, m) => {
5270
+ while (r.pos < end) {
5271
+ const t = r.tag();
5272
+ if ((t & 7) === 4) return m;
5273
+ switch (t >>> 3) {
5274
+ case 1:
5275
+ m.player = r.int32();
5276
+ break;
5277
+ case 2:
5278
+ ;
5279
+ (m.concepts ??= []).push(r.string());
5280
+ break;
5281
+ default:
5282
+ r.skip(t);
5283
+ }
5284
+ }
5285
+ return m;
5286
+ },
5287
+ encode: (m, w) => {
5288
+ {
5289
+ const v = m.player;
5290
+ if (v) w.uint32(8).int32(v);
5291
+ }
5292
+ {
5293
+ const a = m.concepts;
5294
+ if (a != null) for (const e of a) w.uint32(18).string(e);
5295
+ }
5296
+ }
5297
+ }
5298
+ );
5074
5299
 
5075
5300
  // src/wasm/fields/fields.pb.ts
5076
5301
  var FieldType_Enum = /* @__PURE__ */ createEnumType(
@@ -12610,6 +12835,13 @@ function fromTraceHit(message) {
12610
12835
  entity: message.entity ?? 0
12611
12836
  };
12612
12837
  }
12838
+ function toSoundOptions(value) {
12839
+ return {
12840
+ volume: value.volume,
12841
+ pitch: value.pitch,
12842
+ listeners: value.listeners?.map((v) => int32(v))
12843
+ };
12844
+ }
12613
12845
  function toFieldValue(value) {
12614
12846
  return { value: typeof value === "boolean" ? { case: "boolean", value } : typeof value === "number" ? { case: "number", value } : typeof value === "bigint" ? { case: "integer", value } : typeof value === "string" ? { case: "text", value } : typeof value === "object" ? { case: "vector", value } : void 0 };
12615
12847
  }
@@ -13426,10 +13658,14 @@ var Player = class _Player {
13426
13658
  }
13427
13659
  /**
13428
13660
  * sound plays a game sound event, such as Damage.Send.Crit, on the
13429
- * player's hero.
13661
+ * player's hero, and returns its ID. It follows the hero as it moves.
13662
+ * Volume and pitch scale the sound, and listeners limit who hears it.
13430
13663
  */
13431
- sound(sound) {
13432
- return call("Sound", SoundRequest.toBinary({ player: this.slot, sound })) !== void 0;
13664
+ sound(sound, options) {
13665
+ const reply2 = call("Sound", SoundRequest.toBinary({ player: this.slot, sound, options: options === void 0 ? void 0 : toSoundOptions(options) }));
13666
+ if (reply2 === void 0) return void 0;
13667
+ const response = SoundResponse.fromBinary(reply2);
13668
+ return response.id ?? 0;
13433
13669
  }
13434
13670
  /**
13435
13671
  * restoreHero gives the player's live hero target over the next few
@@ -13456,6 +13692,13 @@ var Player = class _Player {
13456
13692
  clearScreenEffect(effect) {
13457
13693
  return call("ClearScreenEffect", ClearScreenEffectRequest.toBinary({ player: this.slot, effect: screenEffectValues[effect] })) !== void 0;
13458
13694
  }
13695
+ /**
13696
+ * silenceVoice keeps the player's hero from speaking the named voice
13697
+ * concepts until called again, on top of those silenced for everyone.
13698
+ */
13699
+ silenceVoice(concepts) {
13700
+ return call("SilencePlayerVoice", SilencePlayerVoiceRequest.toBinary({ player: this.slot, concepts: concepts?.slice() })) !== void 0;
13701
+ }
13459
13702
  /** removeBot removes a bot the mod added. */
13460
13703
  removeBot() {
13461
13704
  return call("RemoveBot", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
@@ -13670,6 +13913,9 @@ function heroBuild(hero) {
13670
13913
  const response = HeroBuildResponse.fromBinary(reply2);
13671
13914
  return (response.categories ?? []).map((v) => fromBuildCategory(v));
13672
13915
  }
13916
+ function silenceVoice(concepts) {
13917
+ return call("SilenceVoice", SilenceVoiceRequest.toBinary({ concepts: concepts?.slice() })) !== void 0;
13918
+ }
13673
13919
  function readField(entity, className, field, type) {
13674
13920
  const reply2 = call("ReadField", ReadFieldRequest.toBinary({ entity, className, field, type: fieldTypeValues[type] }));
13675
13921
  if (reply2 === void 0) return void 0;
@@ -13871,8 +14117,17 @@ function moveEntity(entity, position, facing, velocity) {
13871
14117
  function pushEntity(entity, velocity, spin) {
13872
14118
  return call("PushEntity", PushEntityRequest.toBinary({ entity, velocity, spin })) !== void 0;
13873
14119
  }
13874
- function emitSound(entity, sound) {
13875
- return call("EmitSound", EmitSoundRequest.toBinary({ entity, sound })) !== void 0;
14120
+ function emitSound(entity, sound, options) {
14121
+ const reply2 = call("EmitSound", EmitSoundRequest.toBinary({ entity, sound, options: options === void 0 ? void 0 : toSoundOptions(options) }));
14122
+ if (reply2 === void 0) return void 0;
14123
+ const response = SoundResponse.fromBinary(reply2);
14124
+ return response.id ?? 0;
14125
+ }
14126
+ function adjustSound(id, volume, pitch) {
14127
+ return call("AdjustSound", AdjustSoundRequest.toBinary({ id, volume, pitch })) !== void 0;
14128
+ }
14129
+ function stopSound(id) {
14130
+ return call("StopSound", StopSoundRequest.toBinary({ id })) !== void 0;
13876
14131
  }
13877
14132
  function watchProjectiles(options) {
13878
14133
  return call("WatchProjectiles", ProjectileOptions.toBinary(toProjectileOptions(options))) !== void 0;
@@ -14007,10 +14262,10 @@ function lerpAngle(a, b, t) {
14007
14262
  function poseAt(track, tick2) {
14008
14263
  const last = track.x.length - 1;
14009
14264
  if (last < 0) return void 0;
14010
- const at2 = Math.min(Math.max(tick2 / track.stepTicks, 0), last);
14011
- const i = Math.min(Math.floor(at2), Math.max(last - 1, 0));
14265
+ const at3 = Math.min(Math.max(tick2 / track.stepTicks, 0), last);
14266
+ const i = Math.min(Math.floor(at3), Math.max(last - 1, 0));
14012
14267
  const j = Math.min(i + 1, last);
14013
- const t = at2 - i;
14268
+ const t = at3 - i;
14014
14269
  const seconds = track.stepTicks / ticksPerSecond;
14015
14270
  const blend = (column) => lerp(sample(column, i), sample(column, j), t);
14016
14271
  const slope = (column) => (sample(column, j) - sample(column, i)) / seconds;
@@ -14191,12 +14446,12 @@ var Puppet = class _Puppet {
14191
14446
  const pose = poseAt(this.track, this.tickAt);
14192
14447
  if (!pawn || !pose) return;
14193
14448
  this.syncLook(pawn.entity);
14194
- const gap = Math.hypot(
14449
+ const gap2 = Math.hypot(
14195
14450
  pose.position.x - pawn.position.x,
14196
14451
  pose.position.y - pawn.position.y,
14197
14452
  pose.position.z - pawn.position.z
14198
14453
  );
14199
- const placed = gap > this.snapUnits || this.current !== "playing" ? this.player.teleport(pose.position, pose.facing) : this.player.move(pose.position, pose.facing, pose.velocity);
14454
+ const placed = gap2 > this.snapUnits || this.current !== "playing" ? this.player.teleport(pose.position, pose.facing) : this.player.move(pose.position, pose.facing, pose.velocity);
14200
14455
  if (placed) this.drawn = true;
14201
14456
  this.setHealth(pawn.entity, pose.health);
14202
14457
  }
@@ -14341,7 +14596,7 @@ function advance(seconds) {
14341
14596
  function itemId(name) {
14342
14597
  const m = 1540483477;
14343
14598
  const data = new TextEncoder().encode(name);
14344
- const byte = (at2) => data[at2] ?? 0;
14599
+ const byte = (at3) => data[at3] ?? 0;
14345
14600
  let h = (826366246 ^ data.length) >>> 0;
14346
14601
  let i = 0;
14347
14602
  for (; data.length - i >= 4; i += 4) {
@@ -14950,7 +15205,7 @@ var Layout = class {
14950
15205
  return found;
14951
15206
  }
14952
15207
  };
14953
- function place(layout, child, at2) {
15208
+ function place(layout, child, at3) {
14954
15209
  if (child === null || child === void 0 || typeof child === "boolean") {
14955
15210
  return [];
14956
15211
  }
@@ -14960,13 +15215,13 @@ function place(layout, child, at2) {
14960
15215
  return place(
14961
15216
  layout,
14962
15217
  item2,
14963
- key === void 0 ? `${at2},${index}` : `${at2},=${key}`
15218
+ key === void 0 ? `${at3},${index}` : `${at3},=${key}`
14964
15219
  );
14965
15220
  });
14966
15221
  }
14967
15222
  if (!isElement(child)) {
14968
15223
  const node2 = {
14969
- id: layout.id(at2),
15224
+ id: layout.id(at3),
14970
15225
  kind: 1 /* LABEL */,
14971
15226
  text: String(child)
14972
15227
  };
@@ -14974,11 +15229,11 @@ function place(layout, child, at2) {
14974
15229
  return [node2.id];
14975
15230
  }
14976
15231
  if (child.type === fragment) {
14977
- return place(layout, child.props.children, `${at2}>`);
15232
+ return place(layout, child.props.children, `${at3}>`);
14978
15233
  }
14979
15234
  const props = child.props;
14980
15235
  const node = {
14981
- id: layout.id(at2),
15236
+ id: layout.id(at3),
14982
15237
  style: wireStyle(props.style),
14983
15238
  hover: wireStyle(props.hover),
14984
15239
  tooltip: props.tooltip,
@@ -15026,7 +15281,7 @@ function place(layout, child, at2) {
15026
15281
  if (props.onPress && !props.disabled) {
15027
15282
  layout.screen.presses.set(node.id, { handler: props.onPress });
15028
15283
  }
15029
- node.children = place(layout, props.children, `${at2}/`);
15284
+ node.children = place(layout, props.children, `${at3}/`);
15030
15285
  break;
15031
15286
  case "layout":
15032
15287
  node.kind = 4 /* LAYOUT */;
@@ -15035,7 +15290,7 @@ function place(layout, child, at2) {
15035
15290
  break;
15036
15291
  default:
15037
15292
  node.kind = 0 /* PANEL */;
15038
- node.children = place(layout, props.children, `${at2}/`);
15293
+ node.children = place(layout, props.children, `${at3}/`);
15039
15294
  }
15040
15295
  layout.add(node);
15041
15296
  return [node.id];
@@ -15558,8 +15813,8 @@ var ease = {
15558
15813
  return k * (t - 2.625 / 2.75) ** 2 + 0.984375;
15559
15814
  })
15560
15815
  };
15561
- function shaped(at2, lerp3) {
15562
- return { at: at2, lerp: lerp3 };
15816
+ function shaped(at3, lerp3) {
15817
+ return { at: at3, lerp: lerp3 };
15563
15818
  }
15564
15819
  function line(from, to, duration, shape = ease.linear) {
15565
15820
  return [{ duration, lerp: shape.lerp, at: (u) => mix(from, to, shape.at(u)) }];
@@ -15590,12 +15845,12 @@ function keyframes(keys, options = {}) {
15590
15845
  return spans;
15591
15846
  }
15592
15847
  function through(points, options) {
15593
- let at2 = 0;
15848
+ let at3 = 0;
15594
15849
  let last = points[0];
15595
15850
  const keys = points.map((value) => {
15596
- if (last !== void 0) at2 += distance2(last, value) / options.speed;
15851
+ if (last !== void 0) at3 += distance2(last, value) / options.speed;
15597
15852
  last = value;
15598
- return { at: at2, value, ease: options.ease };
15853
+ return { at: at3, value, ease: options.ease };
15599
15854
  });
15600
15855
  return keyframes(keys, options);
15601
15856
  }
@@ -16329,7 +16584,7 @@ function Banner(props) {
16329
16584
  return arriving(banner, { scale: 0.92 });
16330
16585
  }
16331
16586
  function TopStrip(props) {
16332
- const block = [
16587
+ const block2 = [
16333
16588
  props.heading && Text({
16334
16589
  role: "label",
16335
16590
  style: { letterSpacing: 1 },
@@ -16348,9 +16603,9 @@ function TopStrip(props) {
16348
16603
  { flow: "down", horizontalAlign: "center", margin: [top, 0, 0, 0] },
16349
16604
  children
16350
16605
  );
16351
- if (!props.keepTeamBar) return column(14, [...block, line2]);
16606
+ if (!props.keepTeamBar) return column(14, [...block2, line2]);
16352
16607
  return element("panel", { width: "fill", height: "fill" }, [
16353
- column(teamBarBottom, block),
16608
+ column(teamBarBottom, block2),
16354
16609
  line2 && column(objectiveBarBottom, line2)
16355
16610
  ]);
16356
16611
  }
@@ -16827,6 +17082,185 @@ function ground(point, {
16827
17082
  return hit && !hit.startSolid ? hit.position : void 0;
16828
17083
  }
16829
17084
 
17085
+ // js/src/racegate.ts
17086
+ var cell = 8;
17087
+ var margin = 3;
17088
+ var block = "\u25A0";
17089
+ var gap = "\u3000";
17090
+ var blockScale = 4.05;
17091
+ var inkSpread = 0.6;
17092
+ var inkDepth = 0.15;
17093
+ var columnRise = 1.75;
17094
+ var rowAcross = -1.2;
17095
+ var rowRise = 0.5;
17096
+ var frameWidth = 2;
17097
+ var railInset = 8;
17098
+ var railAlpha = 96;
17099
+ var tron = 1056243711;
17100
+ var tronFaded = 342915839;
17101
+ var anchorParticle = "particles/generic/null.vpcf";
17102
+ var beamMaterial = "materials/physics/wireframe_basic.vmat";
17103
+ var raceGateResources = [anchorParticle, beamMaterial];
17104
+ var nextPoint = 0;
17105
+ var RaceGate = class _RaceGate {
17106
+ constructor(objects, entities) {
17107
+ this.objects = objects;
17108
+ this.entities = entities;
17109
+ }
17110
+ objects;
17111
+ entities;
17112
+ /**
17113
+ * stand stands a gate across yaw at foot. A part the world refuses is left
17114
+ * out, so the gate stands whatever the world made.
17115
+ */
17116
+ static stand(options) {
17117
+ const radians = options.yaw * Math.PI / 180;
17118
+ const halfWidth = Math.round((options.width ?? 112) / cell / 2) * cell;
17119
+ const height = Math.round((options.height ?? 144) / cell) * cell;
17120
+ const color2 = options.color ?? tron;
17121
+ const plane = {
17122
+ foot: options.foot,
17123
+ yaw: radians,
17124
+ across: { x: -Math.sin(radians), y: Math.cos(radians) }
17125
+ };
17126
+ const made = { objects: [], entities: [] };
17127
+ const rail = (color2 & ~255 | railAlpha) >>> 0;
17128
+ outline(plane, halfWidth, height, 0, color2, frameWidth, made);
17129
+ outline(plane, halfWidth, height, railInset, rail, frameWidth / 2, made);
17130
+ band(plane, halfWidth, height, color2, options.faded ?? tronFaded, made);
17131
+ if (options.viewer !== void 0) {
17132
+ const viewers = [options.viewer];
17133
+ made.objects.forEach((object) => object.showOnlyTo(viewers));
17134
+ made.entities.forEach((entity) => showEntityOnlyTo(entity, viewers));
17135
+ }
17136
+ return new _RaceGate(made.objects, made.entities);
17137
+ }
17138
+ /** remove takes every part of the gate out of the world. */
17139
+ remove() {
17140
+ this.entities.forEach((entity) => removeEntity(entity));
17141
+ this.objects.forEach((object) => object.remove());
17142
+ this.objects.length = 0;
17143
+ this.entities.length = 0;
17144
+ }
17145
+ };
17146
+ function at2(plane, side, up, deep = 0) {
17147
+ return {
17148
+ x: plane.foot.x + side * plane.across.x + Math.cos(plane.yaw) * deep,
17149
+ y: plane.foot.y + side * plane.across.y + Math.sin(plane.yaw) * deep,
17150
+ z: plane.foot.z + up
17151
+ };
17152
+ }
17153
+ function band(plane, halfWidth, height, lit, faded, made) {
17154
+ const width = halfWidth + margin * cell;
17155
+ const columns = width * 2 / cell;
17156
+ const openingRows = height / cell;
17157
+ const rows = openingRows + margin;
17158
+ for (let column = 0; column < columns; column++) {
17159
+ if (column >= margin && column < columns - margin) continue;
17160
+ const first = rows - 2 - (column + rows - 2) % 2;
17161
+ const count2 = Math.floor(first / 2) + 1;
17162
+ const outer = column === 0 || column === columns - 1;
17163
+ strip(plane, {
17164
+ text: Array(count2).fill(block).join(gap),
17165
+ side: -width + (column + 0.5) * cell,
17166
+ up: (first + 1) * cell + columnRise,
17167
+ pitch: 90,
17168
+ color: outer ? faded : lit,
17169
+ made
17170
+ });
17171
+ }
17172
+ for (let row2 = openingRows; row2 < rows; row2++) {
17173
+ const outer = row2 === rows - 1;
17174
+ const start = outer ? 0 : margin;
17175
+ const end = outer ? columns : columns - margin;
17176
+ const first = start + (start + row2) % 2;
17177
+ const count2 = Math.ceil((end - first) / 2);
17178
+ strip(plane, {
17179
+ text: Array(count2).fill(block).join(gap),
17180
+ side: -width + (first + count2 - 0.5) * cell + rowAcross,
17181
+ up: (row2 + 0.5) * cell + rowRise,
17182
+ pitch: 0,
17183
+ color: outer ? faded : lit,
17184
+ made
17185
+ });
17186
+ }
17187
+ }
17188
+ function strip(plane, { text: text2, side, up, pitch, color: color2, made }) {
17189
+ const yaw = plane.yaw * 180 / Math.PI - 90;
17190
+ for (const dx of [-1, 1]) {
17191
+ for (const dy of [-1, 1]) {
17192
+ const shown = createText({
17193
+ text: text2,
17194
+ position: at2(
17195
+ plane,
17196
+ side + dx * inkSpread,
17197
+ up + dy * inkSpread,
17198
+ inkDepth * (dx + 2 * dy + 3) / 2
17199
+ ),
17200
+ facing: { pitch, yaw, roll: 90 },
17201
+ fontSize: 100,
17202
+ scale: blockScale,
17203
+ color: color2,
17204
+ align: pitch === 90 ? "left" : "center",
17205
+ verticalAlign: "center"
17206
+ });
17207
+ if (shown) made.objects.push(shown);
17208
+ }
17209
+ }
17210
+ }
17211
+ function outline(plane, halfWidth, height, inset, color2, width, made) {
17212
+ const corners = [
17213
+ at2(plane, -(halfWidth - inset), inset),
17214
+ at2(plane, halfWidth - inset, inset),
17215
+ at2(plane, halfWidth - inset, height - inset),
17216
+ at2(plane, -(halfWidth - inset), height - inset)
17217
+ ];
17218
+ const names = corners.map((corner) => anchor(corner, made));
17219
+ if (names.some((name) => name === void 0)) return;
17220
+ corners.forEach((corner, index) => {
17221
+ const beam = createEntity({
17222
+ designerName: "env_beam",
17223
+ subclass: "",
17224
+ team: 0,
17225
+ position: corner,
17226
+ keyValues: [
17227
+ { key: "LightningStart", value: { text: names[index] } },
17228
+ { key: "LightningEnd", value: { text: names[(index + 1) % 4] } },
17229
+ { key: "texture", value: { text: beamMaterial } },
17230
+ { key: "BoltWidth", value: { number: width } },
17231
+ { key: "NoiseAmplitude", value: { number: 0 } },
17232
+ { key: "TextureScroll", value: { integer: 0 } },
17233
+ { key: "life", value: { number: 0 } },
17234
+ { key: "rendercolor", value: { color: color2 } },
17235
+ { key: "renderamt", value: { integer: 255 } },
17236
+ { key: "spawnflags", value: { integer: 1 } }
17237
+ ]
17238
+ });
17239
+ if (beam) made.entities.push(beam);
17240
+ });
17241
+ }
17242
+ function anchor(position, made) {
17243
+ const carrier = createParticle({ resource: anchorParticle, position });
17244
+ const host2 = carrier?.entity();
17245
+ if (!carrier || !host2) {
17246
+ carrier?.remove();
17247
+ return void 0;
17248
+ }
17249
+ made.objects.push(carrier);
17250
+ const name = `racegate_${host2}_${nextPoint++}`;
17251
+ const point = createEntity({
17252
+ designerName: "info_particle_system",
17253
+ subclass: "",
17254
+ team: 0,
17255
+ position,
17256
+ keyValues: [{ key: "targetname", value: { text: name } }]
17257
+ });
17258
+ if (!point) return void 0;
17259
+ made.entities.push(point);
17260
+ fireInput(point, "SetParent", { text: "!activator" }, host2);
17261
+ return name;
17262
+ }
17263
+
16830
17264
  // js/src/rotation.ts
16831
17265
  var startingRating = 1e3;
16832
17266
  var ratingStep = 32;
@@ -18533,6 +18967,7 @@ export {
18533
18967
  Player,
18534
18968
  ProbeRun,
18535
18969
  Puppet,
18970
+ RaceGate,
18536
18971
  Roster,
18537
18972
  Score2 as Score,
18538
18973
  Standings,
@@ -18544,6 +18979,7 @@ export {
18544
18979
  abilityBarPresses,
18545
18980
  abilityDisplay,
18546
18981
  addBot,
18982
+ adjustSound,
18547
18983
  after,
18548
18984
  afterMatch,
18549
18985
  blockInput,
@@ -18628,6 +19064,7 @@ export {
18628
19064
  poseAt,
18629
19065
  precache,
18630
19066
  pushEntity,
19067
+ raceGateResources,
18631
19068
  ratingChange,
18632
19069
  ratingStep,
18633
19070
  readBoard,
@@ -18661,9 +19098,11 @@ export {
18661
19098
  show,
18662
19099
  showEntityOnlyTo,
18663
19100
  showEntityToAll,
19101
+ silenceVoice,
18664
19102
  spawnNpc,
18665
19103
  startRift,
18666
19104
  startingRating,
19105
+ stopSound,
18667
19106
  strayGraceSeconds,
18668
19107
  theme_exports as theme,
18669
19108
  ticksPerSecond,
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.76",
11
- "@modlock/darwin-x64": "0.1.76",
12
- "@modlock/linux-arm64": "0.1.76",
13
- "@modlock/linux-x64": "0.1.76",
14
- "@modlock/win32-x64": "0.1.76"
10
+ "@modlock/darwin-arm64": "0.1.77",
11
+ "@modlock/darwin-x64": "0.1.77",
12
+ "@modlock/linux-arm64": "0.1.77",
13
+ "@modlock/linux-x64": "0.1.77",
14
+ "@modlock/win32-x64": "0.1.77"
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.76"
23
+ "version": "0.1.77"
24
24
  }
package/racegate.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ import { type Vector } from './host.gen.js';
2
+ /** RaceGateOptions place a gate and choose its look; most have a default. */
3
+ export interface RaceGateOptions {
4
+ /** foot is the road point under the middle of the gate's opening. */
5
+ readonly foot: Vector;
6
+ /** yaw is the direction a runner passes through the gate, in degrees. */
7
+ readonly yaw: number;
8
+ /** width is the opening's width, 112 units by default, in whole cells. */
9
+ readonly width?: number;
10
+ /** height is the opening's height, 144 units by default, in whole cells. */
11
+ readonly height?: number;
12
+ /** color lights the window and the band, 0xRRGGBBAA, Tron cyan by default. */
13
+ readonly color?: number;
14
+ /** faded colors the band's outer ring, a darker cyan by default. */
15
+ readonly faded?: number;
16
+ /** viewer is the one player slot that sees the gate; everyone when unset. */
17
+ readonly viewer?: number;
18
+ }
19
+ /** raceGateResources are what a gate draws with, for a mod's precache. */
20
+ export declare const raceGateResources: string[];
21
+ /** RaceGate is a gate standing in the world, which remove takes down. */
22
+ export declare class RaceGate {
23
+ private readonly objects;
24
+ private readonly entities;
25
+ private constructor();
26
+ /**
27
+ * stand stands a gate across yaw at foot. A part the world refuses is left
28
+ * out, so the gate stands whatever the world made.
29
+ */
30
+ static stand(options: RaceGateOptions): RaceGate;
31
+ /** remove takes every part of the gate out of the world. */
32
+ remove(): void;
33
+ }