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