dredless 1.2.1 → 1.3.0

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.
@@ -4121,6 +4121,8 @@
4121
4121
  summarizeProjectile: () => summarizeProjectile,
4122
4122
  summarizePusher: () => summarizePusher,
4123
4123
  summarizePusherBeam: () => summarizePusherBeam,
4124
+ summarizePvpEvent: () => summarizePvpEvent,
4125
+ summarizePvpPartyEntry: () => summarizePvpPartyEntry,
4124
4126
  summarizeRcd: () => summarizeRcd,
4125
4127
  summarizeRecycler: () => summarizeRecycler,
4126
4128
  summarizeShieldGenerator: () => summarizeShieldGenerator,
@@ -4650,7 +4652,13 @@
4650
4652
  [2, { name: "numeric_pair", ...TWO_FIELD_SPEC }],
4651
4653
  [3, { name: "gate_width", fields: numericFields({ 1: 20, 2: 24, 4: 28, 8: 32, 16: 36, 32: 40 }) }],
4652
4654
  [4, { name: "motion_aux", packedBits: [{ bit: 8, offset: 33 }], fields: numericFields({ 1: 20, 2: 24, 4: 28 }) }],
4653
- [5, { name: "entity_health", fields: numericFields({ 1: 20, 2: 24, 4: 28, 8: 32 }) }],
4655
+ [5, {
4656
+ name: "entity_health",
4657
+ // The official table starts both bar dimensions at 10 (one world unit).
4658
+ // Field values on the wire are deltas relative to these defaults.
4659
+ defaults: { q28: 10, q32: 10 },
4660
+ fields: numericFields({ 1: 20, 2: 24, 4: 28, 8: 32 })
4661
+ }],
4654
4662
  [6, { name: "item_holder", ...TWO_FIELD_SPEC }],
4655
4663
  [7, {
4656
4664
  name: "entity_type",
@@ -4798,6 +4806,25 @@
4798
4806
  }],
4799
4807
  [26, { name: "numeric_single", fields: numericFields({ 1: 20 }) }],
4800
4808
  [31, { name: "numeric_single", fields: numericFields({ 1: 20 }) }],
4809
+ [32, {
4810
+ // Wire 95 has values; treating it as a marker swallows following removals.
4811
+ name: "numeric_triplet",
4812
+ defaults: { q28: 10 },
4813
+ fields: numericFields({ 1: 20, 2: 24, 4: 28 })
4814
+ }],
4815
+ [33, {
4816
+ name: "pvp_event",
4817
+ fields: numericFields({ 2: 20, 4: 24, 8: 28, 16: 32, 32: 36, 64: 40, 128: 44, 256: 48, 512: 52 })
4818
+ }],
4819
+ [34, { name: "pvp_party_config", fields: numericFields({ 2: 20 }) }],
4820
+ [35, {
4821
+ name: "pvp_party_entry",
4822
+ packedBeforeValues: true,
4823
+ orderedValues: true,
4824
+ packedBits: [{ bit: 4, offset: 37 }],
4825
+ blobs: [{ bit: 1, offset: 24 }],
4826
+ fields: numericFields({ 2: 20 })
4827
+ }],
4801
4828
  [37, { name: "loose_item_marker", packedBits: [{ bit: 2, offset: 29 }], fields: numericFields({ 1: 20, 4: 24 }) }],
4802
4829
  [38, { name: "flag_state", packedBits: [{ bit: 1, offset: 21 }], fields: [] }],
4803
4830
  [39, { name: "comms_transmit", ...TWO_FIELD_SPEC }],
@@ -4824,6 +4851,8 @@
4824
4851
  }],
4825
4852
  [54, {
4826
4853
  name: "starter_cannon",
4854
+ // Wire deltas start with both barrels fully extended and capacity 16.
4855
+ defaults: { q36: 50, q44: 16, q48: 50 },
4827
4856
  fields: numericFields({ 1: 20, 2: 32, 4: 24, 8: 28, 16: 44, 32: 36, 64: 48, 128: 52, 256: 40, 512: 56, 1024: 60 })
4828
4857
  }],
4829
4858
  [55, {
@@ -4958,6 +4987,9 @@
4958
4987
  [93, 30],
4959
4988
  [94, 31],
4960
4989
  [95, 32],
4990
+ [96, 33],
4991
+ [97, 34],
4992
+ [98, 35],
4961
4993
  [99, 36],
4962
4994
  [120, 37],
4963
4995
  [121, 38],
@@ -5005,7 +5037,7 @@
5005
5037
  [168, 78],
5006
5038
  [169, 77]
5007
5039
  ]);
5008
- var MASK_ONLY_TABLES = /* @__PURE__ */ new Set([13, 22, 23, 27, 28, 30, 32, 36, 40, 46, 48, 52, 58, 64, 65, 66, 68, 73, 74]);
5040
+ var MASK_ONLY_TABLES = /* @__PURE__ */ new Set([13, 22, 23, 27, 28, 30, 36, 40, 46, 48, 52, 58, 64, 65, 66, 68, 73, 74]);
5009
5041
  var ENTITY_FOOTPRINTS = /* @__PURE__ */ new Map([
5010
5042
  [240, { width: 2, height: 2 }],
5011
5043
  [247, { width: 2, height: 2 }],
@@ -5491,40 +5523,40 @@
5491
5523
  return "bot";
5492
5524
  }
5493
5525
  function isCowardBossState({ health }) {
5494
- return health?.state?.q28 === 70 && health?.state?.q32 === 78;
5526
+ return health?.state?.q28 === 80 && health?.state?.q32 === 88;
5495
5527
  }
5496
5528
  function isOrangeFoolBotState({ combatRecord }) {
5497
5529
  return combatRecord?.q20 === -427551232 && combatRecord?.q24 === 1 && combatRecord?.q72 === 3;
5498
5530
  }
5499
5531
  function isZombieBossBotState({ health, table2Record, combatRecord }) {
5500
- return combatRecord?.q20 === -430233088 && health?.state?.q28 === 30 && health?.state?.q32 === 166 && table2Record?.q20 === 320 && table2Record?.q24 === -900;
5532
+ return combatRecord?.q20 === -430233088 && health?.state?.q28 === 40 && health?.state?.q32 === 176 && table2Record?.q20 === 320 && table2Record?.q24 === -900;
5501
5533
  }
5502
5534
  function isRedSentryBotState({ health, table2Record, combatRecord }) {
5503
- return combatRecord?.q20 === 508251904 && combatRecord?.q72 === 2 || health?.state?.q28 === 70 && health?.state?.q32 === 166 && table2Record?.q20 === 320 && table2Record?.q24 === -900;
5535
+ return combatRecord?.q20 === 508251904 && combatRecord?.q72 === 2 || health?.state?.q28 === 80 && health?.state?.q32 === 176 && table2Record?.q20 === 320 && table2Record?.q24 === -900;
5504
5536
  }
5505
5537
  function isBlueRusherBotState({ health, table2Record, combatRecord }) {
5506
- return combatRecord?.q20 === 1113052928 && combatRecord?.q72 === 2 || health?.state?.q28 === 30 && health?.state?.q32 === 34 && table2Record?.q20 === 80 && table2Record?.q24 === -900;
5538
+ return combatRecord?.q20 === 1113052928 && combatRecord?.q72 === 2 || health?.state?.q28 === 40 && health?.state?.q32 === 44 && table2Record?.q20 === 80 && table2Record?.q24 === -900;
5507
5539
  }
5508
5540
  function isRedSniperBotState({ health, table2Record }) {
5509
- return health?.state?.q28 === 35 && health?.state?.q32 === 89 && table2Record?.q20 === 180 && table2Record?.q24 === -900;
5541
+ return health?.state?.q28 === 45 && health?.state?.q32 === 99 && table2Record?.q20 === 180 && table2Record?.q24 === -900;
5510
5542
  }
5511
5543
  function isYellowHunterBotState({ health, table2Record, combatRecord }) {
5512
- return combatRecord?.q20 === -775665152 && combatRecord?.q72 === 4 && combatRecord?.q44 === -944515328 || health?.state?.q28 === 30 && health?.state?.q32 === 56 && table2Record?.q20 === 120 && table2Record?.q24 === -900;
5544
+ return combatRecord?.q20 === -775665152 && combatRecord?.q72 === 4 && combatRecord?.q44 === -944515328 || health?.state?.q28 === 40 && health?.state?.q32 === 66 && table2Record?.q20 === 120 && table2Record?.q24 === -900;
5513
5545
  }
5514
5546
  function isAquaShielderBotState({ health, table2Record, combatRecord }) {
5515
- return combatRecord?.q20 === 13697024 && combatRecord?.q24 === 1 || health?.state?.q28 === 50 && health?.state?.q32 === 122 && table2Record?.q20 === 240 && table2Record?.q24 === -900;
5547
+ return combatRecord?.q20 === 13697024 && combatRecord?.q24 === 1 || health?.state?.q28 === 60 && health?.state?.q32 === 132 && table2Record?.q20 === 240 && table2Record?.q24 === -900;
5516
5548
  }
5517
5549
  function isLazerEnthusiastBotState({ health, table2Record, table10Record, beamRecord }) {
5518
- return health?.state?.q28 === 140 && health?.state?.q32 === 155 && table2Record?.q20 === 300 && table2Record?.q24 === -900 && Boolean(table10Record) && Boolean(beamRecord);
5550
+ return health?.state?.q28 === 150 && health?.state?.q32 === 165 && table2Record?.q20 === 300 && table2Record?.q24 === -900 && Boolean(table10Record) && Boolean(beamRecord);
5519
5551
  }
5520
5552
  function isYellowMineGuardBotState({ health, smallRecord, combatRecord, table2Record }) {
5521
- return health?.state?.q28 === 30 && health?.state?.q32 === 33 && smallRecord?.q20 === 78 && smallRecord?.q24 === 78 && combatRecord?.q24 === -995542016 && !table2Record;
5553
+ return health?.state?.q28 === 40 && health?.state?.q32 === 43 && smallRecord?.q20 === 78 && smallRecord?.q24 === 78 && combatRecord?.q24 === -995542016 && !table2Record;
5522
5554
  }
5523
5555
  function isShieldHelperBotState({ health, table2Record }) {
5524
- return health?.state?.q28 === 30 && health?.state?.q32 === 33 && health?.maxHp === 1e3 && !table2Record;
5556
+ return health?.state?.q28 === 40 && health?.state?.q32 === 43 && health?.maxHp === 1e3 && !table2Record;
5525
5557
  }
5526
5558
  function isShieldMasterBotState({ health, table2Record }) {
5527
- return health?.state?.q28 === 190 && health?.state?.q32 === 210 && health?.maxHp === 15e3 && Boolean(table2Record);
5559
+ return health?.state?.q28 === 200 && health?.state?.q32 === 220 && health?.maxHp === 15e3 && Boolean(table2Record);
5528
5560
  }
5529
5561
  function botIdentifierFromState({ combatRecord, motionRecord, smallRecord }) {
5530
5562
  if (combatRecord) return `t18:${combatRecord.q20 ?? "-"}:${combatRecord.q24 ?? "-"}:${combatRecord.q72 ?? "-"}`;
@@ -5609,6 +5641,36 @@
5609
5641
  state: cloneRecord(record)
5610
5642
  };
5611
5643
  }
5644
+ function summarizePvpEvent(entity, record, shipsLeft) {
5645
+ if (!record) return null;
5646
+ const damageBonusPercent = record.q52 ?? 0;
5647
+ return {
5648
+ entity,
5649
+ active: (record.q44 ?? 0) >= 0,
5650
+ bounds: {
5651
+ minX: (record.q20 ?? 0) / 10,
5652
+ minY: (record.q24 ?? 0) / 10,
5653
+ maxX: (record.q28 ?? 0) / 10,
5654
+ maxY: (record.q32 ?? 0) / 10
5655
+ },
5656
+ worldBounds: { minX: 0, minY: 0, maxX: record.q36 ?? 0, maxY: record.q40 ?? 0 },
5657
+ timeSeconds: record.q44 ?? 0,
5658
+ damageBonusPercent,
5659
+ damagePercent: damageBonusPercent + 100,
5660
+ damageMultiplier: (damageBonusPercent + 100) / 100,
5661
+ shipsLeft,
5662
+ state: cloneRecord(record)
5663
+ };
5664
+ }
5665
+ function summarizePvpPartyEntry(entity, record) {
5666
+ return {
5667
+ entity,
5668
+ partyId: record.q20 ?? 0,
5669
+ hexCode: decodeText(record.blob24),
5670
+ kind: record.q37 ? "join-request" : "invitation",
5671
+ state: cloneRecord(record)
5672
+ };
5673
+ }
5612
5674
  function summarizeShipSize(entity, record) {
5613
5675
  if (!record) return null;
5614
5676
  return {
@@ -6237,6 +6299,8 @@
6237
6299
  botIdentifierFromState: botIdentifierFromState2,
6238
6300
  summarizeShieldGenerator: summarizeShieldGenerator2,
6239
6301
  summarizeShipControl: summarizeShipControl2,
6302
+ summarizePvpEvent: summarizePvpEvent2,
6303
+ summarizePvpPartyEntry: summarizePvpPartyEntry2,
6240
6304
  summarizeShipSize: summarizeShipSize2,
6241
6305
  summarizeShipWorldMetadata: summarizeShipWorldMetadata2,
6242
6306
  summarizeItemCrate: summarizeItemCrate2,
@@ -6407,6 +6471,8 @@
6407
6471
  balls: derived.specialEntities.balls.slice(),
6408
6472
  recyclers: derived.specialEntities.recyclers.slice(),
6409
6473
  shipControls: derived.shipControls.slice(),
6474
+ pvpEvent: this.pvpEvent(),
6475
+ pvpParties: this.pvpParties(),
6410
6476
  machines: this.#machinesSnapshot(derived.machines),
6411
6477
  tables: includeTables ? this.tablesSnapshot() : derived.tableSummaries.slice()
6412
6478
  };
@@ -6448,6 +6514,26 @@
6448
6514
  shipControls() {
6449
6515
  return this.#derivedState().shipControls.slice();
6450
6516
  }
6517
+ pvpEvent() {
6518
+ const entry = this.table(33).entries().next().value;
6519
+ if (!entry) return null;
6520
+ let shipsLeft = 0;
6521
+ for (const ship of this.table(20).values()) {
6522
+ if (!ship.q153) shipsLeft += 1;
6523
+ }
6524
+ return summarizePvpEvent2(entry[0], entry[1], shipsLeft);
6525
+ }
6526
+ pvpParties() {
6527
+ const config = this.table(34).entries().next().value;
6528
+ const entries = this.table(35);
6529
+ if (!config && entries.size === 0) return null;
6530
+ return {
6531
+ configEntity: config?.[0] ?? null,
6532
+ maxShips: config ? config[1].q20 ?? 0 : 35,
6533
+ entries: [...entries].map(([entity, record]) => summarizePvpPartyEntry2(entity, record)),
6534
+ configState: config ? cloneRecord2(config[1]) : null
6535
+ };
6536
+ }
6451
6537
  shipMetadata() {
6452
6538
  if (this.isOverworld) return null;
6453
6539
  const lockdownRecord = firstRecord2(this.table(11));
@@ -7716,6 +7802,8 @@
7716
7802
  balls: model.balls,
7717
7803
  recyclers: model.recyclers,
7718
7804
  shipControls: model.shipControls,
7805
+ pvpEvent: model.pvpEvent,
7806
+ pvpParties: model.pvpParties,
7719
7807
  commsBubbles: this.commsBubbles.slice(),
7720
7808
  tiles: includeTiles ? [...this.tiles.values()] : void 0
7721
7809
  };
@@ -8796,6 +8884,23 @@
8796
8884
  return typeof data === "string" ? JSON.parse(data) : decodeMsgpack(toUint8Array(data));
8797
8885
  }
8798
8886
 
8887
+ // src/protocol/outbound/pvp.js
8888
+ var TARGETED_KINDS = /* @__PURE__ */ new Set(["Join", "Invite", "Kick", "JoinCancel", "InviteCancel"]);
8889
+ function requireHexCode(value) {
8890
+ if (typeof value !== "string") throw new TypeError("hexCode must be a ship hex code string");
8891
+ const hexCode = value.trim();
8892
+ if (!/^[0-9a-f]+$/i.test(hexCode)) throw new RangeError("hexCode must contain hexadecimal digits");
8893
+ return hexCode;
8894
+ }
8895
+ function buildPvpPartyMessage(kind, hexCode) {
8896
+ if (kind === "NewTeam" || kind === "Leave") {
8897
+ if (hexCode !== void 0) throw new TypeError(`${kind} does not take a ship hex code`);
8898
+ return { type: 10, info: { kind } };
8899
+ }
8900
+ if (!TARGETED_KINDS.has(kind)) throw new RangeError("unsupported PvP party command kind");
8901
+ return { type: 10, info: { kind, hex: requireHexCode(hexCode) } };
8902
+ }
8903
+
8799
8904
  // src/client/domains/index.js
8800
8905
  function normalizeAttachMode(mode = "observe") {
8801
8906
  const value = String(mode || "observe").toLowerCase();
@@ -9145,6 +9250,55 @@
9145
9250
  return worldStateFor(this.client, this.scope)?.snapshot(options) || null;
9146
9251
  }
9147
9252
  };
9253
+ var PvpEventDomain = class {
9254
+ constructor(client) {
9255
+ this.client = client;
9256
+ }
9257
+ state() {
9258
+ return this.#read("pvpEvent");
9259
+ }
9260
+ parties() {
9261
+ return this.#read("pvpParties");
9262
+ }
9263
+ #read(method) {
9264
+ const overworld = this.client.worlds.overworld();
9265
+ const summary = overworld?.model[method]();
9266
+ if (summary != null) return summary;
9267
+ for (const world of this.client.worlds.worlds.values()) {
9268
+ if (world === overworld) continue;
9269
+ const value = world.model[method]();
9270
+ if (value != null) return value;
9271
+ }
9272
+ return null;
9273
+ }
9274
+ createParty() {
9275
+ return this.client.sendMessage(buildPvpPartyMessage("NewTeam"));
9276
+ }
9277
+ leaveParty() {
9278
+ return this.client.sendMessage(buildPvpPartyMessage("Leave"));
9279
+ }
9280
+ joinParty(hexCode) {
9281
+ return this.client.sendMessage(buildPvpPartyMessage("Join", hexCode));
9282
+ }
9283
+ inviteShip(hexCode) {
9284
+ return this.client.sendMessage(buildPvpPartyMessage("Invite", hexCode));
9285
+ }
9286
+ acceptInvitation(hexCode) {
9287
+ return this.joinParty(hexCode);
9288
+ }
9289
+ acceptJoinRequest(hexCode) {
9290
+ return this.inviteShip(hexCode);
9291
+ }
9292
+ kickShip(hexCode) {
9293
+ return this.client.sendMessage(buildPvpPartyMessage("Kick", hexCode));
9294
+ }
9295
+ cancelJoinRequest(hexCode) {
9296
+ return this.client.sendMessage(buildPvpPartyMessage("JoinCancel", hexCode));
9297
+ }
9298
+ cancelInvitation(hexCode) {
9299
+ return this.client.sendMessage(buildPvpPartyMessage("InviteCancel", hexCode));
9300
+ }
9301
+ };
9148
9302
  var ShipDomain = class extends WorldDomain {
9149
9303
  entity() {
9150
9304
  const summary = this.client.worlds.currentShipEntity();
@@ -10388,6 +10542,7 @@
10388
10542
  this.inventory = new InventoryDomain(this);
10389
10543
  this.tips = new TipDomain(this);
10390
10544
  this.management = new ShipManagementDomain(this);
10545
+ this.pvpEvent = new PvpEventDomain(this);
10391
10546
  this.cpuLoad = null;
10392
10547
  this.inventoryState = normalizeInventoryEvent({ type: "inventory", general_slots: 5 });
10393
10548
  this.puiPanels = /* @__PURE__ */ new Map();