@modlock/modlock 0.1.78 → 0.1.80

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
@@ -3933,6 +3933,133 @@ var ActiveResponse = /* @__PURE__ */ createMessageType(
3933
3933
  }
3934
3934
  }
3935
3935
  );
3936
+ var ModifiersResponse = /* @__PURE__ */ createMessageType(
3937
+ "modlock.wasm.abilities.ModifiersResponse",
3938
+ () => [[1, "modifiers", 11, 1, Modifier.codec]],
3939
+ {
3940
+ decode: (r, end, m) => {
3941
+ while (r.pos < end) {
3942
+ const t = r.tag();
3943
+ if ((t & 7) === 4) return m;
3944
+ switch (t >>> 3) {
3945
+ case 1:
3946
+ ;
3947
+ (m.modifiers ??= []).push(Modifier.decode(r, r.delimited(), {}));
3948
+ break;
3949
+ default:
3950
+ r.skip(t);
3951
+ }
3952
+ }
3953
+ return m;
3954
+ },
3955
+ encode: (m, w) => {
3956
+ {
3957
+ const a = m.modifiers;
3958
+ if (a != null) for (const e of a) Modifier.writeField(w, 1, e);
3959
+ }
3960
+ }
3961
+ }
3962
+ );
3963
+ var Modifier = /* @__PURE__ */ createMessageType(
3964
+ "modlock.wasm.abilities.Modifier",
3965
+ () => [
3966
+ [1, "name", 9],
3967
+ [2, "class_name", 9],
3968
+ [3, "caster", 13],
3969
+ [4, "ability", 13],
3970
+ [5, "age", 2],
3971
+ [6, "remaining", 2, 4],
3972
+ [7, "stacks", 5],
3973
+ [8, "max_stacks", 5],
3974
+ [9, "team", 13],
3975
+ [10, "disabled", 8]
3976
+ ],
3977
+ {
3978
+ decode: (r, end, m) => {
3979
+ while (r.pos < end) {
3980
+ const t = r.tag();
3981
+ if ((t & 7) === 4) return m;
3982
+ switch (t >>> 3) {
3983
+ case 1:
3984
+ m.name = r.string();
3985
+ break;
3986
+ case 2:
3987
+ m.className = r.string();
3988
+ break;
3989
+ case 3:
3990
+ m.caster = r.uint32();
3991
+ break;
3992
+ case 4:
3993
+ m.ability = r.uint32();
3994
+ break;
3995
+ case 5:
3996
+ m.age = r.float();
3997
+ break;
3998
+ case 6:
3999
+ m.remaining = r.float();
4000
+ break;
4001
+ case 7:
4002
+ m.stacks = r.int32();
4003
+ break;
4004
+ case 8:
4005
+ m.maxStacks = r.int32();
4006
+ break;
4007
+ case 9:
4008
+ m.team = r.uint32();
4009
+ break;
4010
+ case 10:
4011
+ m.disabled = r.bool();
4012
+ break;
4013
+ default:
4014
+ r.skip(t);
4015
+ }
4016
+ }
4017
+ return m;
4018
+ },
4019
+ encode: (m, w) => {
4020
+ {
4021
+ const v = m.name;
4022
+ if (v) w.uint32(10).string(v);
4023
+ }
4024
+ {
4025
+ const v = m.className;
4026
+ if (v) w.uint32(18).string(v);
4027
+ }
4028
+ {
4029
+ const v = m.caster;
4030
+ if (v) w.uint32(24).uint32(v);
4031
+ }
4032
+ {
4033
+ const v = m.ability;
4034
+ if (v) w.uint32(32).uint32(v);
4035
+ }
4036
+ {
4037
+ const v = m.age;
4038
+ if (v != null && v !== 0) w.uint32(45).float(v);
4039
+ }
4040
+ {
4041
+ const v = m.remaining;
4042
+ if (v != null) w.uint32(53).float(v);
4043
+ }
4044
+ {
4045
+ const v = m.stacks;
4046
+ if (v) w.uint32(56).int32(v);
4047
+ }
4048
+ {
4049
+ const v = m.maxStacks;
4050
+ if (v) w.uint32(64).int32(v);
4051
+ }
4052
+ {
4053
+ const v = m.team;
4054
+ if (v) w.uint32(72).uint32(v);
4055
+ }
4056
+ {
4057
+ const v = m.disabled;
4058
+ if (v) w.uint32(80).bool(v);
4059
+ }
4060
+ }
4061
+ }
4062
+ );
3936
4063
  var HoldModifierStateRequest = /* @__PURE__ */ createMessageType(
3937
4064
  "modlock.wasm.abilities.HoldModifierStateRequest",
3938
4065
  () => [
@@ -12591,2128 +12718,6 @@ var UiRequest = /* @__PURE__ */ createMessageType(
12591
12718
  }
12592
12719
  );
12593
12720
 
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
12721
  // js/src/heroes.ts
14717
12722
  var heroes = [
14718
12723
  {
@@ -14979,17 +12984,2342 @@ var heroes = [
14979
12984
  title: "Yamato",
14980
12985
  portrait: "file://{images}/heroes/yamato_sm.psd"
14981
12986
  }
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 === "") {
12987
+ ];
12988
+ var heroesByName = new Map([
12989
+ ...heroes.map((hero) => [plain(hero.title), hero]),
12990
+ ...heroes.map((hero) => [hero.name.replace(/^hero_/, ""), hero]),
12991
+ ...heroes.map((hero) => [hero.name, hero])
12992
+ ]);
12993
+ function heroNamed(name) {
12994
+ return heroesByName.get(plain(name));
12995
+ }
12996
+ function plain(text2) {
12997
+ return text2.toLowerCase().replace(/[^a-z0-9_]/g, "");
12998
+ }
12999
+ function findHero(typed) {
13000
+ return findTitled(heroes, typed);
13001
+ }
13002
+ function findTitled(list, typed) {
13003
+ const key = plain(typed);
13004
+ if (key === "") {
13005
+ return void 0;
13006
+ }
13007
+ const title = (entry) => entry.title.toLowerCase().replace(/[^a-z0-9]/g, "");
13008
+ return list.find((entry) => entry.name === key || title(entry) === key) ?? list.find((entry) => title(entry).startsWith(key)) ?? list.find((entry) => title(entry).includes(key));
13009
+ }
13010
+
13011
+ // js/src/host.gen.ts
13012
+ function vector(value) {
13013
+ return { x: value?.x ?? 0, y: value?.y ?? 0, z: value?.z ?? 0 };
13014
+ }
13015
+ function int32(value) {
13016
+ return Math.trunc(Math.min(Math.max(value, -2147483648), 2147483647));
13017
+ }
13018
+ function heroName(name) {
13019
+ return heroNamed(name)?.name ?? name;
13020
+ }
13021
+ function angles(value) {
13022
+ return { pitch: value?.pitch ?? 0, yaw: value?.yaw ?? 0, roll: value?.roll ?? 0 };
13023
+ }
13024
+ function known(values, decode) {
13025
+ const out = [];
13026
+ for (const v of values ?? []) {
13027
+ const decoded = decode(v);
13028
+ if (decoded !== void 0) {
13029
+ out.push(decoded);
13030
+ }
13031
+ }
13032
+ return out;
13033
+ }
13034
+ function reply(response) {
13035
+ return Reply.toBinary({ response });
13036
+ }
13037
+ var screenEffectValues = {
13038
+ killed: 0,
13039
+ black: 1,
13040
+ blinded: 2,
13041
+ darkness: 3,
13042
+ matchIntro: 4
13043
+ };
13044
+ var fieldTypeValues = {
13045
+ bool: 1,
13046
+ int8: 2,
13047
+ int16: 3,
13048
+ int32: 4,
13049
+ uint8: 5,
13050
+ uint16: 6,
13051
+ uint32: 7,
13052
+ int64: 8,
13053
+ uint64: 9,
13054
+ float32: 10,
13055
+ float64: 11,
13056
+ vector: 12,
13057
+ handle: 13,
13058
+ string: 14
13059
+ };
13060
+ var pickupKindValues = {
13061
+ urn: 0,
13062
+ movementBuff: 1
13063
+ };
13064
+ var movementActionNames = {
13065
+ 1: "landed",
13066
+ 2: "ziplineAttached",
13067
+ 3: "groundDash",
13068
+ 4: "slide",
13069
+ 5: "bouncePad",
13070
+ 6: "dashJump",
13071
+ 7: "airJump",
13072
+ 8: "wallJump",
13073
+ 9: "airDash",
13074
+ 10: "meleeStarted",
13075
+ 11: "abilityExecuted"
13076
+ };
13077
+ var interactionKindNames = {
13078
+ 1: "pickupCollected",
13079
+ 2: "propBroken"
13080
+ };
13081
+ var laneValues = {
13082
+ none: 0,
13083
+ yellow: 1,
13084
+ green: 3,
13085
+ blue: 4,
13086
+ purple: 6
13087
+ };
13088
+ var textAlignValues = {
13089
+ left: 0,
13090
+ center: 1,
13091
+ right: 2
13092
+ };
13093
+ var textVerticalAlignValues = {
13094
+ bottom: 0,
13095
+ center: 1,
13096
+ top: 2
13097
+ };
13098
+ var disconnectReasonNames = {
13099
+ 1: "shutdown",
13100
+ 2: "disconnectByUser",
13101
+ 3: "disconnectByServer",
13102
+ 4: "lost",
13103
+ 5: "overflow",
13104
+ 6: "steamBanned",
13105
+ 7: "steamInuse",
13106
+ 8: "steamTicket",
13107
+ 9: "steamLogon",
13108
+ 10: "steamAuthcancelled",
13109
+ 11: "steamAuthalreadyused",
13110
+ 12: "steamAuthinvalid",
13111
+ 13: "steamVacbanstate",
13112
+ 14: "steamLoggedInElsewhere",
13113
+ 15: "steamVacCheckTimedout",
13114
+ 16: "steamDropped",
13115
+ 17: "steamOwnership",
13116
+ 18: "serverinfoOverflow",
13117
+ 19: "tickmsgOverflow",
13118
+ 20: "stringtablemsgOverflow",
13119
+ 21: "deltaentmsgOverflow",
13120
+ 22: "tempentmsgOverflow",
13121
+ 23: "soundsmsgOverflow",
13122
+ 24: "snapshotoverflow",
13123
+ 25: "snapshoterror",
13124
+ 26: "reliableoverflow",
13125
+ 27: "baddeltatick",
13126
+ 28: "nomoresplits",
13127
+ 29: "timedout",
13128
+ 30: "disconnected",
13129
+ 31: "leavingsplit",
13130
+ 32: "differentclasstables",
13131
+ 33: "badrelaypassword",
13132
+ 34: "badspectatorpassword",
13133
+ 35: "hltvrestricted",
13134
+ 36: "nospectators",
13135
+ 37: "hltvunavailable",
13136
+ 38: "hltvstop",
13137
+ 39: "kicked",
13138
+ 40: "banadded",
13139
+ 41: "kickbanadded",
13140
+ 42: "hltvdirect",
13141
+ 43: "pureserverClientextra",
13142
+ 44: "pureserverMismatch",
13143
+ 45: "usercmd",
13144
+ 46: "rejectedByGame",
13145
+ 47: "messageParseError",
13146
+ 48: "invalidMessageError",
13147
+ 49: "badServerPassword",
13148
+ 50: "directConnectReservation",
13149
+ 51: "connectionFailure",
13150
+ 52: "noPeerGroupHandlers",
13151
+ 53: "reconnection",
13152
+ 54: "loopshutdown",
13153
+ 55: "loopdeactivate",
13154
+ 56: "hostEndgame",
13155
+ 57: "loopLevelloadActivate",
13156
+ 58: "createServerFailed",
13157
+ 59: "exiting",
13158
+ 60: "requestHoststateIdle",
13159
+ 61: "requestHoststateHltvrelay",
13160
+ 62: "clientConsistencyFail",
13161
+ 63: "clientUnableToCrcMap",
13162
+ 64: "clientNoMap",
13163
+ 65: "clientDifferentMap",
13164
+ 66: "serverRequiresSteam",
13165
+ 67: "steamDenyMisc",
13166
+ 68: "steamDenyBadAntiCheat",
13167
+ 69: "serverShutdown",
13168
+ 71: "replayIncompatible",
13169
+ 72: "connectRequestTimedout",
13170
+ 73: "serverIncompatible",
13171
+ 74: "localproblemManyrelays",
13172
+ 75: "localproblemHostedserverprimaryrelay",
13173
+ 76: "localproblemNetworkconfig",
13174
+ 77: "localproblemOther",
13175
+ 79: "remoteTimeout",
13176
+ 80: "remoteTimeoutConnecting",
13177
+ 81: "remoteOther",
13178
+ 82: "remoteBadcrypt",
13179
+ 83: "remoteCertnottrusted",
13180
+ 84: "unusual",
13181
+ 85: "internalError",
13182
+ 128: "rejectBadchallenge",
13183
+ 129: "rejectNolobby",
13184
+ 130: "rejectBackgroundMap",
13185
+ 131: "rejectSinglePlayer",
13186
+ 132: "rejectHiddenGame",
13187
+ 133: "rejectLanrestrict",
13188
+ 134: "rejectBadpassword",
13189
+ 135: "rejectServerfull",
13190
+ 136: "rejectInvalidreservation",
13191
+ 137: "rejectFailedchannel",
13192
+ 138: "rejectConnectFromLobby",
13193
+ 139: "rejectReservedForLobby",
13194
+ 140: "rejectInvalidkeylength",
13195
+ 141: "rejectOldprotocol",
13196
+ 142: "rejectNewprotocol",
13197
+ 143: "rejectInvalidconnection",
13198
+ 144: "rejectInvalidcertlen",
13199
+ 145: "rejectInvalidsteamcertlen",
13200
+ 146: "rejectSteam",
13201
+ 147: "rejectServerauthdisabled",
13202
+ 148: "rejectServercdkeyauthinvalid",
13203
+ 149: "rejectBanned",
13204
+ 150: "kickedTeamkilling",
13205
+ 151: "kickedTkStart",
13206
+ 152: "kickedUntrustedaccount",
13207
+ 153: "kickedConvictedaccount",
13208
+ 154: "kickedCompetitivecooldown",
13209
+ 155: "kickedTeamhurting",
13210
+ 156: "kickedHostagekilling",
13211
+ 157: "kickedVotedoff",
13212
+ 158: "kickedIdle",
13213
+ 159: "kickedSuicide",
13214
+ 160: "kickedNosteamlogin",
13215
+ 161: "kickedNosteamticket",
13216
+ 162: "kickedInputautomation",
13217
+ 163: "kickedVacnetabnormalbehavior",
13218
+ 164: "kickedInsecureclient"
13219
+ };
13220
+ var modRoleNames = {
13221
+ 0: "unspecified",
13222
+ 1: "developer",
13223
+ 2: "tester"
13224
+ };
13225
+ var cameraParamValues = {
13226
+ distance: 0,
13227
+ fieldOfView: 1,
13228
+ target: 2,
13229
+ verticalOffset: 3,
13230
+ horizontalOffset: 4
13231
+ };
13232
+ function fromAbility(message) {
13233
+ return {
13234
+ name: message.name ?? "",
13235
+ slot: message.slot ?? 0,
13236
+ entity: message.entity ?? 0,
13237
+ upgrades: message.upgrades ?? 0,
13238
+ charges: message.charges ?? 0,
13239
+ cooldownEnd: message.cooldownEnd ?? 0,
13240
+ id: message.id ?? 0,
13241
+ state: message.state ?? 0,
13242
+ cooldownStart: message.cooldownStart ?? 0,
13243
+ rechargeStart: message.rechargeStart ?? 0,
13244
+ rechargeEnd: message.rechargeEnd ?? 0,
13245
+ imbues: message.imbues ?? []
13246
+ };
13247
+ }
13248
+ function toAbilityOptions(value) {
13249
+ return {
13250
+ ability: value.ability,
13251
+ upgrades: value.upgrades,
13252
+ charges: value.charges === void 0 ? void 0 : int32(value.charges),
13253
+ cooldownEnd: value.cooldownEnd,
13254
+ rechargeEnd: value.rechargeEnd,
13255
+ maxCharges: value.maxCharges === void 0 ? void 0 : int32(value.maxCharges)
13256
+ };
13257
+ }
13258
+ function fromModifier(message) {
13259
+ return {
13260
+ name: message.name ?? "",
13261
+ className: message.className ?? "",
13262
+ caster: message.caster ?? 0,
13263
+ ability: message.ability ?? 0,
13264
+ age: message.age ?? 0,
13265
+ remaining: message.remaining,
13266
+ stacks: message.stacks ?? 0,
13267
+ maxStacks: message.maxStacks ?? 0,
13268
+ team: message.team ?? 0,
13269
+ disabled: message.disabled ?? false
13270
+ };
13271
+ }
13272
+ function fromBuildCategory(message) {
13273
+ return {
13274
+ name: message.name ?? "",
13275
+ description: message.description ?? "",
13276
+ items: (message.items ?? []).map((v) => fromBuildItem(v))
13277
+ };
13278
+ }
13279
+ function fromBuildItem(message) {
13280
+ return {
13281
+ item: message.item ?? "",
13282
+ annotation: message.annotation ?? ""
13283
+ };
13284
+ }
13285
+ function fromDamageEvent(message) {
13286
+ return {
13287
+ victim: message.victim ?? 0,
13288
+ attacker: message.attacker ?? 0,
13289
+ inflictor: message.inflictor ?? 0,
13290
+ ability: message.ability ?? 0,
13291
+ flags: message.flags ?? 0n,
13292
+ hitGroup: message.hitGroup ?? 0,
13293
+ amount: message.amount ?? 0
13294
+ };
13295
+ }
13296
+ function fromDamagedEvent(message) {
13297
+ return {
13298
+ victim: message.victim ?? 0,
13299
+ attacker: message.attacker ?? 0,
13300
+ ability: message.ability ?? 0,
13301
+ healthLost: message.healthLost ?? 0,
13302
+ healthBefore: message.healthBefore ?? 0,
13303
+ dealt: message.dealt ?? 0
13304
+ };
13305
+ }
13306
+ function fromLaunchEvent(message) {
13307
+ return {
13308
+ entity: message.entity ?? 0,
13309
+ name: message.name ?? "",
13310
+ owner: message.owner ?? 0,
13311
+ player: Player.of(message.player ?? 0),
13312
+ position: vector(message.position)
13313
+ };
13314
+ }
13315
+ function fromImpactEvent(message) {
13316
+ return {
13317
+ entity: message.entity ?? 0,
13318
+ name: message.name ?? "",
13319
+ owner: message.owner ?? 0,
13320
+ player: Player.of(message.player ?? 0),
13321
+ start: vector(message.start),
13322
+ end: vector(message.end),
13323
+ position: vector(message.position),
13324
+ hit: message.hit ?? 0
13325
+ };
13326
+ }
13327
+ function toProjectileOptions(value) {
13328
+ return {
13329
+ names: value.names?.slice(),
13330
+ keepMomentum: value.keepMomentum
13331
+ };
13332
+ }
13333
+ function toHitOptions(value) {
13334
+ return {
13335
+ victim: value.victim,
13336
+ attacker: value.attacker,
13337
+ inflictor: value.inflictor,
13338
+ amount: value.amount,
13339
+ hitGroup: value.hitGroup === void 0 ? void 0 : int32(value.hitGroup),
13340
+ ability: value.ability
13341
+ };
13342
+ }
13343
+ function toTraceOptions(value) {
13344
+ return {
13345
+ start: value.start,
13346
+ end: value.end,
13347
+ layers: value.layers,
13348
+ exclude: value.exclude,
13349
+ ignore: value.ignore?.slice()
13350
+ };
13351
+ }
13352
+ function fromTraceHit(message) {
13353
+ return {
13354
+ position: vector(message.position),
13355
+ normal: vector(message.normal),
13356
+ startSolid: message.startSolid ?? false,
13357
+ entity: message.entity ?? 0
13358
+ };
13359
+ }
13360
+ function toSoundOptions(value) {
13361
+ return {
13362
+ volume: value.volume,
13363
+ pitch: value.pitch,
13364
+ listeners: value.listeners?.map((v) => int32(v))
13365
+ };
13366
+ }
13367
+ function toFieldValue(value) {
13368
+ 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 };
13369
+ }
13370
+ function fromFieldValue(message) {
13371
+ const value = message?.value;
13372
+ if (value === void 0 || value.case === void 0) return void 0;
13373
+ switch (value.case) {
13374
+ case "vector":
13375
+ return vector(value.value);
13376
+ }
13377
+ return value.value;
13378
+ }
13379
+ function toFieldWrite(value) {
13380
+ return {
13381
+ className: value.className,
13382
+ field: value.field,
13383
+ type: fieldTypeValues[value.type],
13384
+ value: toFieldValue(value.value)
13385
+ };
13386
+ }
13387
+ function fromEntityClassName(message) {
13388
+ return {
13389
+ className: message.className ?? "",
13390
+ designerName: message.designerName ?? ""
13391
+ };
13392
+ }
13393
+ function fromEntityPlacement(message) {
13394
+ return {
13395
+ position: vector(message.position),
13396
+ facing: angles(message.facing),
13397
+ velocity: message.velocity === void 0 ? void 0 : vector(message.velocity)
13398
+ };
13399
+ }
13400
+ function toEntityOptions(value) {
13401
+ return {
13402
+ designerName: value.designerName,
13403
+ subclass: value.subclass,
13404
+ team: int32(value.team),
13405
+ position: value.position,
13406
+ facing: value.facing,
13407
+ keyValues: value.keyValues?.map((v) => toKeyValue(v)),
13408
+ fields: value.fields?.map((v) => toFieldWrite(v)),
13409
+ transmitAlways: value.transmitAlways
13410
+ };
13411
+ }
13412
+ function toKeyValue(value) {
13413
+ return {
13414
+ key: value.key,
13415
+ value: toEntityValue(value.value)
13416
+ };
13417
+ }
13418
+ function toEntityValue(value) {
13419
+ if ("boolean" in value) return { value: { case: "boolean", value: value.boolean } };
13420
+ if ("integer" in value) return { value: { case: "integer", value: int32(value.integer) } };
13421
+ if ("number" in value) return { value: { case: "number", value: value.number } };
13422
+ if ("text" in value) return { value: { case: "text", value: value.text } };
13423
+ if ("vector" in value) return { value: { case: "vector", value: value.vector } };
13424
+ return { value: { case: "color", value: value.color } };
13425
+ }
13426
+ function fromInputEvent(message) {
13427
+ return {
13428
+ player: Player.of(message.player ?? 0),
13429
+ pressed: message.pressed ?? 0n,
13430
+ released: message.released ?? 0n
13431
+ };
13432
+ }
13433
+ function fromRiftState(message) {
13434
+ return {
13435
+ scoringTeam: message.scoringTeam ?? 0,
13436
+ scoringTime: message.scoringTime ?? 0,
13437
+ cashInStarted: message.cashInStarted ?? 0,
13438
+ giveUpTime: message.giveUpTime ?? 0,
13439
+ nextSpawn: message.nextSpawn ?? 0,
13440
+ spawnWindow: message.spawnWindow ?? 0
13441
+ };
13442
+ }
13443
+ function fromMovementSample(message) {
13444
+ return {
13445
+ player: Player.of(message.player ?? 0),
13446
+ pawn: message.pawn ?? 0,
13447
+ position: vector(message.position),
13448
+ velocity: vector(message.velocity),
13449
+ grounded: message.grounded ?? false,
13450
+ sliding: message.sliding ?? false,
13451
+ mantling: message.mantling ?? false,
13452
+ climbing: message.climbing ?? false,
13453
+ dashing: message.dashing ?? false,
13454
+ jumpAbility: message.jumpAbility ?? 0,
13455
+ wallJumps: message.wallJumps ?? 0,
13456
+ mantleAbility: message.mantleAbility ?? 0,
13457
+ mantleStart: message.mantleStart ?? 0,
13458
+ wallContact: vector(message.wallContact),
13459
+ wallNormal: vector(message.wallNormal),
13460
+ wallJumpNormal: vector(message.wallJumpNormal),
13461
+ wallJumpFacing: message.wallJumpFacing ?? 0,
13462
+ ziplineTime: message.ziplineTime,
13463
+ actions: known(message.actions, (v) => movementActionNames[v]),
13464
+ casts: message.casts ?? [],
13465
+ command: message.command === void 0 ? void 0 : fromMovementCommand(message.command),
13466
+ interactions: (message.interactions ?? []).map((v) => fromInteraction(v))
13467
+ };
13468
+ }
13469
+ function fromInteraction(message) {
13470
+ return {
13471
+ kind: interactionKindNames[message.kind ?? 0],
13472
+ entity: message.entity ?? 0,
13473
+ designerName: message.designerName ?? "",
13474
+ subclassId: message.subclassId ?? 0,
13475
+ origin: vector(message.origin),
13476
+ vacuumStart: message.vacuumStart,
13477
+ inflictor: message.inflictor ?? 0
13478
+ };
13479
+ }
13480
+ function fromMovementCommand(message) {
13481
+ return {
13482
+ held: message.held ?? 0n,
13483
+ changed: message.changed ?? 0n,
13484
+ scroll: message.scroll ?? 0n,
13485
+ forward: message.forward ?? 0,
13486
+ left: message.left ?? 0,
13487
+ up: message.up ?? 0,
13488
+ grounded: message.grounded ?? false
13489
+ };
13490
+ }
13491
+ function fromLandedEvent(message) {
13492
+ return {
13493
+ player: Player.of(message.player ?? 0),
13494
+ on: message.on ?? 0,
13495
+ speed: message.speed ?? 0
13496
+ };
13497
+ }
13498
+ function fromNpcsRestoredEvent(message) {
13499
+ return {
13500
+ error: message.error ?? ""
13501
+ };
13502
+ }
13503
+ function toNpcOptions(value) {
13504
+ return {
13505
+ className: value.className,
13506
+ unit: value.unit,
13507
+ team: int32(value.team),
13508
+ position: value.position,
13509
+ facing: value.facing,
13510
+ health: value.health === void 0 ? void 0 : int32(value.health),
13511
+ maxHealth: value.maxHealth === void 0 ? void 0 : int32(value.maxHealth),
13512
+ lane: value.lane,
13513
+ fields: value.fields?.map((v) => toFieldWrite(v))
13514
+ };
13515
+ }
13516
+ function fromNpcState(message) {
13517
+ return {
13518
+ position: vector(message.position),
13519
+ facing: angles(message.facing),
13520
+ health: message.health ?? 0,
13521
+ maxHealth: message.maxHealth ?? 0,
13522
+ team: message.team ?? 0
13523
+ };
13524
+ }
13525
+ function toNpcTarget(value) {
13526
+ return {
13527
+ className: value.className,
13528
+ id: value.id,
13529
+ team: int32(value.team),
13530
+ position: value.position,
13531
+ facing: value.facing,
13532
+ velocity: value.velocity,
13533
+ health: int32(value.health),
13534
+ maxHealth: int32(value.maxHealth),
13535
+ lane: value.lane
13536
+ };
13537
+ }
13538
+ function toTextOptions(value) {
13539
+ return {
13540
+ text: value.text,
13541
+ position: value.position,
13542
+ facing: value.facing,
13543
+ fontSize: value.fontSize,
13544
+ color: value.color,
13545
+ faceCamera: value.faceCamera,
13546
+ scale: value.scale,
13547
+ align: value.align === void 0 ? void 0 : textAlignValues[value.align],
13548
+ verticalAlign: value.verticalAlign === void 0 ? void 0 : textVerticalAlignValues[value.verticalAlign]
13549
+ };
13550
+ }
13551
+ function toParticleOptions(value) {
13552
+ return {
13553
+ resource: value.resource,
13554
+ position: value.position,
13555
+ facing: value.facing,
13556
+ color: value.color,
13557
+ tintPoint: value.tintPoint === void 0 ? void 0 : int32(value.tintPoint),
13558
+ point: value.point === void 0 ? void 0 : toParticlePoint(value.point),
13559
+ parent: value.parent,
13560
+ anchors: value.anchors?.map((v) => toParticleAnchor(v)),
13561
+ inactive: value.inactive
13562
+ };
13563
+ }
13564
+ function toParticleAnchor(value) {
13565
+ return {
13566
+ index: int32(value.index),
13567
+ entity: value.entity
13568
+ };
13569
+ }
13570
+ function toParticlePoint(value) {
13571
+ return {
13572
+ index: int32(value.index),
13573
+ position: value.position
13574
+ };
13575
+ }
13576
+ function fromRestoredEvent(message) {
13577
+ return {
13578
+ player: Player.of(message.player ?? 0),
13579
+ error: message.error ?? ""
13580
+ };
13581
+ }
13582
+ function fromPlayersChangedEvent(message) {
13583
+ return {
13584
+ players: (message.players ?? []).map((v) => fromConnection(v))
13585
+ };
13586
+ }
13587
+ function fromPlayerJoinedEvent(message) {
13588
+ return {
13589
+ connection: fromConnection(message.connection ?? {})
13590
+ };
13591
+ }
13592
+ function fromPlayerLeftEvent(message) {
13593
+ return {
13594
+ connection: fromConnection(message.connection ?? {}),
13595
+ disconnected: message.disconnected ?? false,
13596
+ reason: message.reason === void 0 ? void 0 : disconnectReasonNames[message.reason]
13597
+ };
13598
+ }
13599
+ function fromConnection(message) {
13600
+ return {
13601
+ player: Player.of(message.player ?? 0),
13602
+ steamId: message.steamId ?? 0n,
13603
+ name: message.name ?? "",
13604
+ bot: message.bot ?? false,
13605
+ ready: message.ready ?? false,
13606
+ generation: message.generation ?? 0,
13607
+ roles: known(message.roles, (v) => modRoleNames[v])
13608
+ };
13609
+ }
13610
+ function fromPawn(message) {
13611
+ return {
13612
+ entity: message.entity ?? 0,
13613
+ hero: message.hero ?? 0,
13614
+ team: message.team ?? 0,
13615
+ health: message.health ?? 0,
13616
+ maxHealth: message.maxHealth ?? 0,
13617
+ position: vector(message.position),
13618
+ eyeAngles: angles(message.eyeAngles),
13619
+ cameraAngles: angles(message.cameraAngles),
13620
+ stamina: message.stamina,
13621
+ maxStamina: message.maxStamina,
13622
+ generation: message.generation ?? 0,
13623
+ souls: message.souls ?? 0,
13624
+ eyePosition: vector(message.eyePosition),
13625
+ velocity: vector(message.velocity),
13626
+ carryingUrn: message.carryingUrn,
13627
+ score: message.score === void 0 ? void 0 : fromScore(message.score),
13628
+ cameraPosition: message.cameraPosition === void 0 ? void 0 : vector(message.cameraPosition),
13629
+ effectiveMaxHealth: message.effectiveMaxHealth,
13630
+ abilityPoints: message.abilityPoints ?? 0,
13631
+ abilityUnlocks: message.abilityUnlocks ?? 0
13632
+ };
13633
+ }
13634
+ function fromScore(message) {
13635
+ return {
13636
+ kills: message.kills ?? 0,
13637
+ deaths: message.deaths ?? 0,
13638
+ assists: message.assists ?? 0,
13639
+ lastHits: message.lastHits ?? 0,
13640
+ denies: message.denies ?? 0,
13641
+ heroDamage: message.heroDamage ?? 0,
13642
+ heroHealing: message.heroHealing ?? 0,
13643
+ netWorth: message.netWorth ?? 0
13644
+ };
13645
+ }
13646
+ function toCameraValue(value) {
13647
+ return { value: typeof value === "number" ? { case: "number", value } : typeof value === "object" ? { case: "position", value } : void 0 };
13648
+ }
13649
+ function toCameraMotion(value) {
13650
+ if ("hold" in value) return { motion: { case: "hold", value: value.hold } };
13651
+ if ("approach" in value) return { motion: { case: "approach", value: toCameraApproach(value.approach) } };
13652
+ if ("spring" in value) return { motion: { case: "spring", value: toCameraSpring(value.spring) } };
13653
+ if ("lerp" in value) return { motion: { case: "lerp", value: toCameraLerp(value.lerp) } };
13654
+ return { motion: { case: "lag", value: value.lag } };
13655
+ }
13656
+ function toCameraApproach(value) {
13657
+ return {
13658
+ value: value.value === void 0 ? void 0 : toCameraValue(value.value),
13659
+ speed: value.speed,
13660
+ defaultSpeed: value.defaultSpeed,
13661
+ acceleration: value.acceleration,
13662
+ minDuration: value.minDuration,
13663
+ chaseDefault: value.chaseDefault
13664
+ };
13665
+ }
13666
+ function toCameraSpring(value) {
13667
+ return {
13668
+ value: value.value === void 0 ? void 0 : toCameraValue(value.value),
13669
+ strength: value.strength,
13670
+ minSpeed: value.minSpeed,
13671
+ maxDuration: value.maxDuration
13672
+ };
13673
+ }
13674
+ function toCameraLerp(value) {
13675
+ return {
13676
+ start: toCameraValue(value.start),
13677
+ end: toCameraValue(value.end),
13678
+ bias: value.bias,
13679
+ gain: value.gain,
13680
+ duration: value.duration
13681
+ };
13682
+ }
13683
+ function toCameraOptions(value) {
13684
+ return {
13685
+ context: value.context,
13686
+ param: cameraParamValues[value.param],
13687
+ motion: toCameraMotion(value.motion),
13688
+ delay: value.delay,
13689
+ relative: value.relative,
13690
+ priority: value.priority,
13691
+ shared: value.shared,
13692
+ target: value.target
13693
+ };
13694
+ }
13695
+ function toHeroTarget(value) {
13696
+ return {
13697
+ position: value.position,
13698
+ facing: value.facing,
13699
+ fresh: value.fresh,
13700
+ level: value.level === void 0 ? void 0 : int32(value.level),
13701
+ health: value.health === void 0 ? void 0 : int32(value.health),
13702
+ maxHealth: value.maxHealth === void 0 ? void 0 : int32(value.maxHealth),
13703
+ upgradeBonuses: value.upgradeBonuses?.slice(),
13704
+ abilities: value.abilities?.map((v) => toEquipmentTarget(v)),
13705
+ items: value.items?.map((v) => toEquipmentTarget(v)),
13706
+ replaceItems: value.replaceItems,
13707
+ timers: value.timers?.map((v) => toTimerTarget(v))
13708
+ };
13709
+ }
13710
+ function toEquipmentTarget(value) {
13711
+ return {
13712
+ id: value.id,
13713
+ slot: value.slot === void 0 ? void 0 : int32(value.slot),
13714
+ state: value.state
13715
+ };
13716
+ }
13717
+ function toTimerTarget(value) {
13718
+ return {
13719
+ id: value.id,
13720
+ charges: int32(value.charges),
13721
+ cooldownStart: value.cooldownStart,
13722
+ cooldownEnd: value.cooldownEnd,
13723
+ rechargeStart: value.rechargeStart,
13724
+ rechargeEnd: value.rechargeEnd
13725
+ };
13726
+ }
13727
+ function toBotOptions(value) {
13728
+ return {
13729
+ name: value.name,
13730
+ team: int32(value.team),
13731
+ 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,
13732
+ position: value.position
13733
+ };
13734
+ }
13735
+ function fromSettingChangedEvent(message) {
13736
+ return {
13737
+ player: Player.of(message.player ?? 0),
13738
+ key: message.key ?? "",
13739
+ value: message.value ?? ""
13740
+ };
13741
+ }
13742
+ function fromWheel(message) {
13743
+ return {
13744
+ delta: message.delta ?? 0,
13745
+ fraction: message.fraction ?? 0
13746
+ };
13747
+ }
13748
+ function fromUiPressEvent(message) {
13749
+ return {
13750
+ player: Player.of(message.player ?? 0),
13751
+ node: message.node ?? ""
13752
+ };
13753
+ }
13754
+ function fromUiInputEvent(message) {
13755
+ return {
13756
+ player: Player.of(message.player ?? 0),
13757
+ node: message.node ?? "",
13758
+ value: message.value?.case === "wheel" ? fromWheel(message.value.value) : message.value?.value
13759
+ };
13760
+ }
13761
+ function fromStartEvent(message) {
13762
+ return {
13763
+ args: message.args ?? [],
13764
+ checkOnly: message.checkOnly ?? false,
13765
+ source: message.source ?? new Uint8Array()
13766
+ };
13767
+ }
13768
+ function fromFrameEvent(message) {
13769
+ return {
13770
+ tick: message.tick ?? 0n,
13771
+ timeSeconds: message.timeSeconds ?? 0,
13772
+ movement: (message.movement ?? []).map((v) => fromMovementSample(v)),
13773
+ interactions: known(message.interactions, (v) => interactionKindNames[v])
13774
+ };
13775
+ }
13776
+ function fromCommandEvent(message) {
13777
+ return {
13778
+ player: Player.of(message.player ?? 0),
13779
+ line: message.line ?? ""
13780
+ };
13781
+ }
13782
+ function fromChatEvent(message) {
13783
+ return {
13784
+ player: Player.of(message.player ?? 0),
13785
+ text: message.text ?? "",
13786
+ all: message.all ?? false,
13787
+ lane: message.lane ?? 0
13788
+ };
13789
+ }
13790
+ function fromWorldEvent(message) {
13791
+ return {
13792
+ map: message.map ?? ""
13793
+ };
13794
+ }
13795
+ function fromServiceCall(message) {
13796
+ return {
13797
+ service: message.service ?? "",
13798
+ method: message.method ?? "",
13799
+ payload: message.payload ?? new Uint8Array()
13800
+ };
13801
+ }
13802
+ function toPrecacheOptions(value) {
13803
+ return {
13804
+ heroes: value.heroes?.map((v) => heroName(v)),
13805
+ resources: value.resources?.slice()
13806
+ };
13807
+ }
13808
+ var playerObjects = /* @__PURE__ */ new Map();
13809
+ var Player = class _Player {
13810
+ /** slot identifies the player on the server. */
13811
+ slot;
13812
+ constructor(slot) {
13813
+ this.slot = slot;
13814
+ }
13815
+ /**
13816
+ * of returns the Player for slot, the same object each time until release
13817
+ * forgets it, so === tells whether two values are the same player.
13818
+ */
13819
+ static of(slot) {
13820
+ let object = playerObjects.get(slot);
13821
+ if (object === void 0) {
13822
+ object = new _Player(slot);
13823
+ playerObjects.set(slot, object);
13824
+ }
13825
+ return object;
13826
+ }
13827
+ /**
13828
+ * release forgets the Player for slot, so the next Player.of makes a new one.
13829
+ */
13830
+ static release(slot) {
13831
+ playerObjects.delete(slot);
13832
+ }
13833
+ /** chat sends a server chat line to the player. */
13834
+ chat(text2) {
13835
+ return call("Chat", ChatRequest.toBinary({ player: this.slot, text: text2 })) !== void 0;
13836
+ }
13837
+ /**
13838
+ * centerText shows text in the middle of the player's screen until it is
13839
+ * replaced. Empty text clears it.
13840
+ */
13841
+ centerText(text2) {
13842
+ return call("CenterText", CenterTextRequest.toBinary({ player: this.slot, text: text2 })) !== void 0;
13843
+ }
13844
+ /** announce shows a game announcement with a title to the player. */
13845
+ announce(title, text2) {
13846
+ return call("Announce", AnnounceRequest.toBinary({ player: this.slot, title, text: text2 })) !== void 0;
13847
+ }
13848
+ /**
13849
+ * pawn returns the player's pawn this frame: the hero, or the game's
13850
+ * placeholder with hero 0 that a player joining on a team holds until a hero
13851
+ * is selected. It returns nothing for a spectator and before the game has
13852
+ * made a pawn. The pawn's entity changes whenever the game replaces it.
13853
+ */
13854
+ pawn() {
13855
+ const reply2 = call("Pawn", PlayerRequest.toBinary({ player: this.slot }));
13856
+ if (reply2 === void 0) return void 0;
13857
+ const response = PawnResponse.fromBinary(reply2);
13858
+ return response.pawn === void 0 ? void 0 : fromPawn(response.pawn);
13859
+ }
13860
+ /**
13861
+ * setting returns the player's value of a setting the manifest
13862
+ * declares: the value they chose, or the setting's default. A bot has the
13863
+ * defaults.
13864
+ */
13865
+ setting(key) {
13866
+ const reply2 = call("PlayerSetting", PlayerSettingRequest.toBinary({ player: this.slot, key }));
13867
+ if (reply2 === void 0) return void 0;
13868
+ const response = SettingResponse.fromBinary(reply2);
13869
+ return response.value ?? "";
13870
+ }
13871
+ /**
13872
+ * setSetting changes the player's value of a setting the manifest
13873
+ * declares. The value follows the player to later games and other mods'
13874
+ * servers of the same mod; a bot keeps the defaults.
13875
+ */
13876
+ setSetting(key, value) {
13877
+ return call("SetPlayerSetting", SetPlayerSettingRequest.toBinary({ player: this.slot, key, value })) !== void 0;
13878
+ }
13879
+ /**
13880
+ * addMetric adds to the player's total of a metric the manifest declares.
13881
+ * The host keeps each player's totals in memory and hands them on once,
13882
+ * when the player leaves or the mod stops; a bot keeps none.
13883
+ */
13884
+ addMetric(name, value, label) {
13885
+ return call("AddMetric", AddMetricRequest.toBinary({ player: this.slot, name, value, label })) !== void 0;
13886
+ }
13887
+ /**
13888
+ * handoff replaces the handoff state for the player, such as the
13889
+ * panels their HUD shows. It lasts only through a reload of the mod in the
13890
+ * same game, in memory, as the game's does, and ends early when the player
13891
+ * leaves; only that player reads it back, and a bot keeps none.
13892
+ */
13893
+ handoff(text2) {
13894
+ return call("PlayerHandoff", HandoffPlayerRequest.toBinary({ player: this.slot, text: text2 })) !== void 0;
13895
+ }
13896
+ /** handedOff returns the player's handoff state, or empty. */
13897
+ handedOff() {
13898
+ const reply2 = call("PlayerHandedOff", PlayerRequest.toBinary({ player: this.slot }));
13899
+ if (reply2 === void 0) return void 0;
13900
+ const response = HandedOffResponse.fromBinary(reply2);
13901
+ return response.text ?? "";
13902
+ }
13903
+ /**
13904
+ * selectHero gives the player a hero on a team, 2 or 3, and returns the
13905
+ * hero's identifier as Pawn.hero reports it. The hero appears on a later
13906
+ * frame. A hero the player picked through the game's Change Hero wins: the
13907
+ * game removes the old hero before it spawns the pick, and a call in that
13908
+ * gap, up to 5 seconds, fails and leaves the pick to land.
13909
+ */
13910
+ selectHero(hero, team) {
13911
+ 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) }));
13912
+ if (reply2 === void 0) return void 0;
13913
+ const response = HeroResponse.fromBinary(reply2);
13914
+ return response.hero ?? 0;
13915
+ }
13916
+ /**
13917
+ * spectate moves the player to the spectators, without a hero. The player
13918
+ * watches until a hero selection seats them again.
13919
+ */
13920
+ spectate() {
13921
+ return call("Spectate", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13922
+ }
13923
+ /**
13924
+ * watch points the player's camera at a hero, through the hero's own view
13925
+ * or chasing it, as the game's spectator camera follows it. A spectator watches through
13926
+ * their spectator camera, once it exists. A player with a hero watches
13927
+ * while the hero stays where it stands, keeping its level, souls and items,
13928
+ * until Unwatch returns them to it.
13929
+ */
13930
+ watch(target, chase) {
13931
+ return call("Watch", WatchRequest.toBinary({ player: this.slot, target, chase })) !== void 0;
13932
+ }
13933
+ /**
13934
+ * freeCamera lets the player fly their camera from a position, with the
13935
+ * movement keys and the mouse, as the game's roaming spectator camera does.
13936
+ * A player with a hero leaves it where it stands, as Watch does, until
13937
+ * Unwatch returns them to it; Watch follows a hero again.
13938
+ */
13939
+ freeCamera(position, facing) {
13940
+ return call("FreeCamera", FreeCameraRequest.toBinary({ player: this.slot, position, facing })) !== void 0;
13941
+ }
13942
+ /**
13943
+ * moveCamera adds one operation to the player's camera, as the game's
13944
+ * abilities pull it back, widen its view or swing it to a point. Operations
13945
+ * run alongside the game's own until they end or ClearCamera removes them.
13946
+ */
13947
+ moveCamera(options) {
13948
+ return call("MoveCamera", CameraOptions.toBinary({ player: this.slot, ...toCameraOptions(options) })) !== void 0;
13949
+ }
13950
+ /**
13951
+ * clearCamera removes a context's camera operations from the player's
13952
+ * camera, or every operation, and the camera returns to its usual place.
13953
+ */
13954
+ clearCamera(context) {
13955
+ return call("ClearCamera", ClearCameraRequest.toBinary({ player: this.slot, context })) !== void 0;
13956
+ }
13957
+ /**
13958
+ * unwatch returns a player watching or flying the free camera from their
13959
+ * hero back to it. Stopping the mod returns every such player.
13960
+ */
13961
+ unwatch() {
13962
+ return call("Unwatch", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13963
+ }
13964
+ /**
13965
+ * respawn revives the player's dead hero. A pawn with hero 0 has no hero to
13966
+ * revive; the call fails until SelectHero gives it one.
13967
+ */
13968
+ respawn() {
13969
+ return call("Respawn", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13970
+ }
13971
+ /**
13972
+ * changeTeam moves the player's hero, living or dead, to team 2 or 3 where
13973
+ * it stands, for a human or a bot alike. The hero keeps its hero,
13974
+ * abilities, items and health, and the player keeps their connection; a
13975
+ * dead hero respawns on its new team, on its timer or through Respawn. A
13976
+ * living hero moved inside the other team's base dies to the base's
13977
+ * defense. A player without a hero joins a team through SelectHero
13978
+ * instead.
13979
+ */
13980
+ changeTeam(team) {
13981
+ return call("ChangeTeam", ChangeTeamRequest.toBinary({ player: this.slot, team: int32(team) })) !== void 0;
13982
+ }
13983
+ /** clearItems removes every item the player's hero owns. */
13984
+ clearItems() {
13985
+ return call("ClearItems", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13986
+ }
13987
+ /**
13988
+ * freeze holds the player's hero in place, without input or damage, until
13989
+ * it is released. Stopping the mod releases it.
13990
+ */
13991
+ freeze(frozen) {
13992
+ return call("Freeze", FreezeRequest.toBinary({ player: this.slot, frozen })) !== void 0;
13993
+ }
13994
+ /** restoreStamina refills the player's stamina. */
13995
+ restoreStamina() {
13996
+ return call("RestoreStamina", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
13997
+ }
13998
+ /**
13999
+ * setStamina sets the player's stamina, as Pawn.stamina reads it. The game
14000
+ * regenerates it as usual afterwards.
14001
+ */
14002
+ setStamina(stamina) {
14003
+ return call("SetStamina", SetStaminaRequest.toBinary({ player: this.slot, stamina })) !== void 0;
14004
+ }
14005
+ /**
14006
+ * refreshAbility ends the cooldown of the hero's ability named ability,
14007
+ * such as citadel_ability_melee_parry.
14008
+ */
14009
+ refreshAbility(ability) {
14010
+ return call("RefreshAbility", RefreshAbilityRequest.toBinary({ player: this.slot, ability })) !== void 0;
14011
+ }
14012
+ /**
14013
+ * abilities lists the abilities of the player's hero in the hero's order,
14014
+ * or none without a live hero.
14015
+ */
14016
+ abilities() {
14017
+ const reply2 = call("Abilities", PlayerRequest.toBinary({ player: this.slot }));
14018
+ if (reply2 === void 0) return [];
14019
+ const response = AbilitiesResponse.fromBinary(reply2);
14020
+ return (response.abilities ?? []).map((v) => fromAbility(v));
14021
+ }
14022
+ /**
14023
+ * setAbility changes the upgrades, charges or timers of one of the hero's
14024
+ * abilities. An omitted option stays as it is.
14025
+ */
14026
+ setAbility(options) {
14027
+ return call("SetAbility", AbilityOptions.toBinary({ player: this.slot, ...toAbilityOptions(options) })) !== void 0;
14028
+ }
14029
+ /**
14030
+ * giveItem gives the hero an item, enabled and free. A hero that owns it
14031
+ * keeps its one copy. With imbue, an imbuing item strengthens the hero's
14032
+ * ability in that slot, 0 to 3, as the shop asks when one is bought; the
14033
+ * call fails, granting nothing, when the ability does not accept it.
14034
+ */
14035
+ giveItem(item2, imbue) {
14036
+ return call("GiveItem", GiveItemRequest.toBinary({ player: this.slot, item: item2, imbue })) !== void 0;
14037
+ }
14038
+ /**
14039
+ * buyItem buys an item for the hero as the shop does, under the shop's own
14040
+ * rules and for the souls it charges, or fails and charges nothing when the
14041
+ * shop refuses, as away from the shop or without the souls. With imbue, an
14042
+ * imbuing item strengthens whatever ability the hero holds in that slot, 0
14043
+ * to 3, including one ReplaceAbility put there, which the game's own
14044
+ * buydependentitem refuses; the call fails, buying nothing, when the
14045
+ * ability does not accept it.
14046
+ */
14047
+ buyItem(item2, imbue, source) {
14048
+ return call("BuyItem", BuyItemRequest.toBinary({ player: this.slot, item: item2, imbue, source })) !== void 0;
14049
+ }
14050
+ /**
14051
+ * trainAbility trains or upgrades whatever ability the hero holds in a
14052
+ * slot, 0 to 3, as the player holding the upgrade key and pressing the
14053
+ * slot's ability key does: an untrained ability trains for an ability
14054
+ * unlock, and a trained one buys its next tier for ability points. It works
14055
+ * on an ability ReplaceAbility put there, which the game's own commands for
14056
+ * a slot do not reach. When the game refuses, as without an unlock or the
14057
+ * points, the call fails and nothing is spent.
14058
+ */
14059
+ trainAbility(slot) {
14060
+ return call("TrainAbility", TrainAbilityRequest.toBinary({ player: this.slot, slot })) !== void 0;
14061
+ }
14062
+ /**
14063
+ * replaceAbility puts the ability named ability, untrained unless keep
14064
+ * carries the old one's progress, in the hero's ability slot index, as
14065
+ * Ability.slot, removing the ability there. The game trains and upgrades an
14066
+ * ability in slots 0 to 3 by its slot, so a player holds the upgrade key and
14067
+ * presses the slot's ability key to spend ability points on it, and training
14068
+ * an untrained one costs an ability unlock. A hero change or ResetHero gives
14069
+ * the hero its own abilities again, so a mod that keeps a swap replaces
14070
+ * again then. An ability from another hero loads its models and particles
14071
+ * only if Precache named that hero and those resources before the world
14072
+ * loaded; otherwise its first effect stalls the game on a blocking load and
14073
+ * the game reports an assertion.
14074
+ */
14075
+ replaceAbility(index, ability, keep) {
14076
+ return call("ReplaceAbility", ReplaceAbilityRequest.toBinary({ player: this.slot, index, ability, keep })) !== void 0;
14077
+ }
14078
+ /**
14079
+ * holdModifier keeps a modifier, named as GiveModifier names it, on the
14080
+ * hero with no expiry, giving it back whenever the game removes it or the
14081
+ * hero returns. Every hero that gains the modifier from the same ability
14082
+ * keeps it until the hold ends. Releasing leaves the hero's current
14083
+ * modifier until it dies.
14084
+ */
14085
+ holdModifier(modifier, active) {
14086
+ return call("HoldModifier", HoldModifierRequest.toBinary({ player: this.slot, modifier, active })) !== void 0;
14087
+ }
14088
+ /**
14089
+ * giveModifier gives the hero a modifier for seconds. An ability's
14090
+ * modifier, named "<ability>/<modifier>", comes as if the hero's own
14091
+ * ability applied it; a hero without that ability, or a modifier named on
14092
+ * its own, such as Street Brawl's zipline boost
14093
+ * modifier_street_brawl_round_start_zipline_boost, applies it with the
14094
+ * hero's first ability. The game may end it sooner, as invisibility ends on
14095
+ * a shot.
14096
+ */
14097
+ giveModifier(modifier, seconds) {
14098
+ return call("GiveModifier", GiveModifierRequest.toBinary({ player: this.slot, modifier, seconds })) !== void 0;
14099
+ }
14100
+ /**
14101
+ * teleport moves the player's hero and turns it and the camera. With a
14102
+ * velocity it also sets the hero's motion, as a launch, and the camera
14103
+ * follows the hero.
14104
+ */
14105
+ teleport(position, facing, velocity) {
14106
+ return call("Teleport", TeleportRequest.toBinary({ player: this.slot, position, facing, velocity })) !== void 0;
14107
+ }
14108
+ /**
14109
+ * zipline puts the player's hero on a lane's zipline near the hero, riding
14110
+ * it as from the zipline key, with the zipline's intro. It never picks
14111
+ * another lane: it fails when the lane has no zipline the hero's team rides
14112
+ * on this map, or the hero has no zipline ability. For Street Brawl's fast
14113
+ * ride, give the hero modifier_street_brawl_round_start_zipline_boost too.
14114
+ */
14115
+ zipline(lane) {
14116
+ return call("Zipline", ZiplineRequest.toBinary({ player: this.slot, lane: laneValues[lane] })) !== void 0;
14117
+ }
14118
+ /**
14119
+ * move carries the player's hero to a position as continuous motion,
14120
+ * as a recording plays back. Unlike Teleport it keeps the hero's animated
14121
+ * model drawn when repeated every tick, and leaves the camera alone.
14122
+ */
14123
+ move(position, facing, velocity) {
14124
+ return call("MovePlayer", MovePlayerRequest.toBinary({ player: this.slot, position, facing, velocity })) !== void 0;
14125
+ }
14126
+ /**
14127
+ * steer replays a recorded movement command on the player's hero, usually a
14128
+ * bot: the game runs the command's buttons and axes, so the hero crouches,
14129
+ * slides, jumps and mantles with its own animation, and the step then ends
14130
+ * on the recorded pose. The steering stays until the next Steer replaces
14131
+ * it, its presses and its pose counting once: on the ticks between, the
14132
+ * game's own movement carries the held command on from the pose. A Steer
14133
+ * without one releases the hero.
14134
+ */
14135
+ steer(steering) {
14136
+ return call("Steer", SteerRequest.toBinary({ player: this.slot, steering })) !== void 0;
14137
+ }
14138
+ /**
14139
+ * drive gives a bot the controls a player has, where it looks, the
14140
+ * movement axes and the buttons, as its input on every tick until the next
14141
+ * Drive replaces it. The game runs that input as a player's own, so the
14142
+ * hero accelerates, turns, jumps, dashes, slides and casts with its own
14143
+ * movement and animation; the bot's own brain no longer moves it. Presses
14144
+ * count once. A Drive without a command returns the bot to its brain.
14145
+ */
14146
+ drive(command2) {
14147
+ return call("Drive", DriveRequest.toBinary({ player: this.slot, command: command2 })) !== void 0;
14148
+ }
14149
+ /**
14150
+ * adjustSouls gives the player delta souls, or takes them when delta is
14151
+ * negative. A spend larger than the player's souls fails and spends
14152
+ * nothing. Silent skips the pickup's sound and number.
14153
+ */
14154
+ adjustSouls(delta, silent) {
14155
+ return call("AdjustSouls", AdjustSoulsRequest.toBinary({ player: this.slot, delta: int32(delta), silent })) !== void 0;
14156
+ }
14157
+ /**
14158
+ * adjustAbilityPoints gives the player ability points and ability unlocks,
14159
+ * or takes them when negative, as Pawn.ability_points and
14160
+ * Pawn.ability_unlocks read them. A spend larger than the player holds
14161
+ * fails and spends nothing.
14162
+ */
14163
+ adjustAbilityPoints(points, unlocks) {
14164
+ return call("AdjustAbilityPoints", AdjustAbilityPointsRequest.toBinary({ player: this.slot, points: int32(points), unlocks: int32(unlocks) })) !== void 0;
14165
+ }
14166
+ /** startingSouls sets the souls the player's hero spawns with. */
14167
+ startingSouls(souls) {
14168
+ return call("StartingSouls", StartingSoulsRequest.toBinary({ player: this.slot, souls: int32(souls) })) !== void 0;
14169
+ }
14170
+ /**
14171
+ * resetHero rebuilds the player's hero as it first spawned, without items,
14172
+ * ability upgrades, levels or ability points, holding souls.
14173
+ */
14174
+ resetHero(souls) {
14175
+ return call("ResetHero", ResetHeroRequest.toBinary({ player: this.slot, souls: int32(souls) })) !== void 0;
14176
+ }
14177
+ /** heal restores health to the player's hero, up to its maximum. */
14178
+ heal(amount) {
14179
+ return call("Heal", HealRequest.toBinary({ player: this.slot, amount: int32(amount) })) !== void 0;
14180
+ }
14181
+ /**
14182
+ * sound plays a game sound event, such as Damage.Send.Crit, on the
14183
+ * player's hero, and returns its ID. It follows the hero as it moves.
14184
+ * Volume and pitch scale the sound, and listeners limit who hears it.
14185
+ */
14186
+ sound(sound, options) {
14187
+ const reply2 = call("Sound", SoundRequest.toBinary({ player: this.slot, sound, options: options === void 0 ? void 0 : toSoundOptions(options) }));
14188
+ if (reply2 === void 0) return void 0;
14189
+ const response = SoundResponse.fromBinary(reply2);
14190
+ return response.id ?? 0;
14191
+ }
14192
+ /**
14193
+ * restoreHero gives the player's live hero target over the next few
14194
+ * seconds: the build first, then health, stamina and pose once it settles,
14195
+ * then charges and cooldowns. A Restored event reports when the result has
14196
+ * held for a second, or why it could not. A new call replaces the running
14197
+ * one. A pawn with hero 0 has no hero to restore; the call fails until
14198
+ * SelectHero gives it one.
14199
+ */
14200
+ restoreHero(target) {
14201
+ return call("RestoreHero", RestoreHeroRequest.toBinary({ player: this.slot, target: toHeroTarget(target) })) !== void 0;
14202
+ }
14203
+ /**
14204
+ * screenEffect plays a full-screen effect on the player's view. Effects of
14205
+ * one kind stack. The player's hero must be alive.
14206
+ */
14207
+ screenEffect(effect, timing) {
14208
+ return call("ScreenEffect", ScreenEffectRequest.toBinary({ player: this.slot, effect: screenEffectValues[effect], timing })) !== void 0;
14209
+ }
14210
+ /**
14211
+ * clearScreenEffect ends every running instance of effect on the player's
14212
+ * view.
14213
+ */
14214
+ clearScreenEffect(effect) {
14215
+ return call("ClearScreenEffect", ClearScreenEffectRequest.toBinary({ player: this.slot, effect: screenEffectValues[effect] })) !== void 0;
14216
+ }
14217
+ /**
14218
+ * silenceVoice keeps the player's hero from speaking the named voice
14219
+ * concepts until called again, on top of those silenced for everyone.
14220
+ */
14221
+ silenceVoice(concepts) {
14222
+ return call("SilencePlayerVoice", SilencePlayerVoiceRequest.toBinary({ player: this.slot, concepts: concepts?.slice() })) !== void 0;
14223
+ }
14224
+ /** removeBot removes a bot the mod added. */
14225
+ removeBot() {
14226
+ return call("RemoveBot", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
14227
+ }
14228
+ /**
14229
+ * blockInput withholds buttons from the player's hero until called
14230
+ * again, on top of the block on everyone. Zero releases the player.
14231
+ */
14232
+ blockInput(buttons) {
14233
+ return call("BlockPlayerInput", PlayerInputRequest.toBinary({ player: this.slot, buttons })) !== void 0;
14234
+ }
14235
+ /**
14236
+ * press presses buttons at the player's next input, even through a block.
14237
+ * A bot presses them as a player would.
14238
+ */
14239
+ press(buttons) {
14240
+ return call("Press", PlayerInputRequest.toBinary({ player: this.slot, buttons })) !== void 0;
14241
+ }
14242
+ /** kill kills a player's hero, crediting no one. */
14243
+ kill() {
14244
+ return call("Kill", PlayerRequest.toBinary({ player: this.slot })) !== void 0;
14245
+ }
14246
+ /** setVelocity replaces the motion of a player's hero without moving it. */
14247
+ setVelocity(velocity) {
14248
+ return call("SetVelocity", SetVelocityRequest.toBinary({ player: this.slot, velocity })) !== void 0;
14249
+ }
14250
+ /**
14251
+ * buttons returns the buttons a player holds, as Buttons bits, while the
14252
+ * player is alive or dead.
14253
+ */
14254
+ buttons() {
14255
+ const reply2 = call("Buttons", PlayerRequest.toBinary({ player: this.slot }));
14256
+ if (reply2 === void 0) return void 0;
14257
+ const response = ButtonsResponse.fromBinary(reply2);
14258
+ return response.buttons ?? 0n;
14259
+ }
14260
+ /**
14261
+ * watchMovement adds a player's hero to the movement samples of each Frame
14262
+ * event on a new tick, or removes it.
14263
+ */
14264
+ watchMovement(watch) {
14265
+ return call("WatchMovement", WatchMovementRequest.toBinary({ player: this.slot, watch })) !== void 0;
14266
+ }
14267
+ };
14268
+ var WorldObject = class {
14269
+ /** id identifies the object among the mod's objects. */
14270
+ id;
14271
+ constructor(id) {
14272
+ this.id = id;
14273
+ }
14274
+ /**
14275
+ * move places the object at position, turning it to facing. The
14276
+ * physics step pulls a solid model to its new place over one tick, so a
14277
+ * model moved each frame strikes physics props such as the Hideout ball
14278
+ * with its speed instead of passing through them.
14279
+ */
14280
+ move(position, facing) {
14281
+ return call("MoveObject", MoveObjectRequest.toBinary({ object: this.id, position, facing })) !== void 0;
14282
+ }
14283
+ /** setText replaces a text object's words. */
14284
+ setText(text2) {
14285
+ return call("SetText", SetTextRequest.toBinary({ object: this.id, text: text2 })) !== void 0;
14286
+ }
14287
+ /**
14288
+ * setHidden hides the object from one player or shows it again.
14289
+ * Other players still see it. A player who leaves sees every object when
14290
+ * they return.
14291
+ */
14292
+ setHidden(player, hidden) {
14293
+ return call("SetObjectHidden", SetObjectHiddenRequest.toBinary({ object: this.id, player: player.slot, hidden })) !== void 0;
14294
+ }
14295
+ /**
14296
+ * showOnlyTo sends the object only to the players with the listed
14297
+ * server slots; every other client drops it, or never receives it when the
14298
+ * call follows its creation in the same frame. With no players no client
14299
+ * receives it. The list replaces any earlier one and follows the object
14300
+ * when its entity changes. A player who leaves is taken off every list, so
14301
+ * whoever joins in their slot does not receive the object. A removed object
14302
+ * reaches no client while the engine retires its entity.
14303
+ */
14304
+ showOnlyTo(players2) {
14305
+ return call("ShowObjectOnlyTo", ShowObjectOnlyToRequest.toBinary({ object: this.id, players: players2?.map((v) => int32(v)) })) !== void 0;
14306
+ }
14307
+ /**
14308
+ * showToAll sends the object to every player again, undoing
14309
+ * ShowObjectOnlyTo.
14310
+ */
14311
+ showToAll() {
14312
+ return call("ShowObjectToAll", ObjectRequest.toBinary({ object: this.id })) !== void 0;
14313
+ }
14314
+ /** remove takes the object out of the world. */
14315
+ remove() {
14316
+ return call("RemoveObject", ObjectRequest.toBinary({ object: this.id })) !== void 0;
14317
+ }
14318
+ /**
14319
+ * entity returns the entity handle of a model or particle, as traces
14320
+ * report it and particle anchors take it.
14321
+ */
14322
+ entity() {
14323
+ const reply2 = call("ObjectEntity", ObjectRequest.toBinary({ object: this.id }));
14324
+ if (reply2 === void 0) return void 0;
14325
+ const response = EntityResponse.fromBinary(reply2);
14326
+ return response.entity ?? 0;
14327
+ }
14328
+ };
14329
+ var Npc = class {
14330
+ /** entity is the unit's entity handle, as damage events report it. */
14331
+ entity;
14332
+ constructor(entity) {
14333
+ this.entity = entity;
14334
+ }
14335
+ /** read returns the unit's state, or nothing once it is gone. */
14336
+ read() {
14337
+ const reply2 = call("ReadNpc", NpcRequest.toBinary({ npc: this.entity }));
14338
+ if (reply2 === void 0) return void 0;
14339
+ const response = NpcStateResponse.fromBinary(reply2);
14340
+ return response.state === void 0 ? void 0 : fromNpcState(response.state);
14341
+ }
14342
+ /**
14343
+ * move places the unit and sets its velocity, which drives its walk
14344
+ * animation. It sets the pose without a teleport, which would reset the
14345
+ * unit's animation, so a mode can steer its units every frame. It reports
14346
+ * false once the unit is gone.
14347
+ */
14348
+ move(position, facing, velocity) {
14349
+ const reply2 = call("MoveNpc", MoveNpcRequest.toBinary({ npc: this.entity, position, facing, velocity }));
14350
+ if (reply2 === void 0) return false;
14351
+ const response = AliveResponse.fromBinary(reply2);
14352
+ return response.alive ?? false;
14353
+ }
14354
+ /**
14355
+ * setHealth sets the unit's health, and its maximum when given. It
14356
+ * reports false once the unit is gone.
14357
+ */
14358
+ setHealth(health, maxHealth) {
14359
+ const reply2 = call("SetNpcHealth", SetNpcHealthRequest.toBinary({ npc: this.entity, health: int32(health), maxHealth: maxHealth === void 0 ? void 0 : int32(maxHealth) }));
14360
+ if (reply2 === void 0) return false;
14361
+ const response = AliveResponse.fromBinary(reply2);
14362
+ return response.alive ?? false;
14363
+ }
14364
+ /**
14365
+ * remove takes a unit the mod spawned out of the world without rewards.
14366
+ * It reports false when the unit was already gone.
14367
+ */
14368
+ remove() {
14369
+ const reply2 = call("RemoveNpc", NpcRequest.toBinary({ npc: this.entity }));
14370
+ if (reply2 === void 0) return false;
14371
+ const response = AliveResponse.fromBinary(reply2);
14372
+ return response.alive ?? false;
14373
+ }
14374
+ };
14375
+ var Pickup = class {
14376
+ /** entity is the pickup's entity handle. */
14377
+ entity;
14378
+ constructor(entity) {
14379
+ this.entity = entity;
14380
+ }
14381
+ /**
14382
+ * present reports whether the pickup still lies in the world,
14383
+ * uncollected.
14384
+ */
14385
+ present() {
14386
+ const reply2 = call("PickupPresent", PickupRequest.toBinary({ pickup: this.entity }));
14387
+ if (reply2 === void 0) return false;
14388
+ const response = AliveResponse.fromBinary(reply2);
14389
+ return response.alive ?? false;
14390
+ }
14391
+ /**
14392
+ * remove takes the pickup out of the world. It reports false when a
14393
+ * player had collected it.
14394
+ */
14395
+ remove() {
14396
+ const reply2 = call("RemovePickup", PickupRequest.toBinary({ pickup: this.entity }));
14397
+ if (reply2 === void 0) return false;
14398
+ const response = AliveResponse.fromBinary(reply2);
14399
+ return response.alive ?? false;
14400
+ }
14401
+ };
14402
+ function log(message) {
14403
+ return call("Log", LogRequest.toBinary({ message })) !== void 0;
14404
+ }
14405
+ function serverCommand(command2) {
14406
+ return call("ServerCommand", ServerCommandRequest.toBinary({ command: command2 })) !== void 0;
14407
+ }
14408
+ function precache(options) {
14409
+ return call("Precache", PrecacheOptions.toBinary(toPrecacheOptions(options))) !== void 0;
14410
+ }
14411
+ function readFile(path) {
14412
+ const reply2 = call("ReadFile", ReadFileRequest.toBinary({ path }));
14413
+ if (reply2 === void 0) return void 0;
14414
+ const response = ReadFileResponse.fromBinary(reply2);
14415
+ return response.text;
14416
+ }
14417
+ function writeFile(path, text2) {
14418
+ return call("WriteFile", WriteFileRequest.toBinary({ path, text: text2 })) !== void 0;
14419
+ }
14420
+ function holdReload(held) {
14421
+ return call("HoldReload", HoldReloadRequest.toBinary({ held })) !== void 0;
14422
+ }
14423
+ function handoff(text2) {
14424
+ return call("Handoff", HandoffRequest.toBinary({ text: text2 })) !== void 0;
14425
+ }
14426
+ function handedOff() {
14427
+ const reply2 = call("HandedOff", new Uint8Array());
14428
+ if (reply2 === void 0) return void 0;
14429
+ const response = HandedOffResponse.fromBinary(reply2);
14430
+ return response.text ?? "";
14431
+ }
14432
+ function heroBuild(hero) {
14433
+ const reply2 = call("HeroBuild", HeroBuildRequest.toBinary({ hero: heroName(hero) }));
14434
+ if (reply2 === void 0) return [];
14435
+ const response = HeroBuildResponse.fromBinary(reply2);
14436
+ return (response.categories ?? []).map((v) => fromBuildCategory(v));
14437
+ }
14438
+ function silenceVoice(concepts) {
14439
+ return call("SilenceVoice", SilenceVoiceRequest.toBinary({ concepts: concepts?.slice() })) !== void 0;
14440
+ }
14441
+ function readField(entity, className, field, type) {
14442
+ const reply2 = call("ReadField", ReadFieldRequest.toBinary({ entity, className, field, type: fieldTypeValues[type] }));
14443
+ if (reply2 === void 0) return void 0;
14444
+ const response = FieldResponse.fromBinary(reply2);
14445
+ return fromFieldValue(response.value);
14446
+ }
14447
+ function readModifierField(entity, modifier, className, field, type) {
14448
+ const reply2 = call("ReadModifierField", ReadModifierFieldRequest.toBinary({ entity, modifier, className, field, type: fieldTypeValues[type] }));
14449
+ if (reply2 === void 0) return void 0;
14450
+ const response = FieldResponse.fromBinary(reply2);
14451
+ return fromFieldValue(response.value);
14452
+ }
14453
+ function writeField(entity, className, field, type, value) {
14454
+ return call("WriteField", WriteFieldRequest.toBinary({ entity, className, field, type: fieldTypeValues[type], value: toFieldValue(value) })) !== void 0;
14455
+ }
14456
+ function readFieldList(entity, className, field, type) {
14457
+ const reply2 = call("ReadFieldList", ReadFieldRequest.toBinary({ entity, className, field, type: fieldTypeValues[type] }));
14458
+ if (reply2 === void 0) return [];
14459
+ const response = FieldListResponse.fromBinary(reply2);
14460
+ return known(response.values, (v) => fromFieldValue(v));
14461
+ }
14462
+ function writeFieldList(entity, className, field, type, values) {
14463
+ return call("WriteFieldList", WriteFieldListRequest.toBinary({ entity, className, field, type: fieldTypeValues[type], values: values?.map((v) => toFieldValue(v)) })) !== void 0;
14464
+ }
14465
+ function entityClass(entity) {
14466
+ const reply2 = call("EntityClass", EntityRequest.toBinary({ entity }));
14467
+ if (reply2 === void 0) return void 0;
14468
+ const response = EntityClassResponse.fromBinary(reply2);
14469
+ return response.name === void 0 ? void 0 : fromEntityClassName(response.name);
14470
+ }
14471
+ function entityName(entity) {
14472
+ const reply2 = call("EntityName", EntityRequest.toBinary({ entity }));
14473
+ if (reply2 === void 0) return void 0;
14474
+ const response = EntityNameResponse.fromBinary(reply2);
14475
+ return response.name ?? "";
14476
+ }
14477
+ function entityPosition(entity) {
14478
+ const reply2 = call("EntityPosition", EntityRequest.toBinary({ entity }));
14479
+ if (reply2 === void 0) return void 0;
14480
+ const response = EntityPositionResponse.fromBinary(reply2);
14481
+ return response.placement === void 0 ? void 0 : fromEntityPlacement(response.placement);
14482
+ }
14483
+ function modifierState(entity, state) {
14484
+ const reply2 = call("ModifierState", ModifierStateRequest.toBinary({ entity, state }));
14485
+ if (reply2 === void 0) return false;
14486
+ const response = ActiveResponse.fromBinary(reply2);
14487
+ return response.active ?? false;
14488
+ }
14489
+ function modifiers(entity) {
14490
+ const reply2 = call("Modifiers", EntityRequest.toBinary({ entity }));
14491
+ if (reply2 === void 0) return [];
14492
+ const response = ModifiersResponse.fromBinary(reply2);
14493
+ return (response.modifiers ?? []).map((v) => fromModifier(v));
14494
+ }
14495
+ function holdModifierState(entity, state, active) {
14496
+ return call("HoldModifierState", HoldModifierStateRequest.toBinary({ entity, state, active })) !== void 0;
14497
+ }
14498
+ function setFreeForAll(enabled) {
14499
+ return call("SetFreeForAll", SetFreeForAllRequest.toBinary({ enabled })) !== void 0;
14500
+ }
14501
+ function setTeamSeating(enabled) {
14502
+ return call("SetTeamSeating", SetTeamSeatingRequest.toBinary({ enabled })) !== void 0;
14503
+ }
14504
+ function createModel(options) {
14505
+ const reply2 = call("CreateModel", ModelOptions.toBinary(options));
14506
+ if (reply2 === void 0) return void 0;
14507
+ const response = ObjectResponse.fromBinary(reply2);
14508
+ return new WorldObject(response.object ?? 0);
14509
+ }
14510
+ function createText(options) {
14511
+ const reply2 = call("CreateText", TextOptions.toBinary(toTextOptions(options)));
14512
+ if (reply2 === void 0) return void 0;
14513
+ const response = ObjectResponse.fromBinary(reply2);
14514
+ return new WorldObject(response.object ?? 0);
14515
+ }
14516
+ function createParticle(options) {
14517
+ const reply2 = call("CreateParticle", ParticleOptions.toBinary(toParticleOptions(options)));
14518
+ if (reply2 === void 0) return void 0;
14519
+ const response = ObjectResponse.fromBinary(reply2);
14520
+ return new WorldObject(response.object ?? 0);
14521
+ }
14522
+ function createFog(options) {
14523
+ const reply2 = call("CreateFog", FogOptions.toBinary(options));
14524
+ if (reply2 === void 0) return void 0;
14525
+ const response = ObjectResponse.fromBinary(reply2);
14526
+ return new WorldObject(response.object ?? 0);
14527
+ }
14528
+ function addBot(options) {
14529
+ const reply2 = call("AddBot", BotOptions.toBinary(toBotOptions(options)));
14530
+ if (reply2 === void 0) return void 0;
14531
+ const response = BotResponse.fromBinary(reply2);
14532
+ return Player.of(response.player ?? 0);
14533
+ }
14534
+ function blockInput(buttons) {
14535
+ return call("BlockInput", InputRequest.toBinary({ buttons })) !== void 0;
14536
+ }
14537
+ function watchInput(buttons) {
14538
+ return call("WatchInput", InputRequest.toBinary({ buttons })) !== void 0;
14539
+ }
14540
+ function remapInput(from, to, repeat2) {
14541
+ return call("RemapInput", RemapInputRequest.toBinary({ from, to, repeat: repeat2 })) !== void 0;
14542
+ }
14543
+ function callService(service2, method, payload) {
14544
+ const reply2 = call("CallService", ServiceCall.toBinary({ service: service2, method, payload }));
14545
+ if (reply2 === void 0) return void 0;
14546
+ const response = ServiceReply.fromBinary(reply2);
14547
+ return response.payload ?? new Uint8Array();
14548
+ }
14549
+ function createEntity(options) {
14550
+ const reply2 = call("CreateEntity", EntityOptions.toBinary(toEntityOptions(options)));
14551
+ if (reply2 === void 0) return void 0;
14552
+ const response = EntityResponse.fromBinary(reply2);
14553
+ return response.entity ?? 0;
14554
+ }
14555
+ function fireInput(entity, input2, value, activator) {
14556
+ const reply2 = call("FireInput", FireInputRequest.toBinary({ entity, input: input2, value: value === void 0 ? void 0 : toEntityValue(value), activator }));
14557
+ if (reply2 === void 0) return false;
14558
+ const response = AliveResponse.fromBinary(reply2);
14559
+ return response.alive ?? false;
14560
+ }
14561
+ function removeEntity(entity) {
14562
+ const reply2 = call("RemoveEntity", EntityRequest.toBinary({ entity }));
14563
+ if (reply2 === void 0) return false;
14564
+ const response = AliveResponse.fromBinary(reply2);
14565
+ return response.alive ?? false;
14566
+ }
14567
+ function showEntityOnlyTo(entity, players2) {
14568
+ return call("ShowEntityOnlyTo", ShowEntityOnlyToRequest.toBinary({ entity, players: players2?.map((v) => int32(v)) })) !== void 0;
14569
+ }
14570
+ function showEntityToAll(entity) {
14571
+ return call("ShowEntityToAll", EntityRequest.toBinary({ entity })) !== void 0;
14572
+ }
14573
+ function spawnNpc(options) {
14574
+ const reply2 = call("SpawnNpc", NpcOptions.toBinary(toNpcOptions(options)));
14575
+ if (reply2 === void 0) return void 0;
14576
+ const response = NpcResponse.fromBinary(reply2);
14577
+ return new Npc(response.npc ?? 0);
14578
+ }
14579
+ function createPickup(kind, position) {
14580
+ const reply2 = call("CreatePickup", CreatePickupRequest.toBinary({ kind: pickupKindValues[kind], position }));
14581
+ if (reply2 === void 0) return void 0;
14582
+ const response = PickupResponse.fromBinary(reply2);
14583
+ return new Pickup(response.pickup ?? 0);
14584
+ }
14585
+ function findEntities(className) {
14586
+ const reply2 = call("FindEntities", FindEntitiesRequest.toBinary({ className }));
14587
+ if (reply2 === void 0) return [];
14588
+ const response = EntitiesResponse.fromBinary(reply2);
14589
+ return response.entities ?? [];
14590
+ }
14591
+ function findEntitiesByName(name) {
14592
+ const reply2 = call("FindEntitiesByName", FindEntitiesByNameRequest.toBinary({ name }));
14593
+ if (reply2 === void 0) return [];
14594
+ const response = EntitiesResponse.fromBinary(reply2);
14595
+ return response.entities ?? [];
14596
+ }
14597
+ function removeEntities(className) {
14598
+ const reply2 = call("RemoveEntities", RemoveEntitiesRequest.toBinary({ className }));
14599
+ if (reply2 === void 0) return void 0;
14600
+ const response = CountResponse.fromBinary(reply2);
14601
+ return response.count ?? 0;
14602
+ }
14603
+ function clearMap() {
14604
+ return call("ClearMap", new Uint8Array()) !== void 0;
14605
+ }
14606
+ function damage(options) {
14607
+ return call("Damage", HitOptions.toBinary(toHitOptions(options))) !== void 0;
14608
+ }
14609
+ function killEntity(options) {
14610
+ return call("KillEntity", KillOptions.toBinary(options)) !== void 0;
14611
+ }
14612
+ function trace(options) {
14613
+ const reply2 = call("Trace", TraceOptions.toBinary(toTraceOptions(options)));
14614
+ if (reply2 === void 0) return void 0;
14615
+ const response = TraceResponse.fromBinary(reply2);
14616
+ return response.hit === void 0 ? void 0 : fromTraceHit(response.hit);
14617
+ }
14618
+ function restoreNpcs(npcs) {
14619
+ return call("RestoreNpcs", RestoreNpcsRequest.toBinary({ npcs: npcs?.map((v) => toNpcTarget(v)) })) !== void 0;
14620
+ }
14621
+ function pause(paused) {
14622
+ return call("Pause", PauseRequest.toBinary({ paused })) !== void 0;
14623
+ }
14624
+ function matchClock() {
14625
+ const reply2 = call("MatchClock", new Uint8Array());
14626
+ if (reply2 === void 0) return void 0;
14627
+ const response = MatchClockResponse.fromBinary(reply2);
14628
+ return response.seconds ?? 0;
14629
+ }
14630
+ function holdMatchClock(seconds) {
14631
+ return call("HoldMatchClock", HoldMatchClockRequest.toBinary({ seconds })) !== void 0;
14632
+ }
14633
+ function rift() {
14634
+ const reply2 = call("Rift", new Uint8Array());
14635
+ if (reply2 === void 0) return void 0;
14636
+ const response = RiftResponse.fromBinary(reply2);
14637
+ return response.state === void 0 ? void 0 : fromRiftState(response.state);
14638
+ }
14639
+ function startRift(position) {
14640
+ return call("StartRift", StartRiftRequest.toBinary({ position })) !== void 0;
14641
+ }
14642
+ function moveEntity(entity, position, facing, velocity) {
14643
+ return call("MoveEntity", MoveEntityRequest.toBinary({ entity, position, facing, velocity })) !== void 0;
14644
+ }
14645
+ function pushEntity(entity, velocity, spin) {
14646
+ return call("PushEntity", PushEntityRequest.toBinary({ entity, velocity, spin })) !== void 0;
14647
+ }
14648
+ function emitSound(entity, sound, options) {
14649
+ const reply2 = call("EmitSound", EmitSoundRequest.toBinary({ entity, sound, options: options === void 0 ? void 0 : toSoundOptions(options) }));
14650
+ if (reply2 === void 0) return void 0;
14651
+ const response = SoundResponse.fromBinary(reply2);
14652
+ return response.id ?? 0;
14653
+ }
14654
+ function adjustSound(id, volume, pitch) {
14655
+ return call("AdjustSound", AdjustSoundRequest.toBinary({ id, volume, pitch })) !== void 0;
14656
+ }
14657
+ function stopSound(id) {
14658
+ return call("StopSound", StopSoundRequest.toBinary({ id })) !== void 0;
14659
+ }
14660
+ function watchProjectiles(options) {
14661
+ return call("WatchProjectiles", ProjectileOptions.toBinary(toProjectileOptions(options))) !== void 0;
14662
+ }
14663
+ function holdEntityModifier(entity, modifier, active) {
14664
+ return call("HoldEntityModifier", HoldEntityModifierRequest.toBinary({ entity, modifier, active })) !== void 0;
14665
+ }
14666
+ function giveEntityModifier(entity, modifier, seconds) {
14667
+ return call("GiveEntityModifier", GiveEntityModifierRequest.toBinary({ entity, modifier, seconds })) !== void 0;
14668
+ }
14669
+ function serveMod(handlers2, bytes) {
14670
+ const request = Call.fromBinary(bytes);
14671
+ const input2 = request.request ?? new Uint8Array();
14672
+ try {
14673
+ switch (request.method) {
14674
+ case "Start":
14675
+ return reply(StartResult.toBinary(handlers2.start(fromStartEvent(StartEvent.fromBinary(input2)))));
14676
+ case "Frame":
14677
+ handlers2.frame(fromFrameEvent(FrameEvent.fromBinary(input2)));
14678
+ return reply();
14679
+ case "Command":
14680
+ return reply(CommandResult.toBinary(handlers2.command(fromCommandEvent(CommandEvent.fromBinary(input2)))));
14681
+ case "Chat":
14682
+ handlers2.chat(fromChatEvent(ChatEvent.fromBinary(input2)));
14683
+ return reply();
14684
+ case "World":
14685
+ handlers2.world(fromWorldEvent(WorldEvent.fromBinary(input2)));
14686
+ return reply();
14687
+ case "UiPress":
14688
+ handlers2.uiPress(fromUiPressEvent(UiPressEvent.fromBinary(input2)));
14689
+ return reply();
14690
+ case "UiInput":
14691
+ handlers2.uiInput(fromUiInputEvent(UiInputEvent.fromBinary(input2)));
14692
+ return reply();
14693
+ case "Serve":
14694
+ return reply(ServiceReply.toBinary(handlers2.serve(fromServiceCall(ServiceCall.fromBinary(input2)))));
14695
+ case "Damage":
14696
+ return reply(DamageResult.toBinary(handlers2.damage(fromDamageEvent(DamageEvent.fromBinary(input2)))));
14697
+ case "Damaged":
14698
+ handlers2.damaged(fromDamagedEvent(DamagedEvent.fromBinary(input2)));
14699
+ return reply();
14700
+ case "Input":
14701
+ handlers2.input(fromInputEvent(InputEvent.fromBinary(input2)));
14702
+ return reply();
14703
+ case "Restored":
14704
+ handlers2.restored(fromRestoredEvent(RestoredEvent.fromBinary(input2)));
14705
+ return reply();
14706
+ case "NpcsRestored":
14707
+ handlers2.npcsRestored(fromNpcsRestoredEvent(NpcsRestoredEvent.fromBinary(input2)));
14708
+ return reply();
14709
+ case "Launch":
14710
+ handlers2.launch(fromLaunchEvent(LaunchEvent.fromBinary(input2)));
14711
+ return reply();
14712
+ case "Impact":
14713
+ handlers2.impact(fromImpactEvent(ImpactEvent.fromBinary(input2)));
14714
+ return reply();
14715
+ case "Landed":
14716
+ handlers2.landed(fromLandedEvent(LandedEvent.fromBinary(input2)));
14717
+ return reply();
14718
+ case "SettingChanged":
14719
+ handlers2.settingChanged(fromSettingChangedEvent(SettingChangedEvent.fromBinary(input2)));
14720
+ return reply();
14721
+ case "PlayerJoined":
14722
+ handlers2.playerJoined(fromPlayerJoinedEvent(PlayerJoinedEvent.fromBinary(input2)));
14723
+ return reply();
14724
+ case "PlayerLeft":
14725
+ handlers2.playerLeft(fromPlayerLeftEvent(PlayerLeftEvent.fromBinary(input2)));
14726
+ return reply();
14727
+ case "PlayersChanged":
14728
+ handlers2.playersChanged(fromPlayersChangedEvent(PlayersChangedEvent.fromBinary(input2)));
14729
+ return reply();
14730
+ }
14731
+ } catch (error) {
14732
+ return Reply.toBinary({ error: String(error) });
14733
+ }
14734
+ return Reply.toBinary({ error: `the mod has no method ${request.method}` });
14735
+ }
14736
+
14737
+ // js/src/players.ts
14738
+ var roster = void 0;
14739
+ var generations = /* @__PURE__ */ new Map();
14740
+ var watchers = [];
14741
+ function keepPlayers(players2) {
14742
+ roster = adopt(players2);
14743
+ for (const watcher of watchers) {
14744
+ watcher(roster);
14745
+ }
14746
+ }
14747
+ function adopt(players2) {
14748
+ const current = new Map(players2.map((c) => [c.player.slot, c.generation]));
14749
+ for (const [slot, generation] of generations) {
14750
+ if (current.get(slot) !== generation) Player.release(slot);
14751
+ }
14752
+ generations.clear();
14753
+ return players2.map((c) => {
14754
+ generations.set(c.player.slot, c.generation);
14755
+ const player = Player.of(c.player.slot);
14756
+ return player === c.player ? c : { ...c, player };
14757
+ });
14758
+ }
14759
+ function watchPlayers(watcher) {
14760
+ watchers.push(watcher);
14761
+ if (roster !== void 0) watcher(roster);
14762
+ }
14763
+ function connection(player) {
14764
+ const slot = typeof player === "number" ? player : player.slot;
14765
+ return (roster ?? players()).find((c) => c.player.slot === slot);
14766
+ }
14767
+ function players() {
14768
+ if (roster !== void 0) return roster.slice();
14769
+ const reply2 = call("Players", new Uint8Array());
14770
+ if (reply2 === void 0) return [];
14771
+ return adopt(
14772
+ (PlayersResponse.fromBinary(reply2).players ?? []).map((c) => ({
14773
+ player: Player.of(c.player ?? 0),
14774
+ steamId: c.steamId ?? 0n,
14775
+ name: c.name ?? "",
14776
+ bot: c.bot ?? false,
14777
+ ready: c.ready ?? false,
14778
+ generation: c.generation ?? 0,
14779
+ roles: (c.roles ?? []).flatMap((role) => roleNames[role] ?? [])
14780
+ }))
14781
+ );
14782
+ }
14783
+ var roleNames = {
14784
+ [1 /* DEVELOPER */]: "developer",
14785
+ [2 /* TESTER */]: "tester"
14786
+ };
14787
+
14788
+ // js/src/cast.ts
14789
+ var changeSeconds = 3;
14790
+ var noWant = {};
14791
+ var Cast = class {
14792
+ constructor(options) {
14793
+ this.options = options;
14794
+ watchPlayers((players2) => {
14795
+ this.reported = players2;
14796
+ });
14797
+ }
14798
+ options;
14799
+ seats = /* @__PURE__ */ new Map();
14800
+ /** kicked holds the connection generation each kicked bot's slot had. */
14801
+ kicked = /* @__PURE__ */ new Map();
14802
+ /** reported is the player list the host reported since the last frame. */
14803
+ reported;
14804
+ /** size is the number of members. */
14805
+ get size() {
14806
+ return this.seats.size;
14807
+ }
14808
+ /** members lists the members in the order they joined. */
14809
+ members() {
14810
+ return Array.from(this.seats.values(), (seat) => seat.member);
14811
+ }
14812
+ /** get returns the member in player's slot, if any. */
14813
+ get(player) {
14814
+ return this.seats.get(player.slot)?.member;
14815
+ }
14816
+ /** pawn returns the member's hero as Cast read it this frame. */
14817
+ pawn(player) {
14818
+ return this.seats.get(player.slot)?.pawn;
14819
+ }
14820
+ /**
14821
+ * frame settles the joins and leaves reported since the last frame, reads
14822
+ * each member's hero, and asks the game once a second for any want it does
14823
+ * not show yet. seconds is the game clock.
14824
+ */
14825
+ frame(seconds) {
14826
+ if (this.reported !== void 0) {
14827
+ this.settle(this.reported, seconds);
14828
+ this.reported = void 0;
14829
+ }
14830
+ for (const seat of this.seats.values()) {
14831
+ this.reconcile(seat, seconds);
14832
+ }
14833
+ }
14834
+ /**
14835
+ * settle ends the members whose connection left and makes the new ones,
14836
+ * joined at now.
14837
+ */
14838
+ settle(players2, now4) {
14839
+ const present = new Map(players2.map((c) => [c.player.slot, c]));
14840
+ for (const [slot, seat] of this.seats) {
14841
+ if (present.get(slot)?.generation !== seat.connection.generation) {
14842
+ this.seats.delete(slot);
14843
+ this.options.leave?.(seat.member, seat.connection);
14844
+ }
14845
+ }
14846
+ const { bots = "skip" } = this.options;
14847
+ for (const connection2 of players2) {
14848
+ const slot = connection2.player.slot;
14849
+ if (!connection2.ready || this.seats.has(slot)) continue;
14850
+ if (connection2.bot && bots !== "join") {
14851
+ if (bots === "kick") this.kick(connection2);
14852
+ continue;
14853
+ }
14854
+ this.seats.set(slot, {
14855
+ connection: connection2,
14856
+ member: this.options.join(connection2),
14857
+ pawn: void 0,
14858
+ alive: false,
14859
+ fellAt: -Infinity,
14860
+ hero: 0,
14861
+ heroLostAt: -Infinity,
14862
+ joinedAt: now4,
14863
+ askedAt: -Infinity
14864
+ });
14865
+ }
14866
+ }
14867
+ /** kick asks the server to remove a bot, once per connection. */
14868
+ kick(connection2) {
14869
+ const slot = connection2.player.slot;
14870
+ if (this.kicked.get(slot) === connection2.generation) return;
14871
+ this.kicked.set(slot, connection2.generation);
14872
+ serverCommand(`kick "${connection2.name}"`);
14873
+ }
14874
+ /** reconcile reads a member's hero and asks for the part of the want it lacks. */
14875
+ reconcile(seat, now4) {
14876
+ const pawn = seat.connection.player.pawn();
14877
+ const alive = pawn !== void 0 && pawn.hero !== 0 && pawn.health > 0;
14878
+ if (seat.alive && !alive) seat.fellAt = now4;
14879
+ seat.pawn = pawn;
14880
+ seat.alive = alive;
14881
+ const had = pawn?.hero ?? 0;
14882
+ if (had === 0 && seat.hero !== 0) seat.heroLostAt = now4;
14883
+ seat.hero = had;
14884
+ const changing = had === 0 && now4 - seat.heroLostAt < changeSeconds;
14885
+ if (now4 - seat.askedAt < 1 || changing) return;
14886
+ const want = this.wantOf(seat);
14887
+ const { respawn } = want;
14888
+ const hero = want.hero ?? this.stranded(seat, now4);
14889
+ if (hero !== void 0 && !this.seated(seat, want, hero)) {
14890
+ seat.askedAt = now4;
14891
+ this.seat(seat, want, hero);
14892
+ } else if (respawn !== void 0 && pawn !== void 0 && pawn.hero !== 0 && !alive && now4 - seat.fellAt >= respawn) {
14893
+ seat.askedAt = now4;
14894
+ seat.connection.player.respawn();
14895
+ }
14896
+ }
14897
+ /**
14898
+ * stranded returns 'any' for a human whose hero is free when the game has
14899
+ * left them on a team without one for changeSeconds since they joined, and
14900
+ * otherwise leaves the hero free. Such a pawn never gets a hero on its own,
14901
+ * while a player still choosing one has no pawn and a spectator stands on
14902
+ * team 1. A bot is left to the game, which seats it.
14903
+ */
14904
+ stranded(seat, now4) {
14905
+ const { pawn } = seat;
14906
+ const team = pawn?.team;
14907
+ const heroless = pawn?.hero === 0 && (team === 2 || team === 3);
14908
+ return heroless && !seat.connection.bot && now4 - seat.joinedAt >= changeSeconds ? "any" : void 0;
14909
+ }
14910
+ /** wantOf is what the member in seat wants now. */
14911
+ wantOf(seat) {
14912
+ const { want = noWant } = this.options;
14913
+ return typeof want === "function" ? want(seat.member) : want;
14914
+ }
14915
+ /** seated reports whether the member's hero shows the hero and team they want. */
14916
+ seated(seat, want, hero) {
14917
+ const { pawn } = seat;
14918
+ if (pawn === void 0 || pawn.hero === 0) return false;
14919
+ if (want.team !== void 0 && pawn.team !== want.team) return false;
14920
+ if (hero === "any") return true;
14921
+ const id = typeof hero === "number" ? hero : heroNamed(hero)?.id;
14922
+ return id === void 0 || pawn.hero === id;
14923
+ }
14924
+ /** seat asks the game to put the member on hero and their team. */
14925
+ seat(seat, want, hero) {
14926
+ const { pawn } = seat;
14927
+ let pick = hero;
14928
+ if (hero === "any") {
14929
+ pick = pawn !== void 0 && pawn.hero !== 0 ? pawn.hero : heroes[Math.floor(Math.random() * heroes.length)]?.name;
14930
+ }
14931
+ if (pick !== void 0) {
14932
+ seat.connection.player.selectHero(pick, want.team ?? this.side(seat));
14933
+ }
14934
+ }
14935
+ /** side is the team a member joins: their hero's, or the one with fewer heroes. */
14936
+ side(seat) {
14937
+ const { pawn } = seat;
14938
+ if (pawn !== void 0 && pawn.hero !== 0 && (pawn.team === 2 || pawn.team === 3)) {
14939
+ return pawn.team;
14940
+ }
14941
+ let amber = 0;
14942
+ let sapphire = 0;
14943
+ for (const other of this.seats.values()) {
14944
+ if (other === seat || other.pawn === void 0 || other.pawn.hero === 0)
14945
+ continue;
14946
+ if (other.pawn.team === 2) amber++;
14947
+ if (other.pawn.team === 3) sapphire++;
14948
+ }
14949
+ return sapphire < amber ? 3 : 2;
14950
+ }
14951
+ };
14952
+
14953
+ // js/src/puppet.ts
14954
+ var ticksPerSecond = 64;
14955
+ function trackTicks(track) {
14956
+ return Math.max(track.x.length - 1, 0) * track.stepTicks;
14957
+ }
14958
+ function lerp(a, b, t) {
14959
+ return a + (b - a) * t;
14960
+ }
14961
+ function lerpAngle(a, b, t) {
14962
+ const delta = ((b - a) % 360 + 540) % 360 - 180;
14963
+ return a + delta * t;
14964
+ }
14965
+ function poseAt(track, tick2) {
14966
+ const last = track.x.length - 1;
14967
+ if (last < 0) return void 0;
14968
+ const at3 = Math.min(Math.max(tick2 / track.stepTicks, 0), last);
14969
+ const i = Math.min(Math.floor(at3), Math.max(last - 1, 0));
14970
+ const j = Math.min(i + 1, last);
14971
+ const t = at3 - i;
14972
+ const seconds = track.stepTicks / ticksPerSecond;
14973
+ const blend = (column) => lerp(sample(column, i), sample(column, j), t);
14974
+ const slope = (column) => (sample(column, j) - sample(column, i)) / seconds;
14975
+ const still = i === j;
14976
+ return {
14977
+ position: { x: blend(track.x), y: blend(track.y), z: blend(track.z) },
14978
+ facing: {
14979
+ pitch: track.pitch ? blend(track.pitch) : 0,
14980
+ yaw: lerpAngle(sample(track.yaw, i), sample(track.yaw, j), t),
14981
+ roll: 0
14982
+ },
14983
+ velocity: still ? { x: 0, y: 0, z: 0 } : { x: slope(track.x), y: slope(track.y), z: slope(track.z) },
14984
+ health: track.health && blend(track.health)
14985
+ };
14986
+ }
14987
+ function sample(column, index) {
14988
+ return column[index] ?? 0;
14989
+ }
14990
+ var ghostStates = [
14991
+ "MODIFIER_STATE_INVULNERABLE",
14992
+ "MODIFIER_STATE_NO_TARGET",
14993
+ "MODIFIER_STATE_IGNORED_BY_UNIT_FILTER",
14994
+ "MODIFIER_STATE_IGNORED_BY_NPC_TARGETING",
14995
+ "MODIFIER_STATE_INVISIBLE_ON_MINIMAP",
14996
+ "MODIFIER_STATE_UNIT_STATUS_HIDDEN"
14997
+ ];
14998
+ var ghostAlpha = 110;
14999
+ var renderTransColor = 1;
15000
+ var live = /* @__PURE__ */ new Set();
15001
+ var longestFrame = 0.25;
15002
+ function advancePuppets(seconds) {
15003
+ for (const puppet of live) puppet.advance(seconds);
15004
+ }
15005
+ var Puppet = class _Puppet {
15006
+ /**
15007
+ * The puppet drives player's hero along track. It owns the hero's placement
15008
+ * and, when the track records health, its health.
15009
+ */
15010
+ constructor(player, track, options = {}) {
15011
+ this.player = player;
15012
+ this.track = track;
15013
+ this.snapUnits = options.snapUnits ?? 200;
15014
+ live.add(this);
15015
+ if (options.ghost) this.setGhost(true);
15016
+ }
15017
+ player;
15018
+ track;
15019
+ tickAt = 0;
15020
+ rateNow = 1;
15021
+ current = "paused";
15022
+ /** clock is the game time of the last frame, unset until one arrives. */
15023
+ clock;
15024
+ /** drawn is whether the hero needs placing at the current tick. */
15025
+ drawn = false;
15026
+ ghostNow = false;
15027
+ dead = false;
15028
+ /** looked is the entity and ghost setting syncLook last wrote. */
15029
+ looked;
15030
+ lastHealth;
15031
+ snapUnits;
15032
+ /**
15033
+ * spawn adds a bot and returns a puppet for it, or undefined when no bot
15034
+ * could join. The bot appears at the track's first pose.
15035
+ */
15036
+ static spawn(bot, track, options) {
15037
+ const start = poseAt(track, 0);
15038
+ const player = addBot({ ...bot, position: bot.position ?? start?.position });
15039
+ return player && new _Puppet(player, track, options);
15040
+ }
15041
+ /** state is where playback stands. */
15042
+ get state() {
15043
+ return this.current;
15044
+ }
15045
+ /** tick is the playback position, in track ticks. */
15046
+ get tick() {
15047
+ return this.tickAt;
15048
+ }
15049
+ /** rate is the playback speed: 1 is real time, 0.5 half speed, negative runs backward. */
15050
+ get rate() {
15051
+ return this.rateNow;
15052
+ }
15053
+ set rate(rate) {
15054
+ this.rateNow = rate;
15055
+ }
15056
+ /** isGhost reports whether the puppet is a ghost. */
15057
+ get isGhost() {
15058
+ return this.ghostNow;
15059
+ }
15060
+ /** play starts or resumes playback; from the end it restarts at tick 0. */
15061
+ play() {
15062
+ if (this.current === "ended" && this.rateNow >= 0) this.seek(0);
15063
+ this.current = "playing";
15064
+ }
15065
+ /** pause holds the hero where it stands. */
15066
+ pause() {
15067
+ this.current = "paused";
15068
+ }
15069
+ /**
15070
+ * seek moves playback to tick, clamped to the track, and places the hero
15071
+ * there on the next frame. Playback keeps its state, except that an ended
15072
+ * puppet paused at the new tick.
15073
+ */
15074
+ seek(tick2) {
15075
+ this.tickAt = Math.min(Math.max(tick2, 0), trackTicks(this.track));
15076
+ this.drawn = false;
15077
+ this.lastHealth = void 0;
15078
+ if (this.current === "ended") this.current = "paused";
15079
+ }
15080
+ /**
15081
+ * setGhost draws the hero translucent and holds the modifier states of
15082
+ * ghostStates, so it takes no damage and is not targeted; off restores
15083
+ * both. The hero's collision with other heroes is the game's own.
15084
+ */
15085
+ setGhost(ghost) {
15086
+ this.ghostNow = ghost;
15087
+ const pawn = this.player.pawn();
15088
+ if (pawn) this.syncLook(pawn.entity);
15089
+ }
15090
+ /**
15091
+ * syncLook writes the ghost look and states to the hero entity when the
15092
+ * entity or the ghost setting differs from what it last wrote, so a hero
15093
+ * that respawned takes them again.
15094
+ */
15095
+ syncLook(entity) {
15096
+ if (this.looked?.entity === entity && this.looked.ghost === this.ghostNow) {
15097
+ return;
15098
+ }
15099
+ this.looked = { entity, ghost: this.ghostNow };
15100
+ for (const state of ghostStates) {
15101
+ holdModifierState(entity, state, this.ghostNow);
15102
+ }
15103
+ const alpha = this.ghostNow ? ghostAlpha : 255;
15104
+ const mode = this.ghostNow ? renderTransColor : 0;
15105
+ writeField(entity, "CBaseModelEntity", "m_nRenderMode", "uint8", mode);
15106
+ writeField(
15107
+ entity,
15108
+ "CBaseModelEntity",
15109
+ "m_clrRender",
15110
+ "uint32",
15111
+ 16777215 | alpha << 24
15112
+ );
15113
+ }
15114
+ /** stop ends the puppet and removes its bot; a hero that is not a bot stays. */
15115
+ stop() {
15116
+ live.delete(this);
15117
+ const pawn = this.player.pawn();
15118
+ if (pawn && this.ghostNow) {
15119
+ this.ghostNow = false;
15120
+ this.syncLook(pawn.entity);
15121
+ }
15122
+ const slot = this.player.slot;
15123
+ if (players().some((c) => c.player.slot === slot && c.bot)) {
15124
+ this.player.removeBot();
15125
+ }
15126
+ }
15127
+ /**
15128
+ * advance moves playback to the game clock at seconds and places the hero.
15129
+ * The library calls it each frame; a mod calls it only to step a puppet by
15130
+ * hand.
15131
+ */
15132
+ advance(seconds) {
15133
+ const elapsed = Math.min(seconds - (this.clock ?? seconds), longestFrame);
15134
+ this.clock = seconds;
15135
+ if (this.current === "playing" && elapsed > 0) {
15136
+ this.tickAt += elapsed * ticksPerSecond * this.rateNow;
15137
+ const end = trackTicks(this.track);
15138
+ if (this.tickAt >= end || this.tickAt <= 0) {
15139
+ this.tickAt = Math.min(Math.max(this.tickAt, 0), end);
15140
+ this.current = "ended";
15141
+ }
15142
+ this.drawn = false;
15143
+ }
15144
+ if (!this.drawn) this.place();
15145
+ }
15146
+ /** place puts the hero at the current tick; it retries next frame without a hero. */
15147
+ place() {
15148
+ const pawn = this.player.pawn();
15149
+ const pose = poseAt(this.track, this.tickAt);
15150
+ if (!pawn || !pose) return;
15151
+ this.syncLook(pawn.entity);
15152
+ const gap2 = Math.hypot(
15153
+ pose.position.x - pawn.position.x,
15154
+ pose.position.y - pawn.position.y,
15155
+ pose.position.z - pawn.position.z
15156
+ );
15157
+ const placed = gap2 > this.snapUnits || this.current !== "playing" ? this.player.teleport(pose.position, pose.facing) : this.player.move(pose.position, pose.facing, pose.velocity);
15158
+ if (placed) this.drawn = true;
15159
+ this.setHealth(pawn.entity, pose.health);
15160
+ }
15161
+ /**
15162
+ * setHealth gives the hero the recorded health. A recorded zero kills the
15163
+ * hero once; the first health above zero after that respawns it, and the
15164
+ * next frame places it.
15165
+ */
15166
+ setHealth(entity, health) {
15167
+ if (health === void 0) return;
15168
+ if (health <= 0) {
15169
+ if (!this.dead) this.dead = this.player.kill();
15170
+ return;
15171
+ }
15172
+ if (this.dead) {
15173
+ this.dead = !this.player.respawn();
15174
+ this.drawn = false;
15175
+ return;
15176
+ }
15177
+ const rounded = Math.round(health);
15178
+ if (rounded !== this.lastHealth) {
15179
+ writeField(entity, "CBaseEntity", "m_iHealth", "int32", rounded);
15180
+ this.lastHealth = rounded;
15181
+ }
15182
+ }
15183
+ };
15184
+
15185
+ // js/src/restore.ts
15186
+ var waiting = /* @__PURE__ */ new Map();
15187
+ function restoreHero(player, snapshot, done) {
15188
+ const target = {
15189
+ position: snapshot.position,
15190
+ facing: snapshot.facing,
15191
+ health: snapshot.health,
15192
+ maxHealth: snapshot.maxHealth,
15193
+ level: snapshot.level,
15194
+ upgradeBonuses: snapshot.upgradeBonuses,
15195
+ abilities: snapshot.abilities,
15196
+ items: snapshot.items,
15197
+ replaceItems: snapshot.items !== void 0,
15198
+ timers: snapshot.timers
15199
+ };
15200
+ if (snapshot.souls !== void 0) player.startingSouls(snapshot.souls);
15201
+ waiting.set(player.slot, { souls: snapshot.souls, done });
15202
+ if (player.restoreHero(target)) return true;
15203
+ waiting.delete(player.slot);
15204
+ return false;
15205
+ }
15206
+ function settleRestore(player, error) {
15207
+ const restore = waiting.get(player.slot);
15208
+ if (!restore) return;
15209
+ waiting.delete(player.slot);
15210
+ const held = player.pawn()?.souls;
15211
+ if (restore.souls !== void 0 && held !== void 0 && held !== restore.souls) {
15212
+ player.adjustSouls(restore.souls - held, true);
15213
+ }
15214
+ restore.done?.(error);
15215
+ }
15216
+
15217
+ // js/src/timer.ts
15218
+ var Entry = class {
15219
+ /**
15220
+ * run is the entry's callback. It returns the delay in seconds before its
15221
+ * next run, or undefined when it has run for the last time.
15222
+ */
15223
+ constructor(delay, run) {
15224
+ this.delay = delay;
15225
+ this.run = run;
15226
+ this.at = now === void 0 ? void 0 : now + delay;
15227
+ }
15228
+ delay;
15229
+ run;
15230
+ finished = false;
15231
+ /** at is the game time the entry next runs, unset until the clock is known. */
15232
+ at;
15233
+ /** start counts the first delay from the frame at seconds, once. */
15234
+ start(seconds) {
15235
+ this.at ??= seconds + this.delay;
15236
+ }
15237
+ cancel() {
15238
+ this.finished = true;
15239
+ }
15240
+ };
15241
+ var now;
15242
+ var entries = [];
15243
+ function after(seconds, fn) {
15244
+ return schedule(seconds, () => {
15245
+ fn();
14989
15246
  return void 0;
15247
+ });
15248
+ }
15249
+ function every(seconds, fn) {
15250
+ return schedule(seconds, () => {
15251
+ fn();
15252
+ return seconds;
15253
+ });
15254
+ }
15255
+ function sequence(fn) {
15256
+ let run = 0;
15257
+ return schedule(0, () => fn(++run) ?? void 0);
15258
+ }
15259
+ function schedule(delay, run) {
15260
+ const entry = new Entry(delay, run);
15261
+ entries.push(entry);
15262
+ return entry;
15263
+ }
15264
+ function advance(seconds) {
15265
+ if (now !== void 0 && seconds < now) {
15266
+ const shift = seconds - now;
15267
+ for (const entry of entries) {
15268
+ if (entry.at !== void 0) {
15269
+ entry.at += shift;
15270
+ }
15271
+ }
15272
+ }
15273
+ now = seconds;
15274
+ for (const entry of entries) {
15275
+ entry.start(seconds);
15276
+ }
15277
+ const due = entries.filter((entry) => !entry.finished && entry.at <= seconds).sort((a, b) => a.at - b.at);
15278
+ for (const entry of due) {
15279
+ if (entry.finished) {
15280
+ continue;
15281
+ }
15282
+ try {
15283
+ const wait = entry.run();
15284
+ if (wait === void 0) {
15285
+ entry.finished = true;
15286
+ } else {
15287
+ const next = entry.at + wait;
15288
+ entry.at = next > seconds ? next : seconds + wait;
15289
+ }
15290
+ } catch (error) {
15291
+ entry.finished = true;
15292
+ log(`timer failed: ${String(error)}`);
15293
+ }
15294
+ }
15295
+ entries = entries.filter((entry) => !entry.finished);
15296
+ }
15297
+
15298
+ // js/src/item-id.ts
15299
+ function itemId(name) {
15300
+ const m = 1540483477;
15301
+ const data = new TextEncoder().encode(name);
15302
+ const byte = (at3) => data[at3] ?? 0;
15303
+ let h = (826366246 ^ data.length) >>> 0;
15304
+ let i = 0;
15305
+ for (; data.length - i >= 4; i += 4) {
15306
+ let k = (byte(i) | byte(i + 1) << 8 | byte(i + 2) << 16 | byte(i + 3) << 24) >>> 0;
15307
+ k = Math.imul(k, m) >>> 0;
15308
+ k = (k ^ k >>> 24) >>> 0;
15309
+ k = Math.imul(k, m) >>> 0;
15310
+ h = Math.imul(h, m) >>> 0;
15311
+ h = (h ^ k) >>> 0;
15312
+ }
15313
+ const rest = data.length - i;
15314
+ if (rest >= 3) h = (h ^ byte(i + 2) << 16) >>> 0;
15315
+ if (rest >= 2) h = (h ^ byte(i + 1) << 8) >>> 0;
15316
+ if (rest >= 1) {
15317
+ h = (h ^ byte(i)) >>> 0;
15318
+ h = Math.imul(h, m) >>> 0;
14990
15319
  }
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));
15320
+ h = (h ^ h >>> 13) >>> 0;
15321
+ h = Math.imul(h, m) >>> 0;
15322
+ return (h ^ h >>> 15) >>> 0;
14993
15323
  }
14994
15324
 
14995
15325
  // js/src/ui.ts
@@ -16916,171 +17246,6 @@ function Meter(props) {
16916
17246
  );
16917
17247
  }
16918
17248
 
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
17249
  // js/src/frameclock.ts
17085
17250
  var now3 = () => performance.now();
17086
17251
  var reportTicks = 3840n;
@@ -17991,16 +18156,16 @@ var Dropper = class {
17991
18156
  this.stop(player);
17992
18157
  return;
17993
18158
  }
17994
- const connection = players().find(
17995
- (connection2) => connection2.player.slot === player.slot
18159
+ const connection2 = players().find(
18160
+ (connection3) => connection3.player.slot === player.slot
17996
18161
  );
17997
- if (!connection || this.catalog.length === 0) {
18162
+ if (!connection2 || this.catalog.length === 0) {
17998
18163
  return;
17999
18164
  }
18000
18165
  const yaw = player.pawn()?.eyeAngles.yaw ?? 0;
18001
18166
  this.builders.set(player.slot, {
18002
18167
  player,
18003
- steamId: connection.steamId,
18168
+ steamId: connection2.steamId,
18004
18169
  entry: 0,
18005
18170
  yaw: Math.round(yaw / turnDegrees) * turnDegrees,
18006
18171
  drops: []
@@ -18037,7 +18202,7 @@ var Dropper = class {
18037
18202
  * left, and launches heroes standing on bouncing objects.
18038
18203
  */
18039
18204
  frame(movement) {
18040
- const live2 = new Set(players().map((connection) => connection.player.slot));
18205
+ const live2 = new Set(players().map((connection2) => connection2.player.slot));
18041
18206
  for (const builder of this.builders.values()) {
18042
18207
  if (live2.has(builder.player.slot)) {
18043
18208
  this.aim(builder);
@@ -18848,6 +19013,48 @@ function onPlayerJoin(handler) {
18848
19013
  function onPlayerLeave(handler) {
18849
19014
  leaves.push(handler);
18850
19015
  }
19016
+ function onSpawn(handler) {
19017
+ spawns.push(handler);
19018
+ }
19019
+ var spawned = /* @__PURE__ */ new Map();
19020
+ function seatPlayers(seating = {}) {
19021
+ const { team, respawn } = seating;
19022
+ const hero = seating.hero ?? "any";
19023
+ const wants = /* @__PURE__ */ new Map();
19024
+ const cast = new Cast({
19025
+ join(connection2) {
19026
+ const side = typeof team === "function" ? team(connection2) : team;
19027
+ wants.set(connection2, {
19028
+ hero,
19029
+ ...side === void 0 ? {} : { team: side },
19030
+ ...respawn === void 0 ? {} : { respawn }
19031
+ });
19032
+ return connection2;
19033
+ },
19034
+ leave(connection2) {
19035
+ wants.delete(connection2);
19036
+ },
19037
+ want: (connection2) => wants.get(connection2) ?? {}
19038
+ });
19039
+ onFrame(({ timeSeconds }) => cast.frame(timeSeconds));
19040
+ return cast;
19041
+ }
19042
+ function watchSpawns() {
19043
+ const present = /* @__PURE__ */ new Map();
19044
+ for (const { player } of players()) {
19045
+ const pawn = player.pawn();
19046
+ if (pawn === void 0 || pawn.hero === 0 || pawn.health <= 0) {
19047
+ continue;
19048
+ }
19049
+ present.set(player.slot, pawn.entity);
19050
+ if (spawned.get(player.slot) !== pawn.entity) {
19051
+ for (const handler of spawns) {
19052
+ handler(player, pawn);
19053
+ }
19054
+ }
19055
+ }
19056
+ spawned = present;
19057
+ }
18851
19058
  function onFrame(handler) {
18852
19059
  frames.push(handler);
18853
19060
  }
@@ -18896,6 +19103,7 @@ var frames = [];
18896
19103
  var chats = [];
18897
19104
  var joins = [];
18898
19105
  var leaves = [];
19106
+ var spawns = [];
18899
19107
  var worlds = [];
18900
19108
  var inputs = [];
18901
19109
  var restoreds = [];
@@ -18923,6 +19131,9 @@ var handlers = {
18923
19131
  tick(event.timeSeconds);
18924
19132
  advance(event.timeSeconds);
18925
19133
  advancePuppets(event.timeSeconds);
19134
+ if (spawns.length !== 0) {
19135
+ watchSpawns();
19136
+ }
18926
19137
  for (const handler of frames) {
18927
19138
  handler(event);
18928
19139
  }
@@ -19083,6 +19294,7 @@ export {
19083
19294
  cameraShake,
19084
19295
  clearMap,
19085
19296
  command,
19297
+ connection,
19086
19298
  createEntity,
19087
19299
  createFog,
19088
19300
  createModel,
@@ -19115,6 +19327,7 @@ export {
19115
19327
  handedOff,
19116
19328
  handoff,
19117
19329
  heroBuild,
19330
+ heroNamed,
19118
19331
  heroes,
19119
19332
  hide,
19120
19333
  hideHud,
@@ -19137,6 +19350,7 @@ export {
19137
19350
  log2 as log,
19138
19351
  matchClock,
19139
19352
  modifierState,
19353
+ modifiers,
19140
19354
  moveEntity,
19141
19355
  nextMatch,
19142
19356
  onChat,
@@ -19152,6 +19366,7 @@ export {
19152
19366
  onPlayerLeave,
19153
19367
  onRestored,
19154
19368
  onSettingChanged,
19369
+ onSpawn,
19155
19370
  onStart,
19156
19371
  onWorld,
19157
19372
  pause,
@@ -19180,6 +19395,7 @@ export {
19180
19395
  rosterKey,
19181
19396
  rosterRows,
19182
19397
  route,
19398
+ seatPlayers,
19183
19399
  sequence,
19184
19400
  serve,
19185
19401
  serveMod,