quake2ts 0.0.493 → 0.0.496
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 +12 -12
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/browser/index.global.js +4 -4
- package/packages/game/dist/browser/index.global.js.map +1 -1
- package/packages/game/dist/cjs/index.cjs +406 -264
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +406 -264
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/entities/triggers/always.d.ts +3 -0
- package/packages/game/dist/types/entities/triggers/always.d.ts.map +1 -0
- package/packages/game/dist/types/entities/triggers/bad_area.d.ts +3 -0
- package/packages/game/dist/types/entities/triggers/bad_area.d.ts.map +1 -0
- package/packages/game/dist/types/entities/triggers/common.d.ts +14 -0
- package/packages/game/dist/types/entities/triggers/common.d.ts.map +1 -0
- package/packages/game/dist/types/entities/triggers/counter.d.ts +3 -0
- package/packages/game/dist/types/entities/triggers/counter.d.ts.map +1 -0
- package/packages/game/dist/types/entities/triggers/elevator.d.ts +3 -0
- package/packages/game/dist/types/entities/triggers/elevator.d.ts.map +1 -0
- package/packages/game/dist/types/entities/triggers/gravity.d.ts +3 -0
- package/packages/game/dist/types/entities/triggers/gravity.d.ts.map +1 -0
- package/packages/game/dist/types/entities/triggers/hurt.d.ts +3 -0
- package/packages/game/dist/types/entities/triggers/hurt.d.ts.map +1 -0
- package/packages/game/dist/types/entities/triggers/index.d.ts +3 -0
- package/packages/game/dist/types/entities/triggers/index.d.ts.map +1 -0
- package/packages/game/dist/types/entities/triggers/key.d.ts +3 -0
- package/packages/game/dist/types/entities/triggers/key.d.ts.map +1 -0
- package/packages/game/dist/types/entities/triggers/monsterjump.d.ts +3 -0
- package/packages/game/dist/types/entities/triggers/monsterjump.d.ts.map +1 -0
- package/packages/game/dist/types/entities/triggers/multiple.d.ts +6 -0
- package/packages/game/dist/types/entities/triggers/multiple.d.ts.map +1 -0
- package/packages/game/dist/types/entities/triggers/once.d.ts +3 -0
- package/packages/game/dist/types/entities/triggers/once.d.ts.map +1 -0
- package/packages/game/dist/types/entities/triggers/push.d.ts +3 -0
- package/packages/game/dist/types/entities/triggers/push.d.ts.map +1 -0
- package/packages/game/dist/types/entities/triggers/relay.d.ts +3 -0
- package/packages/game/dist/types/entities/triggers/relay.d.ts.map +1 -0
- package/packages/game/dist/types/entities/triggers/teleport.d.ts +3 -0
- package/packages/game/dist/types/entities/triggers/teleport.d.ts.map +1 -0
- package/packages/game/dist/types/entities/triggers.d.ts +0 -3
- package/packages/game/dist/types/entities/triggers.d.ts.map +0 -1
|
@@ -7732,170 +7732,7 @@ function registerTargetSpawns(registry) {
|
|
|
7732
7732
|
});
|
|
7733
7733
|
}
|
|
7734
7734
|
|
|
7735
|
-
// src/entities/triggers/
|
|
7736
|
-
function clamp2(value, min, max) {
|
|
7737
|
-
return Math.min(Math.max(value, min), max);
|
|
7738
|
-
}
|
|
7739
|
-
function lerp(start, end, t) {
|
|
7740
|
-
return start + (end - start) * t;
|
|
7741
|
-
}
|
|
7742
|
-
var SPAWNFLAG_FOG_AFFECT_FOG = 1;
|
|
7743
|
-
var SPAWNFLAG_FOG_INSTANTANEOUS = 4;
|
|
7744
|
-
var SPAWNFLAG_FOG_FORCE = 8;
|
|
7745
|
-
var SPAWNFLAG_FOG_BLEND = 16;
|
|
7746
|
-
function trigger_fog_touch(self, other, context) {
|
|
7747
|
-
if (!other || !other.client) return;
|
|
7748
|
-
if (self.timestamp > context.timeSeconds) return;
|
|
7749
|
-
self.timestamp = context.timeSeconds + (self.wait || 0);
|
|
7750
|
-
let fog_value_storage = self;
|
|
7751
|
-
if (self.movetarget) {
|
|
7752
|
-
fog_value_storage = self.movetarget;
|
|
7753
|
-
}
|
|
7754
|
-
if (self.spawnflags & SPAWNFLAG_FOG_INSTANTANEOUS) {
|
|
7755
|
-
if (other.client.pers) other.client.pers.fog_transition_time = 0;
|
|
7756
|
-
} else {
|
|
7757
|
-
if (other.client.pers) other.client.pers.fog_transition_time = fog_value_storage.delay || 0.5;
|
|
7758
|
-
}
|
|
7759
|
-
if (self.spawnflags & SPAWNFLAG_FOG_BLEND) {
|
|
7760
|
-
const center = scaleVec3(addVec3(self.absmin, self.absmax), 0.5);
|
|
7761
|
-
const half_size = addVec3(scaleVec3(self.size, 0.5), scaleVec3(other.size, 0.5));
|
|
7762
|
-
const start = {
|
|
7763
|
-
x: -self.movedir.x * half_size.x,
|
|
7764
|
-
y: -self.movedir.y * half_size.y,
|
|
7765
|
-
z: -self.movedir.z * half_size.z
|
|
7766
|
-
};
|
|
7767
|
-
const end = {
|
|
7768
|
-
x: self.movedir.x * half_size.x,
|
|
7769
|
-
y: self.movedir.y * half_size.y,
|
|
7770
|
-
z: self.movedir.z * half_size.z
|
|
7771
|
-
};
|
|
7772
|
-
const delta = subtractVec3(other.origin, center);
|
|
7773
|
-
const absMovedir = {
|
|
7774
|
-
x: Math.abs(self.movedir.x),
|
|
7775
|
-
y: Math.abs(self.movedir.y),
|
|
7776
|
-
z: Math.abs(self.movedir.z)
|
|
7777
|
-
};
|
|
7778
|
-
const player_dist = {
|
|
7779
|
-
x: delta.x * absMovedir.x,
|
|
7780
|
-
y: delta.y * absMovedir.y,
|
|
7781
|
-
z: delta.z * absMovedir.z
|
|
7782
|
-
};
|
|
7783
|
-
let dist = lengthVec3(subtractVec3(player_dist, start));
|
|
7784
|
-
dist /= lengthVec3(subtractVec3(start, end));
|
|
7785
|
-
dist = clamp2(dist, 0, 1);
|
|
7786
|
-
if (self.spawnflags & SPAWNFLAG_FOG_AFFECT_FOG) {
|
|
7787
|
-
const storage2 = fog_value_storage;
|
|
7788
|
-
if (other.client.pers) {
|
|
7789
|
-
other.client.pers.wanted_fog = {
|
|
7790
|
-
density: lerp(storage2.fog_density_off || 0, storage2.fog_density || 0, dist),
|
|
7791
|
-
r: lerp(storage2.fog_color_off?.[0] || 0, storage2.fog_color?.[0] || 0, dist),
|
|
7792
|
-
g: lerp(storage2.fog_color_off?.[1] || 0, storage2.fog_color?.[1] || 0, dist),
|
|
7793
|
-
b: lerp(storage2.fog_color_off?.[2] || 0, storage2.fog_color?.[2] || 0, dist),
|
|
7794
|
-
sky_factor: lerp(storage2.fog_sky_factor_off || 0, storage2.fog_sky_factor || 0, dist)
|
|
7795
|
-
};
|
|
7796
|
-
}
|
|
7797
|
-
}
|
|
7798
|
-
return;
|
|
7799
|
-
}
|
|
7800
|
-
let use_on = true;
|
|
7801
|
-
if (!(self.spawnflags & SPAWNFLAG_FOG_FORCE)) {
|
|
7802
|
-
const len = lengthVec3(other.velocity);
|
|
7803
|
-
if (len <= 1e-4) return;
|
|
7804
|
-
const forward = normalizeVec3(other.velocity);
|
|
7805
|
-
const dot = forward.x * self.movedir.x + forward.y * self.movedir.y + forward.z * self.movedir.z;
|
|
7806
|
-
use_on = dot > 0;
|
|
7807
|
-
}
|
|
7808
|
-
const storage = fog_value_storage;
|
|
7809
|
-
if (self.spawnflags & SPAWNFLAG_FOG_AFFECT_FOG) {
|
|
7810
|
-
if (other.client.pers) {
|
|
7811
|
-
if (use_on) {
|
|
7812
|
-
other.client.pers.wanted_fog = {
|
|
7813
|
-
density: storage.fog_density || 0,
|
|
7814
|
-
r: storage.fog_color?.[0] || 0,
|
|
7815
|
-
g: storage.fog_color?.[1] || 0,
|
|
7816
|
-
b: storage.fog_color?.[2] || 0,
|
|
7817
|
-
sky_factor: storage.fog_sky_factor || 0
|
|
7818
|
-
};
|
|
7819
|
-
} else {
|
|
7820
|
-
other.client.pers.wanted_fog = {
|
|
7821
|
-
density: storage.fog_density_off || 0,
|
|
7822
|
-
r: storage.fog_color_off?.[0] || 0,
|
|
7823
|
-
g: storage.fog_color_off?.[1] || 0,
|
|
7824
|
-
b: storage.fog_color_off?.[2] || 0,
|
|
7825
|
-
sky_factor: storage.fog_sky_factor_off || 0
|
|
7826
|
-
};
|
|
7827
|
-
}
|
|
7828
|
-
}
|
|
7829
|
-
}
|
|
7830
|
-
}
|
|
7831
|
-
function registerTriggerFog(registry) {
|
|
7832
|
-
registry.register("trigger_fog", (entity, context) => {
|
|
7833
|
-
entity.solid = 1 /* Trigger */;
|
|
7834
|
-
entity.movetype = 0 /* None */;
|
|
7835
|
-
entity.svflags |= 1 /* NoClient */;
|
|
7836
|
-
const entAny = entity;
|
|
7837
|
-
const kv = context.keyValues;
|
|
7838
|
-
entAny.fog_density = parseFloat(kv.fog_density) || 0;
|
|
7839
|
-
entAny.fog_color = kv.fog_color ? kv.fog_color.split(" ").map(parseFloat) : [0, 0, 0];
|
|
7840
|
-
entAny.fog_sky_factor = parseFloat(kv.fog_sky_factor) || 0;
|
|
7841
|
-
entAny.fog_density_off = parseFloat(kv.fog_density_off) || 0;
|
|
7842
|
-
entAny.fog_color_off = kv.fog_color_off ? kv.fog_color_off.split(" ").map(parseFloat) : [0, 0, 0];
|
|
7843
|
-
entAny.fog_sky_factor_off = parseFloat(kv.fog_sky_factor_off) || 0;
|
|
7844
|
-
if (entity.target) {
|
|
7845
|
-
entity.movetype = 0 /* None */;
|
|
7846
|
-
entity.movetarget = null;
|
|
7847
|
-
}
|
|
7848
|
-
if (!entity.delay) entity.delay = 0.5;
|
|
7849
|
-
entity.touch = (self, other) => trigger_fog_touch(self, other, context.entities);
|
|
7850
|
-
});
|
|
7851
|
-
}
|
|
7852
|
-
|
|
7853
|
-
// src/entities/triggers/flashlight.ts
|
|
7854
|
-
var registerTriggerFlashlight = (registry) => {
|
|
7855
|
-
registry.register("trigger_flashlight", (self, context) => {
|
|
7856
|
-
self.solid = 1 /* Trigger */;
|
|
7857
|
-
self.movetype = 0;
|
|
7858
|
-
self.svflags |= 1 /* NoClient */;
|
|
7859
|
-
self.touch = (self2, other, plane, surf) => {
|
|
7860
|
-
if (!other || !other.client) return;
|
|
7861
|
-
const style = self2.style || 0;
|
|
7862
|
-
let sound = "";
|
|
7863
|
-
if (style === 0) {
|
|
7864
|
-
if (other.flags & 4194304 /* Flashlight */) {
|
|
7865
|
-
other.flags &= ~4194304 /* Flashlight */;
|
|
7866
|
-
sound = "items/flashlight_off.wav";
|
|
7867
|
-
} else {
|
|
7868
|
-
other.flags |= 4194304 /* Flashlight */;
|
|
7869
|
-
sound = "items/flashlight_on.wav";
|
|
7870
|
-
}
|
|
7871
|
-
} else if (style === 1) {
|
|
7872
|
-
if (!(other.flags & 4194304 /* Flashlight */)) {
|
|
7873
|
-
other.flags |= 4194304 /* Flashlight */;
|
|
7874
|
-
sound = "items/flashlight_on.wav";
|
|
7875
|
-
}
|
|
7876
|
-
} else if (style === 2) {
|
|
7877
|
-
if (other.flags & 4194304 /* Flashlight */) {
|
|
7878
|
-
other.flags &= ~4194304 /* Flashlight */;
|
|
7879
|
-
sound = "items/flashlight_off.wav";
|
|
7880
|
-
}
|
|
7881
|
-
}
|
|
7882
|
-
if (other.flags & 4194304 /* Flashlight */) {
|
|
7883
|
-
other.renderfx |= RenderFx.Flashlight;
|
|
7884
|
-
} else {
|
|
7885
|
-
other.renderfx &= ~RenderFx.Flashlight;
|
|
7886
|
-
}
|
|
7887
|
-
if (sound) {
|
|
7888
|
-
context.entities.sound(other, 0, sound, 1, 3, 0);
|
|
7889
|
-
}
|
|
7890
|
-
};
|
|
7891
|
-
context.entities.linkentity(self);
|
|
7892
|
-
});
|
|
7893
|
-
};
|
|
7894
|
-
|
|
7895
|
-
// src/entities/triggers.ts
|
|
7896
|
-
var FRAME_TIME_SECONDS = 1 / 40;
|
|
7897
|
-
var THINK_INTERVAL = 0.1;
|
|
7898
|
-
var HURT_INTERVAL = 0.1;
|
|
7735
|
+
// src/entities/triggers/common.ts
|
|
7899
7736
|
var TRIGGER_SPAWNFLAGS = {
|
|
7900
7737
|
Monster: 1 << 0,
|
|
7901
7738
|
NotPlayer: 1 << 1,
|
|
@@ -7904,50 +7741,7 @@ var TRIGGER_SPAWNFLAGS = {
|
|
|
7904
7741
|
Latched: 1 << 4,
|
|
7905
7742
|
Clip: 1 << 5
|
|
7906
7743
|
};
|
|
7907
|
-
var
|
|
7908
|
-
NoSound: 1 << 0
|
|
7909
|
-
};
|
|
7910
|
-
var COUNTER_SPAWNFLAGS = {
|
|
7911
|
-
NoMessage: 1 << 0
|
|
7912
|
-
};
|
|
7913
|
-
var PUSH_SPAWNFLAGS = {
|
|
7914
|
-
Once: 1 << 0,
|
|
7915
|
-
Plus: 1 << 1,
|
|
7916
|
-
Silent: 1 << 2,
|
|
7917
|
-
StartOff: 1 << 3,
|
|
7918
|
-
Clip: 1 << 4
|
|
7919
|
-
};
|
|
7920
|
-
var HURT_SPAWNFLAGS = {
|
|
7921
|
-
StartOff: 1 << 0,
|
|
7922
|
-
Toggle: 1 << 1,
|
|
7923
|
-
Silent: 1 << 2,
|
|
7924
|
-
NoProtection: 1 << 3,
|
|
7925
|
-
Slow: 1 << 4,
|
|
7926
|
-
NoPlayers: 1 << 5,
|
|
7927
|
-
NoMonsters: 1 << 6,
|
|
7928
|
-
Clip: 1 << 7
|
|
7929
|
-
};
|
|
7930
|
-
var TELEPORT_SPAWNFLAGS = {
|
|
7931
|
-
StartOn: 1 << 3
|
|
7932
|
-
};
|
|
7933
|
-
var GRAVITY_SPAWNFLAGS = {
|
|
7934
|
-
Toggle: 1 << 0,
|
|
7935
|
-
StartOff: 1 << 1,
|
|
7936
|
-
Clip: 1 << 2
|
|
7937
|
-
};
|
|
7938
|
-
var MONSTERJUMP_SPAWNFLAGS = {
|
|
7939
|
-
Toggle: 1 << 0,
|
|
7940
|
-
StartOff: 1 << 1,
|
|
7941
|
-
Clip: 1 << 2
|
|
7942
|
-
};
|
|
7943
|
-
function trainResume(train, entities) {
|
|
7944
|
-
if (!train.think) {
|
|
7945
|
-
train.think = (self) => {
|
|
7946
|
-
self.nextthink = 0;
|
|
7947
|
-
};
|
|
7948
|
-
}
|
|
7949
|
-
entities.scheduleThink(train, entities.timeSeconds + FRAME_TIME_SECONDS);
|
|
7950
|
-
}
|
|
7744
|
+
var FRAME_TIME_SECONDS = 1 / 40;
|
|
7951
7745
|
function initTrigger(entity) {
|
|
7952
7746
|
entity.movetype = 0 /* None */;
|
|
7953
7747
|
entity.solid = 1 /* Trigger */;
|
|
@@ -7955,10 +7749,6 @@ function initTrigger(entity) {
|
|
|
7955
7749
|
entity.movedir = setMovedir(entity.angles);
|
|
7956
7750
|
entity.angles = { x: 0, y: 0, z: 0 };
|
|
7957
7751
|
}
|
|
7958
|
-
function multiWait(self) {
|
|
7959
|
-
self.nextthink = 0;
|
|
7960
|
-
self.think = void 0;
|
|
7961
|
-
}
|
|
7962
7752
|
function canActivate(trigger, other) {
|
|
7963
7753
|
if (trigger.solid === 0 /* Not */) {
|
|
7964
7754
|
return false;
|
|
@@ -7983,6 +7773,15 @@ function canActivate(trigger, other) {
|
|
|
7983
7773
|
}
|
|
7984
7774
|
return true;
|
|
7985
7775
|
}
|
|
7776
|
+
function triggerEnable(self) {
|
|
7777
|
+
self.solid = 1 /* Trigger */;
|
|
7778
|
+
}
|
|
7779
|
+
|
|
7780
|
+
// src/entities/triggers/multiple.ts
|
|
7781
|
+
function multiWait(self) {
|
|
7782
|
+
self.nextthink = 0;
|
|
7783
|
+
self.think = void 0;
|
|
7784
|
+
}
|
|
7986
7785
|
function multiTrigger(self, entities) {
|
|
7987
7786
|
if (self.nextthink > entities.timeSeconds) {
|
|
7988
7787
|
return;
|
|
@@ -8041,9 +7840,6 @@ function useMulti(self, _other, activator, entities) {
|
|
|
8041
7840
|
self.activator = activator;
|
|
8042
7841
|
multiTrigger(self, entities);
|
|
8043
7842
|
}
|
|
8044
|
-
function triggerEnable(self) {
|
|
8045
|
-
self.solid = 1 /* Trigger */;
|
|
8046
|
-
}
|
|
8047
7843
|
function registerTriggerMultiple(registry) {
|
|
8048
7844
|
registry.register("trigger_multiple", (entity, context) => {
|
|
8049
7845
|
initTrigger(entity);
|
|
@@ -8069,12 +7865,23 @@ function registerTriggerMultiple(registry) {
|
|
|
8069
7865
|
entity.touch = (self, other) => touchMulti(self, other, context.entities);
|
|
8070
7866
|
});
|
|
8071
7867
|
}
|
|
7868
|
+
|
|
7869
|
+
// src/entities/triggers/once.ts
|
|
8072
7870
|
function registerTriggerOnce(registry) {
|
|
8073
7871
|
registry.register("trigger_once", (entity, context) => {
|
|
8074
7872
|
entity.wait = -1;
|
|
8075
|
-
registry.get("trigger_multiple")
|
|
7873
|
+
const multipleSpawn = registry.get("trigger_multiple");
|
|
7874
|
+
if (multipleSpawn) {
|
|
7875
|
+
multipleSpawn(entity, context);
|
|
7876
|
+
} else {
|
|
7877
|
+
}
|
|
8076
7878
|
});
|
|
8077
7879
|
}
|
|
7880
|
+
|
|
7881
|
+
// src/entities/triggers/relay.ts
|
|
7882
|
+
var RELAY_SPAWNFLAGS = {
|
|
7883
|
+
NoSound: 1 << 0
|
|
7884
|
+
};
|
|
8078
7885
|
function registerTriggerRelay(registry) {
|
|
8079
7886
|
registry.register("trigger_relay", (entity, context) => {
|
|
8080
7887
|
if (entity.spawnflags & RELAY_SPAWNFLAGS.NoSound) {
|
|
@@ -8091,6 +7898,8 @@ function registerTriggerRelay(registry) {
|
|
|
8091
7898
|
};
|
|
8092
7899
|
});
|
|
8093
7900
|
}
|
|
7901
|
+
|
|
7902
|
+
// src/entities/triggers/always.ts
|
|
8094
7903
|
function registerTriggerAlways(registry) {
|
|
8095
7904
|
registry.register("trigger_always", (entity, context) => {
|
|
8096
7905
|
if (entity.delay === 0) {
|
|
@@ -8099,14 +7908,27 @@ function registerTriggerAlways(registry) {
|
|
|
8099
7908
|
context.entities.useTargets(entity, entity);
|
|
8100
7909
|
});
|
|
8101
7910
|
}
|
|
7911
|
+
|
|
7912
|
+
// src/entities/triggers/counter.ts
|
|
7913
|
+
var COUNTER_SPAWNFLAGS = {
|
|
7914
|
+
NoMessage: 1 << 0
|
|
7915
|
+
};
|
|
8102
7916
|
function counterUse(self, _other, activator, entities) {
|
|
8103
7917
|
if (self.count === 0) {
|
|
8104
7918
|
return;
|
|
8105
7919
|
}
|
|
8106
7920
|
self.count -= 1;
|
|
8107
7921
|
if (self.count > 0) {
|
|
7922
|
+
if (!(self.spawnflags & COUNTER_SPAWNFLAGS.NoMessage) && activator && activator.client) {
|
|
7923
|
+
entities.engine.centerprintf?.(activator, `${self.count} more to go...`);
|
|
7924
|
+
entities.sound(activator, 0, "misc/talk1.wav", 1, 1, 0);
|
|
7925
|
+
}
|
|
8108
7926
|
return;
|
|
8109
7927
|
}
|
|
7928
|
+
if (!(self.spawnflags & COUNTER_SPAWNFLAGS.NoMessage) && activator && activator.client) {
|
|
7929
|
+
entities.engine.centerprintf?.(activator, "Sequence completed!");
|
|
7930
|
+
entities.sound(activator, 0, "misc/talk1.wav", 1, 1, 0);
|
|
7931
|
+
}
|
|
8110
7932
|
self.activator = activator;
|
|
8111
7933
|
multiTrigger(self, entities);
|
|
8112
7934
|
}
|
|
@@ -8122,6 +7944,8 @@ function registerTriggerCounter(registry) {
|
|
|
8122
7944
|
}
|
|
8123
7945
|
});
|
|
8124
7946
|
}
|
|
7947
|
+
|
|
7948
|
+
// src/entities/triggers/key.ts
|
|
8125
7949
|
function triggerKeyUse(self, activator, entities, warn) {
|
|
8126
7950
|
if (!self.item || !activator) {
|
|
8127
7951
|
return;
|
|
@@ -8132,13 +7956,17 @@ function triggerKeyUse(self, activator, entities, warn) {
|
|
|
8132
7956
|
return;
|
|
8133
7957
|
}
|
|
8134
7958
|
self.timestamp = entities.timeSeconds + 5;
|
|
8135
|
-
|
|
7959
|
+
if (activator.client) {
|
|
7960
|
+
entities.engine.centerprintf?.(activator, `You need the ${self.item}`);
|
|
7961
|
+
entities.sound(activator, 0, "misc/keytry.wav", 1, 1, 0);
|
|
7962
|
+
}
|
|
8136
7963
|
return;
|
|
8137
7964
|
}
|
|
8138
7965
|
activator.inventory[self.item] = available - 1;
|
|
8139
7966
|
if (activator.inventory[self.item] <= 0) {
|
|
8140
7967
|
delete activator.inventory[self.item];
|
|
8141
7968
|
}
|
|
7969
|
+
entities.sound(activator, 0, "misc/keyuse.wav", 1, 1, 0);
|
|
8142
7970
|
entities.useTargets(self, activator);
|
|
8143
7971
|
self.use = void 0;
|
|
8144
7972
|
}
|
|
@@ -8154,6 +7982,16 @@ function registerTriggerKey(registry) {
|
|
|
8154
7982
|
entity.use = (self, other, activator) => triggerKeyUse(self, activator ?? other, context.entities, context.warn);
|
|
8155
7983
|
});
|
|
8156
7984
|
}
|
|
7985
|
+
|
|
7986
|
+
// src/entities/triggers/push.ts
|
|
7987
|
+
var PUSH_SPAWNFLAGS = {
|
|
7988
|
+
Once: 1 << 0,
|
|
7989
|
+
Plus: 1 << 1,
|
|
7990
|
+
Silent: 1 << 2,
|
|
7991
|
+
StartOff: 1 << 3,
|
|
7992
|
+
Clip: 1 << 4
|
|
7993
|
+
};
|
|
7994
|
+
var THINK_INTERVAL = 0.1;
|
|
8157
7995
|
function triggerPushTouch(self, other, entities) {
|
|
8158
7996
|
if (!other) {
|
|
8159
7997
|
return;
|
|
@@ -8165,6 +8003,12 @@ function triggerPushTouch(self, other, entities) {
|
|
|
8165
8003
|
y: self.movedir.y * scale,
|
|
8166
8004
|
z: self.movedir.z * scale
|
|
8167
8005
|
};
|
|
8006
|
+
if (!(self.spawnflags & PUSH_SPAWNFLAGS.Silent)) {
|
|
8007
|
+
if (!other.fly_sound_debounce_time || other.fly_sound_debounce_time < entities.timeSeconds) {
|
|
8008
|
+
other.fly_sound_debounce_time = entities.timeSeconds + 1.5;
|
|
8009
|
+
entities.sound(other, 0, "misc/windfly.wav", 1, 1, 0);
|
|
8010
|
+
}
|
|
8011
|
+
}
|
|
8168
8012
|
}
|
|
8169
8013
|
if (self.spawnflags & PUSH_SPAWNFLAGS.Once) {
|
|
8170
8014
|
entities.free(self);
|
|
@@ -8226,12 +8070,25 @@ function registerTriggerPush(registry) {
|
|
|
8226
8070
|
}
|
|
8227
8071
|
});
|
|
8228
8072
|
}
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
|
|
8073
|
+
|
|
8074
|
+
// src/entities/triggers/hurt.ts
|
|
8075
|
+
var HURT_SPAWNFLAGS = {
|
|
8076
|
+
StartOff: 1 << 0,
|
|
8077
|
+
Toggle: 1 << 1,
|
|
8078
|
+
Silent: 1 << 2,
|
|
8079
|
+
NoProtection: 1 << 3,
|
|
8080
|
+
Slow: 1 << 4,
|
|
8081
|
+
NoPlayers: 1 << 5,
|
|
8082
|
+
NoMonsters: 1 << 6,
|
|
8083
|
+
Clip: 1 << 7
|
|
8084
|
+
};
|
|
8085
|
+
var HURT_INTERVAL = 0.1;
|
|
8086
|
+
function hurtTouch(self, other, entities) {
|
|
8087
|
+
if (!other) {
|
|
8088
|
+
return;
|
|
8089
|
+
}
|
|
8090
|
+
if (!other.takedamage && other.classname !== "grenade") {
|
|
8091
|
+
return;
|
|
8235
8092
|
}
|
|
8236
8093
|
if (self.spawnflags & HURT_SPAWNFLAGS.NoMonsters && other.svflags & 4 /* Monster */) {
|
|
8237
8094
|
return;
|
|
@@ -8246,6 +8103,9 @@ function hurtTouch(self, other, entities) {
|
|
|
8246
8103
|
const damage = self.dmg || 5;
|
|
8247
8104
|
other.health -= damage;
|
|
8248
8105
|
}
|
|
8106
|
+
function toggleSolid2(self) {
|
|
8107
|
+
self.solid = self.solid === 0 /* Not */ ? 1 /* Trigger */ : 0 /* Not */;
|
|
8108
|
+
}
|
|
8249
8109
|
function registerTriggerHurt(registry) {
|
|
8250
8110
|
registry.register("trigger_hurt", (entity, context) => {
|
|
8251
8111
|
initTrigger(entity);
|
|
@@ -8258,12 +8118,17 @@ function registerTriggerHurt(registry) {
|
|
|
8258
8118
|
}
|
|
8259
8119
|
if (entity.spawnflags & HURT_SPAWNFLAGS.Toggle) {
|
|
8260
8120
|
entity.use = (self) => {
|
|
8261
|
-
|
|
8121
|
+
toggleSolid2(self);
|
|
8262
8122
|
self.touch = self.solid === 1 /* Trigger */ ? touchHandler : void 0;
|
|
8263
8123
|
};
|
|
8264
8124
|
}
|
|
8265
8125
|
});
|
|
8266
8126
|
}
|
|
8127
|
+
|
|
8128
|
+
// src/entities/triggers/teleport.ts
|
|
8129
|
+
var TELEPORT_SPAWNFLAGS = {
|
|
8130
|
+
StartOn: 1 << 3
|
|
8131
|
+
};
|
|
8267
8132
|
function teleportTouch(self, other, entities, warn) {
|
|
8268
8133
|
if (!other) {
|
|
8269
8134
|
return;
|
|
@@ -8305,6 +8170,13 @@ function registerTriggerTeleport(registry) {
|
|
|
8305
8170
|
entity.touch = (self, other) => teleportTouch(self, other, context.entities, context.warn);
|
|
8306
8171
|
});
|
|
8307
8172
|
}
|
|
8173
|
+
|
|
8174
|
+
// src/entities/triggers/gravity.ts
|
|
8175
|
+
var GRAVITY_SPAWNFLAGS = {
|
|
8176
|
+
Toggle: 1 << 0,
|
|
8177
|
+
StartOff: 1 << 1,
|
|
8178
|
+
Clip: 1 << 2
|
|
8179
|
+
};
|
|
8308
8180
|
function gravityTouch(self, other) {
|
|
8309
8181
|
if (!other) {
|
|
8310
8182
|
return;
|
|
@@ -8313,6 +8185,9 @@ function gravityTouch(self, other) {
|
|
|
8313
8185
|
}
|
|
8314
8186
|
other.gravity = self.gravity;
|
|
8315
8187
|
}
|
|
8188
|
+
function toggleSolid3(self) {
|
|
8189
|
+
self.solid = self.solid === 0 /* Not */ ? 1 /* Trigger */ : 0 /* Not */;
|
|
8190
|
+
}
|
|
8316
8191
|
function registerTriggerGravity(registry) {
|
|
8317
8192
|
registry.register("trigger_gravity", (entity, context) => {
|
|
8318
8193
|
const gravityText = context.keyValues.gravity;
|
|
@@ -8331,35 +8206,21 @@ function registerTriggerGravity(registry) {
|
|
|
8331
8206
|
}
|
|
8332
8207
|
if (entity.spawnflags & GRAVITY_SPAWNFLAGS.Toggle) {
|
|
8333
8208
|
entity.use = (self) => {
|
|
8334
|
-
|
|
8209
|
+
toggleSolid3(self);
|
|
8335
8210
|
self.touch = self.solid === 1 /* Trigger */ ? touchHandler : void 0;
|
|
8336
8211
|
};
|
|
8337
8212
|
}
|
|
8338
8213
|
});
|
|
8339
8214
|
}
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
if (other.svflags & 2 /* DeadMonster */) {
|
|
8348
|
-
return;
|
|
8349
|
-
}
|
|
8350
|
-
if ((other.svflags & 4 /* Monster */) === 0) {
|
|
8351
|
-
return;
|
|
8352
|
-
}
|
|
8353
|
-
other.velocity = {
|
|
8354
|
-
x: self.movedir.x * self.speed,
|
|
8355
|
-
y: self.movedir.y * self.speed,
|
|
8356
|
-
z: other.velocity.z
|
|
8357
|
-
};
|
|
8358
|
-
if (!other.groundentity) {
|
|
8359
|
-
return;
|
|
8215
|
+
|
|
8216
|
+
// src/entities/triggers/elevator.ts
|
|
8217
|
+
function trainResume(train, entities) {
|
|
8218
|
+
if (!train.think) {
|
|
8219
|
+
train.think = (self) => {
|
|
8220
|
+
self.nextthink = 0;
|
|
8221
|
+
};
|
|
8360
8222
|
}
|
|
8361
|
-
|
|
8362
|
-
other.velocity = { x: other.velocity.x, y: other.velocity.y, z: self.movedir.z };
|
|
8223
|
+
entities.scheduleThink(train, entities.timeSeconds + FRAME_TIME_SECONDS);
|
|
8363
8224
|
}
|
|
8364
8225
|
function triggerElevatorUse(self, other, entities, warn) {
|
|
8365
8226
|
if (!self.movetarget) {
|
|
@@ -8404,6 +8265,40 @@ function registerTriggerElevator(registry) {
|
|
|
8404
8265
|
context.entities.scheduleThink(entity, context.entities.timeSeconds + FRAME_TIME_SECONDS);
|
|
8405
8266
|
});
|
|
8406
8267
|
}
|
|
8268
|
+
|
|
8269
|
+
// src/entities/triggers/monsterjump.ts
|
|
8270
|
+
var MONSTERJUMP_SPAWNFLAGS = {
|
|
8271
|
+
Toggle: 1 << 0,
|
|
8272
|
+
StartOff: 1 << 1,
|
|
8273
|
+
Clip: 1 << 2
|
|
8274
|
+
};
|
|
8275
|
+
function monsterJumpTouch(self, other) {
|
|
8276
|
+
if (!other) {
|
|
8277
|
+
return;
|
|
8278
|
+
}
|
|
8279
|
+
if ((other.flags & (1 /* Fly */ | 2 /* Swim */)) !== 0) {
|
|
8280
|
+
return;
|
|
8281
|
+
}
|
|
8282
|
+
if (other.svflags & 2 /* DeadMonster */) {
|
|
8283
|
+
return;
|
|
8284
|
+
}
|
|
8285
|
+
if ((other.svflags & 4 /* Monster */) === 0) {
|
|
8286
|
+
return;
|
|
8287
|
+
}
|
|
8288
|
+
other.velocity = {
|
|
8289
|
+
x: self.movedir.x * self.speed,
|
|
8290
|
+
y: self.movedir.y * self.speed,
|
|
8291
|
+
z: other.velocity.z
|
|
8292
|
+
};
|
|
8293
|
+
if (!other.groundentity) {
|
|
8294
|
+
return;
|
|
8295
|
+
}
|
|
8296
|
+
other.groundentity = null;
|
|
8297
|
+
other.velocity = { x: other.velocity.x, y: other.velocity.y, z: self.movedir.z };
|
|
8298
|
+
}
|
|
8299
|
+
function toggleSolid4(self) {
|
|
8300
|
+
self.solid = self.solid === 0 /* Not */ ? 1 /* Trigger */ : 0 /* Not */;
|
|
8301
|
+
}
|
|
8407
8302
|
function registerTriggerMonsterJump(registry) {
|
|
8408
8303
|
registry.register("trigger_monsterjump", (entity, context) => {
|
|
8409
8304
|
const heightText = context.keyValues.height;
|
|
@@ -8424,29 +8319,255 @@ function registerTriggerMonsterJump(registry) {
|
|
|
8424
8319
|
}
|
|
8425
8320
|
if (entity.spawnflags & MONSTERJUMP_SPAWNFLAGS.Toggle) {
|
|
8426
8321
|
entity.use = (self) => {
|
|
8427
|
-
|
|
8322
|
+
toggleSolid4(self);
|
|
8428
8323
|
self.touch = self.solid === 1 /* Trigger */ ? touchHandler : void 0;
|
|
8429
8324
|
};
|
|
8430
8325
|
}
|
|
8431
8326
|
});
|
|
8432
8327
|
}
|
|
8433
|
-
|
|
8434
|
-
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
|
|
8439
|
-
|
|
8440
|
-
registerTriggerPush(registry);
|
|
8441
|
-
registerTriggerHurt(registry);
|
|
8442
|
-
registerTriggerTeleport(registry);
|
|
8443
|
-
registerTriggerGravity(registry);
|
|
8444
|
-
registerTriggerElevator(registry);
|
|
8445
|
-
registerTriggerMonsterJump(registry);
|
|
8446
|
-
registerTriggerFog(registry);
|
|
8447
|
-
registerTriggerFlashlight(registry);
|
|
8448
|
-
registerBadArea(registry);
|
|
8328
|
+
|
|
8329
|
+
// src/entities/triggers/fog.ts
|
|
8330
|
+
function clamp2(value, min, max) {
|
|
8331
|
+
return Math.min(Math.max(value, min), max);
|
|
8332
|
+
}
|
|
8333
|
+
function lerp(start, end, t) {
|
|
8334
|
+
return start + (end - start) * t;
|
|
8449
8335
|
}
|
|
8336
|
+
var SPAWNFLAG_FOG_AFFECT_FOG = 1;
|
|
8337
|
+
var SPAWNFLAG_FOG_INSTANTANEOUS = 4;
|
|
8338
|
+
var SPAWNFLAG_FOG_FORCE = 8;
|
|
8339
|
+
var SPAWNFLAG_FOG_BLEND = 16;
|
|
8340
|
+
function trigger_fog_touch(self, other, context) {
|
|
8341
|
+
if (!other || !other.client) return;
|
|
8342
|
+
if (self.timestamp > context.timeSeconds) return;
|
|
8343
|
+
self.timestamp = context.timeSeconds + (self.wait || 0);
|
|
8344
|
+
let fog_value_storage = self;
|
|
8345
|
+
if (self.movetarget) {
|
|
8346
|
+
fog_value_storage = self.movetarget;
|
|
8347
|
+
}
|
|
8348
|
+
if (self.spawnflags & SPAWNFLAG_FOG_INSTANTANEOUS) {
|
|
8349
|
+
if (other.client.pers) other.client.pers.fog_transition_time = 0;
|
|
8350
|
+
} else {
|
|
8351
|
+
if (other.client.pers) other.client.pers.fog_transition_time = fog_value_storage.delay || 0.5;
|
|
8352
|
+
}
|
|
8353
|
+
if (self.spawnflags & SPAWNFLAG_FOG_BLEND) {
|
|
8354
|
+
const center = scaleVec3(addVec3(self.absmin, self.absmax), 0.5);
|
|
8355
|
+
const half_size = addVec3(scaleVec3(self.size, 0.5), scaleVec3(other.size, 0.5));
|
|
8356
|
+
const start = {
|
|
8357
|
+
x: -self.movedir.x * half_size.x,
|
|
8358
|
+
y: -self.movedir.y * half_size.y,
|
|
8359
|
+
z: -self.movedir.z * half_size.z
|
|
8360
|
+
};
|
|
8361
|
+
const end = {
|
|
8362
|
+
x: self.movedir.x * half_size.x,
|
|
8363
|
+
y: self.movedir.y * half_size.y,
|
|
8364
|
+
z: self.movedir.z * half_size.z
|
|
8365
|
+
};
|
|
8366
|
+
const delta = subtractVec3(other.origin, center);
|
|
8367
|
+
const absMovedir = {
|
|
8368
|
+
x: Math.abs(self.movedir.x),
|
|
8369
|
+
y: Math.abs(self.movedir.y),
|
|
8370
|
+
z: Math.abs(self.movedir.z)
|
|
8371
|
+
};
|
|
8372
|
+
const player_dist = {
|
|
8373
|
+
x: delta.x * absMovedir.x,
|
|
8374
|
+
y: delta.y * absMovedir.y,
|
|
8375
|
+
z: delta.z * absMovedir.z
|
|
8376
|
+
};
|
|
8377
|
+
let dist = lengthVec3(subtractVec3(player_dist, start));
|
|
8378
|
+
dist /= lengthVec3(subtractVec3(start, end));
|
|
8379
|
+
dist = clamp2(dist, 0, 1);
|
|
8380
|
+
if (self.spawnflags & SPAWNFLAG_FOG_AFFECT_FOG) {
|
|
8381
|
+
const storage2 = fog_value_storage;
|
|
8382
|
+
if (other.client.pers) {
|
|
8383
|
+
other.client.pers.wanted_fog = {
|
|
8384
|
+
density: lerp(storage2.fog_density_off || 0, storage2.fog_density || 0, dist),
|
|
8385
|
+
r: lerp(storage2.fog_color_off?.[0] || 0, storage2.fog_color?.[0] || 0, dist),
|
|
8386
|
+
g: lerp(storage2.fog_color_off?.[1] || 0, storage2.fog_color?.[1] || 0, dist),
|
|
8387
|
+
b: lerp(storage2.fog_color_off?.[2] || 0, storage2.fog_color?.[2] || 0, dist),
|
|
8388
|
+
sky_factor: lerp(storage2.fog_sky_factor_off || 0, storage2.fog_sky_factor || 0, dist)
|
|
8389
|
+
};
|
|
8390
|
+
}
|
|
8391
|
+
}
|
|
8392
|
+
return;
|
|
8393
|
+
}
|
|
8394
|
+
let use_on = true;
|
|
8395
|
+
if (!(self.spawnflags & SPAWNFLAG_FOG_FORCE)) {
|
|
8396
|
+
const len = lengthVec3(other.velocity);
|
|
8397
|
+
if (len <= 1e-4) return;
|
|
8398
|
+
const forward = normalizeVec3(other.velocity);
|
|
8399
|
+
const dot = forward.x * self.movedir.x + forward.y * self.movedir.y + forward.z * self.movedir.z;
|
|
8400
|
+
use_on = dot > 0;
|
|
8401
|
+
}
|
|
8402
|
+
const storage = fog_value_storage;
|
|
8403
|
+
if (self.spawnflags & SPAWNFLAG_FOG_AFFECT_FOG) {
|
|
8404
|
+
if (other.client.pers) {
|
|
8405
|
+
if (use_on) {
|
|
8406
|
+
other.client.pers.wanted_fog = {
|
|
8407
|
+
density: storage.fog_density || 0,
|
|
8408
|
+
r: storage.fog_color?.[0] || 0,
|
|
8409
|
+
g: storage.fog_color?.[1] || 0,
|
|
8410
|
+
b: storage.fog_color?.[2] || 0,
|
|
8411
|
+
sky_factor: storage.fog_sky_factor || 0
|
|
8412
|
+
};
|
|
8413
|
+
} else {
|
|
8414
|
+
other.client.pers.wanted_fog = {
|
|
8415
|
+
density: storage.fog_density_off || 0,
|
|
8416
|
+
r: storage.fog_color_off?.[0] || 0,
|
|
8417
|
+
g: storage.fog_color_off?.[1] || 0,
|
|
8418
|
+
b: storage.fog_color_off?.[2] || 0,
|
|
8419
|
+
sky_factor: storage.fog_sky_factor_off || 0
|
|
8420
|
+
};
|
|
8421
|
+
}
|
|
8422
|
+
}
|
|
8423
|
+
}
|
|
8424
|
+
}
|
|
8425
|
+
function registerTriggerFog(registry) {
|
|
8426
|
+
registry.register("trigger_fog", (entity, context) => {
|
|
8427
|
+
entity.solid = 1 /* Trigger */;
|
|
8428
|
+
entity.movetype = 0 /* None */;
|
|
8429
|
+
entity.svflags |= 1 /* NoClient */;
|
|
8430
|
+
const entAny = entity;
|
|
8431
|
+
const kv = context.keyValues;
|
|
8432
|
+
entAny.fog_density = parseFloat(kv.fog_density) || 0;
|
|
8433
|
+
entAny.fog_color = kv.fog_color ? kv.fog_color.split(" ").map(parseFloat) : [0, 0, 0];
|
|
8434
|
+
entAny.fog_sky_factor = parseFloat(kv.fog_sky_factor) || 0;
|
|
8435
|
+
entAny.fog_density_off = parseFloat(kv.fog_density_off) || 0;
|
|
8436
|
+
entAny.fog_color_off = kv.fog_color_off ? kv.fog_color_off.split(" ").map(parseFloat) : [0, 0, 0];
|
|
8437
|
+
entAny.fog_sky_factor_off = parseFloat(kv.fog_sky_factor_off) || 0;
|
|
8438
|
+
if (entity.target) {
|
|
8439
|
+
entity.movetype = 0 /* None */;
|
|
8440
|
+
entity.movetarget = null;
|
|
8441
|
+
}
|
|
8442
|
+
if (!entity.delay) entity.delay = 0.5;
|
|
8443
|
+
entity.touch = (self, other) => trigger_fog_touch(self, other, context.entities);
|
|
8444
|
+
});
|
|
8445
|
+
}
|
|
8446
|
+
|
|
8447
|
+
// src/entities/triggers/flashlight.ts
|
|
8448
|
+
var registerTriggerFlashlight = (registry) => {
|
|
8449
|
+
registry.register("trigger_flashlight", (self, context) => {
|
|
8450
|
+
self.solid = 1 /* Trigger */;
|
|
8451
|
+
self.movetype = 0;
|
|
8452
|
+
self.svflags |= 1 /* NoClient */;
|
|
8453
|
+
self.touch = (self2, other, plane, surf) => {
|
|
8454
|
+
if (!other || !other.client) return;
|
|
8455
|
+
const style = self2.style || 0;
|
|
8456
|
+
let sound = "";
|
|
8457
|
+
if (style === 0) {
|
|
8458
|
+
if (other.flags & 4194304 /* Flashlight */) {
|
|
8459
|
+
other.flags &= ~4194304 /* Flashlight */;
|
|
8460
|
+
sound = "items/flashlight_off.wav";
|
|
8461
|
+
} else {
|
|
8462
|
+
other.flags |= 4194304 /* Flashlight */;
|
|
8463
|
+
sound = "items/flashlight_on.wav";
|
|
8464
|
+
}
|
|
8465
|
+
} else if (style === 1) {
|
|
8466
|
+
if (!(other.flags & 4194304 /* Flashlight */)) {
|
|
8467
|
+
other.flags |= 4194304 /* Flashlight */;
|
|
8468
|
+
sound = "items/flashlight_on.wav";
|
|
8469
|
+
}
|
|
8470
|
+
} else if (style === 2) {
|
|
8471
|
+
if (other.flags & 4194304 /* Flashlight */) {
|
|
8472
|
+
other.flags &= ~4194304 /* Flashlight */;
|
|
8473
|
+
sound = "items/flashlight_off.wav";
|
|
8474
|
+
}
|
|
8475
|
+
}
|
|
8476
|
+
if (other.flags & 4194304 /* Flashlight */) {
|
|
8477
|
+
other.renderfx |= RenderFx.Flashlight;
|
|
8478
|
+
} else {
|
|
8479
|
+
other.renderfx &= ~RenderFx.Flashlight;
|
|
8480
|
+
}
|
|
8481
|
+
if (sound) {
|
|
8482
|
+
context.entities.sound(other, 0, sound, 1, 3, 0);
|
|
8483
|
+
}
|
|
8484
|
+
};
|
|
8485
|
+
context.entities.linkentity(self);
|
|
8486
|
+
});
|
|
8487
|
+
};
|
|
8488
|
+
|
|
8489
|
+
// src/entities/triggers/secret.ts
|
|
8490
|
+
var SECRET_SPAWNFLAGS = {
|
|
8491
|
+
Once: 1 << 0
|
|
8492
|
+
};
|
|
8493
|
+
function triggerSecretTouch(self, other, entities) {
|
|
8494
|
+
if (!other || !other.client) {
|
|
8495
|
+
return;
|
|
8496
|
+
}
|
|
8497
|
+
if (self.timestamp > entities.timeSeconds) {
|
|
8498
|
+
return;
|
|
8499
|
+
}
|
|
8500
|
+
self.timestamp = entities.timeSeconds + 1;
|
|
8501
|
+
if (!self.message) {
|
|
8502
|
+
self.message = "You found a secret area!";
|
|
8503
|
+
}
|
|
8504
|
+
if (other.client) {
|
|
8505
|
+
entities.engine.centerprintf?.(other, self.message);
|
|
8506
|
+
entities.sound(other, 0, "misc/secret.wav", 1, 1, 0);
|
|
8507
|
+
}
|
|
8508
|
+
if (self.spawnflags & SECRET_SPAWNFLAGS.Once) {
|
|
8509
|
+
entities.free(self);
|
|
8510
|
+
}
|
|
8511
|
+
}
|
|
8512
|
+
function registerTriggerSecret(registry) {
|
|
8513
|
+
registry.register("trigger_secret", (entity, context) => {
|
|
8514
|
+
entity.movetype = 0 /* None */;
|
|
8515
|
+
entity.solid = 1 /* Trigger */;
|
|
8516
|
+
entity.svflags |= 1 /* NoClient */;
|
|
8517
|
+
entity.movedir = setMovedir(entity.angles);
|
|
8518
|
+
entity.angles = { x: 0, y: 0, z: 0 };
|
|
8519
|
+
if (entity.targetname) {
|
|
8520
|
+
entity.solid = 0 /* Not */;
|
|
8521
|
+
entity.use = (self) => {
|
|
8522
|
+
self.solid = 1 /* Trigger */;
|
|
8523
|
+
self.use = void 0;
|
|
8524
|
+
};
|
|
8525
|
+
}
|
|
8526
|
+
entity.touch = (self, other) => triggerSecretTouch(self, other, context.entities);
|
|
8527
|
+
});
|
|
8528
|
+
}
|
|
8529
|
+
|
|
8530
|
+
// src/entities/triggers/look.ts
|
|
8531
|
+
var LOOK_SPAWNFLAGS = {
|
|
8532
|
+
LookAway: 1 << 0
|
|
8533
|
+
};
|
|
8534
|
+
function triggerLookThink(self, entities) {
|
|
8535
|
+
let fired = false;
|
|
8536
|
+
const players = entities.findByClassname("player");
|
|
8537
|
+
for (const player of players) {
|
|
8538
|
+
if (player.health <= 0) continue;
|
|
8539
|
+
const vec = subtractVec3(self.origin, player.origin);
|
|
8540
|
+
const dist = Math.sqrt(dotVec3(vec, vec));
|
|
8541
|
+
const dir = normalizeVec3(vec);
|
|
8542
|
+
const forward = angleVectors(player.angles).forward;
|
|
8543
|
+
const dot = dotVec3(forward, dir);
|
|
8544
|
+
const fov = self.fov || 0.9;
|
|
8545
|
+
if (dot >= fov) {
|
|
8546
|
+
fired = true;
|
|
8547
|
+
self.activator = player;
|
|
8548
|
+
entities.useTargets(self, player);
|
|
8549
|
+
break;
|
|
8550
|
+
}
|
|
8551
|
+
}
|
|
8552
|
+
if (fired) {
|
|
8553
|
+
entities.free(self);
|
|
8554
|
+
} else {
|
|
8555
|
+
entities.scheduleThink(self, entities.timeSeconds + 0.1);
|
|
8556
|
+
}
|
|
8557
|
+
}
|
|
8558
|
+
function registerTriggerLook(registry) {
|
|
8559
|
+
registry.register("trigger_look", (entity, context) => {
|
|
8560
|
+
entity.movetype = 0 /* None */;
|
|
8561
|
+
entity.solid = 0 /* Not */;
|
|
8562
|
+
entity.svflags |= 1 /* NoClient */;
|
|
8563
|
+
entity.movedir = setMovedir(entity.angles);
|
|
8564
|
+
if (!entity.fov) entity.fov = 0.9;
|
|
8565
|
+
entity.think = (self) => triggerLookThink(self, context.entities);
|
|
8566
|
+
context.entities.scheduleThink(entity, context.entities.timeSeconds + 0.1);
|
|
8567
|
+
});
|
|
8568
|
+
}
|
|
8569
|
+
|
|
8570
|
+
// src/entities/triggers/bad_area.ts
|
|
8450
8571
|
function badAreaTouch(self, other) {
|
|
8451
8572
|
if (!other) return;
|
|
8452
8573
|
if (other.takedamage) {
|
|
@@ -8465,6 +8586,27 @@ function registerBadArea(registry) {
|
|
|
8465
8586
|
});
|
|
8466
8587
|
}
|
|
8467
8588
|
|
|
8589
|
+
// src/entities/triggers/index.ts
|
|
8590
|
+
function registerTriggerSpawns(registry) {
|
|
8591
|
+
registerTriggerMultiple(registry);
|
|
8592
|
+
registerTriggerOnce(registry);
|
|
8593
|
+
registerTriggerRelay(registry);
|
|
8594
|
+
registerTriggerAlways(registry);
|
|
8595
|
+
registerTriggerCounter(registry);
|
|
8596
|
+
registerTriggerKey(registry);
|
|
8597
|
+
registerTriggerPush(registry);
|
|
8598
|
+
registerTriggerHurt(registry);
|
|
8599
|
+
registerTriggerTeleport(registry);
|
|
8600
|
+
registerTriggerGravity(registry);
|
|
8601
|
+
registerTriggerElevator(registry);
|
|
8602
|
+
registerTriggerMonsterJump(registry);
|
|
8603
|
+
registerTriggerFog(registry);
|
|
8604
|
+
registerTriggerFlashlight(registry);
|
|
8605
|
+
registerTriggerSecret(registry);
|
|
8606
|
+
registerTriggerLook(registry);
|
|
8607
|
+
registerBadArea(registry);
|
|
8608
|
+
}
|
|
8609
|
+
|
|
8468
8610
|
// src/combat/weapons/state.ts
|
|
8469
8611
|
var WeaponStateEnum = /* @__PURE__ */ ((WeaponStateEnum2) => {
|
|
8470
8612
|
WeaponStateEnum2[WeaponStateEnum2["WEAPON_READY"] = 0] = "WEAPON_READY";
|