quake2ts 0.0.240 → 0.0.241

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.
@@ -4762,37 +4762,53 @@ function move_calc(ent, dest, context, done) {
4762
4762
  context.scheduleThink(ent, context.timeSeconds + dt);
4763
4763
  }
4764
4764
  }
4765
- function door_blocked(self, other) {
4766
- if (other && other.takedamage) {
4767
- const damage = self.dmg || 2;
4768
- other.health -= damage;
4769
- }
4770
- if (self.state === 1 /* Opening */) {
4771
- self.state = 3 /* Closing */;
4772
- self.think = door_go_down;
4773
- } else if (self.state === 3 /* Closing */) {
4774
- self.state = 1 /* Opening */;
4775
- self.think = door_go_up;
4776
- }
4765
+ var SPAWNFLAG_DOOR_START_OPEN = 1;
4766
+ var SPAWNFLAG_DOOR_CRUSHER = 4;
4767
+ var SPAWNFLAG_DOOR_NOMONSTER = 8;
4768
+ var SPAWNFLAG_DOOR_ANIMATED = 16;
4769
+ var SPAWNFLAG_DOOR_TOGGLE = 32;
4770
+ var SPAWNFLAG_DOOR_ANIMATED_FAST = 64;
4771
+ var EF_ANIM_ALL = 4;
4772
+ var EF_ANIM_ALLFAST = 8;
4773
+ function getMoveInfo(ent) {
4774
+ return ent.moveinfo;
4777
4775
  }
4778
4776
  function door_hit_top(ent, context) {
4777
+ const moveinfo = getMoveInfo(ent);
4778
+ if (moveinfo && moveinfo.sound_end) {
4779
+ context.sound(ent, 0, moveinfo.sound_end, 1, 1, 0);
4780
+ }
4779
4781
  ent.state = 0 /* Open */;
4780
- if (ent.spawnflags & 32) {
4782
+ if (ent.spawnflags & SPAWNFLAG_DOOR_TOGGLE) {
4781
4783
  return;
4782
4784
  }
4783
4785
  if (ent.wait === -1) {
4784
4786
  return;
4785
4787
  }
4786
- ent.think = door_go_down;
4788
+ ent.think = (e) => door_go_down(e, context);
4787
4789
  context.scheduleThink(ent, context.timeSeconds + ent.wait);
4788
4790
  }
4789
4791
  function door_hit_bottom(ent, context) {
4792
+ const moveinfo = getMoveInfo(ent);
4793
+ if (moveinfo && moveinfo.sound_end) {
4794
+ context.sound(ent, 0, moveinfo.sound_end, 1, 1, 0);
4795
+ }
4790
4796
  ent.state = 2 /* Closed */;
4791
4797
  }
4792
4798
  function door_go_down(door, context) {
4799
+ door.think = (e) => door_go_down(e, context);
4800
+ const moveinfo = getMoveInfo(door);
4801
+ if (moveinfo && moveinfo.sound_start) {
4802
+ context.sound(door, 0, moveinfo.sound_start, 1, 1, 0);
4803
+ }
4793
4804
  move_calc(door, door.pos1, context, door_hit_bottom);
4794
4805
  }
4795
4806
  function door_go_up(door, context) {
4807
+ door.think = (e) => door_go_up(e, context);
4808
+ const moveinfo = getMoveInfo(door);
4809
+ if (moveinfo && moveinfo.sound_start) {
4810
+ context.sound(door, 0, moveinfo.sound_start, 1, 1, 0);
4811
+ }
4796
4812
  move_calc(door, door.pos2, context, door_hit_top);
4797
4813
  }
4798
4814
  var func_door = (entity, context) => {
@@ -4804,15 +4820,51 @@ var func_door = (entity, context) => {
4804
4820
  if (!entity.health) entity.health = 0;
4805
4821
  entity.solid = 3 /* Bsp */;
4806
4822
  entity.movetype = 2 /* Push */;
4807
- entity.blocked = door_blocked;
4823
+ entity.blocked = (self, other) => {
4824
+ if (other && other.takedamage) {
4825
+ const damage = self.dmg || 2;
4826
+ if (self.spawnflags & SPAWNFLAG_DOOR_CRUSHER) {
4827
+ other.health -= damage;
4828
+ } else {
4829
+ other.health -= damage;
4830
+ }
4831
+ }
4832
+ if (self.spawnflags & SPAWNFLAG_DOOR_CRUSHER) {
4833
+ return;
4834
+ }
4835
+ if (self.state === 1 /* Opening */) {
4836
+ self.state = 3 /* Closing */;
4837
+ door_go_down(self, context.entities);
4838
+ } else if (self.state === 3 /* Closing */) {
4839
+ self.state = 1 /* Opening */;
4840
+ door_go_up(self, context.entities);
4841
+ }
4842
+ };
4808
4843
  entity.state = 2 /* Closed */;
4809
4844
  entity.pos1 = { ...entity.origin };
4810
4845
  const move = entity.movedir.x * (Math.abs(entity.maxs.x - entity.mins.x) - entity.lip) + entity.movedir.y * (Math.abs(entity.maxs.y - entity.mins.y) - entity.lip) + entity.movedir.z * (Math.abs(entity.maxs.z - entity.mins.z) - entity.lip);
4811
4846
  entity.pos2 = addVec3(entity.pos1, scaleVec3(entity.movedir, move));
4812
- if (entity.spawnflags & 1) {
4847
+ const moveinfo = {
4848
+ sound_start: null,
4849
+ sound_middle: null,
4850
+ sound_end: null
4851
+ };
4852
+ if (entity.sounds !== 1) {
4853
+ moveinfo.sound_start = "doors/dr1_strt.wav";
4854
+ moveinfo.sound_middle = "doors/dr1_mid.wav";
4855
+ moveinfo.sound_end = "doors/dr1_end.wav";
4856
+ }
4857
+ entity.moveinfo = moveinfo;
4858
+ if (entity.spawnflags & SPAWNFLAG_DOOR_START_OPEN) {
4813
4859
  entity.origin = { ...entity.pos2 };
4814
4860
  entity.state = 0 /* Open */;
4815
4861
  }
4862
+ if (entity.spawnflags & SPAWNFLAG_DOOR_ANIMATED) {
4863
+ entity.effects |= EF_ANIM_ALL;
4864
+ }
4865
+ if (entity.spawnflags & SPAWNFLAG_DOOR_ANIMATED_FAST) {
4866
+ entity.effects |= EF_ANIM_ALLFAST;
4867
+ }
4816
4868
  if (entity.health > 0) {
4817
4869
  entity.takedamage = true;
4818
4870
  entity.max_health = entity.health;
@@ -4823,46 +4875,27 @@ var func_door = (entity, context) => {
4823
4875
  };
4824
4876
  }
4825
4877
  entity.use = (self, other, activator) => {
4826
- if (entity.spawnflags & 32) {
4878
+ if (entity.spawnflags & SPAWNFLAG_DOOR_TOGGLE) {
4827
4879
  if (self.state === 2 /* Closed */) {
4828
4880
  self.state = 1 /* Opening */;
4829
- self.think = door_go_up;
4830
- context.entities.scheduleThink(self, context.entities.timeSeconds + 0.1);
4881
+ door_go_up(self, context.entities);
4831
4882
  } else if (self.state === 0 /* Open */) {
4832
4883
  self.state = 3 /* Closing */;
4833
- self.think = door_go_down;
4834
- context.entities.scheduleThink(self, context.entities.timeSeconds + 0.1);
4884
+ door_go_down(self, context.entities);
4835
4885
  }
4836
4886
  return;
4837
4887
  }
4838
4888
  if (self.state !== 2 /* Closed */) return;
4839
4889
  self.state = 1 /* Opening */;
4840
- self.think = door_go_up;
4841
- context.entities.scheduleThink(self, context.entities.timeSeconds + 0.1);
4842
- let soundName = "doors/dr1_strt.wav";
4843
- if (entity.sounds) {
4844
- switch (entity.sounds) {
4845
- case 1:
4846
- soundName = "doors/dr1_strt.wav";
4847
- break;
4848
- case 2:
4849
- soundName = "doors/dr2_strt.wav";
4850
- break;
4851
- case 3:
4852
- soundName = "doors/dr3_strt.wav";
4853
- break;
4854
- case 4:
4855
- soundName = "doors/dr4_strt.wav";
4856
- break;
4857
- default:
4858
- soundName = "doors/dr1_strt.wav";
4859
- }
4860
- }
4861
- context.entities.sound(self, 0, soundName, 1, 1, 0);
4890
+ door_go_up(self, context.entities);
4862
4891
  };
4863
4892
  if (entity.health <= 0 && !entity.targetname) {
4864
4893
  entity.touch = (self, other) => {
4865
- if (!other || other.classname !== "player") return;
4894
+ if (!other) return;
4895
+ if (self.spawnflags & SPAWNFLAG_DOOR_NOMONSTER) {
4896
+ if (other.svflags & 4 /* Monster */) return;
4897
+ }
4898
+ if (other.classname !== "player" && !(other.svflags & 4 /* Monster */)) return;
4866
4899
  self.use?.(self, other, other);
4867
4900
  };
4868
4901
  }