quake2ts 0.0.180 → 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.
@@ -2036,6 +2036,9 @@ function ai_run(self, distance2, deltaSeconds, context) {
2036
2036
  }
2037
2037
  setIdealYawTowards2(self, self.enemy ?? self.goalentity);
2038
2038
  changeYaw(self, deltaSeconds);
2039
+ if (self.monsterinfo.checkattack && self.monsterinfo.checkattack(self, context)) {
2040
+ return;
2041
+ }
2039
2042
  if (distance2 !== 0) {
2040
2043
  M_walkmove(self, self.angles.y, distance2, context);
2041
2044
  }
@@ -2052,6 +2055,9 @@ function ai_face(self, enemy, distance2, deltaSeconds) {
2052
2055
  function ai_charge(self, distance2, deltaSeconds, context) {
2053
2056
  setIdealYawTowards2(self, self.enemy);
2054
2057
  changeYaw(self, deltaSeconds);
2058
+ if (self.monsterinfo.checkattack && self.monsterinfo.checkattack(self, context)) {
2059
+ return;
2060
+ }
2055
2061
  if (distance2 !== 0) {
2056
2062
  M_walkmove(self, self.angles.y, distance2, context);
2057
2063
  }
@@ -8449,6 +8455,9 @@ function infantry_attack(self) {
8449
8455
  function infantry_die(self) {
8450
8456
  self.monsterinfo.current_move = death_move9;
8451
8457
  }
8458
+ function infantry_duck(self) {
8459
+ self.monsterinfo.current_move = duck_move3;
8460
+ }
8452
8461
  var stand_frames11 = Array.from({ length: 22 }, () => ({
8453
8462
  ai: monster_ai_stand12,
8454
8463
  dist: 0
@@ -8520,12 +8529,32 @@ var duck_frames3 = Array.from({ length: 5 }, () => ({
8520
8529
  }));
8521
8530
  duck_move3 = {
8522
8531
  firstframe: 90,
8523
- // Hypothetical start for duck
8524
8532
  lastframe: 94,
8525
8533
  frames: duck_frames3,
8526
8534
  endfunc: infantry_run
8527
- // Return to run
8528
8535
  };
8536
+ function infantry_dodge(self, context) {
8537
+ if (!self.enemy) return false;
8538
+ if (self.monsterinfo.current_move === duck_move3 || self.monsterinfo.current_move === death_move9 || self.monsterinfo.current_move === pain_move7) {
8539
+ return false;
8540
+ }
8541
+ if (Math.random() > 0.3) return false;
8542
+ infantry_duck(self);
8543
+ return true;
8544
+ }
8545
+ function infantry_checkattack(self, context) {
8546
+ if (!self.enemy || self.enemy.health <= 0) return false;
8547
+ if (infantry_dodge(self, context)) return true;
8548
+ const diff = subtractVec3(self.enemy.origin, self.origin);
8549
+ const dist = lengthVec3(diff);
8550
+ if (dist < 600 && visible(self, self.enemy, context.trace)) {
8551
+ if (Math.random() < 0.2) {
8552
+ self.monsterinfo.attack?.(self, context);
8553
+ return true;
8554
+ }
8555
+ }
8556
+ return false;
8557
+ }
8529
8558
  function SP_monster_infantry(self, context) {
8530
8559
  self.model = "models/monsters/infantry/tris.md2";
8531
8560
  self.mins = { x: -16, y: -16, z: -24 };
@@ -8555,6 +8584,7 @@ function SP_monster_infantry(self, context) {
8555
8584
  self.monsterinfo.walk = infantry_walk;
8556
8585
  self.monsterinfo.run = infantry_run;
8557
8586
  self.monsterinfo.attack = infantry_attack;
8587
+ self.monsterinfo.checkattack = infantry_checkattack;
8558
8588
  self.think = monster_think;
8559
8589
  infantry_stand(self);
8560
8590
  self.nextthink = self.timestamp + MONSTER_TICK12;
@@ -9320,7 +9350,7 @@ function mutant_jump_takeoff(self, context) {
9320
9350
  self.groundentity = null;
9321
9351
  context.engine.sound?.(self, 0, "mutant/mutatck2.wav", 1, 1, 0);
9322
9352
  }
9323
- function mutant_check_attack(self) {
9353
+ function mutant_check_attack(self, context) {
9324
9354
  if (self.enemy && self.enemy.health > 0) {
9325
9355
  const diff = subtractVec3(self.enemy.origin, self.origin);
9326
9356
  const dist = lengthVec3(diff);