quake2ts 0.0.497 → 0.0.498

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.
@@ -7209,8 +7209,10 @@ var SPEAKER_SPAWNFLAGS = {
7209
7209
  LoopedOff: 1 << 1,
7210
7210
  Reliable: 1 << 2
7211
7211
  };
7212
- function useChangeLevel(self) {
7212
+ function useChangeLevel(self, other, activator, context) {
7213
7213
  if (self.map) {
7214
+ context.entities.imports.serverCommand(`changelevel ${self.map}
7215
+ `);
7214
7216
  }
7215
7217
  }
7216
7218
  function targetSpeakerUse(self, other, activator, context) {
@@ -7670,13 +7672,14 @@ function registerTargetSpawns(registry) {
7670
7672
  entities.useTargets(self, self.activator ?? null);
7671
7673
  };
7672
7674
  });
7673
- registry.register("target_changelevel", (entity, { keyValues, free }) => {
7675
+ registry.register("target_changelevel", (entity, context) => {
7676
+ const { keyValues, free } = context;
7674
7677
  if (!keyValues.map) {
7675
7678
  free(entity);
7676
7679
  return;
7677
7680
  }
7678
7681
  entity.map = keyValues.map;
7679
- entity.use = useChangeLevel;
7682
+ entity.use = (self, other, activator) => useChangeLevel(self, other, activator ?? null, context);
7680
7683
  entity.solid = 1 /* Trigger */;
7681
7684
  });
7682
7685
  registry.register("target_spawner", (entity, context) => {
@@ -12492,14 +12495,81 @@ var generic_stand_frames = Array.from({ length: 1 }, () => ({
12492
12495
  ai: generic_ai_stand,
12493
12496
  dist: 0
12494
12497
  }));
12498
+ var generic_stand_move = {
12499
+ firstframe: 0,
12500
+ lastframe: 0,
12501
+ frames: generic_stand_frames,
12502
+ endfunc: (self) => {
12503
+ self.monsterinfo.current_move = generic_stand_move;
12504
+ }
12505
+ };
12495
12506
  var generic_walk_frames = Array.from({ length: 1 }, () => ({
12496
12507
  ai: generic_ai_walk,
12497
12508
  dist: 5
12498
12509
  }));
12510
+ var generic_walk_move = {
12511
+ firstframe: 0,
12512
+ lastframe: 0,
12513
+ frames: generic_walk_frames,
12514
+ endfunc: (self) => {
12515
+ self.monsterinfo.current_move = generic_walk_move;
12516
+ }
12517
+ };
12499
12518
  var generic_run_frames = Array.from({ length: 1 }, () => ({
12500
12519
  ai: generic_ai_run,
12501
12520
  dist: 10
12502
12521
  }));
12522
+ var generic_run_move = {
12523
+ firstframe: 0,
12524
+ lastframe: 0,
12525
+ frames: generic_run_frames,
12526
+ endfunc: (self) => {
12527
+ self.monsterinfo.current_move = generic_run_move;
12528
+ }
12529
+ };
12530
+ function createMonsterSpawn(config) {
12531
+ return function(self, context) {
12532
+ self.model = config.model;
12533
+ self.mins = config.mins || { x: -16, y: -16, z: -24 };
12534
+ self.maxs = config.maxs || { x: 16, y: 16, z: 32 };
12535
+ self.movetype = config.fly ? 5 /* Step */ : 5 /* Step */;
12536
+ self.solid = 2 /* BoundingBox */;
12537
+ self.health = config.health * context.health_multiplier;
12538
+ self.max_health = self.health;
12539
+ self.mass = config.mass;
12540
+ self.takedamage = true;
12541
+ self.pain = (self2, other, kick, damage) => {
12542
+ };
12543
+ self.die = (self2, inflictor, attacker, damage, point, mod = 0 /* UNKNOWN */) => {
12544
+ self2.deadflag = 2 /* Dead */;
12545
+ self2.solid = 0 /* Not */;
12546
+ if (self2.health < -40) {
12547
+ throwGibs(context.entities, self2.origin, damage, GIB_ORGANIC, mod);
12548
+ context.entities.free(self2);
12549
+ return;
12550
+ }
12551
+ self2.think = (self3) => {
12552
+ context.entities.free(self3);
12553
+ };
12554
+ self2.nextthink = context.entities.timeSeconds + 5;
12555
+ };
12556
+ self.monsterinfo.stand = (self2, context2) => {
12557
+ self2.monsterinfo.current_move = generic_stand_move;
12558
+ };
12559
+ self.monsterinfo.walk = (self2, context2) => {
12560
+ self2.monsterinfo.current_move = generic_walk_move;
12561
+ };
12562
+ self.monsterinfo.run = (self2, context2) => {
12563
+ self2.monsterinfo.current_move = generic_run_move;
12564
+ };
12565
+ self.monsterinfo.attack = (self2, context2) => {
12566
+ self2.monsterinfo.current_move = generic_run_move;
12567
+ };
12568
+ self.think = monster_think;
12569
+ self.monsterinfo.stand(self, context.entities);
12570
+ self.nextthink = self.timestamp + MONSTER_TICK2;
12571
+ };
12572
+ }
12503
12573
  function M_SetAnimation(self, move, context) {
12504
12574
  self.monsterinfo.current_move = move;
12505
12575
  }
@@ -24224,6 +24294,39 @@ function registerShamblerSpawns(registry) {
24224
24294
  registry.register("monster_shambler", SP_monster_shambler);
24225
24295
  }
24226
24296
 
24297
+ // src/entities/monsters/rogue/common.ts
24298
+ var MAX_REINFORCEMENTS2 = 5;
24299
+ var INVERSE_LOG_SLOTS = Math.pow(2, MAX_REINFORCEMENTS2);
24300
+ function M_PickValidReinforcements(self, space, output) {
24301
+ output.length = 0;
24302
+ if (!self.monsterinfo.reinforcements) return;
24303
+ for (let i = 0; i < self.monsterinfo.reinforcements.length; i++) {
24304
+ if (self.monsterinfo.reinforcements[i].strength <= space) {
24305
+ output.push(i);
24306
+ }
24307
+ }
24308
+ }
24309
+ function M_PickReinforcements(self, rng, countRef, max_slots = 0) {
24310
+ const output = [];
24311
+ const chosen = new Array(MAX_REINFORCEMENTS2).fill(255);
24312
+ let num_chosen = 0;
24313
+ let num_slots = Math.max(1, Math.floor(Math.log2(rng.frandomRange(0, INVERSE_LOG_SLOTS))));
24314
+ let remaining = (self.monsterinfo.monster_slots || 0) - (self.monsterinfo.monster_used || 0);
24315
+ for (num_chosen = 0; num_chosen < num_slots; num_chosen++) {
24316
+ if (max_slots && num_chosen === max_slots || !remaining) {
24317
+ break;
24318
+ }
24319
+ M_PickValidReinforcements(self, remaining, output);
24320
+ if (output.length === 0) {
24321
+ break;
24322
+ }
24323
+ const randIndex = rng.irandomRange(0, output.length);
24324
+ chosen[num_chosen] = output[randIndex];
24325
+ remaining -= self.monsterinfo.reinforcements[chosen[num_chosen]].strength;
24326
+ }
24327
+ return { chosen, count: num_chosen };
24328
+ }
24329
+
24227
24330
  // src/entities/monsters/rogue/widow.ts
24228
24331
  var MODEL_SCALE3 = 1;
24229
24332
  var RANGE_MELEE3 = 100;
@@ -24335,6 +24438,43 @@ function widow_kick(self, context) {
24335
24438
  }
24336
24439
  function widow_spawn_check(self, context) {
24337
24440
  if (M_SlotsLeft(self) > 0) {
24441
+ const result = M_PickReinforcements(self, context.rng, 1);
24442
+ self.monsterinfo.chosen_reinforcements = result.chosen;
24443
+ if (result.count > 0) {
24444
+ const reinforcement = self.monsterinfo.reinforcements[self.monsterinfo.chosen_reinforcements[0]];
24445
+ WidowSpawn(self, context);
24446
+ }
24447
+ }
24448
+ }
24449
+ function WidowSpawn(self, context) {
24450
+ const { forward, right } = angleVectors(self.angles);
24451
+ const offset = { x: 50, y: 0, z: 0 };
24452
+ const start = M_ProjectFlashSource(self, offset, forward, right);
24453
+ if (!self.monsterinfo.chosen_reinforcements) {
24454
+ const result = M_PickReinforcements(self, context.rng, 1);
24455
+ self.monsterinfo.chosen_reinforcements = result.chosen;
24456
+ }
24457
+ if (self.monsterinfo.chosen_reinforcements && self.monsterinfo.chosen_reinforcements[0] !== 255) {
24458
+ const rIndex = self.monsterinfo.chosen_reinforcements[0];
24459
+ const reinforcement = self.monsterinfo.reinforcements[rIndex];
24460
+ const ent = context.spawn();
24461
+ ent.origin = { ...start };
24462
+ ent.angles = { ...self.angles };
24463
+ if (reinforcement.classname === "monster_stalker") {
24464
+ SP_monster_stalker(ent, { entities: context });
24465
+ } else if (reinforcement.classname === "monster_flyer") {
24466
+ SP_monster_flyer(ent, { entities: context });
24467
+ } else {
24468
+ createMonsterSpawn({
24469
+ model: "models/monsters/stalker/tris.md2",
24470
+ health: 100,
24471
+ mass: 100
24472
+ })(ent, { entities: context });
24473
+ }
24474
+ if (ent.inUse) {
24475
+ if (!self.monsterinfo.monster_used) self.monsterinfo.monster_used = 0;
24476
+ self.monsterinfo.monster_used += reinforcement.strength;
24477
+ }
24338
24478
  }
24339
24479
  }
24340
24480
  var widow_frames_stand = Array(20).fill({ ai: widow_ai_stand, dist: 0 });