@modlock/modlock 0.1.79 → 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.
Files changed (3) hide show
  1. package/host.gen.d.ts +45 -0
  2. package/index.js +148 -0
  3. package/package.json +6 -6
package/host.gen.d.ts CHANGED
@@ -102,6 +102,44 @@ export interface AbilityOptions {
102
102
  */
103
103
  maxCharges?: number;
104
104
  }
105
+ /** Modifier is one modifier an entity holds, as the game keeps it. */
106
+ export interface Modifier {
107
+ /**
108
+ * name is the modifier's name, such as modifier_citadel_knockdown, as
109
+ * GiveModifier and ReadModifierField name it. It is empty when the game
110
+ * keeps no readable name.
111
+ */
112
+ readonly name: string;
113
+ /**
114
+ * className is the modifier's server class, such as
115
+ * CCitadel_Modifier_Knockdown, which ReadModifierField takes. Several
116
+ * names can share a class.
117
+ */
118
+ readonly className: string;
119
+ /**
120
+ * caster is the handle of the entity that applied it, such as the hero
121
+ * whose ability did, or 0 when none did.
122
+ */
123
+ readonly caster: number;
124
+ /**
125
+ * ability is the handle of the ability that applied it, or 0 when none did.
126
+ */
127
+ readonly ability: number;
128
+ /** age is how many seconds ago the game created it. */
129
+ readonly age: number;
130
+ /**
131
+ * remaining is how many seconds it has left since it was last applied. It
132
+ * is absent for a modifier that lasts until something removes it.
133
+ */
134
+ readonly remaining?: number;
135
+ /** stacks and maxStacks count its stacks, for a modifier that stacks. */
136
+ readonly stacks: number;
137
+ readonly maxStacks: number;
138
+ /** team is the team number it belongs to. */
139
+ readonly team: number;
140
+ /** disabled is true while the game keeps it without its effects. */
141
+ readonly disabled: boolean;
142
+ }
105
143
  /** BuildCategory is one named group of a build's items. */
106
144
  export interface BuildCategory {
107
145
  /** name is the category's title. */
@@ -1897,6 +1935,13 @@ export declare function entityPosition(entity: number): EntityPlacement | undefi
1897
1935
  * MODIFIER_STATE_PARRY_ACTIVE.
1898
1936
  */
1899
1937
  export declare function modifierState(entity: number, state: string): boolean;
1938
+ /**
1939
+ * modifiers lists every modifier an entity holds, such as the stun a
1940
+ * hero's ultimate keeps on its target, with its name, class, caster,
1941
+ * ability, age, time left and stacks. An entity that holds none answers an
1942
+ * empty list.
1943
+ */
1944
+ export declare function modifiers(entity: number): Modifier[];
1900
1945
  /**
1901
1946
  * holdModifierState holds a modifier state, such as
1902
1947
  * MODIFIER_STATE_FRIENDLY_FIRE_ENABLED, on an entity while the mod runs, or
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
  () => [
@@ -13128,6 +13255,20 @@ function toAbilityOptions(value) {
13128
13255
  maxCharges: value.maxCharges === void 0 ? void 0 : int32(value.maxCharges)
13129
13256
  };
13130
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
+ }
13131
13272
  function fromBuildCategory(message) {
13132
13273
  return {
13133
13274
  name: message.name ?? "",
@@ -14345,6 +14486,12 @@ function modifierState(entity, state) {
14345
14486
  const response = ActiveResponse.fromBinary(reply2);
14346
14487
  return response.active ?? false;
14347
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
+ }
14348
14495
  function holdModifierState(entity, state, active) {
14349
14496
  return call("HoldModifierState", HoldModifierStateRequest.toBinary({ entity, state, active })) !== void 0;
14350
14497
  }
@@ -19203,6 +19350,7 @@ export {
19203
19350
  log2 as log,
19204
19351
  matchClock,
19205
19352
  modifierState,
19353
+ modifiers,
19206
19354
  moveEntity,
19207
19355
  nextMatch,
19208
19356
  onChat,
package/package.json CHANGED
@@ -7,11 +7,11 @@
7
7
  "license": "MIT",
8
8
  "name": "@modlock/modlock",
9
9
  "optionalDependencies": {
10
- "@modlock/darwin-arm64": "0.1.79",
11
- "@modlock/darwin-x64": "0.1.79",
12
- "@modlock/linux-arm64": "0.1.79",
13
- "@modlock/linux-x64": "0.1.79",
14
- "@modlock/win32-x64": "0.1.79"
10
+ "@modlock/darwin-arm64": "0.1.80",
11
+ "@modlock/darwin-x64": "0.1.80",
12
+ "@modlock/linux-arm64": "0.1.80",
13
+ "@modlock/linux-x64": "0.1.80",
14
+ "@modlock/win32-x64": "0.1.80"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
@@ -20,5 +20,5 @@
20
20
  "sideEffects": false,
21
21
  "type": "module",
22
22
  "types": "index.d.ts",
23
- "version": "0.1.79"
23
+ "version": "0.1.80"
24
24
  }