quake2ts 0.0.466 → 0.0.467

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.
@@ -3422,6 +3422,7 @@ function ai_checkattack(self, dist, context) {
3422
3422
  // src/ai/movement.ts
3423
3423
  var STEPSIZE = 18;
3424
3424
  var MONSTER_TICK = 0.1;
3425
+ var MAX_SIDESTEP = 8;
3425
3426
  function yawVector(yawDegrees, distance4) {
3426
3427
  if (distance4 === 0) {
3427
3428
  return { x: 0, y: 0, z: 0 };
@@ -3480,6 +3481,44 @@ function setIdealYawTowards2(self, target) {
3480
3481
  };
3481
3482
  self.ideal_yaw = vectorToYaw(toTarget);
3482
3483
  }
3484
+ function monster_done_dodge(self) {
3485
+ self.monsterinfo.aiflags &= ~524288 /* Dodging */;
3486
+ self.monsterinfo.attack_state = 0 /* Straight */;
3487
+ }
3488
+ function ai_run_slide(self, distance4, context) {
3489
+ const ideal_yaw = self.ideal_yaw;
3490
+ const angle = 90;
3491
+ let ofs;
3492
+ if (self.monsterinfo.lefty) {
3493
+ ofs = angle;
3494
+ } else {
3495
+ ofs = -angle;
3496
+ }
3497
+ if (!(self.monsterinfo.aiflags & 2048 /* ManualSteering */)) {
3498
+ changeYaw(self, MONSTER_TICK);
3499
+ }
3500
+ if (!(self.flags & 1 /* Fly */)) {
3501
+ const scale = 1;
3502
+ const maxDist = MAX_SIDESTEP * scale;
3503
+ if (distance4 > maxDist) distance4 = maxDist;
3504
+ }
3505
+ if (M_walkmove(self, ideal_yaw + ofs, distance4, context)) {
3506
+ return;
3507
+ }
3508
+ if (self.monsterinfo.aiflags & 524288 /* Dodging */) {
3509
+ monster_done_dodge(self);
3510
+ self.monsterinfo.attack_state = 0 /* Straight */;
3511
+ return;
3512
+ }
3513
+ self.monsterinfo.lefty = self.monsterinfo.lefty ? 0 : 1;
3514
+ if (M_walkmove(self, ideal_yaw - ofs, distance4, context)) {
3515
+ return;
3516
+ }
3517
+ if (self.monsterinfo.aiflags & 524288 /* Dodging */) {
3518
+ monster_done_dodge(self);
3519
+ }
3520
+ self.monsterinfo.attack_state = 0 /* Straight */;
3521
+ }
3483
3522
  function ai_stand(self, dist, context) {
3484
3523
  if (dist) {
3485
3524
  M_walkmove(self, self.angles.y, dist, context);
@@ -3538,14 +3577,20 @@ function ai_run(self, dist, context) {
3538
3577
  if (ai_checkattack(self, dist, context)) {
3539
3578
  return;
3540
3579
  }
3541
- if (self.monsterinfo.attack_state === 0 /* Straight */) {
3542
- M_walkmove(self, self.angles.y, dist, context);
3580
+ const enemy_vis = self.enemy && visible(self, self.enemy, context.trace, { throughGlass: false });
3581
+ if (!enemy_vis && self.monsterinfo.attack_state === 1 /* Sliding */) {
3543
3582
  self.monsterinfo.attack_state = 0 /* Straight */;
3544
- return;
3583
+ }
3584
+ if (self.monsterinfo.aiflags & 524288 /* Dodging */) {
3585
+ self.monsterinfo.attack_state = 1 /* Sliding */;
3586
+ }
3587
+ if (self.monsterinfo.attack_state === 0 /* Straight */) {
3545
3588
  }
3546
3589
  if (self.monsterinfo.attack_state === 1 /* Sliding */) {
3547
- M_walkmove(self, self.angles.y, dist, context);
3548
- return;
3590
+ ai_run_slide(self, dist, context);
3591
+ if (self.monsterinfo.attack_state === 1 /* Sliding */) {
3592
+ return;
3593
+ }
3549
3594
  }
3550
3595
  M_MoveToGoal(self, dist, context);
3551
3596
  }
@@ -11940,7 +11985,7 @@ function M_ProjectFlashSource(self, offset, forward, right) {
11940
11985
  }
11941
11986
  function M_MonsterDodge(self, attacker, eta) {
11942
11987
  }
11943
- function monster_done_dodge(self) {
11988
+ function monster_done_dodge2(self) {
11944
11989
  self.monsterinfo.aiflags &= ~524288 /* Dodging */;
11945
11990
  if (self.monsterinfo.attack_state === 1 /* Sliding */) {
11946
11991
  self.monsterinfo.attack_state = 0 /* Straight */;
@@ -12135,7 +12180,7 @@ function blocked_checkplat(context, self, dist) {
12135
12180
  return false;
12136
12181
  }
12137
12182
  function monster_jump_start(context, self) {
12138
- monster_done_dodge(self);
12183
+ monster_done_dodge2(self);
12139
12184
  self.monsterinfo.jump_time = context.timeSeconds + 3;
12140
12185
  }
12141
12186
  function monster_jump_finished(context, self) {
@@ -12312,7 +12357,7 @@ var berserk_frames_run1 = [
12312
12357
  { ai: monster_ai_run, dist: 21 },
12313
12358
  { ai: monster_ai_run, dist: 11, think: monster_footstep },
12314
12359
  { ai: monster_ai_run, dist: 21 },
12315
- { ai: monster_ai_run, dist: 25, think: monster_done_dodge },
12360
+ { ai: monster_ai_run, dist: 25, think: monster_done_dodge2 },
12316
12361
  { ai: monster_ai_run, dist: 18, think: monster_footstep },
12317
12362
  { ai: monster_ai_run, dist: 19 }
12318
12363
  ];
@@ -12323,7 +12368,7 @@ berserk_move_run1 = {
12323
12368
  endfunc: null
12324
12369
  };
12325
12370
  function berserk_run(self, context) {
12326
- monster_done_dodge(self);
12371
+ monster_done_dodge2(self);
12327
12372
  if (self.monsterinfo.aiflags & 1 /* StandGround */) {
12328
12373
  M_SetAnimation3(self, berserk_move_stand);
12329
12374
  } else {
@@ -13696,7 +13741,7 @@ function chick_walk(self) {
13696
13741
  self.monsterinfo.current_move = walk_move2;
13697
13742
  }
13698
13743
  function chick_run(self) {
13699
- monster_done_dodge(self);
13744
+ monster_done_dodge2(self);
13700
13745
  if (self.monsterinfo.aiflags & 4) {
13701
13746
  self.monsterinfo.current_move = stand_move3;
13702
13747
  return;
@@ -21546,7 +21591,7 @@ function guncmdr_walk(self, context) {
21546
21591
  M_SetAnimation(self, walk_move18, context);
21547
21592
  }
21548
21593
  function guncmdr_run(self, context) {
21549
- monster_done_dodge(self);
21594
+ monster_done_dodge2(self);
21550
21595
  if (self.monsterinfo.aiflags & 1 /* StandGround */) {
21551
21596
  M_SetAnimation(self, stand_move21, context);
21552
21597
  } else {
@@ -21564,7 +21609,7 @@ function guncmdr_fire_chain(self, context) {
21564
21609
  M_SetAnimation(self, fire_chain_move2, context);
21565
21610
  }
21566
21611
  function guncmdr_refire_chain(self, context) {
21567
- monster_done_dodge(self);
21612
+ monster_done_dodge2(self);
21568
21613
  self.monsterinfo.attack_state = MonsterAttackState.Straight;
21569
21614
  if (self.enemy && self.enemy.health > 0) {
21570
21615
  if (visible(self, self.enemy, context.trace)) {
@@ -21774,7 +21819,7 @@ function guncmdr_jump_wait_land(self, context) {
21774
21819
  }
21775
21820
  function guncmdr_jump(self, result, context) {
21776
21821
  if (!self.enemy) return;
21777
- monster_done_dodge(self);
21822
+ monster_done_dodge2(self);
21778
21823
  if (result === 2 /* JUMP_JUMP_UP */) {
21779
21824
  M_SetAnimation(self, jump2_move, context);
21780
21825
  } else {
@@ -21785,7 +21830,7 @@ function GunnerCmdrCounter(self, context) {
21785
21830
  context.engine.sound?.(self, 0, "weapons/rocklx1a.wav", 1, 1, 0);
21786
21831
  }
21787
21832
  function guncmdr_attack(self, context) {
21788
- monster_done_dodge(self);
21833
+ monster_done_dodge2(self);
21789
21834
  const d = lengthVec3(subtractVec3(self.enemy.origin, self.origin));
21790
21835
  const { forward, right } = angleVectors(self.angles);
21791
21836
  const RANGE_GRENADE = 100;
@@ -21843,7 +21888,7 @@ function guncmdr_dead(self, context) {
21843
21888
  self.solid = 0 /* Not */;
21844
21889
  }
21845
21890
  function guncmdr_pain(self, context) {
21846
- monster_done_dodge(self);
21891
+ monster_done_dodge2(self);
21847
21892
  if (self.monsterinfo.current_move === jump_move3 || self.monsterinfo.current_move === jump2_move || self.monsterinfo.current_move === duck_attack_move) {
21848
21893
  return;
21849
21894
  }
@@ -22028,7 +22073,7 @@ run_move20 = {
22028
22073
  firstframe: 101,
22029
22074
  lastframe: 106,
22030
22075
  frames: [
22031
- { ai: monster_ai_run24, dist: 15, think: monster_done_dodge },
22076
+ { ai: monster_ai_run24, dist: 15, think: monster_done_dodge2 },
22032
22077
  { ai: monster_ai_run24, dist: 16 },
22033
22078
  { ai: monster_ai_run24, dist: 20 },
22034
22079
  { ai: monster_ai_run24, dist: 18 },
@@ -26623,6 +26668,7 @@ export {
26623
26668
  ai_face,
26624
26669
  ai_move,
26625
26670
  ai_run,
26671
+ ai_run_slide,
26626
26672
  ai_stand,
26627
26673
  ai_turn,
26628
26674
  ai_walk,
@@ -26681,6 +26727,7 @@ export {
26681
26727
  infront,
26682
26728
  isZeroVector,
26683
26729
  killBox,
26730
+ monster_done_dodge,
26684
26731
  monster_jump_finished,
26685
26732
  monster_jump_start,
26686
26733
  monster_think,