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.
@@ -2623,6 +2623,11 @@ var TraceMask = /* @__PURE__ */ ((TraceMask2) => {
2623
2623
  TraceMask2[TraceMask2["Window"] = 2] = "Window";
2624
2624
  return TraceMask2;
2625
2625
  })(TraceMask || {});
2626
+ var BOTTOM_EMPTY = 0;
2627
+ var BOTTOM_SOLID = 1;
2628
+ var BOTTOM_WATER = 2;
2629
+ var BOTTOM_SLIME = 3;
2630
+ var BOTTOM_LAVA = 4;
2626
2631
 
2627
2632
  // src/entities/entity.ts
2628
2633
  var MoveType = /* @__PURE__ */ ((MoveType3) => {
@@ -3536,7 +3541,7 @@ function CheckGround(self, context) {
3536
3541
  }
3537
3542
  }
3538
3543
  }
3539
- function M_CheckBottom(self, context) {
3544
+ function M_CheckBottomEx(self, context) {
3540
3545
  const mins = {
3541
3546
  x: self.origin.x + self.mins.x,
3542
3547
  y: self.origin.y + self.mins.y,
@@ -3548,26 +3553,72 @@ function M_CheckBottom(self, context) {
3548
3553
  z: self.origin.z + self.maxs.z
3549
3554
  };
3550
3555
  let start = { x: 0, y: 0, z: 0 };
3551
- let stop = { x: 0, y: 0, z: 0 };
3552
- for (let i = 0; i < 2; i++) {
3553
- if (i === 1) start = { x: mins.x, y: mins.y, z: 0 };
3554
- else start = { x: maxs.x, y: mins.y, z: 0 };
3555
- start.z = mins.z - 1;
3556
- if (context.pointcontents(start) !== 0) return true;
3557
- stop = { ...start };
3558
- stop.z = start.z - 60;
3559
- const trace = context.trace(start, null, null, stop, self, MASK_MONSTERSOLID);
3560
- if (trace.fraction < 1) return true;
3561
- if (i === 1) start = { x: mins.x, y: maxs.y, z: 0 };
3562
- else start = { x: maxs.x, y: maxs.y, z: 0 };
3563
- start.z = mins.z - 1;
3564
- if (context.pointcontents(start) !== 0) return true;
3565
- stop = { ...start };
3566
- stop.z = start.z - 60;
3567
- const trace2 = context.trace(start, null, null, stop, self, MASK_MONSTERSOLID);
3568
- if (trace2.fraction < 1) return true;
3556
+ let allSolid = true;
3557
+ for (let x = 0; x <= 1; x++) {
3558
+ for (let y = 0; y <= 1; y++) {
3559
+ start.x = x ? maxs.x : mins.x;
3560
+ start.y = y ? maxs.y : mins.y;
3561
+ start.z = mins.z - 1;
3562
+ const content = context.pointcontents(start);
3563
+ if (content !== CONTENTS_SOLID) {
3564
+ allSolid = false;
3565
+ break;
3566
+ }
3567
+ }
3568
+ if (!allSolid) break;
3569
+ }
3570
+ if (allSolid) return BOTTOM_SOLID;
3571
+ start.x = self.origin.x;
3572
+ start.y = self.origin.y;
3573
+ start.z = self.origin.z + self.mins.z;
3574
+ const stop = { ...start };
3575
+ stop.z = start.z - STEPSIZE * 2;
3576
+ const trace = context.trace(start, null, null, stop, self, MASK_MONSTERSOLID);
3577
+ if (trace.fraction === 1) return BOTTOM_EMPTY;
3578
+ const mid = trace.endpos.z;
3579
+ const bottomType = context.pointcontents(trace.endpos);
3580
+ let result = BOTTOM_SOLID;
3581
+ if (bottomType & CONTENTS_WATER) result = BOTTOM_WATER;
3582
+ else if (bottomType & CONTENTS_SLIME) result = BOTTOM_SLIME;
3583
+ else if (bottomType & CONTENTS_LAVA) result = BOTTOM_LAVA;
3584
+ const stepQuadrantSize = {
3585
+ x: (self.maxs.x - self.mins.x) * 0.5,
3586
+ y: (self.maxs.y - self.mins.y) * 0.5
3587
+ };
3588
+ const halfStepQuadrant = {
3589
+ x: stepQuadrantSize.x * 0.5,
3590
+ y: stepQuadrantSize.y * 0.5,
3591
+ z: 0
3592
+ };
3593
+ const halfStepQuadrantMins = {
3594
+ x: -halfStepQuadrant.x,
3595
+ y: -halfStepQuadrant.y,
3596
+ z: 0
3597
+ };
3598
+ const centerStart = {
3599
+ x: self.origin.x + (self.mins.x + self.maxs.x) * 0.5,
3600
+ y: self.origin.y + (self.mins.y + self.maxs.y) * 0.5,
3601
+ z: 0
3602
+ };
3603
+ for (let x = 0; x <= 1; x++) {
3604
+ for (let y = 0; y <= 1; y++) {
3605
+ const quadrantStart = { ...centerStart };
3606
+ if (x) quadrantStart.x += halfStepQuadrant.x;
3607
+ else quadrantStart.x -= halfStepQuadrant.x;
3608
+ if (y) quadrantStart.y += halfStepQuadrant.y;
3609
+ else quadrantStart.y -= halfStepQuadrant.y;
3610
+ quadrantStart.z = start.z;
3611
+ const quadrantEnd = { ...quadrantStart, z: stop.z };
3612
+ const subTrace = context.trace(quadrantStart, halfStepQuadrantMins, halfStepQuadrant, quadrantEnd, self, MASK_MONSTERSOLID);
3613
+ if (subTrace.fraction === 1 || mid - subTrace.endpos.z > STEPSIZE) {
3614
+ return BOTTOM_EMPTY;
3615
+ }
3616
+ }
3569
3617
  }
3570
- return false;
3618
+ return result;
3619
+ }
3620
+ function M_CheckBottom(self, context) {
3621
+ return M_CheckBottomEx(self, context) !== BOTTOM_EMPTY;
3571
3622
  }
3572
3623
  function M_MoveStep(self, move, relink, context) {
3573
3624
  if (!((self.flags & (2 /* Swim */ | 1 /* Fly */)) !== 0) && self.movetype !== 1 /* Noclip */) {
@@ -25859,6 +25910,11 @@ export {
25859
25910
  AmmoType,
25860
25911
  ArmorType,
25861
25912
  AttackState,
25913
+ BOTTOM_EMPTY,
25914
+ BOTTOM_LAVA,
25915
+ BOTTOM_SLIME,
25916
+ BOTTOM_SOLID,
25917
+ BOTTOM_WATER,
25862
25918
  BlockedJumpResult,
25863
25919
  CheckGround,
25864
25920
  DamageFlags,
@@ -25880,6 +25936,7 @@ export {
25880
25936
  M_CheckAttack,
25881
25937
  M_CheckAttack_Base,
25882
25938
  M_CheckBottom,
25939
+ M_CheckBottomEx,
25883
25940
  M_MoveFrame,
25884
25941
  M_MoveStep,
25885
25942
  M_MoveToGoal,