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.
@@ -3395,11 +3395,19 @@ function findTarget(self, level, context, trace, hearability = {}) {
3395
3395
  return false;
3396
3396
  }
3397
3397
  const { candidate, heardit } = chooseCandidate(self, level);
3398
- if (!candidate || !candidate.inUse) return false;
3399
- if (candidate === self.enemy) return true;
3400
- if (rejectNotargetEntity(candidate)) return false;
3398
+ if (!candidate || !candidate.inUse) {
3399
+ return false;
3400
+ }
3401
+ if (candidate === self.enemy) {
3402
+ return true;
3403
+ }
3404
+ if (rejectNotargetEntity(candidate)) {
3405
+ return false;
3406
+ }
3401
3407
  if (!heardit) {
3402
- if (!classifyClientVisibility(self, candidate, level, trace)) return false;
3408
+ if (!classifyClientVisibility(self, candidate, level, trace)) {
3409
+ return false;
3410
+ }
3403
3411
  self.monsterinfo.aiflags &= ~4 /* SoundTarget */;
3404
3412
  self.enemy = candidate;
3405
3413
  } else if (!updateSoundChase(self, candidate, level, hearability, trace)) {
@@ -4347,6 +4355,91 @@ function killBox(teleporter, targets, options = {}) {
4347
4355
  return { events, cleared };
4348
4356
  }
4349
4357
 
4358
+ // src/physics/fluid.ts
4359
+ init_esm();
4360
+ function checkWater2(ent, system, imports) {
4361
+ const origin = ent.origin;
4362
+ const mins = ent.mins;
4363
+ const maxs = ent.maxs;
4364
+ if (!origin || !mins || !maxs) {
4365
+ return;
4366
+ }
4367
+ const point = {
4368
+ x: origin.x + (mins.x + maxs.x) * 0.5,
4369
+ y: origin.y + (mins.y + maxs.y) * 0.5,
4370
+ z: origin.z + mins.z + 1
4371
+ };
4372
+ let cont = imports.pointcontents(point);
4373
+ if ((cont & MASK_WATER) === 0) {
4374
+ if (ent.waterlevel > 0) {
4375
+ playLeaveWaterSound(ent, system);
4376
+ ent.flags &= ~2 /* Swim */;
4377
+ }
4378
+ ent.waterlevel = 0;
4379
+ ent.watertype = 0;
4380
+ return;
4381
+ }
4382
+ ent.watertype = cont;
4383
+ ent.waterlevel = 1;
4384
+ const viewheight = ent.viewheight || (maxs.z - mins.z) * 0.8;
4385
+ const waist = origin.z + (mins.z + maxs.z) * 0.5;
4386
+ const feetZ = origin.z + mins.z + 1;
4387
+ const waistZ = origin.z + mins.z + (maxs.z - mins.z) * 0.5;
4388
+ const headZ = origin.z + maxs.z - 1;
4389
+ const waistPoint = { ...point, z: waistZ };
4390
+ cont = imports.pointcontents(waistPoint);
4391
+ if (cont & MASK_WATER) {
4392
+ ent.waterlevel = 2;
4393
+ const headPoint = { ...point, z: headZ };
4394
+ cont = imports.pointcontents(headPoint);
4395
+ if (cont & MASK_WATER) {
4396
+ ent.waterlevel = 3;
4397
+ }
4398
+ }
4399
+ if ((ent.flags & 2 /* Swim */) === 0) {
4400
+ playEnterWaterSound(ent, system);
4401
+ ent.flags |= 2 /* Swim */;
4402
+ }
4403
+ }
4404
+ function playEnterWaterSound(ent, system) {
4405
+ if (ent.watertype & CONTENTS_LAVA) {
4406
+ system.sound(ent, 0, "player/lava_in.wav", 1, 1, 0);
4407
+ } else if (ent.watertype & CONTENTS_SLIME) {
4408
+ system.sound(ent, 0, "player/watr_in.wav", 1, 1, 0);
4409
+ } else if (ent.watertype & CONTENTS_WATER) {
4410
+ system.sound(ent, 0, "player/watr_in.wav", 1, 1, 0);
4411
+ }
4412
+ }
4413
+ function playLeaveWaterSound(ent, system) {
4414
+ if (ent.watertype & CONTENTS_LAVA) {
4415
+ system.sound(ent, 0, "player/lava_out.wav", 1, 1, 0);
4416
+ } else if (ent.watertype & CONTENTS_SLIME) {
4417
+ system.sound(ent, 0, "player/watr_out.wav", 1, 1, 0);
4418
+ } else if (ent.watertype & CONTENTS_WATER) {
4419
+ system.sound(ent, 0, "player/watr_out.wav", 1, 1, 0);
4420
+ }
4421
+ }
4422
+ function SV_AddCurrents(ent, currentSpeed = 400) {
4423
+ if (!(ent.watertype & MASK_CURRENT)) {
4424
+ return;
4425
+ }
4426
+ const v = { x: 0, y: 0, z: 0 };
4427
+ if (ent.watertype & CONTENTS_CURRENT_0) v.x += 1;
4428
+ if (ent.watertype & CONTENTS_CURRENT_90) v.y += 1;
4429
+ if (ent.watertype & CONTENTS_CURRENT_180) v.x -= 1;
4430
+ if (ent.watertype & CONTENTS_CURRENT_270) v.y -= 1;
4431
+ if (ent.watertype & CONTENTS_CURRENT_UP) v.z += 1;
4432
+ if (ent.watertype & CONTENTS_CURRENT_DOWN) v.z -= 1;
4433
+ let speed = currentSpeed;
4434
+ if (ent.waterlevel === 1 && ent.groundentity) {
4435
+ speed *= 0.5;
4436
+ }
4437
+ const velocity = ent.velocity;
4438
+ velocity.x += v.x * speed;
4439
+ velocity.y += v.y * speed;
4440
+ velocity.z += v.z * speed;
4441
+ }
4442
+
4350
4443
  // src/physics/movement.ts
4351
4444
  var WATER_FRICTION = 2;
4352
4445
  var WATER_GRAVITY_SCALE = 0.1;
@@ -4413,6 +4506,9 @@ function runStep(ent, system, imports, gravity, frametime) {
4413
4506
  if (!isFlying) {
4414
4507
  ent.velocity = addVec3(ent.velocity, scaleVec3(gravity, ent.gravity * frametime));
4415
4508
  }
4509
+ if (ent.waterlevel > 0) {
4510
+ SV_AddCurrents(ent);
4511
+ }
4416
4512
  let timeLeft = frametime;
4417
4513
  let velocity = { ...ent.velocity };
4418
4514
  for (let i = 0; i < 4; i++) {
@@ -4590,71 +4686,6 @@ function runPush(pusher, system, imports, frametime) {
4590
4686
  return true;
4591
4687
  }
4592
4688
 
4593
- // src/physics/fluid.ts
4594
- init_esm();
4595
- function checkWater2(ent, system, imports) {
4596
- const origin = ent.origin;
4597
- const mins = ent.mins;
4598
- const maxs = ent.maxs;
4599
- if (!origin || !mins || !maxs) {
4600
- return;
4601
- }
4602
- const point = {
4603
- x: origin.x + (mins.x + maxs.x) * 0.5,
4604
- y: origin.y + (mins.y + maxs.y) * 0.5,
4605
- z: origin.z + mins.z + 1
4606
- };
4607
- let cont = imports.pointcontents(point);
4608
- if ((cont & MASK_WATER) === 0) {
4609
- if (ent.waterlevel > 0) {
4610
- playLeaveWaterSound(ent, system);
4611
- ent.flags &= ~2 /* Swim */;
4612
- }
4613
- ent.waterlevel = 0;
4614
- ent.watertype = 0;
4615
- return;
4616
- }
4617
- ent.watertype = cont;
4618
- ent.waterlevel = 1;
4619
- const viewheight = ent.viewheight || (maxs.z - mins.z) * 0.8;
4620
- const waist = origin.z + (mins.z + maxs.z) * 0.5;
4621
- const feetZ = origin.z + mins.z + 1;
4622
- const waistZ = origin.z + mins.z + (maxs.z - mins.z) * 0.5;
4623
- const headZ = origin.z + maxs.z - 1;
4624
- const waistPoint = { ...point, z: waistZ };
4625
- cont = imports.pointcontents(waistPoint);
4626
- if (cont & MASK_WATER) {
4627
- ent.waterlevel = 2;
4628
- const headPoint = { ...point, z: headZ };
4629
- cont = imports.pointcontents(headPoint);
4630
- if (cont & MASK_WATER) {
4631
- ent.waterlevel = 3;
4632
- }
4633
- }
4634
- if ((ent.flags & 2 /* Swim */) === 0) {
4635
- playEnterWaterSound(ent, system);
4636
- ent.flags |= 2 /* Swim */;
4637
- }
4638
- }
4639
- function playEnterWaterSound(ent, system) {
4640
- if (ent.watertype & CONTENTS_LAVA) {
4641
- system.sound(ent, 0, "player/lava_in.wav", 1, 1, 0);
4642
- } else if (ent.watertype & CONTENTS_SLIME) {
4643
- system.sound(ent, 0, "player/watr_in.wav", 1, 1, 0);
4644
- } else if (ent.watertype & CONTENTS_WATER) {
4645
- system.sound(ent, 0, "player/watr_in.wav", 1, 1, 0);
4646
- }
4647
- }
4648
- function playLeaveWaterSound(ent, system) {
4649
- if (ent.watertype & CONTENTS_LAVA) {
4650
- system.sound(ent, 0, "player/lava_out.wav", 1, 1, 0);
4651
- } else if (ent.watertype & CONTENTS_SLIME) {
4652
- system.sound(ent, 0, "player/watr_out.wav", 1, 1, 0);
4653
- } else if (ent.watertype & CONTENTS_WATER) {
4654
- system.sound(ent, 0, "player/watr_out.wav", 1, 1, 0);
4655
- }
4656
- }
4657
-
4658
4689
  // src/entities/pool.ts
4659
4690
  var MAX_EDICTS = 2048;
4660
4691
  var WORLD_INDEX = 0;
@@ -25581,23 +25612,47 @@ init_esm();
25581
25612
  var PNOISE_SELF = 0;
25582
25613
  var PNOISE_WEAPON = 1;
25583
25614
  var PNOISE_IMPACT = 2;
25615
+ function player_noise(ent, context) {
25616
+ ent.classname = "player_noise";
25617
+ ent.movetype = 0 /* None */;
25618
+ ent.solid = 0 /* Not */;
25619
+ ent.svflags |= 1 /* NoClient */;
25620
+ ent.mins = { x: -8, y: -8, z: -8 };
25621
+ ent.maxs = { x: 8, y: 8, z: 8 };
25622
+ ent.owner = null;
25623
+ }
25584
25624
  function PlayerNoise(who, where, type, context) {
25625
+ if (!who || !who.client) {
25626
+ return;
25627
+ }
25628
+ if (who.flags & 32 /* NoTarget */) {
25629
+ return;
25630
+ }
25631
+ if (!who.client.player_noise_entity) {
25632
+ const noise2 = context.spawn();
25633
+ player_noise(noise2, context);
25634
+ noise2.owner = who;
25635
+ who.client.player_noise_entity = noise2;
25636
+ }
25637
+ const noise = who.client.player_noise_entity;
25638
+ noise.origin = { ...where };
25639
+ context.linkentity(noise);
25585
25640
  const awareness = context.targetAwareness;
25586
25641
  if (!awareness) return;
25587
25642
  if (type === PNOISE_WEAPON) {
25588
- if (awareness.soundEntity === who) {
25643
+ if (awareness.soundEntity === noise) {
25589
25644
  awareness.soundEntityFrame = awareness.frameNumber;
25590
25645
  } else {
25591
25646
  awareness.sound2Entity = awareness.soundEntity;
25592
25647
  awareness.sound2EntityFrame = awareness.soundEntityFrame;
25593
- awareness.soundEntity = who;
25648
+ awareness.soundEntity = noise;
25594
25649
  awareness.soundEntityFrame = awareness.frameNumber;
25595
25650
  }
25596
25651
  } else if (type === PNOISE_SELF) {
25597
- if (awareness.sightEntity === who) {
25652
+ if (awareness.sightEntity === noise) {
25598
25653
  awareness.sightEntityFrame = awareness.frameNumber;
25599
25654
  } else {
25600
- awareness.sightClient = who;
25655
+ awareness.sightClient = noise;
25601
25656
  }
25602
25657
  }
25603
25658
  }
@@ -26741,6 +26796,7 @@ export {
26741
26796
  pickupPowerArmor,
26742
26797
  pickupPowerup,
26743
26798
  pickupWeapon,
26799
+ player_noise,
26744
26800
  rangeTo as range,
26745
26801
  rangeTo,
26746
26802
  registerCallback,