quake2ts 0.0.414 → 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.
@@ -2467,10 +2467,14 @@ __export(index_exports, {
2467
2467
  KEY_ITEMS: () => KEY_ITEMS,
2468
2468
  KeyId: () => KeyId,
2469
2469
  M_CalculatePitchToFire: () => M_CalculatePitchToFire,
2470
+ M_ChangeYaw: () => M_ChangeYaw,
2470
2471
  M_CheckAttack: () => M_CheckAttack,
2471
2472
  M_CheckAttack_Base: () => M_CheckAttack_Base,
2472
2473
  M_CheckBottom: () => M_CheckBottom,
2473
2474
  M_MoveFrame: () => M_MoveFrame,
2475
+ M_MoveStep: () => M_MoveStep,
2476
+ M_MoveToGoal: () => M_MoveToGoal,
2477
+ M_MoveToPath: () => M_MoveToPath,
2474
2478
  M_walkmove: () => M_walkmove,
2475
2479
  MonsterAttackState: () => MonsterAttackState,
2476
2480
  MoveType: () => MoveType,
@@ -3571,6 +3575,7 @@ function changeYaw(self, deltaSeconds) {
3571
3575
  else if (move < -speed) move = -speed;
3572
3576
  self.angles.y = angleMod(current + move);
3573
3577
  }
3578
+ var M_ChangeYaw = changeYaw;
3574
3579
  function facingIdeal(self) {
3575
3580
  const delta = angleMod(self.angles.y - self.ideal_yaw);
3576
3581
  const hasPathing = (self.monsterinfo.aiflags & 1073741824 /* Pathing */) !== 0;
@@ -3595,8 +3600,6 @@ function ai_stand(self, deltaSeconds, context) {
3595
3600
  if (findTarget(self, context.targetAwareness, context, context.trace)) {
3596
3601
  return;
3597
3602
  }
3598
- if (self.enemy && self.enemy.inUse) {
3599
- }
3600
3603
  changeYaw(self, deltaSeconds);
3601
3604
  }
3602
3605
  function ai_walk(self, distance4, deltaSeconds, context) {
@@ -3605,19 +3608,11 @@ function ai_walk(self, distance4, deltaSeconds, context) {
3605
3608
  }
3606
3609
  setIdealYawTowards2(self, self.goalentity);
3607
3610
  changeYaw(self, deltaSeconds);
3608
- if (distance4 !== 0) {
3609
- walkMove(self, self.angles.y, distance4);
3610
- }
3611
- if (self.goalentity && self.goalentity.classname === "path_corner") {
3612
- const dist = rangeTo(self, self.goalentity);
3613
- if (dist < 64) {
3614
- if (self.goalentity.target) {
3615
- const next = context.pickTarget(self.goalentity.target);
3616
- if (next) {
3617
- self.goalentity = next;
3618
- self.ideal_yaw = self.angles.y;
3619
- }
3620
- }
3611
+ if (self.goalentity) {
3612
+ M_MoveToGoal(self, distance4, context);
3613
+ } else {
3614
+ if (distance4 !== 0) {
3615
+ M_walkmove(self, self.angles.y, distance4, context);
3621
3616
  }
3622
3617
  }
3623
3618
  }
@@ -3731,19 +3726,16 @@ function M_CheckBottom(self, context) {
3731
3726
  }
3732
3727
  return false;
3733
3728
  }
3734
- function M_walkmove(self, yawDegrees, distance4, context) {
3729
+ function M_MoveStep(self, move, relink, context) {
3735
3730
  if (!((self.flags & (2 /* Swim */ | 1 /* Fly */)) !== 0) && self.movetype !== 1 /* Noclip */) {
3736
3731
  if (!self.groundentity && self.waterlevel === 0) {
3737
3732
  return false;
3738
3733
  }
3739
3734
  }
3740
- const delta = yawVector(yawDegrees, distance4);
3741
- if ((self.monsterinfo.aiflags & 1024 /* NoStep */) !== 0 && (self.monsterinfo.aiflags & 1073741824 /* Pathing */) !== 0) {
3742
- }
3743
3735
  const dest = {
3744
- x: self.origin.x + delta.x,
3745
- y: self.origin.y + delta.y,
3746
- z: self.origin.z + delta.z
3736
+ x: self.origin.x + move.x,
3737
+ y: self.origin.y + move.y,
3738
+ z: self.origin.z + move.z
3747
3739
  };
3748
3740
  const trace = context.trace(self.origin, self.mins, self.maxs, dest, self, MASK_MONSTERSOLID);
3749
3741
  if (trace.fraction === 1) {
@@ -3773,13 +3765,13 @@ function M_walkmove(self, yawDegrees, distance4, context) {
3773
3765
  if (traceUp.startsolid || traceUp.allsolid) {
3774
3766
  return false;
3775
3767
  }
3768
+ const stepOrigin = traceUp.endpos;
3776
3769
  const destUp = {
3777
- x: up.x + delta.x,
3778
- y: up.y + delta.y,
3779
- z: up.z
3780
- // stay at up z
3770
+ x: stepOrigin.x + move.x,
3771
+ y: stepOrigin.y + move.y,
3772
+ z: stepOrigin.z
3781
3773
  };
3782
- const traceStep = context.trace(up, self.mins, self.maxs, destUp, self, MASK_MONSTERSOLID);
3774
+ const traceStep = context.trace(stepOrigin, self.mins, self.maxs, destUp, self, MASK_MONSTERSOLID);
3783
3775
  if (traceStep.fraction < 1) {
3784
3776
  return false;
3785
3777
  }
@@ -3787,13 +3779,6 @@ function M_walkmove(self, yawDegrees, distance4, context) {
3787
3779
  x: destUp.x,
3788
3780
  y: destUp.y,
3789
3781
  z: destUp.z - STEPSIZE
3790
- // Go back down
3791
- };
3792
- const downTraceDest = {
3793
- x: destDown.x,
3794
- y: destDown.y,
3795
- z: destDown.z - STEPSIZE
3796
- // Look a bit deeper?
3797
3782
  };
3798
3783
  const traceDown = context.trace(destUp, self.mins, self.maxs, destDown, self, MASK_MONSTERSOLID);
3799
3784
  if (traceDown.startsolid || traceDown.allsolid) {
@@ -3812,6 +3797,10 @@ function M_walkmove(self, yawDegrees, distance4, context) {
3812
3797
  CheckGround(self, context);
3813
3798
  return true;
3814
3799
  }
3800
+ function M_walkmove(self, yawDegrees, distance4, context) {
3801
+ const delta = yawVector(yawDegrees, distance4);
3802
+ return M_MoveStep(self, delta, true, context);
3803
+ }
3815
3804
  function SV_StepDirection(self, yaw, dist, context) {
3816
3805
  for (let i = 0; i <= 90; i += 45) {
3817
3806
  if (M_walkmove(self, yaw + i, dist, context)) {
@@ -3847,6 +3836,46 @@ function SV_NewChaseDir(self, enemy, dist, context) {
3847
3836
  }
3848
3837
  SV_StepDirection(self, self.ideal_yaw, dist, context);
3849
3838
  }
3839
+ function SV_CloseEnough(self, goal, dist) {
3840
+ if (!goal) return false;
3841
+ const dx = Math.abs(self.origin.x - goal.origin.x);
3842
+ const dy = Math.abs(self.origin.y - goal.origin.y);
3843
+ const dz = Math.abs(self.origin.z - goal.origin.z);
3844
+ return dx <= dist && dy <= dist && dz <= dist;
3845
+ }
3846
+ function M_MoveToPath(self, context) {
3847
+ const goal = self.goalentity;
3848
+ if (goal && goal.target) {
3849
+ const next = context.pickTarget(goal.target);
3850
+ if (next) {
3851
+ self.goalentity = next;
3852
+ self.ideal_yaw = vectorToYaw({
3853
+ x: next.origin.x - self.origin.x,
3854
+ y: next.origin.y - self.origin.y,
3855
+ z: next.origin.z - self.origin.z
3856
+ });
3857
+ }
3858
+ }
3859
+ }
3860
+ function M_MoveToGoal(self, dist, context) {
3861
+ const goal = self.goalentity;
3862
+ if (!self.groundentity && !((self.flags & (2 /* Swim */ | 1 /* Fly */)) !== 0)) {
3863
+ return false;
3864
+ }
3865
+ if (self.enemy && SV_CloseEnough(self, self.enemy, dist)) {
3866
+ return true;
3867
+ }
3868
+ if (goal && goal.classname === "path_corner") {
3869
+ if (SV_CloseEnough(self, goal, dist)) {
3870
+ M_MoveToPath(self, context);
3871
+ return true;
3872
+ }
3873
+ }
3874
+ if (!SV_StepDirection(self, self.ideal_yaw, dist, context)) {
3875
+ return false;
3876
+ }
3877
+ return true;
3878
+ }
3850
3879
 
3851
3880
  // src/physics/collision.ts
3852
3881
  function resolveImpact(ent, trace, system) {
@@ -25536,10 +25565,14 @@ function createGame(imports, engine, options) {
25536
25565
  KEY_ITEMS,
25537
25566
  KeyId,
25538
25567
  M_CalculatePitchToFire,
25568
+ M_ChangeYaw,
25539
25569
  M_CheckAttack,
25540
25570
  M_CheckAttack_Base,
25541
25571
  M_CheckBottom,
25542
25572
  M_MoveFrame,
25573
+ M_MoveStep,
25574
+ M_MoveToGoal,
25575
+ M_MoveToPath,
25543
25576
  M_walkmove,
25544
25577
  MonsterAttackState,
25545
25578
  MoveType,