quake2ts 0.0.505 → 0.0.507

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.
@@ -2384,6 +2384,10 @@ function pickupPowerup(client, item, time) {
2384
2384
  powerupId = PowerupId.DoubleDamage;
2385
2385
  icon = "p_double";
2386
2386
  break;
2387
+ case "item_invisibility":
2388
+ powerupId = PowerupId.Invisibility;
2389
+ icon = "p_invisibility";
2390
+ break;
2387
2391
  }
2388
2392
  if (powerupId) {
2389
2393
  const expiresAt = inventory.powerups.get(powerupId);
@@ -2399,6 +2403,9 @@ function pickupPowerup(client, item, time) {
2399
2403
  client.enviro_time = newExpiresAt / 1e3;
2400
2404
  } else if (powerupId === PowerupId.Rebreather) {
2401
2405
  client.breather_time = newExpiresAt / 1e3;
2406
+ } else if (powerupId === PowerupId.Invisibility) {
2407
+ client.invisible_time = newExpiresAt / 1e3;
2408
+ client.invisibility_fade_time = newExpiresAt / 1e3 - 3;
2402
2409
  }
2403
2410
  setPickup(inventory, icon, time);
2404
2411
  return true;
@@ -3153,6 +3160,20 @@ function visible(self, other, trace, options) {
3153
3160
  if ((other.flags & FL_NOVISIBLE) !== 0) {
3154
3161
  return false;
3155
3162
  }
3163
+ if (other.client && options?.timeSeconds !== void 0) {
3164
+ if (other.client.invisible_time && other.client.invisible_time > options.timeSeconds) {
3165
+ if (other.client.invisibility_fade_time && options.timeSeconds < other.client.invisibility_fade_time) {
3166
+ return false;
3167
+ }
3168
+ if (options.random) {
3169
+ if (other.alpha !== void 0) {
3170
+ if (options.random() > other.alpha) {
3171
+ return false;
3172
+ }
3173
+ }
3174
+ }
3175
+ }
3176
+ }
3156
3177
  const start = { x: self.origin.x, y: self.origin.y, z: self.origin.z + self.viewheight };
3157
3178
  const end = { x: other.origin.x, y: other.origin.y, z: other.origin.z + other.viewheight };
3158
3179
  const mask = options?.throughGlass ? 1 /* Opaque */ : 1 /* Opaque */ | 2 /* Window */;
@@ -3357,13 +3378,13 @@ function foundTarget(self, level, context, options) {
3357
3378
  self.monsterinfo.pausetime = 0;
3358
3379
  self.monsterinfo.run?.(self, context);
3359
3380
  }
3360
- function classifyClientVisibility(self, other, level, trace) {
3381
+ function classifyClientVisibility(self, other, level, trace, random5) {
3361
3382
  const distance4 = rangeTo(self, other);
3362
3383
  const range = classifyRange(distance4);
3363
3384
  if (range === "far" /* Far */) return false;
3364
3385
  if (other.light_level <= 5) return false;
3365
3386
  if ((self.monsterinfo.aiflags & 1048576 /* ThirdEye */) === 0) {
3366
- if (!visible(self, other, trace, { throughGlass: false })) return false;
3387
+ if (!visible(self, other, trace, { throughGlass: false, timeSeconds: level.timeSeconds, random: random5 })) return false;
3367
3388
  }
3368
3389
  if (range === "near" /* Near */) {
3369
3390
  return level.timeSeconds <= other.show_hostile || infront(self, other);
@@ -3388,15 +3409,15 @@ function AI_GetSightClient(self, context, trace) {
3388
3409
  if ((self.monsterinfo.aiflags & 1048576 /* ThirdEye */) !== 0) {
3389
3410
  return ent;
3390
3411
  }
3391
- if (visible(self, ent, trace, { throughGlass: false })) {
3412
+ if (visible(self, ent, trace, { throughGlass: false, timeSeconds: context.timeSeconds, random: () => context.rng.frandom() })) {
3392
3413
  return ent;
3393
3414
  }
3394
3415
  }
3395
3416
  return null;
3396
3417
  }
3397
- function updateSoundChase(self, client, level, hearability, trace) {
3418
+ function updateSoundChase(self, client, level, hearability, trace, context) {
3398
3419
  if ((self.spawnflags & SPAWNFLAG_MONSTER_AMBUSH) !== 0) {
3399
- if (!visible(self, client, trace)) return false;
3420
+ if (!visible(self, client, trace, { timeSeconds: level.timeSeconds, random: () => context.rng.frandom() })) return false;
3400
3421
  } else if (hearability.canHear && !hearability.canHear(self, client)) {
3401
3422
  return false;
3402
3423
  }
@@ -3456,12 +3477,12 @@ function findTarget(self, level, context, trace, hearability = {}) {
3456
3477
  return false;
3457
3478
  }
3458
3479
  if (!heardit) {
3459
- if (!classifyClientVisibility(self, candidate, level, trace)) {
3480
+ if (!classifyClientVisibility(self, candidate, level, trace, () => context.rng.frandom())) {
3460
3481
  return false;
3461
3482
  }
3462
3483
  self.monsterinfo.aiflags &= ~4 /* SoundTarget */;
3463
3484
  self.enemy = candidate;
3464
- } else if (!updateSoundChase(self, candidate, level, hearability, trace)) {
3485
+ } else if (!updateSoundChase(self, candidate, level, hearability, trace, context)) {
3465
3486
  return false;
3466
3487
  }
3467
3488
  foundTarget(self, level, context);
@@ -3483,8 +3504,8 @@ function findCover(self, context) {
3483
3504
  for (const spot of spots) {
3484
3505
  if (spot.owner) continue;
3485
3506
  if (spot.targetname) continue;
3486
- if (!visible(self, spot, context.trace, { throughGlass: false })) continue;
3487
- if (visible(spot, self.enemy, context.trace, { throughGlass: false })) continue;
3507
+ if (!visible(self, spot, context.trace, { throughGlass: false, timeSeconds: context.timeSeconds, random: () => context.rng.frandom() })) continue;
3508
+ if (visible(spot, self.enemy, context.trace, { throughGlass: false, timeSeconds: context.timeSeconds, random: () => context.rng.frandom() })) continue;
3488
3509
  self.goalentity = spot;
3489
3510
  self.movetarget = spot;
3490
3511
  setIdealYawTowards(self, spot);
@@ -3646,13 +3667,13 @@ function ai_run(self, dist, context) {
3646
3667
  setIdealYawTowards2(self, self.enemy ?? self.goalentity);
3647
3668
  }
3648
3669
  changeYaw(self, MONSTER_TICK);
3649
- if (self.enemy && self.enemy.inUse && visible(self, self.enemy, context.trace, { throughGlass: false })) {
3670
+ if (self.enemy && self.enemy.inUse && visible(self, self.enemy, context.trace, { throughGlass: false, timeSeconds: context.timeSeconds, random: () => context.rng.frandom() })) {
3650
3671
  self.monsterinfo.blind_fire_target = addVec3(self.enemy.origin, scaleVec3(self.enemy.velocity, -0.1));
3651
3672
  }
3652
3673
  if (ai_checkattack(self, dist, context)) {
3653
3674
  return;
3654
3675
  }
3655
- const enemy_vis = self.enemy && visible(self, self.enemy, context.trace, { throughGlass: false });
3676
+ const enemy_vis = self.enemy && visible(self, self.enemy, context.trace, { throughGlass: false, timeSeconds: context.timeSeconds, random: () => context.rng.frandom() });
3656
3677
  if (!enemy_vis && self.monsterinfo.attack_state === 1 /* Sliding */) {
3657
3678
  self.monsterinfo.attack_state = 0 /* Straight */;
3658
3679
  }
@@ -8937,12 +8958,12 @@ function registerTriggerSpawns(registry) {
8937
8958
  }
8938
8959
 
8939
8960
  // src/combat/weapons/state.ts
8940
- var WeaponStateEnum = /* @__PURE__ */ ((WeaponStateEnum2) => {
8941
- WeaponStateEnum2[WeaponStateEnum2["WEAPON_READY"] = 0] = "WEAPON_READY";
8942
- WeaponStateEnum2[WeaponStateEnum2["WEAPON_ACTIVATING"] = 1] = "WEAPON_ACTIVATING";
8943
- WeaponStateEnum2[WeaponStateEnum2["WEAPON_DROPPING"] = 2] = "WEAPON_DROPPING";
8944
- WeaponStateEnum2[WeaponStateEnum2["WEAPON_FIRING"] = 3] = "WEAPON_FIRING";
8945
- return WeaponStateEnum2;
8961
+ var WeaponStateEnum = /* @__PURE__ */ ((WeaponStateEnum3) => {
8962
+ WeaponStateEnum3[WeaponStateEnum3["WEAPON_READY"] = 0] = "WEAPON_READY";
8963
+ WeaponStateEnum3[WeaponStateEnum3["WEAPON_ACTIVATING"] = 1] = "WEAPON_ACTIVATING";
8964
+ WeaponStateEnum3[WeaponStateEnum3["WEAPON_DROPPING"] = 2] = "WEAPON_DROPPING";
8965
+ WeaponStateEnum3[WeaponStateEnum3["WEAPON_FIRING"] = 3] = "WEAPON_FIRING";
8966
+ return WeaponStateEnum3;
8946
8967
  })(WeaponStateEnum || {});
8947
8968
  function createPlayerWeaponStates() {
8948
8969
  return {
@@ -9047,6 +9068,106 @@ var ANIM_ATTACK = 1;
9047
9068
  var ANIM_PAIN = 2;
9048
9069
  var ANIM_DEATH = 3;
9049
9070
 
9071
+ // src/combat/weapons/switching.ts
9072
+ var instantSwitch = false;
9073
+ function getWeaponIdleLastFrame(weaponId) {
9074
+ switch (weaponId) {
9075
+ case WeaponId.HandGrenade:
9076
+ return FRAME_GRENADE_IDLE_LAST;
9077
+ case WeaponId.Shotgun:
9078
+ return FRAME_SHOTGUN_IDLE_LAST;
9079
+ case WeaponId.SuperShotgun:
9080
+ return FRAME_SSHOTGUN_IDLE_LAST;
9081
+ case WeaponId.Machinegun:
9082
+ return FRAME_MACHINEGUN_IDLE_LAST;
9083
+ case WeaponId.Chaingun:
9084
+ return FRAME_CHAINGUN_IDLE_LAST;
9085
+ case WeaponId.Railgun:
9086
+ return FRAME_RAILGUN_IDLE_LAST;
9087
+ case WeaponId.RocketLauncher:
9088
+ return FRAME_ROCKET_IDLE_LAST;
9089
+ case WeaponId.HyperBlaster:
9090
+ return FRAME_HYPERBLASTER_IDLE_LAST;
9091
+ case WeaponId.BFG10K:
9092
+ return FRAME_BFG_IDLE_LAST;
9093
+ case WeaponId.GrenadeLauncher:
9094
+ return FRAME_GRENADELAUNCHER_IDLE_LAST;
9095
+ case WeaponId.Blaster:
9096
+ return FRAME_BLASTER_IDLE_LAST;
9097
+ default:
9098
+ return 0;
9099
+ }
9100
+ }
9101
+ function ChangeWeapon(ent, weaponId) {
9102
+ if (!ent.client) return;
9103
+ const client = ent.client;
9104
+ if (weaponId) {
9105
+ if (client.weaponstate === 2 /* WEAPON_DROPPING */) {
9106
+ client.newWeapon = weaponId;
9107
+ return;
9108
+ }
9109
+ if (client.weaponstate === 0 /* WEAPON_READY */ || client.weaponstate === 3 /* WEAPON_FIRING */) {
9110
+ client.newWeapon = weaponId;
9111
+ client.weaponstate = 2 /* WEAPON_DROPPING */;
9112
+ if (client.inventory.currentWeapon) {
9113
+ client.gun_frame = getWeaponIdleLastFrame(client.inventory.currentWeapon) + 1;
9114
+ } else {
9115
+ client.gun_frame = 0;
9116
+ }
9117
+ if (instantSwitch) {
9118
+ selectWeapon(client.inventory, weaponId);
9119
+ client.weaponstate = 0 /* WEAPON_READY */;
9120
+ client.weapon_think_time = 0;
9121
+ client.newWeapon = void 0;
9122
+ }
9123
+ return;
9124
+ }
9125
+ client.newWeapon = weaponId;
9126
+ return;
9127
+ }
9128
+ if (client.newWeapon) {
9129
+ selectWeapon(client.inventory, client.newWeapon);
9130
+ client.weaponstate = 1 /* WEAPON_ACTIVATING */;
9131
+ client.gun_frame = 0;
9132
+ client.weapon_think_time = 0;
9133
+ client.newWeapon = void 0;
9134
+ }
9135
+ }
9136
+ function NoAmmoWeaponChange(ent) {
9137
+ if (!ent.client) return;
9138
+ const bestWeapon = getBestWeapon(ent);
9139
+ if (bestWeapon && bestWeapon !== ent.client.inventory.currentWeapon) {
9140
+ ChangeWeapon(ent, bestWeapon);
9141
+ }
9142
+ }
9143
+ function getBestWeapon(player) {
9144
+ if (!player.client) {
9145
+ return null;
9146
+ }
9147
+ const inventory = player.client.inventory;
9148
+ if (inventory.ownedWeapons.has(WeaponId.BFG10K) && inventory.ammo.counts[AmmoType.Cells] >= 50) {
9149
+ return WeaponId.BFG10K;
9150
+ } else if (inventory.ownedWeapons.has(WeaponId.RocketLauncher) && inventory.ammo.counts[AmmoType.Rockets] >= 1) {
9151
+ return WeaponId.RocketLauncher;
9152
+ } else if (inventory.ownedWeapons.has(WeaponId.HyperBlaster) && inventory.ammo.counts[AmmoType.Cells] >= 1) {
9153
+ return WeaponId.HyperBlaster;
9154
+ } else if (inventory.ownedWeapons.has(WeaponId.Railgun) && inventory.ammo.counts[AmmoType.Slugs] >= 1) {
9155
+ return WeaponId.Railgun;
9156
+ } else if (inventory.ownedWeapons.has(WeaponId.Chaingun) && inventory.ammo.counts[AmmoType.Bullets] >= 1) {
9157
+ return WeaponId.Chaingun;
9158
+ } else if (inventory.ownedWeapons.has(WeaponId.GrenadeLauncher) && inventory.ammo.counts[AmmoType.Grenades] >= 1) {
9159
+ return WeaponId.GrenadeLauncher;
9160
+ } else if (inventory.ownedWeapons.has(WeaponId.SuperShotgun) && inventory.ammo.counts[AmmoType.Shells] >= 2) {
9161
+ return WeaponId.SuperShotgun;
9162
+ } else if (inventory.ownedWeapons.has(WeaponId.Machinegun) && inventory.ammo.counts[AmmoType.Bullets] >= 1) {
9163
+ return WeaponId.Machinegun;
9164
+ } else if (inventory.ownedWeapons.has(WeaponId.Shotgun) && inventory.ammo.counts[AmmoType.Shells] >= 1) {
9165
+ return WeaponId.Shotgun;
9166
+ } else {
9167
+ return WeaponId.Blaster;
9168
+ }
9169
+ }
9170
+
9050
9171
  // src/combat/weapons/firing.ts
9051
9172
  var random3 = createRandomGenerator();
9052
9173
  var DEFAULT_SHOTGUN_HSPREAD = 500;
@@ -9075,6 +9196,15 @@ function setPlayerAttackAnim(player) {
9075
9196
  player.client.anim_end = FRAME_attack8;
9076
9197
  }
9077
9198
  }
9199
+ function checkAmmo(game, player, ammoType, count) {
9200
+ if (!player.client) return false;
9201
+ if (player.client.inventory.ammo.counts[ammoType] < count) {
9202
+ game.sound(player, 0, "weapons/noammo.wav", 1, ATTN_NORM, 0);
9203
+ NoAmmoWeaponChange(player);
9204
+ return false;
9205
+ }
9206
+ return true;
9207
+ }
9078
9208
  function fireHitscan(game, player, start, forward, damage, knockback, mod) {
9079
9209
  const end = { x: start.x + forward.x * 8192, y: start.y + forward.y * 8192, z: start.z + forward.z * 8192 };
9080
9210
  if (game.setLagCompensation && player.client) {
@@ -9209,9 +9339,7 @@ function fireRailgun(game, player, start, forward, damage, knockback) {
9209
9339
  function fireShotgun(game, player) {
9210
9340
  if (!player.client) return;
9211
9341
  const inventory = player.client.inventory;
9212
- if (inventory.ammo.counts[AmmoType.Shells] < 1) {
9213
- return;
9214
- }
9342
+ if (!checkAmmo(game, player, AmmoType.Shells, 1)) return;
9215
9343
  inventory.ammo.counts[AmmoType.Shells]--;
9216
9344
  game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_SHOTGUN);
9217
9345
  applyKick(player, -2, 0, -2);
@@ -9224,9 +9352,7 @@ function fireShotgun(game, player) {
9224
9352
  function fireSuperShotgun(game, player) {
9225
9353
  if (!player.client) return;
9226
9354
  const inventory = player.client.inventory;
9227
- if (inventory.ammo.counts[AmmoType.Shells] < 2) {
9228
- return;
9229
- }
9355
+ if (!checkAmmo(game, player, AmmoType.Shells, 2)) return;
9230
9356
  const isPrecision = (player.client.buttons & BUTTON_ATTACK2) !== 0;
9231
9357
  inventory.ammo.counts[AmmoType.Shells] -= 2;
9232
9358
  game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_SSHOTGUN);
@@ -9251,9 +9377,7 @@ function fireSuperShotgun(game, player) {
9251
9377
  function fireMachinegun(game, player) {
9252
9378
  if (!player.client) return;
9253
9379
  const inventory = player.client.inventory;
9254
- if (inventory.ammo.counts[AmmoType.Bullets] < 1) {
9255
- return;
9256
- }
9380
+ if (!checkAmmo(game, player, AmmoType.Bullets, 1)) return;
9257
9381
  inventory.ammo.counts[AmmoType.Bullets]--;
9258
9382
  game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_MACHINEGUN);
9259
9383
  applyKick(player, -1, random3.crandom() * 0.5, 0);
@@ -9289,6 +9413,7 @@ function fireChaingun(game, player) {
9289
9413
  shots = inventory.ammo.counts[AmmoType.Bullets];
9290
9414
  }
9291
9415
  if (shots === 0) {
9416
+ if (!checkAmmo(game, player, AmmoType.Bullets, 1)) return;
9292
9417
  return;
9293
9418
  }
9294
9419
  inventory.ammo.counts[AmmoType.Bullets] -= shots;
@@ -9313,9 +9438,7 @@ function fireChaingun(game, player) {
9313
9438
  function fireRailgunShot(game, player) {
9314
9439
  if (!player.client) return;
9315
9440
  const inventory = player.client.inventory;
9316
- if (inventory.ammo.counts[AmmoType.Slugs] < 1) {
9317
- return;
9318
- }
9441
+ if (!checkAmmo(game, player, AmmoType.Slugs, 1)) return;
9319
9442
  inventory.ammo.counts[AmmoType.Slugs]--;
9320
9443
  game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_RAILGUN);
9321
9444
  applyKick(player, -3, 0, -3);
@@ -9329,9 +9452,7 @@ function fireRailgunShot(game, player) {
9329
9452
  function fireHyperBlaster(game, player) {
9330
9453
  if (!player.client) return;
9331
9454
  const inventory = player.client.inventory;
9332
- if (inventory.ammo.counts[AmmoType.Cells] < 1) {
9333
- return;
9334
- }
9455
+ if (!checkAmmo(game, player, AmmoType.Cells, 1)) return;
9335
9456
  inventory.ammo.counts[AmmoType.Cells]--;
9336
9457
  game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_HYPERBLASTER);
9337
9458
  applyKick(player, -0.5, 0, 0);
@@ -9390,9 +9511,7 @@ function fireBlaster(game, player) {
9390
9511
  function fireRocket(game, player) {
9391
9512
  if (!player.client) return;
9392
9513
  const inventory = player.client.inventory;
9393
- if (inventory.ammo.counts[AmmoType.Rockets] < 1) {
9394
- return;
9395
- }
9514
+ if (!checkAmmo(game, player, AmmoType.Rockets, 1)) return;
9396
9515
  inventory.ammo.counts[AmmoType.Rockets]--;
9397
9516
  game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_ROCKET);
9398
9517
  applyKick(player, -2, 0, -2);
@@ -9410,9 +9529,7 @@ function fireRocket(game, player) {
9410
9529
  function fireGrenadeLauncher(game, player, timer) {
9411
9530
  if (!player.client) return;
9412
9531
  const inventory = player.client.inventory;
9413
- if (inventory.ammo.counts[AmmoType.Grenades] < 1) {
9414
- return;
9415
- }
9532
+ if (!checkAmmo(game, player, AmmoType.Grenades, 1)) return;
9416
9533
  inventory.ammo.counts[AmmoType.Grenades]--;
9417
9534
  game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_GRENADE);
9418
9535
  applyKick(player, -2, 0, -2);
@@ -9424,9 +9541,7 @@ function fireGrenadeLauncher(game, player, timer) {
9424
9541
  function fireHyperBlasterBeam(game, player, weaponState) {
9425
9542
  if (!player.client) return;
9426
9543
  const inventory = player.client.inventory;
9427
- if (inventory.ammo.counts[AmmoType.Cells] < 2) {
9428
- return;
9429
- }
9544
+ if (!checkAmmo(game, player, AmmoType.Cells, 2)) return;
9430
9545
  if ((weaponState.heat || 0) > 20) {
9431
9546
  game.sound(player, 0, "weapons/lashit.wav", 1, 1, 0);
9432
9547
  return;
@@ -9474,9 +9589,7 @@ function fireBFG(game, player) {
9474
9589
  const isPrimeFrame = gun_frame === 9 || gun_frame === 0 || gun_frame === void 0;
9475
9590
  const isFireFrame = gun_frame === 22 || gun_frame === 0 || gun_frame === void 0;
9476
9591
  if (isPrimeFrame) {
9477
- if (inventory.ammo.counts[AmmoType.Cells] < 50) {
9478
- return;
9479
- }
9592
+ if (!checkAmmo(game, player, AmmoType.Cells, 50)) return;
9480
9593
  inventory.ammo.counts[AmmoType.Cells] -= 50;
9481
9594
  game.sound(player, 0, "weapons/bfg__f1y.wav", 1, 0, 0);
9482
9595
  }
@@ -9492,72 +9605,6 @@ function fireBFG(game, player) {
9492
9605
  }
9493
9606
  }
9494
9607
 
9495
- // src/combat/weapons/switching.ts
9496
- var instantSwitch = false;
9497
- function getWeaponIdleLastFrame(weaponId) {
9498
- switch (weaponId) {
9499
- case WeaponId.HandGrenade:
9500
- return FRAME_GRENADE_IDLE_LAST;
9501
- case WeaponId.Shotgun:
9502
- return FRAME_SHOTGUN_IDLE_LAST;
9503
- case WeaponId.SuperShotgun:
9504
- return FRAME_SSHOTGUN_IDLE_LAST;
9505
- case WeaponId.Machinegun:
9506
- return FRAME_MACHINEGUN_IDLE_LAST;
9507
- case WeaponId.Chaingun:
9508
- return FRAME_CHAINGUN_IDLE_LAST;
9509
- case WeaponId.Railgun:
9510
- return FRAME_RAILGUN_IDLE_LAST;
9511
- case WeaponId.RocketLauncher:
9512
- return FRAME_ROCKET_IDLE_LAST;
9513
- case WeaponId.HyperBlaster:
9514
- return FRAME_HYPERBLASTER_IDLE_LAST;
9515
- case WeaponId.BFG10K:
9516
- return FRAME_BFG_IDLE_LAST;
9517
- case WeaponId.GrenadeLauncher:
9518
- return FRAME_GRENADELAUNCHER_IDLE_LAST;
9519
- case WeaponId.Blaster:
9520
- return FRAME_BLASTER_IDLE_LAST;
9521
- default:
9522
- return 0;
9523
- }
9524
- }
9525
- function ChangeWeapon(ent, weaponId) {
9526
- if (!ent.client) return;
9527
- const client = ent.client;
9528
- if (weaponId) {
9529
- if (client.weaponstate === 2 /* WEAPON_DROPPING */) {
9530
- client.newWeapon = weaponId;
9531
- return;
9532
- }
9533
- if (client.weaponstate === 0 /* WEAPON_READY */ || client.weaponstate === 3 /* WEAPON_FIRING */) {
9534
- client.newWeapon = weaponId;
9535
- client.weaponstate = 2 /* WEAPON_DROPPING */;
9536
- if (client.inventory.currentWeapon) {
9537
- client.gun_frame = getWeaponIdleLastFrame(client.inventory.currentWeapon) + 1;
9538
- } else {
9539
- client.gun_frame = 0;
9540
- }
9541
- if (instantSwitch) {
9542
- selectWeapon(client.inventory, weaponId);
9543
- client.weaponstate = 0 /* WEAPON_READY */;
9544
- client.weapon_think_time = 0;
9545
- client.newWeapon = void 0;
9546
- }
9547
- return;
9548
- }
9549
- client.newWeapon = weaponId;
9550
- return;
9551
- }
9552
- if (client.newWeapon) {
9553
- selectWeapon(client.inventory, client.newWeapon);
9554
- client.weaponstate = 1 /* WEAPON_ACTIVATING */;
9555
- client.gun_frame = 0;
9556
- client.weapon_think_time = 0;
9557
- client.newWeapon = void 0;
9558
- }
9559
- }
9560
-
9561
9608
  // src/combat/weapons/common.ts
9562
9609
  function applyKick2(player, pitch, yaw = 0, kickOrigin = 0) {
9563
9610
  if (player.client) {
@@ -10656,6 +10703,12 @@ var POWERUP_ITEMS = {
10656
10703
  id: "item_enviro",
10657
10704
  name: "Enviro Suit",
10658
10705
  timer: 30
10706
+ },
10707
+ "item_invisibility": {
10708
+ type: "powerup",
10709
+ id: "item_invisibility",
10710
+ name: "Invisibility",
10711
+ timer: 30
10659
10712
  }
10660
10713
  };
10661
10714
  var POWER_ARMOR_ITEMS = {
@@ -10789,6 +10842,7 @@ function createItemRespawnFunction(game, originalModel) {
10789
10842
  self.modelindex = cachedIndex;
10790
10843
  self.svflags &= ~1 /* NoClient */;
10791
10844
  game.multicast(self.origin, 1 /* Pvs */, ServerCommand.sound, 0, "items/respawn.wav", 1, 0, 0);
10845
+ game.multicast(self.origin, 1 /* Pvs */, ServerCommand.temp_entity, TempEntity.TELEPORT_EFFECT, self.origin);
10792
10846
  };
10793
10847
  }
10794
10848