quake2ts 0.0.182 → 0.0.184

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.
@@ -3011,6 +3011,12 @@ var EntitySystem = class {
3011
3011
  get rng() {
3012
3012
  return this.random;
3013
3013
  }
3014
+ setSpawnRegistry(registry) {
3015
+ this.spawnRegistry = registry;
3016
+ }
3017
+ getSpawnFunction(classname) {
3018
+ return this.spawnRegistry?.get(classname);
3019
+ }
3014
3020
  get trace() {
3015
3021
  return this.imports.trace;
3016
3022
  }
@@ -9240,18 +9246,79 @@ function medic_fire_blaster(self, context) {
9240
9246
  const forward = normalizeVec3(subtractVec3(self.enemy.origin, start));
9241
9247
  monster_fire_blaster(self, start, forward, 2, 1e3, 0, 0, context, 10 /* HYPERBLASTER */);
9242
9248
  }
9243
- function medic_heal(self, context) {
9249
+ function medic_cable_attack(self, context) {
9250
+ if (!self.enemy || self.enemy.deadflag !== 2 /* Dead */) {
9251
+ return;
9252
+ }
9253
+ const dist = rangeTo(self, self.enemy);
9254
+ if (dist > 400) {
9255
+ self.monsterinfo.current_move = run_move13;
9256
+ return;
9257
+ }
9258
+ const vectors = angleVectors(self.angles);
9259
+ const f = vectors.forward;
9260
+ const r = vectors.right;
9261
+ const u = vectors.up;
9262
+ const offset = { x: 24, y: 0, z: 6 };
9263
+ const start = addVec3(
9264
+ self.origin,
9265
+ addVec3(
9266
+ scaleVec3(f, offset.x),
9267
+ addVec3(scaleVec3(r, offset.y), scaleVec3(u, offset.z))
9268
+ )
9269
+ );
9270
+ const end = self.enemy.origin;
9271
+ context.multicast(self.origin, 1 /* Pvs */, ServerCommand.temp_entity, {
9272
+ te: TempEntity.MEDIC_CABLE_ATTACK,
9273
+ entId: self.index,
9274
+ targetId: self.enemy.index,
9275
+ // Assuming targetId for the beam target
9276
+ start,
9277
+ end
9278
+ });
9279
+ }
9280
+ function medic_hook_launch(self, context) {
9281
+ context.engine.sound?.(self, 0, "medic/medatck2.wav", 1, 1, 0);
9282
+ medic_cable_attack(self, context);
9283
+ }
9284
+ function medic_hook_retract(self, context) {
9244
9285
  if (!self.enemy || self.enemy.deadflag !== 2 /* Dead */) {
9245
9286
  return;
9246
9287
  }
9247
9288
  const ent = self.enemy;
9248
- ent.deadflag = 0 /* Alive */;
9249
- ent.health = ent.max_health;
9250
- ent.takedamage = true;
9251
- ent.solid = 2 /* BoundingBox */;
9252
- ent.nextthink = context.timeSeconds + 0.1;
9253
- if (ent.monsterinfo && ent.monsterinfo.stand) {
9254
- ent.monsterinfo.stand(ent, context);
9289
+ const spawnFunc = context.getSpawnFunction(ent.classname);
9290
+ if (rangeTo(self, ent) > 400) {
9291
+ self.enemy = null;
9292
+ return;
9293
+ }
9294
+ if (!spawnFunc) {
9295
+ ent.deadflag = 0 /* Alive */;
9296
+ ent.health = ent.max_health;
9297
+ ent.takedamage = true;
9298
+ ent.solid = 2 /* BoundingBox */;
9299
+ ent.nextthink = context.timeSeconds + 0.1;
9300
+ if (ent.monsterinfo && ent.monsterinfo.stand) {
9301
+ ent.monsterinfo.stand(ent, context);
9302
+ }
9303
+ } else {
9304
+ const spawnContext = {
9305
+ entities: context,
9306
+ keyValues: { classname: ent.classname },
9307
+ // Minimal keyvalues
9308
+ warn: (msg) => {
9309
+ },
9310
+ // Suppress warnings
9311
+ free: (e) => context.free(e)
9312
+ };
9313
+ const origin = { ...ent.origin };
9314
+ const angles = { ...ent.angles };
9315
+ spawnFunc(ent, spawnContext);
9316
+ ent.origin = origin;
9317
+ ent.angles = angles;
9318
+ context.linkentity(ent);
9319
+ ent.deadflag = 0 /* Alive */;
9320
+ ent.takedamage = true;
9321
+ context.finalizeSpawn(ent);
9255
9322
  }
9256
9323
  self.enemy = null;
9257
9324
  }
@@ -9274,6 +9341,7 @@ function medic_find_dead(self, context) {
9274
9341
  if (ent.deadflag !== 2 /* Dead */) return;
9275
9342
  if (!ent.monsterinfo) return;
9276
9343
  if (ent.classname === "monster_medic") return;
9344
+ if (ent.bad_medic === self) return;
9277
9345
  if (!visible(self, ent, traceWrapper)) return;
9278
9346
  const dist = rangeTo(self, ent);
9279
9347
  if (dist < bestDist) {
@@ -9335,15 +9403,22 @@ attack_hyper_move = {
9335
9403
  frames: attack_hyper_frames,
9336
9404
  endfunc: medic_run
9337
9405
  };
9338
- var attack_cable_frames = Array.from({ length: 10 }, (_, i) => ({
9339
- ai: monster_ai_charge15,
9340
- dist: 0,
9341
- think: i === 5 ? medic_heal : null
9342
- }));
9406
+ var attack_cable_frames = [
9407
+ { ai: monster_ai_charge15, dist: 0, think: medic_hook_launch },
9408
+ { ai: monster_ai_charge15, dist: 0, think: medic_cable_attack },
9409
+ { ai: monster_ai_charge15, dist: 0, think: medic_cable_attack },
9410
+ { ai: monster_ai_charge15, dist: 0, think: medic_cable_attack },
9411
+ { ai: monster_ai_charge15, dist: 0, think: medic_cable_attack },
9412
+ { ai: monster_ai_charge15, dist: 0, think: medic_cable_attack },
9413
+ { ai: monster_ai_charge15, dist: 0, think: medic_cable_attack },
9414
+ { ai: monster_ai_charge15, dist: 0, think: medic_cable_attack },
9415
+ { ai: monster_ai_charge15, dist: 0, think: medic_hook_retract }
9416
+ ];
9343
9417
  attack_cable_move = {
9344
9418
  firstframe: 106,
9345
- // Assume frames come after hyper attack
9346
- lastframe: 115,
9419
+ // FRAME_attack42 (starts at 0+30+40+20+16 = 106) ... wait, check original counts.
9420
+ // stand=30, walk=40, run=20, hyper=16. 30+40+20+16 = 106. Correct.
9421
+ lastframe: 114,
9347
9422
  frames: attack_cable_frames,
9348
9423
  endfunc: medic_run
9349
9424
  };
@@ -13036,7 +13111,7 @@ function createGame({ trace, pointcontents, multicast, unicast }, engine, option
13036
13111
  player.velocity = newState.velocity;
13037
13112
  player.angles = newState.viewAngles;
13038
13113
  };
13039
- return {
13114
+ const gameExports = {
13040
13115
  init(startTimeMs) {
13041
13116
  resetState(startTimeMs);
13042
13117
  return snapshot(0);
@@ -13130,6 +13205,9 @@ function createGame({ trace, pointcontents, multicast, unicast }, engine, option
13130
13205
  frameLoop.reset(save.level.timeSeconds * 1e3);
13131
13206
  }
13132
13207
  };
13208
+ const spawnRegistry = createDefaultSpawnRegistry(gameExports);
13209
+ entities.setSpawnRegistry(spawnRegistry);
13210
+ return gameExports;
13133
13211
  }
13134
13212
  // Annotate the CommonJS export names for ESM import in node:
13135
13213
  0 && (module.exports = {