quake2ts 0.0.438 → 0.0.440

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.
@@ -2469,6 +2469,11 @@ __export(index_exports, {
2469
2469
  AmmoType: () => AmmoType,
2470
2470
  ArmorType: () => ArmorType,
2471
2471
  AttackState: () => AttackState,
2472
+ BOTTOM_EMPTY: () => BOTTOM_EMPTY,
2473
+ BOTTOM_LAVA: () => BOTTOM_LAVA,
2474
+ BOTTOM_SLIME: () => BOTTOM_SLIME,
2475
+ BOTTOM_SOLID: () => BOTTOM_SOLID,
2476
+ BOTTOM_WATER: () => BOTTOM_WATER,
2472
2477
  BlockedJumpResult: () => BlockedJumpResult,
2473
2478
  CheckGround: () => CheckGround,
2474
2479
  DamageFlags: () => DamageFlags,
@@ -2490,6 +2495,7 @@ __export(index_exports, {
2490
2495
  M_CheckAttack: () => M_CheckAttack,
2491
2496
  M_CheckAttack_Base: () => M_CheckAttack_Base,
2492
2497
  M_CheckBottom: () => M_CheckBottom,
2498
+ M_CheckBottomEx: () => M_CheckBottomEx,
2493
2499
  M_MoveFrame: () => M_MoveFrame,
2494
2500
  M_MoveStep: () => M_MoveStep,
2495
2501
  M_MoveToGoal: () => M_MoveToGoal,
@@ -2800,6 +2806,11 @@ var TraceMask = /* @__PURE__ */ ((TraceMask2) => {
2800
2806
  TraceMask2[TraceMask2["Window"] = 2] = "Window";
2801
2807
  return TraceMask2;
2802
2808
  })(TraceMask || {});
2809
+ var BOTTOM_EMPTY = 0;
2810
+ var BOTTOM_SOLID = 1;
2811
+ var BOTTOM_WATER = 2;
2812
+ var BOTTOM_SLIME = 3;
2813
+ var BOTTOM_LAVA = 4;
2803
2814
 
2804
2815
  // src/entities/entity.ts
2805
2816
  var MoveType = /* @__PURE__ */ ((MoveType3) => {
@@ -3713,7 +3724,7 @@ function CheckGround(self, context) {
3713
3724
  }
3714
3725
  }
3715
3726
  }
3716
- function M_CheckBottom(self, context) {
3727
+ function M_CheckBottomEx(self, context) {
3717
3728
  const mins = {
3718
3729
  x: self.origin.x + self.mins.x,
3719
3730
  y: self.origin.y + self.mins.y,
@@ -3725,26 +3736,72 @@ function M_CheckBottom(self, context) {
3725
3736
  z: self.origin.z + self.maxs.z
3726
3737
  };
3727
3738
  let start = { x: 0, y: 0, z: 0 };
3728
- let stop = { x: 0, y: 0, z: 0 };
3729
- for (let i = 0; i < 2; i++) {
3730
- if (i === 1) start = { x: mins.x, y: mins.y, z: 0 };
3731
- else start = { x: maxs.x, y: mins.y, z: 0 };
3732
- start.z = mins.z - 1;
3733
- if (context.pointcontents(start) !== 0) return true;
3734
- stop = { ...start };
3735
- stop.z = start.z - 60;
3736
- const trace = context.trace(start, null, null, stop, self, MASK_MONSTERSOLID);
3737
- if (trace.fraction < 1) return true;
3738
- if (i === 1) start = { x: mins.x, y: maxs.y, z: 0 };
3739
- else start = { x: maxs.x, y: maxs.y, z: 0 };
3740
- start.z = mins.z - 1;
3741
- if (context.pointcontents(start) !== 0) return true;
3742
- stop = { ...start };
3743
- stop.z = start.z - 60;
3744
- const trace2 = context.trace(start, null, null, stop, self, MASK_MONSTERSOLID);
3745
- if (trace2.fraction < 1) return true;
3739
+ let allSolid = true;
3740
+ for (let x = 0; x <= 1; x++) {
3741
+ for (let y = 0; y <= 1; y++) {
3742
+ start.x = x ? maxs.x : mins.x;
3743
+ start.y = y ? maxs.y : mins.y;
3744
+ start.z = mins.z - 1;
3745
+ const content = context.pointcontents(start);
3746
+ if (content !== CONTENTS_SOLID) {
3747
+ allSolid = false;
3748
+ break;
3749
+ }
3750
+ }
3751
+ if (!allSolid) break;
3752
+ }
3753
+ if (allSolid) return BOTTOM_SOLID;
3754
+ start.x = self.origin.x;
3755
+ start.y = self.origin.y;
3756
+ start.z = self.origin.z + self.mins.z;
3757
+ const stop = { ...start };
3758
+ stop.z = start.z - STEPSIZE * 2;
3759
+ const trace = context.trace(start, null, null, stop, self, MASK_MONSTERSOLID);
3760
+ if (trace.fraction === 1) return BOTTOM_EMPTY;
3761
+ const mid = trace.endpos.z;
3762
+ const bottomType = context.pointcontents(trace.endpos);
3763
+ let result = BOTTOM_SOLID;
3764
+ if (bottomType & CONTENTS_WATER) result = BOTTOM_WATER;
3765
+ else if (bottomType & CONTENTS_SLIME) result = BOTTOM_SLIME;
3766
+ else if (bottomType & CONTENTS_LAVA) result = BOTTOM_LAVA;
3767
+ const stepQuadrantSize = {
3768
+ x: (self.maxs.x - self.mins.x) * 0.5,
3769
+ y: (self.maxs.y - self.mins.y) * 0.5
3770
+ };
3771
+ const halfStepQuadrant = {
3772
+ x: stepQuadrantSize.x * 0.5,
3773
+ y: stepQuadrantSize.y * 0.5,
3774
+ z: 0
3775
+ };
3776
+ const halfStepQuadrantMins = {
3777
+ x: -halfStepQuadrant.x,
3778
+ y: -halfStepQuadrant.y,
3779
+ z: 0
3780
+ };
3781
+ const centerStart = {
3782
+ x: self.origin.x + (self.mins.x + self.maxs.x) * 0.5,
3783
+ y: self.origin.y + (self.mins.y + self.maxs.y) * 0.5,
3784
+ z: 0
3785
+ };
3786
+ for (let x = 0; x <= 1; x++) {
3787
+ for (let y = 0; y <= 1; y++) {
3788
+ const quadrantStart = { ...centerStart };
3789
+ if (x) quadrantStart.x += halfStepQuadrant.x;
3790
+ else quadrantStart.x -= halfStepQuadrant.x;
3791
+ if (y) quadrantStart.y += halfStepQuadrant.y;
3792
+ else quadrantStart.y -= halfStepQuadrant.y;
3793
+ quadrantStart.z = start.z;
3794
+ const quadrantEnd = { ...quadrantStart, z: stop.z };
3795
+ const subTrace = context.trace(quadrantStart, halfStepQuadrantMins, halfStepQuadrant, quadrantEnd, self, MASK_MONSTERSOLID);
3796
+ if (subTrace.fraction === 1 || mid - subTrace.endpos.z > STEPSIZE) {
3797
+ return BOTTOM_EMPTY;
3798
+ }
3799
+ }
3746
3800
  }
3747
- return false;
3801
+ return result;
3802
+ }
3803
+ function M_CheckBottom(self, context) {
3804
+ return M_CheckBottomEx(self, context) !== BOTTOM_EMPTY;
3748
3805
  }
3749
3806
  function M_MoveStep(self, move, relink, context) {
3750
3807
  if (!((self.flags & (2 /* Swim */ | 1 /* Fly */)) !== 0) && self.movetype !== 1 /* Noclip */) {
@@ -26037,6 +26094,11 @@ function createGame(imports, engine, options) {
26037
26094
  AmmoType,
26038
26095
  ArmorType,
26039
26096
  AttackState,
26097
+ BOTTOM_EMPTY,
26098
+ BOTTOM_LAVA,
26099
+ BOTTOM_SLIME,
26100
+ BOTTOM_SOLID,
26101
+ BOTTOM_WATER,
26040
26102
  BlockedJumpResult,
26041
26103
  CheckGround,
26042
26104
  DamageFlags,
@@ -26058,6 +26120,7 @@ function createGame(imports, engine, options) {
26058
26120
  M_CheckAttack,
26059
26121
  M_CheckAttack_Base,
26060
26122
  M_CheckBottom,
26123
+ M_CheckBottomEx,
26061
26124
  M_MoveFrame,
26062
26125
  M_MoveStep,
26063
26126
  M_MoveToGoal,