quake2ts 0.0.466 → 0.0.468

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.
@@ -2547,6 +2547,7 @@ __export(index_exports, {
2547
2547
  ai_face: () => ai_face,
2548
2548
  ai_move: () => ai_move,
2549
2549
  ai_run: () => ai_run,
2550
+ ai_run_slide: () => ai_run_slide,
2550
2551
  ai_stand: () => ai_stand,
2551
2552
  ai_turn: () => ai_turn,
2552
2553
  ai_walk: () => ai_walk,
@@ -2605,6 +2606,7 @@ __export(index_exports, {
2605
2606
  infront: () => infront,
2606
2607
  isZeroVector: () => isZeroVector,
2607
2608
  killBox: () => killBox,
2609
+ monster_done_dodge: () => monster_done_dodge,
2608
2610
  monster_jump_finished: () => monster_jump_finished,
2609
2611
  monster_jump_start: () => monster_jump_start,
2610
2612
  monster_think: () => monster_think,
@@ -3611,6 +3613,7 @@ function ai_checkattack(self, dist, context) {
3611
3613
  // src/ai/movement.ts
3612
3614
  var STEPSIZE = 18;
3613
3615
  var MONSTER_TICK = 0.1;
3616
+ var MAX_SIDESTEP = 8;
3614
3617
  function yawVector(yawDegrees, distance4) {
3615
3618
  if (distance4 === 0) {
3616
3619
  return { x: 0, y: 0, z: 0 };
@@ -3669,6 +3672,44 @@ function setIdealYawTowards2(self, target) {
3669
3672
  };
3670
3673
  self.ideal_yaw = vectorToYaw(toTarget);
3671
3674
  }
3675
+ function monster_done_dodge(self) {
3676
+ self.monsterinfo.aiflags &= ~524288 /* Dodging */;
3677
+ self.monsterinfo.attack_state = 0 /* Straight */;
3678
+ }
3679
+ function ai_run_slide(self, distance4, context) {
3680
+ const ideal_yaw = self.ideal_yaw;
3681
+ const angle = 90;
3682
+ let ofs;
3683
+ if (self.monsterinfo.lefty) {
3684
+ ofs = angle;
3685
+ } else {
3686
+ ofs = -angle;
3687
+ }
3688
+ if (!(self.monsterinfo.aiflags & 2048 /* ManualSteering */)) {
3689
+ changeYaw(self, MONSTER_TICK);
3690
+ }
3691
+ if (!(self.flags & 1 /* Fly */)) {
3692
+ const scale = 1;
3693
+ const maxDist = MAX_SIDESTEP * scale;
3694
+ if (distance4 > maxDist) distance4 = maxDist;
3695
+ }
3696
+ if (M_walkmove(self, ideal_yaw + ofs, distance4, context)) {
3697
+ return;
3698
+ }
3699
+ if (self.monsterinfo.aiflags & 524288 /* Dodging */) {
3700
+ monster_done_dodge(self);
3701
+ self.monsterinfo.attack_state = 0 /* Straight */;
3702
+ return;
3703
+ }
3704
+ self.monsterinfo.lefty = self.monsterinfo.lefty ? 0 : 1;
3705
+ if (M_walkmove(self, ideal_yaw - ofs, distance4, context)) {
3706
+ return;
3707
+ }
3708
+ if (self.monsterinfo.aiflags & 524288 /* Dodging */) {
3709
+ monster_done_dodge(self);
3710
+ }
3711
+ self.monsterinfo.attack_state = 0 /* Straight */;
3712
+ }
3672
3713
  function ai_stand(self, dist, context) {
3673
3714
  if (dist) {
3674
3715
  M_walkmove(self, self.angles.y, dist, context);
@@ -3727,14 +3768,20 @@ function ai_run(self, dist, context) {
3727
3768
  if (ai_checkattack(self, dist, context)) {
3728
3769
  return;
3729
3770
  }
3730
- if (self.monsterinfo.attack_state === 0 /* Straight */) {
3731
- M_walkmove(self, self.angles.y, dist, context);
3771
+ const enemy_vis = self.enemy && visible(self, self.enemy, context.trace, { throughGlass: false });
3772
+ if (!enemy_vis && self.monsterinfo.attack_state === 1 /* Sliding */) {
3732
3773
  self.monsterinfo.attack_state = 0 /* Straight */;
3733
- return;
3774
+ }
3775
+ if (self.monsterinfo.aiflags & 524288 /* Dodging */) {
3776
+ self.monsterinfo.attack_state = 1 /* Sliding */;
3777
+ }
3778
+ if (self.monsterinfo.attack_state === 0 /* Straight */) {
3734
3779
  }
3735
3780
  if (self.monsterinfo.attack_state === 1 /* Sliding */) {
3736
- M_walkmove(self, self.angles.y, dist, context);
3737
- return;
3781
+ ai_run_slide(self, dist, context);
3782
+ if (self.monsterinfo.attack_state === 1 /* Sliding */) {
3783
+ return;
3784
+ }
3738
3785
  }
3739
3786
  M_MoveToGoal(self, dist, context);
3740
3787
  }
@@ -12129,7 +12176,7 @@ function M_ProjectFlashSource(self, offset, forward, right) {
12129
12176
  }
12130
12177
  function M_MonsterDodge(self, attacker, eta) {
12131
12178
  }
12132
- function monster_done_dodge(self) {
12179
+ function monster_done_dodge2(self) {
12133
12180
  self.monsterinfo.aiflags &= ~524288 /* Dodging */;
12134
12181
  if (self.monsterinfo.attack_state === 1 /* Sliding */) {
12135
12182
  self.monsterinfo.attack_state = 0 /* Straight */;
@@ -12324,7 +12371,7 @@ function blocked_checkplat(context, self, dist) {
12324
12371
  return false;
12325
12372
  }
12326
12373
  function monster_jump_start(context, self) {
12327
- monster_done_dodge(self);
12374
+ monster_done_dodge2(self);
12328
12375
  self.monsterinfo.jump_time = context.timeSeconds + 3;
12329
12376
  }
12330
12377
  function monster_jump_finished(context, self) {
@@ -12501,7 +12548,7 @@ var berserk_frames_run1 = [
12501
12548
  { ai: monster_ai_run, dist: 21 },
12502
12549
  { ai: monster_ai_run, dist: 11, think: monster_footstep },
12503
12550
  { ai: monster_ai_run, dist: 21 },
12504
- { ai: monster_ai_run, dist: 25, think: monster_done_dodge },
12551
+ { ai: monster_ai_run, dist: 25, think: monster_done_dodge2 },
12505
12552
  { ai: monster_ai_run, dist: 18, think: monster_footstep },
12506
12553
  { ai: monster_ai_run, dist: 19 }
12507
12554
  ];
@@ -12512,7 +12559,7 @@ berserk_move_run1 = {
12512
12559
  endfunc: null
12513
12560
  };
12514
12561
  function berserk_run(self, context) {
12515
- monster_done_dodge(self);
12562
+ monster_done_dodge2(self);
12516
12563
  if (self.monsterinfo.aiflags & 1 /* StandGround */) {
12517
12564
  M_SetAnimation3(self, berserk_move_stand);
12518
12565
  } else {
@@ -13885,7 +13932,7 @@ function chick_walk(self) {
13885
13932
  self.monsterinfo.current_move = walk_move2;
13886
13933
  }
13887
13934
  function chick_run(self) {
13888
- monster_done_dodge(self);
13935
+ monster_done_dodge2(self);
13889
13936
  if (self.monsterinfo.aiflags & 4) {
13890
13937
  self.monsterinfo.current_move = stand_move3;
13891
13938
  return;
@@ -21735,7 +21782,7 @@ function guncmdr_walk(self, context) {
21735
21782
  M_SetAnimation(self, walk_move18, context);
21736
21783
  }
21737
21784
  function guncmdr_run(self, context) {
21738
- monster_done_dodge(self);
21785
+ monster_done_dodge2(self);
21739
21786
  if (self.monsterinfo.aiflags & 1 /* StandGround */) {
21740
21787
  M_SetAnimation(self, stand_move21, context);
21741
21788
  } else {
@@ -21753,7 +21800,7 @@ function guncmdr_fire_chain(self, context) {
21753
21800
  M_SetAnimation(self, fire_chain_move2, context);
21754
21801
  }
21755
21802
  function guncmdr_refire_chain(self, context) {
21756
- monster_done_dodge(self);
21803
+ monster_done_dodge2(self);
21757
21804
  self.monsterinfo.attack_state = MonsterAttackState.Straight;
21758
21805
  if (self.enemy && self.enemy.health > 0) {
21759
21806
  if (visible(self, self.enemy, context.trace)) {
@@ -21963,7 +22010,7 @@ function guncmdr_jump_wait_land(self, context) {
21963
22010
  }
21964
22011
  function guncmdr_jump(self, result, context) {
21965
22012
  if (!self.enemy) return;
21966
- monster_done_dodge(self);
22013
+ monster_done_dodge2(self);
21967
22014
  if (result === 2 /* JUMP_JUMP_UP */) {
21968
22015
  M_SetAnimation(self, jump2_move, context);
21969
22016
  } else {
@@ -21974,7 +22021,7 @@ function GunnerCmdrCounter(self, context) {
21974
22021
  context.engine.sound?.(self, 0, "weapons/rocklx1a.wav", 1, 1, 0);
21975
22022
  }
21976
22023
  function guncmdr_attack(self, context) {
21977
- monster_done_dodge(self);
22024
+ monster_done_dodge2(self);
21978
22025
  const d = lengthVec3(subtractVec3(self.enemy.origin, self.origin));
21979
22026
  const { forward, right } = angleVectors(self.angles);
21980
22027
  const RANGE_GRENADE = 100;
@@ -22032,7 +22079,7 @@ function guncmdr_dead(self, context) {
22032
22079
  self.solid = 0 /* Not */;
22033
22080
  }
22034
22081
  function guncmdr_pain(self, context) {
22035
- monster_done_dodge(self);
22082
+ monster_done_dodge2(self);
22036
22083
  if (self.monsterinfo.current_move === jump_move3 || self.monsterinfo.current_move === jump2_move || self.monsterinfo.current_move === duck_attack_move) {
22037
22084
  return;
22038
22085
  }
@@ -22217,7 +22264,7 @@ run_move20 = {
22217
22264
  firstframe: 101,
22218
22265
  lastframe: 106,
22219
22266
  frames: [
22220
- { ai: monster_ai_run24, dist: 15, think: monster_done_dodge },
22267
+ { ai: monster_ai_run24, dist: 15, think: monster_done_dodge2 },
22221
22268
  { ai: monster_ai_run24, dist: 16 },
22222
22269
  { ai: monster_ai_run24, dist: 20 },
22223
22270
  { ai: monster_ai_run24, dist: 18 },
@@ -26813,6 +26860,7 @@ function createGame(imports, engine, options) {
26813
26860
  ai_face,
26814
26861
  ai_move,
26815
26862
  ai_run,
26863
+ ai_run_slide,
26816
26864
  ai_stand,
26817
26865
  ai_turn,
26818
26866
  ai_walk,
@@ -26871,6 +26919,7 @@ function createGame(imports, engine, options) {
26871
26919
  infront,
26872
26920
  isZeroVector,
26873
26921
  killBox,
26922
+ monster_done_dodge,
26874
26923
  monster_jump_finished,
26875
26924
  monster_jump_start,
26876
26925
  monster_think,