quake2ts 0.0.262 → 0.0.266

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.
Files changed (51) hide show
  1. package/package.json +1 -1
  2. package/packages/client/dist/browser/index.global.js +13 -13
  3. package/packages/client/dist/browser/index.global.js.map +1 -1
  4. package/packages/client/dist/cjs/index.cjs +25 -12
  5. package/packages/client/dist/cjs/index.cjs.map +1 -1
  6. package/packages/client/dist/esm/index.js +25 -12
  7. package/packages/client/dist/esm/index.js.map +1 -1
  8. package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
  9. package/packages/engine/dist/browser/index.global.js +6 -6
  10. package/packages/engine/dist/browser/index.global.js.map +1 -1
  11. package/packages/engine/dist/cjs/index.cjs +25 -12
  12. package/packages/engine/dist/cjs/index.cjs.map +1 -1
  13. package/packages/engine/dist/esm/index.js +25 -12
  14. package/packages/engine/dist/esm/index.js.map +1 -1
  15. package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
  16. package/packages/engine/dist/types/demo/parser.d.ts +2 -0
  17. package/packages/engine/dist/types/demo/parser.d.ts.map +1 -1
  18. package/packages/engine/dist/types/demo/playback.d.ts +1 -0
  19. package/packages/engine/dist/types/demo/playback.d.ts.map +1 -1
  20. package/packages/game/dist/browser/index.global.js +3 -2
  21. package/packages/game/dist/browser/index.global.js.map +1 -1
  22. package/packages/game/dist/cjs/index.cjs +998 -291
  23. package/packages/game/dist/cjs/index.cjs.map +1 -1
  24. package/packages/game/dist/esm/index.js +999 -292
  25. package/packages/game/dist/esm/index.js.map +1 -1
  26. package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
  27. package/packages/game/dist/types/combat/weapons/animation.d.ts +9 -0
  28. package/packages/game/dist/types/combat/weapons/animation.d.ts.map +1 -1
  29. package/packages/game/dist/types/combat/weapons/firing.d.ts.map +1 -1
  30. package/packages/game/dist/types/combat/weapons/switching.d.ts +1 -0
  31. package/packages/game/dist/types/combat/weapons/switching.d.ts.map +1 -1
  32. package/packages/game/dist/types/entities/entity.d.ts +2 -1
  33. package/packages/game/dist/types/entities/entity.d.ts.map +1 -1
  34. package/packages/game/dist/types/entities/monsters/actor.d.ts +6 -0
  35. package/packages/game/dist/types/entities/monsters/actor.d.ts.map +1 -0
  36. package/packages/game/dist/types/entities/monsters/index.d.ts.map +1 -1
  37. package/packages/game/dist/types/entities/monsters/jorg.d.ts.map +1 -1
  38. package/packages/game/dist/types/entities/monsters/makron.d.ts.map +1 -1
  39. package/packages/game/dist/types/entities/player.d.ts +2 -0
  40. package/packages/game/dist/types/entities/player.d.ts.map +1 -1
  41. package/packages/game/dist/types/entities/player_anim.d.ts +50 -0
  42. package/packages/game/dist/types/entities/player_anim.d.ts.map +1 -0
  43. package/packages/game/dist/types/index.d.ts.map +1 -1
  44. package/packages/shared/dist/browser/index.global.js +1 -1
  45. package/packages/shared/dist/browser/index.global.js.map +1 -1
  46. package/packages/shared/dist/cjs/index.cjs +12 -5
  47. package/packages/shared/dist/cjs/index.cjs.map +1 -1
  48. package/packages/shared/dist/esm/index.js +12 -5
  49. package/packages/shared/dist/esm/index.js.map +1 -1
  50. package/packages/shared/dist/tsconfig.tsbuildinfo +1 -1
  51. package/packages/shared/dist/types/pmove/apply.d.ts.map +1 -1
@@ -294,15 +294,15 @@ function rotatePointAroundVector(dir, point, degrees) {
294
294
  const vf = normalizeVec3(dir);
295
295
  const vr = perpendicularVec3(vf);
296
296
  const vup = crossVec3(vr, vf);
297
- const m2 = [
297
+ const m3 = [
298
298
  [vr.x, vup.x, vf.x],
299
299
  [vr.y, vup.y, vf.y],
300
300
  [vr.z, vup.z, vf.z]
301
301
  ];
302
302
  const im = [
303
- [m2[0][0], m2[1][0], m2[2][0]],
304
- [m2[0][1], m2[1][1], m2[2][1]],
305
- [m2[0][2], m2[1][2], m2[2][2]]
303
+ [m3[0][0], m3[1][0], m3[2][0]],
304
+ [m3[0][1], m3[1][1], m3[2][1]],
305
+ [m3[0][2], m3[1][2], m3[2][2]]
306
306
  ];
307
307
  const radians = degrees * DEG_TO_RAD;
308
308
  const cos = Math.cos(radians);
@@ -312,7 +312,7 @@ function rotatePointAroundVector(dir, point, degrees) {
312
312
  [-sin, cos, 0],
313
313
  [0, 0, 1]
314
314
  ];
315
- const rot = concatRotationMatrices(concatRotationMatrices(m2, zrot), im);
315
+ const rot = concatRotationMatrices(concatRotationMatrices(m3, zrot), im);
316
316
  return {
317
317
  x: rot[0][0] * point.x + rot[0][1] * point.y + rot[0][2] * point.z,
318
318
  y: rot[1][0] * point.x + rot[1][1] * point.y + rot[1][2] * point.z,
@@ -1175,7 +1175,14 @@ var applyPmove = (state, cmd, trace, pointContents2) => {
1175
1175
  let newState = { ...state };
1176
1176
  newState = categorizePosition2(newState, trace);
1177
1177
  newState = checkWater(newState, pointContents2);
1178
- const { origin, velocity, onGround, waterLevel } = newState;
1178
+ const { origin, velocity, onGround, waterLevel, viewAngles } = newState;
1179
+ const adjustedAngles = waterLevel >= 2 ? viewAngles : {
1180
+ // For ground/air movement, reduce pitch influence (rerelease/p_move.cpp:1689)
1181
+ x: viewAngles.x > 180 ? (viewAngles.x - 360) / 3 : viewAngles.x / 3,
1182
+ y: viewAngles.y,
1183
+ z: viewAngles.z
1184
+ };
1185
+ const { forward, right } = angleVectors(adjustedAngles);
1179
1186
  const frictionedVelocity = applyPmoveFriction({
1180
1187
  velocity,
1181
1188
  frametime: FRAMETIME,
@@ -1188,13 +1195,13 @@ var applyPmove = (state, cmd, trace, pointContents2) => {
1188
1195
  pmWaterFriction: 1
1189
1196
  });
1190
1197
  const wish = waterLevel >= 2 ? buildWaterWish({
1191
- forward: { x: 1, y: 0, z: 0 },
1192
- right: { x: 0, y: 1, z: 0 },
1198
+ forward,
1199
+ right,
1193
1200
  cmd,
1194
1201
  maxSpeed: 320
1195
1202
  }) : buildAirGroundWish({
1196
- forward: { x: 1, y: 0, z: 0 },
1197
- right: { x: 0, y: 1, z: 0 },
1203
+ forward,
1204
+ right,
1198
1205
  cmd,
1199
1206
  maxSpeed: 320
1200
1207
  });
@@ -10094,11 +10101,11 @@ function registerInfantrySpawns(registry) {
10094
10101
  registry.register("monster_infantry", SP_monster_infantry);
10095
10102
  }
10096
10103
 
10097
- // src/entities/monsters/jorg.ts
10104
+ // src/entities/monsters/makron.ts
10098
10105
  var MONSTER_TICK13 = 0.1;
10099
- var JORG_MACHINEGUN_R1_OFFSET = { x: 40, y: -20, z: 20 };
10100
- var JORG_MACHINEGUN_L1_OFFSET = { x: 40, y: 20, z: 20 };
10101
- var JORG_BFG_OFFSET = { x: 30, y: 0, z: 40 };
10106
+ var MAKRON_BFG_OFFSET = { x: 30, y: 28, z: 24 };
10107
+ var MAKRON_BLASTER_OFFSET_1 = { x: 26, y: 16, z: 24 };
10108
+ var MAKRON_RAILGUN_OFFSET = { x: 26, y: -14, z: 24 };
10102
10109
  function monster_ai_stand13(self, dist, context) {
10103
10110
  ai_stand(self, MONSTER_TICK13, context);
10104
10111
  }
@@ -10117,24 +10124,269 @@ function monster_ai_move13(self, dist, context) {
10117
10124
  var stand_move12;
10118
10125
  var walk_move11;
10119
10126
  var run_move11;
10127
+ var attack_bfg_move;
10128
+ var attack_hyperblaster_move;
10129
+ var attack_railgun_move;
10130
+ var pain4_move;
10131
+ var pain5_move;
10132
+ var pain6_move;
10133
+ var death_move10;
10134
+ var sight_move;
10135
+ function makron_stand(self) {
10136
+ self.monsterinfo.current_move = stand_move12;
10137
+ }
10138
+ function makron_walk(self) {
10139
+ self.monsterinfo.current_move = walk_move11;
10140
+ }
10141
+ function makron_run(self) {
10142
+ if (self.enemy && self.enemy.health > 0) {
10143
+ self.monsterinfo.current_move = run_move11;
10144
+ } else {
10145
+ self.monsterinfo.current_move = stand_move12;
10146
+ }
10147
+ }
10148
+ function makron_attack(self) {
10149
+ if (!self.enemy) return;
10150
+ const r = Math.random();
10151
+ if (r <= 0.3) {
10152
+ self.monsterinfo.current_move = attack_bfg_move;
10153
+ } else if (r <= 0.6) {
10154
+ self.monsterinfo.current_move = attack_hyperblaster_move;
10155
+ } else {
10156
+ self.monsterinfo.current_move = attack_railgun_move;
10157
+ }
10158
+ }
10159
+ function getProjectedOffset2(self, offset) {
10160
+ const { forward, right, up } = angleVectors(self.angles);
10161
+ const start = { ...self.origin };
10162
+ const x = scaleVec3(forward, offset.x);
10163
+ const y = scaleVec3(right, offset.y);
10164
+ const z = scaleVec3(up, offset.z);
10165
+ return addVec3(addVec3(addVec3(start, x), y), z);
10166
+ }
10167
+ function makron_fire_bfg(self, context) {
10168
+ if (!self.enemy) return;
10169
+ context.engine.sound?.(self, 0, "makron/bfg_fire.wav", 1, 1, 0);
10170
+ const start = getProjectedOffset2(self, MAKRON_BFG_OFFSET);
10171
+ const target = { ...self.enemy.origin };
10172
+ target.z += self.enemy.viewheight || 0;
10173
+ const dir = normalizeVec3(subtractVec3(target, start));
10174
+ monster_fire_bfg(self, start, dir, 50, 300, 100, 300, 0, context);
10175
+ }
10176
+ function makron_fire_railgun(self, context) {
10177
+ if (!self.pos1) return;
10178
+ context.engine.sound?.(self, 0, "makron/rail_fire.wav", 1, 1, 0);
10179
+ const start = getProjectedOffset2(self, MAKRON_RAILGUN_OFFSET);
10180
+ const dir = normalizeVec3(subtractVec3(self.pos1, start));
10181
+ monster_fire_railgun(self, start, dir, 50, 100, 0, context);
10182
+ }
10183
+ function makron_save_loc(self) {
10184
+ if (!self.enemy) return;
10185
+ self.pos1 = { ...self.enemy.origin };
10186
+ self.pos1 = { ...self.pos1, z: self.pos1.z + (self.enemy.viewheight || 0) };
10187
+ }
10188
+ function makron_fire_hyperblaster(self, context) {
10189
+ context.engine.sound?.(self, 0, "makron/blaster.wav", 1, 1, 0);
10190
+ const start = getProjectedOffset2(self, MAKRON_BLASTER_OFFSET_1);
10191
+ const relFrame = (self.monsterinfo.nextframe || 0) - attack_hyperblaster_move.firstframe;
10192
+ let yawDelta = 0;
10193
+ let dir;
10194
+ if (self.enemy) {
10195
+ const target = { ...self.enemy.origin };
10196
+ target.z += self.enemy.viewheight || 0;
10197
+ const vec = subtractVec3(target, start);
10198
+ const baseAngles = vectorToAngles(vec);
10199
+ const enemyAngles = { ...baseAngles };
10200
+ if (relFrame <= 12) {
10201
+ enemyAngles.y -= 5 * (relFrame - 4);
10202
+ } else {
10203
+ enemyAngles.y -= 40 - 5 * (relFrame - 12);
10204
+ }
10205
+ const forward = angleVectors(enemyAngles).forward;
10206
+ dir = forward;
10207
+ } else {
10208
+ const { forward } = angleVectors(self.angles);
10209
+ dir = forward;
10210
+ }
10211
+ monster_fire_blaster(self, start, dir, 15, 1e3, 0, 0, context, 1 /* BLASTER */);
10212
+ }
10213
+ function makron_pain(self, other, kick, damage, context) {
10214
+ if (self.health < self.max_health / 2) {
10215
+ self.skin = 1;
10216
+ }
10217
+ if (self.timestamp < (self.pain_finished_time || 0)) return;
10218
+ if (damage <= 25 && Math.random() < 0.2) return;
10219
+ self.pain_finished_time = self.timestamp + 3;
10220
+ if (damage <= 40) {
10221
+ context.engine.sound?.(self, 0, "makron/pain1.wav", 1, 1, 0);
10222
+ self.monsterinfo.current_move = pain4_move;
10223
+ } else if (damage <= 110) {
10224
+ context.engine.sound?.(self, 0, "makron/pain2.wav", 1, 1, 0);
10225
+ self.monsterinfo.current_move = pain5_move;
10226
+ } else {
10227
+ if (Math.random() <= 0.45) {
10228
+ context.engine.sound?.(self, 0, "makron/pain3.wav", 1, 1, 0);
10229
+ self.monsterinfo.current_move = pain6_move;
10230
+ }
10231
+ }
10232
+ }
10233
+ function makron_torso_think(self, context) {
10234
+ if (++self.frame >= 365)
10235
+ self.frame = 346;
10236
+ self.nextthink = context.timeSeconds + 0.1;
10237
+ if (self.angles.x > 0)
10238
+ self.angles = { ...self.angles, x: Math.max(0, self.angles.x - 15) };
10239
+ }
10240
+ function makron_torso(ent, context) {
10241
+ ent.frame = 346;
10242
+ ent.model = "models/monsters/boss3/rider/tris.md2";
10243
+ ent.skin = 1;
10244
+ ent.think = makron_torso_think;
10245
+ ent.nextthink = context.timeSeconds + 0.1;
10246
+ context.sound(ent, 0, "makron/spine.wav", 1, 1, 0);
10247
+ ent.movetype = 7 /* Toss */;
10248
+ const { forward, up } = angleVectors(ent.angles);
10249
+ const vUp = scaleVec3(up, 120);
10250
+ const vFwd = scaleVec3(forward, -120);
10251
+ ent.velocity = addVec3(addVec3(ent.velocity, vUp), vFwd);
10252
+ ent.origin = addVec3(ent.origin, scaleVec3(forward, -10));
10253
+ ent.angles = { ...ent.angles, x: 90 };
10254
+ ent.avelocity = ZERO_VEC3;
10255
+ context.linkentity(ent);
10256
+ }
10257
+ function makron_spawn_torso(self, context) {
10258
+ const tempent = context.spawn();
10259
+ tempent.classname = "makron_torso";
10260
+ tempent.origin = { ...self.origin };
10261
+ tempent.angles = { ...self.angles };
10262
+ tempent.origin.z += self.maxs.z - 15;
10263
+ makron_torso(tempent, context);
10264
+ }
10265
+ function makron_die(self, context) {
10266
+ context.engine.sound?.(self, 0, "makron/death.wav", 1, 1, 0);
10267
+ makron_spawn_torso(self, context);
10268
+ self.monsterinfo.current_move = death_move10;
10269
+ self.mins = { x: -60, y: -60, z: 0 };
10270
+ self.maxs = { x: 60, y: 60, z: 48 };
10271
+ }
10272
+ function makron_dead(self) {
10273
+ self.monsterinfo.nextframe = death_move10.lastframe;
10274
+ self.nextthink = -1;
10275
+ }
10276
+ var stand_frames12 = Array.from({ length: 60 }, () => ({ ai: monster_ai_stand13, dist: 0 }));
10277
+ stand_move12 = { firstframe: 0, lastframe: 59, frames: stand_frames12, endfunc: makron_stand };
10278
+ var walk_frames11 = Array.from({ length: 10 }, () => ({ ai: monster_ai_walk13, dist: 8 }));
10279
+ walk_move11 = { firstframe: 60, lastframe: 69, frames: walk_frames11, endfunc: makron_walk };
10280
+ var run_frames10 = Array.from({ length: 10 }, () => ({ ai: monster_ai_run12, dist: 8 }));
10281
+ run_move11 = { firstframe: 60, lastframe: 69, frames: run_frames10, endfunc: makron_run };
10282
+ var attack_bfg_frames = Array.from({ length: 8 }, (_, i) => ({
10283
+ ai: monster_ai_charge13,
10284
+ dist: 0,
10285
+ think: i === 3 ? makron_fire_bfg : null
10286
+ }));
10287
+ attack_bfg_move = { firstframe: 70, lastframe: 77, frames: attack_bfg_frames, endfunc: makron_run };
10288
+ var attack_hyperblaster_frames = Array.from({ length: 26 }, (_, i) => ({
10289
+ ai: monster_ai_move13,
10290
+ dist: 0,
10291
+ think: i >= 4 && i <= 20 ? makron_fire_hyperblaster : null
10292
+ }));
10293
+ attack_hyperblaster_move = { firstframe: 78, lastframe: 103, frames: attack_hyperblaster_frames, endfunc: makron_run };
10294
+ var attack_railgun_frames = Array.from({ length: 16 }, (_, i) => ({
10295
+ ai: monster_ai_charge13,
10296
+ dist: 0,
10297
+ think: i === 7 ? makron_save_loc : i === 8 ? makron_fire_railgun : null
10298
+ }));
10299
+ attack_railgun_move = { firstframe: 104, lastframe: 119, frames: attack_railgun_frames, endfunc: makron_run };
10300
+ var pain4_frames = Array.from({ length: 4 }, () => ({ ai: monster_ai_move13, dist: 0 }));
10301
+ pain4_move = { firstframe: 120, lastframe: 123, frames: pain4_frames, endfunc: makron_run };
10302
+ var pain5_frames = Array.from({ length: 4 }, () => ({ ai: monster_ai_move13, dist: 0 }));
10303
+ pain5_move = { firstframe: 124, lastframe: 127, frames: pain5_frames, endfunc: makron_run };
10304
+ var pain6_frames = Array.from({ length: 27 }, () => ({ ai: monster_ai_move13, dist: 0 }));
10305
+ pain6_move = { firstframe: 128, lastframe: 154, frames: pain6_frames, endfunc: makron_run };
10306
+ var death_frames10 = Array.from({ length: 95 }, () => ({ ai: monster_ai_move13, dist: 0 }));
10307
+ death_move10 = { firstframe: 155, lastframe: 249, frames: death_frames10, endfunc: makron_dead };
10308
+ var sight_frames = Array.from({ length: 13 }, () => ({ ai: monster_ai_move13, dist: 0 }));
10309
+ sight_move = { firstframe: 250, lastframe: 262, frames: sight_frames, endfunc: makron_run };
10310
+ function SP_monster_makron(self, context) {
10311
+ self.classname = "monster_makron";
10312
+ self.model = "models/monsters/boss3/rider/tris.md2";
10313
+ self.mins = { x: -30, y: -30, z: 0 };
10314
+ self.maxs = { x: 30, y: 30, z: 90 };
10315
+ self.movetype = 5 /* Step */;
10316
+ self.solid = 2 /* BoundingBox */;
10317
+ self.health = 3e3;
10318
+ self.max_health = 3e3;
10319
+ self.mass = 500;
10320
+ self.takedamage = true;
10321
+ self.viewheight = 90;
10322
+ self.pain = (ent, other, kick, dmg) => makron_pain(ent, other, kick, dmg, context.entities);
10323
+ self.die = (self2, inflictor, attacker, damage, point) => {
10324
+ if (self2.health <= -2e3) {
10325
+ throwGibs(context.entities, self2.origin, damage);
10326
+ context.entities.free(self2);
10327
+ return;
10328
+ }
10329
+ self2.deadflag = 2 /* Dead */;
10330
+ self2.solid = 0 /* Not */;
10331
+ makron_die(self2, context.entities);
10332
+ };
10333
+ self.monsterinfo.stand = makron_stand;
10334
+ self.monsterinfo.walk = makron_walk;
10335
+ self.monsterinfo.run = makron_run;
10336
+ self.monsterinfo.attack = makron_attack;
10337
+ self.monsterinfo.sight = (self2, other) => {
10338
+ context.entities.sound?.(self2, 0, "makron/sight.wav", 1, 1, 0);
10339
+ self2.monsterinfo.current_move = sight_move;
10340
+ };
10341
+ self.think = monster_think;
10342
+ self.monsterinfo.current_move = sight_move;
10343
+ self.nextthink = self.timestamp + MONSTER_TICK13;
10344
+ }
10345
+ function registerMakronSpawns(registry) {
10346
+ registry.register("monster_makron", SP_monster_makron);
10347
+ }
10348
+
10349
+ // src/entities/monsters/jorg.ts
10350
+ var MONSTER_TICK14 = 0.1;
10351
+ var JORG_MACHINEGUN_R1_OFFSET = { x: 40, y: -20, z: 20 };
10352
+ var JORG_MACHINEGUN_L1_OFFSET = { x: 40, y: 20, z: 20 };
10353
+ var JORG_BFG_OFFSET = { x: 30, y: 0, z: 40 };
10354
+ function monster_ai_stand14(self, dist, context) {
10355
+ ai_stand(self, MONSTER_TICK14, context);
10356
+ }
10357
+ function monster_ai_walk14(self, dist, context) {
10358
+ ai_walk(self, dist, MONSTER_TICK14, context);
10359
+ }
10360
+ function monster_ai_run13(self, dist, context) {
10361
+ ai_run(self, dist, MONSTER_TICK14, context);
10362
+ }
10363
+ function monster_ai_charge14(self, dist, context) {
10364
+ ai_charge(self, dist, MONSTER_TICK14, context);
10365
+ }
10366
+ function monster_ai_move14(self, dist, context) {
10367
+ ai_move(self, dist);
10368
+ }
10369
+ var stand_move13;
10370
+ var walk_move12;
10371
+ var run_move12;
10120
10372
  var attack1_move3;
10121
10373
  var attack1_end_move;
10122
10374
  var attack2_move2;
10123
10375
  var pain1_move5;
10124
10376
  var pain2_move5;
10125
10377
  var pain3_move4;
10126
- var death_move10;
10378
+ var death_move11;
10127
10379
  function jorg_stand(self) {
10128
- self.monsterinfo.current_move = stand_move12;
10380
+ self.monsterinfo.current_move = stand_move13;
10129
10381
  }
10130
10382
  function jorg_walk(self) {
10131
- self.monsterinfo.current_move = walk_move11;
10383
+ self.monsterinfo.current_move = walk_move12;
10132
10384
  }
10133
10385
  function jorg_run(self) {
10134
10386
  if (self.enemy && self.enemy.health > 0) {
10135
- self.monsterinfo.current_move = run_move11;
10387
+ self.monsterinfo.current_move = run_move12;
10136
10388
  } else {
10137
- self.monsterinfo.current_move = stand_move12;
10389
+ self.monsterinfo.current_move = stand_move13;
10138
10390
  }
10139
10391
  }
10140
10392
  function jorg_attack(self, context) {
@@ -10162,7 +10414,7 @@ function jorg_reattack1(self, context) {
10162
10414
  self.monsterinfo.current_move = attack1_end_move;
10163
10415
  }
10164
10416
  }
10165
- function getProjectedOffset2(self, offset) {
10417
+ function getProjectedOffset3(self, offset) {
10166
10418
  const { forward, right, up } = angleVectors(self.angles);
10167
10419
  const start = { ...self.origin };
10168
10420
  const x = scaleVec3(forward, offset.x);
@@ -10172,16 +10424,16 @@ function getProjectedOffset2(self, offset) {
10172
10424
  }
10173
10425
  function jorg_fire_bullet(self, context) {
10174
10426
  if (!self.enemy) return;
10175
- const startL = getProjectedOffset2(self, JORG_MACHINEGUN_L1_OFFSET);
10427
+ const startL = getProjectedOffset3(self, JORG_MACHINEGUN_L1_OFFSET);
10176
10428
  const dirL = normalizeVec3(subtractVec3(self.enemy.origin, startL));
10177
10429
  monster_fire_bullet_v2(self, startL, dirL, 6, 4, 0.05, 0.05, 0, context, 4 /* MACHINEGUN */);
10178
- const startR = getProjectedOffset2(self, JORG_MACHINEGUN_R1_OFFSET);
10430
+ const startR = getProjectedOffset3(self, JORG_MACHINEGUN_R1_OFFSET);
10179
10431
  const dirR = normalizeVec3(subtractVec3(self.enemy.origin, startR));
10180
10432
  monster_fire_bullet_v2(self, startR, dirR, 6, 4, 0.05, 0.05, 0, context, 4 /* MACHINEGUN */);
10181
10433
  }
10182
10434
  function jorg_fire_bfg(self, context) {
10183
10435
  if (!self.enemy) return;
10184
- const start = getProjectedOffset2(self, JORG_BFG_OFFSET);
10436
+ const start = getProjectedOffset3(self, JORG_BFG_OFFSET);
10185
10437
  const target = { ...self.enemy.origin };
10186
10438
  target.z += self.enemy.viewheight || 0;
10187
10439
  const dir = normalizeVec3(subtractVec3(target, start));
@@ -10212,52 +10464,66 @@ function jorg_pain(self, other, kick, damage, context) {
10212
10464
  }
10213
10465
  function jorg_die(self, context) {
10214
10466
  context.engine.sound?.(self, 0, "boss3/bs3deth1.wav", 1, 1, 0);
10215
- self.monsterinfo.current_move = death_move10;
10467
+ self.monsterinfo.current_move = death_move11;
10216
10468
  }
10217
10469
  function jorg_dead(self) {
10218
- self.monsterinfo.nextframe = death_move10.lastframe;
10470
+ self.monsterinfo.nextframe = death_move11.lastframe;
10219
10471
  self.nextthink = -1;
10220
10472
  }
10221
10473
  function makron_toss(self, context) {
10222
10474
  const makron = context.spawn();
10223
10475
  makron.classname = "monster_makron";
10224
10476
  makron.origin = { ...self.origin };
10225
- makron.angles = { ...self.angles };
10226
- }
10227
- var stand_frames12 = Array.from({ length: 51 }, () => ({ ai: monster_ai_stand13, dist: 0 }));
10228
- stand_move12 = { firstframe: 0, lastframe: 50, frames: stand_frames12, endfunc: jorg_stand };
10229
- var walk_frames11 = Array.from({ length: 14 }, () => ({ ai: monster_ai_walk13, dist: 10 }));
10230
- walk_move11 = { firstframe: 51, lastframe: 64, frames: walk_frames11, endfunc: jorg_walk };
10231
- var run_frames10 = Array.from({ length: 14 }, () => ({ ai: monster_ai_run12, dist: 10 }));
10232
- run_move11 = { firstframe: 51, lastframe: 64, frames: run_frames10, endfunc: jorg_run };
10233
- var attack1_start_frames = Array.from({ length: 8 }, () => ({ ai: monster_ai_charge13, dist: 0 }));
10477
+ makron.target = self.target;
10478
+ makron.enemy = self.enemy;
10479
+ const spawnContext = { entities: context };
10480
+ SP_monster_makron(makron, spawnContext);
10481
+ if (makron.enemy && makron.enemy.health > 0) {
10482
+ const vec = subtractVec3(makron.enemy.origin, makron.origin);
10483
+ makron.angles = { ...makron.angles, y: vectorToYaw(vec) };
10484
+ const dir = normalizeVec3(vec);
10485
+ const vel = scaleVec3(dir, 400);
10486
+ makron.velocity = { x: vel.x, y: vel.y, z: 200 };
10487
+ makron.groundentity = null;
10488
+ if (makron.monsterinfo.sight) {
10489
+ makron.monsterinfo.sight(makron, makron.enemy);
10490
+ }
10491
+ }
10492
+ }
10493
+ var stand_frames13 = Array.from({ length: 51 }, () => ({ ai: monster_ai_stand14, dist: 0 }));
10494
+ stand_move13 = { firstframe: 0, lastframe: 50, frames: stand_frames13, endfunc: jorg_stand };
10495
+ var walk_frames12 = Array.from({ length: 14 }, () => ({ ai: monster_ai_walk14, dist: 10 }));
10496
+ walk_move12 = { firstframe: 51, lastframe: 64, frames: walk_frames12, endfunc: jorg_walk };
10497
+ var run_frames11 = Array.from({ length: 14 }, () => ({ ai: monster_ai_run13, dist: 10 }));
10498
+ run_move12 = { firstframe: 51, lastframe: 64, frames: run_frames11, endfunc: jorg_run };
10499
+ var attack1_start_frames = Array.from({ length: 8 }, () => ({ ai: monster_ai_charge14, dist: 0 }));
10234
10500
  var attack1_start_move = { firstframe: 65, lastframe: 72, frames: attack1_start_frames, endfunc: null };
10235
- var attack1_frames3 = Array.from({ length: 6 }, () => ({ ai: monster_ai_charge13, dist: 0, think: jorg_fire_bullet }));
10501
+ var attack1_frames3 = Array.from({ length: 6 }, () => ({ ai: monster_ai_charge14, dist: 0, think: jorg_fire_bullet }));
10236
10502
  attack1_move3 = { firstframe: 73, lastframe: 78, frames: attack1_frames3, endfunc: jorg_reattack1 };
10237
10503
  attack1_start_move.endfunc = (self) => {
10238
10504
  self.monsterinfo.current_move = attack1_move3;
10239
10505
  };
10240
- var attack1_end_frames = Array.from({ length: 4 }, () => ({ ai: monster_ai_move13, dist: 0 }));
10506
+ var attack1_end_frames = Array.from({ length: 4 }, () => ({ ai: monster_ai_move14, dist: 0 }));
10241
10507
  attack1_end_move = { firstframe: 79, lastframe: 82, frames: attack1_end_frames, endfunc: jorg_run };
10242
10508
  var attack2_frames2 = Array.from({ length: 13 }, (_, i) => ({
10243
- ai: monster_ai_charge13,
10509
+ ai: monster_ai_charge14,
10244
10510
  dist: 0,
10245
10511
  think: i === 6 ? jorg_fire_bfg : null
10246
10512
  }));
10247
10513
  attack2_move2 = { firstframe: 83, lastframe: 95, frames: attack2_frames2, endfunc: jorg_run };
10248
- var pain1_frames5 = Array.from({ length: 3 }, () => ({ ai: monster_ai_move13, dist: 0 }));
10514
+ var pain1_frames5 = Array.from({ length: 3 }, () => ({ ai: monster_ai_move14, dist: 0 }));
10249
10515
  pain1_move5 = { firstframe: 96, lastframe: 98, frames: pain1_frames5, endfunc: jorg_run };
10250
- var pain2_frames5 = Array.from({ length: 3 }, () => ({ ai: monster_ai_move13, dist: 0 }));
10516
+ var pain2_frames5 = Array.from({ length: 3 }, () => ({ ai: monster_ai_move14, dist: 0 }));
10251
10517
  pain2_move5 = { firstframe: 99, lastframe: 101, frames: pain2_frames5, endfunc: jorg_run };
10252
- var pain3_frames4 = Array.from({ length: 25 }, () => ({ ai: monster_ai_move13, dist: 0 }));
10518
+ var pain3_frames4 = Array.from({ length: 25 }, () => ({ ai: monster_ai_move14, dist: 0 }));
10253
10519
  pain3_move4 = { firstframe: 102, lastframe: 126, frames: pain3_frames4, endfunc: jorg_run };
10254
- var death_frames10 = Array.from({ length: 50 }, (_, i) => ({
10255
- ai: monster_ai_move13,
10520
+ var death_frames11 = Array.from({ length: 50 }, (_, i) => ({
10521
+ ai: monster_ai_move14,
10256
10522
  dist: 0,
10257
10523
  think: i === 49 ? ((self, ctx) => {
10258
10524
  }) : i === 48 ? makron_toss : null
10259
10525
  }));
10260
- death_move10 = { firstframe: 127, lastframe: 176, frames: death_frames10, endfunc: jorg_dead };
10526
+ death_move11 = { firstframe: 127, lastframe: 176, frames: death_frames11, endfunc: jorg_dead };
10261
10527
  function SP_monster_jorg(self, context) {
10262
10528
  self.classname = "monster_jorg";
10263
10529
  self.model = "models/monsters/boss3/jorg/tris.md2";
@@ -10290,14 +10556,14 @@ function SP_monster_jorg(self, context) {
10290
10556
  };
10291
10557
  self.think = monster_think;
10292
10558
  jorg_stand(self);
10293
- self.nextthink = self.timestamp + MONSTER_TICK13;
10559
+ self.nextthink = self.timestamp + MONSTER_TICK14;
10294
10560
  }
10295
10561
  function registerJorgSpawns(registry) {
10296
10562
  registry.register("monster_jorg", SP_monster_jorg);
10297
10563
  }
10298
10564
 
10299
10565
  // src/entities/monsters/insane.ts
10300
- var MONSTER_TICK14 = 0.1;
10566
+ var MONSTER_TICK15 = 0.1;
10301
10567
  var SPAWNFLAG_INSANE_CRAWL = 4;
10302
10568
  var SPAWNFLAG_INSANE_CRUCIFIED = 8;
10303
10569
  var SPAWNFLAG_INSANE_STAND_GROUND = 16;
@@ -10467,7 +10733,7 @@ function insane_dead(self, context) {
10467
10733
  function m(ai, dist = 0, think) {
10468
10734
  return { ai: (s, d, c) => {
10469
10735
  if (think) think(s, c);
10470
- ai(s, dist, MONSTER_TICK14, c);
10736
+ ai(s, dist, MONSTER_TICK15, c);
10471
10737
  }, dist };
10472
10738
  }
10473
10739
  var frames_stand_normal = [
@@ -10706,7 +10972,7 @@ insane_move_run_normal = {
10706
10972
  frames: frames_walk_normal.map((f) => ({
10707
10973
  ai: (s, d, c) => {
10708
10974
  if (f.ai === frames_walk_normal[0].ai) insane_scream(s, c);
10709
- ai_run(s, d, MONSTER_TICK14, c);
10975
+ ai_run(s, d, MONSTER_TICK15, c);
10710
10976
  },
10711
10977
  dist: f.dist
10712
10978
  })),
@@ -10752,7 +11018,7 @@ insane_move_run_insane = {
10752
11018
  frames: frames_walk_insane.map((f) => ({
10753
11019
  ai: (s, d, c) => {
10754
11020
  if (f.ai === frames_walk_insane[0].ai) insane_scream(s, c);
10755
- ai_run(s, d, MONSTER_TICK14, c);
11021
+ ai_run(s, d, MONSTER_TICK15, c);
10756
11022
  },
10757
11023
  dist: f.dist
10758
11024
  })),
@@ -10979,7 +11245,7 @@ function SP_misc_insane(self, context) {
10979
11245
  self.monsterinfo.current_move = insane_move_stand_normal;
10980
11246
  self.monsterinfo.scale = 1;
10981
11247
  self.think = monster_think;
10982
- self.nextthink = context.entities.timeSeconds + MONSTER_TICK14;
11248
+ self.nextthink = context.entities.timeSeconds + MONSTER_TICK15;
10983
11249
  if (self.spawnflags & SPAWNFLAG_INSANE_CRUCIFIED) {
10984
11250
  self.mass = 1e5;
10985
11251
  }
@@ -10989,218 +11255,548 @@ function registerInsaneSpawns(registry) {
10989
11255
  registry.register("misc_insane", SP_misc_insane);
10990
11256
  }
10991
11257
 
10992
- // src/entities/monsters/makron.ts
10993
- var MONSTER_TICK15 = 0.1;
10994
- var MAKRON_BFG_OFFSET = { x: 30, y: 28, z: 24 };
10995
- var MAKRON_BLASTER_OFFSET_1 = { x: 26, y: 16, z: 24 };
10996
- var MAKRON_RAILGUN_OFFSET = { x: 26, y: -14, z: 24 };
10997
- function monster_ai_stand14(self, dist, context) {
10998
- ai_stand(self, MONSTER_TICK15, context);
11258
+ // src/entities/monsters/actor.ts
11259
+ var MONSTER_TICK16 = 0.1;
11260
+ var MZ2_ACTOR_MACHINEGUN_1 = 0;
11261
+ var actor_names = [
11262
+ "Hellrot",
11263
+ "Tokay",
11264
+ "Killme",
11265
+ "Disruptor",
11266
+ "Adrianator",
11267
+ "Rambear",
11268
+ "Titus",
11269
+ "Bitterman"
11270
+ ];
11271
+ var FRAME_stand101 = 0;
11272
+ var FRAME_stand140 = 39;
11273
+ var FRAME_walk01 = 40;
11274
+ var FRAME_walk08 = 47;
11275
+ var FRAME_run02 = 48;
11276
+ var FRAME_run07 = 53;
11277
+ var FRAME_pain101 = 54;
11278
+ var FRAME_pain103 = 56;
11279
+ var FRAME_pain201 = 57;
11280
+ var FRAME_pain203 = 59;
11281
+ var FRAME_pain301 = 60;
11282
+ var FRAME_pain303 = 62;
11283
+ var FRAME_flip01 = 63;
11284
+ var FRAME_flip14 = 76;
11285
+ var FRAME_taunt01 = 77;
11286
+ var FRAME_taunt17 = 93;
11287
+ var FRAME_death101 = 94;
11288
+ var FRAME_death107 = 100;
11289
+ var FRAME_death201 = 101;
11290
+ var FRAME_death213 = 113;
11291
+ var FRAME_attak01 = 114;
11292
+ var FRAME_attak04 = 117;
11293
+ var actor_move_stand;
11294
+ var actor_move_walk;
11295
+ var actor_move_run;
11296
+ var actor_move_pain1;
11297
+ var actor_move_pain2;
11298
+ var actor_move_pain3;
11299
+ var actor_move_flipoff;
11300
+ var actor_move_taunt;
11301
+ var actor_move_death1;
11302
+ var actor_move_death2;
11303
+ var actor_move_attack;
11304
+ function m2(ai, dist = 0, think) {
11305
+ return { ai: (s, d, c) => {
11306
+ if (think) think(s, c);
11307
+ ai(s, dist, MONSTER_TICK16, c);
11308
+ }, dist };
10999
11309
  }
11000
- function monster_ai_walk14(self, dist, context) {
11001
- ai_walk(self, dist, MONSTER_TICK15, context);
11310
+ function actor_stand(self, context) {
11311
+ self.monsterinfo.current_move = actor_move_stand;
11312
+ if (context.timeSeconds < 1) {
11313
+ self.frame = FRAME_stand101 + Math.floor(Math.random() * (FRAME_stand140 - FRAME_stand101 + 1));
11314
+ }
11002
11315
  }
11003
- function monster_ai_run13(self, dist, context) {
11004
- ai_run(self, dist, MONSTER_TICK15, context);
11316
+ function actor_walk(self, context) {
11317
+ self.monsterinfo.current_move = actor_move_walk;
11005
11318
  }
11006
- function monster_ai_charge14(self, dist, context) {
11007
- ai_charge(self, dist, MONSTER_TICK15, context);
11319
+ function actor_run(self, context) {
11320
+ if (context.timeSeconds < self.pain_debounce_time && !self.enemy) {
11321
+ if (self.movetarget)
11322
+ actor_walk(self, context);
11323
+ else
11324
+ actor_stand(self, context);
11325
+ return;
11326
+ }
11327
+ if (self.monsterinfo.aiflags & 1 /* StandGround */) {
11328
+ actor_stand(self, context);
11329
+ return;
11330
+ }
11331
+ self.monsterinfo.current_move = actor_move_run;
11008
11332
  }
11009
- function monster_ai_move14(self, dist, context) {
11010
- ai_move(self, dist);
11333
+ var messages = [
11334
+ "Watch it",
11335
+ "#$@*&",
11336
+ "Idiot",
11337
+ "Check your targets"
11338
+ ];
11339
+ function actor_pain(self, other, kick, damage) {
11340
+ const context = self.monsterinfo.context;
11341
+ if (!context) return;
11342
+ if (context.timeSeconds < self.pain_debounce_time)
11343
+ return;
11344
+ self.pain_debounce_time = context.timeSeconds + 3;
11345
+ const random10 = Math.random();
11346
+ if (other && other.client && random10 < 0.4) {
11347
+ const v = subtractVec3(other.origin, self.origin);
11348
+ self.ideal_yaw = vectorToYaw(v);
11349
+ if (Math.random() < 0.5)
11350
+ self.monsterinfo.current_move = actor_move_flipoff;
11351
+ else
11352
+ self.monsterinfo.current_move = actor_move_taunt;
11353
+ const name = actor_names[Math.floor(Math.random() * actor_names.length)];
11354
+ const message = messages[Math.floor(Math.random() * messages.length)];
11355
+ context.centerprintf(other, `${name}: ${message}!
11356
+ `);
11357
+ return;
11358
+ }
11359
+ const n = Math.floor(Math.random() * 3);
11360
+ if (n === 0)
11361
+ self.monsterinfo.current_move = actor_move_pain1;
11362
+ else if (n === 1)
11363
+ self.monsterinfo.current_move = actor_move_pain2;
11364
+ else
11365
+ self.monsterinfo.current_move = actor_move_pain3;
11011
11366
  }
11012
- var stand_move13;
11013
- var walk_move12;
11014
- var run_move12;
11015
- var attack_bfg_move;
11016
- var attack_hyperblaster_move;
11017
- var attack_railgun_move;
11018
- var pain4_move;
11019
- var pain5_move;
11020
- var pain6_move;
11021
- var death_move11;
11022
- var sight_move;
11023
- function makron_stand(self) {
11024
- self.monsterinfo.current_move = stand_move13;
11025
- }
11026
- function makron_walk(self) {
11027
- self.monsterinfo.current_move = walk_move12;
11028
- }
11029
- function makron_run(self) {
11030
- if (self.enemy && self.enemy.health > 0) {
11031
- self.monsterinfo.current_move = run_move12;
11032
- } else {
11033
- self.monsterinfo.current_move = stand_move13;
11034
- }
11035
- }
11036
- function makron_attack(self) {
11037
- if (!self.enemy) return;
11038
- const r = Math.random();
11039
- if (r <= 0.3) {
11040
- self.monsterinfo.current_move = attack_bfg_move;
11041
- } else if (r <= 0.6) {
11042
- self.monsterinfo.current_move = attack_hyperblaster_move;
11043
- } else {
11044
- self.monsterinfo.current_move = attack_railgun_move;
11045
- }
11046
- }
11047
- function getProjectedOffset3(self, offset) {
11048
- const { forward, right, up } = angleVectors(self.angles);
11049
- const start = { ...self.origin };
11050
- const x = scaleVec3(forward, offset.x);
11051
- const y = scaleVec3(right, offset.y);
11052
- const z = scaleVec3(up, offset.z);
11053
- return addVec3(addVec3(addVec3(start, x), y), z);
11054
- }
11055
- function makron_fire_bfg(self, context) {
11056
- if (!self.enemy) return;
11057
- context.engine.sound?.(self, 0, "makron/bfg_fire.wav", 1, 1, 0);
11058
- const start = getProjectedOffset3(self, MAKRON_BFG_OFFSET);
11059
- const target = { ...self.enemy.origin };
11060
- target.z += self.enemy.viewheight || 0;
11061
- const dir = normalizeVec3(subtractVec3(target, start));
11062
- monster_fire_bfg(self, start, dir, 50, 300, 100, 300, 0, context);
11063
- }
11064
- function makron_fire_railgun(self, context) {
11065
- if (!self.pos1) return;
11066
- context.engine.sound?.(self, 0, "makron/rail_fire.wav", 1, 1, 0);
11067
- const start = getProjectedOffset3(self, MAKRON_RAILGUN_OFFSET);
11068
- const dir = normalizeVec3(subtractVec3(self.pos1, start));
11069
- monster_fire_railgun(self, start, dir, 50, 100, 0, context);
11070
- }
11071
- function makron_save_loc(self) {
11072
- if (!self.enemy) return;
11073
- self.pos1 = { ...self.enemy.origin };
11074
- self.pos1 = { ...self.pos1, z: self.pos1.z + (self.enemy.viewheight || 0) };
11367
+ function actor_setskin(self, context) {
11368
+ if (self.health < self.max_health / 2)
11369
+ self.skin = 1;
11370
+ else
11371
+ self.skin = 0;
11075
11372
  }
11076
- function makron_fire_hyperblaster(self, context) {
11077
- context.engine.sound?.(self, 0, "makron/blaster.wav", 1, 1, 0);
11078
- const start = getProjectedOffset3(self, MAKRON_BLASTER_OFFSET_1);
11079
- const relFrame = (self.monsterinfo.nextframe || 0) - attack_hyperblaster_move.firstframe;
11080
- let yawDelta = 0;
11373
+ function actorMachineGun(self, context) {
11374
+ const flashOffset = { x: 0, y: 0, z: 0 };
11375
+ const vectors = angleVectors(self.angles);
11376
+ const forward = vectors.forward;
11377
+ const start = copyVec3(self.origin);
11378
+ start.z += self.viewheight;
11081
11379
  let dir;
11082
11380
  if (self.enemy) {
11083
- const target = { ...self.enemy.origin };
11084
- target.z += self.enemy.viewheight || 0;
11085
- const vec = subtractVec3(target, start);
11086
- const baseAngles = vectorToAngles(vec);
11087
- const enemyAngles = { ...baseAngles };
11088
- if (relFrame <= 12) {
11089
- enemyAngles.y -= 5 * (relFrame - 4);
11381
+ let target;
11382
+ if (self.enemy.health > 0) {
11383
+ target = subtractVec3(self.enemy.origin, scaleVec3(self.enemy.velocity, 0.2));
11384
+ target.z += self.enemy.viewheight;
11090
11385
  } else {
11091
- enemyAngles.y -= 40 - 5 * (relFrame - 12);
11386
+ target = copyVec3(self.enemy.absmin);
11387
+ target.z += self.enemy.size.z / 2 + 1;
11092
11388
  }
11093
- const forward = angleVectors(enemyAngles).forward;
11094
- dir = forward;
11389
+ dir = subtractVec3(target, start);
11390
+ dir = normalizeVec3(dir);
11095
11391
  } else {
11096
- const { forward } = angleVectors(self.angles);
11097
11392
  dir = forward;
11098
11393
  }
11099
- monster_fire_blaster(self, start, dir, 15, 1e3, 0, 0, context, 1 /* BLASTER */);
11394
+ monster_fire_bullet(self, start, dir, 3, 4, 0, 0, MZ2_ACTOR_MACHINEGUN_1, context);
11100
11395
  }
11101
- function makron_pain(self, other, kick, damage, context) {
11102
- if (self.health < self.max_health / 2) {
11103
- self.skin = 1;
11104
- }
11105
- if (self.timestamp < (self.pain_finished_time || 0)) return;
11106
- if (damage <= 25 && Math.random() < 0.2) return;
11107
- self.pain_finished_time = self.timestamp + 3;
11108
- if (damage <= 40) {
11109
- context.engine.sound?.(self, 0, "makron/pain1.wav", 1, 1, 0);
11110
- self.monsterinfo.current_move = pain4_move;
11111
- } else if (damage <= 110) {
11112
- context.engine.sound?.(self, 0, "makron/pain2.wav", 1, 1, 0);
11113
- self.monsterinfo.current_move = pain5_move;
11114
- } else {
11115
- if (Math.random() <= 0.45) {
11116
- context.engine.sound?.(self, 0, "makron/pain3.wav", 1, 1, 0);
11117
- self.monsterinfo.current_move = pain6_move;
11118
- }
11119
- }
11396
+ function actor_dead(self, context) {
11397
+ self.mins = { x: -16, y: -16, z: -24 };
11398
+ self.maxs = { x: 16, y: 16, z: -8 };
11399
+ self.movetype = 7 /* Toss */;
11400
+ self.svflags |= 1;
11401
+ self.nextthink = -1;
11402
+ context.linkentity(self);
11120
11403
  }
11121
- function makron_die(self, context) {
11122
- context.engine.sound?.(self, 0, "makron/death.wav", 1, 1, 0);
11123
- self.monsterinfo.current_move = death_move11;
11404
+ function actor_die(self, inflictor, attacker, damage, point, mod) {
11405
+ const context = self.monsterinfo.context;
11406
+ if (!context) return;
11407
+ if (self.health <= -80) {
11408
+ throwGibs(context, self.origin, damage);
11409
+ self.deadflag = 2 /* Dead */;
11410
+ return;
11411
+ }
11412
+ if (self.deadflag === 2 /* Dead */)
11413
+ return;
11414
+ self.deadflag = 2 /* Dead */;
11415
+ self.takedamage = true;
11416
+ if (Math.random() < 0.5)
11417
+ self.monsterinfo.current_move = actor_move_death1;
11418
+ else
11419
+ self.monsterinfo.current_move = actor_move_death2;
11420
+ }
11421
+ function actor_fire(self, context) {
11422
+ actorMachineGun(self, context);
11423
+ const fire_wait = self.monsterinfo.fire_wait ?? 0;
11424
+ if (context.timeSeconds >= fire_wait)
11425
+ self.monsterinfo.aiflags &= ~128 /* HoldFrame */;
11426
+ else
11427
+ self.monsterinfo.aiflags |= 128 /* HoldFrame */;
11124
11428
  }
11125
- function makron_dead(self) {
11126
- self.monsterinfo.nextframe = death_move11.lastframe;
11127
- self.nextthink = -1;
11429
+ function actor_attack(self, context) {
11430
+ self.monsterinfo.current_move = actor_move_attack;
11431
+ self.monsterinfo.fire_wait = context.timeSeconds + 1 + Math.random() * 1.6;
11128
11432
  }
11129
- var stand_frames13 = Array.from({ length: 60 }, () => ({ ai: monster_ai_stand14, dist: 0 }));
11130
- stand_move13 = { firstframe: 0, lastframe: 59, frames: stand_frames13, endfunc: makron_stand };
11131
- var walk_frames12 = Array.from({ length: 10 }, () => ({ ai: monster_ai_walk14, dist: 8 }));
11132
- walk_move12 = { firstframe: 60, lastframe: 69, frames: walk_frames12, endfunc: makron_walk };
11133
- var run_frames11 = Array.from({ length: 10 }, () => ({ ai: monster_ai_run13, dist: 8 }));
11134
- run_move12 = { firstframe: 60, lastframe: 69, frames: run_frames11, endfunc: makron_run };
11135
- var attack_bfg_frames = Array.from({ length: 8 }, (_, i) => ({
11136
- ai: monster_ai_charge14,
11137
- dist: 0,
11138
- think: i === 3 ? makron_fire_bfg : null
11139
- }));
11140
- attack_bfg_move = { firstframe: 70, lastframe: 77, frames: attack_bfg_frames, endfunc: makron_run };
11141
- var attack_hyperblaster_frames = Array.from({ length: 26 }, (_, i) => ({
11142
- ai: monster_ai_move14,
11143
- dist: 0,
11144
- think: i >= 4 && i <= 20 ? makron_fire_hyperblaster : null
11145
- }));
11146
- attack_hyperblaster_move = { firstframe: 78, lastframe: 103, frames: attack_hyperblaster_frames, endfunc: makron_run };
11147
- var attack_railgun_frames = Array.from({ length: 16 }, (_, i) => ({
11148
- ai: monster_ai_charge14,
11149
- dist: 0,
11150
- think: i === 7 ? makron_save_loc : i === 8 ? makron_fire_railgun : null
11151
- }));
11152
- attack_railgun_move = { firstframe: 104, lastframe: 119, frames: attack_railgun_frames, endfunc: makron_run };
11153
- var pain4_frames = Array.from({ length: 4 }, () => ({ ai: monster_ai_move14, dist: 0 }));
11154
- pain4_move = { firstframe: 120, lastframe: 123, frames: pain4_frames, endfunc: makron_run };
11155
- var pain5_frames = Array.from({ length: 4 }, () => ({ ai: monster_ai_move14, dist: 0 }));
11156
- pain5_move = { firstframe: 124, lastframe: 127, frames: pain5_frames, endfunc: makron_run };
11157
- var pain6_frames = Array.from({ length: 27 }, () => ({ ai: monster_ai_move14, dist: 0 }));
11158
- pain6_move = { firstframe: 128, lastframe: 154, frames: pain6_frames, endfunc: makron_run };
11159
- var death_frames11 = Array.from({ length: 95 }, () => ({ ai: monster_ai_move14, dist: 0 }));
11160
- death_move11 = { firstframe: 155, lastframe: 249, frames: death_frames11, endfunc: makron_dead };
11161
- var sight_frames = Array.from({ length: 13 }, () => ({ ai: monster_ai_move14, dist: 0 }));
11162
- sight_move = { firstframe: 250, lastframe: 262, frames: sight_frames, endfunc: makron_run };
11163
- function SP_monster_makron(self, context) {
11164
- self.classname = "monster_makron";
11165
- self.model = "models/monsters/boss3/rider/tris.md2";
11166
- self.mins = { x: -30, y: -30, z: 0 };
11167
- self.maxs = { x: 30, y: 30, z: 90 };
11433
+ function actor_use(self, other, activator) {
11434
+ const context = self.monsterinfo.context;
11435
+ const target = context.pickTarget(self.target);
11436
+ self.goalentity = target;
11437
+ self.movetarget = target;
11438
+ if (!self.movetarget || self.movetarget.classname !== "target_actor") {
11439
+ console.log(`${self.classname}: bad target ${self.target}`);
11440
+ self.target = void 0;
11441
+ self.monsterinfo.pausetime = 1e8;
11442
+ if (self.monsterinfo.stand) self.monsterinfo.stand(self, context);
11443
+ return;
11444
+ }
11445
+ const goalPos = self.goalentity ? self.goalentity.origin : self.movetarget ? self.movetarget.origin : self.origin;
11446
+ const v = subtractVec3(goalPos, self.origin);
11447
+ self.ideal_yaw = vectorToYaw(v);
11448
+ self.angles.y = self.ideal_yaw;
11449
+ if (self.monsterinfo.walk) self.monsterinfo.walk(self, context);
11450
+ self.target = void 0;
11451
+ }
11452
+ function actor_stand_wrapper(self, context) {
11453
+ actor_stand(self, context);
11454
+ }
11455
+ var frames_stand = [
11456
+ m2(ai_stand),
11457
+ m2(ai_stand),
11458
+ m2(ai_stand),
11459
+ m2(ai_stand),
11460
+ m2(ai_stand),
11461
+ m2(ai_stand),
11462
+ m2(ai_stand),
11463
+ m2(ai_stand),
11464
+ m2(ai_stand),
11465
+ m2(ai_stand),
11466
+ m2(ai_stand),
11467
+ m2(ai_stand),
11468
+ m2(ai_stand),
11469
+ m2(ai_stand),
11470
+ m2(ai_stand),
11471
+ m2(ai_stand),
11472
+ m2(ai_stand),
11473
+ m2(ai_stand),
11474
+ m2(ai_stand),
11475
+ m2(ai_stand),
11476
+ m2(ai_stand),
11477
+ m2(ai_stand),
11478
+ m2(ai_stand),
11479
+ m2(ai_stand),
11480
+ m2(ai_stand),
11481
+ m2(ai_stand),
11482
+ m2(ai_stand),
11483
+ m2(ai_stand),
11484
+ m2(ai_stand),
11485
+ m2(ai_stand),
11486
+ m2(ai_stand),
11487
+ m2(ai_stand),
11488
+ m2(ai_stand),
11489
+ m2(ai_stand),
11490
+ m2(ai_stand),
11491
+ m2(ai_stand),
11492
+ m2(ai_stand),
11493
+ m2(ai_stand),
11494
+ m2(ai_stand),
11495
+ m2(ai_stand)
11496
+ ];
11497
+ actor_move_stand = {
11498
+ firstframe: FRAME_stand101,
11499
+ lastframe: FRAME_stand140,
11500
+ frames: frames_stand,
11501
+ endfunc: null
11502
+ };
11503
+ var frames_walk = [
11504
+ m2(ai_walk),
11505
+ m2(ai_walk, 6),
11506
+ m2(ai_walk, 10),
11507
+ m2(ai_walk, 3),
11508
+ m2(ai_walk, 2),
11509
+ m2(ai_walk, 7),
11510
+ m2(ai_walk, 10),
11511
+ m2(ai_walk, 1)
11512
+ ];
11513
+ actor_move_walk = {
11514
+ firstframe: FRAME_walk01,
11515
+ lastframe: FRAME_walk08,
11516
+ frames: frames_walk,
11517
+ endfunc: null
11518
+ };
11519
+ var frames_run = [
11520
+ m2(ai_run, 4),
11521
+ m2(ai_run, 15),
11522
+ m2(ai_run, 15),
11523
+ m2(ai_run, 8),
11524
+ m2(ai_run, 20),
11525
+ m2(ai_run, 15)
11526
+ ];
11527
+ actor_move_run = {
11528
+ firstframe: FRAME_run02,
11529
+ lastframe: FRAME_run07,
11530
+ frames: frames_run,
11531
+ endfunc: null
11532
+ };
11533
+ var frames_pain1 = [
11534
+ m2(ai_move, -5),
11535
+ m2(ai_move, 4),
11536
+ m2(ai_move, 1)
11537
+ ];
11538
+ actor_move_pain1 = {
11539
+ firstframe: FRAME_pain101,
11540
+ lastframe: FRAME_pain103,
11541
+ frames: frames_pain1,
11542
+ endfunc: actor_run
11543
+ };
11544
+ var frames_pain2 = [
11545
+ m2(ai_move, -4),
11546
+ m2(ai_move, 4),
11547
+ m2(ai_move)
11548
+ ];
11549
+ actor_move_pain2 = {
11550
+ firstframe: FRAME_pain201,
11551
+ lastframe: FRAME_pain203,
11552
+ frames: frames_pain2,
11553
+ endfunc: actor_run
11554
+ };
11555
+ var frames_pain3 = [
11556
+ m2(ai_move, -1),
11557
+ m2(ai_move, 1),
11558
+ m2(ai_move, 0)
11559
+ ];
11560
+ actor_move_pain3 = {
11561
+ firstframe: FRAME_pain301,
11562
+ lastframe: FRAME_pain303,
11563
+ frames: frames_pain3,
11564
+ endfunc: actor_run
11565
+ };
11566
+ var frames_flipoff = [
11567
+ m2(ai_turn),
11568
+ m2(ai_turn),
11569
+ m2(ai_turn),
11570
+ m2(ai_turn),
11571
+ m2(ai_turn),
11572
+ m2(ai_turn),
11573
+ m2(ai_turn),
11574
+ m2(ai_turn),
11575
+ m2(ai_turn),
11576
+ m2(ai_turn),
11577
+ m2(ai_turn),
11578
+ m2(ai_turn),
11579
+ m2(ai_turn),
11580
+ m2(ai_turn)
11581
+ ];
11582
+ actor_move_flipoff = {
11583
+ firstframe: FRAME_flip01,
11584
+ lastframe: FRAME_flip14,
11585
+ frames: frames_flipoff,
11586
+ endfunc: actor_run
11587
+ };
11588
+ var frames_taunt = [
11589
+ m2(ai_turn),
11590
+ m2(ai_turn),
11591
+ m2(ai_turn),
11592
+ m2(ai_turn),
11593
+ m2(ai_turn),
11594
+ m2(ai_turn),
11595
+ m2(ai_turn),
11596
+ m2(ai_turn),
11597
+ m2(ai_turn),
11598
+ m2(ai_turn),
11599
+ m2(ai_turn),
11600
+ m2(ai_turn),
11601
+ m2(ai_turn),
11602
+ m2(ai_turn),
11603
+ m2(ai_turn),
11604
+ m2(ai_turn),
11605
+ m2(ai_turn)
11606
+ ];
11607
+ actor_move_taunt = {
11608
+ firstframe: FRAME_taunt01,
11609
+ lastframe: FRAME_taunt17,
11610
+ frames: frames_taunt,
11611
+ endfunc: actor_run
11612
+ };
11613
+ var frames_death1 = [
11614
+ m2(ai_move),
11615
+ m2(ai_move),
11616
+ m2(ai_move, -13),
11617
+ m2(ai_move, 14),
11618
+ m2(ai_move, 3),
11619
+ m2(ai_move, -2),
11620
+ m2(ai_move, 1)
11621
+ ];
11622
+ actor_move_death1 = {
11623
+ firstframe: FRAME_death101,
11624
+ lastframe: FRAME_death107,
11625
+ frames: frames_death1,
11626
+ endfunc: actor_dead
11627
+ };
11628
+ var frames_death2 = [
11629
+ m2(ai_move),
11630
+ m2(ai_move, 7),
11631
+ m2(ai_move, -6),
11632
+ m2(ai_move, -5),
11633
+ m2(ai_move, 1),
11634
+ m2(ai_move),
11635
+ m2(ai_move, -1),
11636
+ m2(ai_move, -2),
11637
+ m2(ai_move, -1),
11638
+ m2(ai_move, -9),
11639
+ m2(ai_move, -13),
11640
+ m2(ai_move, -13),
11641
+ m2(ai_move)
11642
+ ];
11643
+ actor_move_death2 = {
11644
+ firstframe: FRAME_death201,
11645
+ lastframe: FRAME_death213,
11646
+ frames: frames_death2,
11647
+ endfunc: actor_dead
11648
+ };
11649
+ var frames_attack = [
11650
+ m2(ai_charge, -2, actor_fire),
11651
+ m2(ai_charge, -2),
11652
+ m2(ai_charge, 3),
11653
+ m2(ai_charge, 2)
11654
+ ];
11655
+ actor_move_attack = {
11656
+ firstframe: FRAME_attak01,
11657
+ lastframe: FRAME_attak04,
11658
+ frames: frames_attack,
11659
+ endfunc: actor_run
11660
+ };
11661
+ function SP_misc_actor(self, context) {
11662
+ if (!self.targetname) {
11663
+ console.log(`${self.classname}: no targetname`);
11664
+ context.entities.free(self);
11665
+ return;
11666
+ }
11667
+ if (!self.target) {
11668
+ console.log(`${self.classname}: no target`);
11669
+ context.entities.free(self);
11670
+ return;
11671
+ }
11672
+ self.movetarget = null;
11168
11673
  self.movetype = 5 /* Step */;
11169
11674
  self.solid = 2 /* BoundingBox */;
11170
- self.health = 3e3;
11171
- self.max_health = 3e3;
11172
- self.mass = 500;
11173
- self.takedamage = true;
11174
- self.viewheight = 90;
11175
- self.pain = (ent, other, kick, dmg) => makron_pain(ent, other, kick, dmg, context.entities);
11176
- self.die = (self2, inflictor, attacker, damage, point) => {
11177
- if (self2.health <= -2e3) {
11178
- throwGibs(context.entities, self2.origin, damage);
11179
- context.entities.free(self2);
11180
- return;
11181
- }
11182
- self2.deadflag = 2 /* Dead */;
11183
- self2.solid = 0 /* Not */;
11184
- makron_die(self2, context.entities);
11675
+ self.model = "players/male/tris.md2";
11676
+ self.mins = { x: -16, y: -16, z: -24 };
11677
+ self.maxs = { x: 16, y: 16, z: 32 };
11678
+ if (!self.health)
11679
+ self.health = 100;
11680
+ self.max_health = self.health;
11681
+ self.mass = 200;
11682
+ self.pain = actor_pain;
11683
+ self.die = actor_die;
11684
+ self.monsterinfo = {
11685
+ ...self.monsterinfo,
11686
+ // Preserve default properties like last_sighting, trail_time, pausetime
11687
+ stand: (s) => actor_stand_wrapper(s, context.entities),
11688
+ // Wrap to match signature
11689
+ walk: actor_walk,
11690
+ run: actor_run,
11691
+ attack: actor_attack,
11692
+ melee: void 0,
11693
+ sight: void 0,
11694
+ setskin: (s) => actor_setskin(s, context.entities),
11695
+ // Wrap to match signature
11696
+ aiflags: 256 /* GoodGuy */,
11697
+ scale: 1
11698
+ // MODEL_SCALE
11185
11699
  };
11186
- self.monsterinfo.stand = makron_stand;
11187
- self.monsterinfo.walk = makron_walk;
11188
- self.monsterinfo.run = makron_run;
11189
- self.monsterinfo.attack = makron_attack;
11190
- self.monsterinfo.sight = (self2, other) => {
11191
- context.entities.sound?.(self2, 0, "makron/sight.wav", 1, 1, 0);
11192
- self2.monsterinfo.current_move = sight_move;
11700
+ self.monsterinfo.context = context.entities;
11701
+ context.entities.linkentity(self);
11702
+ self.monsterinfo.current_move = actor_move_stand;
11703
+ self.think = (s) => {
11704
+ const c = s.monsterinfo.context;
11705
+ if (c) monster_think(s, c);
11193
11706
  };
11194
- self.think = monster_think;
11195
- self.monsterinfo.current_move = sight_move;
11196
- self.nextthink = self.timestamp + MONSTER_TICK15;
11707
+ self.nextthink = context.entities.timeSeconds + MONSTER_TICK16;
11708
+ self.use = (self2, other, activator = null) => actor_use(self2, other, activator);
11709
+ }
11710
+ var SPAWNFLAG_TARGET_ACTOR_JUMP = 1;
11711
+ var SPAWNFLAG_TARGET_ACTOR_SHOOT = 2;
11712
+ var SPAWNFLAG_TARGET_ACTOR_ATTACK = 4;
11713
+ var SPAWNFLAG_TARGET_ACTOR_HOLD = 16;
11714
+ var SPAWNFLAG_TARGET_ACTOR_BRUTAL = 32;
11715
+ function target_actor_touch(self, other, plane, surf) {
11716
+ if (!other) return;
11717
+ const context = self.monsterinfo.context;
11718
+ if (other.movetarget !== self)
11719
+ return;
11720
+ if (other.enemy)
11721
+ return;
11722
+ other.goalentity = null;
11723
+ other.movetarget = null;
11724
+ if (self.message) {
11725
+ const name = actor_names[Math.floor(Math.random() * actor_names.length)];
11726
+ }
11727
+ if (self.spawnflags & SPAWNFLAG_TARGET_ACTOR_JUMP) {
11728
+ const v = other.velocity;
11729
+ v.x = self.movedir.x * self.speed;
11730
+ v.y = self.movedir.y * self.speed;
11731
+ if (other.groundentity) {
11732
+ other.groundentity = null;
11733
+ v.z = self.movedir.z;
11734
+ context.sound(other, 2, "player/male/jump1.wav", 1, 1, 0);
11735
+ }
11736
+ }
11737
+ if (self.spawnflags & SPAWNFLAG_TARGET_ACTOR_SHOOT) {
11738
+ } else if (self.spawnflags & SPAWNFLAG_TARGET_ACTOR_ATTACK) {
11739
+ other.enemy = context.pickTarget(self.pathtarget);
11740
+ if (other.enemy) {
11741
+ other.goalentity = other.enemy;
11742
+ if (self.spawnflags & SPAWNFLAG_TARGET_ACTOR_BRUTAL)
11743
+ other.monsterinfo.aiflags |= 512 /* Brutal */;
11744
+ if (self.spawnflags & SPAWNFLAG_TARGET_ACTOR_HOLD) {
11745
+ other.monsterinfo.aiflags |= 1 /* StandGround */;
11746
+ actor_stand(other, context);
11747
+ } else {
11748
+ actor_run(other, context);
11749
+ }
11750
+ }
11751
+ }
11752
+ if (!(self.spawnflags & (SPAWNFLAG_TARGET_ACTOR_ATTACK | SPAWNFLAG_TARGET_ACTOR_SHOOT)) && self.pathtarget) {
11753
+ const savetarget = self.target;
11754
+ self.target = self.pathtarget;
11755
+ context.useTargets(self, other);
11756
+ self.target = savetarget;
11757
+ }
11758
+ other.movetarget = context.pickTarget(self.target);
11759
+ if (!other.goalentity)
11760
+ other.goalentity = other.movetarget;
11761
+ if (!other.movetarget && !other.enemy) {
11762
+ other.monsterinfo.pausetime = 1e8;
11763
+ if (other.monsterinfo.stand) other.monsterinfo.stand(other, context);
11764
+ } else if (other.movetarget === other.goalentity && other.movetarget) {
11765
+ const v = subtractVec3(other.movetarget.origin, other.origin);
11766
+ other.ideal_yaw = vectorToYaw(v);
11767
+ }
11197
11768
  }
11198
- function registerMakronSpawns(registry) {
11199
- registry.register("monster_makron", SP_monster_makron);
11769
+ function SP_target_actor(self, context) {
11770
+ if (!self.targetname)
11771
+ console.log(`${self.classname}: no targetname`);
11772
+ self.solid = 1 /* Trigger */;
11773
+ self.touch = target_actor_touch;
11774
+ self.mins = { x: -8, y: -8, z: -8 };
11775
+ self.maxs = { x: 8, y: 8, z: 8 };
11776
+ self.svflags = 1 << 6;
11777
+ self.monsterinfo = {
11778
+ ...self.monsterinfo
11779
+ };
11780
+ self.monsterinfo.context = context.entities;
11781
+ if (self.spawnflags & SPAWNFLAG_TARGET_ACTOR_JUMP) {
11782
+ if (!self.speed)
11783
+ self.speed = 200;
11784
+ const height = self.height || 200;
11785
+ if (self.angles.y === 0)
11786
+ self.angles.y = 360;
11787
+ const dir = setMovedir(self.angles);
11788
+ dir.z = height;
11789
+ self.movedir = dir;
11790
+ }
11791
+ context.entities.linkentity(self);
11792
+ }
11793
+ function registerActorSpawns(registry) {
11794
+ registry.register("misc_actor", SP_misc_actor);
11795
+ registry.register("target_actor", SP_target_actor);
11200
11796
  }
11201
11797
 
11202
11798
  // src/entities/monsters/medic.ts
11203
- var MONSTER_TICK16 = 0.1;
11799
+ var MONSTER_TICK17 = 0.1;
11204
11800
  function monster_ai_stand15(self, dist, context) {
11205
11801
  if (self.classname === "monster_medic") {
11206
11802
  if (medic_find_dead(self, context)) {
@@ -11208,24 +11804,24 @@ function monster_ai_stand15(self, dist, context) {
11208
11804
  return;
11209
11805
  }
11210
11806
  }
11211
- ai_stand(self, MONSTER_TICK16, context);
11807
+ ai_stand(self, MONSTER_TICK17, context);
11212
11808
  }
11213
11809
  function monster_ai_walk15(self, dist, context) {
11214
- ai_walk(self, dist, MONSTER_TICK16, context);
11810
+ ai_walk(self, dist, MONSTER_TICK17, context);
11215
11811
  }
11216
11812
  function monster_ai_run14(self, dist, context) {
11217
11813
  if (self.classname === "monster_medic") {
11218
11814
  if (medic_find_dead(self, context)) {
11219
11815
  self.monsterinfo.current_move = run_move13;
11220
11816
  } else {
11221
- ai_run(self, dist, MONSTER_TICK16, context);
11817
+ ai_run(self, dist, MONSTER_TICK17, context);
11222
11818
  }
11223
11819
  } else {
11224
- ai_run(self, dist, MONSTER_TICK16, context);
11820
+ ai_run(self, dist, MONSTER_TICK17, context);
11225
11821
  }
11226
11822
  }
11227
11823
  function monster_ai_charge15(self, dist, context) {
11228
- ai_charge(self, dist, MONSTER_TICK16, context);
11824
+ ai_charge(self, dist, MONSTER_TICK17, context);
11229
11825
  }
11230
11826
  function monster_ai_move15(self, dist, context) {
11231
11827
  ai_move(self, dist);
@@ -11561,7 +12157,7 @@ function SP_monster_medic(self, context) {
11561
12157
  self.monsterinfo.attack = medic_attack;
11562
12158
  self.think = monster_think;
11563
12159
  medic_stand(self);
11564
- self.nextthink = self.timestamp + MONSTER_TICK16;
12160
+ self.nextthink = self.timestamp + MONSTER_TICK17;
11565
12161
  }
11566
12162
  function SP_monster_medic_commander(self, context) {
11567
12163
  SP_monster_medic(self, context);
@@ -11576,25 +12172,25 @@ function registerMedicSpawns(registry) {
11576
12172
  }
11577
12173
 
11578
12174
  // src/entities/monsters/mutant.ts
11579
- var MONSTER_TICK17 = 0.1;
12175
+ var MONSTER_TICK18 = 0.1;
11580
12176
  var random6 = () => Math.random();
11581
12177
  function monster_ai_stand16(self, dist, context) {
11582
- ai_stand(self, MONSTER_TICK17, context);
12178
+ ai_stand(self, MONSTER_TICK18, context);
11583
12179
  }
11584
12180
  function monster_ai_walk16(self, dist, context) {
11585
- ai_walk(self, dist, MONSTER_TICK17, context);
12181
+ ai_walk(self, dist, MONSTER_TICK18, context);
11586
12182
  }
11587
12183
  function monster_ai_run15(self, dist, context) {
11588
- ai_run(self, dist, MONSTER_TICK17, context);
12184
+ ai_run(self, dist, MONSTER_TICK18, context);
11589
12185
  }
11590
12186
  function monster_ai_charge16(self, dist, context) {
11591
- ai_charge(self, dist, MONSTER_TICK17, context);
12187
+ ai_charge(self, dist, MONSTER_TICK18, context);
11592
12188
  }
11593
12189
  function monster_ai_move16(self, dist, context) {
11594
12190
  ai_move(self, dist);
11595
12191
  }
11596
12192
  function monster_ai_face(self, dist, context) {
11597
- ai_face(self, null, dist, MONSTER_TICK17);
12193
+ ai_face(self, null, dist, MONSTER_TICK18);
11598
12194
  }
11599
12195
  var stand_move15;
11600
12196
  var walk_move14;
@@ -11958,26 +12554,26 @@ function SP_monster_mutant(self, context) {
11958
12554
  self.monsterinfo.idle = mutant_stand;
11959
12555
  self.think = monster_think;
11960
12556
  mutant_stand(self);
11961
- self.nextthink = self.timestamp + MONSTER_TICK17;
12557
+ self.nextthink = self.timestamp + MONSTER_TICK18;
11962
12558
  }
11963
12559
  function registerMutantSpawns(registry) {
11964
12560
  registry.register("monster_mutant", SP_monster_mutant);
11965
12561
  }
11966
12562
 
11967
12563
  // src/entities/monsters/parasite.ts
11968
- var MONSTER_TICK18 = 0.1;
12564
+ var MONSTER_TICK19 = 0.1;
11969
12565
  var random7 = () => Math.random();
11970
12566
  function monster_ai_stand17(self, dist, context) {
11971
- ai_stand(self, MONSTER_TICK18, context);
12567
+ ai_stand(self, MONSTER_TICK19, context);
11972
12568
  }
11973
12569
  function monster_ai_walk17(self, dist, context) {
11974
- ai_walk(self, dist, MONSTER_TICK18, context);
12570
+ ai_walk(self, dist, MONSTER_TICK19, context);
11975
12571
  }
11976
12572
  function monster_ai_run16(self, dist, context) {
11977
- ai_run(self, dist, MONSTER_TICK18, context);
12573
+ ai_run(self, dist, MONSTER_TICK19, context);
11978
12574
  }
11979
12575
  function monster_ai_charge17(self, dist, context) {
11980
- ai_charge(self, dist, MONSTER_TICK18, context);
12576
+ ai_charge(self, dist, MONSTER_TICK19, context);
11981
12577
  }
11982
12578
  function monster_ai_move17(self, dist, context) {
11983
12579
  ai_move(self, dist);
@@ -12354,28 +12950,28 @@ function SP_monster_parasite(self, context) {
12354
12950
  self.monsterinfo.idle = parasite_idle;
12355
12951
  self.think = monster_think;
12356
12952
  parasite_stand(self);
12357
- self.nextthink = self.timestamp + MONSTER_TICK18;
12953
+ self.nextthink = self.timestamp + MONSTER_TICK19;
12358
12954
  }
12359
12955
  function registerParasiteSpawns(registry) {
12360
12956
  registry.register("monster_parasite", SP_monster_parasite);
12361
12957
  }
12362
12958
 
12363
12959
  // src/entities/monsters/soldier.ts
12364
- var MONSTER_TICK19 = 0.1;
12960
+ var MONSTER_TICK20 = 0.1;
12365
12961
  var SOLDIER_LIGHT = 1;
12366
12962
  var SOLDIER_SSG = 2;
12367
12963
  var SOLDIER_MACHINEGUN = 4;
12368
12964
  function monster_ai_stand18(self, dist, context) {
12369
- ai_stand(self, MONSTER_TICK19, context);
12965
+ ai_stand(self, MONSTER_TICK20, context);
12370
12966
  }
12371
12967
  function monster_ai_walk18(self, dist, context) {
12372
- ai_walk(self, dist, MONSTER_TICK19, context);
12968
+ ai_walk(self, dist, MONSTER_TICK20, context);
12373
12969
  }
12374
12970
  function monster_ai_run17(self, dist, context) {
12375
- ai_run(self, dist, MONSTER_TICK19, context);
12971
+ ai_run(self, dist, MONSTER_TICK20, context);
12376
12972
  }
12377
12973
  function monster_ai_charge18(self, dist, context) {
12378
- ai_charge(self, dist, MONSTER_TICK19, context);
12974
+ ai_charge(self, dist, MONSTER_TICK20, context);
12379
12975
  }
12380
12976
  function monster_ai_move18(self, dist, context) {
12381
12977
  ai_move(self, dist);
@@ -12659,7 +13255,7 @@ function SP_monster_soldier(self, context) {
12659
13255
  };
12660
13256
  self.think = monster_think;
12661
13257
  soldier_stand(self);
12662
- self.nextthink = self.timestamp + MONSTER_TICK19;
13258
+ self.nextthink = self.timestamp + MONSTER_TICK20;
12663
13259
  }
12664
13260
  function SP_monster_soldier_light(self, context) {
12665
13261
  self.spawnflags |= SOLDIER_LIGHT;
@@ -12699,12 +13295,12 @@ function registerMonsterSpawns(registry) {
12699
13295
  }
12700
13296
 
12701
13297
  // src/entities/monsters/supertank.ts
12702
- var MONSTER_TICK20 = 0.1;
13298
+ var MONSTER_TICK21 = 0.1;
12703
13299
  var SUPERTANK_MACHINEGUN_OFFSET = { x: 30, y: 30, z: 40 };
12704
13300
  var SUPERTANK_ROCKET_OFFSET = { x: 30, y: -30, z: 40 };
12705
13301
  var SUPERTANK_GRENADE_OFFSET = { x: 20, y: 0, z: 70 };
12706
13302
  function monster_ai_stand19(self, dist, context) {
12707
- ai_stand(self, MONSTER_TICK20, context);
13303
+ ai_stand(self, MONSTER_TICK21, context);
12708
13304
  }
12709
13305
  function monster_ai_run18(self, dist, context) {
12710
13306
  if (self.enemy && self.enemy.health > 0) {
@@ -12714,7 +13310,7 @@ function monster_ai_run18(self, dist, context) {
12714
13310
  }
12715
13311
  }
12716
13312
  function monster_ai_charge19(self, dist, context) {
12717
- ai_charge(self, dist, MONSTER_TICK20, context);
13313
+ ai_charge(self, dist, MONSTER_TICK21, context);
12718
13314
  }
12719
13315
  function monster_ai_move19(self, dist, context) {
12720
13316
  ai_move(self, dist);
@@ -12910,7 +13506,7 @@ function SP_monster_supertank(self, context) {
12910
13506
  };
12911
13507
  self.think = monster_think;
12912
13508
  supertank_stand(self);
12913
- self.nextthink = self.timestamp + MONSTER_TICK20;
13509
+ self.nextthink = self.timestamp + MONSTER_TICK21;
12914
13510
  }
12915
13511
  function registerSupertankSpawns(registry) {
12916
13512
  registry.register("monster_supertank", SP_monster_supertank);
@@ -12923,7 +13519,7 @@ function registerSupertankSpawns(registry) {
12923
13519
  }
12924
13520
 
12925
13521
  // src/entities/monsters/tank.ts
12926
- var MONSTER_TICK21 = 0.1;
13522
+ var MONSTER_TICK22 = 0.1;
12927
13523
  function M_AdjustBlindfireTarget(self, start, target, right, context) {
12928
13524
  const tr = context.trace(start, target, ZERO_VEC3, ZERO_VEC3, self, MASK_SHOT);
12929
13525
  if (!tr.startsolid && !tr.allsolid && tr.fraction >= 0.5) {
@@ -12950,10 +13546,10 @@ function tank_blind_check(self, context) {
12950
13546
  }
12951
13547
  }
12952
13548
  function monster_ai_stand20(self, dist, context) {
12953
- ai_stand(self, MONSTER_TICK21, context);
13549
+ ai_stand(self, MONSTER_TICK22, context);
12954
13550
  }
12955
13551
  function monster_ai_walk19(self, dist, context) {
12956
- ai_walk(self, dist, MONSTER_TICK21, context);
13552
+ ai_walk(self, dist, MONSTER_TICK22, context);
12957
13553
  }
12958
13554
  function monster_ai_run19(self, dist, context) {
12959
13555
  if (self.enemy && self.enemy.health > 0) {
@@ -12963,7 +13559,7 @@ function monster_ai_run19(self, dist, context) {
12963
13559
  }
12964
13560
  }
12965
13561
  function monster_ai_charge20(self, dist, context) {
12966
- ai_charge(self, dist, MONSTER_TICK21, context);
13562
+ ai_charge(self, dist, MONSTER_TICK22, context);
12967
13563
  }
12968
13564
  function monster_ai_move20(self, dist, context) {
12969
13565
  ai_move(self, dist);
@@ -13274,7 +13870,7 @@ function SP_monster_tank(self, context) {
13274
13870
  self.monsterinfo.blindfire = true;
13275
13871
  self.think = monster_think;
13276
13872
  tank_stand(self);
13277
- self.nextthink = self.timestamp + MONSTER_TICK21;
13873
+ self.nextthink = self.timestamp + MONSTER_TICK22;
13278
13874
  }
13279
13875
  function registerTankSpawns(registry) {
13280
13876
  registry.register("monster_tank", SP_monster_tank);
@@ -13293,15 +13889,15 @@ function registerTankCommanderSpawns(registry) {
13293
13889
  }
13294
13890
 
13295
13891
  // src/entities/monsters/turret.ts
13296
- var MONSTER_TICK22 = 0.1;
13892
+ var MONSTER_TICK23 = 0.1;
13297
13893
  function monster_ai_stand21(self, dist, context) {
13298
- ai_stand(self, MONSTER_TICK22, context);
13894
+ ai_stand(self, MONSTER_TICK23, context);
13299
13895
  }
13300
13896
  function monster_ai_run20(self, dist, context) {
13301
- ai_run(self, dist, MONSTER_TICK22, context);
13897
+ ai_run(self, dist, MONSTER_TICK23, context);
13302
13898
  }
13303
13899
  function monster_ai_charge21(self, dist, context) {
13304
- ai_charge(self, dist, MONSTER_TICK22, context);
13900
+ ai_charge(self, dist, MONSTER_TICK23, context);
13305
13901
  }
13306
13902
  var stand_move20;
13307
13903
  var run_move19;
@@ -13437,7 +14033,7 @@ function SP_monster_turret(self, context) {
13437
14033
  };
13438
14034
  self.think = monster_think;
13439
14035
  turret_stand(self);
13440
- self.nextthink = self.timestamp + MONSTER_TICK22;
14036
+ self.nextthink = self.timestamp + MONSTER_TICK23;
13441
14037
  }
13442
14038
  function registerTurretSpawns(registry) {
13443
14039
  registry.register("monster_turret", SP_monster_turret);
@@ -13468,6 +14064,7 @@ function registerMonsterSpawns2(registry) {
13468
14064
  registerJorgSpawns(registry);
13469
14065
  registerMakronSpawns(registry);
13470
14066
  registerInsaneSpawns(registry);
14067
+ registerActorSpawns(registry);
13471
14068
  }
13472
14069
 
13473
14070
  // src/entities/worldspawn.ts
@@ -14915,7 +15512,97 @@ function ClientObituary(self, inflictor, attacker, mod, sys) {
14915
15512
  }
14916
15513
  }
14917
15514
 
15515
+ // src/entities/player_anim.ts
15516
+ var FRAME_stand01 = 0;
15517
+ var FRAME_stand402 = 39;
15518
+ var FRAME_run1 = 40;
15519
+ var FRAME_run6 = 45;
15520
+ var FRAME_pain1012 = 54;
15521
+ var FRAME_pain104 = 57;
15522
+ var FRAME_pain2012 = 58;
15523
+ var FRAME_pain204 = 61;
15524
+ var FRAME_pain3012 = 62;
15525
+ var FRAME_pain304 = 65;
15526
+ var FRAME_death1012 = 66;
15527
+ var FRAME_death106 = 71;
15528
+ var FRAME_death2012 = 72;
15529
+ var FRAME_death206 = 77;
15530
+ var FRAME_death301 = 78;
15531
+ var FRAME_death306 = 83;
15532
+ var ANIM_BASIC = 0;
15533
+ var ANIM_PAIN = 2;
15534
+ var ANIM_DEATH = 3;
15535
+
15536
+ // src/combat/weapons/firing.ts
15537
+ var random9 = createRandomGenerator();
15538
+
14918
15539
  // src/entities/player.ts
15540
+ function P_PlayerThink(ent, sys) {
15541
+ if (!ent.client) return;
15542
+ const client = ent.client;
15543
+ let animChanged = false;
15544
+ if (ent.deadflag) {
15545
+ } else {
15546
+ const speed = Math.sqrt(ent.velocity.x * ent.velocity.x + ent.velocity.y * ent.velocity.y);
15547
+ const moving = speed > 10;
15548
+ if (client.anim_priority === ANIM_BASIC || client.anim_priority === void 0) {
15549
+ if (moving) {
15550
+ if (ent.frame < FRAME_run1 || ent.frame > FRAME_run6) {
15551
+ ent.frame = FRAME_run1;
15552
+ client.anim_end = FRAME_run6;
15553
+ client.anim_priority = ANIM_BASIC;
15554
+ animChanged = true;
15555
+ }
15556
+ } else {
15557
+ if (ent.frame >= FRAME_run1 && ent.frame <= FRAME_run6 || client.anim_priority === ANIM_BASIC && client.anim_end !== FRAME_stand402 || client.anim_priority === void 0) {
15558
+ ent.frame = FRAME_stand01;
15559
+ client.anim_end = FRAME_stand402;
15560
+ client.anim_priority = ANIM_BASIC;
15561
+ animChanged = true;
15562
+ }
15563
+ }
15564
+ }
15565
+ }
15566
+ if (animChanged) {
15567
+ return;
15568
+ }
15569
+ if (client.anim_end !== void 0 && client.anim_end !== ent.frame) {
15570
+ if (ent.frame < client.anim_end) {
15571
+ ent.frame++;
15572
+ } else if (ent.frame > client.anim_end) {
15573
+ ent.frame--;
15574
+ }
15575
+ } else if (client.anim_end === ent.frame) {
15576
+ if (client.anim_priority === ANIM_BASIC) {
15577
+ if (ent.frame === FRAME_run6) ent.frame = FRAME_run1;
15578
+ else if (ent.frame === FRAME_stand402) ent.frame = FRAME_stand01;
15579
+ } else {
15580
+ if (client.anim_priority !== ANIM_DEATH) {
15581
+ client.anim_priority = ANIM_BASIC;
15582
+ }
15583
+ }
15584
+ }
15585
+ }
15586
+ function player_pain(self, damage) {
15587
+ if (!self.client) return;
15588
+ if (self.health < 40) {
15589
+ }
15590
+ if (self.client.anim_priority && self.client.anim_priority >= ANIM_PAIN) {
15591
+ return;
15592
+ }
15593
+ self.client.anim_priority = ANIM_PAIN;
15594
+ const r = random9.frandom();
15595
+ if (r < 0.33) {
15596
+ self.frame = FRAME_pain1012;
15597
+ self.client.anim_end = FRAME_pain104;
15598
+ } else if (r < 0.66) {
15599
+ self.frame = FRAME_pain2012;
15600
+ self.client.anim_end = FRAME_pain204;
15601
+ } else {
15602
+ self.frame = FRAME_pain3012;
15603
+ self.client.anim_end = FRAME_pain304;
15604
+ }
15605
+ }
14919
15606
  function player_die(self, inflictor, attacker, damage, point, mod, sys) {
14920
15607
  self.deadflag = 2 /* Dead */;
14921
15608
  self.solid = 0 /* Not */;
@@ -14923,8 +15610,24 @@ function player_die(self, inflictor, attacker, damage, point, mod, sys) {
14923
15610
  self.takedamage = false;
14924
15611
  if (self.health < -40 && sys) {
14925
15612
  throwGibs(sys, self.origin, damage);
15613
+ return;
15614
+ }
15615
+ if (self.client) {
15616
+ self.client.anim_priority = ANIM_DEATH;
15617
+ const r = random9.frandom();
15618
+ if (r < 0.33) {
15619
+ self.frame = FRAME_death1012;
15620
+ self.client.anim_end = FRAME_death106;
15621
+ } else if (r < 0.66) {
15622
+ self.frame = FRAME_death2012;
15623
+ self.client.anim_end = FRAME_death206;
15624
+ } else {
15625
+ self.frame = FRAME_death301;
15626
+ self.client.anim_end = FRAME_death306;
15627
+ }
15628
+ } else {
15629
+ self.frame = 0;
14926
15630
  }
14927
- self.frame = 0;
14928
15631
  if (sys) {
14929
15632
  ClientObituary(self, inflictor, attacker, mod, sys);
14930
15633
  }
@@ -14958,6 +15661,7 @@ function player_think(self, sys) {
14958
15661
  weaponItem.think(self, sys);
14959
15662
  }
14960
15663
  }
15664
+ P_PlayerThink(self, sys);
14961
15665
  self.nextthink = sys.timeSeconds + 0.1;
14962
15666
  sys.scheduleThink(self, self.nextthink);
14963
15667
  }
@@ -15304,7 +16008,7 @@ var WEAPONS = {
15304
16008
  };
15305
16009
 
15306
16010
  // src/index.ts
15307
- var ZERO_VEC37 = { x: 0, y: 0, z: 0 };
16011
+ var ZERO_VEC36 = { x: 0, y: 0, z: 0 };
15308
16012
  function createGame(imports, engine, options) {
15309
16013
  const gravity = options.gravity;
15310
16014
  const deathmatch = options.deathmatch ?? false;
@@ -15373,8 +16077,8 @@ function createGame(imports, engine, options) {
15373
16077
  };
15374
16078
  entities.runFrame();
15375
16079
  });
15376
- let origin = { ...ZERO_VEC37 };
15377
- let velocity = { ...ZERO_VEC37 };
16080
+ let origin = { ...ZERO_VEC36 };
16081
+ let velocity = { ...ZERO_VEC36 };
15378
16082
  const calculateBlend = (player, time) => {
15379
16083
  const blend = [0, 0, 0, 0];
15380
16084
  if (!player || !player.client) return blend;
@@ -15456,10 +16160,10 @@ function createGame(imports, engine, options) {
15456
16160
  // TODO
15457
16161
  damageIndicators: [],
15458
16162
  stats: player ? populatePlayerStats(player, levelClock.current.timeSeconds) : [],
15459
- kick_angles: player?.client?.kick_angles ?? ZERO_VEC37,
15460
- kick_origin: player?.client?.kick_origin ?? ZERO_VEC37,
15461
- gunoffset: ZERO_VEC37,
15462
- gunangles: ZERO_VEC37,
16163
+ kick_angles: player?.client?.kick_angles ?? ZERO_VEC36,
16164
+ kick_origin: player?.client?.kick_origin ?? ZERO_VEC36,
16165
+ gunoffset: ZERO_VEC36,
16166
+ gunangles: ZERO_VEC36,
15463
16167
  gunindex: 0,
15464
16168
  gun_frame: player?.client?.gun_frame ?? 0,
15465
16169
  rdflags: player?.client?.rdflags ?? 0,
@@ -15473,8 +16177,8 @@ function createGame(imports, engine, options) {
15473
16177
  const resetState = (startTimeMs) => {
15474
16178
  frameLoop.reset(startTimeMs);
15475
16179
  levelClock.start(startTimeMs);
15476
- origin = { ...ZERO_VEC37 };
15477
- velocity = { ...ZERO_VEC37 };
16180
+ origin = { ...ZERO_VEC36 };
16181
+ velocity = { ...ZERO_VEC36 };
15478
16182
  entities.beginFrame(startTimeMs / 1e3);
15479
16183
  entities.runFrame();
15480
16184
  };
@@ -15502,10 +16206,10 @@ function createGame(imports, engine, options) {
15502
16206
  blend: [0, 0, 0, 0],
15503
16207
  // Stubs
15504
16208
  stats: populatePlayerStats(player, levelClock.current.timeSeconds),
15505
- kick_angles: ZERO_VEC37,
15506
- kick_origin: ZERO_VEC37,
15507
- gunoffset: ZERO_VEC37,
15508
- gunangles: ZERO_VEC37,
16209
+ kick_angles: ZERO_VEC36,
16210
+ kick_origin: ZERO_VEC36,
16211
+ gunoffset: ZERO_VEC36,
16212
+ gunangles: ZERO_VEC36,
15509
16213
  gunindex: 0,
15510
16214
  pm_type: 0,
15511
16215
  pm_time: 0,
@@ -15563,6 +16267,9 @@ function createGame(imports, engine, options) {
15563
16267
  player.die = (self, inflictor, attacker, damage, point, mod) => {
15564
16268
  player_die(self, inflictor, attacker, damage, point, mod, entities);
15565
16269
  };
16270
+ player.pain = (self, other, kick, damage) => {
16271
+ player_pain(self, damage);
16272
+ };
15566
16273
  player.think = (self) => {
15567
16274
  player_think(self, entities);
15568
16275
  };
@@ -15632,8 +16339,8 @@ function createGame(imports, engine, options) {
15632
16339
  rng,
15633
16340
  player: player?.client?.inventory
15634
16341
  });
15635
- origin = player ? { ...player.origin } : { ...ZERO_VEC37 };
15636
- velocity = player ? { ...player.velocity } : { ...ZERO_VEC37 };
16342
+ origin = player ? { ...player.origin } : { ...ZERO_VEC36 };
16343
+ velocity = player ? { ...player.velocity } : { ...ZERO_VEC36 };
15637
16344
  frameLoop.reset(save.level.timeSeconds * 1e3);
15638
16345
  }
15639
16346
  };