quake2ts 0.0.214 → 0.0.216

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.
@@ -5304,6 +5304,7 @@ function throwGibs(sys, origin, damage) {
5304
5304
  // src/entities/monsters/berserk.ts
5305
5305
  var MONSTER_TICK = 0.1;
5306
5306
  var MELEE_DISTANCE = 80;
5307
+ var SPAWNFLAG_BERSERK_NOJUMPING = 16;
5307
5308
  var random2 = createRandomGenerator();
5308
5309
  function frandom() {
5309
5310
  return random2.frandom();
@@ -5525,6 +5526,25 @@ berserk_move_attack_club = {
5525
5526
  frames: berserk_frames_attack_club,
5526
5527
  endfunc: berserk_run
5527
5528
  };
5529
+ function T_SlamRadiusDamage(inflictor, attacker, damage, radius, kick, context) {
5530
+ const entities = context.findByRadius(inflictor.origin, radius);
5531
+ for (const ent of entities) {
5532
+ if (ent === inflictor) continue;
5533
+ if (!ent.takedamage) continue;
5534
+ const dist = Math.sqrt(
5535
+ Math.pow(ent.origin.x - inflictor.origin.x, 2) + Math.pow(ent.origin.y - inflictor.origin.y, 2) + Math.pow(ent.origin.z - inflictor.origin.z, 2)
5536
+ );
5537
+ const amount = Math.max(0, 1 - dist / radius);
5538
+ if (amount <= 0) continue;
5539
+ const points = Math.max(1, damage * amount * amount);
5540
+ const k = kick * amount * amount;
5541
+ const dir = normalizeVec3(subtractVec3(ent.origin, inflictor.origin));
5542
+ T_Damage(ent, inflictor, attacker, dir, ent.origin, dir, points, k, 1 /* RADIUS */, 0 /* UNKNOWN */, context.timeSeconds, context.multicast.bind(context));
5543
+ if (ent.client) {
5544
+ ent.velocity = { ...ent.velocity, z: Math.max(270, ent.velocity.z) };
5545
+ }
5546
+ }
5547
+ }
5528
5548
  function berserk_attack_slam(self, context) {
5529
5549
  context.sound(self, 1, SOUNDS.thud, 1, 1, 0);
5530
5550
  context.sound(self, 2, SOUNDS.explod, 0.75, 1, 0);
@@ -5539,34 +5559,17 @@ function berserk_attack_slam(self, context) {
5539
5559
  context.multicast(tr.endpos, 2 /* Phs */, ServerCommand.temp_entity, TempEntity.BERSERK_SLAM, tr.endpos);
5540
5560
  self.gravity = 1;
5541
5561
  self.velocity = { x: 0, y: 0, z: 0 };
5542
- const damage = 8;
5543
- const kick = 300;
5544
- const radius = 165;
5545
- const entities = context.findByRadius(tr.endpos, radius * 2);
5546
- for (const ent of entities) {
5547
- if (ent === self) continue;
5548
- if (!ent.takedamage) continue;
5549
- const dist = Math.sqrt(
5550
- Math.pow(ent.origin.x - tr.endpos.x, 2) + Math.pow(ent.origin.y - tr.endpos.y, 2) + Math.pow(ent.origin.z - tr.endpos.z, 2)
5551
- );
5552
- const amount = Math.max(0, 1 - dist / radius);
5553
- if (amount <= 0) continue;
5554
- const points = Math.max(1, damage * amount * amount);
5555
- const k = kick * amount * amount;
5556
- const dir = normalizeVec3(subtractVec3(ent.origin, tr.endpos));
5557
- T_Damage(ent, self, self, dir, ent.origin, dir, points, k, 1 /* RADIUS */, 0 /* UNKNOWN */, context.timeSeconds, context.multicast.bind(context));
5558
- if (ent.client) {
5559
- const currentVel = { ...ent.velocity };
5560
- currentVel.z = Math.max(270, currentVel.z);
5561
- ent.velocity = currentVel;
5562
- }
5563
- }
5562
+ T_SlamRadiusDamage(self, self, 8, 165, 300, context);
5564
5563
  }
5565
5564
  function berserk_jump_touch(self, other, plane, surf, context) {
5566
5565
  if (self.health <= 0) {
5567
5566
  self.touch = void 0;
5568
5567
  return;
5569
5568
  }
5569
+ if (other && other.takedamage) {
5570
+ self.touch = void 0;
5571
+ berserk_attack_slam(self, context);
5572
+ }
5570
5573
  }
5571
5574
  function berserk_high_gravity(self, context) {
5572
5575
  const base = 800;
@@ -5666,6 +5669,7 @@ function berserk_attack(self, context) {
5666
5669
  if ((self.monsterinfo.melee_debounce_time || 0) <= context.timeSeconds && dist < MELEE_DISTANCE) {
5667
5670
  berserk_melee(self, context);
5668
5671
  } else if (self.timestamp < context.timeSeconds && brandom() && dist > 150) {
5672
+ if (self.spawnflags & SPAWNFLAG_BERSERK_NOJUMPING) return;
5669
5673
  M_SetAnimation(self, berserk_move_attack_strike);
5670
5674
  context.sound(self, 1, SOUNDS.jump, 1, 1, 0);
5671
5675
  self.timestamp = context.timeSeconds + 5;