quake2ts 0.0.505 → 0.0.506
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.
- package/package.json +1 -1
- package/packages/client/dist/browser/index.global.js +17 -17
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/browser/index.global.js +5 -5
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs +126 -99
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +126 -99
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/combat/weapons/firing.d.ts.map +1 -1
- package/packages/game/dist/types/entities/items/common.d.ts.map +1 -1
|
@@ -8736,12 +8736,12 @@ function registerTriggerSpawns(registry) {
|
|
|
8736
8736
|
}
|
|
8737
8737
|
|
|
8738
8738
|
// src/combat/weapons/state.ts
|
|
8739
|
-
var WeaponStateEnum = /* @__PURE__ */ ((
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
return
|
|
8739
|
+
var WeaponStateEnum = /* @__PURE__ */ ((WeaponStateEnum3) => {
|
|
8740
|
+
WeaponStateEnum3[WeaponStateEnum3["WEAPON_READY"] = 0] = "WEAPON_READY";
|
|
8741
|
+
WeaponStateEnum3[WeaponStateEnum3["WEAPON_ACTIVATING"] = 1] = "WEAPON_ACTIVATING";
|
|
8742
|
+
WeaponStateEnum3[WeaponStateEnum3["WEAPON_DROPPING"] = 2] = "WEAPON_DROPPING";
|
|
8743
|
+
WeaponStateEnum3[WeaponStateEnum3["WEAPON_FIRING"] = 3] = "WEAPON_FIRING";
|
|
8744
|
+
return WeaponStateEnum3;
|
|
8745
8745
|
})(WeaponStateEnum || {});
|
|
8746
8746
|
function createPlayerWeaponStates() {
|
|
8747
8747
|
return {
|
|
@@ -8846,6 +8846,106 @@ var ANIM_ATTACK = 1;
|
|
|
8846
8846
|
var ANIM_PAIN = 2;
|
|
8847
8847
|
var ANIM_DEATH = 3;
|
|
8848
8848
|
|
|
8849
|
+
// src/combat/weapons/switching.ts
|
|
8850
|
+
var instantSwitch = false;
|
|
8851
|
+
function getWeaponIdleLastFrame(weaponId) {
|
|
8852
|
+
switch (weaponId) {
|
|
8853
|
+
case WeaponId.HandGrenade:
|
|
8854
|
+
return FRAME_GRENADE_IDLE_LAST;
|
|
8855
|
+
case WeaponId.Shotgun:
|
|
8856
|
+
return FRAME_SHOTGUN_IDLE_LAST;
|
|
8857
|
+
case WeaponId.SuperShotgun:
|
|
8858
|
+
return FRAME_SSHOTGUN_IDLE_LAST;
|
|
8859
|
+
case WeaponId.Machinegun:
|
|
8860
|
+
return FRAME_MACHINEGUN_IDLE_LAST;
|
|
8861
|
+
case WeaponId.Chaingun:
|
|
8862
|
+
return FRAME_CHAINGUN_IDLE_LAST;
|
|
8863
|
+
case WeaponId.Railgun:
|
|
8864
|
+
return FRAME_RAILGUN_IDLE_LAST;
|
|
8865
|
+
case WeaponId.RocketLauncher:
|
|
8866
|
+
return FRAME_ROCKET_IDLE_LAST;
|
|
8867
|
+
case WeaponId.HyperBlaster:
|
|
8868
|
+
return FRAME_HYPERBLASTER_IDLE_LAST;
|
|
8869
|
+
case WeaponId.BFG10K:
|
|
8870
|
+
return FRAME_BFG_IDLE_LAST;
|
|
8871
|
+
case WeaponId.GrenadeLauncher:
|
|
8872
|
+
return FRAME_GRENADELAUNCHER_IDLE_LAST;
|
|
8873
|
+
case WeaponId.Blaster:
|
|
8874
|
+
return FRAME_BLASTER_IDLE_LAST;
|
|
8875
|
+
default:
|
|
8876
|
+
return 0;
|
|
8877
|
+
}
|
|
8878
|
+
}
|
|
8879
|
+
function ChangeWeapon(ent, weaponId) {
|
|
8880
|
+
if (!ent.client) return;
|
|
8881
|
+
const client = ent.client;
|
|
8882
|
+
if (weaponId) {
|
|
8883
|
+
if (client.weaponstate === 2 /* WEAPON_DROPPING */) {
|
|
8884
|
+
client.newWeapon = weaponId;
|
|
8885
|
+
return;
|
|
8886
|
+
}
|
|
8887
|
+
if (client.weaponstate === 0 /* WEAPON_READY */ || client.weaponstate === 3 /* WEAPON_FIRING */) {
|
|
8888
|
+
client.newWeapon = weaponId;
|
|
8889
|
+
client.weaponstate = 2 /* WEAPON_DROPPING */;
|
|
8890
|
+
if (client.inventory.currentWeapon) {
|
|
8891
|
+
client.gun_frame = getWeaponIdleLastFrame(client.inventory.currentWeapon) + 1;
|
|
8892
|
+
} else {
|
|
8893
|
+
client.gun_frame = 0;
|
|
8894
|
+
}
|
|
8895
|
+
if (instantSwitch) {
|
|
8896
|
+
selectWeapon(client.inventory, weaponId);
|
|
8897
|
+
client.weaponstate = 0 /* WEAPON_READY */;
|
|
8898
|
+
client.weapon_think_time = 0;
|
|
8899
|
+
client.newWeapon = void 0;
|
|
8900
|
+
}
|
|
8901
|
+
return;
|
|
8902
|
+
}
|
|
8903
|
+
client.newWeapon = weaponId;
|
|
8904
|
+
return;
|
|
8905
|
+
}
|
|
8906
|
+
if (client.newWeapon) {
|
|
8907
|
+
selectWeapon(client.inventory, client.newWeapon);
|
|
8908
|
+
client.weaponstate = 1 /* WEAPON_ACTIVATING */;
|
|
8909
|
+
client.gun_frame = 0;
|
|
8910
|
+
client.weapon_think_time = 0;
|
|
8911
|
+
client.newWeapon = void 0;
|
|
8912
|
+
}
|
|
8913
|
+
}
|
|
8914
|
+
function NoAmmoWeaponChange(ent) {
|
|
8915
|
+
if (!ent.client) return;
|
|
8916
|
+
const bestWeapon = getBestWeapon(ent);
|
|
8917
|
+
if (bestWeapon && bestWeapon !== ent.client.inventory.currentWeapon) {
|
|
8918
|
+
ChangeWeapon(ent, bestWeapon);
|
|
8919
|
+
}
|
|
8920
|
+
}
|
|
8921
|
+
function getBestWeapon(player) {
|
|
8922
|
+
if (!player.client) {
|
|
8923
|
+
return null;
|
|
8924
|
+
}
|
|
8925
|
+
const inventory = player.client.inventory;
|
|
8926
|
+
if (inventory.ownedWeapons.has(WeaponId.BFG10K) && inventory.ammo.counts[AmmoType.Cells] >= 50) {
|
|
8927
|
+
return WeaponId.BFG10K;
|
|
8928
|
+
} else if (inventory.ownedWeapons.has(WeaponId.RocketLauncher) && inventory.ammo.counts[AmmoType.Rockets] >= 1) {
|
|
8929
|
+
return WeaponId.RocketLauncher;
|
|
8930
|
+
} else if (inventory.ownedWeapons.has(WeaponId.HyperBlaster) && inventory.ammo.counts[AmmoType.Cells] >= 1) {
|
|
8931
|
+
return WeaponId.HyperBlaster;
|
|
8932
|
+
} else if (inventory.ownedWeapons.has(WeaponId.Railgun) && inventory.ammo.counts[AmmoType.Slugs] >= 1) {
|
|
8933
|
+
return WeaponId.Railgun;
|
|
8934
|
+
} else if (inventory.ownedWeapons.has(WeaponId.Chaingun) && inventory.ammo.counts[AmmoType.Bullets] >= 1) {
|
|
8935
|
+
return WeaponId.Chaingun;
|
|
8936
|
+
} else if (inventory.ownedWeapons.has(WeaponId.GrenadeLauncher) && inventory.ammo.counts[AmmoType.Grenades] >= 1) {
|
|
8937
|
+
return WeaponId.GrenadeLauncher;
|
|
8938
|
+
} else if (inventory.ownedWeapons.has(WeaponId.SuperShotgun) && inventory.ammo.counts[AmmoType.Shells] >= 2) {
|
|
8939
|
+
return WeaponId.SuperShotgun;
|
|
8940
|
+
} else if (inventory.ownedWeapons.has(WeaponId.Machinegun) && inventory.ammo.counts[AmmoType.Bullets] >= 1) {
|
|
8941
|
+
return WeaponId.Machinegun;
|
|
8942
|
+
} else if (inventory.ownedWeapons.has(WeaponId.Shotgun) && inventory.ammo.counts[AmmoType.Shells] >= 1) {
|
|
8943
|
+
return WeaponId.Shotgun;
|
|
8944
|
+
} else {
|
|
8945
|
+
return WeaponId.Blaster;
|
|
8946
|
+
}
|
|
8947
|
+
}
|
|
8948
|
+
|
|
8849
8949
|
// src/combat/weapons/firing.ts
|
|
8850
8950
|
var random3 = createRandomGenerator();
|
|
8851
8951
|
var DEFAULT_SHOTGUN_HSPREAD = 500;
|
|
@@ -8874,6 +8974,15 @@ function setPlayerAttackAnim(player) {
|
|
|
8874
8974
|
player.client.anim_end = FRAME_attack8;
|
|
8875
8975
|
}
|
|
8876
8976
|
}
|
|
8977
|
+
function checkAmmo(game, player, ammoType, count) {
|
|
8978
|
+
if (!player.client) return false;
|
|
8979
|
+
if (player.client.inventory.ammo.counts[ammoType] < count) {
|
|
8980
|
+
game.sound(player, 0, "weapons/noammo.wav", 1, ATTN_NORM, 0);
|
|
8981
|
+
NoAmmoWeaponChange(player);
|
|
8982
|
+
return false;
|
|
8983
|
+
}
|
|
8984
|
+
return true;
|
|
8985
|
+
}
|
|
8877
8986
|
function fireHitscan(game, player, start, forward, damage, knockback, mod) {
|
|
8878
8987
|
const end = { x: start.x + forward.x * 8192, y: start.y + forward.y * 8192, z: start.z + forward.z * 8192 };
|
|
8879
8988
|
if (game.setLagCompensation && player.client) {
|
|
@@ -9008,9 +9117,7 @@ function fireRailgun(game, player, start, forward, damage, knockback) {
|
|
|
9008
9117
|
function fireShotgun(game, player) {
|
|
9009
9118
|
if (!player.client) return;
|
|
9010
9119
|
const inventory = player.client.inventory;
|
|
9011
|
-
if (
|
|
9012
|
-
return;
|
|
9013
|
-
}
|
|
9120
|
+
if (!checkAmmo(game, player, AmmoType.Shells, 1)) return;
|
|
9014
9121
|
inventory.ammo.counts[AmmoType.Shells]--;
|
|
9015
9122
|
game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_SHOTGUN);
|
|
9016
9123
|
applyKick(player, -2, 0, -2);
|
|
@@ -9023,9 +9130,7 @@ function fireShotgun(game, player) {
|
|
|
9023
9130
|
function fireSuperShotgun(game, player) {
|
|
9024
9131
|
if (!player.client) return;
|
|
9025
9132
|
const inventory = player.client.inventory;
|
|
9026
|
-
if (
|
|
9027
|
-
return;
|
|
9028
|
-
}
|
|
9133
|
+
if (!checkAmmo(game, player, AmmoType.Shells, 2)) return;
|
|
9029
9134
|
const isPrecision = (player.client.buttons & BUTTON_ATTACK2) !== 0;
|
|
9030
9135
|
inventory.ammo.counts[AmmoType.Shells] -= 2;
|
|
9031
9136
|
game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_SSHOTGUN);
|
|
@@ -9050,9 +9155,7 @@ function fireSuperShotgun(game, player) {
|
|
|
9050
9155
|
function fireMachinegun(game, player) {
|
|
9051
9156
|
if (!player.client) return;
|
|
9052
9157
|
const inventory = player.client.inventory;
|
|
9053
|
-
if (
|
|
9054
|
-
return;
|
|
9055
|
-
}
|
|
9158
|
+
if (!checkAmmo(game, player, AmmoType.Bullets, 1)) return;
|
|
9056
9159
|
inventory.ammo.counts[AmmoType.Bullets]--;
|
|
9057
9160
|
game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_MACHINEGUN);
|
|
9058
9161
|
applyKick(player, -1, random3.crandom() * 0.5, 0);
|
|
@@ -9088,6 +9191,7 @@ function fireChaingun(game, player) {
|
|
|
9088
9191
|
shots = inventory.ammo.counts[AmmoType.Bullets];
|
|
9089
9192
|
}
|
|
9090
9193
|
if (shots === 0) {
|
|
9194
|
+
if (!checkAmmo(game, player, AmmoType.Bullets, 1)) return;
|
|
9091
9195
|
return;
|
|
9092
9196
|
}
|
|
9093
9197
|
inventory.ammo.counts[AmmoType.Bullets] -= shots;
|
|
@@ -9112,9 +9216,7 @@ function fireChaingun(game, player) {
|
|
|
9112
9216
|
function fireRailgunShot(game, player) {
|
|
9113
9217
|
if (!player.client) return;
|
|
9114
9218
|
const inventory = player.client.inventory;
|
|
9115
|
-
if (
|
|
9116
|
-
return;
|
|
9117
|
-
}
|
|
9219
|
+
if (!checkAmmo(game, player, AmmoType.Slugs, 1)) return;
|
|
9118
9220
|
inventory.ammo.counts[AmmoType.Slugs]--;
|
|
9119
9221
|
game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_RAILGUN);
|
|
9120
9222
|
applyKick(player, -3, 0, -3);
|
|
@@ -9128,9 +9230,7 @@ function fireRailgunShot(game, player) {
|
|
|
9128
9230
|
function fireHyperBlaster(game, player) {
|
|
9129
9231
|
if (!player.client) return;
|
|
9130
9232
|
const inventory = player.client.inventory;
|
|
9131
|
-
if (
|
|
9132
|
-
return;
|
|
9133
|
-
}
|
|
9233
|
+
if (!checkAmmo(game, player, AmmoType.Cells, 1)) return;
|
|
9134
9234
|
inventory.ammo.counts[AmmoType.Cells]--;
|
|
9135
9235
|
game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_HYPERBLASTER);
|
|
9136
9236
|
applyKick(player, -0.5, 0, 0);
|
|
@@ -9189,9 +9289,7 @@ function fireBlaster(game, player) {
|
|
|
9189
9289
|
function fireRocket(game, player) {
|
|
9190
9290
|
if (!player.client) return;
|
|
9191
9291
|
const inventory = player.client.inventory;
|
|
9192
|
-
if (
|
|
9193
|
-
return;
|
|
9194
|
-
}
|
|
9292
|
+
if (!checkAmmo(game, player, AmmoType.Rockets, 1)) return;
|
|
9195
9293
|
inventory.ammo.counts[AmmoType.Rockets]--;
|
|
9196
9294
|
game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_ROCKET);
|
|
9197
9295
|
applyKick(player, -2, 0, -2);
|
|
@@ -9209,9 +9307,7 @@ function fireRocket(game, player) {
|
|
|
9209
9307
|
function fireGrenadeLauncher(game, player, timer) {
|
|
9210
9308
|
if (!player.client) return;
|
|
9211
9309
|
const inventory = player.client.inventory;
|
|
9212
|
-
if (
|
|
9213
|
-
return;
|
|
9214
|
-
}
|
|
9310
|
+
if (!checkAmmo(game, player, AmmoType.Grenades, 1)) return;
|
|
9215
9311
|
inventory.ammo.counts[AmmoType.Grenades]--;
|
|
9216
9312
|
game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_GRENADE);
|
|
9217
9313
|
applyKick(player, -2, 0, -2);
|
|
@@ -9223,9 +9319,7 @@ function fireGrenadeLauncher(game, player, timer) {
|
|
|
9223
9319
|
function fireHyperBlasterBeam(game, player, weaponState) {
|
|
9224
9320
|
if (!player.client) return;
|
|
9225
9321
|
const inventory = player.client.inventory;
|
|
9226
|
-
if (
|
|
9227
|
-
return;
|
|
9228
|
-
}
|
|
9322
|
+
if (!checkAmmo(game, player, AmmoType.Cells, 2)) return;
|
|
9229
9323
|
if ((weaponState.heat || 0) > 20) {
|
|
9230
9324
|
game.sound(player, 0, "weapons/lashit.wav", 1, 1, 0);
|
|
9231
9325
|
return;
|
|
@@ -9273,9 +9367,7 @@ function fireBFG(game, player) {
|
|
|
9273
9367
|
const isPrimeFrame = gun_frame === 9 || gun_frame === 0 || gun_frame === void 0;
|
|
9274
9368
|
const isFireFrame = gun_frame === 22 || gun_frame === 0 || gun_frame === void 0;
|
|
9275
9369
|
if (isPrimeFrame) {
|
|
9276
|
-
if (
|
|
9277
|
-
return;
|
|
9278
|
-
}
|
|
9370
|
+
if (!checkAmmo(game, player, AmmoType.Cells, 50)) return;
|
|
9279
9371
|
inventory.ammo.counts[AmmoType.Cells] -= 50;
|
|
9280
9372
|
game.sound(player, 0, "weapons/bfg__f1y.wav", 1, 0, 0);
|
|
9281
9373
|
}
|
|
@@ -9291,72 +9383,6 @@ function fireBFG(game, player) {
|
|
|
9291
9383
|
}
|
|
9292
9384
|
}
|
|
9293
9385
|
|
|
9294
|
-
// src/combat/weapons/switching.ts
|
|
9295
|
-
var instantSwitch = false;
|
|
9296
|
-
function getWeaponIdleLastFrame(weaponId) {
|
|
9297
|
-
switch (weaponId) {
|
|
9298
|
-
case WeaponId.HandGrenade:
|
|
9299
|
-
return FRAME_GRENADE_IDLE_LAST;
|
|
9300
|
-
case WeaponId.Shotgun:
|
|
9301
|
-
return FRAME_SHOTGUN_IDLE_LAST;
|
|
9302
|
-
case WeaponId.SuperShotgun:
|
|
9303
|
-
return FRAME_SSHOTGUN_IDLE_LAST;
|
|
9304
|
-
case WeaponId.Machinegun:
|
|
9305
|
-
return FRAME_MACHINEGUN_IDLE_LAST;
|
|
9306
|
-
case WeaponId.Chaingun:
|
|
9307
|
-
return FRAME_CHAINGUN_IDLE_LAST;
|
|
9308
|
-
case WeaponId.Railgun:
|
|
9309
|
-
return FRAME_RAILGUN_IDLE_LAST;
|
|
9310
|
-
case WeaponId.RocketLauncher:
|
|
9311
|
-
return FRAME_ROCKET_IDLE_LAST;
|
|
9312
|
-
case WeaponId.HyperBlaster:
|
|
9313
|
-
return FRAME_HYPERBLASTER_IDLE_LAST;
|
|
9314
|
-
case WeaponId.BFG10K:
|
|
9315
|
-
return FRAME_BFG_IDLE_LAST;
|
|
9316
|
-
case WeaponId.GrenadeLauncher:
|
|
9317
|
-
return FRAME_GRENADELAUNCHER_IDLE_LAST;
|
|
9318
|
-
case WeaponId.Blaster:
|
|
9319
|
-
return FRAME_BLASTER_IDLE_LAST;
|
|
9320
|
-
default:
|
|
9321
|
-
return 0;
|
|
9322
|
-
}
|
|
9323
|
-
}
|
|
9324
|
-
function ChangeWeapon(ent, weaponId) {
|
|
9325
|
-
if (!ent.client) return;
|
|
9326
|
-
const client = ent.client;
|
|
9327
|
-
if (weaponId) {
|
|
9328
|
-
if (client.weaponstate === 2 /* WEAPON_DROPPING */) {
|
|
9329
|
-
client.newWeapon = weaponId;
|
|
9330
|
-
return;
|
|
9331
|
-
}
|
|
9332
|
-
if (client.weaponstate === 0 /* WEAPON_READY */ || client.weaponstate === 3 /* WEAPON_FIRING */) {
|
|
9333
|
-
client.newWeapon = weaponId;
|
|
9334
|
-
client.weaponstate = 2 /* WEAPON_DROPPING */;
|
|
9335
|
-
if (client.inventory.currentWeapon) {
|
|
9336
|
-
client.gun_frame = getWeaponIdleLastFrame(client.inventory.currentWeapon) + 1;
|
|
9337
|
-
} else {
|
|
9338
|
-
client.gun_frame = 0;
|
|
9339
|
-
}
|
|
9340
|
-
if (instantSwitch) {
|
|
9341
|
-
selectWeapon(client.inventory, weaponId);
|
|
9342
|
-
client.weaponstate = 0 /* WEAPON_READY */;
|
|
9343
|
-
client.weapon_think_time = 0;
|
|
9344
|
-
client.newWeapon = void 0;
|
|
9345
|
-
}
|
|
9346
|
-
return;
|
|
9347
|
-
}
|
|
9348
|
-
client.newWeapon = weaponId;
|
|
9349
|
-
return;
|
|
9350
|
-
}
|
|
9351
|
-
if (client.newWeapon) {
|
|
9352
|
-
selectWeapon(client.inventory, client.newWeapon);
|
|
9353
|
-
client.weaponstate = 1 /* WEAPON_ACTIVATING */;
|
|
9354
|
-
client.gun_frame = 0;
|
|
9355
|
-
client.weapon_think_time = 0;
|
|
9356
|
-
client.newWeapon = void 0;
|
|
9357
|
-
}
|
|
9358
|
-
}
|
|
9359
|
-
|
|
9360
9386
|
// src/combat/weapons/common.ts
|
|
9361
9387
|
function applyKick2(player, pitch, yaw = 0, kickOrigin = 0) {
|
|
9362
9388
|
if (player.client) {
|
|
@@ -10588,6 +10614,7 @@ function createItemRespawnFunction(game, originalModel) {
|
|
|
10588
10614
|
self.modelindex = cachedIndex;
|
|
10589
10615
|
self.svflags &= ~1 /* NoClient */;
|
|
10590
10616
|
game.multicast(self.origin, 1 /* Pvs */, ServerCommand.sound, 0, "items/respawn.wav", 1, 0, 0);
|
|
10617
|
+
game.multicast(self.origin, 1 /* Pvs */, ServerCommand.temp_entity, TempEntity.TELEPORT_EFFECT, self.origin);
|
|
10591
10618
|
};
|
|
10592
10619
|
}
|
|
10593
10620
|
|