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.
- package/package.json +1 -1
- package/packages/client/dist/browser/index.global.js +13 -13
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/cjs/index.cjs +554 -2
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +554 -2
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/browser/index.global.js +16 -16
- package/packages/engine/dist/browser/index.global.js.map +1 -1
- package/packages/engine/dist/cjs/index.cjs +360 -35
- package/packages/engine/dist/cjs/index.cjs.map +1 -1
- package/packages/engine/dist/esm/index.js +360 -35
- package/packages/engine/dist/esm/index.js.map +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/types/audio/constants.d.ts +1 -23
- package/packages/engine/dist/types/audio/constants.d.ts.map +1 -1
- package/packages/game/dist/browser/index.global.js +3 -3
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs +556 -19
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +556 -19
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/entities/monsters/actor.d.ts.map +1 -1
- package/packages/game/dist/types/entities/monsters/arachnid.d.ts.map +1 -1
- package/packages/game/dist/types/entities/system.d.ts +1 -0
- package/packages/game/dist/types/entities/system.d.ts.map +1 -1
- package/packages/game/dist/types/index.d.ts +2 -0
- package/packages/game/dist/types/index.d.ts.map +1 -1
- package/packages/server/dist/index.cjs +54 -11
- package/packages/server/dist/index.d.cts +6 -1
- package/packages/server/dist/index.d.ts +6 -1
- package/packages/server/dist/index.js +56 -13
- package/packages/shared/dist/browser/index.global.js +1 -1
- package/packages/shared/dist/browser/index.global.js.map +1 -1
- package/packages/shared/dist/cjs/index.cjs +562 -0
- package/packages/shared/dist/cjs/index.cjs.map +1 -1
- package/packages/shared/dist/esm/index.js +549 -0
- package/packages/shared/dist/esm/index.js.map +1 -1
- package/packages/shared/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/shared/dist/types/audio/constants.d.ts +24 -0
- package/packages/shared/dist/types/audio/constants.d.ts.map +1 -0
- package/packages/shared/dist/types/index.d.ts +1 -0
- package/packages/shared/dist/types/index.d.ts.map +1 -1
- package/packages/shared/dist/types/net/index.d.ts +1 -0
- package/packages/shared/dist/types/net/index.d.ts.map +1 -1
- package/packages/shared/dist/types/protocol/crc.d.ts +5 -0
- package/packages/shared/dist/types/protocol/crc.d.ts.map +1 -0
- package/packages/shared/dist/types/protocol/index.d.ts +1 -0
- package/packages/shared/dist/types/protocol/index.d.ts.map +1 -1
- package/packages/tools/dist/tsconfig.tsbuildinfo +1 -1
|
@@ -446,7 +446,7 @@ function G_SetPowerupStat(stats, powerupId, val) {
|
|
|
446
446
|
if (safeVal < 0) safeVal = 0;
|
|
447
447
|
setCompressedInteger(stats, 41, index, safeVal, NUM_BITS_FOR_POWERUP);
|
|
448
448
|
}
|
|
449
|
-
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;
|
|
449
|
+
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;
|
|
450
450
|
var init_esm = __esm({
|
|
451
451
|
"../shared/dist/esm/index.js"() {
|
|
452
452
|
"use strict";
|
|
@@ -463,6 +463,170 @@ var init_esm = __esm({
|
|
|
463
463
|
ROLL = 2;
|
|
464
464
|
DEG2RAD_FACTOR = Math.PI / 180;
|
|
465
465
|
RAD2DEG_FACTOR = 180 / Math.PI;
|
|
466
|
+
ANORMS = [
|
|
467
|
+
[-0.525731, 0, 0.850651],
|
|
468
|
+
[-0.442863, 0.238856, 0.864188],
|
|
469
|
+
[-0.295242, 0, 0.955423],
|
|
470
|
+
[-0.309017, 0.5, 0.809017],
|
|
471
|
+
[-0.16246, 0.262866, 0.951056],
|
|
472
|
+
[0, 0, 1],
|
|
473
|
+
[0, 0.850651, 0.525731],
|
|
474
|
+
[-0.147621, 0.716567, 0.681718],
|
|
475
|
+
[0.147621, 0.716567, 0.681718],
|
|
476
|
+
[0, 0.525731, 0.850651],
|
|
477
|
+
[0.309017, 0.5, 0.809017],
|
|
478
|
+
[0.525731, 0, 0.850651],
|
|
479
|
+
[0.295242, 0, 0.955423],
|
|
480
|
+
[0.442863, 0.238856, 0.864188],
|
|
481
|
+
[0.16246, 0.262866, 0.951056],
|
|
482
|
+
[-0.681718, 0.147621, 0.716567],
|
|
483
|
+
[-0.809017, 0.309017, 0.5],
|
|
484
|
+
[-0.587785, 0.425325, 0.688191],
|
|
485
|
+
[-0.850651, 0.525731, 0],
|
|
486
|
+
[-0.864188, 0.442863, 0.238856],
|
|
487
|
+
[-0.716567, 0.681718, 0.147621],
|
|
488
|
+
[-0.688191, 0.587785, 0.425325],
|
|
489
|
+
[-0.5, 0.809017, 0.309017],
|
|
490
|
+
[-0.238856, 0.864188, 0.442863],
|
|
491
|
+
[-0.425325, 0.688191, 0.587785],
|
|
492
|
+
[-0.716567, 0.681718, -0.147621],
|
|
493
|
+
[-0.5, 0.809017, -0.309017],
|
|
494
|
+
[-0.525731, 0.850651, 0],
|
|
495
|
+
[0, 0.850651, -0.525731],
|
|
496
|
+
[-0.238856, 0.864188, -0.442863],
|
|
497
|
+
[0, 0.955423, -0.295242],
|
|
498
|
+
[-0.262866, 0.951056, -0.16246],
|
|
499
|
+
[0, 1, 0],
|
|
500
|
+
[0, 0.955423, 0.295242],
|
|
501
|
+
[-0.262866, 0.951056, 0.16246],
|
|
502
|
+
[0.238856, 0.864188, 0.442863],
|
|
503
|
+
[0.262866, 0.951056, 0.16246],
|
|
504
|
+
[0.5, 0.809017, 0.309017],
|
|
505
|
+
[0.238856, 0.864188, -0.442863],
|
|
506
|
+
[0.262866, 0.951056, -0.16246],
|
|
507
|
+
[0.5, 0.809017, -0.309017],
|
|
508
|
+
[0.850651, 0.525731, 0],
|
|
509
|
+
[0.716567, 0.681718, 0.147621],
|
|
510
|
+
[0.716567, 0.681718, -0.147621],
|
|
511
|
+
[0.525731, 0.850651, 0],
|
|
512
|
+
[0.425325, 0.688191, 0.587785],
|
|
513
|
+
[0.864188, 0.442863, 0.238856],
|
|
514
|
+
[0.688191, 0.587785, 0.425325],
|
|
515
|
+
[0.809017, 0.309017, 0.5],
|
|
516
|
+
[0.681718, 0.147621, 0.716567],
|
|
517
|
+
[0.587785, 0.425325, 0.688191],
|
|
518
|
+
[0.955423, 0.295242, 0],
|
|
519
|
+
[1, 0, 0],
|
|
520
|
+
[0.951056, 0.16246, 0.262866],
|
|
521
|
+
[0.850651, -0.525731, 0],
|
|
522
|
+
[0.955423, -0.295242, 0],
|
|
523
|
+
[0.864188, -0.442863, 0.238856],
|
|
524
|
+
[0.951056, -0.16246, 0.262866],
|
|
525
|
+
[0.809017, -0.309017, 0.5],
|
|
526
|
+
[0.681718, -0.147621, 0.716567],
|
|
527
|
+
[0.850651, 0, 0.525731],
|
|
528
|
+
[0.864188, 0.442863, -0.238856],
|
|
529
|
+
[0.809017, 0.309017, -0.5],
|
|
530
|
+
[0.951056, 0.16246, -0.262866],
|
|
531
|
+
[0.525731, 0, -0.850651],
|
|
532
|
+
[0.681718, 0.147621, -0.716567],
|
|
533
|
+
[0.681718, -0.147621, -0.716567],
|
|
534
|
+
[0.850651, 0, -0.525731],
|
|
535
|
+
[0.809017, -0.309017, -0.5],
|
|
536
|
+
[0.864188, -0.442863, -0.238856],
|
|
537
|
+
[0.951056, -0.16246, -0.262866],
|
|
538
|
+
[0.147621, 0.716567, -0.681718],
|
|
539
|
+
[0.309017, 0.5, -0.809017],
|
|
540
|
+
[0.425325, 0.688191, -0.587785],
|
|
541
|
+
[0.442863, 0.238856, -0.864188],
|
|
542
|
+
[0.587785, 0.425325, -0.688191],
|
|
543
|
+
[0.688191, 0.587785, -0.425325],
|
|
544
|
+
[-0.147621, 0.716567, -0.681718],
|
|
545
|
+
[-0.309017, 0.5, -0.809017],
|
|
546
|
+
[0, 0.525731, -0.850651],
|
|
547
|
+
[-0.525731, 0, -0.850651],
|
|
548
|
+
[-0.442863, 0.238856, -0.864188],
|
|
549
|
+
[-0.295242, 0, -0.955423],
|
|
550
|
+
[-0.16246, 0.262866, -0.951056],
|
|
551
|
+
[0, 0, -1],
|
|
552
|
+
[0.295242, 0, -0.955423],
|
|
553
|
+
[0.16246, 0.262866, -0.951056],
|
|
554
|
+
[-0.442863, -0.238856, -0.864188],
|
|
555
|
+
[-0.309017, -0.5, -0.809017],
|
|
556
|
+
[-0.16246, -0.262866, -0.951056],
|
|
557
|
+
[0, -0.850651, -0.525731],
|
|
558
|
+
[-0.147621, -0.716567, -0.681718],
|
|
559
|
+
[0.147621, -0.716567, -0.681718],
|
|
560
|
+
[0, -0.525731, -0.850651],
|
|
561
|
+
[0.309017, -0.5, -0.809017],
|
|
562
|
+
[0.442863, -0.238856, -0.864188],
|
|
563
|
+
[0.16246, -0.262866, -0.951056],
|
|
564
|
+
[0.238856, -0.864188, -0.442863],
|
|
565
|
+
[0.5, -0.809017, -0.309017],
|
|
566
|
+
[0.425325, -0.688191, -0.587785],
|
|
567
|
+
[0.716567, -0.681718, -0.147621],
|
|
568
|
+
[0.688191, -0.587785, -0.425325],
|
|
569
|
+
[0.587785, -0.425325, -0.688191],
|
|
570
|
+
[0, -0.955423, -0.295242],
|
|
571
|
+
[0, -1, 0],
|
|
572
|
+
[0.262866, -0.951056, -0.16246],
|
|
573
|
+
[0, -0.850651, 0.525731],
|
|
574
|
+
[0, -0.955423, 0.295242],
|
|
575
|
+
[0.238856, -0.864188, 0.442863],
|
|
576
|
+
[0.262866, -0.951056, 0.16246],
|
|
577
|
+
[0.5, -0.809017, 0.309017],
|
|
578
|
+
[0.716567, -0.681718, 0.147621],
|
|
579
|
+
[0.525731, -0.850651, 0],
|
|
580
|
+
[-0.238856, -0.864188, -0.442863],
|
|
581
|
+
[-0.5, -0.809017, -0.309017],
|
|
582
|
+
[-0.262866, -0.951056, -0.16246],
|
|
583
|
+
[-0.850651, -0.525731, 0],
|
|
584
|
+
[-0.716567, -0.681718, -0.147621],
|
|
585
|
+
[-0.716567, -0.681718, 0.147621],
|
|
586
|
+
[-0.525731, -0.850651, 0],
|
|
587
|
+
[-0.5, -0.809017, 0.309017],
|
|
588
|
+
[-0.238856, -0.864188, 0.442863],
|
|
589
|
+
[-0.262866, -0.951056, 0.16246],
|
|
590
|
+
[-0.864188, -0.442863, 0.238856],
|
|
591
|
+
[-0.809017, -0.309017, 0.5],
|
|
592
|
+
[-0.688191, -0.587785, 0.425325],
|
|
593
|
+
[-0.681718, -0.147621, 0.716567],
|
|
594
|
+
[-0.442863, -0.238856, 0.864188],
|
|
595
|
+
[-0.587785, -0.425325, 0.688191],
|
|
596
|
+
[-0.309017, -0.5, 0.809017],
|
|
597
|
+
[-0.147621, -0.716567, 0.681718],
|
|
598
|
+
[-0.425325, -0.688191, 0.587785],
|
|
599
|
+
[-0.16246, -0.262866, 0.951056],
|
|
600
|
+
[0.442863, -0.238856, 0.864188],
|
|
601
|
+
[0.16246, -0.262866, 0.951056],
|
|
602
|
+
[0.309017, -0.5, 0.809017],
|
|
603
|
+
[0.147621, -0.716567, 0.681718],
|
|
604
|
+
[0, -0.525731, 0.850651],
|
|
605
|
+
[0.425325, -0.688191, 0.587785],
|
|
606
|
+
[0.587785, -0.425325, 0.688191],
|
|
607
|
+
[0.688191, -0.587785, 0.425325],
|
|
608
|
+
[-0.955423, 0.295242, 0],
|
|
609
|
+
[-0.951056, 0.16246, 0.262866],
|
|
610
|
+
[-1, 0, 0],
|
|
611
|
+
[-0.850651, 0, 0.525731],
|
|
612
|
+
[-0.955423, -0.295242, 0],
|
|
613
|
+
[-0.951056, -0.16246, 0.262866],
|
|
614
|
+
[-0.864188, 0.442863, -0.238856],
|
|
615
|
+
[-0.951056, 0.16246, -0.262866],
|
|
616
|
+
[-0.809017, 0.309017, -0.5],
|
|
617
|
+
[-0.864188, -0.442863, -0.238856],
|
|
618
|
+
[-0.951056, -0.16246, -0.262866],
|
|
619
|
+
[-0.809017, -0.309017, -0.5],
|
|
620
|
+
[-0.681718, 0.147621, -0.716567],
|
|
621
|
+
[-0.681718, -0.147621, -0.716567],
|
|
622
|
+
[-0.850651, 0, -0.525731],
|
|
623
|
+
[-0.688191, 0.587785, -0.425325],
|
|
624
|
+
[-0.587785, 0.425325, -0.688191],
|
|
625
|
+
[-0.425325, 0.688191, -0.587785],
|
|
626
|
+
[-0.425325, -0.688191, -0.587785],
|
|
627
|
+
[-0.587785, -0.425325, -0.688191],
|
|
628
|
+
[-0.688191, -0.587785, -0.425325]
|
|
629
|
+
];
|
|
466
630
|
STATE_SIZE = 624;
|
|
467
631
|
MIDDLE_WORD = 397;
|
|
468
632
|
MATRIX_A = 2567483615;
|
|
@@ -1166,6 +1330,333 @@ var init_esm = __esm({
|
|
|
1166
1330
|
velocity: finalVelocity
|
|
1167
1331
|
};
|
|
1168
1332
|
};
|
|
1333
|
+
BinaryWriter = class {
|
|
1334
|
+
constructor(sizeOrBuffer = 1400) {
|
|
1335
|
+
if (typeof sizeOrBuffer === "number") {
|
|
1336
|
+
this.buffer = new Uint8Array(sizeOrBuffer);
|
|
1337
|
+
this.fixed = false;
|
|
1338
|
+
} else {
|
|
1339
|
+
this.buffer = sizeOrBuffer;
|
|
1340
|
+
this.fixed = true;
|
|
1341
|
+
}
|
|
1342
|
+
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
1343
|
+
this.offset = 0;
|
|
1344
|
+
}
|
|
1345
|
+
ensureSpace(bytes) {
|
|
1346
|
+
if (this.offset + bytes > this.buffer.byteLength) {
|
|
1347
|
+
if (this.fixed) {
|
|
1348
|
+
throw new Error(`Buffer overflow: capacity ${this.buffer.byteLength}, needed ${this.offset + bytes}`);
|
|
1349
|
+
}
|
|
1350
|
+
const newSize = Math.max(this.buffer.byteLength * 2, this.offset + bytes);
|
|
1351
|
+
const newBuffer = new Uint8Array(newSize);
|
|
1352
|
+
newBuffer.set(this.buffer);
|
|
1353
|
+
this.buffer = newBuffer;
|
|
1354
|
+
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
writeByte(value) {
|
|
1358
|
+
this.ensureSpace(1);
|
|
1359
|
+
this.view.setUint8(this.offset, value);
|
|
1360
|
+
this.offset += 1;
|
|
1361
|
+
}
|
|
1362
|
+
writeChar(value) {
|
|
1363
|
+
this.ensureSpace(1);
|
|
1364
|
+
this.view.setInt8(this.offset, value);
|
|
1365
|
+
this.offset += 1;
|
|
1366
|
+
}
|
|
1367
|
+
writeShort(value) {
|
|
1368
|
+
this.ensureSpace(2);
|
|
1369
|
+
this.view.setInt16(this.offset, value, true);
|
|
1370
|
+
this.offset += 2;
|
|
1371
|
+
}
|
|
1372
|
+
writeLong(value) {
|
|
1373
|
+
this.ensureSpace(4);
|
|
1374
|
+
this.view.setInt32(this.offset, value, true);
|
|
1375
|
+
this.offset += 4;
|
|
1376
|
+
}
|
|
1377
|
+
writeFloat(value) {
|
|
1378
|
+
this.ensureSpace(4);
|
|
1379
|
+
this.view.setFloat32(this.offset, value, true);
|
|
1380
|
+
this.offset += 4;
|
|
1381
|
+
}
|
|
1382
|
+
writeString(value) {
|
|
1383
|
+
const len = value.length;
|
|
1384
|
+
this.ensureSpace(len + 1);
|
|
1385
|
+
for (let i = 0; i < len; i++) {
|
|
1386
|
+
this.view.setUint8(this.offset + i, value.charCodeAt(i));
|
|
1387
|
+
}
|
|
1388
|
+
this.view.setUint8(this.offset + len, 0);
|
|
1389
|
+
this.offset += len + 1;
|
|
1390
|
+
}
|
|
1391
|
+
writeCoord(value) {
|
|
1392
|
+
this.writeShort(Math.trunc(value * 8));
|
|
1393
|
+
}
|
|
1394
|
+
writeAngle(value) {
|
|
1395
|
+
this.writeByte(Math.trunc(value * 256 / 360) & 255);
|
|
1396
|
+
}
|
|
1397
|
+
writeAngle16(value) {
|
|
1398
|
+
this.writeShort(Math.trunc(value * 65536 / 360) & 65535);
|
|
1399
|
+
}
|
|
1400
|
+
writePos(pos) {
|
|
1401
|
+
this.writeCoord(pos.x);
|
|
1402
|
+
this.writeCoord(pos.y);
|
|
1403
|
+
this.writeCoord(pos.z);
|
|
1404
|
+
}
|
|
1405
|
+
writeDir(dir) {
|
|
1406
|
+
let maxDot = -1;
|
|
1407
|
+
let bestIndex = 0;
|
|
1408
|
+
if (dir.x === 0 && dir.y === 0 && dir.z === 0) {
|
|
1409
|
+
this.writeByte(0);
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
for (let i = 0; i < ANORMS.length; i++) {
|
|
1413
|
+
const norm = ANORMS[i];
|
|
1414
|
+
const dot = dir.x * norm[0] + dir.y * norm[1] + dir.z * norm[2];
|
|
1415
|
+
if (dot > maxDot) {
|
|
1416
|
+
maxDot = dot;
|
|
1417
|
+
bestIndex = i;
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
this.writeByte(bestIndex);
|
|
1421
|
+
}
|
|
1422
|
+
getData() {
|
|
1423
|
+
return this.buffer.slice(0, this.offset);
|
|
1424
|
+
}
|
|
1425
|
+
getBuffer() {
|
|
1426
|
+
return this.buffer;
|
|
1427
|
+
}
|
|
1428
|
+
getOffset() {
|
|
1429
|
+
return this.offset;
|
|
1430
|
+
}
|
|
1431
|
+
reset() {
|
|
1432
|
+
this.offset = 0;
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
_NetChan = class _NetChan2 {
|
|
1436
|
+
constructor() {
|
|
1437
|
+
this.qport = 0;
|
|
1438
|
+
this.incomingSequence = 0;
|
|
1439
|
+
this.outgoingSequence = 0;
|
|
1440
|
+
this.incomingAcknowledged = 0;
|
|
1441
|
+
this.incomingReliableAcknowledged = false;
|
|
1442
|
+
this.incomingReliableSequence = 0;
|
|
1443
|
+
this.outgoingReliableSequence = 0;
|
|
1444
|
+
this.reliableLength = 0;
|
|
1445
|
+
this.lastReceived = 0;
|
|
1446
|
+
this.lastSent = 0;
|
|
1447
|
+
this.remoteAddress = null;
|
|
1448
|
+
this.reliableMessage = new BinaryWriter(_NetChan2.MAX_MSGLEN);
|
|
1449
|
+
const now = Date.now();
|
|
1450
|
+
this.lastReceived = now;
|
|
1451
|
+
this.lastSent = now;
|
|
1452
|
+
this.qport = Math.floor(Math.random() * 65536);
|
|
1453
|
+
}
|
|
1454
|
+
/**
|
|
1455
|
+
* Setup the netchan with specific settings
|
|
1456
|
+
*/
|
|
1457
|
+
setup(qport, address = null) {
|
|
1458
|
+
this.qport = qport;
|
|
1459
|
+
this.remoteAddress = address;
|
|
1460
|
+
this.reset();
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Reset the netchan state
|
|
1464
|
+
*/
|
|
1465
|
+
reset() {
|
|
1466
|
+
this.incomingSequence = 0;
|
|
1467
|
+
this.outgoingSequence = 0;
|
|
1468
|
+
this.incomingAcknowledged = 0;
|
|
1469
|
+
this.incomingReliableAcknowledged = false;
|
|
1470
|
+
this.incomingReliableSequence = 0;
|
|
1471
|
+
this.outgoingReliableSequence = 0;
|
|
1472
|
+
this.reliableLength = 0;
|
|
1473
|
+
this.reliableMessage.reset();
|
|
1474
|
+
this.lastReceived = Date.now();
|
|
1475
|
+
this.lastSent = Date.now();
|
|
1476
|
+
}
|
|
1477
|
+
/**
|
|
1478
|
+
* Transmits a packet containing reliable and unreliable data
|
|
1479
|
+
*/
|
|
1480
|
+
transmit(unreliableData) {
|
|
1481
|
+
this.outgoingSequence++;
|
|
1482
|
+
this.lastSent = Date.now();
|
|
1483
|
+
const headerSize = _NetChan2.PACKET_HEADER;
|
|
1484
|
+
const reliableSize = this.reliableLength > 0 ? this.reliableLength + 2 : 0;
|
|
1485
|
+
let unreliableSize = unreliableData ? unreliableData.length : 0;
|
|
1486
|
+
if (headerSize + reliableSize + unreliableSize > _NetChan2.MAX_MSGLEN) {
|
|
1487
|
+
unreliableSize = _NetChan2.MAX_MSGLEN - headerSize - reliableSize;
|
|
1488
|
+
if (unreliableSize < 0) unreliableSize = 0;
|
|
1489
|
+
}
|
|
1490
|
+
const buffer = new ArrayBuffer(headerSize + reliableSize + unreliableSize);
|
|
1491
|
+
const view = new DataView(buffer);
|
|
1492
|
+
const result = new Uint8Array(buffer);
|
|
1493
|
+
let sequence = this.outgoingSequence;
|
|
1494
|
+
if (this.reliableLength > 0) {
|
|
1495
|
+
sequence |= 2147483648;
|
|
1496
|
+
if ((this.outgoingReliableSequence & 1) !== 0) {
|
|
1497
|
+
sequence |= 1073741824;
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
view.setUint32(0, sequence, true);
|
|
1501
|
+
let ack = this.incomingSequence;
|
|
1502
|
+
if ((this.incomingReliableSequence & 1) !== 0) {
|
|
1503
|
+
ack |= 2147483648;
|
|
1504
|
+
}
|
|
1505
|
+
view.setUint32(4, ack, true);
|
|
1506
|
+
view.setUint16(8, this.qport, true);
|
|
1507
|
+
let offset = headerSize;
|
|
1508
|
+
if (this.reliableLength > 0) {
|
|
1509
|
+
view.setUint16(offset, this.reliableLength, true);
|
|
1510
|
+
offset += 2;
|
|
1511
|
+
const reliableBuffer = this.reliableMessage.getBuffer();
|
|
1512
|
+
const reliableBytes = reliableBuffer.subarray(0, this.reliableLength);
|
|
1513
|
+
result.set(reliableBytes, offset);
|
|
1514
|
+
offset += this.reliableLength;
|
|
1515
|
+
}
|
|
1516
|
+
if (unreliableData && unreliableSize > 0) {
|
|
1517
|
+
const chunk = unreliableData.slice(0, unreliableSize);
|
|
1518
|
+
result.set(chunk, offset);
|
|
1519
|
+
}
|
|
1520
|
+
return result;
|
|
1521
|
+
}
|
|
1522
|
+
/**
|
|
1523
|
+
* Processes a received packet
|
|
1524
|
+
* Returns the payload data (reliable + unreliable) to be processed, or null if discarded
|
|
1525
|
+
*/
|
|
1526
|
+
process(packet) {
|
|
1527
|
+
if (packet.length < _NetChan2.PACKET_HEADER) {
|
|
1528
|
+
return null;
|
|
1529
|
+
}
|
|
1530
|
+
this.lastReceived = Date.now();
|
|
1531
|
+
const view = new DataView(packet.buffer, packet.byteOffset, packet.byteLength);
|
|
1532
|
+
const sequence = view.getUint32(0, true);
|
|
1533
|
+
const ack = view.getUint32(4, true);
|
|
1534
|
+
const qport = view.getUint16(8, true);
|
|
1535
|
+
if (this.qport !== qport) {
|
|
1536
|
+
return null;
|
|
1537
|
+
}
|
|
1538
|
+
const seqNumberClean = sequence & ~(2147483648 | 1073741824);
|
|
1539
|
+
if ((seqNumberClean - this.incomingSequence | 0) <= 0) {
|
|
1540
|
+
return null;
|
|
1541
|
+
}
|
|
1542
|
+
this.incomingSequence = seqNumberClean;
|
|
1543
|
+
const ackNumber = ack & ~2147483648;
|
|
1544
|
+
const ackReliable = (ack & 2147483648) !== 0;
|
|
1545
|
+
if (ackNumber > this.incomingAcknowledged) {
|
|
1546
|
+
this.incomingAcknowledged = ackNumber;
|
|
1547
|
+
}
|
|
1548
|
+
if (this.reliableLength > 0) {
|
|
1549
|
+
const receivedAckBit = ackReliable ? 1 : 0;
|
|
1550
|
+
const currentReliableBit = this.outgoingReliableSequence & 1;
|
|
1551
|
+
if (receivedAckBit !== currentReliableBit) {
|
|
1552
|
+
this.reliableLength = 0;
|
|
1553
|
+
this.reliableMessage.reset();
|
|
1554
|
+
this.outgoingReliableSequence ^= 1;
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
const hasReliableData = (sequence & 2147483648) !== 0;
|
|
1558
|
+
const reliableSeqBit = (sequence & 1073741824) !== 0 ? 1 : 0;
|
|
1559
|
+
let payloadOffset = _NetChan2.PACKET_HEADER;
|
|
1560
|
+
let reliableData = null;
|
|
1561
|
+
if (hasReliableData) {
|
|
1562
|
+
if (payloadOffset + 2 > packet.byteLength) return null;
|
|
1563
|
+
const reliableLen = view.getUint16(payloadOffset, true);
|
|
1564
|
+
payloadOffset += 2;
|
|
1565
|
+
const expectedBit = this.incomingReliableSequence & 1;
|
|
1566
|
+
if (reliableSeqBit === expectedBit) {
|
|
1567
|
+
this.incomingReliableSequence++;
|
|
1568
|
+
if (payloadOffset + reliableLen > packet.byteLength) return null;
|
|
1569
|
+
reliableData = packet.slice(payloadOffset, payloadOffset + reliableLen);
|
|
1570
|
+
}
|
|
1571
|
+
payloadOffset += reliableLen;
|
|
1572
|
+
}
|
|
1573
|
+
const unreliableData = packet.slice(payloadOffset);
|
|
1574
|
+
if (reliableData && reliableData.length > 0) {
|
|
1575
|
+
const totalLen = reliableData.length + unreliableData.length;
|
|
1576
|
+
const result = new Uint8Array(totalLen);
|
|
1577
|
+
result.set(reliableData, 0);
|
|
1578
|
+
result.set(unreliableData, reliableData.length);
|
|
1579
|
+
return result;
|
|
1580
|
+
}
|
|
1581
|
+
if (unreliableData) {
|
|
1582
|
+
return unreliableData;
|
|
1583
|
+
}
|
|
1584
|
+
return new Uint8Array(0);
|
|
1585
|
+
}
|
|
1586
|
+
/**
|
|
1587
|
+
* Checks if reliable message buffer is empty and ready for new data
|
|
1588
|
+
*/
|
|
1589
|
+
canSendReliable() {
|
|
1590
|
+
return this.reliableLength === 0;
|
|
1591
|
+
}
|
|
1592
|
+
/**
|
|
1593
|
+
* Writes a byte to the reliable message buffer
|
|
1594
|
+
*/
|
|
1595
|
+
writeReliableByte(value) {
|
|
1596
|
+
if (this.reliableLength + 1 > _NetChan2.MAX_MSGLEN - _NetChan2.HEADER_OVERHEAD) {
|
|
1597
|
+
throw new Error("NetChan reliable buffer overflow");
|
|
1598
|
+
}
|
|
1599
|
+
this.reliableMessage.writeByte(value);
|
|
1600
|
+
this.reliableLength++;
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* Writes a short to the reliable message buffer
|
|
1604
|
+
*/
|
|
1605
|
+
writeReliableShort(value) {
|
|
1606
|
+
if (this.reliableLength + 2 > _NetChan2.MAX_MSGLEN - _NetChan2.HEADER_OVERHEAD) {
|
|
1607
|
+
throw new Error("NetChan reliable buffer overflow");
|
|
1608
|
+
}
|
|
1609
|
+
this.reliableMessage.writeShort(value);
|
|
1610
|
+
this.reliableLength += 2;
|
|
1611
|
+
}
|
|
1612
|
+
/**
|
|
1613
|
+
* Writes a long to the reliable message buffer
|
|
1614
|
+
*/
|
|
1615
|
+
writeReliableLong(value) {
|
|
1616
|
+
if (this.reliableLength + 4 > _NetChan2.MAX_MSGLEN - _NetChan2.HEADER_OVERHEAD) {
|
|
1617
|
+
throw new Error("NetChan reliable buffer overflow");
|
|
1618
|
+
}
|
|
1619
|
+
this.reliableMessage.writeLong(value);
|
|
1620
|
+
this.reliableLength += 4;
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Writes a string to the reliable message buffer
|
|
1624
|
+
*/
|
|
1625
|
+
writeReliableString(value) {
|
|
1626
|
+
const len = value.length + 1;
|
|
1627
|
+
if (this.reliableLength + len > _NetChan2.MAX_MSGLEN - _NetChan2.HEADER_OVERHEAD) {
|
|
1628
|
+
throw new Error("NetChan reliable buffer overflow");
|
|
1629
|
+
}
|
|
1630
|
+
this.reliableMessage.writeString(value);
|
|
1631
|
+
this.reliableLength += len;
|
|
1632
|
+
}
|
|
1633
|
+
/**
|
|
1634
|
+
* Returns the current reliable data buffer
|
|
1635
|
+
*/
|
|
1636
|
+
getReliableData() {
|
|
1637
|
+
if (this.reliableLength === 0) {
|
|
1638
|
+
return new Uint8Array(0);
|
|
1639
|
+
}
|
|
1640
|
+
const buffer = this.reliableMessage.getBuffer();
|
|
1641
|
+
return buffer.subarray(0, this.reliableLength);
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Checks if we need to send a keepalive packet
|
|
1645
|
+
*/
|
|
1646
|
+
needsKeepalive(currentTime) {
|
|
1647
|
+
return currentTime - this.lastSent > 1e3;
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* Checks if the connection has timed out
|
|
1651
|
+
*/
|
|
1652
|
+
isTimedOut(currentTime, timeoutMs = 3e4) {
|
|
1653
|
+
return currentTime - this.lastReceived > timeoutMs;
|
|
1654
|
+
}
|
|
1655
|
+
};
|
|
1656
|
+
_NetChan.MAX_MSGLEN = 1400;
|
|
1657
|
+
_NetChan.FRAGMENT_SIZE = 1024;
|
|
1658
|
+
_NetChan.PACKET_HEADER = 10;
|
|
1659
|
+
_NetChan.HEADER_OVERHEAD = _NetChan.PACKET_HEADER + 2;
|
|
1169
1660
|
WeaponId = /* @__PURE__ */ ((WeaponId22) => {
|
|
1170
1661
|
WeaponId22["Blaster"] = "blaster";
|
|
1171
1662
|
WeaponId22["Shotgun"] = "shotgun";
|
|
@@ -1236,6 +1727,22 @@ var init_esm = __esm({
|
|
|
1236
1727
|
"bfg10k"
|
|
1237
1728
|
/* BFG10K */
|
|
1238
1729
|
];
|
|
1730
|
+
SoundChannel = /* @__PURE__ */ ((SoundChannel2) => {
|
|
1731
|
+
SoundChannel2[SoundChannel2["Auto"] = 0] = "Auto";
|
|
1732
|
+
SoundChannel2[SoundChannel2["Weapon"] = 1] = "Weapon";
|
|
1733
|
+
SoundChannel2[SoundChannel2["Voice"] = 2] = "Voice";
|
|
1734
|
+
SoundChannel2[SoundChannel2["Item"] = 3] = "Item";
|
|
1735
|
+
SoundChannel2[SoundChannel2["Body"] = 4] = "Body";
|
|
1736
|
+
SoundChannel2[SoundChannel2["Aux"] = 5] = "Aux";
|
|
1737
|
+
SoundChannel2[SoundChannel2["Footstep"] = 6] = "Footstep";
|
|
1738
|
+
SoundChannel2[SoundChannel2["Aux3"] = 7] = "Aux3";
|
|
1739
|
+
SoundChannel2[SoundChannel2["NoPhsAdd"] = 8] = "NoPhsAdd";
|
|
1740
|
+
SoundChannel2[SoundChannel2["Reliable"] = 16] = "Reliable";
|
|
1741
|
+
SoundChannel2[SoundChannel2["ForcePos"] = 32] = "ForcePos";
|
|
1742
|
+
return SoundChannel2;
|
|
1743
|
+
})(SoundChannel || {});
|
|
1744
|
+
ATTN_NORM = 1;
|
|
1745
|
+
ATTN_IDLE = 2;
|
|
1239
1746
|
}
|
|
1240
1747
|
});
|
|
1241
1748
|
|
|
@@ -3640,6 +4147,9 @@ var EntitySystem = class {
|
|
|
3640
4147
|
sound(entity, channel, sound, volume, attenuation, timeofs) {
|
|
3641
4148
|
this.engine.sound?.(entity, channel, sound, volume, attenuation, timeofs);
|
|
3642
4149
|
}
|
|
4150
|
+
soundIndex(sound) {
|
|
4151
|
+
return this.engine.soundIndex?.(sound) || 0;
|
|
4152
|
+
}
|
|
3643
4153
|
modelIndex(model) {
|
|
3644
4154
|
return this.engine.modelIndex?.(model) || 0;
|
|
3645
4155
|
}
|
|
@@ -4798,7 +5308,7 @@ function createBfgBall(sys, owner, start, dir, damage, speed, damageRadius) {
|
|
|
4798
5308
|
|
|
4799
5309
|
// src/entities/targets.ts
|
|
4800
5310
|
var ATTN_NONE = 0;
|
|
4801
|
-
var
|
|
5311
|
+
var ATTN_NORM2 = 1;
|
|
4802
5312
|
var SPEAKER_SPAWNFLAGS = {
|
|
4803
5313
|
LoopedOn: 1 << 0,
|
|
4804
5314
|
LoopedOff: 1 << 1,
|
|
@@ -4890,7 +5400,7 @@ function useTargetBlaster(self, other, activator, context) {
|
|
|
4890
5400
|
bolt.effects = 0;
|
|
4891
5401
|
}
|
|
4892
5402
|
}
|
|
4893
|
-
context.entities.sound(self, 2, "weapons/laser2.wav", 1,
|
|
5403
|
+
context.entities.sound(self, 2, "weapons/laser2.wav", 1, ATTN_NORM2, 0);
|
|
4894
5404
|
}
|
|
4895
5405
|
var SPAWNFLAG_EARTHQUAKE_SILENT = 1;
|
|
4896
5406
|
var SPAWNFLAG_EARTHQUAKE_TOGGLE = 2;
|
|
@@ -5115,7 +5625,7 @@ function registerTargetSpawns(registry) {
|
|
|
5115
5625
|
if (attenuation) {
|
|
5116
5626
|
entity.attenuation = Number.parseFloat(attenuation);
|
|
5117
5627
|
} else {
|
|
5118
|
-
entity.attenuation =
|
|
5628
|
+
entity.attenuation = ATTN_NORM2;
|
|
5119
5629
|
}
|
|
5120
5630
|
if (context.keyValues.volume) {
|
|
5121
5631
|
entity.volume = Number.parseFloat(context.keyValues.volume);
|
|
@@ -12626,6 +13136,12 @@ var actor_names = [
|
|
|
12626
13136
|
"Titus",
|
|
12627
13137
|
"Bitterman"
|
|
12628
13138
|
];
|
|
13139
|
+
var sound_pain1 = "player/male/pain100.wav";
|
|
13140
|
+
var sound_pain2 = "player/male/pain75.wav";
|
|
13141
|
+
var sound_pain3 = "player/male/pain50.wav";
|
|
13142
|
+
var sound_die1 = "player/male/death1.wav";
|
|
13143
|
+
var sound_die2 = "player/male/death2.wav";
|
|
13144
|
+
var sound_gib = "misc/udeath.wav";
|
|
12629
13145
|
var FRAME_stand101 = 0;
|
|
12630
13146
|
var FRAME_stand140 = 39;
|
|
12631
13147
|
var FRAME_walk01 = 40;
|
|
@@ -12700,6 +13216,11 @@ function actor_pain(self, other, kick, damage) {
|
|
|
12700
13216
|
if (context.timeSeconds < self.pain_debounce_time)
|
|
12701
13217
|
return;
|
|
12702
13218
|
self.pain_debounce_time = context.timeSeconds + 3;
|
|
13219
|
+
const n = Math.floor(Math.random() * 3);
|
|
13220
|
+
let sound = sound_pain1;
|
|
13221
|
+
if (n === 1) sound = sound_pain2;
|
|
13222
|
+
if (n === 2) sound = sound_pain3;
|
|
13223
|
+
context.sound(self, SoundChannel.Voice, sound, 1, ATTN_NORM, 0);
|
|
12703
13224
|
const random13 = Math.random();
|
|
12704
13225
|
if (other && other.client && random13 < 0.4) {
|
|
12705
13226
|
const v = subtractVec3(other.origin, self.origin);
|
|
@@ -12714,7 +13235,6 @@ function actor_pain(self, other, kick, damage) {
|
|
|
12714
13235
|
`);
|
|
12715
13236
|
return;
|
|
12716
13237
|
}
|
|
12717
|
-
const n = Math.floor(Math.random() * 3);
|
|
12718
13238
|
if (n === 0)
|
|
12719
13239
|
self.monsterinfo.current_move = actor_move_pain1;
|
|
12720
13240
|
else if (n === 1)
|
|
@@ -12763,15 +13283,19 @@ function actor_die(self, inflictor, attacker, damage, point, mod) {
|
|
|
12763
13283
|
const context = self.monsterinfo.context;
|
|
12764
13284
|
if (!context) return;
|
|
12765
13285
|
if (self.health <= -80) {
|
|
13286
|
+
context.sound(self, SoundChannel.Voice, sound_gib, 1, ATTN_NORM, 0);
|
|
12766
13287
|
throwGibs(context, self.origin, damage);
|
|
12767
13288
|
self.deadflag = 2 /* Dead */;
|
|
12768
13289
|
return;
|
|
12769
13290
|
}
|
|
12770
13291
|
if (self.deadflag === 2 /* Dead */)
|
|
12771
13292
|
return;
|
|
13293
|
+
const n = Math.floor(Math.random() * 2);
|
|
13294
|
+
const sound = n === 0 ? sound_die1 : sound_die2;
|
|
13295
|
+
context.sound(self, SoundChannel.Voice, sound, 1, ATTN_NORM, 0);
|
|
12772
13296
|
self.deadflag = 2 /* Dead */;
|
|
12773
13297
|
self.takedamage = true;
|
|
12774
|
-
if (
|
|
13298
|
+
if (n === 0)
|
|
12775
13299
|
self.monsterinfo.current_move = actor_move_death1;
|
|
12776
13300
|
else
|
|
12777
13301
|
self.monsterinfo.current_move = actor_move_death2;
|
|
@@ -13039,6 +13563,13 @@ function SP_misc_actor(self, context) {
|
|
|
13039
13563
|
self.mass = 200;
|
|
13040
13564
|
self.pain = actor_pain;
|
|
13041
13565
|
self.die = actor_die;
|
|
13566
|
+
context.entities.soundIndex(sound_pain1);
|
|
13567
|
+
context.entities.soundIndex(sound_pain2);
|
|
13568
|
+
context.entities.soundIndex(sound_pain3);
|
|
13569
|
+
context.entities.soundIndex(sound_die1);
|
|
13570
|
+
context.entities.soundIndex(sound_die2);
|
|
13571
|
+
context.entities.soundIndex(sound_gib);
|
|
13572
|
+
context.entities.soundIndex("player/male/jump1.wav");
|
|
13042
13573
|
self.monsterinfo = {
|
|
13043
13574
|
...self.monsterinfo,
|
|
13044
13575
|
// Preserve default properties like last_sighting, trail_time, pausetime
|
|
@@ -13089,7 +13620,7 @@ function target_actor_touch(self, other, plane, surf) {
|
|
|
13089
13620
|
if (other.groundentity) {
|
|
13090
13621
|
other.groundentity = null;
|
|
13091
13622
|
v.z = self.movedir.z;
|
|
13092
|
-
context.sound(other,
|
|
13623
|
+
context.sound(other, SoundChannel.Voice, "player/male/jump1.wav", 1, ATTN_NORM, 0);
|
|
13093
13624
|
}
|
|
13094
13625
|
}
|
|
13095
13626
|
if (self.spawnflags & SPAWNFLAG_TARGET_ACTOR_SHOOT) {
|
|
@@ -16410,11 +16941,6 @@ var FRAME_rails_up16 = 113;
|
|
|
16410
16941
|
var MODEL_SCALE = 1;
|
|
16411
16942
|
var MELEE_DISTANCE5 = 64;
|
|
16412
16943
|
var MONSTER_TICK27 = 0.1;
|
|
16413
|
-
var CHAN_WEAPON = 1;
|
|
16414
|
-
var CHAN_VOICE = 2;
|
|
16415
|
-
var CHAN_BODY = 4;
|
|
16416
|
-
var ATTN_NORM2 = 1;
|
|
16417
|
-
var ATTN_IDLE = 2;
|
|
16418
16944
|
var MZ2_ARACHNID_RAIL1 = 20;
|
|
16419
16945
|
var MZ2_ARACHNID_RAIL2 = 21;
|
|
16420
16946
|
var MZ2_ARACHNID_RAIL_UP1 = 22;
|
|
@@ -16466,7 +16992,7 @@ function arachnid_stand(self, context) {
|
|
|
16466
16992
|
M_SetAnimation3(self, arachnid_move_stand, context);
|
|
16467
16993
|
}
|
|
16468
16994
|
function arachnid_footstep(self, context) {
|
|
16469
|
-
context.engine.sound?.(self,
|
|
16995
|
+
context.engine.sound?.(self, SoundChannel.Body, sound_step, 0.5, ATTN_IDLE, 0);
|
|
16470
16996
|
}
|
|
16471
16997
|
var arachnid_frames_walk = [
|
|
16472
16998
|
{ ai: monster_ai_walk22, dist: 8, think: arachnid_footstep },
|
|
@@ -16545,7 +17071,7 @@ function arachnid_pain(self, other, kick, damage, context) {
|
|
|
16545
17071
|
return;
|
|
16546
17072
|
}
|
|
16547
17073
|
self.pain_debounce_time = context.timeSeconds + 3;
|
|
16548
|
-
context.engine.sound?.(self,
|
|
17074
|
+
context.engine.sound?.(self, SoundChannel.Voice, sound_pain, 1, ATTN_NORM, 0);
|
|
16549
17075
|
if (!M_ShouldReactToPain(self)) {
|
|
16550
17076
|
return;
|
|
16551
17077
|
}
|
|
@@ -16559,7 +17085,7 @@ function arachnid_charge_rail(self, context) {
|
|
|
16559
17085
|
if (!self.enemy || !self.enemy.inUse) {
|
|
16560
17086
|
return;
|
|
16561
17087
|
}
|
|
16562
|
-
context.engine.sound?.(self,
|
|
17088
|
+
context.engine.sound?.(self, SoundChannel.Weapon, sound_charge, 1, ATTN_NORM, 0);
|
|
16563
17089
|
self.pos1 = { ...self.enemy.origin };
|
|
16564
17090
|
self.pos1 = { ...self.pos1, z: self.pos1.z + self.enemy.viewheight };
|
|
16565
17091
|
}
|
|
@@ -16630,7 +17156,7 @@ var arachnid_attack_up1 = {
|
|
|
16630
17156
|
endfunc: arachnid_run
|
|
16631
17157
|
};
|
|
16632
17158
|
function arachnid_melee_charge(self, context) {
|
|
16633
|
-
context.engine.sound?.(self,
|
|
17159
|
+
context.engine.sound?.(self, SoundChannel.Weapon, sound_melee, 1, ATTN_NORM, 0);
|
|
16634
17160
|
}
|
|
16635
17161
|
function arachnid_melee_hit(self, context) {
|
|
16636
17162
|
if (!monster_fire_hit(self, { x: MELEE_DISTANCE5, y: 0, z: 0 }, 15, 50, context)) {
|
|
@@ -16707,7 +17233,7 @@ var arachnid_move_death = {
|
|
|
16707
17233
|
};
|
|
16708
17234
|
function arachnid_die(self, inflictor, attacker, damage, point, mod, context) {
|
|
16709
17235
|
if (M_CheckGib(self, context)) {
|
|
16710
|
-
context.engine.sound?.(self,
|
|
17236
|
+
context.engine.sound?.(self, SoundChannel.Voice, "misc/udeath.wav", 1, ATTN_NORM, 0);
|
|
16711
17237
|
throwGibs(context, self.origin, damage);
|
|
16712
17238
|
self.deadflag = 2 /* Dead */;
|
|
16713
17239
|
return;
|
|
@@ -16715,7 +17241,7 @@ function arachnid_die(self, inflictor, attacker, damage, point, mod, context) {
|
|
|
16715
17241
|
if (self.deadflag === 2 /* Dead */) {
|
|
16716
17242
|
return;
|
|
16717
17243
|
}
|
|
16718
|
-
context.engine.sound?.(self,
|
|
17244
|
+
context.engine.sound?.(self, SoundChannel.Voice, sound_death, 1, ATTN_NORM, 0);
|
|
16719
17245
|
self.deadflag = 2 /* Dead */;
|
|
16720
17246
|
self.takedamage = true;
|
|
16721
17247
|
M_SetAnimation3(self, arachnid_move_death, context);
|
|
@@ -16733,6 +17259,14 @@ function SP_monster_arachnid(self, context) {
|
|
|
16733
17259
|
sound_pain = "arachnid/pain.wav";
|
|
16734
17260
|
sound_death = "arachnid/death.wav";
|
|
16735
17261
|
sound_sight = "arachnid/sight.wav";
|
|
17262
|
+
context.soundIndex(sound_step);
|
|
17263
|
+
context.soundIndex(sound_charge);
|
|
17264
|
+
context.soundIndex(sound_melee);
|
|
17265
|
+
context.soundIndex(sound_melee_hit);
|
|
17266
|
+
context.soundIndex(sound_pain);
|
|
17267
|
+
context.soundIndex(sound_death);
|
|
17268
|
+
context.soundIndex(sound_sight);
|
|
17269
|
+
context.soundIndex("misc/udeath.wav");
|
|
16736
17270
|
self.model = "models/monsters/arachnid/tris.md2";
|
|
16737
17271
|
self.mins = { x: -48, y: -48, z: -20 };
|
|
16738
17272
|
self.maxs = { x: 48, y: 48, z: 48 };
|
|
@@ -16749,7 +17283,7 @@ function SP_monster_arachnid(self, context) {
|
|
|
16749
17283
|
walk: arachnid_walk,
|
|
16750
17284
|
run: arachnid_run,
|
|
16751
17285
|
attack: arachnid_attack,
|
|
16752
|
-
sight: (e, o) => context.engine.sound?.(e,
|
|
17286
|
+
sight: (e, o) => context.engine.sound?.(e, SoundChannel.Voice, sound_sight, 1, ATTN_NORM, 0),
|
|
16753
17287
|
scale: MODEL_SCALE,
|
|
16754
17288
|
aiflags: self.monsterinfo?.aiflags || 0
|
|
16755
17289
|
};
|
|
@@ -19022,6 +19556,9 @@ function createGame(imports, engine, options) {
|
|
|
19022
19556
|
sound(entity, channel, sound, volume, attenuation, timeofs) {
|
|
19023
19557
|
entities.sound(entity, channel, sound, volume, attenuation, timeofs);
|
|
19024
19558
|
},
|
|
19559
|
+
soundIndex(sound) {
|
|
19560
|
+
return entities.soundIndex(sound);
|
|
19561
|
+
},
|
|
19025
19562
|
centerprintf(entity, message) {
|
|
19026
19563
|
engine.centerprintf?.(entity, message);
|
|
19027
19564
|
},
|