quake2ts 0.0.227 → 0.0.228
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 +5 -5
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/browser/index.global.js +2 -2
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs +94 -52
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +94 -52
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/entities/funcs.d.ts.map +1 -1
- package/packages/game/dist/types/entities/triggers.d.ts.map +1 -1
|
@@ -205,9 +205,6 @@ function lengthVec3(a) {
|
|
|
205
205
|
function distance(a, b) {
|
|
206
206
|
return lengthVec3(subtractVec3(a, b));
|
|
207
207
|
}
|
|
208
|
-
function vec3Equals(a, b) {
|
|
209
|
-
return a.x === b.x && a.y === b.y && a.z === b.z;
|
|
210
|
-
}
|
|
211
208
|
function normalizeVec3(a) {
|
|
212
209
|
const len = lengthVec3(a);
|
|
213
210
|
return len === 0 ? a : scaleVec3(a, 1 / len);
|
|
@@ -3918,6 +3915,30 @@ function multiTrigger(self, entities) {
|
|
|
3918
3915
|
if (self.nextthink > entities.timeSeconds) {
|
|
3919
3916
|
return;
|
|
3920
3917
|
}
|
|
3918
|
+
let noise = "";
|
|
3919
|
+
switch (self.sounds) {
|
|
3920
|
+
case 1:
|
|
3921
|
+
noise = "misc/secret.wav";
|
|
3922
|
+
break;
|
|
3923
|
+
case 2:
|
|
3924
|
+
noise = "misc/talk.wav";
|
|
3925
|
+
break;
|
|
3926
|
+
case 3:
|
|
3927
|
+
noise = "misc/trigger1.wav";
|
|
3928
|
+
break;
|
|
3929
|
+
case 4:
|
|
3930
|
+
noise = "switches/butn2.wav";
|
|
3931
|
+
break;
|
|
3932
|
+
}
|
|
3933
|
+
if (noise) {
|
|
3934
|
+
entities.sound(self, 0, noise, 1, 1, 0);
|
|
3935
|
+
}
|
|
3936
|
+
if (self.message && self.activator && self.activator.client) {
|
|
3937
|
+
entities.engine.centerprintf?.(self.activator, self.message);
|
|
3938
|
+
if (self.sounds === 2) {
|
|
3939
|
+
entities.sound(self.activator, 0, "misc/talk.wav", 1, 1, 0);
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3921
3942
|
entities.useTargets(self, self.activator);
|
|
3922
3943
|
if (self.wait > 0) {
|
|
3923
3944
|
self.think = multiWait;
|
|
@@ -3957,6 +3978,9 @@ function registerTriggerMultiple(registry) {
|
|
|
3957
3978
|
if (entity.wait === 0) {
|
|
3958
3979
|
entity.wait = 0.2;
|
|
3959
3980
|
}
|
|
3981
|
+
if (entity.spawnflags & TRIGGER_SPAWNFLAGS.Clip) {
|
|
3982
|
+
entity.solid = 3 /* Bsp */;
|
|
3983
|
+
}
|
|
3960
3984
|
if (entity.spawnflags & TRIGGER_SPAWNFLAGS.Latched) {
|
|
3961
3985
|
}
|
|
3962
3986
|
if (entity.spawnflags & (TRIGGER_SPAWNFLAGS.Triggered | TRIGGER_SPAWNFLAGS.Toggle)) {
|
|
@@ -3983,6 +4007,12 @@ function registerTriggerRelay(registry) {
|
|
|
3983
4007
|
entity.noise_index = -1;
|
|
3984
4008
|
}
|
|
3985
4009
|
entity.use = (self, _other, activator) => {
|
|
4010
|
+
if (!(self.spawnflags & RELAY_SPAWNFLAGS.NoSound)) {
|
|
4011
|
+
context.entities.sound(self, 0, "misc/trigger1.wav", 1, 1, 0);
|
|
4012
|
+
}
|
|
4013
|
+
if (self.message && activator && activator.client) {
|
|
4014
|
+
context.entities.engine.centerprintf?.(activator, self.message);
|
|
4015
|
+
}
|
|
3986
4016
|
context.entities.useTargets(self, activator ?? self);
|
|
3987
4017
|
};
|
|
3988
4018
|
});
|
|
@@ -4826,6 +4856,41 @@ function registerItemSpawns(game, registry) {
|
|
|
4826
4856
|
}
|
|
4827
4857
|
|
|
4828
4858
|
// src/entities/funcs.ts
|
|
4859
|
+
function move_calc(ent, dest, context, done) {
|
|
4860
|
+
const dt = 0.1;
|
|
4861
|
+
const vec = subtractVec3(dest, ent.origin);
|
|
4862
|
+
const dist = lengthVec3(vec);
|
|
4863
|
+
const dir = normalizeVec3(vec);
|
|
4864
|
+
const speed = ent.speed || 100;
|
|
4865
|
+
let currentSpeed = lengthVec3(ent.velocity);
|
|
4866
|
+
if (ent.accel) {
|
|
4867
|
+
currentSpeed += ent.accel * dt;
|
|
4868
|
+
} else {
|
|
4869
|
+
currentSpeed = speed;
|
|
4870
|
+
}
|
|
4871
|
+
if (ent.decel) {
|
|
4872
|
+
const distToStop = currentSpeed * currentSpeed / (2 * ent.decel);
|
|
4873
|
+
if (dist <= distToStop) {
|
|
4874
|
+
currentSpeed -= ent.decel * dt;
|
|
4875
|
+
if (currentSpeed < 10) currentSpeed = 10;
|
|
4876
|
+
}
|
|
4877
|
+
}
|
|
4878
|
+
if (currentSpeed > speed) currentSpeed = speed;
|
|
4879
|
+
const move = currentSpeed * dt;
|
|
4880
|
+
if (dist <= move) {
|
|
4881
|
+
ent.velocity = scaleVec3(dir, dist / dt);
|
|
4882
|
+
ent.think = (e) => {
|
|
4883
|
+
e.velocity = { x: 0, y: 0, z: 0 };
|
|
4884
|
+
e.origin = { ...dest };
|
|
4885
|
+
context.linkentity(e);
|
|
4886
|
+
done(e, context);
|
|
4887
|
+
};
|
|
4888
|
+
context.scheduleThink(ent, context.timeSeconds + dt);
|
|
4889
|
+
} else {
|
|
4890
|
+
ent.velocity = scaleVec3(dir, currentSpeed);
|
|
4891
|
+
context.scheduleThink(ent, context.timeSeconds + dt);
|
|
4892
|
+
}
|
|
4893
|
+
}
|
|
4829
4894
|
function door_blocked(self, other) {
|
|
4830
4895
|
if (other && other.takedamage) {
|
|
4831
4896
|
const damage = self.dmg || 2;
|
|
@@ -4839,34 +4904,25 @@ function door_blocked(self, other) {
|
|
|
4839
4904
|
self.think = door_go_up;
|
|
4840
4905
|
}
|
|
4841
4906
|
}
|
|
4842
|
-
function
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
door.velocity = { x: 0, y: 0, z: 0 };
|
|
4907
|
+
function door_hit_top(ent, context) {
|
|
4908
|
+
ent.state = 0 /* Open */;
|
|
4909
|
+
if (ent.spawnflags & 32) {
|
|
4846
4910
|
return;
|
|
4847
4911
|
}
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
door.velocity = scaleVec3(normalizeVec3(subtractVec3(door.pos1, door.origin)), speed);
|
|
4851
|
-
if (move <= door.speed * 0.1) {
|
|
4852
|
-
door.velocity = scaleVec3(subtractVec3(door.pos1, door.origin), 10);
|
|
4912
|
+
if (ent.wait === -1) {
|
|
4913
|
+
return;
|
|
4853
4914
|
}
|
|
4854
|
-
|
|
4915
|
+
ent.think = door_go_down;
|
|
4916
|
+
context.scheduleThink(ent, context.timeSeconds + ent.wait);
|
|
4917
|
+
}
|
|
4918
|
+
function door_hit_bottom(ent, context) {
|
|
4919
|
+
ent.state = 2 /* Closed */;
|
|
4920
|
+
}
|
|
4921
|
+
function door_go_down(door, context) {
|
|
4922
|
+
move_calc(door, door.pos1, context, door_hit_bottom);
|
|
4855
4923
|
}
|
|
4856
4924
|
function door_go_up(door, context) {
|
|
4857
|
-
|
|
4858
|
-
door.state = 0 /* Open */;
|
|
4859
|
-
door.velocity = { x: 0, y: 0, z: 0 };
|
|
4860
|
-
context?.scheduleThink(door, context.timeSeconds + door.wait);
|
|
4861
|
-
door.think = door_go_down;
|
|
4862
|
-
return;
|
|
4863
|
-
}
|
|
4864
|
-
const move = distance(door.origin, door.pos2);
|
|
4865
|
-
door.velocity = scaleVec3(normalizeVec3(subtractVec3(door.pos2, door.origin)), door.speed);
|
|
4866
|
-
if (move <= door.speed * 0.1) {
|
|
4867
|
-
door.velocity = scaleVec3(subtractVec3(door.pos2, door.origin), 10);
|
|
4868
|
-
}
|
|
4869
|
-
context?.scheduleThink(door, context.timeSeconds + 0.1);
|
|
4925
|
+
move_calc(door, door.pos2, context, door_hit_top);
|
|
4870
4926
|
}
|
|
4871
4927
|
var func_door = (entity, context) => {
|
|
4872
4928
|
entity.movedir = setMovedir(entity.angles);
|
|
@@ -5013,35 +5069,21 @@ var func_train = (entity, context) => {
|
|
|
5013
5069
|
entity.think = (self) => train_find(self, context.entities);
|
|
5014
5070
|
context.entities.scheduleThink(entity, context.entities.timeSeconds + 0.1);
|
|
5015
5071
|
};
|
|
5016
|
-
function
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
ent.
|
|
5020
|
-
|
|
5021
|
-
}
|
|
5022
|
-
const move = distance(ent.origin, ent.pos2);
|
|
5023
|
-
ent.velocity = scaleVec3(normalizeVec3(subtractVec3(ent.pos2, ent.origin)), ent.speed);
|
|
5024
|
-
if (move <= ent.speed * 0.1) {
|
|
5025
|
-
ent.velocity = scaleVec3(subtractVec3(ent.pos2, ent.origin), 10);
|
|
5072
|
+
function plat_hit_top(ent, context) {
|
|
5073
|
+
ent.state = 0 /* Up */;
|
|
5074
|
+
if (!(ent.spawnflags & 1)) {
|
|
5075
|
+
ent.think = plat_wait_top;
|
|
5076
|
+
context.scheduleThink(ent, context.timeSeconds + ent.wait);
|
|
5026
5077
|
}
|
|
5027
|
-
|
|
5078
|
+
}
|
|
5079
|
+
function plat_hit_bottom(ent, context) {
|
|
5080
|
+
ent.state = 1 /* Down */;
|
|
5081
|
+
}
|
|
5082
|
+
function plat_go_down(ent, context) {
|
|
5083
|
+
move_calc(ent, ent.pos2, context, plat_hit_bottom);
|
|
5028
5084
|
}
|
|
5029
5085
|
function plat_go_up(ent, context) {
|
|
5030
|
-
|
|
5031
|
-
ent.state = 0 /* Up */;
|
|
5032
|
-
ent.velocity = { x: 0, y: 0, z: 0 };
|
|
5033
|
-
if (!(ent.spawnflags & 1)) {
|
|
5034
|
-
ent.think = plat_wait_top;
|
|
5035
|
-
context.scheduleThink(ent, context.timeSeconds + ent.wait);
|
|
5036
|
-
}
|
|
5037
|
-
return;
|
|
5038
|
-
}
|
|
5039
|
-
const move = distance(ent.origin, ent.pos1);
|
|
5040
|
-
ent.velocity = scaleVec3(normalizeVec3(subtractVec3(ent.pos1, ent.origin)), ent.speed);
|
|
5041
|
-
if (move <= ent.speed * 0.1) {
|
|
5042
|
-
ent.velocity = scaleVec3(subtractVec3(ent.pos1, ent.origin), 10);
|
|
5043
|
-
}
|
|
5044
|
-
context.scheduleThink(ent, context.timeSeconds + 0.1);
|
|
5086
|
+
move_calc(ent, ent.pos1, context, plat_hit_top);
|
|
5045
5087
|
}
|
|
5046
5088
|
function plat_wait_top(ent, context) {
|
|
5047
5089
|
ent.state = 3 /* GoingDown */;
|