@modlock/modlock 0.1.77 → 0.1.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -4113,6 +4113,94 @@ var BuildItem = /* @__PURE__ */ createMessageType(
4113
4113
  }
4114
4114
  }
4115
4115
  );
4116
+ var HoldEntityModifierRequest = /* @__PURE__ */ createMessageType(
4117
+ "modlock.wasm.abilities.HoldEntityModifierRequest",
4118
+ () => [
4119
+ [1, "entity", 13],
4120
+ [2, "modifier", 9],
4121
+ [3, "active", 8, 4]
4122
+ ],
4123
+ {
4124
+ decode: (r, end, m) => {
4125
+ while (r.pos < end) {
4126
+ const t = r.tag();
4127
+ if ((t & 7) === 4) return m;
4128
+ switch (t >>> 3) {
4129
+ case 1:
4130
+ m.entity = r.uint32();
4131
+ break;
4132
+ case 2:
4133
+ m.modifier = r.string();
4134
+ break;
4135
+ case 3:
4136
+ m.active = r.bool();
4137
+ break;
4138
+ default:
4139
+ r.skip(t);
4140
+ }
4141
+ }
4142
+ return m;
4143
+ },
4144
+ encode: (m, w) => {
4145
+ {
4146
+ const v = m.entity;
4147
+ if (v) w.uint32(8).uint32(v);
4148
+ }
4149
+ {
4150
+ const v = m.modifier;
4151
+ if (v) w.uint32(18).string(v);
4152
+ }
4153
+ {
4154
+ const v = m.active;
4155
+ if (v != null) w.uint32(24).bool(v);
4156
+ }
4157
+ }
4158
+ }
4159
+ );
4160
+ var GiveEntityModifierRequest = /* @__PURE__ */ createMessageType(
4161
+ "modlock.wasm.abilities.GiveEntityModifierRequest",
4162
+ () => [
4163
+ [1, "entity", 13],
4164
+ [2, "modifier", 9],
4165
+ [3, "seconds", 2]
4166
+ ],
4167
+ {
4168
+ decode: (r, end, m) => {
4169
+ while (r.pos < end) {
4170
+ const t = r.tag();
4171
+ if ((t & 7) === 4) return m;
4172
+ switch (t >>> 3) {
4173
+ case 1:
4174
+ m.entity = r.uint32();
4175
+ break;
4176
+ case 2:
4177
+ m.modifier = r.string();
4178
+ break;
4179
+ case 3:
4180
+ m.seconds = r.float();
4181
+ break;
4182
+ default:
4183
+ r.skip(t);
4184
+ }
4185
+ }
4186
+ return m;
4187
+ },
4188
+ encode: (m, w) => {
4189
+ {
4190
+ const v = m.entity;
4191
+ if (v) w.uint32(8).uint32(v);
4192
+ }
4193
+ {
4194
+ const v = m.modifier;
4195
+ if (v) w.uint32(18).string(v);
4196
+ }
4197
+ {
4198
+ const v = m.seconds;
4199
+ if (v != null && v !== 0) w.uint32(29).float(v);
4200
+ }
4201
+ }
4202
+ }
4203
+ );
4116
4204
 
4117
4205
  // src/wasm/combat/combat.pb.ts
4118
4206
  var DamageEvent = /* @__PURE__ */ createMessageType(
@@ -12503,2122 +12591,6 @@ var UiRequest = /* @__PURE__ */ createMessageType(
12503
12591
  }
12504
12592
  );
12505
12593
 
12506
- // js/src/host.gen.ts
12507
- function vector(value) {
12508
- return { x: value?.x ?? 0, y: value?.y ?? 0, z: value?.z ?? 0 };
12509
- }
12510
- function int32(value) {
12511
- return Math.trunc(Math.min(Math.max(value, -2147483648), 2147483647));
12512
- }
12513
- function angles(value) {
12514
- return { pitch: value?.pitch ?? 0, yaw: value?.yaw ?? 0, roll: value?.roll ?? 0 };
12515
- }
12516
- function known(values, decode) {
12517
- const out = [];
12518
- for (const v of values ?? []) {
12519
- const decoded = decode(v);
12520
- if (decoded !== void 0) {
12521
- out.push(decoded);
12522
- }
12523
- }
12524
- return out;
12525
- }
12526
- function reply(response) {
12527
- return Reply.toBinary({ response });
12528
- }
12529
- var screenEffectValues = {
12530
- killed: 0,
12531
- black: 1,
12532
- blinded: 2,
12533
- darkness: 3,
12534
- matchIntro: 4
12535
- };
12536
- var fieldTypeValues = {
12537
- bool: 1,
12538
- int8: 2,
12539
- int16: 3,
12540
- int32: 4,
12541
- uint8: 5,
12542
- uint16: 6,
12543
- uint32: 7,
12544
- int64: 8,
12545
- uint64: 9,
12546
- float32: 10,
12547
- float64: 11,
12548
- vector: 12,
12549
- handle: 13,
12550
- string: 14
12551
- };
12552
- var pickupKindValues = {
12553
- urn: 0,
12554
- movementBuff: 1
12555
- };
12556
- var movementActionNames = {
12557
- 1: "landed",
12558
- 2: "ziplineAttached",
12559
- 3: "groundDash",
12560
- 4: "slide",
12561
- 5: "bouncePad",
12562
- 6: "dashJump",
12563
- 7: "airJump",
12564
- 8: "wallJump",
12565
- 9: "airDash",
12566
- 10: "meleeStarted",
12567
- 11: "abilityExecuted"
12568
- };
12569
- var interactionKindNames = {
12570
- 1: "pickupCollected",
12571
- 2: "propBroken"
12572
- };
12573
- var laneValues = {
12574
- none: 0,
12575
- yellow: 1,
12576
- green: 3,
12577
- blue: 4,
12578
- purple: 6
12579
- };
12580
- var textAlignValues = {
12581
- left: 0,
12582
- center: 1,
12583
- right: 2
12584
- };
12585
- var textVerticalAlignValues = {
12586
- bottom: 0,
12587
- center: 1,
12588
- top: 2
12589
- };
12590
- var disconnectReasonNames = {
12591
- 1: "shutdown",
12592
- 2: "disconnectByUser",
12593
- 3: "disconnectByServer",
12594
- 4: "lost",
12595
- 5: "overflow",
12596
- 6: "steamBanned",
12597
- 7: "steamInuse",
12598
- 8: "steamTicket",
12599
- 9: "steamLogon",
12600
- 10: "steamAuthcancelled",
12601
- 11: "steamAuthalreadyused",
12602
- 12: "steamAuthinvalid",
12603
- 13: "steamVacbanstate",
12604
- 14: "steamLoggedInElsewhere",
12605
- 15: "steamVacCheckTimedout",
12606
- 16: "steamDropped",
12607
- 17: "steamOwnership",
12608
- 18: "serverinfoOverflow",
12609
- 19: "tickmsgOverflow",
12610
- 20: "stringtablemsgOverflow",
12611
- 21: "deltaentmsgOverflow",
12612
- 22: "tempentmsgOverflow",
12613
- 23: "soundsmsgOverflow",
12614
- 24: "snapshotoverflow",
12615
- 25: "snapshoterror",
12616
- 26: "reliableoverflow",
12617
- 27: "baddeltatick",
12618
- 28: "nomoresplits",
12619
- 29: "timedout",
12620
- 30: "disconnected",
12621
- 31: "leavingsplit",
12622
- 32: "differentclasstables",
12623
- 33: "badrelaypassword",
12624
- 34: "badspectatorpassword",
12625
- 35: "hltvrestricted",
12626
- 36: "nospectators",
12627
- 37: "hltvunavailable",
12628
- 38: "hltvstop",
12629
- 39: "kicked",
12630
- 40: "banadded",
12631
- 41: "kickbanadded",
12632
- 42: "hltvdirect",
12633
- 43: "pureserverClientextra",
12634
- 44: "pureserverMismatch",
12635
- 45: "usercmd",
12636
- 46: "rejectedByGame",
12637
- 47: "messageParseError",
12638
- 48: "invalidMessageError",
12639
- 49: "badServerPassword",
12640
- 50: "directConnectReservation",
12641
- 51: "connectionFailure",
12642
- 52: "noPeerGroupHandlers",
12643
- 53: "reconnection",
12644
- 54: "loopshutdown",
12645
- 55: "loopdeactivate",
12646
- 56: "hostEndgame",
12647
- 57: "loopLevelloadActivate",
12648
- 58: "createServerFailed",
12649
- 59: "exiting",
12650
- 60: "requestHoststateIdle",
12651
- 61: "requestHoststateHltvrelay",
12652
- 62: "clientConsistencyFail",
12653
- 63: "clientUnableToCrcMap",
12654
- 64: "clientNoMap",
12655
- 65: "clientDifferentMap",
12656
- 66: "serverRequiresSteam",
12657
- 67: "steamDenyMisc",
12658
- 68: "steamDenyBadAntiCheat",
12659
- 69: "serverShutdown",
12660
- 71: "replayIncompatible",
12661
- 72: "connectRequestTimedout",
12662
- 73: "serverIncompatible",
12663
- 74: "localproblemManyrelays",
12664
- 75: "localproblemHostedserverprimaryrelay",
12665
- 76: "localproblemNetworkconfig",
12666
- 77: "localproblemOther",
12667
- 79: "remoteTimeout",
12668
- 80: "remoteTimeoutConnecting",
12669
- 81: "remoteOther",
12670
- 82: "remoteBadcrypt",
12671
- 83: "remoteCertnottrusted",
12672
- 84: "unusual",
12673
- 85: "internalError",
12674
- 128: "rejectBadchallenge",
12675
- 129: "rejectNolobby",
12676
- 130: "rejectBackgroundMap",
12677
- 131: "rejectSinglePlayer",
12678
- 132: "rejectHiddenGame",
12679
- 133: "rejectLanrestrict",
12680
- 134: "rejectBadpassword",
12681
- 135: "rejectServerfull",
12682
- 136: "rejectInvalidreservation",
12683
- 137: "rejectFailedchannel",
12684
- 138: "rejectConnectFromLobby",
12685
- 139: "rejectReservedForLobby",
12686
- 140: "rejectInvalidkeylength",
12687
- 141: "rejectOldprotocol",
12688
- 142: "rejectNewprotocol",
12689
- 143: "rejectInvalidconnection",
12690
- 144: "rejectInvalidcertlen",
12691
- 145: "rejectInvalidsteamcertlen",
12692
- 146: "rejectSteam",
12693
- 147: "rejectServerauthdisabled",
12694
- 148: "rejectServercdkeyauthinvalid",
12695
- 149: "rejectBanned",
12696
- 150: "kickedTeamkilling",
12697
- 151: "kickedTkStart",
12698
- 152: "kickedUntrustedaccount",
12699
- 153: "kickedConvictedaccount",
12700
- 154: "kickedCompetitivecooldown",
12701
- 155: "kickedTeamhurting",
12702
- 156: "kickedHostagekilling",
12703
- 157: "kickedVotedoff",
12704
- 158: "kickedIdle",
12705
- 159: "kickedSuicide",
12706
- 160: "kickedNosteamlogin",
12707
- 161: "kickedNosteamticket",
12708
- 162: "kickedInputautomation",
12709
- 163: "kickedVacnetabnormalbehavior",
12710
- 164: "kickedInsecureclient"
12711
- };
12712
- var modRoleNames = {
12713
- 0: "unspecified",
12714
- 1: "developer",
12715
- 2: "tester"
12716
- };
12717
- var cameraParamValues = {
12718
- distance: 0,
12719
- fieldOfView: 1,
12720
- target: 2,
12721
- verticalOffset: 3,
12722
- horizontalOffset: 4
12723
- };
12724
- function fromAbility(message) {
12725
- return {
12726
- name: message.name ?? "",
12727
- slot: message.slot ?? 0,
12728
- entity: message.entity ?? 0,
12729
- upgrades: message.upgrades ?? 0,
12730
- charges: message.charges ?? 0,
12731
- cooldownEnd: message.cooldownEnd ?? 0,
12732
- id: message.id ?? 0,
12733
- state: message.state ?? 0,
12734
- cooldownStart: message.cooldownStart ?? 0,
12735
- rechargeStart: message.rechargeStart ?? 0,
12736
- rechargeEnd: message.rechargeEnd ?? 0,
12737
- imbues: message.imbues ?? []
12738
- };
12739
- }
12740
- function toAbilityOptions(value) {
12741
- return {
12742
- ability: value.ability,
12743
- upgrades: value.upgrades,
12744
- charges: value.charges === void 0 ? void 0 : int32(value.charges),
12745
- cooldownEnd: value.cooldownEnd,
12746
- rechargeEnd: value.rechargeEnd,
12747
- maxCharges: value.maxCharges === void 0 ? void 0 : int32(value.maxCharges)
12748
- };
12749
- }
12750
- function fromBuildCategory(message) {
12751
- return {
12752
- name: message.name ?? "",
12753
- description: message.description ?? "",
12754
- items: (message.items ?? []).map((v) => fromBuildItem(v))
12755
- };
12756
- }
12757
- function fromBuildItem(message) {
12758
- return {
12759
- item: message.item ?? "",
12760
- annotation: message.annotation ?? ""
12761
- };
12762
- }
12763
- function fromDamageEvent(message) {
12764
- return {
12765
- victim: message.victim ?? 0,
12766
- attacker: message.attacker ?? 0,
12767
- inflictor: message.inflictor ?? 0,
12768
- ability: message.ability ?? 0,
12769
- flags: message.flags ?? 0n,
12770
- hitGroup: message.hitGroup ?? 0,
12771
- amount: message.amount ?? 0
12772
- };
12773
- }
12774
- function fromDamagedEvent(message) {
12775
- return {
12776
- victim: message.victim ?? 0,
12777
- attacker: message.attacker ?? 0,
12778
- ability: message.ability ?? 0,
12779
- healthLost: message.healthLost ?? 0,
12780
- healthBefore: message.healthBefore ?? 0,
12781
- dealt: message.dealt ?? 0
12782
- };
12783
- }
12784
- function fromLaunchEvent(message) {
12785
- return {
12786
- entity: message.entity ?? 0,
12787
- name: message.name ?? "",
12788
- owner: message.owner ?? 0,
12789
- player: Player.of(message.player ?? 0),
12790
- position: vector(message.position)
12791
- };
12792
- }
12793
- function fromImpactEvent(message) {
12794
- return {
12795
- entity: message.entity ?? 0,
12796
- name: message.name ?? "",
12797
- owner: message.owner ?? 0,
12798
- player: Player.of(message.player ?? 0),
12799
- start: vector(message.start),
12800
- end: vector(message.end),
12801
- position: vector(message.position),
12802
- hit: message.hit ?? 0
12803
- };
12804
- }
12805
- function toProjectileOptions(value) {
12806
- return {
12807
- names: value.names?.slice(),
12808
- keepMomentum: value.keepMomentum
12809
- };
12810
- }
12811
- function toHitOptions(value) {
12812
- return {
12813
- victim: value.victim,
12814
- attacker: value.attacker,
12815
- inflictor: value.inflictor,
12816
- amount: value.amount,
12817
- hitGroup: value.hitGroup === void 0 ? void 0 : int32(value.hitGroup),
12818
- ability: value.ability
12819
- };
12820
- }
12821
- function toTraceOptions(value) {
12822
- return {
12823
- start: value.start,
12824
- end: value.end,
12825
- layers: value.layers,
12826
- exclude: value.exclude,
12827
- ignore: value.ignore?.slice()
12828
- };
12829
- }
12830
- function fromTraceHit(message) {
12831
- return {
12832
- position: vector(message.position),
12833
- normal: vector(message.normal),
12834
- startSolid: message.startSolid ?? false,
12835
- entity: message.entity ?? 0
12836
- };
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
- }
12845
- function toFieldValue(value) {
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 };
12847
- }
12848
- function fromFieldValue(message) {
12849
- const value = message?.value;
12850
- if (value === void 0 || value.case === void 0) return void 0;
12851
- switch (value.case) {
12852
- case "vector":
12853
- return vector(value.value);
12854
- }
12855
- return value.value;
12856
- }
12857
- function toFieldWrite(value) {
12858
- return {
12859
- className: value.className,
12860
- field: value.field,
12861
- type: fieldTypeValues[value.type],
12862
- value: toFieldValue(value.value)
12863
- };
12864
- }
12865
- function fromEntityClassName(message) {
12866
- return {
12867
- className: message.className ?? "",
12868
- designerName: message.designerName ?? ""
12869
- };
12870
- }
12871
- function fromEntityPlacement(message) {
12872
- return {
12873
- position: vector(message.position),
12874
- facing: angles(message.facing),
12875
- velocity: message.velocity === void 0 ? void 0 : vector(message.velocity)
12876
- };
12877
- }
12878
- function toEntityOptions(value) {
12879
- return {
12880
- designerName: value.designerName,
12881
- subclass: value.subclass,
12882
- team: int32(value.team),
12883
- position: value.position,
12884
- facing: value.facing,
12885
- keyValues: value.keyValues?.map((v) => toKeyValue(v)),
12886
- fields: value.fields?.map((v) => toFieldWrite(v)),
12887
- transmitAlways: value.transmitAlways
12888
- };
12889
- }
12890
- function toKeyValue(value) {
12891
- return {
12892
- key: value.key,
12893
- value: toEntityValue(value.value)
12894
- };
12895
- }
12896
- function toEntityValue(value) {
12897
- if ("boolean" in value) return { value: { case: "boolean", value: value.boolean } };
12898
- if ("integer" in value) return { value: { case: "integer", value: int32(value.integer) } };
12899
- if ("number" in value) return { value: { case: "number", value: value.number } };
12900
- if ("text" in value) return { value: { case: "text", value: value.text } };
12901
- if ("vector" in value) return { value: { case: "vector", value: value.vector } };
12902
- return { value: { case: "color", value: value.color } };
12903
- }
12904
- function fromInputEvent(message) {
12905
- return {
12906
- player: Player.of(message.player ?? 0),
12907
- pressed: message.pressed ?? 0n,
12908
- released: message.released ?? 0n
12909
- };
12910
- }
12911
- function fromRiftState(message) {
12912
- return {
12913
- scoringTeam: message.scoringTeam ?? 0,
12914
- scoringTime: message.scoringTime ?? 0,
12915
- cashInStarted: message.cashInStarted ?? 0,
12916
- giveUpTime: message.giveUpTime ?? 0,
12917
- nextSpawn: message.nextSpawn ?? 0,
12918
- spawnWindow: message.spawnWindow ?? 0
12919
- };
12920
- }
12921
- function fromMovementSample(message) {
12922
- return {
12923
- player: Player.of(message.player ?? 0),
12924
- pawn: message.pawn ?? 0,
12925
- position: vector(message.position),
12926
- velocity: vector(message.velocity),
12927
- grounded: message.grounded ?? false,
12928
- sliding: message.sliding ?? false,
12929
- mantling: message.mantling ?? false,
12930
- climbing: message.climbing ?? false,
12931
- dashing: message.dashing ?? false,
12932
- jumpAbility: message.jumpAbility ?? 0,
12933
- wallJumps: message.wallJumps ?? 0,
12934
- mantleAbility: message.mantleAbility ?? 0,
12935
- mantleStart: message.mantleStart ?? 0,
12936
- wallContact: vector(message.wallContact),
12937
- wallNormal: vector(message.wallNormal),
12938
- wallJumpNormal: vector(message.wallJumpNormal),
12939
- wallJumpFacing: message.wallJumpFacing ?? 0,
12940
- ziplineTime: message.ziplineTime,
12941
- actions: known(message.actions, (v) => movementActionNames[v]),
12942
- casts: message.casts ?? [],
12943
- command: message.command === void 0 ? void 0 : fromMovementCommand(message.command),
12944
- interactions: (message.interactions ?? []).map((v) => fromInteraction(v))
12945
- };
12946
- }
12947
- function fromInteraction(message) {
12948
- return {
12949
- kind: interactionKindNames[message.kind ?? 0],
12950
- entity: message.entity ?? 0,
12951
- designerName: message.designerName ?? "",
12952
- subclassId: message.subclassId ?? 0,
12953
- origin: vector(message.origin),
12954
- vacuumStart: message.vacuumStart,
12955
- inflictor: message.inflictor ?? 0
12956
- };
12957
- }
12958
- function fromMovementCommand(message) {
12959
- return {
12960
- held: message.held ?? 0n,
12961
- changed: message.changed ?? 0n,
12962
- scroll: message.scroll ?? 0n,
12963
- forward: message.forward ?? 0,
12964
- left: message.left ?? 0,
12965
- up: message.up ?? 0,
12966
- grounded: message.grounded ?? false
12967
- };
12968
- }
12969
- function fromLandedEvent(message) {
12970
- return {
12971
- player: Player.of(message.player ?? 0),
12972
- on: message.on ?? 0,
12973
- speed: message.speed ?? 0
12974
- };
12975
- }
12976
- function fromNpcsRestoredEvent(message) {
12977
- return {
12978
- error: message.error ?? ""
12979
- };
12980
- }
12981
- function toNpcOptions(value) {
12982
- return {
12983
- className: value.className,
12984
- unit: value.unit,
12985
- team: int32(value.team),
12986
- position: value.position,
12987
- facing: value.facing,
12988
- health: value.health === void 0 ? void 0 : int32(value.health),
12989
- maxHealth: value.maxHealth === void 0 ? void 0 : int32(value.maxHealth),
12990
- lane: value.lane,
12991
- fields: value.fields?.map((v) => toFieldWrite(v))
12992
- };
12993
- }
12994
- function fromNpcState(message) {
12995
- return {
12996
- position: vector(message.position),
12997
- facing: angles(message.facing),
12998
- health: message.health ?? 0,
12999
- maxHealth: message.maxHealth ?? 0,
13000
- team: message.team ?? 0
13001
- };
13002
- }
13003
- function toNpcTarget(value) {
13004
- return {
13005
- className: value.className,
13006
- id: value.id,
13007
- team: int32(value.team),
13008
- position: value.position,
13009
- facing: value.facing,
13010
- velocity: value.velocity,
13011
- health: int32(value.health),
13012
- maxHealth: int32(value.maxHealth),
13013
- lane: value.lane
13014
- };
13015
- }
13016
- function toTextOptions(value) {
13017
- return {
13018
- text: value.text,
13019
- position: value.position,
13020
- facing: value.facing,
13021
- fontSize: value.fontSize,
13022
- color: value.color,
13023
- faceCamera: value.faceCamera,
13024
- scale: value.scale,
13025
- align: value.align === void 0 ? void 0 : textAlignValues[value.align],
13026
- verticalAlign: value.verticalAlign === void 0 ? void 0 : textVerticalAlignValues[value.verticalAlign]
13027
- };
13028
- }
13029
- function toParticleOptions(value) {
13030
- return {
13031
- resource: value.resource,
13032
- position: value.position,
13033
- facing: value.facing,
13034
- color: value.color,
13035
- tintPoint: value.tintPoint === void 0 ? void 0 : int32(value.tintPoint),
13036
- point: value.point === void 0 ? void 0 : toParticlePoint(value.point),
13037
- parent: value.parent,
13038
- anchors: value.anchors?.map((v) => toParticleAnchor(v)),
13039
- inactive: value.inactive
13040
- };
13041
- }
13042
- function toParticleAnchor(value) {
13043
- return {
13044
- index: int32(value.index),
13045
- entity: value.entity
13046
- };
13047
- }
13048
- function toParticlePoint(value) {
13049
- return {
13050
- index: int32(value.index),
13051
- position: value.position
13052
- };
13053
- }
13054
- function fromRestoredEvent(message) {
13055
- return {
13056
- player: Player.of(message.player ?? 0),
13057
- error: message.error ?? ""
13058
- };
13059
- }
13060
- function fromPlayersChangedEvent(message) {
13061
- return {
13062
- players: (message.players ?? []).map((v) => fromConnection(v))
13063
- };
13064
- }
13065
- function fromPlayerJoinedEvent(message) {
13066
- return {
13067
- connection: fromConnection(message.connection ?? {})
13068
- };
13069
- }
13070
- function fromPlayerLeftEvent(message) {
13071
- return {
13072
- connection: fromConnection(message.connection ?? {}),
13073
- disconnected: message.disconnected ?? false,
13074
- reason: message.reason === void 0 ? void 0 : disconnectReasonNames[message.reason]
13075
- };
13076
- }
13077
- function fromConnection(message) {
13078
- return {
13079
- player: Player.of(message.player ?? 0),
13080
- steamId: message.steamId ?? 0n,
13081
- name: message.name ?? "",
13082
- bot: message.bot ?? false,
13083
- ready: message.ready ?? false,
13084
- generation: message.generation ?? 0,
13085
- roles: known(message.roles, (v) => modRoleNames[v])
13086
- };
13087
- }
13088
- function fromPawn(message) {
13089
- return {
13090
- entity: message.entity ?? 0,
13091
- hero: message.hero ?? 0,
13092
- team: message.team ?? 0,
13093
- health: message.health ?? 0,
13094
- maxHealth: message.maxHealth ?? 0,
13095
- position: vector(message.position),
13096
- eyeAngles: angles(message.eyeAngles),
13097
- cameraAngles: angles(message.cameraAngles),
13098
- stamina: message.stamina,
13099
- maxStamina: message.maxStamina,
13100
- generation: message.generation ?? 0,
13101
- souls: message.souls ?? 0,
13102
- eyePosition: vector(message.eyePosition),
13103
- velocity: vector(message.velocity),
13104
- carryingUrn: message.carryingUrn,
13105
- score: message.score === void 0 ? void 0 : fromScore(message.score),
13106
- cameraPosition: message.cameraPosition === void 0 ? void 0 : vector(message.cameraPosition),
13107
- effectiveMaxHealth: message.effectiveMaxHealth,
13108
- abilityPoints: message.abilityPoints ?? 0,
13109
- abilityUnlocks: message.abilityUnlocks ?? 0
13110
- };
13111
- }
13112
- function fromScore(message) {
13113
- return {
13114
- kills: message.kills ?? 0,
13115
- deaths: message.deaths ?? 0,
13116
- assists: message.assists ?? 0,
13117
- lastHits: message.lastHits ?? 0,
13118
- denies: message.denies ?? 0,
13119
- heroDamage: message.heroDamage ?? 0,
13120
- heroHealing: message.heroHealing ?? 0,
13121
- netWorth: message.netWorth ?? 0
13122
- };
13123
- }
13124
- function toCameraValue(value) {
13125
- return { value: typeof value === "number" ? { case: "number", value } : typeof value === "object" ? { case: "position", value } : void 0 };
13126
- }
13127
- function toCameraMotion(value) {
13128
- if ("hold" in value) return { motion: { case: "hold", value: value.hold } };
13129
- if ("approach" in value) return { motion: { case: "approach", value: toCameraApproach(value.approach) } };
13130
- if ("spring" in value) return { motion: { case: "spring", value: toCameraSpring(value.spring) } };
13131
- if ("lerp" in value) return { motion: { case: "lerp", value: toCameraLerp(value.lerp) } };
13132
- return { motion: { case: "lag", value: value.lag } };
13133
- }
13134
- function toCameraApproach(value) {
13135
- return {
13136
- value: value.value === void 0 ? void 0 : toCameraValue(value.value),
13137
- speed: value.speed,
13138
- defaultSpeed: value.defaultSpeed,
13139
- acceleration: value.acceleration,
13140
- minDuration: value.minDuration,
13141
- chaseDefault: value.chaseDefault
13142
- };
13143
- }
13144
- function toCameraSpring(value) {
13145
- return {
13146
- value: value.value === void 0 ? void 0 : toCameraValue(value.value),
13147
- strength: value.strength,
13148
- minSpeed: value.minSpeed,
13149
- maxDuration: value.maxDuration
13150
- };
13151
- }
13152
- function toCameraLerp(value) {
13153
- return {
13154
- start: toCameraValue(value.start),
13155
- end: toCameraValue(value.end),
13156
- bias: value.bias,
13157
- gain: value.gain,
13158
- duration: value.duration
13159
- };
13160
- }
13161
- function toCameraOptions(value) {
13162
- return {
13163
- context: value.context,
13164
- param: cameraParamValues[value.param],
13165
- motion: toCameraMotion(value.motion),
13166
- delay: value.delay,
13167
- relative: value.relative,
13168
- priority: value.priority,
13169
- shared: value.shared,
13170
- target: value.target
13171
- };
13172
- }
13173
- function toHeroTarget(value) {
13174
- return {
13175
- position: value.position,
13176
- facing: value.facing,
13177
- fresh: value.fresh,
13178
- level: value.level === void 0 ? void 0 : int32(value.level),
13179
- health: value.health === void 0 ? void 0 : int32(value.health),
13180
- maxHealth: value.maxHealth === void 0 ? void 0 : int32(value.maxHealth),
13181
- upgradeBonuses: value.upgradeBonuses?.slice(),
13182
- abilities: value.abilities?.map((v) => toEquipmentTarget(v)),
13183
- items: value.items?.map((v) => toEquipmentTarget(v)),
13184
- replaceItems: value.replaceItems,
13185
- timers: value.timers?.map((v) => toTimerTarget(v))
13186
- };
13187
- }
13188
- function toEquipmentTarget(value) {
13189
- return {
13190
- id: value.id,
13191
- slot: value.slot === void 0 ? void 0 : int32(value.slot),
13192
- state: value.state
13193
- };
13194
- }
13195
- function toTimerTarget(value) {
13196
- return {
13197
- id: value.id,
13198
- charges: int32(value.charges),
13199
- cooldownStart: value.cooldownStart,
13200
- cooldownEnd: value.cooldownEnd,
13201
- rechargeStart: value.rechargeStart,
13202
- rechargeEnd: value.rechargeEnd
13203
- };
13204
- }
13205
- function toBotOptions(value) {
13206
- return {
13207
- name: value.name,
13208
- team: int32(value.team),
13209
- hero: value.hero === void 0 ? void 0 : typeof value.hero === "string" ? { case: "heroName", value: value.hero } : typeof value.hero === "number" ? { case: "heroId", value: value.hero } : void 0,
13210
- position: value.position
13211
- };
13212
- }
13213
- function fromSettingChangedEvent(message) {
13214
- return {
13215
- player: Player.of(message.player ?? 0),
13216
- key: message.key ?? "",
13217
- value: message.value ?? ""
13218
- };
13219
- }
13220
- function fromWheel(message) {
13221
- return {
13222
- delta: message.delta ?? 0,
13223
- fraction: message.fraction ?? 0
13224
- };
13225
- }
13226
- function fromUiPressEvent(message) {
13227
- return {
13228
- player: Player.of(message.player ?? 0),
13229
- node: message.node ?? ""
13230
- };
13231
- }
13232
- function fromUiInputEvent(message) {
13233
- return {
13234
- player: Player.of(message.player ?? 0),
13235
- node: message.node ?? "",
13236
- value: message.value?.case === "wheel" ? fromWheel(message.value.value) : message.value?.value
13237
- };
13238
- }
13239
- function fromStartEvent(message) {
13240
- return {
13241
- args: message.args ?? [],
13242
- checkOnly: message.checkOnly ?? false,
13243
- source: message.source ?? new Uint8Array()
13244
- };
13245
- }
13246
- function fromFrameEvent(message) {
13247
- return {
13248
- tick: message.tick ?? 0n,
13249
- timeSeconds: message.timeSeconds ?? 0,
13250
- movement: (message.movement ?? []).map((v) => fromMovementSample(v)),
13251
- interactions: known(message.interactions, (v) => interactionKindNames[v])
13252
- };
13253
- }
13254
- function fromCommandEvent(message) {
13255
- return {
13256
- player: Player.of(message.player ?? 0),
13257
- line: message.line ?? ""
13258
- };
13259
- }
13260
- function fromChatEvent(message) {
13261
- return {
13262
- player: Player.of(message.player ?? 0),
13263
- text: message.text ?? "",
13264
- all: message.all ?? false,
13265
- lane: message.lane ?? 0
13266
- };
13267
- }
13268
- function fromWorldEvent(message) {
13269
- return {
13270
- map: message.map ?? ""
13271
- };
13272
- }
13273
- function fromServiceCall(message) {
13274
- return {
13275
- service: message.service ?? "",
13276
- method: message.method ?? "",
13277
- payload: message.payload ?? new Uint8Array()
13278
- };
13279
- }
13280
- function toPrecacheOptions(value) {
13281
- return {
13282
- heroes: value.heroes?.slice(),
13283
- resources: value.resources?.slice()
13284
- };
13285
- }
13286
- var playerObjects = /* @__PURE__ */ new Map();
13287
- var Player = class _Player {
13288
- /** slot identifies the player on the server. */
13289
- slot;
13290
- constructor(slot) {
13291
- this.slot = slot;
13292
- }
13293
- /**
13294
- * of returns the Player for slot, the same object each time until release
13295
- * forgets it, so === tells whether two values are the same player.
13296
- */
13297
- static of(slot) {
13298
- let object = playerObjects.get(slot);
13299
- if (object === void 0) {
13300
- object = new _Player(slot);
13301
- playerObjects.set(slot, object);
13302
- }
13303
- return object;
13304
- }
13305
- /**
13306
- * release forgets the Player for slot, so the next Player.of makes a new one.
13307
- */
13308
- static release(slot) {
13309
- playerObjects.delete(slot);
13310
- }
13311
- /** chat sends a server chat line to the player. */
13312
- chat(text2) {
13313
- return call("Chat", ChatRequest.toBinary({ player: this.slot, text: text2 })) !== void 0;
13314
- }
13315
- /**
13316
- * centerText shows text in the middle of the player's screen until it is
13317
- * replaced. Empty text clears it.
13318
- */
13319
- centerText(text2) {
13320
- return call("CenterText", CenterTextRequest.toBinary({ player: this.slot, text: text2 })) !== void 0;
13321
- }
13322
- /** announce shows a game announcement with a title to the player. */
13323
- announce(title, text2) {
13324
- return call("Announce", AnnounceRequest.toBinary({ player: this.slot, title, text: text2 })) !== void 0;
13325
- }
13326
- /**
13327
- * pawn returns the player's pawn this frame: the hero, or the game's
13328
- * placeholder with hero 0 that a player joining on a team holds until a hero
13329
- * is selected. It returns nothing for a spectator and before the game has
13330
- * made a pawn. The pawn's entity changes whenever the game replaces it.
13331
- */
13332
- pawn() {
13333
- const reply2 = call("Pawn", PlayerRequest.toBinary({ player: this.slot }));
13334
- if (reply2 === void 0) return void 0;
13335
- const response = PawnResponse.fromBinary(reply2);
13336
- return response.pawn === void 0 ? void 0 : fromPawn(response.pawn);
13337
- }
13338
- /**
13339
- * setting returns the player's value of a setting the manifest
13340
- * declares: the value they chose, or the setting's default. A bot has the
13341
- * defaults.
13342
- */
13343
- setting(key) {
13344
- const reply2 = call("PlayerSetting", PlayerSettingRequest.toBinary({ player: this.slot, key }));
13345
- if (reply2 === void 0) return void 0;
13346
- const response = SettingResponse.fromBinary(reply2);
13347
- return response.value ?? "";
13348
- }
13349
- /**
13350
- * setSetting changes the player's value of a setting the manifest
13351
- * declares. The value follows the player to later games and other mods'
13352
- * servers of the same mod; a bot keeps the defaults.
13353
- */
13354
- setSetting(key, value) {
13355
- return call("SetPlayerSetting", SetPlayerSettingRequest.toBinary({ player: this.slot, key, value })) !== void 0;
13356
- }
13357
- /**
13358
- * addMetric adds to the player's total of a metric the manifest declares.
13359
- * The host keeps each player's totals in memory and hands them on once,
13360
- * when the player leaves or the mod stops; a bot keeps none.
13361
- */
13362
- addMetric(name, value, label) {
13363
- return call("AddMetric", AddMetricRequest.toBinary({ player: this.slot, name, value, label })) !== void 0;
13364
- }
13365
- /**
13366
- * handoff replaces the handoff state for the player, such as the
13367
- * panels their HUD shows. It lasts only through a reload of the mod in the
13368
- * same game, in memory, as the game's does, and ends early when the player
13369
- * leaves; only that player reads it back, and a bot keeps none.
13370
- */
13371
- handoff(text2) {
13372
- return call("PlayerHandoff", HandoffPlayerRequest.toBinary({ player: this.slot, text: text2 })) !== void 0;
13373
- }
13374
- /** handedOff returns the player's handoff state, or empty. */
13375
- handedOff() {
13376
- const reply2 = call("PlayerHandedOff", PlayerRequest.toBinary({ player: this.slot }));
13377
- if (reply2 === void 0) return void 0;
13378
- const response = HandedOffResponse.fromBinary(reply2);
13379
- return response.text ?? "";
13380
- }
13381
- /**
13382
- * selectHero gives the player a hero on a team, 2 or 3, and returns the
13383
- * hero's identifier as Pawn.hero reports it. The hero appears on a later
13384
- * frame. A hero the player picked through the game's Change Hero wins: the
13385
- * game removes the old hero before it spawns the pick, and a call in that
13386
- * gap, up to 5 seconds, fails and leaves the pick to land.
13387
- */
13388
- selectHero(hero, team) {
13389
- const reply2 = call("SelectHero", SelectHeroRequest.toBinary({ player: this.slot, hero: typeof hero === "string" ? { case: "heroName", value: hero } : typeof hero === "number" ? { case: "heroId", value: hero } : void 0, team: int32(team) }));
13390
- if (reply2 === void 0) return void 0;
13391
- const response = HeroResponse.fromBinary(reply2);
13392
- return response.hero ?? 0;
13393
- }
13394
- /**
13395
- * spectate moves the player to the spectators, without a hero. The player
13396
- * watches until a hero selection seats them again.
13397
- */
13398
- spectate() {
13399
- return call("Spectate", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13400
- }
13401
- /**
13402
- * watch points the player's camera at a hero, through the hero's own view
13403
- * or chasing it, as the game's spectator camera follows it. A spectator watches through
13404
- * their spectator camera, once it exists. A player with a hero watches
13405
- * while the hero stays where it stands, keeping its level, souls and items,
13406
- * until Unwatch returns them to it.
13407
- */
13408
- watch(target, chase) {
13409
- return call("Watch", WatchRequest.toBinary({ player: this.slot, target, chase })) !== void 0;
13410
- }
13411
- /**
13412
- * freeCamera lets the player fly their camera from a position, with the
13413
- * movement keys and the mouse, as the game's roaming spectator camera does.
13414
- * A player with a hero leaves it where it stands, as Watch does, until
13415
- * Unwatch returns them to it; Watch follows a hero again.
13416
- */
13417
- freeCamera(position, facing) {
13418
- return call("FreeCamera", FreeCameraRequest.toBinary({ player: this.slot, position, facing })) !== void 0;
13419
- }
13420
- /**
13421
- * moveCamera adds one operation to the player's camera, as the game's
13422
- * abilities pull it back, widen its view or swing it to a point. Operations
13423
- * run alongside the game's own until they end or ClearCamera removes them.
13424
- */
13425
- moveCamera(options) {
13426
- return call("MoveCamera", CameraOptions.toBinary({ player: this.slot, ...toCameraOptions(options) })) !== void 0;
13427
- }
13428
- /**
13429
- * clearCamera removes a context's camera operations from the player's
13430
- * camera, or every operation, and the camera returns to its usual place.
13431
- */
13432
- clearCamera(context) {
13433
- return call("ClearCamera", ClearCameraRequest.toBinary({ player: this.slot, context })) !== void 0;
13434
- }
13435
- /**
13436
- * unwatch returns a player watching or flying the free camera from their
13437
- * hero back to it. Stopping the mod returns every such player.
13438
- */
13439
- unwatch() {
13440
- return call("Unwatch", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13441
- }
13442
- /**
13443
- * respawn revives the player's dead hero. A pawn with hero 0 has no hero to
13444
- * revive; the call fails until SelectHero gives it one.
13445
- */
13446
- respawn() {
13447
- return call("Respawn", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13448
- }
13449
- /**
13450
- * changeTeam moves the player's hero, living or dead, to team 2 or 3 where
13451
- * it stands, for a human or a bot alike. The hero keeps its hero,
13452
- * abilities, items and health, and the player keeps their connection; a
13453
- * dead hero respawns on its new team, on its timer or through Respawn. A
13454
- * living hero moved inside the other team's base dies to the base's
13455
- * defense. A player without a hero joins a team through SelectHero
13456
- * instead.
13457
- */
13458
- changeTeam(team) {
13459
- return call("ChangeTeam", ChangeTeamRequest.toBinary({ player: this.slot, team: int32(team) })) !== void 0;
13460
- }
13461
- /** clearItems removes every item the player's hero owns. */
13462
- clearItems() {
13463
- return call("ClearItems", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13464
- }
13465
- /**
13466
- * freeze holds the player's hero in place, without input or damage, until
13467
- * it is released. Stopping the mod releases it.
13468
- */
13469
- freeze(frozen) {
13470
- return call("Freeze", FreezeRequest.toBinary({ player: this.slot, frozen })) !== void 0;
13471
- }
13472
- /** restoreStamina refills the player's stamina. */
13473
- restoreStamina() {
13474
- return call("RestoreStamina", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13475
- }
13476
- /**
13477
- * setStamina sets the player's stamina, as Pawn.stamina reads it. The game
13478
- * regenerates it as usual afterwards.
13479
- */
13480
- setStamina(stamina) {
13481
- return call("SetStamina", SetStaminaRequest.toBinary({ player: this.slot, stamina })) !== void 0;
13482
- }
13483
- /**
13484
- * refreshAbility ends the cooldown of the hero's ability named ability,
13485
- * such as citadel_ability_melee_parry.
13486
- */
13487
- refreshAbility(ability) {
13488
- return call("RefreshAbility", RefreshAbilityRequest.toBinary({ player: this.slot, ability })) !== void 0;
13489
- }
13490
- /**
13491
- * abilities lists the abilities of the player's hero in the hero's order,
13492
- * or none without a live hero.
13493
- */
13494
- abilities() {
13495
- const reply2 = call("Abilities", PlayerRequest.toBinary({ player: this.slot }));
13496
- if (reply2 === void 0) return [];
13497
- const response = AbilitiesResponse.fromBinary(reply2);
13498
- return (response.abilities ?? []).map((v) => fromAbility(v));
13499
- }
13500
- /**
13501
- * setAbility changes the upgrades, charges or timers of one of the hero's
13502
- * abilities. An omitted option stays as it is.
13503
- */
13504
- setAbility(options) {
13505
- return call("SetAbility", AbilityOptions.toBinary({ player: this.slot, ...toAbilityOptions(options) })) !== void 0;
13506
- }
13507
- /**
13508
- * giveItem gives the hero an item, enabled and free. A hero that owns it
13509
- * keeps its one copy. With imbue, an imbuing item strengthens the hero's
13510
- * ability in that slot, 0 to 3, as the shop asks when one is bought; the
13511
- * call fails, granting nothing, when the ability does not accept it.
13512
- */
13513
- giveItem(item2, imbue) {
13514
- return call("GiveItem", GiveItemRequest.toBinary({ player: this.slot, item: item2, imbue })) !== void 0;
13515
- }
13516
- /**
13517
- * buyItem buys an item for the hero as the shop does, under the shop's own
13518
- * rules and for the souls it charges, or fails and charges nothing when the
13519
- * shop refuses, as away from the shop or without the souls. With imbue, an
13520
- * imbuing item strengthens whatever ability the hero holds in that slot, 0
13521
- * to 3, including one ReplaceAbility put there, which the game's own
13522
- * buydependentitem refuses; the call fails, buying nothing, when the
13523
- * ability does not accept it.
13524
- */
13525
- buyItem(item2, imbue, source) {
13526
- return call("BuyItem", BuyItemRequest.toBinary({ player: this.slot, item: item2, imbue, source })) !== void 0;
13527
- }
13528
- /**
13529
- * trainAbility trains or upgrades whatever ability the hero holds in a
13530
- * slot, 0 to 3, as the player holding the upgrade key and pressing the
13531
- * slot's ability key does: an untrained ability trains for an ability
13532
- * unlock, and a trained one buys its next tier for ability points. It works
13533
- * on an ability ReplaceAbility put there, which the game's own commands for
13534
- * a slot do not reach. When the game refuses, as without an unlock or the
13535
- * points, the call fails and nothing is spent.
13536
- */
13537
- trainAbility(slot) {
13538
- return call("TrainAbility", TrainAbilityRequest.toBinary({ player: this.slot, slot })) !== void 0;
13539
- }
13540
- /**
13541
- * replaceAbility puts the ability named ability, untrained unless keep
13542
- * carries the old one's progress, in the hero's ability slot index, as
13543
- * Ability.slot, removing the ability there. The game trains and upgrades an
13544
- * ability in slots 0 to 3 by its slot, so a player holds the upgrade key and
13545
- * presses the slot's ability key to spend ability points on it, and training
13546
- * an untrained one costs an ability unlock. A hero change or ResetHero gives
13547
- * the hero its own abilities again, so a mod that keeps a swap replaces
13548
- * again then. An ability from another hero loads its models and particles
13549
- * only if Precache named that hero and those resources before the world
13550
- * loaded; otherwise its first effect stalls the game on a blocking load and
13551
- * the game reports an assertion.
13552
- */
13553
- replaceAbility(index, ability, keep) {
13554
- return call("ReplaceAbility", ReplaceAbilityRequest.toBinary({ player: this.slot, index, ability, keep })) !== void 0;
13555
- }
13556
- /**
13557
- * holdModifier keeps a modifier, named as GiveModifier names it, on the
13558
- * hero with no expiry, giving it back whenever the game removes it or the
13559
- * hero returns. Every hero that gains the modifier from the same ability
13560
- * keeps it until the hold ends. Releasing leaves the hero's current
13561
- * modifier until it dies.
13562
- */
13563
- holdModifier(modifier, active) {
13564
- return call("HoldModifier", HoldModifierRequest.toBinary({ player: this.slot, modifier, active })) !== void 0;
13565
- }
13566
- /**
13567
- * giveModifier gives the hero a modifier for seconds. An ability's
13568
- * modifier, named "<ability>/<modifier>", comes as if the hero's own
13569
- * ability applied it; a hero without that ability, or a modifier named on
13570
- * its own, such as Street Brawl's zipline boost
13571
- * modifier_street_brawl_round_start_zipline_boost, applies it with the
13572
- * hero's first ability. The game may end it sooner, as invisibility ends on
13573
- * a shot.
13574
- */
13575
- giveModifier(modifier, seconds) {
13576
- return call("GiveModifier", GiveModifierRequest.toBinary({ player: this.slot, modifier, seconds })) !== void 0;
13577
- }
13578
- /**
13579
- * teleport moves the player's hero and turns it and the camera. With a
13580
- * velocity it also sets the hero's motion, as a launch, and the camera
13581
- * follows the hero.
13582
- */
13583
- teleport(position, facing, velocity) {
13584
- return call("Teleport", TeleportRequest.toBinary({ player: this.slot, position, facing, velocity })) !== void 0;
13585
- }
13586
- /**
13587
- * zipline puts the player's hero on a lane's zipline near the hero, riding
13588
- * it as from the zipline key, with the zipline's intro. It never picks
13589
- * another lane: it fails when the lane has no zipline the hero's team rides
13590
- * on this map, or the hero has no zipline ability. For Street Brawl's fast
13591
- * ride, give the hero modifier_street_brawl_round_start_zipline_boost too.
13592
- */
13593
- zipline(lane) {
13594
- return call("Zipline", ZiplineRequest.toBinary({ player: this.slot, lane: laneValues[lane] })) !== void 0;
13595
- }
13596
- /**
13597
- * move carries the player's hero to a position as continuous motion,
13598
- * as a recording plays back. Unlike Teleport it keeps the hero's animated
13599
- * model drawn when repeated every tick, and leaves the camera alone.
13600
- */
13601
- move(position, facing, velocity) {
13602
- return call("MovePlayer", MovePlayerRequest.toBinary({ player: this.slot, position, facing, velocity })) !== void 0;
13603
- }
13604
- /**
13605
- * steer replays a recorded movement command on the player's hero, usually a
13606
- * bot: the game runs the command's buttons and axes, so the hero crouches,
13607
- * slides, jumps and mantles with its own animation, and the step then ends
13608
- * on the recorded pose. The steering stays until the next Steer replaces
13609
- * it, its presses and its pose counting once: on the ticks between, the
13610
- * game's own movement carries the held command on from the pose. A Steer
13611
- * without one releases the hero.
13612
- */
13613
- steer(steering) {
13614
- return call("Steer", SteerRequest.toBinary({ player: this.slot, steering })) !== void 0;
13615
- }
13616
- /**
13617
- * drive gives a bot the controls a player has, where it looks, the
13618
- * movement axes and the buttons, as its input on every tick until the next
13619
- * Drive replaces it. The game runs that input as a player's own, so the
13620
- * hero accelerates, turns, jumps, dashes, slides and casts with its own
13621
- * movement and animation; the bot's own brain no longer moves it. Presses
13622
- * count once. A Drive without a command returns the bot to its brain.
13623
- */
13624
- drive(command2) {
13625
- return call("Drive", DriveRequest.toBinary({ player: this.slot, command: command2 })) !== void 0;
13626
- }
13627
- /**
13628
- * adjustSouls gives the player delta souls, or takes them when delta is
13629
- * negative. A spend larger than the player's souls fails and spends
13630
- * nothing. Silent skips the pickup's sound and number.
13631
- */
13632
- adjustSouls(delta, silent) {
13633
- return call("AdjustSouls", AdjustSoulsRequest.toBinary({ player: this.slot, delta: int32(delta), silent })) !== void 0;
13634
- }
13635
- /**
13636
- * adjustAbilityPoints gives the player ability points and ability unlocks,
13637
- * or takes them when negative, as Pawn.ability_points and
13638
- * Pawn.ability_unlocks read them. A spend larger than the player holds
13639
- * fails and spends nothing.
13640
- */
13641
- adjustAbilityPoints(points, unlocks) {
13642
- return call("AdjustAbilityPoints", AdjustAbilityPointsRequest.toBinary({ player: this.slot, points: int32(points), unlocks: int32(unlocks) })) !== void 0;
13643
- }
13644
- /** startingSouls sets the souls the player's hero spawns with. */
13645
- startingSouls(souls) {
13646
- return call("StartingSouls", StartingSoulsRequest.toBinary({ player: this.slot, souls: int32(souls) })) !== void 0;
13647
- }
13648
- /**
13649
- * resetHero rebuilds the player's hero as it first spawned, without items,
13650
- * ability upgrades, levels or ability points, holding souls.
13651
- */
13652
- resetHero(souls) {
13653
- return call("ResetHero", ResetHeroRequest.toBinary({ player: this.slot, souls: int32(souls) })) !== void 0;
13654
- }
13655
- /** heal restores health to the player's hero, up to its maximum. */
13656
- heal(amount) {
13657
- return call("Heal", HealRequest.toBinary({ player: this.slot, amount: int32(amount) })) !== void 0;
13658
- }
13659
- /**
13660
- * sound plays a game sound event, such as Damage.Send.Crit, on the
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.
13663
- */
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;
13669
- }
13670
- /**
13671
- * restoreHero gives the player's live hero target over the next few
13672
- * seconds: the build first, then health, stamina and pose once it settles,
13673
- * then charges and cooldowns. A Restored event reports when the result has
13674
- * held for a second, or why it could not. A new call replaces the running
13675
- * one. A pawn with hero 0 has no hero to restore; the call fails until
13676
- * SelectHero gives it one.
13677
- */
13678
- restoreHero(target) {
13679
- return call("RestoreHero", RestoreHeroRequest.toBinary({ player: this.slot, target: toHeroTarget(target) })) !== void 0;
13680
- }
13681
- /**
13682
- * screenEffect plays a full-screen effect on the player's view. Effects of
13683
- * one kind stack. The player's hero must be alive.
13684
- */
13685
- screenEffect(effect, timing) {
13686
- return call("ScreenEffect", ScreenEffectRequest.toBinary({ player: this.slot, effect: screenEffectValues[effect], timing })) !== void 0;
13687
- }
13688
- /**
13689
- * clearScreenEffect ends every running instance of effect on the player's
13690
- * view.
13691
- */
13692
- clearScreenEffect(effect) {
13693
- return call("ClearScreenEffect", ClearScreenEffectRequest.toBinary({ player: this.slot, effect: screenEffectValues[effect] })) !== void 0;
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
- }
13702
- /** removeBot removes a bot the mod added. */
13703
- removeBot() {
13704
- return call("RemoveBot", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13705
- }
13706
- /**
13707
- * blockInput withholds buttons from the player's hero until called
13708
- * again, on top of the block on everyone. Zero releases the player.
13709
- */
13710
- blockInput(buttons) {
13711
- return call("BlockPlayerInput", PlayerInputRequest.toBinary({ player: this.slot, buttons })) !== void 0;
13712
- }
13713
- /**
13714
- * press presses buttons at the player's next input, even through a block.
13715
- * A bot presses them as a player would.
13716
- */
13717
- press(buttons) {
13718
- return call("Press", PlayerInputRequest.toBinary({ player: this.slot, buttons })) !== void 0;
13719
- }
13720
- /** kill kills a player's hero, crediting no one. */
13721
- kill() {
13722
- return call("Kill", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13723
- }
13724
- /** setVelocity replaces the motion of a player's hero without moving it. */
13725
- setVelocity(velocity) {
13726
- return call("SetVelocity", SetVelocityRequest.toBinary({ player: this.slot, velocity })) !== void 0;
13727
- }
13728
- /**
13729
- * buttons returns the buttons a player holds, as Buttons bits, while the
13730
- * player is alive or dead.
13731
- */
13732
- buttons() {
13733
- const reply2 = call("Buttons", PlayerRequest.toBinary({ player: this.slot }));
13734
- if (reply2 === void 0) return void 0;
13735
- const response = ButtonsResponse.fromBinary(reply2);
13736
- return response.buttons ?? 0n;
13737
- }
13738
- /**
13739
- * watchMovement adds a player's hero to the movement samples of each Frame
13740
- * event on a new tick, or removes it.
13741
- */
13742
- watchMovement(watch) {
13743
- return call("WatchMovement", WatchMovementRequest.toBinary({ player: this.slot, watch })) !== void 0;
13744
- }
13745
- };
13746
- var WorldObject = class {
13747
- /** id identifies the object among the mod's objects. */
13748
- id;
13749
- constructor(id) {
13750
- this.id = id;
13751
- }
13752
- /**
13753
- * move places the object at position, turning it to facing. The
13754
- * physics step pulls a solid model to its new place over one tick, so a
13755
- * model moved each frame strikes physics props such as the Hideout ball
13756
- * with its speed instead of passing through them.
13757
- */
13758
- move(position, facing) {
13759
- return call("MoveObject", MoveObjectRequest.toBinary({ object: this.id, position, facing })) !== void 0;
13760
- }
13761
- /** setText replaces a text object's words. */
13762
- setText(text2) {
13763
- return call("SetText", SetTextRequest.toBinary({ object: this.id, text: text2 })) !== void 0;
13764
- }
13765
- /**
13766
- * setHidden hides the object from one player or shows it again.
13767
- * Other players still see it. A player who leaves sees every object when
13768
- * they return.
13769
- */
13770
- setHidden(player, hidden) {
13771
- return call("SetObjectHidden", SetObjectHiddenRequest.toBinary({ object: this.id, player: player.slot, hidden })) !== void 0;
13772
- }
13773
- /**
13774
- * showOnlyTo sends the object only to the players with the listed
13775
- * server slots; every other client drops it, or never receives it when the
13776
- * call follows its creation in the same frame. With no players no client
13777
- * receives it. The list replaces any earlier one and follows the object
13778
- * when its entity changes. A player who leaves is taken off every list, so
13779
- * whoever joins in their slot does not receive the object. A removed object
13780
- * reaches no client while the engine retires its entity.
13781
- */
13782
- showOnlyTo(players2) {
13783
- return call("ShowObjectOnlyTo", ShowObjectOnlyToRequest.toBinary({ object: this.id, players: players2?.map((v) => int32(v)) })) !== void 0;
13784
- }
13785
- /**
13786
- * showToAll sends the object to every player again, undoing
13787
- * ShowObjectOnlyTo.
13788
- */
13789
- showToAll() {
13790
- return call("ShowObjectToAll", ObjectRequest.toBinary({ object: this.id })) !== void 0;
13791
- }
13792
- /** remove takes the object out of the world. */
13793
- remove() {
13794
- return call("RemoveObject", ObjectRequest.toBinary({ object: this.id })) !== void 0;
13795
- }
13796
- /**
13797
- * entity returns the entity handle of a model or particle, as traces
13798
- * report it and particle anchors take it.
13799
- */
13800
- entity() {
13801
- const reply2 = call("ObjectEntity", ObjectRequest.toBinary({ object: this.id }));
13802
- if (reply2 === void 0) return void 0;
13803
- const response = EntityResponse.fromBinary(reply2);
13804
- return response.entity ?? 0;
13805
- }
13806
- };
13807
- var Npc = class {
13808
- /** entity is the unit's entity handle, as damage events report it. */
13809
- entity;
13810
- constructor(entity) {
13811
- this.entity = entity;
13812
- }
13813
- /** read returns the unit's state, or nothing once it is gone. */
13814
- read() {
13815
- const reply2 = call("ReadNpc", NpcRequest.toBinary({ npc: this.entity }));
13816
- if (reply2 === void 0) return void 0;
13817
- const response = NpcStateResponse.fromBinary(reply2);
13818
- return response.state === void 0 ? void 0 : fromNpcState(response.state);
13819
- }
13820
- /**
13821
- * move places the unit and sets its velocity, which drives its walk
13822
- * animation. It sets the pose without a teleport, which would reset the
13823
- * unit's animation, so a mode can steer its units every frame. It reports
13824
- * false once the unit is gone.
13825
- */
13826
- move(position, facing, velocity) {
13827
- const reply2 = call("MoveNpc", MoveNpcRequest.toBinary({ npc: this.entity, position, facing, velocity }));
13828
- if (reply2 === void 0) return false;
13829
- const response = AliveResponse.fromBinary(reply2);
13830
- return response.alive ?? false;
13831
- }
13832
- /**
13833
- * setHealth sets the unit's health, and its maximum when given. It
13834
- * reports false once the unit is gone.
13835
- */
13836
- setHealth(health, maxHealth) {
13837
- const reply2 = call("SetNpcHealth", SetNpcHealthRequest.toBinary({ npc: this.entity, health: int32(health), maxHealth: maxHealth === void 0 ? void 0 : int32(maxHealth) }));
13838
- if (reply2 === void 0) return false;
13839
- const response = AliveResponse.fromBinary(reply2);
13840
- return response.alive ?? false;
13841
- }
13842
- /**
13843
- * remove takes a unit the mod spawned out of the world without rewards.
13844
- * It reports false when the unit was already gone.
13845
- */
13846
- remove() {
13847
- const reply2 = call("RemoveNpc", NpcRequest.toBinary({ npc: this.entity }));
13848
- if (reply2 === void 0) return false;
13849
- const response = AliveResponse.fromBinary(reply2);
13850
- return response.alive ?? false;
13851
- }
13852
- };
13853
- var Pickup = class {
13854
- /** entity is the pickup's entity handle. */
13855
- entity;
13856
- constructor(entity) {
13857
- this.entity = entity;
13858
- }
13859
- /**
13860
- * present reports whether the pickup still lies in the world,
13861
- * uncollected.
13862
- */
13863
- present() {
13864
- const reply2 = call("PickupPresent", PickupRequest.toBinary({ pickup: this.entity }));
13865
- if (reply2 === void 0) return false;
13866
- const response = AliveResponse.fromBinary(reply2);
13867
- return response.alive ?? false;
13868
- }
13869
- /**
13870
- * remove takes the pickup out of the world. It reports false when a
13871
- * player had collected it.
13872
- */
13873
- remove() {
13874
- const reply2 = call("RemovePickup", PickupRequest.toBinary({ pickup: this.entity }));
13875
- if (reply2 === void 0) return false;
13876
- const response = AliveResponse.fromBinary(reply2);
13877
- return response.alive ?? false;
13878
- }
13879
- };
13880
- function log(message) {
13881
- return call("Log", LogRequest.toBinary({ message })) !== void 0;
13882
- }
13883
- function serverCommand(command2) {
13884
- return call("ServerCommand", ServerCommandRequest.toBinary({ command: command2 })) !== void 0;
13885
- }
13886
- function precache(options) {
13887
- return call("Precache", PrecacheOptions.toBinary(toPrecacheOptions(options))) !== void 0;
13888
- }
13889
- function readFile(path) {
13890
- const reply2 = call("ReadFile", ReadFileRequest.toBinary({ path }));
13891
- if (reply2 === void 0) return void 0;
13892
- const response = ReadFileResponse.fromBinary(reply2);
13893
- return response.text;
13894
- }
13895
- function writeFile(path, text2) {
13896
- return call("WriteFile", WriteFileRequest.toBinary({ path, text: text2 })) !== void 0;
13897
- }
13898
- function holdReload(held) {
13899
- return call("HoldReload", HoldReloadRequest.toBinary({ held })) !== void 0;
13900
- }
13901
- function handoff(text2) {
13902
- return call("Handoff", HandoffRequest.toBinary({ text: text2 })) !== void 0;
13903
- }
13904
- function handedOff() {
13905
- const reply2 = call("HandedOff", new Uint8Array());
13906
- if (reply2 === void 0) return void 0;
13907
- const response = HandedOffResponse.fromBinary(reply2);
13908
- return response.text ?? "";
13909
- }
13910
- function heroBuild(hero) {
13911
- const reply2 = call("HeroBuild", HeroBuildRequest.toBinary({ hero }));
13912
- if (reply2 === void 0) return [];
13913
- const response = HeroBuildResponse.fromBinary(reply2);
13914
- return (response.categories ?? []).map((v) => fromBuildCategory(v));
13915
- }
13916
- function silenceVoice(concepts) {
13917
- return call("SilenceVoice", SilenceVoiceRequest.toBinary({ concepts: concepts?.slice() })) !== void 0;
13918
- }
13919
- function readField(entity, className, field, type) {
13920
- const reply2 = call("ReadField", ReadFieldRequest.toBinary({ entity, className, field, type: fieldTypeValues[type] }));
13921
- if (reply2 === void 0) return void 0;
13922
- const response = FieldResponse.fromBinary(reply2);
13923
- return fromFieldValue(response.value);
13924
- }
13925
- function readModifierField(entity, modifier, className, field, type) {
13926
- const reply2 = call("ReadModifierField", ReadModifierFieldRequest.toBinary({ entity, modifier, className, field, type: fieldTypeValues[type] }));
13927
- if (reply2 === void 0) return void 0;
13928
- const response = FieldResponse.fromBinary(reply2);
13929
- return fromFieldValue(response.value);
13930
- }
13931
- function writeField(entity, className, field, type, value) {
13932
- return call("WriteField", WriteFieldRequest.toBinary({ entity, className, field, type: fieldTypeValues[type], value: toFieldValue(value) })) !== void 0;
13933
- }
13934
- function readFieldList(entity, className, field, type) {
13935
- const reply2 = call("ReadFieldList", ReadFieldRequest.toBinary({ entity, className, field, type: fieldTypeValues[type] }));
13936
- if (reply2 === void 0) return [];
13937
- const response = FieldListResponse.fromBinary(reply2);
13938
- return known(response.values, (v) => fromFieldValue(v));
13939
- }
13940
- function writeFieldList(entity, className, field, type, values) {
13941
- return call("WriteFieldList", WriteFieldListRequest.toBinary({ entity, className, field, type: fieldTypeValues[type], values: values?.map((v) => toFieldValue(v)) })) !== void 0;
13942
- }
13943
- function entityClass(entity) {
13944
- const reply2 = call("EntityClass", EntityRequest.toBinary({ entity }));
13945
- if (reply2 === void 0) return void 0;
13946
- const response = EntityClassResponse.fromBinary(reply2);
13947
- return response.name === void 0 ? void 0 : fromEntityClassName(response.name);
13948
- }
13949
- function entityName(entity) {
13950
- const reply2 = call("EntityName", EntityRequest.toBinary({ entity }));
13951
- if (reply2 === void 0) return void 0;
13952
- const response = EntityNameResponse.fromBinary(reply2);
13953
- return response.name ?? "";
13954
- }
13955
- function entityPosition(entity) {
13956
- const reply2 = call("EntityPosition", EntityRequest.toBinary({ entity }));
13957
- if (reply2 === void 0) return void 0;
13958
- const response = EntityPositionResponse.fromBinary(reply2);
13959
- return response.placement === void 0 ? void 0 : fromEntityPlacement(response.placement);
13960
- }
13961
- function modifierState(entity, state) {
13962
- const reply2 = call("ModifierState", ModifierStateRequest.toBinary({ entity, state }));
13963
- if (reply2 === void 0) return false;
13964
- const response = ActiveResponse.fromBinary(reply2);
13965
- return response.active ?? false;
13966
- }
13967
- function holdModifierState(entity, state, active) {
13968
- return call("HoldModifierState", HoldModifierStateRequest.toBinary({ entity, state, active })) !== void 0;
13969
- }
13970
- function setFreeForAll(enabled) {
13971
- return call("SetFreeForAll", SetFreeForAllRequest.toBinary({ enabled })) !== void 0;
13972
- }
13973
- function setTeamSeating(enabled) {
13974
- return call("SetTeamSeating", SetTeamSeatingRequest.toBinary({ enabled })) !== void 0;
13975
- }
13976
- function createModel(options) {
13977
- const reply2 = call("CreateModel", ModelOptions.toBinary(options));
13978
- if (reply2 === void 0) return void 0;
13979
- const response = ObjectResponse.fromBinary(reply2);
13980
- return new WorldObject(response.object ?? 0);
13981
- }
13982
- function createText(options) {
13983
- const reply2 = call("CreateText", TextOptions.toBinary(toTextOptions(options)));
13984
- if (reply2 === void 0) return void 0;
13985
- const response = ObjectResponse.fromBinary(reply2);
13986
- return new WorldObject(response.object ?? 0);
13987
- }
13988
- function createParticle(options) {
13989
- const reply2 = call("CreateParticle", ParticleOptions.toBinary(toParticleOptions(options)));
13990
- if (reply2 === void 0) return void 0;
13991
- const response = ObjectResponse.fromBinary(reply2);
13992
- return new WorldObject(response.object ?? 0);
13993
- }
13994
- function createFog(options) {
13995
- const reply2 = call("CreateFog", FogOptions.toBinary(options));
13996
- if (reply2 === void 0) return void 0;
13997
- const response = ObjectResponse.fromBinary(reply2);
13998
- return new WorldObject(response.object ?? 0);
13999
- }
14000
- function addBot(options) {
14001
- const reply2 = call("AddBot", BotOptions.toBinary(toBotOptions(options)));
14002
- if (reply2 === void 0) return void 0;
14003
- const response = BotResponse.fromBinary(reply2);
14004
- return Player.of(response.player ?? 0);
14005
- }
14006
- function blockInput(buttons) {
14007
- return call("BlockInput", InputRequest.toBinary({ buttons })) !== void 0;
14008
- }
14009
- function watchInput(buttons) {
14010
- return call("WatchInput", InputRequest.toBinary({ buttons })) !== void 0;
14011
- }
14012
- function remapInput(from, to, repeat2) {
14013
- return call("RemapInput", RemapInputRequest.toBinary({ from, to, repeat: repeat2 })) !== void 0;
14014
- }
14015
- function callService(service2, method, payload) {
14016
- const reply2 = call("CallService", ServiceCall.toBinary({ service: service2, method, payload }));
14017
- if (reply2 === void 0) return void 0;
14018
- const response = ServiceReply.fromBinary(reply2);
14019
- return response.payload ?? new Uint8Array();
14020
- }
14021
- function createEntity(options) {
14022
- const reply2 = call("CreateEntity", EntityOptions.toBinary(toEntityOptions(options)));
14023
- if (reply2 === void 0) return void 0;
14024
- const response = EntityResponse.fromBinary(reply2);
14025
- return response.entity ?? 0;
14026
- }
14027
- function fireInput(entity, input2, value, activator) {
14028
- const reply2 = call("FireInput", FireInputRequest.toBinary({ entity, input: input2, value: value === void 0 ? void 0 : toEntityValue(value), activator }));
14029
- if (reply2 === void 0) return false;
14030
- const response = AliveResponse.fromBinary(reply2);
14031
- return response.alive ?? false;
14032
- }
14033
- function removeEntity(entity) {
14034
- const reply2 = call("RemoveEntity", EntityRequest.toBinary({ entity }));
14035
- if (reply2 === void 0) return false;
14036
- const response = AliveResponse.fromBinary(reply2);
14037
- return response.alive ?? false;
14038
- }
14039
- function showEntityOnlyTo(entity, players2) {
14040
- return call("ShowEntityOnlyTo", ShowEntityOnlyToRequest.toBinary({ entity, players: players2?.map((v) => int32(v)) })) !== void 0;
14041
- }
14042
- function showEntityToAll(entity) {
14043
- return call("ShowEntityToAll", EntityRequest.toBinary({ entity })) !== void 0;
14044
- }
14045
- function spawnNpc(options) {
14046
- const reply2 = call("SpawnNpc", NpcOptions.toBinary(toNpcOptions(options)));
14047
- if (reply2 === void 0) return void 0;
14048
- const response = NpcResponse.fromBinary(reply2);
14049
- return new Npc(response.npc ?? 0);
14050
- }
14051
- function createPickup(kind, position) {
14052
- const reply2 = call("CreatePickup", CreatePickupRequest.toBinary({ kind: pickupKindValues[kind], position }));
14053
- if (reply2 === void 0) return void 0;
14054
- const response = PickupResponse.fromBinary(reply2);
14055
- return new Pickup(response.pickup ?? 0);
14056
- }
14057
- function findEntities(className) {
14058
- const reply2 = call("FindEntities", FindEntitiesRequest.toBinary({ className }));
14059
- if (reply2 === void 0) return [];
14060
- const response = EntitiesResponse.fromBinary(reply2);
14061
- return response.entities ?? [];
14062
- }
14063
- function findEntitiesByName(name) {
14064
- const reply2 = call("FindEntitiesByName", FindEntitiesByNameRequest.toBinary({ name }));
14065
- if (reply2 === void 0) return [];
14066
- const response = EntitiesResponse.fromBinary(reply2);
14067
- return response.entities ?? [];
14068
- }
14069
- function removeEntities(className) {
14070
- const reply2 = call("RemoveEntities", RemoveEntitiesRequest.toBinary({ className }));
14071
- if (reply2 === void 0) return void 0;
14072
- const response = CountResponse.fromBinary(reply2);
14073
- return response.count ?? 0;
14074
- }
14075
- function clearMap() {
14076
- return call("ClearMap", new Uint8Array()) !== void 0;
14077
- }
14078
- function damage(options) {
14079
- return call("Damage", HitOptions.toBinary(toHitOptions(options))) !== void 0;
14080
- }
14081
- function killEntity(options) {
14082
- return call("KillEntity", KillOptions.toBinary(options)) !== void 0;
14083
- }
14084
- function trace(options) {
14085
- const reply2 = call("Trace", TraceOptions.toBinary(toTraceOptions(options)));
14086
- if (reply2 === void 0) return void 0;
14087
- const response = TraceResponse.fromBinary(reply2);
14088
- return response.hit === void 0 ? void 0 : fromTraceHit(response.hit);
14089
- }
14090
- function restoreNpcs(npcs) {
14091
- return call("RestoreNpcs", RestoreNpcsRequest.toBinary({ npcs: npcs?.map((v) => toNpcTarget(v)) })) !== void 0;
14092
- }
14093
- function pause(paused) {
14094
- return call("Pause", PauseRequest.toBinary({ paused })) !== void 0;
14095
- }
14096
- function matchClock() {
14097
- const reply2 = call("MatchClock", new Uint8Array());
14098
- if (reply2 === void 0) return void 0;
14099
- const response = MatchClockResponse.fromBinary(reply2);
14100
- return response.seconds ?? 0;
14101
- }
14102
- function holdMatchClock(seconds) {
14103
- return call("HoldMatchClock", HoldMatchClockRequest.toBinary({ seconds })) !== void 0;
14104
- }
14105
- function rift() {
14106
- const reply2 = call("Rift", new Uint8Array());
14107
- if (reply2 === void 0) return void 0;
14108
- const response = RiftResponse.fromBinary(reply2);
14109
- return response.state === void 0 ? void 0 : fromRiftState(response.state);
14110
- }
14111
- function startRift(position) {
14112
- return call("StartRift", StartRiftRequest.toBinary({ position })) !== void 0;
14113
- }
14114
- function moveEntity(entity, position, facing, velocity) {
14115
- return call("MoveEntity", MoveEntityRequest.toBinary({ entity, position, facing, velocity })) !== void 0;
14116
- }
14117
- function pushEntity(entity, velocity, spin) {
14118
- return call("PushEntity", PushEntityRequest.toBinary({ entity, velocity, spin })) !== void 0;
14119
- }
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;
14131
- }
14132
- function watchProjectiles(options) {
14133
- return call("WatchProjectiles", ProjectileOptions.toBinary(toProjectileOptions(options))) !== void 0;
14134
- }
14135
- function serveMod(handlers2, bytes) {
14136
- const request = Call.fromBinary(bytes);
14137
- const input2 = request.request ?? new Uint8Array();
14138
- try {
14139
- switch (request.method) {
14140
- case "Start":
14141
- return reply(StartResult.toBinary(handlers2.start(fromStartEvent(StartEvent.fromBinary(input2)))));
14142
- case "Frame":
14143
- handlers2.frame(fromFrameEvent(FrameEvent.fromBinary(input2)));
14144
- return reply();
14145
- case "Command":
14146
- return reply(CommandResult.toBinary(handlers2.command(fromCommandEvent(CommandEvent.fromBinary(input2)))));
14147
- case "Chat":
14148
- handlers2.chat(fromChatEvent(ChatEvent.fromBinary(input2)));
14149
- return reply();
14150
- case "World":
14151
- handlers2.world(fromWorldEvent(WorldEvent.fromBinary(input2)));
14152
- return reply();
14153
- case "UiPress":
14154
- handlers2.uiPress(fromUiPressEvent(UiPressEvent.fromBinary(input2)));
14155
- return reply();
14156
- case "UiInput":
14157
- handlers2.uiInput(fromUiInputEvent(UiInputEvent.fromBinary(input2)));
14158
- return reply();
14159
- case "Serve":
14160
- return reply(ServiceReply.toBinary(handlers2.serve(fromServiceCall(ServiceCall.fromBinary(input2)))));
14161
- case "Damage":
14162
- return reply(DamageResult.toBinary(handlers2.damage(fromDamageEvent(DamageEvent.fromBinary(input2)))));
14163
- case "Damaged":
14164
- handlers2.damaged(fromDamagedEvent(DamagedEvent.fromBinary(input2)));
14165
- return reply();
14166
- case "Input":
14167
- handlers2.input(fromInputEvent(InputEvent.fromBinary(input2)));
14168
- return reply();
14169
- case "Restored":
14170
- handlers2.restored(fromRestoredEvent(RestoredEvent.fromBinary(input2)));
14171
- return reply();
14172
- case "NpcsRestored":
14173
- handlers2.npcsRestored(fromNpcsRestoredEvent(NpcsRestoredEvent.fromBinary(input2)));
14174
- return reply();
14175
- case "Launch":
14176
- handlers2.launch(fromLaunchEvent(LaunchEvent.fromBinary(input2)));
14177
- return reply();
14178
- case "Impact":
14179
- handlers2.impact(fromImpactEvent(ImpactEvent.fromBinary(input2)));
14180
- return reply();
14181
- case "Landed":
14182
- handlers2.landed(fromLandedEvent(LandedEvent.fromBinary(input2)));
14183
- return reply();
14184
- case "SettingChanged":
14185
- handlers2.settingChanged(fromSettingChangedEvent(SettingChangedEvent.fromBinary(input2)));
14186
- return reply();
14187
- case "PlayerJoined":
14188
- handlers2.playerJoined(fromPlayerJoinedEvent(PlayerJoinedEvent.fromBinary(input2)));
14189
- return reply();
14190
- case "PlayerLeft":
14191
- handlers2.playerLeft(fromPlayerLeftEvent(PlayerLeftEvent.fromBinary(input2)));
14192
- return reply();
14193
- case "PlayersChanged":
14194
- handlers2.playersChanged(fromPlayersChangedEvent(PlayersChangedEvent.fromBinary(input2)));
14195
- return reply();
14196
- }
14197
- } catch (error) {
14198
- return Reply.toBinary({ error: String(error) });
14199
- }
14200
- return Reply.toBinary({ error: `the mod has no method ${request.method}` });
14201
- }
14202
-
14203
- // js/src/players.ts
14204
- var roster = void 0;
14205
- var generations = /* @__PURE__ */ new Map();
14206
- var watchers = [];
14207
- function keepPlayers(players2) {
14208
- roster = adopt(players2);
14209
- for (const watcher of watchers) {
14210
- watcher(roster);
14211
- }
14212
- }
14213
- function adopt(players2) {
14214
- const current = new Map(players2.map((c) => [c.player.slot, c.generation]));
14215
- for (const [slot, generation] of generations) {
14216
- if (current.get(slot) !== generation) Player.release(slot);
14217
- }
14218
- generations.clear();
14219
- return players2.map((c) => {
14220
- generations.set(c.player.slot, c.generation);
14221
- const player = Player.of(c.player.slot);
14222
- return player === c.player ? c : { ...c, player };
14223
- });
14224
- }
14225
- function watchPlayers(watcher) {
14226
- watchers.push(watcher);
14227
- if (roster !== void 0) watcher(roster);
14228
- }
14229
- function players() {
14230
- if (roster !== void 0) return roster.slice();
14231
- const reply2 = call("Players", new Uint8Array());
14232
- if (reply2 === void 0) return [];
14233
- return adopt(
14234
- (PlayersResponse.fromBinary(reply2).players ?? []).map((c) => ({
14235
- player: Player.of(c.player ?? 0),
14236
- steamId: c.steamId ?? 0n,
14237
- name: c.name ?? "",
14238
- bot: c.bot ?? false,
14239
- ready: c.ready ?? false,
14240
- generation: c.generation ?? 0,
14241
- roles: (c.roles ?? []).flatMap((role) => roleNames[role] ?? [])
14242
- }))
14243
- );
14244
- }
14245
- var roleNames = {
14246
- [1 /* DEVELOPER */]: "developer",
14247
- [2 /* TESTER */]: "tester"
14248
- };
14249
-
14250
- // js/src/puppet.ts
14251
- var ticksPerSecond = 64;
14252
- function trackTicks(track) {
14253
- return Math.max(track.x.length - 1, 0) * track.stepTicks;
14254
- }
14255
- function lerp(a, b, t) {
14256
- return a + (b - a) * t;
14257
- }
14258
- function lerpAngle(a, b, t) {
14259
- const delta = ((b - a) % 360 + 540) % 360 - 180;
14260
- return a + delta * t;
14261
- }
14262
- function poseAt(track, tick2) {
14263
- const last = track.x.length - 1;
14264
- if (last < 0) return void 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));
14267
- const j = Math.min(i + 1, last);
14268
- const t = at3 - i;
14269
- const seconds = track.stepTicks / ticksPerSecond;
14270
- const blend = (column) => lerp(sample(column, i), sample(column, j), t);
14271
- const slope = (column) => (sample(column, j) - sample(column, i)) / seconds;
14272
- const still = i === j;
14273
- return {
14274
- position: { x: blend(track.x), y: blend(track.y), z: blend(track.z) },
14275
- facing: {
14276
- pitch: track.pitch ? blend(track.pitch) : 0,
14277
- yaw: lerpAngle(sample(track.yaw, i), sample(track.yaw, j), t),
14278
- roll: 0
14279
- },
14280
- velocity: still ? { x: 0, y: 0, z: 0 } : { x: slope(track.x), y: slope(track.y), z: slope(track.z) },
14281
- health: track.health && blend(track.health)
14282
- };
14283
- }
14284
- function sample(column, index) {
14285
- return column[index] ?? 0;
14286
- }
14287
- var ghostStates = [
14288
- "MODIFIER_STATE_INVULNERABLE",
14289
- "MODIFIER_STATE_NO_TARGET",
14290
- "MODIFIER_STATE_IGNORED_BY_UNIT_FILTER",
14291
- "MODIFIER_STATE_IGNORED_BY_NPC_TARGETING",
14292
- "MODIFIER_STATE_INVISIBLE_ON_MINIMAP",
14293
- "MODIFIER_STATE_UNIT_STATUS_HIDDEN"
14294
- ];
14295
- var ghostAlpha = 110;
14296
- var renderTransColor = 1;
14297
- var live = /* @__PURE__ */ new Set();
14298
- var longestFrame = 0.25;
14299
- function advancePuppets(seconds) {
14300
- for (const puppet of live) puppet.advance(seconds);
14301
- }
14302
- var Puppet = class _Puppet {
14303
- /**
14304
- * The puppet drives player's hero along track. It owns the hero's placement
14305
- * and, when the track records health, its health.
14306
- */
14307
- constructor(player, track, options = {}) {
14308
- this.player = player;
14309
- this.track = track;
14310
- this.snapUnits = options.snapUnits ?? 200;
14311
- live.add(this);
14312
- if (options.ghost) this.setGhost(true);
14313
- }
14314
- player;
14315
- track;
14316
- tickAt = 0;
14317
- rateNow = 1;
14318
- current = "paused";
14319
- /** clock is the game time of the last frame, unset until one arrives. */
14320
- clock;
14321
- /** drawn is whether the hero needs placing at the current tick. */
14322
- drawn = false;
14323
- ghostNow = false;
14324
- dead = false;
14325
- /** looked is the entity and ghost setting syncLook last wrote. */
14326
- looked;
14327
- lastHealth;
14328
- snapUnits;
14329
- /**
14330
- * spawn adds a bot and returns a puppet for it, or undefined when no bot
14331
- * could join. The bot appears at the track's first pose.
14332
- */
14333
- static spawn(bot, track, options) {
14334
- const start = poseAt(track, 0);
14335
- const player = addBot({ ...bot, position: bot.position ?? start?.position });
14336
- return player && new _Puppet(player, track, options);
14337
- }
14338
- /** state is where playback stands. */
14339
- get state() {
14340
- return this.current;
14341
- }
14342
- /** tick is the playback position, in track ticks. */
14343
- get tick() {
14344
- return this.tickAt;
14345
- }
14346
- /** rate is the playback speed: 1 is real time, 0.5 half speed, negative runs backward. */
14347
- get rate() {
14348
- return this.rateNow;
14349
- }
14350
- set rate(rate) {
14351
- this.rateNow = rate;
14352
- }
14353
- /** isGhost reports whether the puppet is a ghost. */
14354
- get isGhost() {
14355
- return this.ghostNow;
14356
- }
14357
- /** play starts or resumes playback; from the end it restarts at tick 0. */
14358
- play() {
14359
- if (this.current === "ended" && this.rateNow >= 0) this.seek(0);
14360
- this.current = "playing";
14361
- }
14362
- /** pause holds the hero where it stands. */
14363
- pause() {
14364
- this.current = "paused";
14365
- }
14366
- /**
14367
- * seek moves playback to tick, clamped to the track, and places the hero
14368
- * there on the next frame. Playback keeps its state, except that an ended
14369
- * puppet paused at the new tick.
14370
- */
14371
- seek(tick2) {
14372
- this.tickAt = Math.min(Math.max(tick2, 0), trackTicks(this.track));
14373
- this.drawn = false;
14374
- this.lastHealth = void 0;
14375
- if (this.current === "ended") this.current = "paused";
14376
- }
14377
- /**
14378
- * setGhost draws the hero translucent and holds the modifier states of
14379
- * ghostStates, so it takes no damage and is not targeted; off restores
14380
- * both. The hero's collision with other heroes is the game's own.
14381
- */
14382
- setGhost(ghost) {
14383
- this.ghostNow = ghost;
14384
- const pawn = this.player.pawn();
14385
- if (pawn) this.syncLook(pawn.entity);
14386
- }
14387
- /**
14388
- * syncLook writes the ghost look and states to the hero entity when the
14389
- * entity or the ghost setting differs from what it last wrote, so a hero
14390
- * that respawned takes them again.
14391
- */
14392
- syncLook(entity) {
14393
- if (this.looked?.entity === entity && this.looked.ghost === this.ghostNow) {
14394
- return;
14395
- }
14396
- this.looked = { entity, ghost: this.ghostNow };
14397
- for (const state of ghostStates) {
14398
- holdModifierState(entity, state, this.ghostNow);
14399
- }
14400
- const alpha = this.ghostNow ? ghostAlpha : 255;
14401
- const mode = this.ghostNow ? renderTransColor : 0;
14402
- writeField(entity, "CBaseModelEntity", "m_nRenderMode", "uint8", mode);
14403
- writeField(
14404
- entity,
14405
- "CBaseModelEntity",
14406
- "m_clrRender",
14407
- "uint32",
14408
- 16777215 | alpha << 24
14409
- );
14410
- }
14411
- /** stop ends the puppet and removes its bot; a hero that is not a bot stays. */
14412
- stop() {
14413
- live.delete(this);
14414
- const pawn = this.player.pawn();
14415
- if (pawn && this.ghostNow) {
14416
- this.ghostNow = false;
14417
- this.syncLook(pawn.entity);
14418
- }
14419
- const slot = this.player.slot;
14420
- if (players().some((c) => c.player.slot === slot && c.bot)) {
14421
- this.player.removeBot();
14422
- }
14423
- }
14424
- /**
14425
- * advance moves playback to the game clock at seconds and places the hero.
14426
- * The library calls it each frame; a mod calls it only to step a puppet by
14427
- * hand.
14428
- */
14429
- advance(seconds) {
14430
- const elapsed = Math.min(seconds - (this.clock ?? seconds), longestFrame);
14431
- this.clock = seconds;
14432
- if (this.current === "playing" && elapsed > 0) {
14433
- this.tickAt += elapsed * ticksPerSecond * this.rateNow;
14434
- const end = trackTicks(this.track);
14435
- if (this.tickAt >= end || this.tickAt <= 0) {
14436
- this.tickAt = Math.min(Math.max(this.tickAt, 0), end);
14437
- this.current = "ended";
14438
- }
14439
- this.drawn = false;
14440
- }
14441
- if (!this.drawn) this.place();
14442
- }
14443
- /** place puts the hero at the current tick; it retries next frame without a hero. */
14444
- place() {
14445
- const pawn = this.player.pawn();
14446
- const pose = poseAt(this.track, this.tickAt);
14447
- if (!pawn || !pose) return;
14448
- this.syncLook(pawn.entity);
14449
- const gap2 = Math.hypot(
14450
- pose.position.x - pawn.position.x,
14451
- pose.position.y - pawn.position.y,
14452
- pose.position.z - pawn.position.z
14453
- );
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);
14455
- if (placed) this.drawn = true;
14456
- this.setHealth(pawn.entity, pose.health);
14457
- }
14458
- /**
14459
- * setHealth gives the hero the recorded health. A recorded zero kills the
14460
- * hero once; the first health above zero after that respawns it, and the
14461
- * next frame places it.
14462
- */
14463
- setHealth(entity, health) {
14464
- if (health === void 0) return;
14465
- if (health <= 0) {
14466
- if (!this.dead) this.dead = this.player.kill();
14467
- return;
14468
- }
14469
- if (this.dead) {
14470
- this.dead = !this.player.respawn();
14471
- this.drawn = false;
14472
- return;
14473
- }
14474
- const rounded = Math.round(health);
14475
- if (rounded !== this.lastHealth) {
14476
- writeField(entity, "CBaseEntity", "m_iHealth", "int32", rounded);
14477
- this.lastHealth = rounded;
14478
- }
14479
- }
14480
- };
14481
-
14482
- // js/src/restore.ts
14483
- var waiting = /* @__PURE__ */ new Map();
14484
- function restoreHero(player, snapshot, done) {
14485
- const target = {
14486
- position: snapshot.position,
14487
- facing: snapshot.facing,
14488
- health: snapshot.health,
14489
- maxHealth: snapshot.maxHealth,
14490
- level: snapshot.level,
14491
- upgradeBonuses: snapshot.upgradeBonuses,
14492
- abilities: snapshot.abilities,
14493
- items: snapshot.items,
14494
- replaceItems: snapshot.items !== void 0,
14495
- timers: snapshot.timers
14496
- };
14497
- if (snapshot.souls !== void 0) player.startingSouls(snapshot.souls);
14498
- waiting.set(player.slot, { souls: snapshot.souls, done });
14499
- if (player.restoreHero(target)) return true;
14500
- waiting.delete(player.slot);
14501
- return false;
14502
- }
14503
- function settleRestore(player, error) {
14504
- const restore = waiting.get(player.slot);
14505
- if (!restore) return;
14506
- waiting.delete(player.slot);
14507
- const held = player.pawn()?.souls;
14508
- if (restore.souls !== void 0 && held !== void 0 && held !== restore.souls) {
14509
- player.adjustSouls(restore.souls - held, true);
14510
- }
14511
- restore.done?.(error);
14512
- }
14513
-
14514
- // js/src/timer.ts
14515
- var Entry = class {
14516
- /**
14517
- * run is the entry's callback. It returns the delay in seconds before its
14518
- * next run, or undefined when it has run for the last time.
14519
- */
14520
- constructor(delay, run) {
14521
- this.delay = delay;
14522
- this.run = run;
14523
- this.at = now === void 0 ? void 0 : now + delay;
14524
- }
14525
- delay;
14526
- run;
14527
- finished = false;
14528
- /** at is the game time the entry next runs, unset until the clock is known. */
14529
- at;
14530
- /** start counts the first delay from the frame at seconds, once. */
14531
- start(seconds) {
14532
- this.at ??= seconds + this.delay;
14533
- }
14534
- cancel() {
14535
- this.finished = true;
14536
- }
14537
- };
14538
- var now;
14539
- var entries = [];
14540
- function after(seconds, fn) {
14541
- return schedule(seconds, () => {
14542
- fn();
14543
- return void 0;
14544
- });
14545
- }
14546
- function every(seconds, fn) {
14547
- return schedule(seconds, () => {
14548
- fn();
14549
- return seconds;
14550
- });
14551
- }
14552
- function sequence(fn) {
14553
- let run = 0;
14554
- return schedule(0, () => fn(++run) ?? void 0);
14555
- }
14556
- function schedule(delay, run) {
14557
- const entry = new Entry(delay, run);
14558
- entries.push(entry);
14559
- return entry;
14560
- }
14561
- function advance(seconds) {
14562
- if (now !== void 0 && seconds < now) {
14563
- const shift = seconds - now;
14564
- for (const entry of entries) {
14565
- if (entry.at !== void 0) {
14566
- entry.at += shift;
14567
- }
14568
- }
14569
- }
14570
- now = seconds;
14571
- for (const entry of entries) {
14572
- entry.start(seconds);
14573
- }
14574
- const due = entries.filter((entry) => !entry.finished && entry.at <= seconds).sort((a, b) => a.at - b.at);
14575
- for (const entry of due) {
14576
- if (entry.finished) {
14577
- continue;
14578
- }
14579
- try {
14580
- const wait = entry.run();
14581
- if (wait === void 0) {
14582
- entry.finished = true;
14583
- } else {
14584
- const next = entry.at + wait;
14585
- entry.at = next > seconds ? next : seconds + wait;
14586
- }
14587
- } catch (error) {
14588
- entry.finished = true;
14589
- log(`timer failed: ${String(error)}`);
14590
- }
14591
- }
14592
- entries = entries.filter((entry) => !entry.finished);
14593
- }
14594
-
14595
- // js/src/item-id.ts
14596
- function itemId(name) {
14597
- const m = 1540483477;
14598
- const data = new TextEncoder().encode(name);
14599
- const byte = (at3) => data[at3] ?? 0;
14600
- let h = (826366246 ^ data.length) >>> 0;
14601
- let i = 0;
14602
- for (; data.length - i >= 4; i += 4) {
14603
- let k = (byte(i) | byte(i + 1) << 8 | byte(i + 2) << 16 | byte(i + 3) << 24) >>> 0;
14604
- k = Math.imul(k, m) >>> 0;
14605
- k = (k ^ k >>> 24) >>> 0;
14606
- k = Math.imul(k, m) >>> 0;
14607
- h = Math.imul(h, m) >>> 0;
14608
- h = (h ^ k) >>> 0;
14609
- }
14610
- const rest = data.length - i;
14611
- if (rest >= 3) h = (h ^ byte(i + 2) << 16) >>> 0;
14612
- if (rest >= 2) h = (h ^ byte(i + 1) << 8) >>> 0;
14613
- if (rest >= 1) {
14614
- h = (h ^ byte(i)) >>> 0;
14615
- h = Math.imul(h, m) >>> 0;
14616
- }
14617
- h = (h ^ h >>> 13) >>> 0;
14618
- h = Math.imul(h, m) >>> 0;
14619
- return (h ^ h >>> 15) >>> 0;
14620
- }
14621
-
14622
12594
  // js/src/heroes.ts
14623
12595
  var heroes = [
14624
12596
  {
@@ -14885,17 +12857,2322 @@ var heroes = [
14885
12857
  title: "Yamato",
14886
12858
  portrait: "file://{images}/heroes/yamato_sm.psd"
14887
12859
  }
14888
- ];
14889
- function findHero(typed) {
14890
- return findTitled(heroes, typed);
14891
- }
14892
- function findTitled(list, typed) {
14893
- const key = typed.toLowerCase().replace(/[^a-z0-9_]/g, "");
14894
- if (key === "") {
12860
+ ];
12861
+ var heroesByName = new Map([
12862
+ ...heroes.map((hero) => [plain(hero.title), hero]),
12863
+ ...heroes.map((hero) => [hero.name.replace(/^hero_/, ""), hero]),
12864
+ ...heroes.map((hero) => [hero.name, hero])
12865
+ ]);
12866
+ function heroNamed(name) {
12867
+ return heroesByName.get(plain(name));
12868
+ }
12869
+ function plain(text2) {
12870
+ return text2.toLowerCase().replace(/[^a-z0-9_]/g, "");
12871
+ }
12872
+ function findHero(typed) {
12873
+ return findTitled(heroes, typed);
12874
+ }
12875
+ function findTitled(list, typed) {
12876
+ const key = plain(typed);
12877
+ if (key === "") {
12878
+ return void 0;
12879
+ }
12880
+ const title = (entry) => entry.title.toLowerCase().replace(/[^a-z0-9]/g, "");
12881
+ return list.find((entry) => entry.name === key || title(entry) === key) ?? list.find((entry) => title(entry).startsWith(key)) ?? list.find((entry) => title(entry).includes(key));
12882
+ }
12883
+
12884
+ // js/src/host.gen.ts
12885
+ function vector(value) {
12886
+ return { x: value?.x ?? 0, y: value?.y ?? 0, z: value?.z ?? 0 };
12887
+ }
12888
+ function int32(value) {
12889
+ return Math.trunc(Math.min(Math.max(value, -2147483648), 2147483647));
12890
+ }
12891
+ function heroName(name) {
12892
+ return heroNamed(name)?.name ?? name;
12893
+ }
12894
+ function angles(value) {
12895
+ return { pitch: value?.pitch ?? 0, yaw: value?.yaw ?? 0, roll: value?.roll ?? 0 };
12896
+ }
12897
+ function known(values, decode) {
12898
+ const out = [];
12899
+ for (const v of values ?? []) {
12900
+ const decoded = decode(v);
12901
+ if (decoded !== void 0) {
12902
+ out.push(decoded);
12903
+ }
12904
+ }
12905
+ return out;
12906
+ }
12907
+ function reply(response) {
12908
+ return Reply.toBinary({ response });
12909
+ }
12910
+ var screenEffectValues = {
12911
+ killed: 0,
12912
+ black: 1,
12913
+ blinded: 2,
12914
+ darkness: 3,
12915
+ matchIntro: 4
12916
+ };
12917
+ var fieldTypeValues = {
12918
+ bool: 1,
12919
+ int8: 2,
12920
+ int16: 3,
12921
+ int32: 4,
12922
+ uint8: 5,
12923
+ uint16: 6,
12924
+ uint32: 7,
12925
+ int64: 8,
12926
+ uint64: 9,
12927
+ float32: 10,
12928
+ float64: 11,
12929
+ vector: 12,
12930
+ handle: 13,
12931
+ string: 14
12932
+ };
12933
+ var pickupKindValues = {
12934
+ urn: 0,
12935
+ movementBuff: 1
12936
+ };
12937
+ var movementActionNames = {
12938
+ 1: "landed",
12939
+ 2: "ziplineAttached",
12940
+ 3: "groundDash",
12941
+ 4: "slide",
12942
+ 5: "bouncePad",
12943
+ 6: "dashJump",
12944
+ 7: "airJump",
12945
+ 8: "wallJump",
12946
+ 9: "airDash",
12947
+ 10: "meleeStarted",
12948
+ 11: "abilityExecuted"
12949
+ };
12950
+ var interactionKindNames = {
12951
+ 1: "pickupCollected",
12952
+ 2: "propBroken"
12953
+ };
12954
+ var laneValues = {
12955
+ none: 0,
12956
+ yellow: 1,
12957
+ green: 3,
12958
+ blue: 4,
12959
+ purple: 6
12960
+ };
12961
+ var textAlignValues = {
12962
+ left: 0,
12963
+ center: 1,
12964
+ right: 2
12965
+ };
12966
+ var textVerticalAlignValues = {
12967
+ bottom: 0,
12968
+ center: 1,
12969
+ top: 2
12970
+ };
12971
+ var disconnectReasonNames = {
12972
+ 1: "shutdown",
12973
+ 2: "disconnectByUser",
12974
+ 3: "disconnectByServer",
12975
+ 4: "lost",
12976
+ 5: "overflow",
12977
+ 6: "steamBanned",
12978
+ 7: "steamInuse",
12979
+ 8: "steamTicket",
12980
+ 9: "steamLogon",
12981
+ 10: "steamAuthcancelled",
12982
+ 11: "steamAuthalreadyused",
12983
+ 12: "steamAuthinvalid",
12984
+ 13: "steamVacbanstate",
12985
+ 14: "steamLoggedInElsewhere",
12986
+ 15: "steamVacCheckTimedout",
12987
+ 16: "steamDropped",
12988
+ 17: "steamOwnership",
12989
+ 18: "serverinfoOverflow",
12990
+ 19: "tickmsgOverflow",
12991
+ 20: "stringtablemsgOverflow",
12992
+ 21: "deltaentmsgOverflow",
12993
+ 22: "tempentmsgOverflow",
12994
+ 23: "soundsmsgOverflow",
12995
+ 24: "snapshotoverflow",
12996
+ 25: "snapshoterror",
12997
+ 26: "reliableoverflow",
12998
+ 27: "baddeltatick",
12999
+ 28: "nomoresplits",
13000
+ 29: "timedout",
13001
+ 30: "disconnected",
13002
+ 31: "leavingsplit",
13003
+ 32: "differentclasstables",
13004
+ 33: "badrelaypassword",
13005
+ 34: "badspectatorpassword",
13006
+ 35: "hltvrestricted",
13007
+ 36: "nospectators",
13008
+ 37: "hltvunavailable",
13009
+ 38: "hltvstop",
13010
+ 39: "kicked",
13011
+ 40: "banadded",
13012
+ 41: "kickbanadded",
13013
+ 42: "hltvdirect",
13014
+ 43: "pureserverClientextra",
13015
+ 44: "pureserverMismatch",
13016
+ 45: "usercmd",
13017
+ 46: "rejectedByGame",
13018
+ 47: "messageParseError",
13019
+ 48: "invalidMessageError",
13020
+ 49: "badServerPassword",
13021
+ 50: "directConnectReservation",
13022
+ 51: "connectionFailure",
13023
+ 52: "noPeerGroupHandlers",
13024
+ 53: "reconnection",
13025
+ 54: "loopshutdown",
13026
+ 55: "loopdeactivate",
13027
+ 56: "hostEndgame",
13028
+ 57: "loopLevelloadActivate",
13029
+ 58: "createServerFailed",
13030
+ 59: "exiting",
13031
+ 60: "requestHoststateIdle",
13032
+ 61: "requestHoststateHltvrelay",
13033
+ 62: "clientConsistencyFail",
13034
+ 63: "clientUnableToCrcMap",
13035
+ 64: "clientNoMap",
13036
+ 65: "clientDifferentMap",
13037
+ 66: "serverRequiresSteam",
13038
+ 67: "steamDenyMisc",
13039
+ 68: "steamDenyBadAntiCheat",
13040
+ 69: "serverShutdown",
13041
+ 71: "replayIncompatible",
13042
+ 72: "connectRequestTimedout",
13043
+ 73: "serverIncompatible",
13044
+ 74: "localproblemManyrelays",
13045
+ 75: "localproblemHostedserverprimaryrelay",
13046
+ 76: "localproblemNetworkconfig",
13047
+ 77: "localproblemOther",
13048
+ 79: "remoteTimeout",
13049
+ 80: "remoteTimeoutConnecting",
13050
+ 81: "remoteOther",
13051
+ 82: "remoteBadcrypt",
13052
+ 83: "remoteCertnottrusted",
13053
+ 84: "unusual",
13054
+ 85: "internalError",
13055
+ 128: "rejectBadchallenge",
13056
+ 129: "rejectNolobby",
13057
+ 130: "rejectBackgroundMap",
13058
+ 131: "rejectSinglePlayer",
13059
+ 132: "rejectHiddenGame",
13060
+ 133: "rejectLanrestrict",
13061
+ 134: "rejectBadpassword",
13062
+ 135: "rejectServerfull",
13063
+ 136: "rejectInvalidreservation",
13064
+ 137: "rejectFailedchannel",
13065
+ 138: "rejectConnectFromLobby",
13066
+ 139: "rejectReservedForLobby",
13067
+ 140: "rejectInvalidkeylength",
13068
+ 141: "rejectOldprotocol",
13069
+ 142: "rejectNewprotocol",
13070
+ 143: "rejectInvalidconnection",
13071
+ 144: "rejectInvalidcertlen",
13072
+ 145: "rejectInvalidsteamcertlen",
13073
+ 146: "rejectSteam",
13074
+ 147: "rejectServerauthdisabled",
13075
+ 148: "rejectServercdkeyauthinvalid",
13076
+ 149: "rejectBanned",
13077
+ 150: "kickedTeamkilling",
13078
+ 151: "kickedTkStart",
13079
+ 152: "kickedUntrustedaccount",
13080
+ 153: "kickedConvictedaccount",
13081
+ 154: "kickedCompetitivecooldown",
13082
+ 155: "kickedTeamhurting",
13083
+ 156: "kickedHostagekilling",
13084
+ 157: "kickedVotedoff",
13085
+ 158: "kickedIdle",
13086
+ 159: "kickedSuicide",
13087
+ 160: "kickedNosteamlogin",
13088
+ 161: "kickedNosteamticket",
13089
+ 162: "kickedInputautomation",
13090
+ 163: "kickedVacnetabnormalbehavior",
13091
+ 164: "kickedInsecureclient"
13092
+ };
13093
+ var modRoleNames = {
13094
+ 0: "unspecified",
13095
+ 1: "developer",
13096
+ 2: "tester"
13097
+ };
13098
+ var cameraParamValues = {
13099
+ distance: 0,
13100
+ fieldOfView: 1,
13101
+ target: 2,
13102
+ verticalOffset: 3,
13103
+ horizontalOffset: 4
13104
+ };
13105
+ function fromAbility(message) {
13106
+ return {
13107
+ name: message.name ?? "",
13108
+ slot: message.slot ?? 0,
13109
+ entity: message.entity ?? 0,
13110
+ upgrades: message.upgrades ?? 0,
13111
+ charges: message.charges ?? 0,
13112
+ cooldownEnd: message.cooldownEnd ?? 0,
13113
+ id: message.id ?? 0,
13114
+ state: message.state ?? 0,
13115
+ cooldownStart: message.cooldownStart ?? 0,
13116
+ rechargeStart: message.rechargeStart ?? 0,
13117
+ rechargeEnd: message.rechargeEnd ?? 0,
13118
+ imbues: message.imbues ?? []
13119
+ };
13120
+ }
13121
+ function toAbilityOptions(value) {
13122
+ return {
13123
+ ability: value.ability,
13124
+ upgrades: value.upgrades,
13125
+ charges: value.charges === void 0 ? void 0 : int32(value.charges),
13126
+ cooldownEnd: value.cooldownEnd,
13127
+ rechargeEnd: value.rechargeEnd,
13128
+ maxCharges: value.maxCharges === void 0 ? void 0 : int32(value.maxCharges)
13129
+ };
13130
+ }
13131
+ function fromBuildCategory(message) {
13132
+ return {
13133
+ name: message.name ?? "",
13134
+ description: message.description ?? "",
13135
+ items: (message.items ?? []).map((v) => fromBuildItem(v))
13136
+ };
13137
+ }
13138
+ function fromBuildItem(message) {
13139
+ return {
13140
+ item: message.item ?? "",
13141
+ annotation: message.annotation ?? ""
13142
+ };
13143
+ }
13144
+ function fromDamageEvent(message) {
13145
+ return {
13146
+ victim: message.victim ?? 0,
13147
+ attacker: message.attacker ?? 0,
13148
+ inflictor: message.inflictor ?? 0,
13149
+ ability: message.ability ?? 0,
13150
+ flags: message.flags ?? 0n,
13151
+ hitGroup: message.hitGroup ?? 0,
13152
+ amount: message.amount ?? 0
13153
+ };
13154
+ }
13155
+ function fromDamagedEvent(message) {
13156
+ return {
13157
+ victim: message.victim ?? 0,
13158
+ attacker: message.attacker ?? 0,
13159
+ ability: message.ability ?? 0,
13160
+ healthLost: message.healthLost ?? 0,
13161
+ healthBefore: message.healthBefore ?? 0,
13162
+ dealt: message.dealt ?? 0
13163
+ };
13164
+ }
13165
+ function fromLaunchEvent(message) {
13166
+ return {
13167
+ entity: message.entity ?? 0,
13168
+ name: message.name ?? "",
13169
+ owner: message.owner ?? 0,
13170
+ player: Player.of(message.player ?? 0),
13171
+ position: vector(message.position)
13172
+ };
13173
+ }
13174
+ function fromImpactEvent(message) {
13175
+ return {
13176
+ entity: message.entity ?? 0,
13177
+ name: message.name ?? "",
13178
+ owner: message.owner ?? 0,
13179
+ player: Player.of(message.player ?? 0),
13180
+ start: vector(message.start),
13181
+ end: vector(message.end),
13182
+ position: vector(message.position),
13183
+ hit: message.hit ?? 0
13184
+ };
13185
+ }
13186
+ function toProjectileOptions(value) {
13187
+ return {
13188
+ names: value.names?.slice(),
13189
+ keepMomentum: value.keepMomentum
13190
+ };
13191
+ }
13192
+ function toHitOptions(value) {
13193
+ return {
13194
+ victim: value.victim,
13195
+ attacker: value.attacker,
13196
+ inflictor: value.inflictor,
13197
+ amount: value.amount,
13198
+ hitGroup: value.hitGroup === void 0 ? void 0 : int32(value.hitGroup),
13199
+ ability: value.ability
13200
+ };
13201
+ }
13202
+ function toTraceOptions(value) {
13203
+ return {
13204
+ start: value.start,
13205
+ end: value.end,
13206
+ layers: value.layers,
13207
+ exclude: value.exclude,
13208
+ ignore: value.ignore?.slice()
13209
+ };
13210
+ }
13211
+ function fromTraceHit(message) {
13212
+ return {
13213
+ position: vector(message.position),
13214
+ normal: vector(message.normal),
13215
+ startSolid: message.startSolid ?? false,
13216
+ entity: message.entity ?? 0
13217
+ };
13218
+ }
13219
+ function toSoundOptions(value) {
13220
+ return {
13221
+ volume: value.volume,
13222
+ pitch: value.pitch,
13223
+ listeners: value.listeners?.map((v) => int32(v))
13224
+ };
13225
+ }
13226
+ function toFieldValue(value) {
13227
+ 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 };
13228
+ }
13229
+ function fromFieldValue(message) {
13230
+ const value = message?.value;
13231
+ if (value === void 0 || value.case === void 0) return void 0;
13232
+ switch (value.case) {
13233
+ case "vector":
13234
+ return vector(value.value);
13235
+ }
13236
+ return value.value;
13237
+ }
13238
+ function toFieldWrite(value) {
13239
+ return {
13240
+ className: value.className,
13241
+ field: value.field,
13242
+ type: fieldTypeValues[value.type],
13243
+ value: toFieldValue(value.value)
13244
+ };
13245
+ }
13246
+ function fromEntityClassName(message) {
13247
+ return {
13248
+ className: message.className ?? "",
13249
+ designerName: message.designerName ?? ""
13250
+ };
13251
+ }
13252
+ function fromEntityPlacement(message) {
13253
+ return {
13254
+ position: vector(message.position),
13255
+ facing: angles(message.facing),
13256
+ velocity: message.velocity === void 0 ? void 0 : vector(message.velocity)
13257
+ };
13258
+ }
13259
+ function toEntityOptions(value) {
13260
+ return {
13261
+ designerName: value.designerName,
13262
+ subclass: value.subclass,
13263
+ team: int32(value.team),
13264
+ position: value.position,
13265
+ facing: value.facing,
13266
+ keyValues: value.keyValues?.map((v) => toKeyValue(v)),
13267
+ fields: value.fields?.map((v) => toFieldWrite(v)),
13268
+ transmitAlways: value.transmitAlways
13269
+ };
13270
+ }
13271
+ function toKeyValue(value) {
13272
+ return {
13273
+ key: value.key,
13274
+ value: toEntityValue(value.value)
13275
+ };
13276
+ }
13277
+ function toEntityValue(value) {
13278
+ if ("boolean" in value) return { value: { case: "boolean", value: value.boolean } };
13279
+ if ("integer" in value) return { value: { case: "integer", value: int32(value.integer) } };
13280
+ if ("number" in value) return { value: { case: "number", value: value.number } };
13281
+ if ("text" in value) return { value: { case: "text", value: value.text } };
13282
+ if ("vector" in value) return { value: { case: "vector", value: value.vector } };
13283
+ return { value: { case: "color", value: value.color } };
13284
+ }
13285
+ function fromInputEvent(message) {
13286
+ return {
13287
+ player: Player.of(message.player ?? 0),
13288
+ pressed: message.pressed ?? 0n,
13289
+ released: message.released ?? 0n
13290
+ };
13291
+ }
13292
+ function fromRiftState(message) {
13293
+ return {
13294
+ scoringTeam: message.scoringTeam ?? 0,
13295
+ scoringTime: message.scoringTime ?? 0,
13296
+ cashInStarted: message.cashInStarted ?? 0,
13297
+ giveUpTime: message.giveUpTime ?? 0,
13298
+ nextSpawn: message.nextSpawn ?? 0,
13299
+ spawnWindow: message.spawnWindow ?? 0
13300
+ };
13301
+ }
13302
+ function fromMovementSample(message) {
13303
+ return {
13304
+ player: Player.of(message.player ?? 0),
13305
+ pawn: message.pawn ?? 0,
13306
+ position: vector(message.position),
13307
+ velocity: vector(message.velocity),
13308
+ grounded: message.grounded ?? false,
13309
+ sliding: message.sliding ?? false,
13310
+ mantling: message.mantling ?? false,
13311
+ climbing: message.climbing ?? false,
13312
+ dashing: message.dashing ?? false,
13313
+ jumpAbility: message.jumpAbility ?? 0,
13314
+ wallJumps: message.wallJumps ?? 0,
13315
+ mantleAbility: message.mantleAbility ?? 0,
13316
+ mantleStart: message.mantleStart ?? 0,
13317
+ wallContact: vector(message.wallContact),
13318
+ wallNormal: vector(message.wallNormal),
13319
+ wallJumpNormal: vector(message.wallJumpNormal),
13320
+ wallJumpFacing: message.wallJumpFacing ?? 0,
13321
+ ziplineTime: message.ziplineTime,
13322
+ actions: known(message.actions, (v) => movementActionNames[v]),
13323
+ casts: message.casts ?? [],
13324
+ command: message.command === void 0 ? void 0 : fromMovementCommand(message.command),
13325
+ interactions: (message.interactions ?? []).map((v) => fromInteraction(v))
13326
+ };
13327
+ }
13328
+ function fromInteraction(message) {
13329
+ return {
13330
+ kind: interactionKindNames[message.kind ?? 0],
13331
+ entity: message.entity ?? 0,
13332
+ designerName: message.designerName ?? "",
13333
+ subclassId: message.subclassId ?? 0,
13334
+ origin: vector(message.origin),
13335
+ vacuumStart: message.vacuumStart,
13336
+ inflictor: message.inflictor ?? 0
13337
+ };
13338
+ }
13339
+ function fromMovementCommand(message) {
13340
+ return {
13341
+ held: message.held ?? 0n,
13342
+ changed: message.changed ?? 0n,
13343
+ scroll: message.scroll ?? 0n,
13344
+ forward: message.forward ?? 0,
13345
+ left: message.left ?? 0,
13346
+ up: message.up ?? 0,
13347
+ grounded: message.grounded ?? false
13348
+ };
13349
+ }
13350
+ function fromLandedEvent(message) {
13351
+ return {
13352
+ player: Player.of(message.player ?? 0),
13353
+ on: message.on ?? 0,
13354
+ speed: message.speed ?? 0
13355
+ };
13356
+ }
13357
+ function fromNpcsRestoredEvent(message) {
13358
+ return {
13359
+ error: message.error ?? ""
13360
+ };
13361
+ }
13362
+ function toNpcOptions(value) {
13363
+ return {
13364
+ className: value.className,
13365
+ unit: value.unit,
13366
+ team: int32(value.team),
13367
+ position: value.position,
13368
+ facing: value.facing,
13369
+ health: value.health === void 0 ? void 0 : int32(value.health),
13370
+ maxHealth: value.maxHealth === void 0 ? void 0 : int32(value.maxHealth),
13371
+ lane: value.lane,
13372
+ fields: value.fields?.map((v) => toFieldWrite(v))
13373
+ };
13374
+ }
13375
+ function fromNpcState(message) {
13376
+ return {
13377
+ position: vector(message.position),
13378
+ facing: angles(message.facing),
13379
+ health: message.health ?? 0,
13380
+ maxHealth: message.maxHealth ?? 0,
13381
+ team: message.team ?? 0
13382
+ };
13383
+ }
13384
+ function toNpcTarget(value) {
13385
+ return {
13386
+ className: value.className,
13387
+ id: value.id,
13388
+ team: int32(value.team),
13389
+ position: value.position,
13390
+ facing: value.facing,
13391
+ velocity: value.velocity,
13392
+ health: int32(value.health),
13393
+ maxHealth: int32(value.maxHealth),
13394
+ lane: value.lane
13395
+ };
13396
+ }
13397
+ function toTextOptions(value) {
13398
+ return {
13399
+ text: value.text,
13400
+ position: value.position,
13401
+ facing: value.facing,
13402
+ fontSize: value.fontSize,
13403
+ color: value.color,
13404
+ faceCamera: value.faceCamera,
13405
+ scale: value.scale,
13406
+ align: value.align === void 0 ? void 0 : textAlignValues[value.align],
13407
+ verticalAlign: value.verticalAlign === void 0 ? void 0 : textVerticalAlignValues[value.verticalAlign]
13408
+ };
13409
+ }
13410
+ function toParticleOptions(value) {
13411
+ return {
13412
+ resource: value.resource,
13413
+ position: value.position,
13414
+ facing: value.facing,
13415
+ color: value.color,
13416
+ tintPoint: value.tintPoint === void 0 ? void 0 : int32(value.tintPoint),
13417
+ point: value.point === void 0 ? void 0 : toParticlePoint(value.point),
13418
+ parent: value.parent,
13419
+ anchors: value.anchors?.map((v) => toParticleAnchor(v)),
13420
+ inactive: value.inactive
13421
+ };
13422
+ }
13423
+ function toParticleAnchor(value) {
13424
+ return {
13425
+ index: int32(value.index),
13426
+ entity: value.entity
13427
+ };
13428
+ }
13429
+ function toParticlePoint(value) {
13430
+ return {
13431
+ index: int32(value.index),
13432
+ position: value.position
13433
+ };
13434
+ }
13435
+ function fromRestoredEvent(message) {
13436
+ return {
13437
+ player: Player.of(message.player ?? 0),
13438
+ error: message.error ?? ""
13439
+ };
13440
+ }
13441
+ function fromPlayersChangedEvent(message) {
13442
+ return {
13443
+ players: (message.players ?? []).map((v) => fromConnection(v))
13444
+ };
13445
+ }
13446
+ function fromPlayerJoinedEvent(message) {
13447
+ return {
13448
+ connection: fromConnection(message.connection ?? {})
13449
+ };
13450
+ }
13451
+ function fromPlayerLeftEvent(message) {
13452
+ return {
13453
+ connection: fromConnection(message.connection ?? {}),
13454
+ disconnected: message.disconnected ?? false,
13455
+ reason: message.reason === void 0 ? void 0 : disconnectReasonNames[message.reason]
13456
+ };
13457
+ }
13458
+ function fromConnection(message) {
13459
+ return {
13460
+ player: Player.of(message.player ?? 0),
13461
+ steamId: message.steamId ?? 0n,
13462
+ name: message.name ?? "",
13463
+ bot: message.bot ?? false,
13464
+ ready: message.ready ?? false,
13465
+ generation: message.generation ?? 0,
13466
+ roles: known(message.roles, (v) => modRoleNames[v])
13467
+ };
13468
+ }
13469
+ function fromPawn(message) {
13470
+ return {
13471
+ entity: message.entity ?? 0,
13472
+ hero: message.hero ?? 0,
13473
+ team: message.team ?? 0,
13474
+ health: message.health ?? 0,
13475
+ maxHealth: message.maxHealth ?? 0,
13476
+ position: vector(message.position),
13477
+ eyeAngles: angles(message.eyeAngles),
13478
+ cameraAngles: angles(message.cameraAngles),
13479
+ stamina: message.stamina,
13480
+ maxStamina: message.maxStamina,
13481
+ generation: message.generation ?? 0,
13482
+ souls: message.souls ?? 0,
13483
+ eyePosition: vector(message.eyePosition),
13484
+ velocity: vector(message.velocity),
13485
+ carryingUrn: message.carryingUrn,
13486
+ score: message.score === void 0 ? void 0 : fromScore(message.score),
13487
+ cameraPosition: message.cameraPosition === void 0 ? void 0 : vector(message.cameraPosition),
13488
+ effectiveMaxHealth: message.effectiveMaxHealth,
13489
+ abilityPoints: message.abilityPoints ?? 0,
13490
+ abilityUnlocks: message.abilityUnlocks ?? 0
13491
+ };
13492
+ }
13493
+ function fromScore(message) {
13494
+ return {
13495
+ kills: message.kills ?? 0,
13496
+ deaths: message.deaths ?? 0,
13497
+ assists: message.assists ?? 0,
13498
+ lastHits: message.lastHits ?? 0,
13499
+ denies: message.denies ?? 0,
13500
+ heroDamage: message.heroDamage ?? 0,
13501
+ heroHealing: message.heroHealing ?? 0,
13502
+ netWorth: message.netWorth ?? 0
13503
+ };
13504
+ }
13505
+ function toCameraValue(value) {
13506
+ return { value: typeof value === "number" ? { case: "number", value } : typeof value === "object" ? { case: "position", value } : void 0 };
13507
+ }
13508
+ function toCameraMotion(value) {
13509
+ if ("hold" in value) return { motion: { case: "hold", value: value.hold } };
13510
+ if ("approach" in value) return { motion: { case: "approach", value: toCameraApproach(value.approach) } };
13511
+ if ("spring" in value) return { motion: { case: "spring", value: toCameraSpring(value.spring) } };
13512
+ if ("lerp" in value) return { motion: { case: "lerp", value: toCameraLerp(value.lerp) } };
13513
+ return { motion: { case: "lag", value: value.lag } };
13514
+ }
13515
+ function toCameraApproach(value) {
13516
+ return {
13517
+ value: value.value === void 0 ? void 0 : toCameraValue(value.value),
13518
+ speed: value.speed,
13519
+ defaultSpeed: value.defaultSpeed,
13520
+ acceleration: value.acceleration,
13521
+ minDuration: value.minDuration,
13522
+ chaseDefault: value.chaseDefault
13523
+ };
13524
+ }
13525
+ function toCameraSpring(value) {
13526
+ return {
13527
+ value: value.value === void 0 ? void 0 : toCameraValue(value.value),
13528
+ strength: value.strength,
13529
+ minSpeed: value.minSpeed,
13530
+ maxDuration: value.maxDuration
13531
+ };
13532
+ }
13533
+ function toCameraLerp(value) {
13534
+ return {
13535
+ start: toCameraValue(value.start),
13536
+ end: toCameraValue(value.end),
13537
+ bias: value.bias,
13538
+ gain: value.gain,
13539
+ duration: value.duration
13540
+ };
13541
+ }
13542
+ function toCameraOptions(value) {
13543
+ return {
13544
+ context: value.context,
13545
+ param: cameraParamValues[value.param],
13546
+ motion: toCameraMotion(value.motion),
13547
+ delay: value.delay,
13548
+ relative: value.relative,
13549
+ priority: value.priority,
13550
+ shared: value.shared,
13551
+ target: value.target
13552
+ };
13553
+ }
13554
+ function toHeroTarget(value) {
13555
+ return {
13556
+ position: value.position,
13557
+ facing: value.facing,
13558
+ fresh: value.fresh,
13559
+ level: value.level === void 0 ? void 0 : int32(value.level),
13560
+ health: value.health === void 0 ? void 0 : int32(value.health),
13561
+ maxHealth: value.maxHealth === void 0 ? void 0 : int32(value.maxHealth),
13562
+ upgradeBonuses: value.upgradeBonuses?.slice(),
13563
+ abilities: value.abilities?.map((v) => toEquipmentTarget(v)),
13564
+ items: value.items?.map((v) => toEquipmentTarget(v)),
13565
+ replaceItems: value.replaceItems,
13566
+ timers: value.timers?.map((v) => toTimerTarget(v))
13567
+ };
13568
+ }
13569
+ function toEquipmentTarget(value) {
13570
+ return {
13571
+ id: value.id,
13572
+ slot: value.slot === void 0 ? void 0 : int32(value.slot),
13573
+ state: value.state
13574
+ };
13575
+ }
13576
+ function toTimerTarget(value) {
13577
+ return {
13578
+ id: value.id,
13579
+ charges: int32(value.charges),
13580
+ cooldownStart: value.cooldownStart,
13581
+ cooldownEnd: value.cooldownEnd,
13582
+ rechargeStart: value.rechargeStart,
13583
+ rechargeEnd: value.rechargeEnd
13584
+ };
13585
+ }
13586
+ function toBotOptions(value) {
13587
+ return {
13588
+ name: value.name,
13589
+ team: int32(value.team),
13590
+ hero: value.hero === void 0 ? void 0 : typeof value.hero === "string" ? { case: "heroName", value: heroName(value.hero) } : typeof value.hero === "number" ? { case: "heroId", value: value.hero } : void 0,
13591
+ position: value.position
13592
+ };
13593
+ }
13594
+ function fromSettingChangedEvent(message) {
13595
+ return {
13596
+ player: Player.of(message.player ?? 0),
13597
+ key: message.key ?? "",
13598
+ value: message.value ?? ""
13599
+ };
13600
+ }
13601
+ function fromWheel(message) {
13602
+ return {
13603
+ delta: message.delta ?? 0,
13604
+ fraction: message.fraction ?? 0
13605
+ };
13606
+ }
13607
+ function fromUiPressEvent(message) {
13608
+ return {
13609
+ player: Player.of(message.player ?? 0),
13610
+ node: message.node ?? ""
13611
+ };
13612
+ }
13613
+ function fromUiInputEvent(message) {
13614
+ return {
13615
+ player: Player.of(message.player ?? 0),
13616
+ node: message.node ?? "",
13617
+ value: message.value?.case === "wheel" ? fromWheel(message.value.value) : message.value?.value
13618
+ };
13619
+ }
13620
+ function fromStartEvent(message) {
13621
+ return {
13622
+ args: message.args ?? [],
13623
+ checkOnly: message.checkOnly ?? false,
13624
+ source: message.source ?? new Uint8Array()
13625
+ };
13626
+ }
13627
+ function fromFrameEvent(message) {
13628
+ return {
13629
+ tick: message.tick ?? 0n,
13630
+ timeSeconds: message.timeSeconds ?? 0,
13631
+ movement: (message.movement ?? []).map((v) => fromMovementSample(v)),
13632
+ interactions: known(message.interactions, (v) => interactionKindNames[v])
13633
+ };
13634
+ }
13635
+ function fromCommandEvent(message) {
13636
+ return {
13637
+ player: Player.of(message.player ?? 0),
13638
+ line: message.line ?? ""
13639
+ };
13640
+ }
13641
+ function fromChatEvent(message) {
13642
+ return {
13643
+ player: Player.of(message.player ?? 0),
13644
+ text: message.text ?? "",
13645
+ all: message.all ?? false,
13646
+ lane: message.lane ?? 0
13647
+ };
13648
+ }
13649
+ function fromWorldEvent(message) {
13650
+ return {
13651
+ map: message.map ?? ""
13652
+ };
13653
+ }
13654
+ function fromServiceCall(message) {
13655
+ return {
13656
+ service: message.service ?? "",
13657
+ method: message.method ?? "",
13658
+ payload: message.payload ?? new Uint8Array()
13659
+ };
13660
+ }
13661
+ function toPrecacheOptions(value) {
13662
+ return {
13663
+ heroes: value.heroes?.map((v) => heroName(v)),
13664
+ resources: value.resources?.slice()
13665
+ };
13666
+ }
13667
+ var playerObjects = /* @__PURE__ */ new Map();
13668
+ var Player = class _Player {
13669
+ /** slot identifies the player on the server. */
13670
+ slot;
13671
+ constructor(slot) {
13672
+ this.slot = slot;
13673
+ }
13674
+ /**
13675
+ * of returns the Player for slot, the same object each time until release
13676
+ * forgets it, so === tells whether two values are the same player.
13677
+ */
13678
+ static of(slot) {
13679
+ let object = playerObjects.get(slot);
13680
+ if (object === void 0) {
13681
+ object = new _Player(slot);
13682
+ playerObjects.set(slot, object);
13683
+ }
13684
+ return object;
13685
+ }
13686
+ /**
13687
+ * release forgets the Player for slot, so the next Player.of makes a new one.
13688
+ */
13689
+ static release(slot) {
13690
+ playerObjects.delete(slot);
13691
+ }
13692
+ /** chat sends a server chat line to the player. */
13693
+ chat(text2) {
13694
+ return call("Chat", ChatRequest.toBinary({ player: this.slot, text: text2 })) !== void 0;
13695
+ }
13696
+ /**
13697
+ * centerText shows text in the middle of the player's screen until it is
13698
+ * replaced. Empty text clears it.
13699
+ */
13700
+ centerText(text2) {
13701
+ return call("CenterText", CenterTextRequest.toBinary({ player: this.slot, text: text2 })) !== void 0;
13702
+ }
13703
+ /** announce shows a game announcement with a title to the player. */
13704
+ announce(title, text2) {
13705
+ return call("Announce", AnnounceRequest.toBinary({ player: this.slot, title, text: text2 })) !== void 0;
13706
+ }
13707
+ /**
13708
+ * pawn returns the player's pawn this frame: the hero, or the game's
13709
+ * placeholder with hero 0 that a player joining on a team holds until a hero
13710
+ * is selected. It returns nothing for a spectator and before the game has
13711
+ * made a pawn. The pawn's entity changes whenever the game replaces it.
13712
+ */
13713
+ pawn() {
13714
+ const reply2 = call("Pawn", PlayerRequest.toBinary({ player: this.slot }));
13715
+ if (reply2 === void 0) return void 0;
13716
+ const response = PawnResponse.fromBinary(reply2);
13717
+ return response.pawn === void 0 ? void 0 : fromPawn(response.pawn);
13718
+ }
13719
+ /**
13720
+ * setting returns the player's value of a setting the manifest
13721
+ * declares: the value they chose, or the setting's default. A bot has the
13722
+ * defaults.
13723
+ */
13724
+ setting(key) {
13725
+ const reply2 = call("PlayerSetting", PlayerSettingRequest.toBinary({ player: this.slot, key }));
13726
+ if (reply2 === void 0) return void 0;
13727
+ const response = SettingResponse.fromBinary(reply2);
13728
+ return response.value ?? "";
13729
+ }
13730
+ /**
13731
+ * setSetting changes the player's value of a setting the manifest
13732
+ * declares. The value follows the player to later games and other mods'
13733
+ * servers of the same mod; a bot keeps the defaults.
13734
+ */
13735
+ setSetting(key, value) {
13736
+ return call("SetPlayerSetting", SetPlayerSettingRequest.toBinary({ player: this.slot, key, value })) !== void 0;
13737
+ }
13738
+ /**
13739
+ * addMetric adds to the player's total of a metric the manifest declares.
13740
+ * The host keeps each player's totals in memory and hands them on once,
13741
+ * when the player leaves or the mod stops; a bot keeps none.
13742
+ */
13743
+ addMetric(name, value, label) {
13744
+ return call("AddMetric", AddMetricRequest.toBinary({ player: this.slot, name, value, label })) !== void 0;
13745
+ }
13746
+ /**
13747
+ * handoff replaces the handoff state for the player, such as the
13748
+ * panels their HUD shows. It lasts only through a reload of the mod in the
13749
+ * same game, in memory, as the game's does, and ends early when the player
13750
+ * leaves; only that player reads it back, and a bot keeps none.
13751
+ */
13752
+ handoff(text2) {
13753
+ return call("PlayerHandoff", HandoffPlayerRequest.toBinary({ player: this.slot, text: text2 })) !== void 0;
13754
+ }
13755
+ /** handedOff returns the player's handoff state, or empty. */
13756
+ handedOff() {
13757
+ const reply2 = call("PlayerHandedOff", PlayerRequest.toBinary({ player: this.slot }));
13758
+ if (reply2 === void 0) return void 0;
13759
+ const response = HandedOffResponse.fromBinary(reply2);
13760
+ return response.text ?? "";
13761
+ }
13762
+ /**
13763
+ * selectHero gives the player a hero on a team, 2 or 3, and returns the
13764
+ * hero's identifier as Pawn.hero reports it. The hero appears on a later
13765
+ * frame. A hero the player picked through the game's Change Hero wins: the
13766
+ * game removes the old hero before it spawns the pick, and a call in that
13767
+ * gap, up to 5 seconds, fails and leaves the pick to land.
13768
+ */
13769
+ selectHero(hero, team) {
13770
+ const reply2 = call("SelectHero", SelectHeroRequest.toBinary({ player: this.slot, hero: typeof hero === "string" ? { case: "heroName", value: heroName(hero) } : typeof hero === "number" ? { case: "heroId", value: hero } : void 0, team: int32(team) }));
13771
+ if (reply2 === void 0) return void 0;
13772
+ const response = HeroResponse.fromBinary(reply2);
13773
+ return response.hero ?? 0;
13774
+ }
13775
+ /**
13776
+ * spectate moves the player to the spectators, without a hero. The player
13777
+ * watches until a hero selection seats them again.
13778
+ */
13779
+ spectate() {
13780
+ return call("Spectate", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13781
+ }
13782
+ /**
13783
+ * watch points the player's camera at a hero, through the hero's own view
13784
+ * or chasing it, as the game's spectator camera follows it. A spectator watches through
13785
+ * their spectator camera, once it exists. A player with a hero watches
13786
+ * while the hero stays where it stands, keeping its level, souls and items,
13787
+ * until Unwatch returns them to it.
13788
+ */
13789
+ watch(target, chase) {
13790
+ return call("Watch", WatchRequest.toBinary({ player: this.slot, target, chase })) !== void 0;
13791
+ }
13792
+ /**
13793
+ * freeCamera lets the player fly their camera from a position, with the
13794
+ * movement keys and the mouse, as the game's roaming spectator camera does.
13795
+ * A player with a hero leaves it where it stands, as Watch does, until
13796
+ * Unwatch returns them to it; Watch follows a hero again.
13797
+ */
13798
+ freeCamera(position, facing) {
13799
+ return call("FreeCamera", FreeCameraRequest.toBinary({ player: this.slot, position, facing })) !== void 0;
13800
+ }
13801
+ /**
13802
+ * moveCamera adds one operation to the player's camera, as the game's
13803
+ * abilities pull it back, widen its view or swing it to a point. Operations
13804
+ * run alongside the game's own until they end or ClearCamera removes them.
13805
+ */
13806
+ moveCamera(options) {
13807
+ return call("MoveCamera", CameraOptions.toBinary({ player: this.slot, ...toCameraOptions(options) })) !== void 0;
13808
+ }
13809
+ /**
13810
+ * clearCamera removes a context's camera operations from the player's
13811
+ * camera, or every operation, and the camera returns to its usual place.
13812
+ */
13813
+ clearCamera(context) {
13814
+ return call("ClearCamera", ClearCameraRequest.toBinary({ player: this.slot, context })) !== void 0;
13815
+ }
13816
+ /**
13817
+ * unwatch returns a player watching or flying the free camera from their
13818
+ * hero back to it. Stopping the mod returns every such player.
13819
+ */
13820
+ unwatch() {
13821
+ return call("Unwatch", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13822
+ }
13823
+ /**
13824
+ * respawn revives the player's dead hero. A pawn with hero 0 has no hero to
13825
+ * revive; the call fails until SelectHero gives it one.
13826
+ */
13827
+ respawn() {
13828
+ return call("Respawn", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13829
+ }
13830
+ /**
13831
+ * changeTeam moves the player's hero, living or dead, to team 2 or 3 where
13832
+ * it stands, for a human or a bot alike. The hero keeps its hero,
13833
+ * abilities, items and health, and the player keeps their connection; a
13834
+ * dead hero respawns on its new team, on its timer or through Respawn. A
13835
+ * living hero moved inside the other team's base dies to the base's
13836
+ * defense. A player without a hero joins a team through SelectHero
13837
+ * instead.
13838
+ */
13839
+ changeTeam(team) {
13840
+ return call("ChangeTeam", ChangeTeamRequest.toBinary({ player: this.slot, team: int32(team) })) !== void 0;
13841
+ }
13842
+ /** clearItems removes every item the player's hero owns. */
13843
+ clearItems() {
13844
+ return call("ClearItems", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13845
+ }
13846
+ /**
13847
+ * freeze holds the player's hero in place, without input or damage, until
13848
+ * it is released. Stopping the mod releases it.
13849
+ */
13850
+ freeze(frozen) {
13851
+ return call("Freeze", FreezeRequest.toBinary({ player: this.slot, frozen })) !== void 0;
13852
+ }
13853
+ /** restoreStamina refills the player's stamina. */
13854
+ restoreStamina() {
13855
+ return call("RestoreStamina", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13856
+ }
13857
+ /**
13858
+ * setStamina sets the player's stamina, as Pawn.stamina reads it. The game
13859
+ * regenerates it as usual afterwards.
13860
+ */
13861
+ setStamina(stamina) {
13862
+ return call("SetStamina", SetStaminaRequest.toBinary({ player: this.slot, stamina })) !== void 0;
13863
+ }
13864
+ /**
13865
+ * refreshAbility ends the cooldown of the hero's ability named ability,
13866
+ * such as citadel_ability_melee_parry.
13867
+ */
13868
+ refreshAbility(ability) {
13869
+ return call("RefreshAbility", RefreshAbilityRequest.toBinary({ player: this.slot, ability })) !== void 0;
13870
+ }
13871
+ /**
13872
+ * abilities lists the abilities of the player's hero in the hero's order,
13873
+ * or none without a live hero.
13874
+ */
13875
+ abilities() {
13876
+ const reply2 = call("Abilities", PlayerRequest.toBinary({ player: this.slot }));
13877
+ if (reply2 === void 0) return [];
13878
+ const response = AbilitiesResponse.fromBinary(reply2);
13879
+ return (response.abilities ?? []).map((v) => fromAbility(v));
13880
+ }
13881
+ /**
13882
+ * setAbility changes the upgrades, charges or timers of one of the hero's
13883
+ * abilities. An omitted option stays as it is.
13884
+ */
13885
+ setAbility(options) {
13886
+ return call("SetAbility", AbilityOptions.toBinary({ player: this.slot, ...toAbilityOptions(options) })) !== void 0;
13887
+ }
13888
+ /**
13889
+ * giveItem gives the hero an item, enabled and free. A hero that owns it
13890
+ * keeps its one copy. With imbue, an imbuing item strengthens the hero's
13891
+ * ability in that slot, 0 to 3, as the shop asks when one is bought; the
13892
+ * call fails, granting nothing, when the ability does not accept it.
13893
+ */
13894
+ giveItem(item2, imbue) {
13895
+ return call("GiveItem", GiveItemRequest.toBinary({ player: this.slot, item: item2, imbue })) !== void 0;
13896
+ }
13897
+ /**
13898
+ * buyItem buys an item for the hero as the shop does, under the shop's own
13899
+ * rules and for the souls it charges, or fails and charges nothing when the
13900
+ * shop refuses, as away from the shop or without the souls. With imbue, an
13901
+ * imbuing item strengthens whatever ability the hero holds in that slot, 0
13902
+ * to 3, including one ReplaceAbility put there, which the game's own
13903
+ * buydependentitem refuses; the call fails, buying nothing, when the
13904
+ * ability does not accept it.
13905
+ */
13906
+ buyItem(item2, imbue, source) {
13907
+ return call("BuyItem", BuyItemRequest.toBinary({ player: this.slot, item: item2, imbue, source })) !== void 0;
13908
+ }
13909
+ /**
13910
+ * trainAbility trains or upgrades whatever ability the hero holds in a
13911
+ * slot, 0 to 3, as the player holding the upgrade key and pressing the
13912
+ * slot's ability key does: an untrained ability trains for an ability
13913
+ * unlock, and a trained one buys its next tier for ability points. It works
13914
+ * on an ability ReplaceAbility put there, which the game's own commands for
13915
+ * a slot do not reach. When the game refuses, as without an unlock or the
13916
+ * points, the call fails and nothing is spent.
13917
+ */
13918
+ trainAbility(slot) {
13919
+ return call("TrainAbility", TrainAbilityRequest.toBinary({ player: this.slot, slot })) !== void 0;
13920
+ }
13921
+ /**
13922
+ * replaceAbility puts the ability named ability, untrained unless keep
13923
+ * carries the old one's progress, in the hero's ability slot index, as
13924
+ * Ability.slot, removing the ability there. The game trains and upgrades an
13925
+ * ability in slots 0 to 3 by its slot, so a player holds the upgrade key and
13926
+ * presses the slot's ability key to spend ability points on it, and training
13927
+ * an untrained one costs an ability unlock. A hero change or ResetHero gives
13928
+ * the hero its own abilities again, so a mod that keeps a swap replaces
13929
+ * again then. An ability from another hero loads its models and particles
13930
+ * only if Precache named that hero and those resources before the world
13931
+ * loaded; otherwise its first effect stalls the game on a blocking load and
13932
+ * the game reports an assertion.
13933
+ */
13934
+ replaceAbility(index, ability, keep) {
13935
+ return call("ReplaceAbility", ReplaceAbilityRequest.toBinary({ player: this.slot, index, ability, keep })) !== void 0;
13936
+ }
13937
+ /**
13938
+ * holdModifier keeps a modifier, named as GiveModifier names it, on the
13939
+ * hero with no expiry, giving it back whenever the game removes it or the
13940
+ * hero returns. Every hero that gains the modifier from the same ability
13941
+ * keeps it until the hold ends. Releasing leaves the hero's current
13942
+ * modifier until it dies.
13943
+ */
13944
+ holdModifier(modifier, active) {
13945
+ return call("HoldModifier", HoldModifierRequest.toBinary({ player: this.slot, modifier, active })) !== void 0;
13946
+ }
13947
+ /**
13948
+ * giveModifier gives the hero a modifier for seconds. An ability's
13949
+ * modifier, named "<ability>/<modifier>", comes as if the hero's own
13950
+ * ability applied it; a hero without that ability, or a modifier named on
13951
+ * its own, such as Street Brawl's zipline boost
13952
+ * modifier_street_brawl_round_start_zipline_boost, applies it with the
13953
+ * hero's first ability. The game may end it sooner, as invisibility ends on
13954
+ * a shot.
13955
+ */
13956
+ giveModifier(modifier, seconds) {
13957
+ return call("GiveModifier", GiveModifierRequest.toBinary({ player: this.slot, modifier, seconds })) !== void 0;
13958
+ }
13959
+ /**
13960
+ * teleport moves the player's hero and turns it and the camera. With a
13961
+ * velocity it also sets the hero's motion, as a launch, and the camera
13962
+ * follows the hero.
13963
+ */
13964
+ teleport(position, facing, velocity) {
13965
+ return call("Teleport", TeleportRequest.toBinary({ player: this.slot, position, facing, velocity })) !== void 0;
13966
+ }
13967
+ /**
13968
+ * zipline puts the player's hero on a lane's zipline near the hero, riding
13969
+ * it as from the zipline key, with the zipline's intro. It never picks
13970
+ * another lane: it fails when the lane has no zipline the hero's team rides
13971
+ * on this map, or the hero has no zipline ability. For Street Brawl's fast
13972
+ * ride, give the hero modifier_street_brawl_round_start_zipline_boost too.
13973
+ */
13974
+ zipline(lane) {
13975
+ return call("Zipline", ZiplineRequest.toBinary({ player: this.slot, lane: laneValues[lane] })) !== void 0;
13976
+ }
13977
+ /**
13978
+ * move carries the player's hero to a position as continuous motion,
13979
+ * as a recording plays back. Unlike Teleport it keeps the hero's animated
13980
+ * model drawn when repeated every tick, and leaves the camera alone.
13981
+ */
13982
+ move(position, facing, velocity) {
13983
+ return call("MovePlayer", MovePlayerRequest.toBinary({ player: this.slot, position, facing, velocity })) !== void 0;
13984
+ }
13985
+ /**
13986
+ * steer replays a recorded movement command on the player's hero, usually a
13987
+ * bot: the game runs the command's buttons and axes, so the hero crouches,
13988
+ * slides, jumps and mantles with its own animation, and the step then ends
13989
+ * on the recorded pose. The steering stays until the next Steer replaces
13990
+ * it, its presses and its pose counting once: on the ticks between, the
13991
+ * game's own movement carries the held command on from the pose. A Steer
13992
+ * without one releases the hero.
13993
+ */
13994
+ steer(steering) {
13995
+ return call("Steer", SteerRequest.toBinary({ player: this.slot, steering })) !== void 0;
13996
+ }
13997
+ /**
13998
+ * drive gives a bot the controls a player has, where it looks, the
13999
+ * movement axes and the buttons, as its input on every tick until the next
14000
+ * Drive replaces it. The game runs that input as a player's own, so the
14001
+ * hero accelerates, turns, jumps, dashes, slides and casts with its own
14002
+ * movement and animation; the bot's own brain no longer moves it. Presses
14003
+ * count once. A Drive without a command returns the bot to its brain.
14004
+ */
14005
+ drive(command2) {
14006
+ return call("Drive", DriveRequest.toBinary({ player: this.slot, command: command2 })) !== void 0;
14007
+ }
14008
+ /**
14009
+ * adjustSouls gives the player delta souls, or takes them when delta is
14010
+ * negative. A spend larger than the player's souls fails and spends
14011
+ * nothing. Silent skips the pickup's sound and number.
14012
+ */
14013
+ adjustSouls(delta, silent) {
14014
+ return call("AdjustSouls", AdjustSoulsRequest.toBinary({ player: this.slot, delta: int32(delta), silent })) !== void 0;
14015
+ }
14016
+ /**
14017
+ * adjustAbilityPoints gives the player ability points and ability unlocks,
14018
+ * or takes them when negative, as Pawn.ability_points and
14019
+ * Pawn.ability_unlocks read them. A spend larger than the player holds
14020
+ * fails and spends nothing.
14021
+ */
14022
+ adjustAbilityPoints(points, unlocks) {
14023
+ return call("AdjustAbilityPoints", AdjustAbilityPointsRequest.toBinary({ player: this.slot, points: int32(points), unlocks: int32(unlocks) })) !== void 0;
14024
+ }
14025
+ /** startingSouls sets the souls the player's hero spawns with. */
14026
+ startingSouls(souls) {
14027
+ return call("StartingSouls", StartingSoulsRequest.toBinary({ player: this.slot, souls: int32(souls) })) !== void 0;
14028
+ }
14029
+ /**
14030
+ * resetHero rebuilds the player's hero as it first spawned, without items,
14031
+ * ability upgrades, levels or ability points, holding souls.
14032
+ */
14033
+ resetHero(souls) {
14034
+ return call("ResetHero", ResetHeroRequest.toBinary({ player: this.slot, souls: int32(souls) })) !== void 0;
14035
+ }
14036
+ /** heal restores health to the player's hero, up to its maximum. */
14037
+ heal(amount) {
14038
+ return call("Heal", HealRequest.toBinary({ player: this.slot, amount: int32(amount) })) !== void 0;
14039
+ }
14040
+ /**
14041
+ * sound plays a game sound event, such as Damage.Send.Crit, on the
14042
+ * player's hero, and returns its ID. It follows the hero as it moves.
14043
+ * Volume and pitch scale the sound, and listeners limit who hears it.
14044
+ */
14045
+ sound(sound, options) {
14046
+ const reply2 = call("Sound", SoundRequest.toBinary({ player: this.slot, sound, options: options === void 0 ? void 0 : toSoundOptions(options) }));
14047
+ if (reply2 === void 0) return void 0;
14048
+ const response = SoundResponse.fromBinary(reply2);
14049
+ return response.id ?? 0;
14050
+ }
14051
+ /**
14052
+ * restoreHero gives the player's live hero target over the next few
14053
+ * seconds: the build first, then health, stamina and pose once it settles,
14054
+ * then charges and cooldowns. A Restored event reports when the result has
14055
+ * held for a second, or why it could not. A new call replaces the running
14056
+ * one. A pawn with hero 0 has no hero to restore; the call fails until
14057
+ * SelectHero gives it one.
14058
+ */
14059
+ restoreHero(target) {
14060
+ return call("RestoreHero", RestoreHeroRequest.toBinary({ player: this.slot, target: toHeroTarget(target) })) !== void 0;
14061
+ }
14062
+ /**
14063
+ * screenEffect plays a full-screen effect on the player's view. Effects of
14064
+ * one kind stack. The player's hero must be alive.
14065
+ */
14066
+ screenEffect(effect, timing) {
14067
+ return call("ScreenEffect", ScreenEffectRequest.toBinary({ player: this.slot, effect: screenEffectValues[effect], timing })) !== void 0;
14068
+ }
14069
+ /**
14070
+ * clearScreenEffect ends every running instance of effect on the player's
14071
+ * view.
14072
+ */
14073
+ clearScreenEffect(effect) {
14074
+ return call("ClearScreenEffect", ClearScreenEffectRequest.toBinary({ player: this.slot, effect: screenEffectValues[effect] })) !== void 0;
14075
+ }
14076
+ /**
14077
+ * silenceVoice keeps the player's hero from speaking the named voice
14078
+ * concepts until called again, on top of those silenced for everyone.
14079
+ */
14080
+ silenceVoice(concepts) {
14081
+ return call("SilencePlayerVoice", SilencePlayerVoiceRequest.toBinary({ player: this.slot, concepts: concepts?.slice() })) !== void 0;
14082
+ }
14083
+ /** removeBot removes a bot the mod added. */
14084
+ removeBot() {
14085
+ return call("RemoveBot", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
14086
+ }
14087
+ /**
14088
+ * blockInput withholds buttons from the player's hero until called
14089
+ * again, on top of the block on everyone. Zero releases the player.
14090
+ */
14091
+ blockInput(buttons) {
14092
+ return call("BlockPlayerInput", PlayerInputRequest.toBinary({ player: this.slot, buttons })) !== void 0;
14093
+ }
14094
+ /**
14095
+ * press presses buttons at the player's next input, even through a block.
14096
+ * A bot presses them as a player would.
14097
+ */
14098
+ press(buttons) {
14099
+ return call("Press", PlayerInputRequest.toBinary({ player: this.slot, buttons })) !== void 0;
14100
+ }
14101
+ /** kill kills a player's hero, crediting no one. */
14102
+ kill() {
14103
+ return call("Kill", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
14104
+ }
14105
+ /** setVelocity replaces the motion of a player's hero without moving it. */
14106
+ setVelocity(velocity) {
14107
+ return call("SetVelocity", SetVelocityRequest.toBinary({ player: this.slot, velocity })) !== void 0;
14108
+ }
14109
+ /**
14110
+ * buttons returns the buttons a player holds, as Buttons bits, while the
14111
+ * player is alive or dead.
14112
+ */
14113
+ buttons() {
14114
+ const reply2 = call("Buttons", PlayerRequest.toBinary({ player: this.slot }));
14115
+ if (reply2 === void 0) return void 0;
14116
+ const response = ButtonsResponse.fromBinary(reply2);
14117
+ return response.buttons ?? 0n;
14118
+ }
14119
+ /**
14120
+ * watchMovement adds a player's hero to the movement samples of each Frame
14121
+ * event on a new tick, or removes it.
14122
+ */
14123
+ watchMovement(watch) {
14124
+ return call("WatchMovement", WatchMovementRequest.toBinary({ player: this.slot, watch })) !== void 0;
14125
+ }
14126
+ };
14127
+ var WorldObject = class {
14128
+ /** id identifies the object among the mod's objects. */
14129
+ id;
14130
+ constructor(id) {
14131
+ this.id = id;
14132
+ }
14133
+ /**
14134
+ * move places the object at position, turning it to facing. The
14135
+ * physics step pulls a solid model to its new place over one tick, so a
14136
+ * model moved each frame strikes physics props such as the Hideout ball
14137
+ * with its speed instead of passing through them.
14138
+ */
14139
+ move(position, facing) {
14140
+ return call("MoveObject", MoveObjectRequest.toBinary({ object: this.id, position, facing })) !== void 0;
14141
+ }
14142
+ /** setText replaces a text object's words. */
14143
+ setText(text2) {
14144
+ return call("SetText", SetTextRequest.toBinary({ object: this.id, text: text2 })) !== void 0;
14145
+ }
14146
+ /**
14147
+ * setHidden hides the object from one player or shows it again.
14148
+ * Other players still see it. A player who leaves sees every object when
14149
+ * they return.
14150
+ */
14151
+ setHidden(player, hidden) {
14152
+ return call("SetObjectHidden", SetObjectHiddenRequest.toBinary({ object: this.id, player: player.slot, hidden })) !== void 0;
14153
+ }
14154
+ /**
14155
+ * showOnlyTo sends the object only to the players with the listed
14156
+ * server slots; every other client drops it, or never receives it when the
14157
+ * call follows its creation in the same frame. With no players no client
14158
+ * receives it. The list replaces any earlier one and follows the object
14159
+ * when its entity changes. A player who leaves is taken off every list, so
14160
+ * whoever joins in their slot does not receive the object. A removed object
14161
+ * reaches no client while the engine retires its entity.
14162
+ */
14163
+ showOnlyTo(players2) {
14164
+ return call("ShowObjectOnlyTo", ShowObjectOnlyToRequest.toBinary({ object: this.id, players: players2?.map((v) => int32(v)) })) !== void 0;
14165
+ }
14166
+ /**
14167
+ * showToAll sends the object to every player again, undoing
14168
+ * ShowObjectOnlyTo.
14169
+ */
14170
+ showToAll() {
14171
+ return call("ShowObjectToAll", ObjectRequest.toBinary({ object: this.id })) !== void 0;
14172
+ }
14173
+ /** remove takes the object out of the world. */
14174
+ remove() {
14175
+ return call("RemoveObject", ObjectRequest.toBinary({ object: this.id })) !== void 0;
14176
+ }
14177
+ /**
14178
+ * entity returns the entity handle of a model or particle, as traces
14179
+ * report it and particle anchors take it.
14180
+ */
14181
+ entity() {
14182
+ const reply2 = call("ObjectEntity", ObjectRequest.toBinary({ object: this.id }));
14183
+ if (reply2 === void 0) return void 0;
14184
+ const response = EntityResponse.fromBinary(reply2);
14185
+ return response.entity ?? 0;
14186
+ }
14187
+ };
14188
+ var Npc = class {
14189
+ /** entity is the unit's entity handle, as damage events report it. */
14190
+ entity;
14191
+ constructor(entity) {
14192
+ this.entity = entity;
14193
+ }
14194
+ /** read returns the unit's state, or nothing once it is gone. */
14195
+ read() {
14196
+ const reply2 = call("ReadNpc", NpcRequest.toBinary({ npc: this.entity }));
14197
+ if (reply2 === void 0) return void 0;
14198
+ const response = NpcStateResponse.fromBinary(reply2);
14199
+ return response.state === void 0 ? void 0 : fromNpcState(response.state);
14200
+ }
14201
+ /**
14202
+ * move places the unit and sets its velocity, which drives its walk
14203
+ * animation. It sets the pose without a teleport, which would reset the
14204
+ * unit's animation, so a mode can steer its units every frame. It reports
14205
+ * false once the unit is gone.
14206
+ */
14207
+ move(position, facing, velocity) {
14208
+ const reply2 = call("MoveNpc", MoveNpcRequest.toBinary({ npc: this.entity, position, facing, velocity }));
14209
+ if (reply2 === void 0) return false;
14210
+ const response = AliveResponse.fromBinary(reply2);
14211
+ return response.alive ?? false;
14212
+ }
14213
+ /**
14214
+ * setHealth sets the unit's health, and its maximum when given. It
14215
+ * reports false once the unit is gone.
14216
+ */
14217
+ setHealth(health, maxHealth) {
14218
+ const reply2 = call("SetNpcHealth", SetNpcHealthRequest.toBinary({ npc: this.entity, health: int32(health), maxHealth: maxHealth === void 0 ? void 0 : int32(maxHealth) }));
14219
+ if (reply2 === void 0) return false;
14220
+ const response = AliveResponse.fromBinary(reply2);
14221
+ return response.alive ?? false;
14222
+ }
14223
+ /**
14224
+ * remove takes a unit the mod spawned out of the world without rewards.
14225
+ * It reports false when the unit was already gone.
14226
+ */
14227
+ remove() {
14228
+ const reply2 = call("RemoveNpc", NpcRequest.toBinary({ npc: this.entity }));
14229
+ if (reply2 === void 0) return false;
14230
+ const response = AliveResponse.fromBinary(reply2);
14231
+ return response.alive ?? false;
14232
+ }
14233
+ };
14234
+ var Pickup = class {
14235
+ /** entity is the pickup's entity handle. */
14236
+ entity;
14237
+ constructor(entity) {
14238
+ this.entity = entity;
14239
+ }
14240
+ /**
14241
+ * present reports whether the pickup still lies in the world,
14242
+ * uncollected.
14243
+ */
14244
+ present() {
14245
+ const reply2 = call("PickupPresent", PickupRequest.toBinary({ pickup: this.entity }));
14246
+ if (reply2 === void 0) return false;
14247
+ const response = AliveResponse.fromBinary(reply2);
14248
+ return response.alive ?? false;
14249
+ }
14250
+ /**
14251
+ * remove takes the pickup out of the world. It reports false when a
14252
+ * player had collected it.
14253
+ */
14254
+ remove() {
14255
+ const reply2 = call("RemovePickup", PickupRequest.toBinary({ pickup: this.entity }));
14256
+ if (reply2 === void 0) return false;
14257
+ const response = AliveResponse.fromBinary(reply2);
14258
+ return response.alive ?? false;
14259
+ }
14260
+ };
14261
+ function log(message) {
14262
+ return call("Log", LogRequest.toBinary({ message })) !== void 0;
14263
+ }
14264
+ function serverCommand(command2) {
14265
+ return call("ServerCommand", ServerCommandRequest.toBinary({ command: command2 })) !== void 0;
14266
+ }
14267
+ function precache(options) {
14268
+ return call("Precache", PrecacheOptions.toBinary(toPrecacheOptions(options))) !== void 0;
14269
+ }
14270
+ function readFile(path) {
14271
+ const reply2 = call("ReadFile", ReadFileRequest.toBinary({ path }));
14272
+ if (reply2 === void 0) return void 0;
14273
+ const response = ReadFileResponse.fromBinary(reply2);
14274
+ return response.text;
14275
+ }
14276
+ function writeFile(path, text2) {
14277
+ return call("WriteFile", WriteFileRequest.toBinary({ path, text: text2 })) !== void 0;
14278
+ }
14279
+ function holdReload(held) {
14280
+ return call("HoldReload", HoldReloadRequest.toBinary({ held })) !== void 0;
14281
+ }
14282
+ function handoff(text2) {
14283
+ return call("Handoff", HandoffRequest.toBinary({ text: text2 })) !== void 0;
14284
+ }
14285
+ function handedOff() {
14286
+ const reply2 = call("HandedOff", new Uint8Array());
14287
+ if (reply2 === void 0) return void 0;
14288
+ const response = HandedOffResponse.fromBinary(reply2);
14289
+ return response.text ?? "";
14290
+ }
14291
+ function heroBuild(hero) {
14292
+ const reply2 = call("HeroBuild", HeroBuildRequest.toBinary({ hero: heroName(hero) }));
14293
+ if (reply2 === void 0) return [];
14294
+ const response = HeroBuildResponse.fromBinary(reply2);
14295
+ return (response.categories ?? []).map((v) => fromBuildCategory(v));
14296
+ }
14297
+ function silenceVoice(concepts) {
14298
+ return call("SilenceVoice", SilenceVoiceRequest.toBinary({ concepts: concepts?.slice() })) !== void 0;
14299
+ }
14300
+ function readField(entity, className, field, type) {
14301
+ const reply2 = call("ReadField", ReadFieldRequest.toBinary({ entity, className, field, type: fieldTypeValues[type] }));
14302
+ if (reply2 === void 0) return void 0;
14303
+ const response = FieldResponse.fromBinary(reply2);
14304
+ return fromFieldValue(response.value);
14305
+ }
14306
+ function readModifierField(entity, modifier, className, field, type) {
14307
+ const reply2 = call("ReadModifierField", ReadModifierFieldRequest.toBinary({ entity, modifier, className, field, type: fieldTypeValues[type] }));
14308
+ if (reply2 === void 0) return void 0;
14309
+ const response = FieldResponse.fromBinary(reply2);
14310
+ return fromFieldValue(response.value);
14311
+ }
14312
+ function writeField(entity, className, field, type, value) {
14313
+ return call("WriteField", WriteFieldRequest.toBinary({ entity, className, field, type: fieldTypeValues[type], value: toFieldValue(value) })) !== void 0;
14314
+ }
14315
+ function readFieldList(entity, className, field, type) {
14316
+ const reply2 = call("ReadFieldList", ReadFieldRequest.toBinary({ entity, className, field, type: fieldTypeValues[type] }));
14317
+ if (reply2 === void 0) return [];
14318
+ const response = FieldListResponse.fromBinary(reply2);
14319
+ return known(response.values, (v) => fromFieldValue(v));
14320
+ }
14321
+ function writeFieldList(entity, className, field, type, values) {
14322
+ return call("WriteFieldList", WriteFieldListRequest.toBinary({ entity, className, field, type: fieldTypeValues[type], values: values?.map((v) => toFieldValue(v)) })) !== void 0;
14323
+ }
14324
+ function entityClass(entity) {
14325
+ const reply2 = call("EntityClass", EntityRequest.toBinary({ entity }));
14326
+ if (reply2 === void 0) return void 0;
14327
+ const response = EntityClassResponse.fromBinary(reply2);
14328
+ return response.name === void 0 ? void 0 : fromEntityClassName(response.name);
14329
+ }
14330
+ function entityName(entity) {
14331
+ const reply2 = call("EntityName", EntityRequest.toBinary({ entity }));
14332
+ if (reply2 === void 0) return void 0;
14333
+ const response = EntityNameResponse.fromBinary(reply2);
14334
+ return response.name ?? "";
14335
+ }
14336
+ function entityPosition(entity) {
14337
+ const reply2 = call("EntityPosition", EntityRequest.toBinary({ entity }));
14338
+ if (reply2 === void 0) return void 0;
14339
+ const response = EntityPositionResponse.fromBinary(reply2);
14340
+ return response.placement === void 0 ? void 0 : fromEntityPlacement(response.placement);
14341
+ }
14342
+ function modifierState(entity, state) {
14343
+ const reply2 = call("ModifierState", ModifierStateRequest.toBinary({ entity, state }));
14344
+ if (reply2 === void 0) return false;
14345
+ const response = ActiveResponse.fromBinary(reply2);
14346
+ return response.active ?? false;
14347
+ }
14348
+ function holdModifierState(entity, state, active) {
14349
+ return call("HoldModifierState", HoldModifierStateRequest.toBinary({ entity, state, active })) !== void 0;
14350
+ }
14351
+ function setFreeForAll(enabled) {
14352
+ return call("SetFreeForAll", SetFreeForAllRequest.toBinary({ enabled })) !== void 0;
14353
+ }
14354
+ function setTeamSeating(enabled) {
14355
+ return call("SetTeamSeating", SetTeamSeatingRequest.toBinary({ enabled })) !== void 0;
14356
+ }
14357
+ function createModel(options) {
14358
+ const reply2 = call("CreateModel", ModelOptions.toBinary(options));
14359
+ if (reply2 === void 0) return void 0;
14360
+ const response = ObjectResponse.fromBinary(reply2);
14361
+ return new WorldObject(response.object ?? 0);
14362
+ }
14363
+ function createText(options) {
14364
+ const reply2 = call("CreateText", TextOptions.toBinary(toTextOptions(options)));
14365
+ if (reply2 === void 0) return void 0;
14366
+ const response = ObjectResponse.fromBinary(reply2);
14367
+ return new WorldObject(response.object ?? 0);
14368
+ }
14369
+ function createParticle(options) {
14370
+ const reply2 = call("CreateParticle", ParticleOptions.toBinary(toParticleOptions(options)));
14371
+ if (reply2 === void 0) return void 0;
14372
+ const response = ObjectResponse.fromBinary(reply2);
14373
+ return new WorldObject(response.object ?? 0);
14374
+ }
14375
+ function createFog(options) {
14376
+ const reply2 = call("CreateFog", FogOptions.toBinary(options));
14377
+ if (reply2 === void 0) return void 0;
14378
+ const response = ObjectResponse.fromBinary(reply2);
14379
+ return new WorldObject(response.object ?? 0);
14380
+ }
14381
+ function addBot(options) {
14382
+ const reply2 = call("AddBot", BotOptions.toBinary(toBotOptions(options)));
14383
+ if (reply2 === void 0) return void 0;
14384
+ const response = BotResponse.fromBinary(reply2);
14385
+ return Player.of(response.player ?? 0);
14386
+ }
14387
+ function blockInput(buttons) {
14388
+ return call("BlockInput", InputRequest.toBinary({ buttons })) !== void 0;
14389
+ }
14390
+ function watchInput(buttons) {
14391
+ return call("WatchInput", InputRequest.toBinary({ buttons })) !== void 0;
14392
+ }
14393
+ function remapInput(from, to, repeat2) {
14394
+ return call("RemapInput", RemapInputRequest.toBinary({ from, to, repeat: repeat2 })) !== void 0;
14395
+ }
14396
+ function callService(service2, method, payload) {
14397
+ const reply2 = call("CallService", ServiceCall.toBinary({ service: service2, method, payload }));
14398
+ if (reply2 === void 0) return void 0;
14399
+ const response = ServiceReply.fromBinary(reply2);
14400
+ return response.payload ?? new Uint8Array();
14401
+ }
14402
+ function createEntity(options) {
14403
+ const reply2 = call("CreateEntity", EntityOptions.toBinary(toEntityOptions(options)));
14404
+ if (reply2 === void 0) return void 0;
14405
+ const response = EntityResponse.fromBinary(reply2);
14406
+ return response.entity ?? 0;
14407
+ }
14408
+ function fireInput(entity, input2, value, activator) {
14409
+ const reply2 = call("FireInput", FireInputRequest.toBinary({ entity, input: input2, value: value === void 0 ? void 0 : toEntityValue(value), activator }));
14410
+ if (reply2 === void 0) return false;
14411
+ const response = AliveResponse.fromBinary(reply2);
14412
+ return response.alive ?? false;
14413
+ }
14414
+ function removeEntity(entity) {
14415
+ const reply2 = call("RemoveEntity", EntityRequest.toBinary({ entity }));
14416
+ if (reply2 === void 0) return false;
14417
+ const response = AliveResponse.fromBinary(reply2);
14418
+ return response.alive ?? false;
14419
+ }
14420
+ function showEntityOnlyTo(entity, players2) {
14421
+ return call("ShowEntityOnlyTo", ShowEntityOnlyToRequest.toBinary({ entity, players: players2?.map((v) => int32(v)) })) !== void 0;
14422
+ }
14423
+ function showEntityToAll(entity) {
14424
+ return call("ShowEntityToAll", EntityRequest.toBinary({ entity })) !== void 0;
14425
+ }
14426
+ function spawnNpc(options) {
14427
+ const reply2 = call("SpawnNpc", NpcOptions.toBinary(toNpcOptions(options)));
14428
+ if (reply2 === void 0) return void 0;
14429
+ const response = NpcResponse.fromBinary(reply2);
14430
+ return new Npc(response.npc ?? 0);
14431
+ }
14432
+ function createPickup(kind, position) {
14433
+ const reply2 = call("CreatePickup", CreatePickupRequest.toBinary({ kind: pickupKindValues[kind], position }));
14434
+ if (reply2 === void 0) return void 0;
14435
+ const response = PickupResponse.fromBinary(reply2);
14436
+ return new Pickup(response.pickup ?? 0);
14437
+ }
14438
+ function findEntities(className) {
14439
+ const reply2 = call("FindEntities", FindEntitiesRequest.toBinary({ className }));
14440
+ if (reply2 === void 0) return [];
14441
+ const response = EntitiesResponse.fromBinary(reply2);
14442
+ return response.entities ?? [];
14443
+ }
14444
+ function findEntitiesByName(name) {
14445
+ const reply2 = call("FindEntitiesByName", FindEntitiesByNameRequest.toBinary({ name }));
14446
+ if (reply2 === void 0) return [];
14447
+ const response = EntitiesResponse.fromBinary(reply2);
14448
+ return response.entities ?? [];
14449
+ }
14450
+ function removeEntities(className) {
14451
+ const reply2 = call("RemoveEntities", RemoveEntitiesRequest.toBinary({ className }));
14452
+ if (reply2 === void 0) return void 0;
14453
+ const response = CountResponse.fromBinary(reply2);
14454
+ return response.count ?? 0;
14455
+ }
14456
+ function clearMap() {
14457
+ return call("ClearMap", new Uint8Array()) !== void 0;
14458
+ }
14459
+ function damage(options) {
14460
+ return call("Damage", HitOptions.toBinary(toHitOptions(options))) !== void 0;
14461
+ }
14462
+ function killEntity(options) {
14463
+ return call("KillEntity", KillOptions.toBinary(options)) !== void 0;
14464
+ }
14465
+ function trace(options) {
14466
+ const reply2 = call("Trace", TraceOptions.toBinary(toTraceOptions(options)));
14467
+ if (reply2 === void 0) return void 0;
14468
+ const response = TraceResponse.fromBinary(reply2);
14469
+ return response.hit === void 0 ? void 0 : fromTraceHit(response.hit);
14470
+ }
14471
+ function restoreNpcs(npcs) {
14472
+ return call("RestoreNpcs", RestoreNpcsRequest.toBinary({ npcs: npcs?.map((v) => toNpcTarget(v)) })) !== void 0;
14473
+ }
14474
+ function pause(paused) {
14475
+ return call("Pause", PauseRequest.toBinary({ paused })) !== void 0;
14476
+ }
14477
+ function matchClock() {
14478
+ const reply2 = call("MatchClock", new Uint8Array());
14479
+ if (reply2 === void 0) return void 0;
14480
+ const response = MatchClockResponse.fromBinary(reply2);
14481
+ return response.seconds ?? 0;
14482
+ }
14483
+ function holdMatchClock(seconds) {
14484
+ return call("HoldMatchClock", HoldMatchClockRequest.toBinary({ seconds })) !== void 0;
14485
+ }
14486
+ function rift() {
14487
+ const reply2 = call("Rift", new Uint8Array());
14488
+ if (reply2 === void 0) return void 0;
14489
+ const response = RiftResponse.fromBinary(reply2);
14490
+ return response.state === void 0 ? void 0 : fromRiftState(response.state);
14491
+ }
14492
+ function startRift(position) {
14493
+ return call("StartRift", StartRiftRequest.toBinary({ position })) !== void 0;
14494
+ }
14495
+ function moveEntity(entity, position, facing, velocity) {
14496
+ return call("MoveEntity", MoveEntityRequest.toBinary({ entity, position, facing, velocity })) !== void 0;
14497
+ }
14498
+ function pushEntity(entity, velocity, spin) {
14499
+ return call("PushEntity", PushEntityRequest.toBinary({ entity, velocity, spin })) !== void 0;
14500
+ }
14501
+ function emitSound(entity, sound, options) {
14502
+ const reply2 = call("EmitSound", EmitSoundRequest.toBinary({ entity, sound, options: options === void 0 ? void 0 : toSoundOptions(options) }));
14503
+ if (reply2 === void 0) return void 0;
14504
+ const response = SoundResponse.fromBinary(reply2);
14505
+ return response.id ?? 0;
14506
+ }
14507
+ function adjustSound(id, volume, pitch) {
14508
+ return call("AdjustSound", AdjustSoundRequest.toBinary({ id, volume, pitch })) !== void 0;
14509
+ }
14510
+ function stopSound(id) {
14511
+ return call("StopSound", StopSoundRequest.toBinary({ id })) !== void 0;
14512
+ }
14513
+ function watchProjectiles(options) {
14514
+ return call("WatchProjectiles", ProjectileOptions.toBinary(toProjectileOptions(options))) !== void 0;
14515
+ }
14516
+ function holdEntityModifier(entity, modifier, active) {
14517
+ return call("HoldEntityModifier", HoldEntityModifierRequest.toBinary({ entity, modifier, active })) !== void 0;
14518
+ }
14519
+ function giveEntityModifier(entity, modifier, seconds) {
14520
+ return call("GiveEntityModifier", GiveEntityModifierRequest.toBinary({ entity, modifier, seconds })) !== void 0;
14521
+ }
14522
+ function serveMod(handlers2, bytes) {
14523
+ const request = Call.fromBinary(bytes);
14524
+ const input2 = request.request ?? new Uint8Array();
14525
+ try {
14526
+ switch (request.method) {
14527
+ case "Start":
14528
+ return reply(StartResult.toBinary(handlers2.start(fromStartEvent(StartEvent.fromBinary(input2)))));
14529
+ case "Frame":
14530
+ handlers2.frame(fromFrameEvent(FrameEvent.fromBinary(input2)));
14531
+ return reply();
14532
+ case "Command":
14533
+ return reply(CommandResult.toBinary(handlers2.command(fromCommandEvent(CommandEvent.fromBinary(input2)))));
14534
+ case "Chat":
14535
+ handlers2.chat(fromChatEvent(ChatEvent.fromBinary(input2)));
14536
+ return reply();
14537
+ case "World":
14538
+ handlers2.world(fromWorldEvent(WorldEvent.fromBinary(input2)));
14539
+ return reply();
14540
+ case "UiPress":
14541
+ handlers2.uiPress(fromUiPressEvent(UiPressEvent.fromBinary(input2)));
14542
+ return reply();
14543
+ case "UiInput":
14544
+ handlers2.uiInput(fromUiInputEvent(UiInputEvent.fromBinary(input2)));
14545
+ return reply();
14546
+ case "Serve":
14547
+ return reply(ServiceReply.toBinary(handlers2.serve(fromServiceCall(ServiceCall.fromBinary(input2)))));
14548
+ case "Damage":
14549
+ return reply(DamageResult.toBinary(handlers2.damage(fromDamageEvent(DamageEvent.fromBinary(input2)))));
14550
+ case "Damaged":
14551
+ handlers2.damaged(fromDamagedEvent(DamagedEvent.fromBinary(input2)));
14552
+ return reply();
14553
+ case "Input":
14554
+ handlers2.input(fromInputEvent(InputEvent.fromBinary(input2)));
14555
+ return reply();
14556
+ case "Restored":
14557
+ handlers2.restored(fromRestoredEvent(RestoredEvent.fromBinary(input2)));
14558
+ return reply();
14559
+ case "NpcsRestored":
14560
+ handlers2.npcsRestored(fromNpcsRestoredEvent(NpcsRestoredEvent.fromBinary(input2)));
14561
+ return reply();
14562
+ case "Launch":
14563
+ handlers2.launch(fromLaunchEvent(LaunchEvent.fromBinary(input2)));
14564
+ return reply();
14565
+ case "Impact":
14566
+ handlers2.impact(fromImpactEvent(ImpactEvent.fromBinary(input2)));
14567
+ return reply();
14568
+ case "Landed":
14569
+ handlers2.landed(fromLandedEvent(LandedEvent.fromBinary(input2)));
14570
+ return reply();
14571
+ case "SettingChanged":
14572
+ handlers2.settingChanged(fromSettingChangedEvent(SettingChangedEvent.fromBinary(input2)));
14573
+ return reply();
14574
+ case "PlayerJoined":
14575
+ handlers2.playerJoined(fromPlayerJoinedEvent(PlayerJoinedEvent.fromBinary(input2)));
14576
+ return reply();
14577
+ case "PlayerLeft":
14578
+ handlers2.playerLeft(fromPlayerLeftEvent(PlayerLeftEvent.fromBinary(input2)));
14579
+ return reply();
14580
+ case "PlayersChanged":
14581
+ handlers2.playersChanged(fromPlayersChangedEvent(PlayersChangedEvent.fromBinary(input2)));
14582
+ return reply();
14583
+ }
14584
+ } catch (error) {
14585
+ return Reply.toBinary({ error: String(error) });
14586
+ }
14587
+ return Reply.toBinary({ error: `the mod has no method ${request.method}` });
14588
+ }
14589
+
14590
+ // js/src/players.ts
14591
+ var roster = void 0;
14592
+ var generations = /* @__PURE__ */ new Map();
14593
+ var watchers = [];
14594
+ function keepPlayers(players2) {
14595
+ roster = adopt(players2);
14596
+ for (const watcher of watchers) {
14597
+ watcher(roster);
14598
+ }
14599
+ }
14600
+ function adopt(players2) {
14601
+ const current = new Map(players2.map((c) => [c.player.slot, c.generation]));
14602
+ for (const [slot, generation] of generations) {
14603
+ if (current.get(slot) !== generation) Player.release(slot);
14604
+ }
14605
+ generations.clear();
14606
+ return players2.map((c) => {
14607
+ generations.set(c.player.slot, c.generation);
14608
+ const player = Player.of(c.player.slot);
14609
+ return player === c.player ? c : { ...c, player };
14610
+ });
14611
+ }
14612
+ function watchPlayers(watcher) {
14613
+ watchers.push(watcher);
14614
+ if (roster !== void 0) watcher(roster);
14615
+ }
14616
+ function connection(player) {
14617
+ const slot = typeof player === "number" ? player : player.slot;
14618
+ return (roster ?? players()).find((c) => c.player.slot === slot);
14619
+ }
14620
+ function players() {
14621
+ if (roster !== void 0) return roster.slice();
14622
+ const reply2 = call("Players", new Uint8Array());
14623
+ if (reply2 === void 0) return [];
14624
+ return adopt(
14625
+ (PlayersResponse.fromBinary(reply2).players ?? []).map((c) => ({
14626
+ player: Player.of(c.player ?? 0),
14627
+ steamId: c.steamId ?? 0n,
14628
+ name: c.name ?? "",
14629
+ bot: c.bot ?? false,
14630
+ ready: c.ready ?? false,
14631
+ generation: c.generation ?? 0,
14632
+ roles: (c.roles ?? []).flatMap((role) => roleNames[role] ?? [])
14633
+ }))
14634
+ );
14635
+ }
14636
+ var roleNames = {
14637
+ [1 /* DEVELOPER */]: "developer",
14638
+ [2 /* TESTER */]: "tester"
14639
+ };
14640
+
14641
+ // js/src/cast.ts
14642
+ var changeSeconds = 3;
14643
+ var noWant = {};
14644
+ var Cast = class {
14645
+ constructor(options) {
14646
+ this.options = options;
14647
+ watchPlayers((players2) => {
14648
+ this.reported = players2;
14649
+ });
14650
+ }
14651
+ options;
14652
+ seats = /* @__PURE__ */ new Map();
14653
+ /** kicked holds the connection generation each kicked bot's slot had. */
14654
+ kicked = /* @__PURE__ */ new Map();
14655
+ /** reported is the player list the host reported since the last frame. */
14656
+ reported;
14657
+ /** size is the number of members. */
14658
+ get size() {
14659
+ return this.seats.size;
14660
+ }
14661
+ /** members lists the members in the order they joined. */
14662
+ members() {
14663
+ return Array.from(this.seats.values(), (seat) => seat.member);
14664
+ }
14665
+ /** get returns the member in player's slot, if any. */
14666
+ get(player) {
14667
+ return this.seats.get(player.slot)?.member;
14668
+ }
14669
+ /** pawn returns the member's hero as Cast read it this frame. */
14670
+ pawn(player) {
14671
+ return this.seats.get(player.slot)?.pawn;
14672
+ }
14673
+ /**
14674
+ * frame settles the joins and leaves reported since the last frame, reads
14675
+ * each member's hero, and asks the game once a second for any want it does
14676
+ * not show yet. seconds is the game clock.
14677
+ */
14678
+ frame(seconds) {
14679
+ if (this.reported !== void 0) {
14680
+ this.settle(this.reported, seconds);
14681
+ this.reported = void 0;
14682
+ }
14683
+ for (const seat of this.seats.values()) {
14684
+ this.reconcile(seat, seconds);
14685
+ }
14686
+ }
14687
+ /**
14688
+ * settle ends the members whose connection left and makes the new ones,
14689
+ * joined at now.
14690
+ */
14691
+ settle(players2, now4) {
14692
+ const present = new Map(players2.map((c) => [c.player.slot, c]));
14693
+ for (const [slot, seat] of this.seats) {
14694
+ if (present.get(slot)?.generation !== seat.connection.generation) {
14695
+ this.seats.delete(slot);
14696
+ this.options.leave?.(seat.member, seat.connection);
14697
+ }
14698
+ }
14699
+ const { bots = "skip" } = this.options;
14700
+ for (const connection2 of players2) {
14701
+ const slot = connection2.player.slot;
14702
+ if (!connection2.ready || this.seats.has(slot)) continue;
14703
+ if (connection2.bot && bots !== "join") {
14704
+ if (bots === "kick") this.kick(connection2);
14705
+ continue;
14706
+ }
14707
+ this.seats.set(slot, {
14708
+ connection: connection2,
14709
+ member: this.options.join(connection2),
14710
+ pawn: void 0,
14711
+ alive: false,
14712
+ fellAt: -Infinity,
14713
+ hero: 0,
14714
+ heroLostAt: -Infinity,
14715
+ joinedAt: now4,
14716
+ askedAt: -Infinity
14717
+ });
14718
+ }
14719
+ }
14720
+ /** kick asks the server to remove a bot, once per connection. */
14721
+ kick(connection2) {
14722
+ const slot = connection2.player.slot;
14723
+ if (this.kicked.get(slot) === connection2.generation) return;
14724
+ this.kicked.set(slot, connection2.generation);
14725
+ serverCommand(`kick "${connection2.name}"`);
14726
+ }
14727
+ /** reconcile reads a member's hero and asks for the part of the want it lacks. */
14728
+ reconcile(seat, now4) {
14729
+ const pawn = seat.connection.player.pawn();
14730
+ const alive = pawn !== void 0 && pawn.hero !== 0 && pawn.health > 0;
14731
+ if (seat.alive && !alive) seat.fellAt = now4;
14732
+ seat.pawn = pawn;
14733
+ seat.alive = alive;
14734
+ const had = pawn?.hero ?? 0;
14735
+ if (had === 0 && seat.hero !== 0) seat.heroLostAt = now4;
14736
+ seat.hero = had;
14737
+ const changing = had === 0 && now4 - seat.heroLostAt < changeSeconds;
14738
+ if (now4 - seat.askedAt < 1 || changing) return;
14739
+ const want = this.wantOf(seat);
14740
+ const { respawn } = want;
14741
+ const hero = want.hero ?? this.stranded(seat, now4);
14742
+ if (hero !== void 0 && !this.seated(seat, want, hero)) {
14743
+ seat.askedAt = now4;
14744
+ this.seat(seat, want, hero);
14745
+ } else if (respawn !== void 0 && pawn !== void 0 && pawn.hero !== 0 && !alive && now4 - seat.fellAt >= respawn) {
14746
+ seat.askedAt = now4;
14747
+ seat.connection.player.respawn();
14748
+ }
14749
+ }
14750
+ /**
14751
+ * stranded returns 'any' for a human whose hero is free when the game has
14752
+ * left them on a team without one for changeSeconds since they joined, and
14753
+ * otherwise leaves the hero free. Such a pawn never gets a hero on its own,
14754
+ * while a player still choosing one has no pawn and a spectator stands on
14755
+ * team 1. A bot is left to the game, which seats it.
14756
+ */
14757
+ stranded(seat, now4) {
14758
+ const { pawn } = seat;
14759
+ const team = pawn?.team;
14760
+ const heroless = pawn?.hero === 0 && (team === 2 || team === 3);
14761
+ return heroless && !seat.connection.bot && now4 - seat.joinedAt >= changeSeconds ? "any" : void 0;
14762
+ }
14763
+ /** wantOf is what the member in seat wants now. */
14764
+ wantOf(seat) {
14765
+ const { want = noWant } = this.options;
14766
+ return typeof want === "function" ? want(seat.member) : want;
14767
+ }
14768
+ /** seated reports whether the member's hero shows the hero and team they want. */
14769
+ seated(seat, want, hero) {
14770
+ const { pawn } = seat;
14771
+ if (pawn === void 0 || pawn.hero === 0) return false;
14772
+ if (want.team !== void 0 && pawn.team !== want.team) return false;
14773
+ if (hero === "any") return true;
14774
+ const id = typeof hero === "number" ? hero : heroNamed(hero)?.id;
14775
+ return id === void 0 || pawn.hero === id;
14776
+ }
14777
+ /** seat asks the game to put the member on hero and their team. */
14778
+ seat(seat, want, hero) {
14779
+ const { pawn } = seat;
14780
+ let pick = hero;
14781
+ if (hero === "any") {
14782
+ pick = pawn !== void 0 && pawn.hero !== 0 ? pawn.hero : heroes[Math.floor(Math.random() * heroes.length)]?.name;
14783
+ }
14784
+ if (pick !== void 0) {
14785
+ seat.connection.player.selectHero(pick, want.team ?? this.side(seat));
14786
+ }
14787
+ }
14788
+ /** side is the team a member joins: their hero's, or the one with fewer heroes. */
14789
+ side(seat) {
14790
+ const { pawn } = seat;
14791
+ if (pawn !== void 0 && pawn.hero !== 0 && (pawn.team === 2 || pawn.team === 3)) {
14792
+ return pawn.team;
14793
+ }
14794
+ let amber = 0;
14795
+ let sapphire = 0;
14796
+ for (const other of this.seats.values()) {
14797
+ if (other === seat || other.pawn === void 0 || other.pawn.hero === 0)
14798
+ continue;
14799
+ if (other.pawn.team === 2) amber++;
14800
+ if (other.pawn.team === 3) sapphire++;
14801
+ }
14802
+ return sapphire < amber ? 3 : 2;
14803
+ }
14804
+ };
14805
+
14806
+ // js/src/puppet.ts
14807
+ var ticksPerSecond = 64;
14808
+ function trackTicks(track) {
14809
+ return Math.max(track.x.length - 1, 0) * track.stepTicks;
14810
+ }
14811
+ function lerp(a, b, t) {
14812
+ return a + (b - a) * t;
14813
+ }
14814
+ function lerpAngle(a, b, t) {
14815
+ const delta = ((b - a) % 360 + 540) % 360 - 180;
14816
+ return a + delta * t;
14817
+ }
14818
+ function poseAt(track, tick2) {
14819
+ const last = track.x.length - 1;
14820
+ if (last < 0) return void 0;
14821
+ const at3 = Math.min(Math.max(tick2 / track.stepTicks, 0), last);
14822
+ const i = Math.min(Math.floor(at3), Math.max(last - 1, 0));
14823
+ const j = Math.min(i + 1, last);
14824
+ const t = at3 - i;
14825
+ const seconds = track.stepTicks / ticksPerSecond;
14826
+ const blend = (column) => lerp(sample(column, i), sample(column, j), t);
14827
+ const slope = (column) => (sample(column, j) - sample(column, i)) / seconds;
14828
+ const still = i === j;
14829
+ return {
14830
+ position: { x: blend(track.x), y: blend(track.y), z: blend(track.z) },
14831
+ facing: {
14832
+ pitch: track.pitch ? blend(track.pitch) : 0,
14833
+ yaw: lerpAngle(sample(track.yaw, i), sample(track.yaw, j), t),
14834
+ roll: 0
14835
+ },
14836
+ velocity: still ? { x: 0, y: 0, z: 0 } : { x: slope(track.x), y: slope(track.y), z: slope(track.z) },
14837
+ health: track.health && blend(track.health)
14838
+ };
14839
+ }
14840
+ function sample(column, index) {
14841
+ return column[index] ?? 0;
14842
+ }
14843
+ var ghostStates = [
14844
+ "MODIFIER_STATE_INVULNERABLE",
14845
+ "MODIFIER_STATE_NO_TARGET",
14846
+ "MODIFIER_STATE_IGNORED_BY_UNIT_FILTER",
14847
+ "MODIFIER_STATE_IGNORED_BY_NPC_TARGETING",
14848
+ "MODIFIER_STATE_INVISIBLE_ON_MINIMAP",
14849
+ "MODIFIER_STATE_UNIT_STATUS_HIDDEN"
14850
+ ];
14851
+ var ghostAlpha = 110;
14852
+ var renderTransColor = 1;
14853
+ var live = /* @__PURE__ */ new Set();
14854
+ var longestFrame = 0.25;
14855
+ function advancePuppets(seconds) {
14856
+ for (const puppet of live) puppet.advance(seconds);
14857
+ }
14858
+ var Puppet = class _Puppet {
14859
+ /**
14860
+ * The puppet drives player's hero along track. It owns the hero's placement
14861
+ * and, when the track records health, its health.
14862
+ */
14863
+ constructor(player, track, options = {}) {
14864
+ this.player = player;
14865
+ this.track = track;
14866
+ this.snapUnits = options.snapUnits ?? 200;
14867
+ live.add(this);
14868
+ if (options.ghost) this.setGhost(true);
14869
+ }
14870
+ player;
14871
+ track;
14872
+ tickAt = 0;
14873
+ rateNow = 1;
14874
+ current = "paused";
14875
+ /** clock is the game time of the last frame, unset until one arrives. */
14876
+ clock;
14877
+ /** drawn is whether the hero needs placing at the current tick. */
14878
+ drawn = false;
14879
+ ghostNow = false;
14880
+ dead = false;
14881
+ /** looked is the entity and ghost setting syncLook last wrote. */
14882
+ looked;
14883
+ lastHealth;
14884
+ snapUnits;
14885
+ /**
14886
+ * spawn adds a bot and returns a puppet for it, or undefined when no bot
14887
+ * could join. The bot appears at the track's first pose.
14888
+ */
14889
+ static spawn(bot, track, options) {
14890
+ const start = poseAt(track, 0);
14891
+ const player = addBot({ ...bot, position: bot.position ?? start?.position });
14892
+ return player && new _Puppet(player, track, options);
14893
+ }
14894
+ /** state is where playback stands. */
14895
+ get state() {
14896
+ return this.current;
14897
+ }
14898
+ /** tick is the playback position, in track ticks. */
14899
+ get tick() {
14900
+ return this.tickAt;
14901
+ }
14902
+ /** rate is the playback speed: 1 is real time, 0.5 half speed, negative runs backward. */
14903
+ get rate() {
14904
+ return this.rateNow;
14905
+ }
14906
+ set rate(rate) {
14907
+ this.rateNow = rate;
14908
+ }
14909
+ /** isGhost reports whether the puppet is a ghost. */
14910
+ get isGhost() {
14911
+ return this.ghostNow;
14912
+ }
14913
+ /** play starts or resumes playback; from the end it restarts at tick 0. */
14914
+ play() {
14915
+ if (this.current === "ended" && this.rateNow >= 0) this.seek(0);
14916
+ this.current = "playing";
14917
+ }
14918
+ /** pause holds the hero where it stands. */
14919
+ pause() {
14920
+ this.current = "paused";
14921
+ }
14922
+ /**
14923
+ * seek moves playback to tick, clamped to the track, and places the hero
14924
+ * there on the next frame. Playback keeps its state, except that an ended
14925
+ * puppet paused at the new tick.
14926
+ */
14927
+ seek(tick2) {
14928
+ this.tickAt = Math.min(Math.max(tick2, 0), trackTicks(this.track));
14929
+ this.drawn = false;
14930
+ this.lastHealth = void 0;
14931
+ if (this.current === "ended") this.current = "paused";
14932
+ }
14933
+ /**
14934
+ * setGhost draws the hero translucent and holds the modifier states of
14935
+ * ghostStates, so it takes no damage and is not targeted; off restores
14936
+ * both. The hero's collision with other heroes is the game's own.
14937
+ */
14938
+ setGhost(ghost) {
14939
+ this.ghostNow = ghost;
14940
+ const pawn = this.player.pawn();
14941
+ if (pawn) this.syncLook(pawn.entity);
14942
+ }
14943
+ /**
14944
+ * syncLook writes the ghost look and states to the hero entity when the
14945
+ * entity or the ghost setting differs from what it last wrote, so a hero
14946
+ * that respawned takes them again.
14947
+ */
14948
+ syncLook(entity) {
14949
+ if (this.looked?.entity === entity && this.looked.ghost === this.ghostNow) {
14950
+ return;
14951
+ }
14952
+ this.looked = { entity, ghost: this.ghostNow };
14953
+ for (const state of ghostStates) {
14954
+ holdModifierState(entity, state, this.ghostNow);
14955
+ }
14956
+ const alpha = this.ghostNow ? ghostAlpha : 255;
14957
+ const mode = this.ghostNow ? renderTransColor : 0;
14958
+ writeField(entity, "CBaseModelEntity", "m_nRenderMode", "uint8", mode);
14959
+ writeField(
14960
+ entity,
14961
+ "CBaseModelEntity",
14962
+ "m_clrRender",
14963
+ "uint32",
14964
+ 16777215 | alpha << 24
14965
+ );
14966
+ }
14967
+ /** stop ends the puppet and removes its bot; a hero that is not a bot stays. */
14968
+ stop() {
14969
+ live.delete(this);
14970
+ const pawn = this.player.pawn();
14971
+ if (pawn && this.ghostNow) {
14972
+ this.ghostNow = false;
14973
+ this.syncLook(pawn.entity);
14974
+ }
14975
+ const slot = this.player.slot;
14976
+ if (players().some((c) => c.player.slot === slot && c.bot)) {
14977
+ this.player.removeBot();
14978
+ }
14979
+ }
14980
+ /**
14981
+ * advance moves playback to the game clock at seconds and places the hero.
14982
+ * The library calls it each frame; a mod calls it only to step a puppet by
14983
+ * hand.
14984
+ */
14985
+ advance(seconds) {
14986
+ const elapsed = Math.min(seconds - (this.clock ?? seconds), longestFrame);
14987
+ this.clock = seconds;
14988
+ if (this.current === "playing" && elapsed > 0) {
14989
+ this.tickAt += elapsed * ticksPerSecond * this.rateNow;
14990
+ const end = trackTicks(this.track);
14991
+ if (this.tickAt >= end || this.tickAt <= 0) {
14992
+ this.tickAt = Math.min(Math.max(this.tickAt, 0), end);
14993
+ this.current = "ended";
14994
+ }
14995
+ this.drawn = false;
14996
+ }
14997
+ if (!this.drawn) this.place();
14998
+ }
14999
+ /** place puts the hero at the current tick; it retries next frame without a hero. */
15000
+ place() {
15001
+ const pawn = this.player.pawn();
15002
+ const pose = poseAt(this.track, this.tickAt);
15003
+ if (!pawn || !pose) return;
15004
+ this.syncLook(pawn.entity);
15005
+ const gap2 = Math.hypot(
15006
+ pose.position.x - pawn.position.x,
15007
+ pose.position.y - pawn.position.y,
15008
+ pose.position.z - pawn.position.z
15009
+ );
15010
+ const placed = gap2 > this.snapUnits || this.current !== "playing" ? this.player.teleport(pose.position, pose.facing) : this.player.move(pose.position, pose.facing, pose.velocity);
15011
+ if (placed) this.drawn = true;
15012
+ this.setHealth(pawn.entity, pose.health);
15013
+ }
15014
+ /**
15015
+ * setHealth gives the hero the recorded health. A recorded zero kills the
15016
+ * hero once; the first health above zero after that respawns it, and the
15017
+ * next frame places it.
15018
+ */
15019
+ setHealth(entity, health) {
15020
+ if (health === void 0) return;
15021
+ if (health <= 0) {
15022
+ if (!this.dead) this.dead = this.player.kill();
15023
+ return;
15024
+ }
15025
+ if (this.dead) {
15026
+ this.dead = !this.player.respawn();
15027
+ this.drawn = false;
15028
+ return;
15029
+ }
15030
+ const rounded = Math.round(health);
15031
+ if (rounded !== this.lastHealth) {
15032
+ writeField(entity, "CBaseEntity", "m_iHealth", "int32", rounded);
15033
+ this.lastHealth = rounded;
15034
+ }
15035
+ }
15036
+ };
15037
+
15038
+ // js/src/restore.ts
15039
+ var waiting = /* @__PURE__ */ new Map();
15040
+ function restoreHero(player, snapshot, done) {
15041
+ const target = {
15042
+ position: snapshot.position,
15043
+ facing: snapshot.facing,
15044
+ health: snapshot.health,
15045
+ maxHealth: snapshot.maxHealth,
15046
+ level: snapshot.level,
15047
+ upgradeBonuses: snapshot.upgradeBonuses,
15048
+ abilities: snapshot.abilities,
15049
+ items: snapshot.items,
15050
+ replaceItems: snapshot.items !== void 0,
15051
+ timers: snapshot.timers
15052
+ };
15053
+ if (snapshot.souls !== void 0) player.startingSouls(snapshot.souls);
15054
+ waiting.set(player.slot, { souls: snapshot.souls, done });
15055
+ if (player.restoreHero(target)) return true;
15056
+ waiting.delete(player.slot);
15057
+ return false;
15058
+ }
15059
+ function settleRestore(player, error) {
15060
+ const restore = waiting.get(player.slot);
15061
+ if (!restore) return;
15062
+ waiting.delete(player.slot);
15063
+ const held = player.pawn()?.souls;
15064
+ if (restore.souls !== void 0 && held !== void 0 && held !== restore.souls) {
15065
+ player.adjustSouls(restore.souls - held, true);
15066
+ }
15067
+ restore.done?.(error);
15068
+ }
15069
+
15070
+ // js/src/timer.ts
15071
+ var Entry = class {
15072
+ /**
15073
+ * run is the entry's callback. It returns the delay in seconds before its
15074
+ * next run, or undefined when it has run for the last time.
15075
+ */
15076
+ constructor(delay, run) {
15077
+ this.delay = delay;
15078
+ this.run = run;
15079
+ this.at = now === void 0 ? void 0 : now + delay;
15080
+ }
15081
+ delay;
15082
+ run;
15083
+ finished = false;
15084
+ /** at is the game time the entry next runs, unset until the clock is known. */
15085
+ at;
15086
+ /** start counts the first delay from the frame at seconds, once. */
15087
+ start(seconds) {
15088
+ this.at ??= seconds + this.delay;
15089
+ }
15090
+ cancel() {
15091
+ this.finished = true;
15092
+ }
15093
+ };
15094
+ var now;
15095
+ var entries = [];
15096
+ function after(seconds, fn) {
15097
+ return schedule(seconds, () => {
15098
+ fn();
14895
15099
  return void 0;
15100
+ });
15101
+ }
15102
+ function every(seconds, fn) {
15103
+ return schedule(seconds, () => {
15104
+ fn();
15105
+ return seconds;
15106
+ });
15107
+ }
15108
+ function sequence(fn) {
15109
+ let run = 0;
15110
+ return schedule(0, () => fn(++run) ?? void 0);
15111
+ }
15112
+ function schedule(delay, run) {
15113
+ const entry = new Entry(delay, run);
15114
+ entries.push(entry);
15115
+ return entry;
15116
+ }
15117
+ function advance(seconds) {
15118
+ if (now !== void 0 && seconds < now) {
15119
+ const shift = seconds - now;
15120
+ for (const entry of entries) {
15121
+ if (entry.at !== void 0) {
15122
+ entry.at += shift;
15123
+ }
15124
+ }
15125
+ }
15126
+ now = seconds;
15127
+ for (const entry of entries) {
15128
+ entry.start(seconds);
15129
+ }
15130
+ const due = entries.filter((entry) => !entry.finished && entry.at <= seconds).sort((a, b) => a.at - b.at);
15131
+ for (const entry of due) {
15132
+ if (entry.finished) {
15133
+ continue;
15134
+ }
15135
+ try {
15136
+ const wait = entry.run();
15137
+ if (wait === void 0) {
15138
+ entry.finished = true;
15139
+ } else {
15140
+ const next = entry.at + wait;
15141
+ entry.at = next > seconds ? next : seconds + wait;
15142
+ }
15143
+ } catch (error) {
15144
+ entry.finished = true;
15145
+ log(`timer failed: ${String(error)}`);
15146
+ }
15147
+ }
15148
+ entries = entries.filter((entry) => !entry.finished);
15149
+ }
15150
+
15151
+ // js/src/item-id.ts
15152
+ function itemId(name) {
15153
+ const m = 1540483477;
15154
+ const data = new TextEncoder().encode(name);
15155
+ const byte = (at3) => data[at3] ?? 0;
15156
+ let h = (826366246 ^ data.length) >>> 0;
15157
+ let i = 0;
15158
+ for (; data.length - i >= 4; i += 4) {
15159
+ let k = (byte(i) | byte(i + 1) << 8 | byte(i + 2) << 16 | byte(i + 3) << 24) >>> 0;
15160
+ k = Math.imul(k, m) >>> 0;
15161
+ k = (k ^ k >>> 24) >>> 0;
15162
+ k = Math.imul(k, m) >>> 0;
15163
+ h = Math.imul(h, m) >>> 0;
15164
+ h = (h ^ k) >>> 0;
15165
+ }
15166
+ const rest = data.length - i;
15167
+ if (rest >= 3) h = (h ^ byte(i + 2) << 16) >>> 0;
15168
+ if (rest >= 2) h = (h ^ byte(i + 1) << 8) >>> 0;
15169
+ if (rest >= 1) {
15170
+ h = (h ^ byte(i)) >>> 0;
15171
+ h = Math.imul(h, m) >>> 0;
14896
15172
  }
14897
- const plain = (entry) => entry.title.toLowerCase().replace(/[^a-z0-9]/g, "");
14898
- return list.find((entry) => entry.name === key || plain(entry) === key) ?? list.find((entry) => plain(entry).startsWith(key)) ?? list.find((entry) => plain(entry).includes(key));
15173
+ h = (h ^ h >>> 13) >>> 0;
15174
+ h = Math.imul(h, m) >>> 0;
15175
+ return (h ^ h >>> 15) >>> 0;
14899
15176
  }
14900
15177
 
14901
15178
  // js/src/ui.ts
@@ -16822,171 +17099,6 @@ function Meter(props) {
16822
17099
  );
16823
17100
  }
16824
17101
 
16825
- // js/src/cast.ts
16826
- var changeSeconds = 3;
16827
- var noWant = {};
16828
- var Cast = class {
16829
- constructor(options) {
16830
- this.options = options;
16831
- watchPlayers((players2) => {
16832
- this.reported = players2;
16833
- });
16834
- }
16835
- options;
16836
- seats = /* @__PURE__ */ new Map();
16837
- /** kicked holds the connection generation each kicked bot's slot had. */
16838
- kicked = /* @__PURE__ */ new Map();
16839
- /** reported is the player list the host reported since the last frame. */
16840
- reported;
16841
- /** size is the number of members. */
16842
- get size() {
16843
- return this.seats.size;
16844
- }
16845
- /** members lists the members in the order they joined. */
16846
- members() {
16847
- return Array.from(this.seats.values(), (seat) => seat.member);
16848
- }
16849
- /** get returns the member in player's slot, if any. */
16850
- get(player) {
16851
- return this.seats.get(player.slot)?.member;
16852
- }
16853
- /** pawn returns the member's hero as Cast read it this frame. */
16854
- pawn(player) {
16855
- return this.seats.get(player.slot)?.pawn;
16856
- }
16857
- /**
16858
- * frame settles the joins and leaves reported since the last frame, reads
16859
- * each member's hero, and asks the game once a second for any want it does
16860
- * not show yet. seconds is the game clock.
16861
- */
16862
- frame(seconds) {
16863
- if (this.reported !== void 0) {
16864
- this.settle(this.reported, seconds);
16865
- this.reported = void 0;
16866
- }
16867
- for (const seat of this.seats.values()) {
16868
- this.reconcile(seat, seconds);
16869
- }
16870
- }
16871
- /**
16872
- * settle ends the members whose connection left and makes the new ones,
16873
- * joined at now.
16874
- */
16875
- settle(players2, now4) {
16876
- const present = new Map(players2.map((c) => [c.player.slot, c]));
16877
- for (const [slot, seat] of this.seats) {
16878
- if (present.get(slot)?.generation !== seat.connection.generation) {
16879
- this.seats.delete(slot);
16880
- this.options.leave?.(seat.member, seat.connection);
16881
- }
16882
- }
16883
- const { bots = "skip" } = this.options;
16884
- for (const connection of players2) {
16885
- const slot = connection.player.slot;
16886
- if (!connection.ready || this.seats.has(slot)) continue;
16887
- if (connection.bot && bots !== "join") {
16888
- if (bots === "kick") this.kick(connection);
16889
- continue;
16890
- }
16891
- this.seats.set(slot, {
16892
- connection,
16893
- member: this.options.join(connection),
16894
- pawn: void 0,
16895
- alive: false,
16896
- fellAt: -Infinity,
16897
- hero: 0,
16898
- heroLostAt: -Infinity,
16899
- joinedAt: now4,
16900
- askedAt: -Infinity
16901
- });
16902
- }
16903
- }
16904
- /** kick asks the server to remove a bot, once per connection. */
16905
- kick(connection) {
16906
- const slot = connection.player.slot;
16907
- if (this.kicked.get(slot) === connection.generation) return;
16908
- this.kicked.set(slot, connection.generation);
16909
- serverCommand(`kick "${connection.name}"`);
16910
- }
16911
- /** reconcile reads a member's hero and asks for the part of the want it lacks. */
16912
- reconcile(seat, now4) {
16913
- const pawn = seat.connection.player.pawn();
16914
- const alive = pawn !== void 0 && pawn.hero !== 0 && pawn.health > 0;
16915
- if (seat.alive && !alive) seat.fellAt = now4;
16916
- seat.pawn = pawn;
16917
- seat.alive = alive;
16918
- const had = pawn?.hero ?? 0;
16919
- if (had === 0 && seat.hero !== 0) seat.heroLostAt = now4;
16920
- seat.hero = had;
16921
- const changing = had === 0 && now4 - seat.heroLostAt < changeSeconds;
16922
- if (now4 - seat.askedAt < 1 || changing) return;
16923
- const want = this.wantOf(seat);
16924
- const { respawn } = want;
16925
- const hero = want.hero ?? this.stranded(seat, now4);
16926
- if (hero !== void 0 && !this.seated(seat, want, hero)) {
16927
- seat.askedAt = now4;
16928
- this.seat(seat, want, hero);
16929
- } else if (respawn !== void 0 && pawn !== void 0 && pawn.hero !== 0 && !alive && now4 - seat.fellAt >= respawn) {
16930
- seat.askedAt = now4;
16931
- seat.connection.player.respawn();
16932
- }
16933
- }
16934
- /**
16935
- * stranded returns 'any' for a human whose hero is free when the game has
16936
- * left them on a team without one for changeSeconds since they joined, and
16937
- * otherwise leaves the hero free. Such a pawn never gets a hero on its own,
16938
- * while a player still choosing one has no pawn and a spectator stands on
16939
- * team 1. A bot is left to the game, which seats it.
16940
- */
16941
- stranded(seat, now4) {
16942
- const { pawn } = seat;
16943
- const team = pawn?.team;
16944
- const heroless = pawn?.hero === 0 && (team === 2 || team === 3);
16945
- return heroless && !seat.connection.bot && now4 - seat.joinedAt >= changeSeconds ? "any" : void 0;
16946
- }
16947
- /** wantOf is what the member in seat wants now. */
16948
- wantOf(seat) {
16949
- const { want = noWant } = this.options;
16950
- return typeof want === "function" ? want(seat.member) : want;
16951
- }
16952
- /** seated reports whether the member's hero shows the hero and team they want. */
16953
- seated(seat, want, hero) {
16954
- const { pawn } = seat;
16955
- if (pawn === void 0 || pawn.hero === 0) return false;
16956
- if (want.team !== void 0 && pawn.team !== want.team) return false;
16957
- if (hero === "any") return true;
16958
- const id = typeof hero === "number" ? hero : heroes.find((known2) => known2.name === hero)?.id;
16959
- return id === void 0 || pawn.hero === id;
16960
- }
16961
- /** seat asks the game to put the member on hero and their team. */
16962
- seat(seat, want, hero) {
16963
- const { pawn } = seat;
16964
- let pick = hero;
16965
- if (hero === "any") {
16966
- pick = pawn !== void 0 && pawn.hero !== 0 ? pawn.hero : heroes[Math.floor(Math.random() * heroes.length)]?.name;
16967
- }
16968
- if (pick !== void 0) {
16969
- seat.connection.player.selectHero(pick, want.team ?? this.side(seat));
16970
- }
16971
- }
16972
- /** side is the team a member joins: their hero's, or the one with fewer heroes. */
16973
- side(seat) {
16974
- const { pawn } = seat;
16975
- if (pawn !== void 0 && pawn.hero !== 0 && (pawn.team === 2 || pawn.team === 3)) {
16976
- return pawn.team;
16977
- }
16978
- let amber = 0;
16979
- let sapphire = 0;
16980
- for (const other of this.seats.values()) {
16981
- if (other === seat || other.pawn === void 0 || other.pawn.hero === 0)
16982
- continue;
16983
- if (other.pawn.team === 2) amber++;
16984
- if (other.pawn.team === 3) sapphire++;
16985
- }
16986
- return sapphire < amber ? 3 : 2;
16987
- }
16988
- };
16989
-
16990
17102
  // js/src/frameclock.ts
16991
17103
  var now3 = () => performance.now();
16992
17104
  var reportTicks = 3840n;
@@ -17897,16 +18009,16 @@ var Dropper = class {
17897
18009
  this.stop(player);
17898
18010
  return;
17899
18011
  }
17900
- const connection = players().find(
17901
- (connection2) => connection2.player.slot === player.slot
18012
+ const connection2 = players().find(
18013
+ (connection3) => connection3.player.slot === player.slot
17902
18014
  );
17903
- if (!connection || this.catalog.length === 0) {
18015
+ if (!connection2 || this.catalog.length === 0) {
17904
18016
  return;
17905
18017
  }
17906
18018
  const yaw = player.pawn()?.eyeAngles.yaw ?? 0;
17907
18019
  this.builders.set(player.slot, {
17908
18020
  player,
17909
- steamId: connection.steamId,
18021
+ steamId: connection2.steamId,
17910
18022
  entry: 0,
17911
18023
  yaw: Math.round(yaw / turnDegrees) * turnDegrees,
17912
18024
  drops: []
@@ -17943,7 +18055,7 @@ var Dropper = class {
17943
18055
  * left, and launches heroes standing on bouncing objects.
17944
18056
  */
17945
18057
  frame(movement) {
17946
- const live2 = new Set(players().map((connection) => connection.player.slot));
18058
+ const live2 = new Set(players().map((connection2) => connection2.player.slot));
17947
18059
  for (const builder of this.builders.values()) {
17948
18060
  if (live2.has(builder.player.slot)) {
17949
18061
  this.aim(builder);
@@ -18754,6 +18866,48 @@ function onPlayerJoin(handler) {
18754
18866
  function onPlayerLeave(handler) {
18755
18867
  leaves.push(handler);
18756
18868
  }
18869
+ function onSpawn(handler) {
18870
+ spawns.push(handler);
18871
+ }
18872
+ var spawned = /* @__PURE__ */ new Map();
18873
+ function seatPlayers(seating = {}) {
18874
+ const { team, respawn } = seating;
18875
+ const hero = seating.hero ?? "any";
18876
+ const wants = /* @__PURE__ */ new Map();
18877
+ const cast = new Cast({
18878
+ join(connection2) {
18879
+ const side = typeof team === "function" ? team(connection2) : team;
18880
+ wants.set(connection2, {
18881
+ hero,
18882
+ ...side === void 0 ? {} : { team: side },
18883
+ ...respawn === void 0 ? {} : { respawn }
18884
+ });
18885
+ return connection2;
18886
+ },
18887
+ leave(connection2) {
18888
+ wants.delete(connection2);
18889
+ },
18890
+ want: (connection2) => wants.get(connection2) ?? {}
18891
+ });
18892
+ onFrame(({ timeSeconds }) => cast.frame(timeSeconds));
18893
+ return cast;
18894
+ }
18895
+ function watchSpawns() {
18896
+ const present = /* @__PURE__ */ new Map();
18897
+ for (const { player } of players()) {
18898
+ const pawn = player.pawn();
18899
+ if (pawn === void 0 || pawn.hero === 0 || pawn.health <= 0) {
18900
+ continue;
18901
+ }
18902
+ present.set(player.slot, pawn.entity);
18903
+ if (spawned.get(player.slot) !== pawn.entity) {
18904
+ for (const handler of spawns) {
18905
+ handler(player, pawn);
18906
+ }
18907
+ }
18908
+ }
18909
+ spawned = present;
18910
+ }
18757
18911
  function onFrame(handler) {
18758
18912
  frames.push(handler);
18759
18913
  }
@@ -18802,6 +18956,7 @@ var frames = [];
18802
18956
  var chats = [];
18803
18957
  var joins = [];
18804
18958
  var leaves = [];
18959
+ var spawns = [];
18805
18960
  var worlds = [];
18806
18961
  var inputs = [];
18807
18962
  var restoreds = [];
@@ -18829,6 +18984,9 @@ var handlers = {
18829
18984
  tick(event.timeSeconds);
18830
18985
  advance(event.timeSeconds);
18831
18986
  advancePuppets(event.timeSeconds);
18987
+ if (spawns.length !== 0) {
18988
+ watchSpawns();
18989
+ }
18832
18990
  for (const handler of frames) {
18833
18991
  handler(event);
18834
18992
  }
@@ -18989,6 +19147,7 @@ export {
18989
19147
  cameraShake,
18990
19148
  clearMap,
18991
19149
  command,
19150
+ connection,
18992
19151
  createEntity,
18993
19152
  createFog,
18994
19153
  createModel,
@@ -19016,14 +19175,17 @@ export {
19016
19175
  frameClock,
19017
19176
  freeCursor,
19018
19177
  ghostStates,
19178
+ giveEntityModifier,
19019
19179
  ground,
19020
19180
  handedOff,
19021
19181
  handoff,
19022
19182
  heroBuild,
19183
+ heroNamed,
19023
19184
  heroes,
19024
19185
  hide,
19025
19186
  hideHud,
19026
19187
  holdBystander,
19188
+ holdEntityModifier,
19027
19189
  holdMatchClock,
19028
19190
  holdModifierState,
19029
19191
  holdReload,
@@ -19056,6 +19218,7 @@ export {
19056
19218
  onPlayerLeave,
19057
19219
  onRestored,
19058
19220
  onSettingChanged,
19221
+ onSpawn,
19059
19222
  onStart,
19060
19223
  onWorld,
19061
19224
  pause,
@@ -19084,6 +19247,7 @@ export {
19084
19247
  rosterKey,
19085
19248
  rosterRows,
19086
19249
  route,
19250
+ seatPlayers,
19087
19251
  sequence,
19088
19252
  serve,
19089
19253
  serveMod,