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.
- 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/client/dist/tsconfig.tsbuildinfo +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 +164 -110
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +164 -110
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/ai/perception.d.ts +5 -2
- package/packages/game/dist/types/ai/perception.d.ts.map +1 -1
- package/packages/game/dist/types/ai/targeting.d.ts.map +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
- package/packages/game/dist/types/inventory/items.d.ts.map +1 -1
- package/packages/game/dist/types/inventory/playerInventory.d.ts +2 -0
- package/packages/game/dist/types/inventory/playerInventory.d.ts.map +1 -1
|
@@ -2183,6 +2183,10 @@ function pickupPowerup(client, item, time) {
|
|
|
2183
2183
|
powerupId = PowerupId.DoubleDamage;
|
|
2184
2184
|
icon = "p_double";
|
|
2185
2185
|
break;
|
|
2186
|
+
case "item_invisibility":
|
|
2187
|
+
powerupId = PowerupId.Invisibility;
|
|
2188
|
+
icon = "p_invisibility";
|
|
2189
|
+
break;
|
|
2186
2190
|
}
|
|
2187
2191
|
if (powerupId) {
|
|
2188
2192
|
const expiresAt = inventory.powerups.get(powerupId);
|
|
@@ -2198,6 +2202,9 @@ function pickupPowerup(client, item, time) {
|
|
|
2198
2202
|
client.enviro_time = newExpiresAt / 1e3;
|
|
2199
2203
|
} else if (powerupId === PowerupId.Rebreather) {
|
|
2200
2204
|
client.breather_time = newExpiresAt / 1e3;
|
|
2205
|
+
} else if (powerupId === PowerupId.Invisibility) {
|
|
2206
|
+
client.invisible_time = newExpiresAt / 1e3;
|
|
2207
|
+
client.invisibility_fade_time = newExpiresAt / 1e3 - 3;
|
|
2201
2208
|
}
|
|
2202
2209
|
setPickup(inventory, icon, time);
|
|
2203
2210
|
return true;
|
|
@@ -2952,6 +2959,20 @@ function visible(self, other, trace, options) {
|
|
|
2952
2959
|
if ((other.flags & FL_NOVISIBLE) !== 0) {
|
|
2953
2960
|
return false;
|
|
2954
2961
|
}
|
|
2962
|
+
if (other.client && options?.timeSeconds !== void 0) {
|
|
2963
|
+
if (other.client.invisible_time && other.client.invisible_time > options.timeSeconds) {
|
|
2964
|
+
if (other.client.invisibility_fade_time && options.timeSeconds < other.client.invisibility_fade_time) {
|
|
2965
|
+
return false;
|
|
2966
|
+
}
|
|
2967
|
+
if (options.random) {
|
|
2968
|
+
if (other.alpha !== void 0) {
|
|
2969
|
+
if (options.random() > other.alpha) {
|
|
2970
|
+
return false;
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2955
2976
|
const start = { x: self.origin.x, y: self.origin.y, z: self.origin.z + self.viewheight };
|
|
2956
2977
|
const end = { x: other.origin.x, y: other.origin.y, z: other.origin.z + other.viewheight };
|
|
2957
2978
|
const mask = options?.throughGlass ? 1 /* Opaque */ : 1 /* Opaque */ | 2 /* Window */;
|
|
@@ -3156,13 +3177,13 @@ function foundTarget(self, level, context, options) {
|
|
|
3156
3177
|
self.monsterinfo.pausetime = 0;
|
|
3157
3178
|
self.monsterinfo.run?.(self, context);
|
|
3158
3179
|
}
|
|
3159
|
-
function classifyClientVisibility(self, other, level, trace) {
|
|
3180
|
+
function classifyClientVisibility(self, other, level, trace, random5) {
|
|
3160
3181
|
const distance4 = rangeTo(self, other);
|
|
3161
3182
|
const range = classifyRange(distance4);
|
|
3162
3183
|
if (range === "far" /* Far */) return false;
|
|
3163
3184
|
if (other.light_level <= 5) return false;
|
|
3164
3185
|
if ((self.monsterinfo.aiflags & 1048576 /* ThirdEye */) === 0) {
|
|
3165
|
-
if (!visible(self, other, trace, { throughGlass: false })) return false;
|
|
3186
|
+
if (!visible(self, other, trace, { throughGlass: false, timeSeconds: level.timeSeconds, random: random5 })) return false;
|
|
3166
3187
|
}
|
|
3167
3188
|
if (range === "near" /* Near */) {
|
|
3168
3189
|
return level.timeSeconds <= other.show_hostile || infront(self, other);
|
|
@@ -3187,15 +3208,15 @@ function AI_GetSightClient(self, context, trace) {
|
|
|
3187
3208
|
if ((self.monsterinfo.aiflags & 1048576 /* ThirdEye */) !== 0) {
|
|
3188
3209
|
return ent;
|
|
3189
3210
|
}
|
|
3190
|
-
if (visible(self, ent, trace, { throughGlass: false })) {
|
|
3211
|
+
if (visible(self, ent, trace, { throughGlass: false, timeSeconds: context.timeSeconds, random: () => context.rng.frandom() })) {
|
|
3191
3212
|
return ent;
|
|
3192
3213
|
}
|
|
3193
3214
|
}
|
|
3194
3215
|
return null;
|
|
3195
3216
|
}
|
|
3196
|
-
function updateSoundChase(self, client, level, hearability, trace) {
|
|
3217
|
+
function updateSoundChase(self, client, level, hearability, trace, context) {
|
|
3197
3218
|
if ((self.spawnflags & SPAWNFLAG_MONSTER_AMBUSH) !== 0) {
|
|
3198
|
-
if (!visible(self, client, trace)) return false;
|
|
3219
|
+
if (!visible(self, client, trace, { timeSeconds: level.timeSeconds, random: () => context.rng.frandom() })) return false;
|
|
3199
3220
|
} else if (hearability.canHear && !hearability.canHear(self, client)) {
|
|
3200
3221
|
return false;
|
|
3201
3222
|
}
|
|
@@ -3255,12 +3276,12 @@ function findTarget(self, level, context, trace, hearability = {}) {
|
|
|
3255
3276
|
return false;
|
|
3256
3277
|
}
|
|
3257
3278
|
if (!heardit) {
|
|
3258
|
-
if (!classifyClientVisibility(self, candidate, level, trace)) {
|
|
3279
|
+
if (!classifyClientVisibility(self, candidate, level, trace, () => context.rng.frandom())) {
|
|
3259
3280
|
return false;
|
|
3260
3281
|
}
|
|
3261
3282
|
self.monsterinfo.aiflags &= ~4 /* SoundTarget */;
|
|
3262
3283
|
self.enemy = candidate;
|
|
3263
|
-
} else if (!updateSoundChase(self, candidate, level, hearability, trace)) {
|
|
3284
|
+
} else if (!updateSoundChase(self, candidate, level, hearability, trace, context)) {
|
|
3264
3285
|
return false;
|
|
3265
3286
|
}
|
|
3266
3287
|
foundTarget(self, level, context);
|
|
@@ -3282,8 +3303,8 @@ function findCover(self, context) {
|
|
|
3282
3303
|
for (const spot of spots) {
|
|
3283
3304
|
if (spot.owner) continue;
|
|
3284
3305
|
if (spot.targetname) continue;
|
|
3285
|
-
if (!visible(self, spot, context.trace, { throughGlass: false })) continue;
|
|
3286
|
-
if (visible(spot, self.enemy, context.trace, { throughGlass: false })) continue;
|
|
3306
|
+
if (!visible(self, spot, context.trace, { throughGlass: false, timeSeconds: context.timeSeconds, random: () => context.rng.frandom() })) continue;
|
|
3307
|
+
if (visible(spot, self.enemy, context.trace, { throughGlass: false, timeSeconds: context.timeSeconds, random: () => context.rng.frandom() })) continue;
|
|
3287
3308
|
self.goalentity = spot;
|
|
3288
3309
|
self.movetarget = spot;
|
|
3289
3310
|
setIdealYawTowards(self, spot);
|
|
@@ -3445,13 +3466,13 @@ function ai_run(self, dist, context) {
|
|
|
3445
3466
|
setIdealYawTowards2(self, self.enemy ?? self.goalentity);
|
|
3446
3467
|
}
|
|
3447
3468
|
changeYaw(self, MONSTER_TICK);
|
|
3448
|
-
if (self.enemy && self.enemy.inUse && visible(self, self.enemy, context.trace, { throughGlass: false })) {
|
|
3469
|
+
if (self.enemy && self.enemy.inUse && visible(self, self.enemy, context.trace, { throughGlass: false, timeSeconds: context.timeSeconds, random: () => context.rng.frandom() })) {
|
|
3449
3470
|
self.monsterinfo.blind_fire_target = addVec3(self.enemy.origin, scaleVec3(self.enemy.velocity, -0.1));
|
|
3450
3471
|
}
|
|
3451
3472
|
if (ai_checkattack(self, dist, context)) {
|
|
3452
3473
|
return;
|
|
3453
3474
|
}
|
|
3454
|
-
const enemy_vis = self.enemy && visible(self, self.enemy, context.trace, { throughGlass: false });
|
|
3475
|
+
const enemy_vis = self.enemy && visible(self, self.enemy, context.trace, { throughGlass: false, timeSeconds: context.timeSeconds, random: () => context.rng.frandom() });
|
|
3455
3476
|
if (!enemy_vis && self.monsterinfo.attack_state === 1 /* Sliding */) {
|
|
3456
3477
|
self.monsterinfo.attack_state = 0 /* Straight */;
|
|
3457
3478
|
}
|
|
@@ -8736,12 +8757,12 @@ function registerTriggerSpawns(registry) {
|
|
|
8736
8757
|
}
|
|
8737
8758
|
|
|
8738
8759
|
// src/combat/weapons/state.ts
|
|
8739
|
-
var WeaponStateEnum = /* @__PURE__ */ ((
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
return
|
|
8760
|
+
var WeaponStateEnum = /* @__PURE__ */ ((WeaponStateEnum3) => {
|
|
8761
|
+
WeaponStateEnum3[WeaponStateEnum3["WEAPON_READY"] = 0] = "WEAPON_READY";
|
|
8762
|
+
WeaponStateEnum3[WeaponStateEnum3["WEAPON_ACTIVATING"] = 1] = "WEAPON_ACTIVATING";
|
|
8763
|
+
WeaponStateEnum3[WeaponStateEnum3["WEAPON_DROPPING"] = 2] = "WEAPON_DROPPING";
|
|
8764
|
+
WeaponStateEnum3[WeaponStateEnum3["WEAPON_FIRING"] = 3] = "WEAPON_FIRING";
|
|
8765
|
+
return WeaponStateEnum3;
|
|
8745
8766
|
})(WeaponStateEnum || {});
|
|
8746
8767
|
function createPlayerWeaponStates() {
|
|
8747
8768
|
return {
|
|
@@ -8846,6 +8867,106 @@ var ANIM_ATTACK = 1;
|
|
|
8846
8867
|
var ANIM_PAIN = 2;
|
|
8847
8868
|
var ANIM_DEATH = 3;
|
|
8848
8869
|
|
|
8870
|
+
// src/combat/weapons/switching.ts
|
|
8871
|
+
var instantSwitch = false;
|
|
8872
|
+
function getWeaponIdleLastFrame(weaponId) {
|
|
8873
|
+
switch (weaponId) {
|
|
8874
|
+
case WeaponId.HandGrenade:
|
|
8875
|
+
return FRAME_GRENADE_IDLE_LAST;
|
|
8876
|
+
case WeaponId.Shotgun:
|
|
8877
|
+
return FRAME_SHOTGUN_IDLE_LAST;
|
|
8878
|
+
case WeaponId.SuperShotgun:
|
|
8879
|
+
return FRAME_SSHOTGUN_IDLE_LAST;
|
|
8880
|
+
case WeaponId.Machinegun:
|
|
8881
|
+
return FRAME_MACHINEGUN_IDLE_LAST;
|
|
8882
|
+
case WeaponId.Chaingun:
|
|
8883
|
+
return FRAME_CHAINGUN_IDLE_LAST;
|
|
8884
|
+
case WeaponId.Railgun:
|
|
8885
|
+
return FRAME_RAILGUN_IDLE_LAST;
|
|
8886
|
+
case WeaponId.RocketLauncher:
|
|
8887
|
+
return FRAME_ROCKET_IDLE_LAST;
|
|
8888
|
+
case WeaponId.HyperBlaster:
|
|
8889
|
+
return FRAME_HYPERBLASTER_IDLE_LAST;
|
|
8890
|
+
case WeaponId.BFG10K:
|
|
8891
|
+
return FRAME_BFG_IDLE_LAST;
|
|
8892
|
+
case WeaponId.GrenadeLauncher:
|
|
8893
|
+
return FRAME_GRENADELAUNCHER_IDLE_LAST;
|
|
8894
|
+
case WeaponId.Blaster:
|
|
8895
|
+
return FRAME_BLASTER_IDLE_LAST;
|
|
8896
|
+
default:
|
|
8897
|
+
return 0;
|
|
8898
|
+
}
|
|
8899
|
+
}
|
|
8900
|
+
function ChangeWeapon(ent, weaponId) {
|
|
8901
|
+
if (!ent.client) return;
|
|
8902
|
+
const client = ent.client;
|
|
8903
|
+
if (weaponId) {
|
|
8904
|
+
if (client.weaponstate === 2 /* WEAPON_DROPPING */) {
|
|
8905
|
+
client.newWeapon = weaponId;
|
|
8906
|
+
return;
|
|
8907
|
+
}
|
|
8908
|
+
if (client.weaponstate === 0 /* WEAPON_READY */ || client.weaponstate === 3 /* WEAPON_FIRING */) {
|
|
8909
|
+
client.newWeapon = weaponId;
|
|
8910
|
+
client.weaponstate = 2 /* WEAPON_DROPPING */;
|
|
8911
|
+
if (client.inventory.currentWeapon) {
|
|
8912
|
+
client.gun_frame = getWeaponIdleLastFrame(client.inventory.currentWeapon) + 1;
|
|
8913
|
+
} else {
|
|
8914
|
+
client.gun_frame = 0;
|
|
8915
|
+
}
|
|
8916
|
+
if (instantSwitch) {
|
|
8917
|
+
selectWeapon(client.inventory, weaponId);
|
|
8918
|
+
client.weaponstate = 0 /* WEAPON_READY */;
|
|
8919
|
+
client.weapon_think_time = 0;
|
|
8920
|
+
client.newWeapon = void 0;
|
|
8921
|
+
}
|
|
8922
|
+
return;
|
|
8923
|
+
}
|
|
8924
|
+
client.newWeapon = weaponId;
|
|
8925
|
+
return;
|
|
8926
|
+
}
|
|
8927
|
+
if (client.newWeapon) {
|
|
8928
|
+
selectWeapon(client.inventory, client.newWeapon);
|
|
8929
|
+
client.weaponstate = 1 /* WEAPON_ACTIVATING */;
|
|
8930
|
+
client.gun_frame = 0;
|
|
8931
|
+
client.weapon_think_time = 0;
|
|
8932
|
+
client.newWeapon = void 0;
|
|
8933
|
+
}
|
|
8934
|
+
}
|
|
8935
|
+
function NoAmmoWeaponChange(ent) {
|
|
8936
|
+
if (!ent.client) return;
|
|
8937
|
+
const bestWeapon = getBestWeapon(ent);
|
|
8938
|
+
if (bestWeapon && bestWeapon !== ent.client.inventory.currentWeapon) {
|
|
8939
|
+
ChangeWeapon(ent, bestWeapon);
|
|
8940
|
+
}
|
|
8941
|
+
}
|
|
8942
|
+
function getBestWeapon(player) {
|
|
8943
|
+
if (!player.client) {
|
|
8944
|
+
return null;
|
|
8945
|
+
}
|
|
8946
|
+
const inventory = player.client.inventory;
|
|
8947
|
+
if (inventory.ownedWeapons.has(WeaponId.BFG10K) && inventory.ammo.counts[AmmoType.Cells] >= 50) {
|
|
8948
|
+
return WeaponId.BFG10K;
|
|
8949
|
+
} else if (inventory.ownedWeapons.has(WeaponId.RocketLauncher) && inventory.ammo.counts[AmmoType.Rockets] >= 1) {
|
|
8950
|
+
return WeaponId.RocketLauncher;
|
|
8951
|
+
} else if (inventory.ownedWeapons.has(WeaponId.HyperBlaster) && inventory.ammo.counts[AmmoType.Cells] >= 1) {
|
|
8952
|
+
return WeaponId.HyperBlaster;
|
|
8953
|
+
} else if (inventory.ownedWeapons.has(WeaponId.Railgun) && inventory.ammo.counts[AmmoType.Slugs] >= 1) {
|
|
8954
|
+
return WeaponId.Railgun;
|
|
8955
|
+
} else if (inventory.ownedWeapons.has(WeaponId.Chaingun) && inventory.ammo.counts[AmmoType.Bullets] >= 1) {
|
|
8956
|
+
return WeaponId.Chaingun;
|
|
8957
|
+
} else if (inventory.ownedWeapons.has(WeaponId.GrenadeLauncher) && inventory.ammo.counts[AmmoType.Grenades] >= 1) {
|
|
8958
|
+
return WeaponId.GrenadeLauncher;
|
|
8959
|
+
} else if (inventory.ownedWeapons.has(WeaponId.SuperShotgun) && inventory.ammo.counts[AmmoType.Shells] >= 2) {
|
|
8960
|
+
return WeaponId.SuperShotgun;
|
|
8961
|
+
} else if (inventory.ownedWeapons.has(WeaponId.Machinegun) && inventory.ammo.counts[AmmoType.Bullets] >= 1) {
|
|
8962
|
+
return WeaponId.Machinegun;
|
|
8963
|
+
} else if (inventory.ownedWeapons.has(WeaponId.Shotgun) && inventory.ammo.counts[AmmoType.Shells] >= 1) {
|
|
8964
|
+
return WeaponId.Shotgun;
|
|
8965
|
+
} else {
|
|
8966
|
+
return WeaponId.Blaster;
|
|
8967
|
+
}
|
|
8968
|
+
}
|
|
8969
|
+
|
|
8849
8970
|
// src/combat/weapons/firing.ts
|
|
8850
8971
|
var random3 = createRandomGenerator();
|
|
8851
8972
|
var DEFAULT_SHOTGUN_HSPREAD = 500;
|
|
@@ -8874,6 +8995,15 @@ function setPlayerAttackAnim(player) {
|
|
|
8874
8995
|
player.client.anim_end = FRAME_attack8;
|
|
8875
8996
|
}
|
|
8876
8997
|
}
|
|
8998
|
+
function checkAmmo(game, player, ammoType, count) {
|
|
8999
|
+
if (!player.client) return false;
|
|
9000
|
+
if (player.client.inventory.ammo.counts[ammoType] < count) {
|
|
9001
|
+
game.sound(player, 0, "weapons/noammo.wav", 1, ATTN_NORM, 0);
|
|
9002
|
+
NoAmmoWeaponChange(player);
|
|
9003
|
+
return false;
|
|
9004
|
+
}
|
|
9005
|
+
return true;
|
|
9006
|
+
}
|
|
8877
9007
|
function fireHitscan(game, player, start, forward, damage, knockback, mod) {
|
|
8878
9008
|
const end = { x: start.x + forward.x * 8192, y: start.y + forward.y * 8192, z: start.z + forward.z * 8192 };
|
|
8879
9009
|
if (game.setLagCompensation && player.client) {
|
|
@@ -9008,9 +9138,7 @@ function fireRailgun(game, player, start, forward, damage, knockback) {
|
|
|
9008
9138
|
function fireShotgun(game, player) {
|
|
9009
9139
|
if (!player.client) return;
|
|
9010
9140
|
const inventory = player.client.inventory;
|
|
9011
|
-
if (
|
|
9012
|
-
return;
|
|
9013
|
-
}
|
|
9141
|
+
if (!checkAmmo(game, player, AmmoType.Shells, 1)) return;
|
|
9014
9142
|
inventory.ammo.counts[AmmoType.Shells]--;
|
|
9015
9143
|
game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_SHOTGUN);
|
|
9016
9144
|
applyKick(player, -2, 0, -2);
|
|
@@ -9023,9 +9151,7 @@ function fireShotgun(game, player) {
|
|
|
9023
9151
|
function fireSuperShotgun(game, player) {
|
|
9024
9152
|
if (!player.client) return;
|
|
9025
9153
|
const inventory = player.client.inventory;
|
|
9026
|
-
if (
|
|
9027
|
-
return;
|
|
9028
|
-
}
|
|
9154
|
+
if (!checkAmmo(game, player, AmmoType.Shells, 2)) return;
|
|
9029
9155
|
const isPrecision = (player.client.buttons & BUTTON_ATTACK2) !== 0;
|
|
9030
9156
|
inventory.ammo.counts[AmmoType.Shells] -= 2;
|
|
9031
9157
|
game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_SSHOTGUN);
|
|
@@ -9050,9 +9176,7 @@ function fireSuperShotgun(game, player) {
|
|
|
9050
9176
|
function fireMachinegun(game, player) {
|
|
9051
9177
|
if (!player.client) return;
|
|
9052
9178
|
const inventory = player.client.inventory;
|
|
9053
|
-
if (
|
|
9054
|
-
return;
|
|
9055
|
-
}
|
|
9179
|
+
if (!checkAmmo(game, player, AmmoType.Bullets, 1)) return;
|
|
9056
9180
|
inventory.ammo.counts[AmmoType.Bullets]--;
|
|
9057
9181
|
game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_MACHINEGUN);
|
|
9058
9182
|
applyKick(player, -1, random3.crandom() * 0.5, 0);
|
|
@@ -9088,6 +9212,7 @@ function fireChaingun(game, player) {
|
|
|
9088
9212
|
shots = inventory.ammo.counts[AmmoType.Bullets];
|
|
9089
9213
|
}
|
|
9090
9214
|
if (shots === 0) {
|
|
9215
|
+
if (!checkAmmo(game, player, AmmoType.Bullets, 1)) return;
|
|
9091
9216
|
return;
|
|
9092
9217
|
}
|
|
9093
9218
|
inventory.ammo.counts[AmmoType.Bullets] -= shots;
|
|
@@ -9112,9 +9237,7 @@ function fireChaingun(game, player) {
|
|
|
9112
9237
|
function fireRailgunShot(game, player) {
|
|
9113
9238
|
if (!player.client) return;
|
|
9114
9239
|
const inventory = player.client.inventory;
|
|
9115
|
-
if (
|
|
9116
|
-
return;
|
|
9117
|
-
}
|
|
9240
|
+
if (!checkAmmo(game, player, AmmoType.Slugs, 1)) return;
|
|
9118
9241
|
inventory.ammo.counts[AmmoType.Slugs]--;
|
|
9119
9242
|
game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_RAILGUN);
|
|
9120
9243
|
applyKick(player, -3, 0, -3);
|
|
@@ -9128,9 +9251,7 @@ function fireRailgunShot(game, player) {
|
|
|
9128
9251
|
function fireHyperBlaster(game, player) {
|
|
9129
9252
|
if (!player.client) return;
|
|
9130
9253
|
const inventory = player.client.inventory;
|
|
9131
|
-
if (
|
|
9132
|
-
return;
|
|
9133
|
-
}
|
|
9254
|
+
if (!checkAmmo(game, player, AmmoType.Cells, 1)) return;
|
|
9134
9255
|
inventory.ammo.counts[AmmoType.Cells]--;
|
|
9135
9256
|
game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_HYPERBLASTER);
|
|
9136
9257
|
applyKick(player, -0.5, 0, 0);
|
|
@@ -9189,9 +9310,7 @@ function fireBlaster(game, player) {
|
|
|
9189
9310
|
function fireRocket(game, player) {
|
|
9190
9311
|
if (!player.client) return;
|
|
9191
9312
|
const inventory = player.client.inventory;
|
|
9192
|
-
if (
|
|
9193
|
-
return;
|
|
9194
|
-
}
|
|
9313
|
+
if (!checkAmmo(game, player, AmmoType.Rockets, 1)) return;
|
|
9195
9314
|
inventory.ammo.counts[AmmoType.Rockets]--;
|
|
9196
9315
|
game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_ROCKET);
|
|
9197
9316
|
applyKick(player, -2, 0, -2);
|
|
@@ -9209,9 +9328,7 @@ function fireRocket(game, player) {
|
|
|
9209
9328
|
function fireGrenadeLauncher(game, player, timer) {
|
|
9210
9329
|
if (!player.client) return;
|
|
9211
9330
|
const inventory = player.client.inventory;
|
|
9212
|
-
if (
|
|
9213
|
-
return;
|
|
9214
|
-
}
|
|
9331
|
+
if (!checkAmmo(game, player, AmmoType.Grenades, 1)) return;
|
|
9215
9332
|
inventory.ammo.counts[AmmoType.Grenades]--;
|
|
9216
9333
|
game.multicast(player.origin, 1 /* Pvs */, ServerCommand.muzzleflash, player.index, MZ_GRENADE);
|
|
9217
9334
|
applyKick(player, -2, 0, -2);
|
|
@@ -9223,9 +9340,7 @@ function fireGrenadeLauncher(game, player, timer) {
|
|
|
9223
9340
|
function fireHyperBlasterBeam(game, player, weaponState) {
|
|
9224
9341
|
if (!player.client) return;
|
|
9225
9342
|
const inventory = player.client.inventory;
|
|
9226
|
-
if (
|
|
9227
|
-
return;
|
|
9228
|
-
}
|
|
9343
|
+
if (!checkAmmo(game, player, AmmoType.Cells, 2)) return;
|
|
9229
9344
|
if ((weaponState.heat || 0) > 20) {
|
|
9230
9345
|
game.sound(player, 0, "weapons/lashit.wav", 1, 1, 0);
|
|
9231
9346
|
return;
|
|
@@ -9273,9 +9388,7 @@ function fireBFG(game, player) {
|
|
|
9273
9388
|
const isPrimeFrame = gun_frame === 9 || gun_frame === 0 || gun_frame === void 0;
|
|
9274
9389
|
const isFireFrame = gun_frame === 22 || gun_frame === 0 || gun_frame === void 0;
|
|
9275
9390
|
if (isPrimeFrame) {
|
|
9276
|
-
if (
|
|
9277
|
-
return;
|
|
9278
|
-
}
|
|
9391
|
+
if (!checkAmmo(game, player, AmmoType.Cells, 50)) return;
|
|
9279
9392
|
inventory.ammo.counts[AmmoType.Cells] -= 50;
|
|
9280
9393
|
game.sound(player, 0, "weapons/bfg__f1y.wav", 1, 0, 0);
|
|
9281
9394
|
}
|
|
@@ -9291,72 +9404,6 @@ function fireBFG(game, player) {
|
|
|
9291
9404
|
}
|
|
9292
9405
|
}
|
|
9293
9406
|
|
|
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
9407
|
// src/combat/weapons/common.ts
|
|
9361
9408
|
function applyKick2(player, pitch, yaw = 0, kickOrigin = 0) {
|
|
9362
9409
|
if (player.client) {
|
|
@@ -10455,6 +10502,12 @@ var POWERUP_ITEMS = {
|
|
|
10455
10502
|
id: "item_enviro",
|
|
10456
10503
|
name: "Enviro Suit",
|
|
10457
10504
|
timer: 30
|
|
10505
|
+
},
|
|
10506
|
+
"item_invisibility": {
|
|
10507
|
+
type: "powerup",
|
|
10508
|
+
id: "item_invisibility",
|
|
10509
|
+
name: "Invisibility",
|
|
10510
|
+
timer: 30
|
|
10458
10511
|
}
|
|
10459
10512
|
};
|
|
10460
10513
|
var POWER_ARMOR_ITEMS = {
|
|
@@ -10588,6 +10641,7 @@ function createItemRespawnFunction(game, originalModel) {
|
|
|
10588
10641
|
self.modelindex = cachedIndex;
|
|
10589
10642
|
self.svflags &= ~1 /* NoClient */;
|
|
10590
10643
|
game.multicast(self.origin, 1 /* Pvs */, ServerCommand.sound, 0, "items/respawn.wav", 1, 0, 0);
|
|
10644
|
+
game.multicast(self.origin, 1 /* Pvs */, ServerCommand.temp_entity, TempEntity.TELEPORT_EFFECT, self.origin);
|
|
10591
10645
|
};
|
|
10592
10646
|
}
|
|
10593
10647
|
|