quake2ts 0.0.179 → 0.0.181

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.
@@ -2202,6 +2202,9 @@ function ai_run(self, distance2, deltaSeconds, context) {
2202
2202
  }
2203
2203
  setIdealYawTowards2(self, self.enemy ?? self.goalentity);
2204
2204
  changeYaw(self, deltaSeconds);
2205
+ if (self.monsterinfo.checkattack && self.monsterinfo.checkattack(self, context)) {
2206
+ return;
2207
+ }
2205
2208
  if (distance2 !== 0) {
2206
2209
  M_walkmove(self, self.angles.y, distance2, context);
2207
2210
  }
@@ -2218,6 +2221,9 @@ function ai_face(self, enemy, distance2, deltaSeconds) {
2218
2221
  function ai_charge(self, distance2, deltaSeconds, context) {
2219
2222
  setIdealYawTowards2(self, self.enemy);
2220
2223
  changeYaw(self, deltaSeconds);
2224
+ if (self.monsterinfo.checkattack && self.monsterinfo.checkattack(self, context)) {
2225
+ return;
2226
+ }
2221
2227
  if (distance2 !== 0) {
2222
2228
  M_walkmove(self, self.angles.y, distance2, context);
2223
2229
  }
@@ -8615,6 +8621,9 @@ function infantry_attack(self) {
8615
8621
  function infantry_die(self) {
8616
8622
  self.monsterinfo.current_move = death_move9;
8617
8623
  }
8624
+ function infantry_duck(self) {
8625
+ self.monsterinfo.current_move = duck_move3;
8626
+ }
8618
8627
  var stand_frames11 = Array.from({ length: 22 }, () => ({
8619
8628
  ai: monster_ai_stand12,
8620
8629
  dist: 0
@@ -8686,12 +8695,32 @@ var duck_frames3 = Array.from({ length: 5 }, () => ({
8686
8695
  }));
8687
8696
  duck_move3 = {
8688
8697
  firstframe: 90,
8689
- // Hypothetical start for duck
8690
8698
  lastframe: 94,
8691
8699
  frames: duck_frames3,
8692
8700
  endfunc: infantry_run
8693
- // Return to run
8694
8701
  };
8702
+ function infantry_dodge(self, context) {
8703
+ if (!self.enemy) return false;
8704
+ if (self.monsterinfo.current_move === duck_move3 || self.monsterinfo.current_move === death_move9 || self.monsterinfo.current_move === pain_move7) {
8705
+ return false;
8706
+ }
8707
+ if (Math.random() > 0.3) return false;
8708
+ infantry_duck(self);
8709
+ return true;
8710
+ }
8711
+ function infantry_checkattack(self, context) {
8712
+ if (!self.enemy || self.enemy.health <= 0) return false;
8713
+ if (infantry_dodge(self, context)) return true;
8714
+ const diff = subtractVec3(self.enemy.origin, self.origin);
8715
+ const dist = lengthVec3(diff);
8716
+ if (dist < 600 && visible(self, self.enemy, context.trace)) {
8717
+ if (Math.random() < 0.2) {
8718
+ self.monsterinfo.attack?.(self, context);
8719
+ return true;
8720
+ }
8721
+ }
8722
+ return false;
8723
+ }
8695
8724
  function SP_monster_infantry(self, context) {
8696
8725
  self.model = "models/monsters/infantry/tris.md2";
8697
8726
  self.mins = { x: -16, y: -16, z: -24 };
@@ -8721,6 +8750,7 @@ function SP_monster_infantry(self, context) {
8721
8750
  self.monsterinfo.walk = infantry_walk;
8722
8751
  self.monsterinfo.run = infantry_run;
8723
8752
  self.monsterinfo.attack = infantry_attack;
8753
+ self.monsterinfo.checkattack = infantry_checkattack;
8724
8754
  self.think = monster_think;
8725
8755
  infantry_stand(self);
8726
8756
  self.nextthink = self.timestamp + MONSTER_TICK12;
@@ -9486,7 +9516,7 @@ function mutant_jump_takeoff(self, context) {
9486
9516
  self.groundentity = null;
9487
9517
  context.engine.sound?.(self, 0, "mutant/mutatck2.wav", 1, 1, 0);
9488
9518
  }
9489
- function mutant_check_attack(self) {
9519
+ function mutant_check_attack(self, context) {
9490
9520
  if (self.enemy && self.enemy.health > 0) {
9491
9521
  const diff = subtractVec3(self.enemy.origin, self.origin);
9492
9522
  const dist = lengthVec3(diff);