quake2ts 0.0.413 → 0.0.415

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.
@@ -3400,6 +3400,7 @@ function changeYaw(self, deltaSeconds) {
3400
3400
  else if (move < -speed) move = -speed;
3401
3401
  self.angles.y = angleMod(current + move);
3402
3402
  }
3403
+ var M_ChangeYaw = changeYaw;
3403
3404
  function facingIdeal(self) {
3404
3405
  const delta = angleMod(self.angles.y - self.ideal_yaw);
3405
3406
  const hasPathing = (self.monsterinfo.aiflags & 1073741824 /* Pathing */) !== 0;
@@ -3424,8 +3425,6 @@ function ai_stand(self, deltaSeconds, context) {
3424
3425
  if (findTarget(self, context.targetAwareness, context, context.trace)) {
3425
3426
  return;
3426
3427
  }
3427
- if (self.enemy && self.enemy.inUse) {
3428
- }
3429
3428
  changeYaw(self, deltaSeconds);
3430
3429
  }
3431
3430
  function ai_walk(self, distance4, deltaSeconds, context) {
@@ -3434,19 +3433,11 @@ function ai_walk(self, distance4, deltaSeconds, context) {
3434
3433
  }
3435
3434
  setIdealYawTowards2(self, self.goalentity);
3436
3435
  changeYaw(self, deltaSeconds);
3437
- if (distance4 !== 0) {
3438
- walkMove(self, self.angles.y, distance4);
3439
- }
3440
- if (self.goalentity && self.goalentity.classname === "path_corner") {
3441
- const dist = rangeTo(self, self.goalentity);
3442
- if (dist < 64) {
3443
- if (self.goalentity.target) {
3444
- const next = context.pickTarget(self.goalentity.target);
3445
- if (next) {
3446
- self.goalentity = next;
3447
- self.ideal_yaw = self.angles.y;
3448
- }
3449
- }
3436
+ if (self.goalentity) {
3437
+ M_MoveToGoal(self, distance4, context);
3438
+ } else {
3439
+ if (distance4 !== 0) {
3440
+ M_walkmove(self, self.angles.y, distance4, context);
3450
3441
  }
3451
3442
  }
3452
3443
  }
@@ -3560,19 +3551,16 @@ function M_CheckBottom(self, context) {
3560
3551
  }
3561
3552
  return false;
3562
3553
  }
3563
- function M_walkmove(self, yawDegrees, distance4, context) {
3554
+ function M_MoveStep(self, move, relink, context) {
3564
3555
  if (!((self.flags & (2 /* Swim */ | 1 /* Fly */)) !== 0) && self.movetype !== 1 /* Noclip */) {
3565
3556
  if (!self.groundentity && self.waterlevel === 0) {
3566
3557
  return false;
3567
3558
  }
3568
3559
  }
3569
- const delta = yawVector(yawDegrees, distance4);
3570
- if ((self.monsterinfo.aiflags & 1024 /* NoStep */) !== 0 && (self.monsterinfo.aiflags & 1073741824 /* Pathing */) !== 0) {
3571
- }
3572
3560
  const dest = {
3573
- x: self.origin.x + delta.x,
3574
- y: self.origin.y + delta.y,
3575
- z: self.origin.z + delta.z
3561
+ x: self.origin.x + move.x,
3562
+ y: self.origin.y + move.y,
3563
+ z: self.origin.z + move.z
3576
3564
  };
3577
3565
  const trace = context.trace(self.origin, self.mins, self.maxs, dest, self, MASK_MONSTERSOLID);
3578
3566
  if (trace.fraction === 1) {
@@ -3602,13 +3590,13 @@ function M_walkmove(self, yawDegrees, distance4, context) {
3602
3590
  if (traceUp.startsolid || traceUp.allsolid) {
3603
3591
  return false;
3604
3592
  }
3593
+ const stepOrigin = traceUp.endpos;
3605
3594
  const destUp = {
3606
- x: up.x + delta.x,
3607
- y: up.y + delta.y,
3608
- z: up.z
3609
- // stay at up z
3595
+ x: stepOrigin.x + move.x,
3596
+ y: stepOrigin.y + move.y,
3597
+ z: stepOrigin.z
3610
3598
  };
3611
- const traceStep = context.trace(up, self.mins, self.maxs, destUp, self, MASK_MONSTERSOLID);
3599
+ const traceStep = context.trace(stepOrigin, self.mins, self.maxs, destUp, self, MASK_MONSTERSOLID);
3612
3600
  if (traceStep.fraction < 1) {
3613
3601
  return false;
3614
3602
  }
@@ -3616,13 +3604,6 @@ function M_walkmove(self, yawDegrees, distance4, context) {
3616
3604
  x: destUp.x,
3617
3605
  y: destUp.y,
3618
3606
  z: destUp.z - STEPSIZE
3619
- // Go back down
3620
- };
3621
- const downTraceDest = {
3622
- x: destDown.x,
3623
- y: destDown.y,
3624
- z: destDown.z - STEPSIZE
3625
- // Look a bit deeper?
3626
3607
  };
3627
3608
  const traceDown = context.trace(destUp, self.mins, self.maxs, destDown, self, MASK_MONSTERSOLID);
3628
3609
  if (traceDown.startsolid || traceDown.allsolid) {
@@ -3641,6 +3622,10 @@ function M_walkmove(self, yawDegrees, distance4, context) {
3641
3622
  CheckGround(self, context);
3642
3623
  return true;
3643
3624
  }
3625
+ function M_walkmove(self, yawDegrees, distance4, context) {
3626
+ const delta = yawVector(yawDegrees, distance4);
3627
+ return M_MoveStep(self, delta, true, context);
3628
+ }
3644
3629
  function SV_StepDirection(self, yaw, dist, context) {
3645
3630
  for (let i = 0; i <= 90; i += 45) {
3646
3631
  if (M_walkmove(self, yaw + i, dist, context)) {
@@ -3676,6 +3661,46 @@ function SV_NewChaseDir(self, enemy, dist, context) {
3676
3661
  }
3677
3662
  SV_StepDirection(self, self.ideal_yaw, dist, context);
3678
3663
  }
3664
+ function SV_CloseEnough(self, goal, dist) {
3665
+ if (!goal) return false;
3666
+ const dx = Math.abs(self.origin.x - goal.origin.x);
3667
+ const dy = Math.abs(self.origin.y - goal.origin.y);
3668
+ const dz = Math.abs(self.origin.z - goal.origin.z);
3669
+ return dx <= dist && dy <= dist && dz <= dist;
3670
+ }
3671
+ function M_MoveToPath(self, context) {
3672
+ const goal = self.goalentity;
3673
+ if (goal && goal.target) {
3674
+ const next = context.pickTarget(goal.target);
3675
+ if (next) {
3676
+ self.goalentity = next;
3677
+ self.ideal_yaw = vectorToYaw({
3678
+ x: next.origin.x - self.origin.x,
3679
+ y: next.origin.y - self.origin.y,
3680
+ z: next.origin.z - self.origin.z
3681
+ });
3682
+ }
3683
+ }
3684
+ }
3685
+ function M_MoveToGoal(self, dist, context) {
3686
+ const goal = self.goalentity;
3687
+ if (!self.groundentity && !((self.flags & (2 /* Swim */ | 1 /* Fly */)) !== 0)) {
3688
+ return false;
3689
+ }
3690
+ if (self.enemy && SV_CloseEnough(self, self.enemy, dist)) {
3691
+ return true;
3692
+ }
3693
+ if (goal && goal.classname === "path_corner") {
3694
+ if (SV_CloseEnough(self, goal, dist)) {
3695
+ M_MoveToPath(self, context);
3696
+ return true;
3697
+ }
3698
+ }
3699
+ if (!SV_StepDirection(self, self.ideal_yaw, dist, context)) {
3700
+ return false;
3701
+ }
3702
+ return true;
3703
+ }
3679
3704
 
3680
3705
  // src/physics/collision.ts
3681
3706
  function resolveImpact(ent, trace, system) {
@@ -4500,6 +4525,9 @@ var EntitySystem = class {
4500
4525
  get pointcontents() {
4501
4526
  return this.imports.pointcontents;
4502
4527
  }
4528
+ get areaEdicts() {
4529
+ return this.imports.areaEdicts;
4530
+ }
4503
4531
  get game() {
4504
4532
  return this._game;
4505
4533
  }
@@ -25361,10 +25389,14 @@ export {
25361
25389
  KEY_ITEMS,
25362
25390
  KeyId,
25363
25391
  M_CalculatePitchToFire,
25392
+ M_ChangeYaw,
25364
25393
  M_CheckAttack,
25365
25394
  M_CheckAttack_Base,
25366
25395
  M_CheckBottom,
25367
25396
  M_MoveFrame,
25397
+ M_MoveStep,
25398
+ M_MoveToGoal,
25399
+ M_MoveToPath,
25368
25400
  M_walkmove,
25369
25401
  MonsterAttackState,
25370
25402
  MoveType,