quake2ts 0.0.469 → 0.0.470
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 +16 -16
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/browser/index.global.js +4 -4
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs +130 -73
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +129 -73
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/ai/noise.d.ts +1 -0
- package/packages/game/dist/types/ai/noise.d.ts.map +1 -1
- package/packages/game/dist/types/ai/targeting.d.ts.map +1 -1
- package/packages/game/dist/types/inventory/playerInventory.d.ts +8 -0
- package/packages/game/dist/types/inventory/playerInventory.d.ts.map +1 -1
- package/packages/game/dist/types/physics/fluid.d.ts +5 -0
- package/packages/game/dist/types/physics/fluid.d.ts.map +1 -1
- package/packages/game/dist/types/physics/movement.d.ts.map +1 -1
|
@@ -2620,6 +2620,7 @@ __export(index_exports, {
|
|
|
2620
2620
|
pickupPowerArmor: () => pickupPowerArmor,
|
|
2621
2621
|
pickupPowerup: () => pickupPowerup,
|
|
2622
2622
|
pickupWeapon: () => pickupWeapon,
|
|
2623
|
+
player_noise: () => player_noise,
|
|
2623
2624
|
range: () => rangeTo,
|
|
2624
2625
|
rangeTo: () => rangeTo,
|
|
2625
2626
|
registerCallback: () => registerCallback,
|
|
@@ -3586,11 +3587,19 @@ function findTarget(self, level, context, trace, hearability = {}) {
|
|
|
3586
3587
|
return false;
|
|
3587
3588
|
}
|
|
3588
3589
|
const { candidate, heardit } = chooseCandidate(self, level);
|
|
3589
|
-
if (!candidate || !candidate.inUse)
|
|
3590
|
-
|
|
3591
|
-
|
|
3590
|
+
if (!candidate || !candidate.inUse) {
|
|
3591
|
+
return false;
|
|
3592
|
+
}
|
|
3593
|
+
if (candidate === self.enemy) {
|
|
3594
|
+
return true;
|
|
3595
|
+
}
|
|
3596
|
+
if (rejectNotargetEntity(candidate)) {
|
|
3597
|
+
return false;
|
|
3598
|
+
}
|
|
3592
3599
|
if (!heardit) {
|
|
3593
|
-
if (!classifyClientVisibility(self, candidate, level, trace))
|
|
3600
|
+
if (!classifyClientVisibility(self, candidate, level, trace)) {
|
|
3601
|
+
return false;
|
|
3602
|
+
}
|
|
3594
3603
|
self.monsterinfo.aiflags &= ~4 /* SoundTarget */;
|
|
3595
3604
|
self.enemy = candidate;
|
|
3596
3605
|
} else if (!updateSoundChase(self, candidate, level, hearability, trace)) {
|
|
@@ -4538,6 +4547,91 @@ function killBox(teleporter, targets, options = {}) {
|
|
|
4538
4547
|
return { events, cleared };
|
|
4539
4548
|
}
|
|
4540
4549
|
|
|
4550
|
+
// src/physics/fluid.ts
|
|
4551
|
+
init_esm();
|
|
4552
|
+
function checkWater2(ent, system, imports) {
|
|
4553
|
+
const origin = ent.origin;
|
|
4554
|
+
const mins = ent.mins;
|
|
4555
|
+
const maxs = ent.maxs;
|
|
4556
|
+
if (!origin || !mins || !maxs) {
|
|
4557
|
+
return;
|
|
4558
|
+
}
|
|
4559
|
+
const point = {
|
|
4560
|
+
x: origin.x + (mins.x + maxs.x) * 0.5,
|
|
4561
|
+
y: origin.y + (mins.y + maxs.y) * 0.5,
|
|
4562
|
+
z: origin.z + mins.z + 1
|
|
4563
|
+
};
|
|
4564
|
+
let cont = imports.pointcontents(point);
|
|
4565
|
+
if ((cont & MASK_WATER) === 0) {
|
|
4566
|
+
if (ent.waterlevel > 0) {
|
|
4567
|
+
playLeaveWaterSound(ent, system);
|
|
4568
|
+
ent.flags &= ~2 /* Swim */;
|
|
4569
|
+
}
|
|
4570
|
+
ent.waterlevel = 0;
|
|
4571
|
+
ent.watertype = 0;
|
|
4572
|
+
return;
|
|
4573
|
+
}
|
|
4574
|
+
ent.watertype = cont;
|
|
4575
|
+
ent.waterlevel = 1;
|
|
4576
|
+
const viewheight = ent.viewheight || (maxs.z - mins.z) * 0.8;
|
|
4577
|
+
const waist = origin.z + (mins.z + maxs.z) * 0.5;
|
|
4578
|
+
const feetZ = origin.z + mins.z + 1;
|
|
4579
|
+
const waistZ = origin.z + mins.z + (maxs.z - mins.z) * 0.5;
|
|
4580
|
+
const headZ = origin.z + maxs.z - 1;
|
|
4581
|
+
const waistPoint = { ...point, z: waistZ };
|
|
4582
|
+
cont = imports.pointcontents(waistPoint);
|
|
4583
|
+
if (cont & MASK_WATER) {
|
|
4584
|
+
ent.waterlevel = 2;
|
|
4585
|
+
const headPoint = { ...point, z: headZ };
|
|
4586
|
+
cont = imports.pointcontents(headPoint);
|
|
4587
|
+
if (cont & MASK_WATER) {
|
|
4588
|
+
ent.waterlevel = 3;
|
|
4589
|
+
}
|
|
4590
|
+
}
|
|
4591
|
+
if ((ent.flags & 2 /* Swim */) === 0) {
|
|
4592
|
+
playEnterWaterSound(ent, system);
|
|
4593
|
+
ent.flags |= 2 /* Swim */;
|
|
4594
|
+
}
|
|
4595
|
+
}
|
|
4596
|
+
function playEnterWaterSound(ent, system) {
|
|
4597
|
+
if (ent.watertype & CONTENTS_LAVA) {
|
|
4598
|
+
system.sound(ent, 0, "player/lava_in.wav", 1, 1, 0);
|
|
4599
|
+
} else if (ent.watertype & CONTENTS_SLIME) {
|
|
4600
|
+
system.sound(ent, 0, "player/watr_in.wav", 1, 1, 0);
|
|
4601
|
+
} else if (ent.watertype & CONTENTS_WATER) {
|
|
4602
|
+
system.sound(ent, 0, "player/watr_in.wav", 1, 1, 0);
|
|
4603
|
+
}
|
|
4604
|
+
}
|
|
4605
|
+
function playLeaveWaterSound(ent, system) {
|
|
4606
|
+
if (ent.watertype & CONTENTS_LAVA) {
|
|
4607
|
+
system.sound(ent, 0, "player/lava_out.wav", 1, 1, 0);
|
|
4608
|
+
} else if (ent.watertype & CONTENTS_SLIME) {
|
|
4609
|
+
system.sound(ent, 0, "player/watr_out.wav", 1, 1, 0);
|
|
4610
|
+
} else if (ent.watertype & CONTENTS_WATER) {
|
|
4611
|
+
system.sound(ent, 0, "player/watr_out.wav", 1, 1, 0);
|
|
4612
|
+
}
|
|
4613
|
+
}
|
|
4614
|
+
function SV_AddCurrents(ent, currentSpeed = 400) {
|
|
4615
|
+
if (!(ent.watertype & MASK_CURRENT)) {
|
|
4616
|
+
return;
|
|
4617
|
+
}
|
|
4618
|
+
const v = { x: 0, y: 0, z: 0 };
|
|
4619
|
+
if (ent.watertype & CONTENTS_CURRENT_0) v.x += 1;
|
|
4620
|
+
if (ent.watertype & CONTENTS_CURRENT_90) v.y += 1;
|
|
4621
|
+
if (ent.watertype & CONTENTS_CURRENT_180) v.x -= 1;
|
|
4622
|
+
if (ent.watertype & CONTENTS_CURRENT_270) v.y -= 1;
|
|
4623
|
+
if (ent.watertype & CONTENTS_CURRENT_UP) v.z += 1;
|
|
4624
|
+
if (ent.watertype & CONTENTS_CURRENT_DOWN) v.z -= 1;
|
|
4625
|
+
let speed = currentSpeed;
|
|
4626
|
+
if (ent.waterlevel === 1 && ent.groundentity) {
|
|
4627
|
+
speed *= 0.5;
|
|
4628
|
+
}
|
|
4629
|
+
const velocity = ent.velocity;
|
|
4630
|
+
velocity.x += v.x * speed;
|
|
4631
|
+
velocity.y += v.y * speed;
|
|
4632
|
+
velocity.z += v.z * speed;
|
|
4633
|
+
}
|
|
4634
|
+
|
|
4541
4635
|
// src/physics/movement.ts
|
|
4542
4636
|
var WATER_FRICTION = 2;
|
|
4543
4637
|
var WATER_GRAVITY_SCALE = 0.1;
|
|
@@ -4604,6 +4698,9 @@ function runStep(ent, system, imports, gravity, frametime) {
|
|
|
4604
4698
|
if (!isFlying) {
|
|
4605
4699
|
ent.velocity = addVec3(ent.velocity, scaleVec3(gravity, ent.gravity * frametime));
|
|
4606
4700
|
}
|
|
4701
|
+
if (ent.waterlevel > 0) {
|
|
4702
|
+
SV_AddCurrents(ent);
|
|
4703
|
+
}
|
|
4607
4704
|
let timeLeft = frametime;
|
|
4608
4705
|
let velocity = { ...ent.velocity };
|
|
4609
4706
|
for (let i = 0; i < 4; i++) {
|
|
@@ -4781,71 +4878,6 @@ function runPush(pusher, system, imports, frametime) {
|
|
|
4781
4878
|
return true;
|
|
4782
4879
|
}
|
|
4783
4880
|
|
|
4784
|
-
// src/physics/fluid.ts
|
|
4785
|
-
init_esm();
|
|
4786
|
-
function checkWater2(ent, system, imports) {
|
|
4787
|
-
const origin = ent.origin;
|
|
4788
|
-
const mins = ent.mins;
|
|
4789
|
-
const maxs = ent.maxs;
|
|
4790
|
-
if (!origin || !mins || !maxs) {
|
|
4791
|
-
return;
|
|
4792
|
-
}
|
|
4793
|
-
const point = {
|
|
4794
|
-
x: origin.x + (mins.x + maxs.x) * 0.5,
|
|
4795
|
-
y: origin.y + (mins.y + maxs.y) * 0.5,
|
|
4796
|
-
z: origin.z + mins.z + 1
|
|
4797
|
-
};
|
|
4798
|
-
let cont = imports.pointcontents(point);
|
|
4799
|
-
if ((cont & MASK_WATER) === 0) {
|
|
4800
|
-
if (ent.waterlevel > 0) {
|
|
4801
|
-
playLeaveWaterSound(ent, system);
|
|
4802
|
-
ent.flags &= ~2 /* Swim */;
|
|
4803
|
-
}
|
|
4804
|
-
ent.waterlevel = 0;
|
|
4805
|
-
ent.watertype = 0;
|
|
4806
|
-
return;
|
|
4807
|
-
}
|
|
4808
|
-
ent.watertype = cont;
|
|
4809
|
-
ent.waterlevel = 1;
|
|
4810
|
-
const viewheight = ent.viewheight || (maxs.z - mins.z) * 0.8;
|
|
4811
|
-
const waist = origin.z + (mins.z + maxs.z) * 0.5;
|
|
4812
|
-
const feetZ = origin.z + mins.z + 1;
|
|
4813
|
-
const waistZ = origin.z + mins.z + (maxs.z - mins.z) * 0.5;
|
|
4814
|
-
const headZ = origin.z + maxs.z - 1;
|
|
4815
|
-
const waistPoint = { ...point, z: waistZ };
|
|
4816
|
-
cont = imports.pointcontents(waistPoint);
|
|
4817
|
-
if (cont & MASK_WATER) {
|
|
4818
|
-
ent.waterlevel = 2;
|
|
4819
|
-
const headPoint = { ...point, z: headZ };
|
|
4820
|
-
cont = imports.pointcontents(headPoint);
|
|
4821
|
-
if (cont & MASK_WATER) {
|
|
4822
|
-
ent.waterlevel = 3;
|
|
4823
|
-
}
|
|
4824
|
-
}
|
|
4825
|
-
if ((ent.flags & 2 /* Swim */) === 0) {
|
|
4826
|
-
playEnterWaterSound(ent, system);
|
|
4827
|
-
ent.flags |= 2 /* Swim */;
|
|
4828
|
-
}
|
|
4829
|
-
}
|
|
4830
|
-
function playEnterWaterSound(ent, system) {
|
|
4831
|
-
if (ent.watertype & CONTENTS_LAVA) {
|
|
4832
|
-
system.sound(ent, 0, "player/lava_in.wav", 1, 1, 0);
|
|
4833
|
-
} else if (ent.watertype & CONTENTS_SLIME) {
|
|
4834
|
-
system.sound(ent, 0, "player/watr_in.wav", 1, 1, 0);
|
|
4835
|
-
} else if (ent.watertype & CONTENTS_WATER) {
|
|
4836
|
-
system.sound(ent, 0, "player/watr_in.wav", 1, 1, 0);
|
|
4837
|
-
}
|
|
4838
|
-
}
|
|
4839
|
-
function playLeaveWaterSound(ent, system) {
|
|
4840
|
-
if (ent.watertype & CONTENTS_LAVA) {
|
|
4841
|
-
system.sound(ent, 0, "player/lava_out.wav", 1, 1, 0);
|
|
4842
|
-
} else if (ent.watertype & CONTENTS_SLIME) {
|
|
4843
|
-
system.sound(ent, 0, "player/watr_out.wav", 1, 1, 0);
|
|
4844
|
-
} else if (ent.watertype & CONTENTS_WATER) {
|
|
4845
|
-
system.sound(ent, 0, "player/watr_out.wav", 1, 1, 0);
|
|
4846
|
-
}
|
|
4847
|
-
}
|
|
4848
|
-
|
|
4849
4881
|
// src/entities/pool.ts
|
|
4850
4882
|
var MAX_EDICTS = 2048;
|
|
4851
4883
|
var WORLD_INDEX = 0;
|
|
@@ -25772,23 +25804,47 @@ init_esm();
|
|
|
25772
25804
|
var PNOISE_SELF = 0;
|
|
25773
25805
|
var PNOISE_WEAPON = 1;
|
|
25774
25806
|
var PNOISE_IMPACT = 2;
|
|
25807
|
+
function player_noise(ent, context) {
|
|
25808
|
+
ent.classname = "player_noise";
|
|
25809
|
+
ent.movetype = 0 /* None */;
|
|
25810
|
+
ent.solid = 0 /* Not */;
|
|
25811
|
+
ent.svflags |= 1 /* NoClient */;
|
|
25812
|
+
ent.mins = { x: -8, y: -8, z: -8 };
|
|
25813
|
+
ent.maxs = { x: 8, y: 8, z: 8 };
|
|
25814
|
+
ent.owner = null;
|
|
25815
|
+
}
|
|
25775
25816
|
function PlayerNoise(who, where, type, context) {
|
|
25817
|
+
if (!who || !who.client) {
|
|
25818
|
+
return;
|
|
25819
|
+
}
|
|
25820
|
+
if (who.flags & 32 /* NoTarget */) {
|
|
25821
|
+
return;
|
|
25822
|
+
}
|
|
25823
|
+
if (!who.client.player_noise_entity) {
|
|
25824
|
+
const noise2 = context.spawn();
|
|
25825
|
+
player_noise(noise2, context);
|
|
25826
|
+
noise2.owner = who;
|
|
25827
|
+
who.client.player_noise_entity = noise2;
|
|
25828
|
+
}
|
|
25829
|
+
const noise = who.client.player_noise_entity;
|
|
25830
|
+
noise.origin = { ...where };
|
|
25831
|
+
context.linkentity(noise);
|
|
25776
25832
|
const awareness = context.targetAwareness;
|
|
25777
25833
|
if (!awareness) return;
|
|
25778
25834
|
if (type === PNOISE_WEAPON) {
|
|
25779
|
-
if (awareness.soundEntity ===
|
|
25835
|
+
if (awareness.soundEntity === noise) {
|
|
25780
25836
|
awareness.soundEntityFrame = awareness.frameNumber;
|
|
25781
25837
|
} else {
|
|
25782
25838
|
awareness.sound2Entity = awareness.soundEntity;
|
|
25783
25839
|
awareness.sound2EntityFrame = awareness.soundEntityFrame;
|
|
25784
|
-
awareness.soundEntity =
|
|
25840
|
+
awareness.soundEntity = noise;
|
|
25785
25841
|
awareness.soundEntityFrame = awareness.frameNumber;
|
|
25786
25842
|
}
|
|
25787
25843
|
} else if (type === PNOISE_SELF) {
|
|
25788
|
-
if (awareness.sightEntity ===
|
|
25844
|
+
if (awareness.sightEntity === noise) {
|
|
25789
25845
|
awareness.sightEntityFrame = awareness.frameNumber;
|
|
25790
25846
|
} else {
|
|
25791
|
-
awareness.sightClient =
|
|
25847
|
+
awareness.sightClient = noise;
|
|
25792
25848
|
}
|
|
25793
25849
|
}
|
|
25794
25850
|
}
|
|
@@ -26933,6 +26989,7 @@ function createGame(imports, engine, options) {
|
|
|
26933
26989
|
pickupPowerArmor,
|
|
26934
26990
|
pickupPowerup,
|
|
26935
26991
|
pickupWeapon,
|
|
26992
|
+
player_noise,
|
|
26936
26993
|
range,
|
|
26937
26994
|
rangeTo,
|
|
26938
26995
|
registerCallback,
|