quake2ts 0.0.270 → 0.0.271
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 +7 -7
- 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 +3 -3
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs +112 -1
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +112 -1
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/entities/entity.d.ts +2 -0
- package/packages/game/dist/types/entities/entity.d.ts.map +1 -1
- package/packages/game/dist/types/entities/system.d.ts.map +1 -1
- package/packages/game/dist/types/entities/targets.d.ts.map +1 -1
- package/packages/game/dist/types/inventory/playerInventory.d.ts +1 -0
- package/packages/game/dist/types/inventory/playerInventory.d.ts.map +1 -1
|
@@ -1750,6 +1750,8 @@ var Entity = class {
|
|
|
1750
1750
|
this.attenuation = 0;
|
|
1751
1751
|
this.volume = 0;
|
|
1752
1752
|
this.fly_sound_debounce_time = 0;
|
|
1753
|
+
this.last_move_time = 0;
|
|
1754
|
+
this.damage_debounce_time = 0;
|
|
1753
1755
|
this.enemy = null;
|
|
1754
1756
|
this.movetarget = null;
|
|
1755
1757
|
this.target_ent = null;
|
|
@@ -1889,6 +1891,8 @@ var Entity = class {
|
|
|
1889
1891
|
this.sounds = 0;
|
|
1890
1892
|
this.noise_index = 0;
|
|
1891
1893
|
this.fly_sound_debounce_time = 0;
|
|
1894
|
+
this.last_move_time = 0;
|
|
1895
|
+
this.damage_debounce_time = 0;
|
|
1892
1896
|
this.enemy = null;
|
|
1893
1897
|
this.movetarget = null;
|
|
1894
1898
|
this.target_ent = null;
|
|
@@ -1984,6 +1988,8 @@ var ENTITY_FIELD_METADATA = [
|
|
|
1984
1988
|
{ name: "attenuation", type: "float", save: true },
|
|
1985
1989
|
{ name: "volume", type: "float", save: true },
|
|
1986
1990
|
{ name: "fly_sound_debounce_time", type: "float", save: true },
|
|
1991
|
+
{ name: "last_move_time", type: "float", save: true },
|
|
1992
|
+
{ name: "damage_debounce_time", type: "float", save: true },
|
|
1987
1993
|
{ name: "enemy", type: "entity", save: true },
|
|
1988
1994
|
{ name: "movetarget", type: "entity", save: true },
|
|
1989
1995
|
{ name: "target_ent", type: "entity", save: true },
|
|
@@ -3222,7 +3228,9 @@ var EntitySystem = class {
|
|
|
3222
3228
|
}
|
|
3223
3229
|
forEachEntity(callback) {
|
|
3224
3230
|
for (const entity of this.pool) {
|
|
3225
|
-
|
|
3231
|
+
if (entity.inUse && !entity.freePending) {
|
|
3232
|
+
callback(entity);
|
|
3233
|
+
}
|
|
3226
3234
|
}
|
|
3227
3235
|
}
|
|
3228
3236
|
find(predicate) {
|
|
@@ -4373,6 +4381,7 @@ function createBfgBall(sys, owner, start, dir, damage, speed, damageRadius) {
|
|
|
4373
4381
|
}
|
|
4374
4382
|
|
|
4375
4383
|
// src/entities/targets.ts
|
|
4384
|
+
var ATTN_NONE = 0;
|
|
4376
4385
|
var ATTN_NORM = 1;
|
|
4377
4386
|
var SPEAKER_SPAWNFLAGS = {
|
|
4378
4387
|
LoopedOn: 1 << 0,
|
|
@@ -4465,6 +4474,88 @@ function useTargetBlaster(self, other, activator, context) {
|
|
|
4465
4474
|
}
|
|
4466
4475
|
context.entities.sound(self, 2, "weapons/laser2.wav", 1, ATTN_NORM, 0);
|
|
4467
4476
|
}
|
|
4477
|
+
var SPAWNFLAG_EARTHQUAKE_SILENT = 1;
|
|
4478
|
+
var SPAWNFLAG_EARTHQUAKE_TOGGLE = 2;
|
|
4479
|
+
var SPAWNFLAG_EARTHQUAKE_ONE_SHOT = 8;
|
|
4480
|
+
function target_earthquake_think(self, context) {
|
|
4481
|
+
if (!(self.spawnflags & SPAWNFLAG_EARTHQUAKE_SILENT)) {
|
|
4482
|
+
if (self.last_move_time < context.entities.timeSeconds) {
|
|
4483
|
+
context.entities.sound(self, 2, "world/quake.wav", 1, ATTN_NONE, 0);
|
|
4484
|
+
self.last_move_time = context.entities.timeSeconds + 0.5;
|
|
4485
|
+
}
|
|
4486
|
+
}
|
|
4487
|
+
context.entities.forEachEntity((ent) => {
|
|
4488
|
+
if (!ent.client) return;
|
|
4489
|
+
ent.client.quake_time = context.entities.timeSeconds + 0.2;
|
|
4490
|
+
});
|
|
4491
|
+
if (context.entities.timeSeconds < self.timestamp) {
|
|
4492
|
+
self.nextthink = context.entities.timeSeconds + 0.1;
|
|
4493
|
+
}
|
|
4494
|
+
}
|
|
4495
|
+
function useTargetEarthquake(self, other, activator, context) {
|
|
4496
|
+
if (self.spawnflags & SPAWNFLAG_EARTHQUAKE_ONE_SHOT) {
|
|
4497
|
+
context.entities.forEachEntity((ent) => {
|
|
4498
|
+
if (!ent.client) return;
|
|
4499
|
+
if (ent.client) {
|
|
4500
|
+
if (!ent.client.kick_angles) ent.client.kick_angles = { x: 0, y: 0, z: 0 };
|
|
4501
|
+
ent.client.kick_angles = { ...ent.client.kick_angles, x: -self.speed * 0.1 };
|
|
4502
|
+
}
|
|
4503
|
+
});
|
|
4504
|
+
return;
|
|
4505
|
+
}
|
|
4506
|
+
self.timestamp = context.entities.timeSeconds + self.count;
|
|
4507
|
+
if (self.spawnflags & SPAWNFLAG_EARTHQUAKE_TOGGLE) {
|
|
4508
|
+
if (self.style) {
|
|
4509
|
+
self.nextthink = 0;
|
|
4510
|
+
} else {
|
|
4511
|
+
self.nextthink = context.entities.timeSeconds + 0.1;
|
|
4512
|
+
}
|
|
4513
|
+
self.style = !self.style ? 1 : 0;
|
|
4514
|
+
} else {
|
|
4515
|
+
self.nextthink = context.entities.timeSeconds + 0.1;
|
|
4516
|
+
self.last_move_time = 0;
|
|
4517
|
+
}
|
|
4518
|
+
self.activator = activator;
|
|
4519
|
+
}
|
|
4520
|
+
var SPAWNFLAG_LIGHTRAMP_TOGGLE = 1;
|
|
4521
|
+
function target_lightramp_think(self, context) {
|
|
4522
|
+
const timeDelta = context.entities.timeSeconds - self.timestamp;
|
|
4523
|
+
const val = self.movedir.x + timeDelta / 0.1 * self.movedir.z;
|
|
4524
|
+
let charCode = Math.floor("a".charCodeAt(0) + val);
|
|
4525
|
+
const styleStr = String.fromCharCode(charCode);
|
|
4526
|
+
const CS_LIGHTS = 32;
|
|
4527
|
+
if (self.enemy && self.enemy.style !== void 0) {
|
|
4528
|
+
context.entities.configstring(CS_LIGHTS + self.enemy.style, styleStr);
|
|
4529
|
+
}
|
|
4530
|
+
if (timeDelta < self.speed) {
|
|
4531
|
+
self.nextthink = context.entities.timeSeconds + 0.1;
|
|
4532
|
+
} else if (self.spawnflags & SPAWNFLAG_LIGHTRAMP_TOGGLE) {
|
|
4533
|
+
const temp = self.movedir.x;
|
|
4534
|
+
self.movedir = { ...self.movedir, x: self.movedir.y, y: temp, z: self.movedir.z * -1 };
|
|
4535
|
+
}
|
|
4536
|
+
}
|
|
4537
|
+
function useTargetLightramp(self, other, activator, context) {
|
|
4538
|
+
if (!self.enemy) {
|
|
4539
|
+
let e = null;
|
|
4540
|
+
let found = false;
|
|
4541
|
+
context.entities.forEachEntity((ent) => {
|
|
4542
|
+
if (ent.targetname === self.target) {
|
|
4543
|
+
if (ent.classname === "light") {
|
|
4544
|
+
self.enemy = ent;
|
|
4545
|
+
found = true;
|
|
4546
|
+
} else {
|
|
4547
|
+
context.warn(`${self.classname} target ${self.target} is not a light`);
|
|
4548
|
+
}
|
|
4549
|
+
}
|
|
4550
|
+
});
|
|
4551
|
+
if (!found) {
|
|
4552
|
+
context.warn(`${self.classname} target ${self.target} not found`);
|
|
4553
|
+
return;
|
|
4554
|
+
}
|
|
4555
|
+
}
|
|
4556
|
+
self.timestamp = context.entities.timeSeconds;
|
|
4557
|
+
target_lightramp_think(self, context);
|
|
4558
|
+
}
|
|
4468
4559
|
var TARGET_LASER_START_ON = 1;
|
|
4469
4560
|
var TARGET_LASER_RED = 2;
|
|
4470
4561
|
var TARGET_LASER_GREEN = 4;
|
|
@@ -4721,6 +4812,26 @@ function registerTargetSpawns(registry) {
|
|
|
4721
4812
|
};
|
|
4722
4813
|
context.entities.scheduleThink(entity, context.entities.timeSeconds + entity.delay);
|
|
4723
4814
|
});
|
|
4815
|
+
registry.register("target_earthquake", (entity, context) => {
|
|
4816
|
+
if (!entity.count) entity.count = 5;
|
|
4817
|
+
if (!entity.speed) entity.speed = 200;
|
|
4818
|
+
entity.svflags |= 1 /* NoClient */;
|
|
4819
|
+
entity.think = (self) => target_earthquake_think(self, context);
|
|
4820
|
+
entity.use = (self, other, activator) => useTargetEarthquake(self, other, activator ?? null, context);
|
|
4821
|
+
if (!(entity.spawnflags & SPAWNFLAG_EARTHQUAKE_SILENT)) {
|
|
4822
|
+
}
|
|
4823
|
+
});
|
|
4824
|
+
registry.register("target_lightramp", (entity, context) => {
|
|
4825
|
+
entity.svflags |= 1 /* NoClient */;
|
|
4826
|
+
entity.use = (self, other, activator) => useTargetLightramp(self, other, activator ?? null, context);
|
|
4827
|
+
entity.think = (self) => target_lightramp_think(self, context);
|
|
4828
|
+
if (entity.message && entity.message.length === 2 && entity.speed) {
|
|
4829
|
+
const start = entity.message.charCodeAt(0) - "a".charCodeAt(0);
|
|
4830
|
+
const end = entity.message.charCodeAt(1) - "a".charCodeAt(0);
|
|
4831
|
+
const slope = (end - start) / (entity.speed / 0.1);
|
|
4832
|
+
entity.movedir = { x: start, y: end, z: slope };
|
|
4833
|
+
}
|
|
4834
|
+
});
|
|
4724
4835
|
}
|
|
4725
4836
|
|
|
4726
4837
|
// src/entities/triggers.ts
|