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.
@@ -7009,8 +7009,10 @@ var SPEAKER_SPAWNFLAGS = {
7009
7009
  LoopedOff: 1 << 1,
7010
7010
  Reliable: 1 << 2
7011
7011
  };
7012
- function useChangeLevel(self) {
7012
+ function useChangeLevel(self, other, activator, context) {
7013
7013
  if (self.map) {
7014
+ context.entities.imports.serverCommand(`changelevel ${self.map}
7015
+ `);
7014
7016
  }
7015
7017
  }
7016
7018
  function targetSpeakerUse(self, other, activator, context) {
@@ -7470,13 +7472,14 @@ function registerTargetSpawns(registry) {
7470
7472
  entities.useTargets(self, self.activator ?? null);
7471
7473
  };
7472
7474
  });
7473
- registry.register("target_changelevel", (entity, { keyValues, free }) => {
7475
+ registry.register("target_changelevel", (entity, context) => {
7476
+ const { keyValues, free } = context;
7474
7477
  if (!keyValues.map) {
7475
7478
  free(entity);
7476
7479
  return;
7477
7480
  }
7478
7481
  entity.map = keyValues.map;
7479
- entity.use = useChangeLevel;
7482
+ entity.use = (self, other, activator) => useChangeLevel(self, other, activator ?? null, context);
7480
7483
  entity.solid = 1 /* Trigger */;
7481
7484
  });
7482
7485
  registry.register("target_spawner", (entity, context) => {
@@ -12292,14 +12295,81 @@ var generic_stand_frames = Array.from({ length: 1 }, () => ({
12292
12295
  ai: generic_ai_stand,
12293
12296
  dist: 0
12294
12297
  }));
12298
+ var generic_stand_move = {
12299
+ firstframe: 0,
12300
+ lastframe: 0,
12301
+ frames: generic_stand_frames,
12302
+ endfunc: (self) => {
12303
+ self.monsterinfo.current_move = generic_stand_move;
12304
+ }
12305
+ };
12295
12306
  var generic_walk_frames = Array.from({ length: 1 }, () => ({
12296
12307
  ai: generic_ai_walk,
12297
12308
  dist: 5
12298
12309
  }));
12310
+ var generic_walk_move = {
12311
+ firstframe: 0,
12312
+ lastframe: 0,
12313
+ frames: generic_walk_frames,
12314
+ endfunc: (self) => {
12315
+ self.monsterinfo.current_move = generic_walk_move;
12316
+ }
12317
+ };
12299
12318
  var generic_run_frames = Array.from({ length: 1 }, () => ({
12300
12319
  ai: generic_ai_run,
12301
12320
  dist: 10
12302
12321
  }));
12322
+ var generic_run_move = {
12323
+ firstframe: 0,
12324
+ lastframe: 0,
12325
+ frames: generic_run_frames,
12326
+ endfunc: (self) => {
12327
+ self.monsterinfo.current_move = generic_run_move;
12328
+ }
12329
+ };
12330
+ function createMonsterSpawn(config) {
12331
+ return function(self, context) {
12332
+ self.model = config.model;
12333
+ self.mins = config.mins || { x: -16, y: -16, z: -24 };
12334
+ self.maxs = config.maxs || { x: 16, y: 16, z: 32 };
12335
+ self.movetype = config.fly ? 5 /* Step */ : 5 /* Step */;
12336
+ self.solid = 2 /* BoundingBox */;
12337
+ self.health = config.health * context.health_multiplier;
12338
+ self.max_health = self.health;
12339
+ self.mass = config.mass;
12340
+ self.takedamage = true;
12341
+ self.pain = (self2, other, kick, damage) => {
12342
+ };
12343
+ self.die = (self2, inflictor, attacker, damage, point, mod = 0 /* UNKNOWN */) => {
12344
+ self2.deadflag = 2 /* Dead */;
12345
+ self2.solid = 0 /* Not */;
12346
+ if (self2.health < -40) {
12347
+ throwGibs(context.entities, self2.origin, damage, GIB_ORGANIC, mod);
12348
+ context.entities.free(self2);
12349
+ return;
12350
+ }
12351
+ self2.think = (self3) => {
12352
+ context.entities.free(self3);
12353
+ };
12354
+ self2.nextthink = context.entities.timeSeconds + 5;
12355
+ };
12356
+ self.monsterinfo.stand = (self2, context2) => {
12357
+ self2.monsterinfo.current_move = generic_stand_move;
12358
+ };
12359
+ self.monsterinfo.walk = (self2, context2) => {
12360
+ self2.monsterinfo.current_move = generic_walk_move;
12361
+ };
12362
+ self.monsterinfo.run = (self2, context2) => {
12363
+ self2.monsterinfo.current_move = generic_run_move;
12364
+ };
12365
+ self.monsterinfo.attack = (self2, context2) => {
12366
+ self2.monsterinfo.current_move = generic_run_move;
12367
+ };
12368
+ self.think = monster_think;
12369
+ self.monsterinfo.stand(self, context.entities);
12370
+ self.nextthink = self.timestamp + MONSTER_TICK2;
12371
+ };
12372
+ }
12303
12373
  function M_SetAnimation(self, move, context) {
12304
12374
  self.monsterinfo.current_move = move;
12305
12375
  }
@@ -24024,6 +24094,39 @@ function registerShamblerSpawns(registry) {
24024
24094
  registry.register("monster_shambler", SP_monster_shambler);
24025
24095
  }
24026
24096
 
24097
+ // src/entities/monsters/rogue/common.ts
24098
+ var MAX_REINFORCEMENTS2 = 5;
24099
+ var INVERSE_LOG_SLOTS = Math.pow(2, MAX_REINFORCEMENTS2);
24100
+ function M_PickValidReinforcements(self, space, output) {
24101
+ output.length = 0;
24102
+ if (!self.monsterinfo.reinforcements) return;
24103
+ for (let i = 0; i < self.monsterinfo.reinforcements.length; i++) {
24104
+ if (self.monsterinfo.reinforcements[i].strength <= space) {
24105
+ output.push(i);
24106
+ }
24107
+ }
24108
+ }
24109
+ function M_PickReinforcements(self, rng, countRef, max_slots = 0) {
24110
+ const output = [];
24111
+ const chosen = new Array(MAX_REINFORCEMENTS2).fill(255);
24112
+ let num_chosen = 0;
24113
+ let num_slots = Math.max(1, Math.floor(Math.log2(rng.frandomRange(0, INVERSE_LOG_SLOTS))));
24114
+ let remaining = (self.monsterinfo.monster_slots || 0) - (self.monsterinfo.monster_used || 0);
24115
+ for (num_chosen = 0; num_chosen < num_slots; num_chosen++) {
24116
+ if (max_slots && num_chosen === max_slots || !remaining) {
24117
+ break;
24118
+ }
24119
+ M_PickValidReinforcements(self, remaining, output);
24120
+ if (output.length === 0) {
24121
+ break;
24122
+ }
24123
+ const randIndex = rng.irandomRange(0, output.length);
24124
+ chosen[num_chosen] = output[randIndex];
24125
+ remaining -= self.monsterinfo.reinforcements[chosen[num_chosen]].strength;
24126
+ }
24127
+ return { chosen, count: num_chosen };
24128
+ }
24129
+
24027
24130
  // src/entities/monsters/rogue/widow.ts
24028
24131
  var MODEL_SCALE3 = 1;
24029
24132
  var RANGE_MELEE3 = 100;
@@ -24135,6 +24238,43 @@ function widow_kick(self, context) {
24135
24238
  }
24136
24239
  function widow_spawn_check(self, context) {
24137
24240
  if (M_SlotsLeft(self) > 0) {
24241
+ const result = M_PickReinforcements(self, context.rng, 1);
24242
+ self.monsterinfo.chosen_reinforcements = result.chosen;
24243
+ if (result.count > 0) {
24244
+ const reinforcement = self.monsterinfo.reinforcements[self.monsterinfo.chosen_reinforcements[0]];
24245
+ WidowSpawn(self, context);
24246
+ }
24247
+ }
24248
+ }
24249
+ function WidowSpawn(self, context) {
24250
+ const { forward, right } = angleVectors(self.angles);
24251
+ const offset = { x: 50, y: 0, z: 0 };
24252
+ const start = M_ProjectFlashSource(self, offset, forward, right);
24253
+ if (!self.monsterinfo.chosen_reinforcements) {
24254
+ const result = M_PickReinforcements(self, context.rng, 1);
24255
+ self.monsterinfo.chosen_reinforcements = result.chosen;
24256
+ }
24257
+ if (self.monsterinfo.chosen_reinforcements && self.monsterinfo.chosen_reinforcements[0] !== 255) {
24258
+ const rIndex = self.monsterinfo.chosen_reinforcements[0];
24259
+ const reinforcement = self.monsterinfo.reinforcements[rIndex];
24260
+ const ent = context.spawn();
24261
+ ent.origin = { ...start };
24262
+ ent.angles = { ...self.angles };
24263
+ if (reinforcement.classname === "monster_stalker") {
24264
+ SP_monster_stalker(ent, { entities: context });
24265
+ } else if (reinforcement.classname === "monster_flyer") {
24266
+ SP_monster_flyer(ent, { entities: context });
24267
+ } else {
24268
+ createMonsterSpawn({
24269
+ model: "models/monsters/stalker/tris.md2",
24270
+ health: 100,
24271
+ mass: 100
24272
+ })(ent, { entities: context });
24273
+ }
24274
+ if (ent.inUse) {
24275
+ if (!self.monsterinfo.monster_used) self.monsterinfo.monster_used = 0;
24276
+ self.monsterinfo.monster_used += reinforcement.strength;
24277
+ }
24138
24278
  }
24139
24279
  }
24140
24280
  var widow_frames_stand = Array(20).fill({ ai: widow_ai_stand, dist: 0 });