quake2ts 0.0.288 → 0.0.290

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 (52) hide show
  1. package/package.json +1 -1
  2. package/packages/client/dist/browser/index.global.js +13 -13
  3. package/packages/client/dist/browser/index.global.js.map +1 -1
  4. package/packages/client/dist/cjs/index.cjs +554 -2
  5. package/packages/client/dist/cjs/index.cjs.map +1 -1
  6. package/packages/client/dist/esm/index.js +554 -2
  7. package/packages/client/dist/esm/index.js.map +1 -1
  8. package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
  9. package/packages/engine/dist/browser/index.global.js +16 -16
  10. package/packages/engine/dist/browser/index.global.js.map +1 -1
  11. package/packages/engine/dist/cjs/index.cjs +360 -35
  12. package/packages/engine/dist/cjs/index.cjs.map +1 -1
  13. package/packages/engine/dist/esm/index.js +360 -35
  14. package/packages/engine/dist/esm/index.js.map +1 -1
  15. package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
  16. package/packages/engine/dist/types/audio/constants.d.ts +1 -23
  17. package/packages/engine/dist/types/audio/constants.d.ts.map +1 -1
  18. package/packages/game/dist/browser/index.global.js +3 -3
  19. package/packages/game/dist/browser/index.global.js.map +1 -1
  20. package/packages/game/dist/cjs/index.cjs +556 -19
  21. package/packages/game/dist/cjs/index.cjs.map +1 -1
  22. package/packages/game/dist/esm/index.js +556 -19
  23. package/packages/game/dist/esm/index.js.map +1 -1
  24. package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
  25. package/packages/game/dist/types/entities/monsters/actor.d.ts.map +1 -1
  26. package/packages/game/dist/types/entities/monsters/arachnid.d.ts.map +1 -1
  27. package/packages/game/dist/types/entities/system.d.ts +1 -0
  28. package/packages/game/dist/types/entities/system.d.ts.map +1 -1
  29. package/packages/game/dist/types/index.d.ts +2 -0
  30. package/packages/game/dist/types/index.d.ts.map +1 -1
  31. package/packages/server/dist/index.cjs +54 -11
  32. package/packages/server/dist/index.d.cts +6 -1
  33. package/packages/server/dist/index.d.ts +6 -1
  34. package/packages/server/dist/index.js +56 -13
  35. package/packages/shared/dist/browser/index.global.js +1 -1
  36. package/packages/shared/dist/browser/index.global.js.map +1 -1
  37. package/packages/shared/dist/cjs/index.cjs +562 -0
  38. package/packages/shared/dist/cjs/index.cjs.map +1 -1
  39. package/packages/shared/dist/esm/index.js +549 -0
  40. package/packages/shared/dist/esm/index.js.map +1 -1
  41. package/packages/shared/dist/tsconfig.tsbuildinfo +1 -1
  42. package/packages/shared/dist/types/audio/constants.d.ts +24 -0
  43. package/packages/shared/dist/types/audio/constants.d.ts.map +1 -0
  44. package/packages/shared/dist/types/index.d.ts +1 -0
  45. package/packages/shared/dist/types/index.d.ts.map +1 -1
  46. package/packages/shared/dist/types/net/index.d.ts +1 -0
  47. package/packages/shared/dist/types/net/index.d.ts.map +1 -1
  48. package/packages/shared/dist/types/protocol/crc.d.ts +5 -0
  49. package/packages/shared/dist/types/protocol/crc.d.ts.map +1 -0
  50. package/packages/shared/dist/types/protocol/index.d.ts +1 -0
  51. package/packages/shared/dist/types/protocol/index.d.ts.map +1 -1
  52. package/packages/tools/dist/tsconfig.tsbuildinfo +1 -1
@@ -434,7 +434,7 @@ function G_SetPowerupStat(stats, powerupId, val) {
434
434
  if (safeVal < 0) safeVal = 0;
435
435
  setCompressedInteger(stats, 41, index, safeVal, NUM_BITS_FOR_POWERUP);
436
436
  }
437
- var __defProp2, __export2, ZERO_VEC3, STOP_EPSILON, DEG_TO_RAD, PITCH, YAW, ROLL, DEG2RAD_FACTOR, RAD2DEG_FACTOR, STATE_SIZE, MIDDLE_WORD, MATRIX_A, UPPER_MASK, LOWER_MASK, TWO_POW_32, MersenneTwister19937, RandomGenerator, CONTENTS_SOLID, CONTENTS_WINDOW, CONTENTS_AUX, CONTENTS_LAVA, CONTENTS_SLIME, CONTENTS_WATER, CONTENTS_MIST, CONTENTS_NO_WATERJUMP, CONTENTS_PROJECTILECLIP, CONTENTS_AREAPORTAL, CONTENTS_PLAYERCLIP, CONTENTS_MONSTERCLIP, CONTENTS_CURRENT_0, CONTENTS_CURRENT_90, CONTENTS_CURRENT_180, CONTENTS_CURRENT_270, CONTENTS_CURRENT_UP, CONTENTS_CURRENT_DOWN, CONTENTS_ORIGIN, CONTENTS_MONSTER, CONTENTS_DEADMONSTER, CONTENTS_DETAIL, CONTENTS_TRANSLUCENT, CONTENTS_LADDER, CONTENTS_PLAYER, CONTENTS_PROJECTILE, SURF_LIGHT, SURF_SLICK, SURF_SKY, SURF_WARP, SURF_TRANS33, SURF_TRANS66, SURF_FLOWING, SURF_NODRAW, SURF_ALPHATEST, SURF_N64_UV, SURF_N64_SCROLL_X, SURF_N64_SCROLL_Y, SURF_N64_SCROLL_FLIP, MASK_SOLID, MASK_PLAYERSOLID, MASK_DEADSOLID, MASK_MONSTERSOLID, MASK_WATER, MASK_OPAQUE, MASK_SHOT, MASK_CURRENT, MASK_BLOCK_SIGHT, MASK_NAV_SOLID, MASK_LADDER_NAV_SOLID, MASK_WALK_NAV_SOLID, MASK_PROJECTILE, MAX_CHECKCOUNT, CvarFlags, MAX_CLIENTS, MAX_LIGHTSTYLES, MAX_MODELS, MAX_SOUNDS, MAX_IMAGES, MAX_ITEMS, MAX_GENERAL, MAX_SHADOW_LIGHTS, MAX_WHEEL_ITEMS, ConfigStringIndex, MAX_CONFIGSTRINGS, replay_exports, WaterLevel, WATERJUMP_CLEAR, ServerCommand, TempEntity, MZ_BLASTER, MZ_MACHINEGUN, MZ_SHOTGUN, MZ_CHAINGUN1, MZ_RAILGUN, MZ_ROCKET, MZ_GRENADE, MZ_SSHOTGUN, MZ_BFG, MZ_HYPERBLASTER, PowerupId, PlayerStat, AMMO_MAX, NUM_BITS_FOR_AMMO, NUM_AMMO_STATS, POWERUP_MAX, NUM_BITS_FOR_POWERUP, NUM_POWERUP_STATS, POWERUP_STAT_MAP, RenderFx, entityFlags_exports, U_NUMBER, U_MODEL, U_SOUND, U_ORIGIN1, U_ORIGIN2, U_ORIGIN3, U_ANGLE1, U_ANGLE2, U_ANGLE3, U_FRAME, U_SKIN, U_EFFECTS, U_RENDERFX, U_SOLID, U_EVENT, U_MOREBITS, U_MODEL2, U_MODEL3, U_MODEL4, U_REMOVE, FRAMETIME, MASK_WATER2, WaterLevel3, categorizePosition2, checkWater, applyPmove, WeaponId, AmmoType, AMMO_TYPE_COUNT, AmmoItemId, WEAPON_WHEEL_ORDER;
437
+ var __defProp2, __export2, ZERO_VEC3, STOP_EPSILON, DEG_TO_RAD, PITCH, YAW, ROLL, DEG2RAD_FACTOR, RAD2DEG_FACTOR, ANORMS, STATE_SIZE, MIDDLE_WORD, MATRIX_A, UPPER_MASK, LOWER_MASK, TWO_POW_32, MersenneTwister19937, RandomGenerator, CONTENTS_SOLID, CONTENTS_WINDOW, CONTENTS_AUX, CONTENTS_LAVA, CONTENTS_SLIME, CONTENTS_WATER, CONTENTS_MIST, CONTENTS_NO_WATERJUMP, CONTENTS_PROJECTILECLIP, CONTENTS_AREAPORTAL, CONTENTS_PLAYERCLIP, CONTENTS_MONSTERCLIP, CONTENTS_CURRENT_0, CONTENTS_CURRENT_90, CONTENTS_CURRENT_180, CONTENTS_CURRENT_270, CONTENTS_CURRENT_UP, CONTENTS_CURRENT_DOWN, CONTENTS_ORIGIN, CONTENTS_MONSTER, CONTENTS_DEADMONSTER, CONTENTS_DETAIL, CONTENTS_TRANSLUCENT, CONTENTS_LADDER, CONTENTS_PLAYER, CONTENTS_PROJECTILE, SURF_LIGHT, SURF_SLICK, SURF_SKY, SURF_WARP, SURF_TRANS33, SURF_TRANS66, SURF_FLOWING, SURF_NODRAW, SURF_ALPHATEST, SURF_N64_UV, SURF_N64_SCROLL_X, SURF_N64_SCROLL_Y, SURF_N64_SCROLL_FLIP, MASK_SOLID, MASK_PLAYERSOLID, MASK_DEADSOLID, MASK_MONSTERSOLID, MASK_WATER, MASK_OPAQUE, MASK_SHOT, MASK_CURRENT, MASK_BLOCK_SIGHT, MASK_NAV_SOLID, MASK_LADDER_NAV_SOLID, MASK_WALK_NAV_SOLID, MASK_PROJECTILE, MAX_CHECKCOUNT, CvarFlags, MAX_CLIENTS, MAX_LIGHTSTYLES, MAX_MODELS, MAX_SOUNDS, MAX_IMAGES, MAX_ITEMS, MAX_GENERAL, MAX_SHADOW_LIGHTS, MAX_WHEEL_ITEMS, ConfigStringIndex, MAX_CONFIGSTRINGS, replay_exports, WaterLevel, WATERJUMP_CLEAR, ServerCommand, TempEntity, MZ_BLASTER, MZ_MACHINEGUN, MZ_SHOTGUN, MZ_CHAINGUN1, MZ_RAILGUN, MZ_ROCKET, MZ_GRENADE, MZ_SSHOTGUN, MZ_BFG, MZ_HYPERBLASTER, PowerupId, PlayerStat, AMMO_MAX, NUM_BITS_FOR_AMMO, NUM_AMMO_STATS, POWERUP_MAX, NUM_BITS_FOR_POWERUP, NUM_POWERUP_STATS, POWERUP_STAT_MAP, RenderFx, entityFlags_exports, U_NUMBER, U_MODEL, U_SOUND, U_ORIGIN1, U_ORIGIN2, U_ORIGIN3, U_ANGLE1, U_ANGLE2, U_ANGLE3, U_FRAME, U_SKIN, U_EFFECTS, U_RENDERFX, U_SOLID, U_EVENT, U_MOREBITS, U_MODEL2, U_MODEL3, U_MODEL4, U_REMOVE, FRAMETIME, MASK_WATER2, WaterLevel3, categorizePosition2, checkWater, applyPmove, BinaryWriter, _NetChan, WeaponId, AmmoType, AMMO_TYPE_COUNT, AmmoItemId, WEAPON_WHEEL_ORDER, SoundChannel, ATTN_NORM, ATTN_IDLE;
438
438
  var init_esm = __esm({
439
439
  "../shared/dist/esm/index.js"() {
440
440
  "use strict";
@@ -451,6 +451,170 @@ var init_esm = __esm({
451
451
  ROLL = 2;
452
452
  DEG2RAD_FACTOR = Math.PI / 180;
453
453
  RAD2DEG_FACTOR = 180 / Math.PI;
454
+ ANORMS = [
455
+ [-0.525731, 0, 0.850651],
456
+ [-0.442863, 0.238856, 0.864188],
457
+ [-0.295242, 0, 0.955423],
458
+ [-0.309017, 0.5, 0.809017],
459
+ [-0.16246, 0.262866, 0.951056],
460
+ [0, 0, 1],
461
+ [0, 0.850651, 0.525731],
462
+ [-0.147621, 0.716567, 0.681718],
463
+ [0.147621, 0.716567, 0.681718],
464
+ [0, 0.525731, 0.850651],
465
+ [0.309017, 0.5, 0.809017],
466
+ [0.525731, 0, 0.850651],
467
+ [0.295242, 0, 0.955423],
468
+ [0.442863, 0.238856, 0.864188],
469
+ [0.16246, 0.262866, 0.951056],
470
+ [-0.681718, 0.147621, 0.716567],
471
+ [-0.809017, 0.309017, 0.5],
472
+ [-0.587785, 0.425325, 0.688191],
473
+ [-0.850651, 0.525731, 0],
474
+ [-0.864188, 0.442863, 0.238856],
475
+ [-0.716567, 0.681718, 0.147621],
476
+ [-0.688191, 0.587785, 0.425325],
477
+ [-0.5, 0.809017, 0.309017],
478
+ [-0.238856, 0.864188, 0.442863],
479
+ [-0.425325, 0.688191, 0.587785],
480
+ [-0.716567, 0.681718, -0.147621],
481
+ [-0.5, 0.809017, -0.309017],
482
+ [-0.525731, 0.850651, 0],
483
+ [0, 0.850651, -0.525731],
484
+ [-0.238856, 0.864188, -0.442863],
485
+ [0, 0.955423, -0.295242],
486
+ [-0.262866, 0.951056, -0.16246],
487
+ [0, 1, 0],
488
+ [0, 0.955423, 0.295242],
489
+ [-0.262866, 0.951056, 0.16246],
490
+ [0.238856, 0.864188, 0.442863],
491
+ [0.262866, 0.951056, 0.16246],
492
+ [0.5, 0.809017, 0.309017],
493
+ [0.238856, 0.864188, -0.442863],
494
+ [0.262866, 0.951056, -0.16246],
495
+ [0.5, 0.809017, -0.309017],
496
+ [0.850651, 0.525731, 0],
497
+ [0.716567, 0.681718, 0.147621],
498
+ [0.716567, 0.681718, -0.147621],
499
+ [0.525731, 0.850651, 0],
500
+ [0.425325, 0.688191, 0.587785],
501
+ [0.864188, 0.442863, 0.238856],
502
+ [0.688191, 0.587785, 0.425325],
503
+ [0.809017, 0.309017, 0.5],
504
+ [0.681718, 0.147621, 0.716567],
505
+ [0.587785, 0.425325, 0.688191],
506
+ [0.955423, 0.295242, 0],
507
+ [1, 0, 0],
508
+ [0.951056, 0.16246, 0.262866],
509
+ [0.850651, -0.525731, 0],
510
+ [0.955423, -0.295242, 0],
511
+ [0.864188, -0.442863, 0.238856],
512
+ [0.951056, -0.16246, 0.262866],
513
+ [0.809017, -0.309017, 0.5],
514
+ [0.681718, -0.147621, 0.716567],
515
+ [0.850651, 0, 0.525731],
516
+ [0.864188, 0.442863, -0.238856],
517
+ [0.809017, 0.309017, -0.5],
518
+ [0.951056, 0.16246, -0.262866],
519
+ [0.525731, 0, -0.850651],
520
+ [0.681718, 0.147621, -0.716567],
521
+ [0.681718, -0.147621, -0.716567],
522
+ [0.850651, 0, -0.525731],
523
+ [0.809017, -0.309017, -0.5],
524
+ [0.864188, -0.442863, -0.238856],
525
+ [0.951056, -0.16246, -0.262866],
526
+ [0.147621, 0.716567, -0.681718],
527
+ [0.309017, 0.5, -0.809017],
528
+ [0.425325, 0.688191, -0.587785],
529
+ [0.442863, 0.238856, -0.864188],
530
+ [0.587785, 0.425325, -0.688191],
531
+ [0.688191, 0.587785, -0.425325],
532
+ [-0.147621, 0.716567, -0.681718],
533
+ [-0.309017, 0.5, -0.809017],
534
+ [0, 0.525731, -0.850651],
535
+ [-0.525731, 0, -0.850651],
536
+ [-0.442863, 0.238856, -0.864188],
537
+ [-0.295242, 0, -0.955423],
538
+ [-0.16246, 0.262866, -0.951056],
539
+ [0, 0, -1],
540
+ [0.295242, 0, -0.955423],
541
+ [0.16246, 0.262866, -0.951056],
542
+ [-0.442863, -0.238856, -0.864188],
543
+ [-0.309017, -0.5, -0.809017],
544
+ [-0.16246, -0.262866, -0.951056],
545
+ [0, -0.850651, -0.525731],
546
+ [-0.147621, -0.716567, -0.681718],
547
+ [0.147621, -0.716567, -0.681718],
548
+ [0, -0.525731, -0.850651],
549
+ [0.309017, -0.5, -0.809017],
550
+ [0.442863, -0.238856, -0.864188],
551
+ [0.16246, -0.262866, -0.951056],
552
+ [0.238856, -0.864188, -0.442863],
553
+ [0.5, -0.809017, -0.309017],
554
+ [0.425325, -0.688191, -0.587785],
555
+ [0.716567, -0.681718, -0.147621],
556
+ [0.688191, -0.587785, -0.425325],
557
+ [0.587785, -0.425325, -0.688191],
558
+ [0, -0.955423, -0.295242],
559
+ [0, -1, 0],
560
+ [0.262866, -0.951056, -0.16246],
561
+ [0, -0.850651, 0.525731],
562
+ [0, -0.955423, 0.295242],
563
+ [0.238856, -0.864188, 0.442863],
564
+ [0.262866, -0.951056, 0.16246],
565
+ [0.5, -0.809017, 0.309017],
566
+ [0.716567, -0.681718, 0.147621],
567
+ [0.525731, -0.850651, 0],
568
+ [-0.238856, -0.864188, -0.442863],
569
+ [-0.5, -0.809017, -0.309017],
570
+ [-0.262866, -0.951056, -0.16246],
571
+ [-0.850651, -0.525731, 0],
572
+ [-0.716567, -0.681718, -0.147621],
573
+ [-0.716567, -0.681718, 0.147621],
574
+ [-0.525731, -0.850651, 0],
575
+ [-0.5, -0.809017, 0.309017],
576
+ [-0.238856, -0.864188, 0.442863],
577
+ [-0.262866, -0.951056, 0.16246],
578
+ [-0.864188, -0.442863, 0.238856],
579
+ [-0.809017, -0.309017, 0.5],
580
+ [-0.688191, -0.587785, 0.425325],
581
+ [-0.681718, -0.147621, 0.716567],
582
+ [-0.442863, -0.238856, 0.864188],
583
+ [-0.587785, -0.425325, 0.688191],
584
+ [-0.309017, -0.5, 0.809017],
585
+ [-0.147621, -0.716567, 0.681718],
586
+ [-0.425325, -0.688191, 0.587785],
587
+ [-0.16246, -0.262866, 0.951056],
588
+ [0.442863, -0.238856, 0.864188],
589
+ [0.16246, -0.262866, 0.951056],
590
+ [0.309017, -0.5, 0.809017],
591
+ [0.147621, -0.716567, 0.681718],
592
+ [0, -0.525731, 0.850651],
593
+ [0.425325, -0.688191, 0.587785],
594
+ [0.587785, -0.425325, 0.688191],
595
+ [0.688191, -0.587785, 0.425325],
596
+ [-0.955423, 0.295242, 0],
597
+ [-0.951056, 0.16246, 0.262866],
598
+ [-1, 0, 0],
599
+ [-0.850651, 0, 0.525731],
600
+ [-0.955423, -0.295242, 0],
601
+ [-0.951056, -0.16246, 0.262866],
602
+ [-0.864188, 0.442863, -0.238856],
603
+ [-0.951056, 0.16246, -0.262866],
604
+ [-0.809017, 0.309017, -0.5],
605
+ [-0.864188, -0.442863, -0.238856],
606
+ [-0.951056, -0.16246, -0.262866],
607
+ [-0.809017, -0.309017, -0.5],
608
+ [-0.681718, 0.147621, -0.716567],
609
+ [-0.681718, -0.147621, -0.716567],
610
+ [-0.850651, 0, -0.525731],
611
+ [-0.688191, 0.587785, -0.425325],
612
+ [-0.587785, 0.425325, -0.688191],
613
+ [-0.425325, 0.688191, -0.587785],
614
+ [-0.425325, -0.688191, -0.587785],
615
+ [-0.587785, -0.425325, -0.688191],
616
+ [-0.688191, -0.587785, -0.425325]
617
+ ];
454
618
  STATE_SIZE = 624;
455
619
  MIDDLE_WORD = 397;
456
620
  MATRIX_A = 2567483615;
@@ -1154,6 +1318,333 @@ var init_esm = __esm({
1154
1318
  velocity: finalVelocity
1155
1319
  };
1156
1320
  };
1321
+ BinaryWriter = class {
1322
+ constructor(sizeOrBuffer = 1400) {
1323
+ if (typeof sizeOrBuffer === "number") {
1324
+ this.buffer = new Uint8Array(sizeOrBuffer);
1325
+ this.fixed = false;
1326
+ } else {
1327
+ this.buffer = sizeOrBuffer;
1328
+ this.fixed = true;
1329
+ }
1330
+ this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
1331
+ this.offset = 0;
1332
+ }
1333
+ ensureSpace(bytes) {
1334
+ if (this.offset + bytes > this.buffer.byteLength) {
1335
+ if (this.fixed) {
1336
+ throw new Error(`Buffer overflow: capacity ${this.buffer.byteLength}, needed ${this.offset + bytes}`);
1337
+ }
1338
+ const newSize = Math.max(this.buffer.byteLength * 2, this.offset + bytes);
1339
+ const newBuffer = new Uint8Array(newSize);
1340
+ newBuffer.set(this.buffer);
1341
+ this.buffer = newBuffer;
1342
+ this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
1343
+ }
1344
+ }
1345
+ writeByte(value) {
1346
+ this.ensureSpace(1);
1347
+ this.view.setUint8(this.offset, value);
1348
+ this.offset += 1;
1349
+ }
1350
+ writeChar(value) {
1351
+ this.ensureSpace(1);
1352
+ this.view.setInt8(this.offset, value);
1353
+ this.offset += 1;
1354
+ }
1355
+ writeShort(value) {
1356
+ this.ensureSpace(2);
1357
+ this.view.setInt16(this.offset, value, true);
1358
+ this.offset += 2;
1359
+ }
1360
+ writeLong(value) {
1361
+ this.ensureSpace(4);
1362
+ this.view.setInt32(this.offset, value, true);
1363
+ this.offset += 4;
1364
+ }
1365
+ writeFloat(value) {
1366
+ this.ensureSpace(4);
1367
+ this.view.setFloat32(this.offset, value, true);
1368
+ this.offset += 4;
1369
+ }
1370
+ writeString(value) {
1371
+ const len = value.length;
1372
+ this.ensureSpace(len + 1);
1373
+ for (let i = 0; i < len; i++) {
1374
+ this.view.setUint8(this.offset + i, value.charCodeAt(i));
1375
+ }
1376
+ this.view.setUint8(this.offset + len, 0);
1377
+ this.offset += len + 1;
1378
+ }
1379
+ writeCoord(value) {
1380
+ this.writeShort(Math.trunc(value * 8));
1381
+ }
1382
+ writeAngle(value) {
1383
+ this.writeByte(Math.trunc(value * 256 / 360) & 255);
1384
+ }
1385
+ writeAngle16(value) {
1386
+ this.writeShort(Math.trunc(value * 65536 / 360) & 65535);
1387
+ }
1388
+ writePos(pos) {
1389
+ this.writeCoord(pos.x);
1390
+ this.writeCoord(pos.y);
1391
+ this.writeCoord(pos.z);
1392
+ }
1393
+ writeDir(dir) {
1394
+ let maxDot = -1;
1395
+ let bestIndex = 0;
1396
+ if (dir.x === 0 && dir.y === 0 && dir.z === 0) {
1397
+ this.writeByte(0);
1398
+ return;
1399
+ }
1400
+ for (let i = 0; i < ANORMS.length; i++) {
1401
+ const norm = ANORMS[i];
1402
+ const dot = dir.x * norm[0] + dir.y * norm[1] + dir.z * norm[2];
1403
+ if (dot > maxDot) {
1404
+ maxDot = dot;
1405
+ bestIndex = i;
1406
+ }
1407
+ }
1408
+ this.writeByte(bestIndex);
1409
+ }
1410
+ getData() {
1411
+ return this.buffer.slice(0, this.offset);
1412
+ }
1413
+ getBuffer() {
1414
+ return this.buffer;
1415
+ }
1416
+ getOffset() {
1417
+ return this.offset;
1418
+ }
1419
+ reset() {
1420
+ this.offset = 0;
1421
+ }
1422
+ };
1423
+ _NetChan = class _NetChan2 {
1424
+ constructor() {
1425
+ this.qport = 0;
1426
+ this.incomingSequence = 0;
1427
+ this.outgoingSequence = 0;
1428
+ this.incomingAcknowledged = 0;
1429
+ this.incomingReliableAcknowledged = false;
1430
+ this.incomingReliableSequence = 0;
1431
+ this.outgoingReliableSequence = 0;
1432
+ this.reliableLength = 0;
1433
+ this.lastReceived = 0;
1434
+ this.lastSent = 0;
1435
+ this.remoteAddress = null;
1436
+ this.reliableMessage = new BinaryWriter(_NetChan2.MAX_MSGLEN);
1437
+ const now = Date.now();
1438
+ this.lastReceived = now;
1439
+ this.lastSent = now;
1440
+ this.qport = Math.floor(Math.random() * 65536);
1441
+ }
1442
+ /**
1443
+ * Setup the netchan with specific settings
1444
+ */
1445
+ setup(qport, address = null) {
1446
+ this.qport = qport;
1447
+ this.remoteAddress = address;
1448
+ this.reset();
1449
+ }
1450
+ /**
1451
+ * Reset the netchan state
1452
+ */
1453
+ reset() {
1454
+ this.incomingSequence = 0;
1455
+ this.outgoingSequence = 0;
1456
+ this.incomingAcknowledged = 0;
1457
+ this.incomingReliableAcknowledged = false;
1458
+ this.incomingReliableSequence = 0;
1459
+ this.outgoingReliableSequence = 0;
1460
+ this.reliableLength = 0;
1461
+ this.reliableMessage.reset();
1462
+ this.lastReceived = Date.now();
1463
+ this.lastSent = Date.now();
1464
+ }
1465
+ /**
1466
+ * Transmits a packet containing reliable and unreliable data
1467
+ */
1468
+ transmit(unreliableData) {
1469
+ this.outgoingSequence++;
1470
+ this.lastSent = Date.now();
1471
+ const headerSize = _NetChan2.PACKET_HEADER;
1472
+ const reliableSize = this.reliableLength > 0 ? this.reliableLength + 2 : 0;
1473
+ let unreliableSize = unreliableData ? unreliableData.length : 0;
1474
+ if (headerSize + reliableSize + unreliableSize > _NetChan2.MAX_MSGLEN) {
1475
+ unreliableSize = _NetChan2.MAX_MSGLEN - headerSize - reliableSize;
1476
+ if (unreliableSize < 0) unreliableSize = 0;
1477
+ }
1478
+ const buffer = new ArrayBuffer(headerSize + reliableSize + unreliableSize);
1479
+ const view = new DataView(buffer);
1480
+ const result = new Uint8Array(buffer);
1481
+ let sequence = this.outgoingSequence;
1482
+ if (this.reliableLength > 0) {
1483
+ sequence |= 2147483648;
1484
+ if ((this.outgoingReliableSequence & 1) !== 0) {
1485
+ sequence |= 1073741824;
1486
+ }
1487
+ }
1488
+ view.setUint32(0, sequence, true);
1489
+ let ack = this.incomingSequence;
1490
+ if ((this.incomingReliableSequence & 1) !== 0) {
1491
+ ack |= 2147483648;
1492
+ }
1493
+ view.setUint32(4, ack, true);
1494
+ view.setUint16(8, this.qport, true);
1495
+ let offset = headerSize;
1496
+ if (this.reliableLength > 0) {
1497
+ view.setUint16(offset, this.reliableLength, true);
1498
+ offset += 2;
1499
+ const reliableBuffer = this.reliableMessage.getBuffer();
1500
+ const reliableBytes = reliableBuffer.subarray(0, this.reliableLength);
1501
+ result.set(reliableBytes, offset);
1502
+ offset += this.reliableLength;
1503
+ }
1504
+ if (unreliableData && unreliableSize > 0) {
1505
+ const chunk = unreliableData.slice(0, unreliableSize);
1506
+ result.set(chunk, offset);
1507
+ }
1508
+ return result;
1509
+ }
1510
+ /**
1511
+ * Processes a received packet
1512
+ * Returns the payload data (reliable + unreliable) to be processed, or null if discarded
1513
+ */
1514
+ process(packet) {
1515
+ if (packet.length < _NetChan2.PACKET_HEADER) {
1516
+ return null;
1517
+ }
1518
+ this.lastReceived = Date.now();
1519
+ const view = new DataView(packet.buffer, packet.byteOffset, packet.byteLength);
1520
+ const sequence = view.getUint32(0, true);
1521
+ const ack = view.getUint32(4, true);
1522
+ const qport = view.getUint16(8, true);
1523
+ if (this.qport !== qport) {
1524
+ return null;
1525
+ }
1526
+ const seqNumberClean = sequence & ~(2147483648 | 1073741824);
1527
+ if ((seqNumberClean - this.incomingSequence | 0) <= 0) {
1528
+ return null;
1529
+ }
1530
+ this.incomingSequence = seqNumberClean;
1531
+ const ackNumber = ack & ~2147483648;
1532
+ const ackReliable = (ack & 2147483648) !== 0;
1533
+ if (ackNumber > this.incomingAcknowledged) {
1534
+ this.incomingAcknowledged = ackNumber;
1535
+ }
1536
+ if (this.reliableLength > 0) {
1537
+ const receivedAckBit = ackReliable ? 1 : 0;
1538
+ const currentReliableBit = this.outgoingReliableSequence & 1;
1539
+ if (receivedAckBit !== currentReliableBit) {
1540
+ this.reliableLength = 0;
1541
+ this.reliableMessage.reset();
1542
+ this.outgoingReliableSequence ^= 1;
1543
+ }
1544
+ }
1545
+ const hasReliableData = (sequence & 2147483648) !== 0;
1546
+ const reliableSeqBit = (sequence & 1073741824) !== 0 ? 1 : 0;
1547
+ let payloadOffset = _NetChan2.PACKET_HEADER;
1548
+ let reliableData = null;
1549
+ if (hasReliableData) {
1550
+ if (payloadOffset + 2 > packet.byteLength) return null;
1551
+ const reliableLen = view.getUint16(payloadOffset, true);
1552
+ payloadOffset += 2;
1553
+ const expectedBit = this.incomingReliableSequence & 1;
1554
+ if (reliableSeqBit === expectedBit) {
1555
+ this.incomingReliableSequence++;
1556
+ if (payloadOffset + reliableLen > packet.byteLength) return null;
1557
+ reliableData = packet.slice(payloadOffset, payloadOffset + reliableLen);
1558
+ }
1559
+ payloadOffset += reliableLen;
1560
+ }
1561
+ const unreliableData = packet.slice(payloadOffset);
1562
+ if (reliableData && reliableData.length > 0) {
1563
+ const totalLen = reliableData.length + unreliableData.length;
1564
+ const result = new Uint8Array(totalLen);
1565
+ result.set(reliableData, 0);
1566
+ result.set(unreliableData, reliableData.length);
1567
+ return result;
1568
+ }
1569
+ if (unreliableData) {
1570
+ return unreliableData;
1571
+ }
1572
+ return new Uint8Array(0);
1573
+ }
1574
+ /**
1575
+ * Checks if reliable message buffer is empty and ready for new data
1576
+ */
1577
+ canSendReliable() {
1578
+ return this.reliableLength === 0;
1579
+ }
1580
+ /**
1581
+ * Writes a byte to the reliable message buffer
1582
+ */
1583
+ writeReliableByte(value) {
1584
+ if (this.reliableLength + 1 > _NetChan2.MAX_MSGLEN - _NetChan2.HEADER_OVERHEAD) {
1585
+ throw new Error("NetChan reliable buffer overflow");
1586
+ }
1587
+ this.reliableMessage.writeByte(value);
1588
+ this.reliableLength++;
1589
+ }
1590
+ /**
1591
+ * Writes a short to the reliable message buffer
1592
+ */
1593
+ writeReliableShort(value) {
1594
+ if (this.reliableLength + 2 > _NetChan2.MAX_MSGLEN - _NetChan2.HEADER_OVERHEAD) {
1595
+ throw new Error("NetChan reliable buffer overflow");
1596
+ }
1597
+ this.reliableMessage.writeShort(value);
1598
+ this.reliableLength += 2;
1599
+ }
1600
+ /**
1601
+ * Writes a long to the reliable message buffer
1602
+ */
1603
+ writeReliableLong(value) {
1604
+ if (this.reliableLength + 4 > _NetChan2.MAX_MSGLEN - _NetChan2.HEADER_OVERHEAD) {
1605
+ throw new Error("NetChan reliable buffer overflow");
1606
+ }
1607
+ this.reliableMessage.writeLong(value);
1608
+ this.reliableLength += 4;
1609
+ }
1610
+ /**
1611
+ * Writes a string to the reliable message buffer
1612
+ */
1613
+ writeReliableString(value) {
1614
+ const len = value.length + 1;
1615
+ if (this.reliableLength + len > _NetChan2.MAX_MSGLEN - _NetChan2.HEADER_OVERHEAD) {
1616
+ throw new Error("NetChan reliable buffer overflow");
1617
+ }
1618
+ this.reliableMessage.writeString(value);
1619
+ this.reliableLength += len;
1620
+ }
1621
+ /**
1622
+ * Returns the current reliable data buffer
1623
+ */
1624
+ getReliableData() {
1625
+ if (this.reliableLength === 0) {
1626
+ return new Uint8Array(0);
1627
+ }
1628
+ const buffer = this.reliableMessage.getBuffer();
1629
+ return buffer.subarray(0, this.reliableLength);
1630
+ }
1631
+ /**
1632
+ * Checks if we need to send a keepalive packet
1633
+ */
1634
+ needsKeepalive(currentTime) {
1635
+ return currentTime - this.lastSent > 1e3;
1636
+ }
1637
+ /**
1638
+ * Checks if the connection has timed out
1639
+ */
1640
+ isTimedOut(currentTime, timeoutMs = 3e4) {
1641
+ return currentTime - this.lastReceived > timeoutMs;
1642
+ }
1643
+ };
1644
+ _NetChan.MAX_MSGLEN = 1400;
1645
+ _NetChan.FRAGMENT_SIZE = 1024;
1646
+ _NetChan.PACKET_HEADER = 10;
1647
+ _NetChan.HEADER_OVERHEAD = _NetChan.PACKET_HEADER + 2;
1157
1648
  WeaponId = /* @__PURE__ */ ((WeaponId22) => {
1158
1649
  WeaponId22["Blaster"] = "blaster";
1159
1650
  WeaponId22["Shotgun"] = "shotgun";
@@ -1224,6 +1715,22 @@ var init_esm = __esm({
1224
1715
  "bfg10k"
1225
1716
  /* BFG10K */
1226
1717
  ];
1718
+ SoundChannel = /* @__PURE__ */ ((SoundChannel2) => {
1719
+ SoundChannel2[SoundChannel2["Auto"] = 0] = "Auto";
1720
+ SoundChannel2[SoundChannel2["Weapon"] = 1] = "Weapon";
1721
+ SoundChannel2[SoundChannel2["Voice"] = 2] = "Voice";
1722
+ SoundChannel2[SoundChannel2["Item"] = 3] = "Item";
1723
+ SoundChannel2[SoundChannel2["Body"] = 4] = "Body";
1724
+ SoundChannel2[SoundChannel2["Aux"] = 5] = "Aux";
1725
+ SoundChannel2[SoundChannel2["Footstep"] = 6] = "Footstep";
1726
+ SoundChannel2[SoundChannel2["Aux3"] = 7] = "Aux3";
1727
+ SoundChannel2[SoundChannel2["NoPhsAdd"] = 8] = "NoPhsAdd";
1728
+ SoundChannel2[SoundChannel2["Reliable"] = 16] = "Reliable";
1729
+ SoundChannel2[SoundChannel2["ForcePos"] = 32] = "ForcePos";
1730
+ return SoundChannel2;
1731
+ })(SoundChannel || {});
1732
+ ATTN_NORM = 1;
1733
+ ATTN_IDLE = 2;
1227
1734
  }
1228
1735
  });
1229
1736
 
@@ -3481,6 +3988,9 @@ var EntitySystem = class {
3481
3988
  sound(entity, channel, sound, volume, attenuation, timeofs) {
3482
3989
  this.engine.sound?.(entity, channel, sound, volume, attenuation, timeofs);
3483
3990
  }
3991
+ soundIndex(sound) {
3992
+ return this.engine.soundIndex?.(sound) || 0;
3993
+ }
3484
3994
  modelIndex(model) {
3485
3995
  return this.engine.modelIndex?.(model) || 0;
3486
3996
  }
@@ -4639,7 +5149,7 @@ function createBfgBall(sys, owner, start, dir, damage, speed, damageRadius) {
4639
5149
 
4640
5150
  // src/entities/targets.ts
4641
5151
  var ATTN_NONE = 0;
4642
- var ATTN_NORM = 1;
5152
+ var ATTN_NORM2 = 1;
4643
5153
  var SPEAKER_SPAWNFLAGS = {
4644
5154
  LoopedOn: 1 << 0,
4645
5155
  LoopedOff: 1 << 1,
@@ -4731,7 +5241,7 @@ function useTargetBlaster(self, other, activator, context) {
4731
5241
  bolt.effects = 0;
4732
5242
  }
4733
5243
  }
4734
- context.entities.sound(self, 2, "weapons/laser2.wav", 1, ATTN_NORM, 0);
5244
+ context.entities.sound(self, 2, "weapons/laser2.wav", 1, ATTN_NORM2, 0);
4735
5245
  }
4736
5246
  var SPAWNFLAG_EARTHQUAKE_SILENT = 1;
4737
5247
  var SPAWNFLAG_EARTHQUAKE_TOGGLE = 2;
@@ -4956,7 +5466,7 @@ function registerTargetSpawns(registry) {
4956
5466
  if (attenuation) {
4957
5467
  entity.attenuation = Number.parseFloat(attenuation);
4958
5468
  } else {
4959
- entity.attenuation = ATTN_NORM;
5469
+ entity.attenuation = ATTN_NORM2;
4960
5470
  }
4961
5471
  if (context.keyValues.volume) {
4962
5472
  entity.volume = Number.parseFloat(context.keyValues.volume);
@@ -12467,6 +12977,12 @@ var actor_names = [
12467
12977
  "Titus",
12468
12978
  "Bitterman"
12469
12979
  ];
12980
+ var sound_pain1 = "player/male/pain100.wav";
12981
+ var sound_pain2 = "player/male/pain75.wav";
12982
+ var sound_pain3 = "player/male/pain50.wav";
12983
+ var sound_die1 = "player/male/death1.wav";
12984
+ var sound_die2 = "player/male/death2.wav";
12985
+ var sound_gib = "misc/udeath.wav";
12470
12986
  var FRAME_stand101 = 0;
12471
12987
  var FRAME_stand140 = 39;
12472
12988
  var FRAME_walk01 = 40;
@@ -12541,6 +13057,11 @@ function actor_pain(self, other, kick, damage) {
12541
13057
  if (context.timeSeconds < self.pain_debounce_time)
12542
13058
  return;
12543
13059
  self.pain_debounce_time = context.timeSeconds + 3;
13060
+ const n = Math.floor(Math.random() * 3);
13061
+ let sound = sound_pain1;
13062
+ if (n === 1) sound = sound_pain2;
13063
+ if (n === 2) sound = sound_pain3;
13064
+ context.sound(self, SoundChannel.Voice, sound, 1, ATTN_NORM, 0);
12544
13065
  const random13 = Math.random();
12545
13066
  if (other && other.client && random13 < 0.4) {
12546
13067
  const v = subtractVec3(other.origin, self.origin);
@@ -12555,7 +13076,6 @@ function actor_pain(self, other, kick, damage) {
12555
13076
  `);
12556
13077
  return;
12557
13078
  }
12558
- const n = Math.floor(Math.random() * 3);
12559
13079
  if (n === 0)
12560
13080
  self.monsterinfo.current_move = actor_move_pain1;
12561
13081
  else if (n === 1)
@@ -12604,15 +13124,19 @@ function actor_die(self, inflictor, attacker, damage, point, mod) {
12604
13124
  const context = self.monsterinfo.context;
12605
13125
  if (!context) return;
12606
13126
  if (self.health <= -80) {
13127
+ context.sound(self, SoundChannel.Voice, sound_gib, 1, ATTN_NORM, 0);
12607
13128
  throwGibs(context, self.origin, damage);
12608
13129
  self.deadflag = 2 /* Dead */;
12609
13130
  return;
12610
13131
  }
12611
13132
  if (self.deadflag === 2 /* Dead */)
12612
13133
  return;
13134
+ const n = Math.floor(Math.random() * 2);
13135
+ const sound = n === 0 ? sound_die1 : sound_die2;
13136
+ context.sound(self, SoundChannel.Voice, sound, 1, ATTN_NORM, 0);
12613
13137
  self.deadflag = 2 /* Dead */;
12614
13138
  self.takedamage = true;
12615
- if (Math.random() < 0.5)
13139
+ if (n === 0)
12616
13140
  self.monsterinfo.current_move = actor_move_death1;
12617
13141
  else
12618
13142
  self.monsterinfo.current_move = actor_move_death2;
@@ -12880,6 +13404,13 @@ function SP_misc_actor(self, context) {
12880
13404
  self.mass = 200;
12881
13405
  self.pain = actor_pain;
12882
13406
  self.die = actor_die;
13407
+ context.entities.soundIndex(sound_pain1);
13408
+ context.entities.soundIndex(sound_pain2);
13409
+ context.entities.soundIndex(sound_pain3);
13410
+ context.entities.soundIndex(sound_die1);
13411
+ context.entities.soundIndex(sound_die2);
13412
+ context.entities.soundIndex(sound_gib);
13413
+ context.entities.soundIndex("player/male/jump1.wav");
12883
13414
  self.monsterinfo = {
12884
13415
  ...self.monsterinfo,
12885
13416
  // Preserve default properties like last_sighting, trail_time, pausetime
@@ -12930,7 +13461,7 @@ function target_actor_touch(self, other, plane, surf) {
12930
13461
  if (other.groundentity) {
12931
13462
  other.groundentity = null;
12932
13463
  v.z = self.movedir.z;
12933
- context.sound(other, 2, "player/male/jump1.wav", 1, 1, 0);
13464
+ context.sound(other, SoundChannel.Voice, "player/male/jump1.wav", 1, ATTN_NORM, 0);
12934
13465
  }
12935
13466
  }
12936
13467
  if (self.spawnflags & SPAWNFLAG_TARGET_ACTOR_SHOOT) {
@@ -16251,11 +16782,6 @@ var FRAME_rails_up16 = 113;
16251
16782
  var MODEL_SCALE = 1;
16252
16783
  var MELEE_DISTANCE5 = 64;
16253
16784
  var MONSTER_TICK27 = 0.1;
16254
- var CHAN_WEAPON = 1;
16255
- var CHAN_VOICE = 2;
16256
- var CHAN_BODY = 4;
16257
- var ATTN_NORM2 = 1;
16258
- var ATTN_IDLE = 2;
16259
16785
  var MZ2_ARACHNID_RAIL1 = 20;
16260
16786
  var MZ2_ARACHNID_RAIL2 = 21;
16261
16787
  var MZ2_ARACHNID_RAIL_UP1 = 22;
@@ -16307,7 +16833,7 @@ function arachnid_stand(self, context) {
16307
16833
  M_SetAnimation3(self, arachnid_move_stand, context);
16308
16834
  }
16309
16835
  function arachnid_footstep(self, context) {
16310
- context.engine.sound?.(self, CHAN_BODY, sound_step, 0.5, ATTN_IDLE, 0);
16836
+ context.engine.sound?.(self, SoundChannel.Body, sound_step, 0.5, ATTN_IDLE, 0);
16311
16837
  }
16312
16838
  var arachnid_frames_walk = [
16313
16839
  { ai: monster_ai_walk22, dist: 8, think: arachnid_footstep },
@@ -16386,7 +16912,7 @@ function arachnid_pain(self, other, kick, damage, context) {
16386
16912
  return;
16387
16913
  }
16388
16914
  self.pain_debounce_time = context.timeSeconds + 3;
16389
- context.engine.sound?.(self, CHAN_VOICE, sound_pain, 1, ATTN_NORM2, 0);
16915
+ context.engine.sound?.(self, SoundChannel.Voice, sound_pain, 1, ATTN_NORM, 0);
16390
16916
  if (!M_ShouldReactToPain(self)) {
16391
16917
  return;
16392
16918
  }
@@ -16400,7 +16926,7 @@ function arachnid_charge_rail(self, context) {
16400
16926
  if (!self.enemy || !self.enemy.inUse) {
16401
16927
  return;
16402
16928
  }
16403
- context.engine.sound?.(self, CHAN_WEAPON, sound_charge, 1, ATTN_NORM2, 0);
16929
+ context.engine.sound?.(self, SoundChannel.Weapon, sound_charge, 1, ATTN_NORM, 0);
16404
16930
  self.pos1 = { ...self.enemy.origin };
16405
16931
  self.pos1 = { ...self.pos1, z: self.pos1.z + self.enemy.viewheight };
16406
16932
  }
@@ -16471,7 +16997,7 @@ var arachnid_attack_up1 = {
16471
16997
  endfunc: arachnid_run
16472
16998
  };
16473
16999
  function arachnid_melee_charge(self, context) {
16474
- context.engine.sound?.(self, CHAN_WEAPON, sound_melee, 1, ATTN_NORM2, 0);
17000
+ context.engine.sound?.(self, SoundChannel.Weapon, sound_melee, 1, ATTN_NORM, 0);
16475
17001
  }
16476
17002
  function arachnid_melee_hit(self, context) {
16477
17003
  if (!monster_fire_hit(self, { x: MELEE_DISTANCE5, y: 0, z: 0 }, 15, 50, context)) {
@@ -16548,7 +17074,7 @@ var arachnid_move_death = {
16548
17074
  };
16549
17075
  function arachnid_die(self, inflictor, attacker, damage, point, mod, context) {
16550
17076
  if (M_CheckGib(self, context)) {
16551
- context.engine.sound?.(self, CHAN_VOICE, "misc/udeath.wav", 1, ATTN_NORM2, 0);
17077
+ context.engine.sound?.(self, SoundChannel.Voice, "misc/udeath.wav", 1, ATTN_NORM, 0);
16552
17078
  throwGibs(context, self.origin, damage);
16553
17079
  self.deadflag = 2 /* Dead */;
16554
17080
  return;
@@ -16556,7 +17082,7 @@ function arachnid_die(self, inflictor, attacker, damage, point, mod, context) {
16556
17082
  if (self.deadflag === 2 /* Dead */) {
16557
17083
  return;
16558
17084
  }
16559
- context.engine.sound?.(self, CHAN_VOICE, sound_death, 1, ATTN_NORM2, 0);
17085
+ context.engine.sound?.(self, SoundChannel.Voice, sound_death, 1, ATTN_NORM, 0);
16560
17086
  self.deadflag = 2 /* Dead */;
16561
17087
  self.takedamage = true;
16562
17088
  M_SetAnimation3(self, arachnid_move_death, context);
@@ -16574,6 +17100,14 @@ function SP_monster_arachnid(self, context) {
16574
17100
  sound_pain = "arachnid/pain.wav";
16575
17101
  sound_death = "arachnid/death.wav";
16576
17102
  sound_sight = "arachnid/sight.wav";
17103
+ context.soundIndex(sound_step);
17104
+ context.soundIndex(sound_charge);
17105
+ context.soundIndex(sound_melee);
17106
+ context.soundIndex(sound_melee_hit);
17107
+ context.soundIndex(sound_pain);
17108
+ context.soundIndex(sound_death);
17109
+ context.soundIndex(sound_sight);
17110
+ context.soundIndex("misc/udeath.wav");
16577
17111
  self.model = "models/monsters/arachnid/tris.md2";
16578
17112
  self.mins = { x: -48, y: -48, z: -20 };
16579
17113
  self.maxs = { x: 48, y: 48, z: 48 };
@@ -16590,7 +17124,7 @@ function SP_monster_arachnid(self, context) {
16590
17124
  walk: arachnid_walk,
16591
17125
  run: arachnid_run,
16592
17126
  attack: arachnid_attack,
16593
- sight: (e, o) => context.engine.sound?.(e, CHAN_VOICE, sound_sight, 1, ATTN_NORM2, 0),
17127
+ sight: (e, o) => context.engine.sound?.(e, SoundChannel.Voice, sound_sight, 1, ATTN_NORM, 0),
16594
17128
  scale: MODEL_SCALE,
16595
17129
  aiflags: self.monsterinfo?.aiflags || 0
16596
17130
  };
@@ -18863,6 +19397,9 @@ function createGame(imports, engine, options) {
18863
19397
  sound(entity, channel, sound, volume, attenuation, timeofs) {
18864
19398
  entities.sound(entity, channel, sound, volume, attenuation, timeofs);
18865
19399
  },
19400
+ soundIndex(sound) {
19401
+ return entities.soundIndex(sound);
19402
+ },
18866
19403
  centerprintf(entity, message) {
18867
19404
  engine.centerprintf?.(entity, message);
18868
19405
  },