quake2ts 0.0.494 → 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
|
@@ -7932,170 +7932,7 @@ function registerTargetSpawns(registry) {
|
|
|
7932
7932
|
});
|
|
7933
7933
|
}
|
|
7934
7934
|
|
|
7935
|
-
// src/entities/triggers/
|
|
7936
|
-
function clamp2(value, min, max) {
|
|
7937
|
-
return Math.min(Math.max(value, min), max);
|
|
7938
|
-
}
|
|
7939
|
-
function lerp(start, end, t) {
|
|
7940
|
-
return start + (end - start) * t;
|
|
7941
|
-
}
|
|
7942
|
-
var SPAWNFLAG_FOG_AFFECT_FOG = 1;
|
|
7943
|
-
var SPAWNFLAG_FOG_INSTANTANEOUS = 4;
|
|
7944
|
-
var SPAWNFLAG_FOG_FORCE = 8;
|
|
7945
|
-
var SPAWNFLAG_FOG_BLEND = 16;
|
|
7946
|
-
function trigger_fog_touch(self, other, context) {
|
|
7947
|
-
if (!other || !other.client) return;
|
|
7948
|
-
if (self.timestamp > context.timeSeconds) return;
|
|
7949
|
-
self.timestamp = context.timeSeconds + (self.wait || 0);
|
|
7950
|
-
let fog_value_storage = self;
|
|
7951
|
-
if (self.movetarget) {
|
|
7952
|
-
fog_value_storage = self.movetarget;
|
|
7953
|
-
}
|
|
7954
|
-
if (self.spawnflags & SPAWNFLAG_FOG_INSTANTANEOUS) {
|
|
7955
|
-
if (other.client.pers) other.client.pers.fog_transition_time = 0;
|
|
7956
|
-
} else {
|
|
7957
|
-
if (other.client.pers) other.client.pers.fog_transition_time = fog_value_storage.delay || 0.5;
|
|
7958
|
-
}
|
|
7959
|
-
if (self.spawnflags & SPAWNFLAG_FOG_BLEND) {
|
|
7960
|
-
const center = scaleVec3(addVec3(self.absmin, self.absmax), 0.5);
|
|
7961
|
-
const half_size = addVec3(scaleVec3(self.size, 0.5), scaleVec3(other.size, 0.5));
|
|
7962
|
-
const start = {
|
|
7963
|
-
x: -self.movedir.x * half_size.x,
|
|
7964
|
-
y: -self.movedir.y * half_size.y,
|
|
7965
|
-
z: -self.movedir.z * half_size.z
|
|
7966
|
-
};
|
|
7967
|
-
const end = {
|
|
7968
|
-
x: self.movedir.x * half_size.x,
|
|
7969
|
-
y: self.movedir.y * half_size.y,
|
|
7970
|
-
z: self.movedir.z * half_size.z
|
|
7971
|
-
};
|
|
7972
|
-
const delta = subtractVec3(other.origin, center);
|
|
7973
|
-
const absMovedir = {
|
|
7974
|
-
x: Math.abs(self.movedir.x),
|
|
7975
|
-
y: Math.abs(self.movedir.y),
|
|
7976
|
-
z: Math.abs(self.movedir.z)
|
|
7977
|
-
};
|
|
7978
|
-
const player_dist = {
|
|
7979
|
-
x: delta.x * absMovedir.x,
|
|
7980
|
-
y: delta.y * absMovedir.y,
|
|
7981
|
-
z: delta.z * absMovedir.z
|
|
7982
|
-
};
|
|
7983
|
-
let dist = lengthVec3(subtractVec3(player_dist, start));
|
|
7984
|
-
dist /= lengthVec3(subtractVec3(start, end));
|
|
7985
|
-
dist = clamp2(dist, 0, 1);
|
|
7986
|
-
if (self.spawnflags & SPAWNFLAG_FOG_AFFECT_FOG) {
|
|
7987
|
-
const storage2 = fog_value_storage;
|
|
7988
|
-
if (other.client.pers) {
|
|
7989
|
-
other.client.pers.wanted_fog = {
|
|
7990
|
-
density: lerp(storage2.fog_density_off || 0, storage2.fog_density || 0, dist),
|
|
7991
|
-
r: lerp(storage2.fog_color_off?.[0] || 0, storage2.fog_color?.[0] || 0, dist),
|
|
7992
|
-
g: lerp(storage2.fog_color_off?.[1] || 0, storage2.fog_color?.[1] || 0, dist),
|
|
7993
|
-
b: lerp(storage2.fog_color_off?.[2] || 0, storage2.fog_color?.[2] || 0, dist),
|
|
7994
|
-
sky_factor: lerp(storage2.fog_sky_factor_off || 0, storage2.fog_sky_factor || 0, dist)
|
|
7995
|
-
};
|
|
7996
|
-
}
|
|
7997
|
-
}
|
|
7998
|
-
return;
|
|
7999
|
-
}
|
|
8000
|
-
let use_on = true;
|
|
8001
|
-
if (!(self.spawnflags & SPAWNFLAG_FOG_FORCE)) {
|
|
8002
|
-
const len = lengthVec3(other.velocity);
|
|
8003
|
-
if (len <= 1e-4) return;
|
|
8004
|
-
const forward = normalizeVec3(other.velocity);
|
|
8005
|
-
const dot = forward.x * self.movedir.x + forward.y * self.movedir.y + forward.z * self.movedir.z;
|
|
8006
|
-
use_on = dot > 0;
|
|
8007
|
-
}
|
|
8008
|
-
const storage = fog_value_storage;
|
|
8009
|
-
if (self.spawnflags & SPAWNFLAG_FOG_AFFECT_FOG) {
|
|
8010
|
-
if (other.client.pers) {
|
|
8011
|
-
if (use_on) {
|
|
8012
|
-
other.client.pers.wanted_fog = {
|
|
8013
|
-
density: storage.fog_density || 0,
|
|
8014
|
-
r: storage.fog_color?.[0] || 0,
|
|
8015
|
-
g: storage.fog_color?.[1] || 0,
|
|
8016
|
-
b: storage.fog_color?.[2] || 0,
|
|
8017
|
-
sky_factor: storage.fog_sky_factor || 0
|
|
8018
|
-
};
|
|
8019
|
-
} else {
|
|
8020
|
-
other.client.pers.wanted_fog = {
|
|
8021
|
-
density: storage.fog_density_off || 0,
|
|
8022
|
-
r: storage.fog_color_off?.[0] || 0,
|
|
8023
|
-
g: storage.fog_color_off?.[1] || 0,
|
|
8024
|
-
b: storage.fog_color_off?.[2] || 0,
|
|
8025
|
-
sky_factor: storage.fog_sky_factor_off || 0
|
|
8026
|
-
};
|
|
8027
|
-
}
|
|
8028
|
-
}
|
|
8029
|
-
}
|
|
8030
|
-
}
|
|
8031
|
-
function registerTriggerFog(registry) {
|
|
8032
|
-
registry.register("trigger_fog", (entity, context) => {
|
|
8033
|
-
entity.solid = 1 /* Trigger */;
|
|
8034
|
-
entity.movetype = 0 /* None */;
|
|
8035
|
-
entity.svflags |= 1 /* NoClient */;
|
|
8036
|
-
const entAny = entity;
|
|
8037
|
-
const kv = context.keyValues;
|
|
8038
|
-
entAny.fog_density = parseFloat(kv.fog_density) || 0;
|
|
8039
|
-
entAny.fog_color = kv.fog_color ? kv.fog_color.split(" ").map(parseFloat) : [0, 0, 0];
|
|
8040
|
-
entAny.fog_sky_factor = parseFloat(kv.fog_sky_factor) || 0;
|
|
8041
|
-
entAny.fog_density_off = parseFloat(kv.fog_density_off) || 0;
|
|
8042
|
-
entAny.fog_color_off = kv.fog_color_off ? kv.fog_color_off.split(" ").map(parseFloat) : [0, 0, 0];
|
|
8043
|
-
entAny.fog_sky_factor_off = parseFloat(kv.fog_sky_factor_off) || 0;
|
|
8044
|
-
if (entity.target) {
|
|
8045
|
-
entity.movetype = 0 /* None */;
|
|
8046
|
-
entity.movetarget = null;
|
|
8047
|
-
}
|
|
8048
|
-
if (!entity.delay) entity.delay = 0.5;
|
|
8049
|
-
entity.touch = (self, other) => trigger_fog_touch(self, other, context.entities);
|
|
8050
|
-
});
|
|
8051
|
-
}
|
|
8052
|
-
|
|
8053
|
-
// src/entities/triggers/flashlight.ts
|
|
8054
|
-
var registerTriggerFlashlight = (registry) => {
|
|
8055
|
-
registry.register("trigger_flashlight", (self, context) => {
|
|
8056
|
-
self.solid = 1 /* Trigger */;
|
|
8057
|
-
self.movetype = 0;
|
|
8058
|
-
self.svflags |= 1 /* NoClient */;
|
|
8059
|
-
self.touch = (self2, other, plane, surf) => {
|
|
8060
|
-
if (!other || !other.client) return;
|
|
8061
|
-
const style = self2.style || 0;
|
|
8062
|
-
let sound = "";
|
|
8063
|
-
if (style === 0) {
|
|
8064
|
-
if (other.flags & 4194304 /* Flashlight */) {
|
|
8065
|
-
other.flags &= ~4194304 /* Flashlight */;
|
|
8066
|
-
sound = "items/flashlight_off.wav";
|
|
8067
|
-
} else {
|
|
8068
|
-
other.flags |= 4194304 /* Flashlight */;
|
|
8069
|
-
sound = "items/flashlight_on.wav";
|
|
8070
|
-
}
|
|
8071
|
-
} else if (style === 1) {
|
|
8072
|
-
if (!(other.flags & 4194304 /* Flashlight */)) {
|
|
8073
|
-
other.flags |= 4194304 /* Flashlight */;
|
|
8074
|
-
sound = "items/flashlight_on.wav";
|
|
8075
|
-
}
|
|
8076
|
-
} else if (style === 2) {
|
|
8077
|
-
if (other.flags & 4194304 /* Flashlight */) {
|
|
8078
|
-
other.flags &= ~4194304 /* Flashlight */;
|
|
8079
|
-
sound = "items/flashlight_off.wav";
|
|
8080
|
-
}
|
|
8081
|
-
}
|
|
8082
|
-
if (other.flags & 4194304 /* Flashlight */) {
|
|
8083
|
-
other.renderfx |= RenderFx.Flashlight;
|
|
8084
|
-
} else {
|
|
8085
|
-
other.renderfx &= ~RenderFx.Flashlight;
|
|
8086
|
-
}
|
|
8087
|
-
if (sound) {
|
|
8088
|
-
context.entities.sound(other, 0, sound, 1, 3, 0);
|
|
8089
|
-
}
|
|
8090
|
-
};
|
|
8091
|
-
context.entities.linkentity(self);
|
|
8092
|
-
});
|
|
8093
|
-
};
|
|
8094
|
-
|
|
8095
|
-
// src/entities/triggers.ts
|
|
8096
|
-
var FRAME_TIME_SECONDS = 1 / 40;
|
|
8097
|
-
var THINK_INTERVAL = 0.1;
|
|
8098
|
-
var HURT_INTERVAL = 0.1;
|
|
7935
|
+
// src/entities/triggers/common.ts
|
|
8099
7936
|
var TRIGGER_SPAWNFLAGS = {
|
|
8100
7937
|
Monster: 1 << 0,
|
|
8101
7938
|
NotPlayer: 1 << 1,
|
|
@@ -8104,50 +7941,7 @@ var TRIGGER_SPAWNFLAGS = {
|
|
|
8104
7941
|
Latched: 1 << 4,
|
|
8105
7942
|
Clip: 1 << 5
|
|
8106
7943
|
};
|
|
8107
|
-
var
|
|
8108
|
-
NoSound: 1 << 0
|
|
8109
|
-
};
|
|
8110
|
-
var COUNTER_SPAWNFLAGS = {
|
|
8111
|
-
NoMessage: 1 << 0
|
|
8112
|
-
};
|
|
8113
|
-
var PUSH_SPAWNFLAGS = {
|
|
8114
|
-
Once: 1 << 0,
|
|
8115
|
-
Plus: 1 << 1,
|
|
8116
|
-
Silent: 1 << 2,
|
|
8117
|
-
StartOff: 1 << 3,
|
|
8118
|
-
Clip: 1 << 4
|
|
8119
|
-
};
|
|
8120
|
-
var HURT_SPAWNFLAGS = {
|
|
8121
|
-
StartOff: 1 << 0,
|
|
8122
|
-
Toggle: 1 << 1,
|
|
8123
|
-
Silent: 1 << 2,
|
|
8124
|
-
NoProtection: 1 << 3,
|
|
8125
|
-
Slow: 1 << 4,
|
|
8126
|
-
NoPlayers: 1 << 5,
|
|
8127
|
-
NoMonsters: 1 << 6,
|
|
8128
|
-
Clip: 1 << 7
|
|
8129
|
-
};
|
|
8130
|
-
var TELEPORT_SPAWNFLAGS = {
|
|
8131
|
-
StartOn: 1 << 3
|
|
8132
|
-
};
|
|
8133
|
-
var GRAVITY_SPAWNFLAGS = {
|
|
8134
|
-
Toggle: 1 << 0,
|
|
8135
|
-
StartOff: 1 << 1,
|
|
8136
|
-
Clip: 1 << 2
|
|
8137
|
-
};
|
|
8138
|
-
var MONSTERJUMP_SPAWNFLAGS = {
|
|
8139
|
-
Toggle: 1 << 0,
|
|
8140
|
-
StartOff: 1 << 1,
|
|
8141
|
-
Clip: 1 << 2
|
|
8142
|
-
};
|
|
8143
|
-
function trainResume(train, entities) {
|
|
8144
|
-
if (!train.think) {
|
|
8145
|
-
train.think = (self) => {
|
|
8146
|
-
self.nextthink = 0;
|
|
8147
|
-
};
|
|
8148
|
-
}
|
|
8149
|
-
entities.scheduleThink(train, entities.timeSeconds + FRAME_TIME_SECONDS);
|
|
8150
|
-
}
|
|
7944
|
+
var FRAME_TIME_SECONDS = 1 / 40;
|
|
8151
7945
|
function initTrigger(entity) {
|
|
8152
7946
|
entity.movetype = 0 /* None */;
|
|
8153
7947
|
entity.solid = 1 /* Trigger */;
|
|
@@ -8155,10 +7949,6 @@ function initTrigger(entity) {
|
|
|
8155
7949
|
entity.movedir = setMovedir(entity.angles);
|
|
8156
7950
|
entity.angles = { x: 0, y: 0, z: 0 };
|
|
8157
7951
|
}
|
|
8158
|
-
function multiWait(self) {
|
|
8159
|
-
self.nextthink = 0;
|
|
8160
|
-
self.think = void 0;
|
|
8161
|
-
}
|
|
8162
7952
|
function canActivate(trigger, other) {
|
|
8163
7953
|
if (trigger.solid === 0 /* Not */) {
|
|
8164
7954
|
return false;
|
|
@@ -8183,6 +7973,15 @@ function canActivate(trigger, other) {
|
|
|
8183
7973
|
}
|
|
8184
7974
|
return true;
|
|
8185
7975
|
}
|
|
7976
|
+
function triggerEnable(self) {
|
|
7977
|
+
self.solid = 1 /* Trigger */;
|
|
7978
|
+
}
|
|
7979
|
+
|
|
7980
|
+
// src/entities/triggers/multiple.ts
|
|
7981
|
+
function multiWait(self) {
|
|
7982
|
+
self.nextthink = 0;
|
|
7983
|
+
self.think = void 0;
|
|
7984
|
+
}
|
|
8186
7985
|
function multiTrigger(self, entities) {
|
|
8187
7986
|
if (self.nextthink > entities.timeSeconds) {
|
|
8188
7987
|
return;
|
|
@@ -8241,9 +8040,6 @@ function useMulti(self, _other, activator, entities) {
|
|
|
8241
8040
|
self.activator = activator;
|
|
8242
8041
|
multiTrigger(self, entities);
|
|
8243
8042
|
}
|
|
8244
|
-
function triggerEnable(self) {
|
|
8245
|
-
self.solid = 1 /* Trigger */;
|
|
8246
|
-
}
|
|
8247
8043
|
function registerTriggerMultiple(registry) {
|
|
8248
8044
|
registry.register("trigger_multiple", (entity, context) => {
|
|
8249
8045
|
initTrigger(entity);
|
|
@@ -8269,12 +8065,23 @@ function registerTriggerMultiple(registry) {
|
|
|
8269
8065
|
entity.touch = (self, other) => touchMulti(self, other, context.entities);
|
|
8270
8066
|
});
|
|
8271
8067
|
}
|
|
8068
|
+
|
|
8069
|
+
// src/entities/triggers/once.ts
|
|
8272
8070
|
function registerTriggerOnce(registry) {
|
|
8273
8071
|
registry.register("trigger_once", (entity, context) => {
|
|
8274
8072
|
entity.wait = -1;
|
|
8275
|
-
registry.get("trigger_multiple")
|
|
8073
|
+
const multipleSpawn = registry.get("trigger_multiple");
|
|
8074
|
+
if (multipleSpawn) {
|
|
8075
|
+
multipleSpawn(entity, context);
|
|
8076
|
+
} else {
|
|
8077
|
+
}
|
|
8276
8078
|
});
|
|
8277
8079
|
}
|
|
8080
|
+
|
|
8081
|
+
// src/entities/triggers/relay.ts
|
|
8082
|
+
var RELAY_SPAWNFLAGS = {
|
|
8083
|
+
NoSound: 1 << 0
|
|
8084
|
+
};
|
|
8278
8085
|
function registerTriggerRelay(registry) {
|
|
8279
8086
|
registry.register("trigger_relay", (entity, context) => {
|
|
8280
8087
|
if (entity.spawnflags & RELAY_SPAWNFLAGS.NoSound) {
|
|
@@ -8291,6 +8098,8 @@ function registerTriggerRelay(registry) {
|
|
|
8291
8098
|
};
|
|
8292
8099
|
});
|
|
8293
8100
|
}
|
|
8101
|
+
|
|
8102
|
+
// src/entities/triggers/always.ts
|
|
8294
8103
|
function registerTriggerAlways(registry) {
|
|
8295
8104
|
registry.register("trigger_always", (entity, context) => {
|
|
8296
8105
|
if (entity.delay === 0) {
|
|
@@ -8299,14 +8108,27 @@ function registerTriggerAlways(registry) {
|
|
|
8299
8108
|
context.entities.useTargets(entity, entity);
|
|
8300
8109
|
});
|
|
8301
8110
|
}
|
|
8111
|
+
|
|
8112
|
+
// src/entities/triggers/counter.ts
|
|
8113
|
+
var COUNTER_SPAWNFLAGS = {
|
|
8114
|
+
NoMessage: 1 << 0
|
|
8115
|
+
};
|
|
8302
8116
|
function counterUse(self, _other, activator, entities) {
|
|
8303
8117
|
if (self.count === 0) {
|
|
8304
8118
|
return;
|
|
8305
8119
|
}
|
|
8306
8120
|
self.count -= 1;
|
|
8307
8121
|
if (self.count > 0) {
|
|
8122
|
+
if (!(self.spawnflags & COUNTER_SPAWNFLAGS.NoMessage) && activator && activator.client) {
|
|
8123
|
+
entities.engine.centerprintf?.(activator, `${self.count} more to go...`);
|
|
8124
|
+
entities.sound(activator, 0, "misc/talk1.wav", 1, 1, 0);
|
|
8125
|
+
}
|
|
8308
8126
|
return;
|
|
8309
8127
|
}
|
|
8128
|
+
if (!(self.spawnflags & COUNTER_SPAWNFLAGS.NoMessage) && activator && activator.client) {
|
|
8129
|
+
entities.engine.centerprintf?.(activator, "Sequence completed!");
|
|
8130
|
+
entities.sound(activator, 0, "misc/talk1.wav", 1, 1, 0);
|
|
8131
|
+
}
|
|
8310
8132
|
self.activator = activator;
|
|
8311
8133
|
multiTrigger(self, entities);
|
|
8312
8134
|
}
|
|
@@ -8322,6 +8144,8 @@ function registerTriggerCounter(registry) {
|
|
|
8322
8144
|
}
|
|
8323
8145
|
});
|
|
8324
8146
|
}
|
|
8147
|
+
|
|
8148
|
+
// src/entities/triggers/key.ts
|
|
8325
8149
|
function triggerKeyUse(self, activator, entities, warn) {
|
|
8326
8150
|
if (!self.item || !activator) {
|
|
8327
8151
|
return;
|
|
@@ -8332,13 +8156,17 @@ function triggerKeyUse(self, activator, entities, warn) {
|
|
|
8332
8156
|
return;
|
|
8333
8157
|
}
|
|
8334
8158
|
self.timestamp = entities.timeSeconds + 5;
|
|
8335
|
-
|
|
8159
|
+
if (activator.client) {
|
|
8160
|
+
entities.engine.centerprintf?.(activator, `You need the ${self.item}`);
|
|
8161
|
+
entities.sound(activator, 0, "misc/keytry.wav", 1, 1, 0);
|
|
8162
|
+
}
|
|
8336
8163
|
return;
|
|
8337
8164
|
}
|
|
8338
8165
|
activator.inventory[self.item] = available - 1;
|
|
8339
8166
|
if (activator.inventory[self.item] <= 0) {
|
|
8340
8167
|
delete activator.inventory[self.item];
|
|
8341
8168
|
}
|
|
8169
|
+
entities.sound(activator, 0, "misc/keyuse.wav", 1, 1, 0);
|
|
8342
8170
|
entities.useTargets(self, activator);
|
|
8343
8171
|
self.use = void 0;
|
|
8344
8172
|
}
|
|
@@ -8354,6 +8182,16 @@ function registerTriggerKey(registry) {
|
|
|
8354
8182
|
entity.use = (self, other, activator) => triggerKeyUse(self, activator ?? other, context.entities, context.warn);
|
|
8355
8183
|
});
|
|
8356
8184
|
}
|
|
8185
|
+
|
|
8186
|
+
// src/entities/triggers/push.ts
|
|
8187
|
+
var PUSH_SPAWNFLAGS = {
|
|
8188
|
+
Once: 1 << 0,
|
|
8189
|
+
Plus: 1 << 1,
|
|
8190
|
+
Silent: 1 << 2,
|
|
8191
|
+
StartOff: 1 << 3,
|
|
8192
|
+
Clip: 1 << 4
|
|
8193
|
+
};
|
|
8194
|
+
var THINK_INTERVAL = 0.1;
|
|
8357
8195
|
function triggerPushTouch(self, other, entities) {
|
|
8358
8196
|
if (!other) {
|
|
8359
8197
|
return;
|
|
@@ -8365,6 +8203,12 @@ function triggerPushTouch(self, other, entities) {
|
|
|
8365
8203
|
y: self.movedir.y * scale,
|
|
8366
8204
|
z: self.movedir.z * scale
|
|
8367
8205
|
};
|
|
8206
|
+
if (!(self.spawnflags & PUSH_SPAWNFLAGS.Silent)) {
|
|
8207
|
+
if (!other.fly_sound_debounce_time || other.fly_sound_debounce_time < entities.timeSeconds) {
|
|
8208
|
+
other.fly_sound_debounce_time = entities.timeSeconds + 1.5;
|
|
8209
|
+
entities.sound(other, 0, "misc/windfly.wav", 1, 1, 0);
|
|
8210
|
+
}
|
|
8211
|
+
}
|
|
8368
8212
|
}
|
|
8369
8213
|
if (self.spawnflags & PUSH_SPAWNFLAGS.Once) {
|
|
8370
8214
|
entities.free(self);
|
|
@@ -8426,12 +8270,25 @@ function registerTriggerPush(registry) {
|
|
|
8426
8270
|
}
|
|
8427
8271
|
});
|
|
8428
8272
|
}
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
|
-
|
|
8433
|
-
|
|
8434
|
-
|
|
8273
|
+
|
|
8274
|
+
// src/entities/triggers/hurt.ts
|
|
8275
|
+
var HURT_SPAWNFLAGS = {
|
|
8276
|
+
StartOff: 1 << 0,
|
|
8277
|
+
Toggle: 1 << 1,
|
|
8278
|
+
Silent: 1 << 2,
|
|
8279
|
+
NoProtection: 1 << 3,
|
|
8280
|
+
Slow: 1 << 4,
|
|
8281
|
+
NoPlayers: 1 << 5,
|
|
8282
|
+
NoMonsters: 1 << 6,
|
|
8283
|
+
Clip: 1 << 7
|
|
8284
|
+
};
|
|
8285
|
+
var HURT_INTERVAL = 0.1;
|
|
8286
|
+
function hurtTouch(self, other, entities) {
|
|
8287
|
+
if (!other) {
|
|
8288
|
+
return;
|
|
8289
|
+
}
|
|
8290
|
+
if (!other.takedamage && other.classname !== "grenade") {
|
|
8291
|
+
return;
|
|
8435
8292
|
}
|
|
8436
8293
|
if (self.spawnflags & HURT_SPAWNFLAGS.NoMonsters && other.svflags & 4 /* Monster */) {
|
|
8437
8294
|
return;
|
|
@@ -8446,6 +8303,9 @@ function hurtTouch(self, other, entities) {
|
|
|
8446
8303
|
const damage = self.dmg || 5;
|
|
8447
8304
|
other.health -= damage;
|
|
8448
8305
|
}
|
|
8306
|
+
function toggleSolid2(self) {
|
|
8307
|
+
self.solid = self.solid === 0 /* Not */ ? 1 /* Trigger */ : 0 /* Not */;
|
|
8308
|
+
}
|
|
8449
8309
|
function registerTriggerHurt(registry) {
|
|
8450
8310
|
registry.register("trigger_hurt", (entity, context) => {
|
|
8451
8311
|
initTrigger(entity);
|
|
@@ -8458,12 +8318,17 @@ function registerTriggerHurt(registry) {
|
|
|
8458
8318
|
}
|
|
8459
8319
|
if (entity.spawnflags & HURT_SPAWNFLAGS.Toggle) {
|
|
8460
8320
|
entity.use = (self) => {
|
|
8461
|
-
|
|
8321
|
+
toggleSolid2(self);
|
|
8462
8322
|
self.touch = self.solid === 1 /* Trigger */ ? touchHandler : void 0;
|
|
8463
8323
|
};
|
|
8464
8324
|
}
|
|
8465
8325
|
});
|
|
8466
8326
|
}
|
|
8327
|
+
|
|
8328
|
+
// src/entities/triggers/teleport.ts
|
|
8329
|
+
var TELEPORT_SPAWNFLAGS = {
|
|
8330
|
+
StartOn: 1 << 3
|
|
8331
|
+
};
|
|
8467
8332
|
function teleportTouch(self, other, entities, warn) {
|
|
8468
8333
|
if (!other) {
|
|
8469
8334
|
return;
|
|
@@ -8505,6 +8370,13 @@ function registerTriggerTeleport(registry) {
|
|
|
8505
8370
|
entity.touch = (self, other) => teleportTouch(self, other, context.entities, context.warn);
|
|
8506
8371
|
});
|
|
8507
8372
|
}
|
|
8373
|
+
|
|
8374
|
+
// src/entities/triggers/gravity.ts
|
|
8375
|
+
var GRAVITY_SPAWNFLAGS = {
|
|
8376
|
+
Toggle: 1 << 0,
|
|
8377
|
+
StartOff: 1 << 1,
|
|
8378
|
+
Clip: 1 << 2
|
|
8379
|
+
};
|
|
8508
8380
|
function gravityTouch(self, other) {
|
|
8509
8381
|
if (!other) {
|
|
8510
8382
|
return;
|
|
@@ -8513,6 +8385,9 @@ function gravityTouch(self, other) {
|
|
|
8513
8385
|
}
|
|
8514
8386
|
other.gravity = self.gravity;
|
|
8515
8387
|
}
|
|
8388
|
+
function toggleSolid3(self) {
|
|
8389
|
+
self.solid = self.solid === 0 /* Not */ ? 1 /* Trigger */ : 0 /* Not */;
|
|
8390
|
+
}
|
|
8516
8391
|
function registerTriggerGravity(registry) {
|
|
8517
8392
|
registry.register("trigger_gravity", (entity, context) => {
|
|
8518
8393
|
const gravityText = context.keyValues.gravity;
|
|
@@ -8531,35 +8406,21 @@ function registerTriggerGravity(registry) {
|
|
|
8531
8406
|
}
|
|
8532
8407
|
if (entity.spawnflags & GRAVITY_SPAWNFLAGS.Toggle) {
|
|
8533
8408
|
entity.use = (self) => {
|
|
8534
|
-
|
|
8409
|
+
toggleSolid3(self);
|
|
8535
8410
|
self.touch = self.solid === 1 /* Trigger */ ? touchHandler : void 0;
|
|
8536
8411
|
};
|
|
8537
8412
|
}
|
|
8538
8413
|
});
|
|
8539
8414
|
}
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
if (other.svflags & 2 /* DeadMonster */) {
|
|
8548
|
-
return;
|
|
8549
|
-
}
|
|
8550
|
-
if ((other.svflags & 4 /* Monster */) === 0) {
|
|
8551
|
-
return;
|
|
8552
|
-
}
|
|
8553
|
-
other.velocity = {
|
|
8554
|
-
x: self.movedir.x * self.speed,
|
|
8555
|
-
y: self.movedir.y * self.speed,
|
|
8556
|
-
z: other.velocity.z
|
|
8557
|
-
};
|
|
8558
|
-
if (!other.groundentity) {
|
|
8559
|
-
return;
|
|
8415
|
+
|
|
8416
|
+
// src/entities/triggers/elevator.ts
|
|
8417
|
+
function trainResume(train, entities) {
|
|
8418
|
+
if (!train.think) {
|
|
8419
|
+
train.think = (self) => {
|
|
8420
|
+
self.nextthink = 0;
|
|
8421
|
+
};
|
|
8560
8422
|
}
|
|
8561
|
-
|
|
8562
|
-
other.velocity = { x: other.velocity.x, y: other.velocity.y, z: self.movedir.z };
|
|
8423
|
+
entities.scheduleThink(train, entities.timeSeconds + FRAME_TIME_SECONDS);
|
|
8563
8424
|
}
|
|
8564
8425
|
function triggerElevatorUse(self, other, entities, warn) {
|
|
8565
8426
|
if (!self.movetarget) {
|
|
@@ -8604,6 +8465,40 @@ function registerTriggerElevator(registry) {
|
|
|
8604
8465
|
context.entities.scheduleThink(entity, context.entities.timeSeconds + FRAME_TIME_SECONDS);
|
|
8605
8466
|
});
|
|
8606
8467
|
}
|
|
8468
|
+
|
|
8469
|
+
// src/entities/triggers/monsterjump.ts
|
|
8470
|
+
var MONSTERJUMP_SPAWNFLAGS = {
|
|
8471
|
+
Toggle: 1 << 0,
|
|
8472
|
+
StartOff: 1 << 1,
|
|
8473
|
+
Clip: 1 << 2
|
|
8474
|
+
};
|
|
8475
|
+
function monsterJumpTouch(self, other) {
|
|
8476
|
+
if (!other) {
|
|
8477
|
+
return;
|
|
8478
|
+
}
|
|
8479
|
+
if ((other.flags & (1 /* Fly */ | 2 /* Swim */)) !== 0) {
|
|
8480
|
+
return;
|
|
8481
|
+
}
|
|
8482
|
+
if (other.svflags & 2 /* DeadMonster */) {
|
|
8483
|
+
return;
|
|
8484
|
+
}
|
|
8485
|
+
if ((other.svflags & 4 /* Monster */) === 0) {
|
|
8486
|
+
return;
|
|
8487
|
+
}
|
|
8488
|
+
other.velocity = {
|
|
8489
|
+
x: self.movedir.x * self.speed,
|
|
8490
|
+
y: self.movedir.y * self.speed,
|
|
8491
|
+
z: other.velocity.z
|
|
8492
|
+
};
|
|
8493
|
+
if (!other.groundentity) {
|
|
8494
|
+
return;
|
|
8495
|
+
}
|
|
8496
|
+
other.groundentity = null;
|
|
8497
|
+
other.velocity = { x: other.velocity.x, y: other.velocity.y, z: self.movedir.z };
|
|
8498
|
+
}
|
|
8499
|
+
function toggleSolid4(self) {
|
|
8500
|
+
self.solid = self.solid === 0 /* Not */ ? 1 /* Trigger */ : 0 /* Not */;
|
|
8501
|
+
}
|
|
8607
8502
|
function registerTriggerMonsterJump(registry) {
|
|
8608
8503
|
registry.register("trigger_monsterjump", (entity, context) => {
|
|
8609
8504
|
const heightText = context.keyValues.height;
|
|
@@ -8624,29 +8519,255 @@ function registerTriggerMonsterJump(registry) {
|
|
|
8624
8519
|
}
|
|
8625
8520
|
if (entity.spawnflags & MONSTERJUMP_SPAWNFLAGS.Toggle) {
|
|
8626
8521
|
entity.use = (self) => {
|
|
8627
|
-
|
|
8522
|
+
toggleSolid4(self);
|
|
8628
8523
|
self.touch = self.solid === 1 /* Trigger */ ? touchHandler : void 0;
|
|
8629
8524
|
};
|
|
8630
8525
|
}
|
|
8631
8526
|
});
|
|
8632
8527
|
}
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
registerTriggerPush(registry);
|
|
8641
|
-
registerTriggerHurt(registry);
|
|
8642
|
-
registerTriggerTeleport(registry);
|
|
8643
|
-
registerTriggerGravity(registry);
|
|
8644
|
-
registerTriggerElevator(registry);
|
|
8645
|
-
registerTriggerMonsterJump(registry);
|
|
8646
|
-
registerTriggerFog(registry);
|
|
8647
|
-
registerTriggerFlashlight(registry);
|
|
8648
|
-
registerBadArea(registry);
|
|
8528
|
+
|
|
8529
|
+
// src/entities/triggers/fog.ts
|
|
8530
|
+
function clamp2(value, min, max) {
|
|
8531
|
+
return Math.min(Math.max(value, min), max);
|
|
8532
|
+
}
|
|
8533
|
+
function lerp(start, end, t) {
|
|
8534
|
+
return start + (end - start) * t;
|
|
8649
8535
|
}
|
|
8536
|
+
var SPAWNFLAG_FOG_AFFECT_FOG = 1;
|
|
8537
|
+
var SPAWNFLAG_FOG_INSTANTANEOUS = 4;
|
|
8538
|
+
var SPAWNFLAG_FOG_FORCE = 8;
|
|
8539
|
+
var SPAWNFLAG_FOG_BLEND = 16;
|
|
8540
|
+
function trigger_fog_touch(self, other, context) {
|
|
8541
|
+
if (!other || !other.client) return;
|
|
8542
|
+
if (self.timestamp > context.timeSeconds) return;
|
|
8543
|
+
self.timestamp = context.timeSeconds + (self.wait || 0);
|
|
8544
|
+
let fog_value_storage = self;
|
|
8545
|
+
if (self.movetarget) {
|
|
8546
|
+
fog_value_storage = self.movetarget;
|
|
8547
|
+
}
|
|
8548
|
+
if (self.spawnflags & SPAWNFLAG_FOG_INSTANTANEOUS) {
|
|
8549
|
+
if (other.client.pers) other.client.pers.fog_transition_time = 0;
|
|
8550
|
+
} else {
|
|
8551
|
+
if (other.client.pers) other.client.pers.fog_transition_time = fog_value_storage.delay || 0.5;
|
|
8552
|
+
}
|
|
8553
|
+
if (self.spawnflags & SPAWNFLAG_FOG_BLEND) {
|
|
8554
|
+
const center = scaleVec3(addVec3(self.absmin, self.absmax), 0.5);
|
|
8555
|
+
const half_size = addVec3(scaleVec3(self.size, 0.5), scaleVec3(other.size, 0.5));
|
|
8556
|
+
const start = {
|
|
8557
|
+
x: -self.movedir.x * half_size.x,
|
|
8558
|
+
y: -self.movedir.y * half_size.y,
|
|
8559
|
+
z: -self.movedir.z * half_size.z
|
|
8560
|
+
};
|
|
8561
|
+
const end = {
|
|
8562
|
+
x: self.movedir.x * half_size.x,
|
|
8563
|
+
y: self.movedir.y * half_size.y,
|
|
8564
|
+
z: self.movedir.z * half_size.z
|
|
8565
|
+
};
|
|
8566
|
+
const delta = subtractVec3(other.origin, center);
|
|
8567
|
+
const absMovedir = {
|
|
8568
|
+
x: Math.abs(self.movedir.x),
|
|
8569
|
+
y: Math.abs(self.movedir.y),
|
|
8570
|
+
z: Math.abs(self.movedir.z)
|
|
8571
|
+
};
|
|
8572
|
+
const player_dist = {
|
|
8573
|
+
x: delta.x * absMovedir.x,
|
|
8574
|
+
y: delta.y * absMovedir.y,
|
|
8575
|
+
z: delta.z * absMovedir.z
|
|
8576
|
+
};
|
|
8577
|
+
let dist = lengthVec3(subtractVec3(player_dist, start));
|
|
8578
|
+
dist /= lengthVec3(subtractVec3(start, end));
|
|
8579
|
+
dist = clamp2(dist, 0, 1);
|
|
8580
|
+
if (self.spawnflags & SPAWNFLAG_FOG_AFFECT_FOG) {
|
|
8581
|
+
const storage2 = fog_value_storage;
|
|
8582
|
+
if (other.client.pers) {
|
|
8583
|
+
other.client.pers.wanted_fog = {
|
|
8584
|
+
density: lerp(storage2.fog_density_off || 0, storage2.fog_density || 0, dist),
|
|
8585
|
+
r: lerp(storage2.fog_color_off?.[0] || 0, storage2.fog_color?.[0] || 0, dist),
|
|
8586
|
+
g: lerp(storage2.fog_color_off?.[1] || 0, storage2.fog_color?.[1] || 0, dist),
|
|
8587
|
+
b: lerp(storage2.fog_color_off?.[2] || 0, storage2.fog_color?.[2] || 0, dist),
|
|
8588
|
+
sky_factor: lerp(storage2.fog_sky_factor_off || 0, storage2.fog_sky_factor || 0, dist)
|
|
8589
|
+
};
|
|
8590
|
+
}
|
|
8591
|
+
}
|
|
8592
|
+
return;
|
|
8593
|
+
}
|
|
8594
|
+
let use_on = true;
|
|
8595
|
+
if (!(self.spawnflags & SPAWNFLAG_FOG_FORCE)) {
|
|
8596
|
+
const len = lengthVec3(other.velocity);
|
|
8597
|
+
if (len <= 1e-4) return;
|
|
8598
|
+
const forward = normalizeVec3(other.velocity);
|
|
8599
|
+
const dot = forward.x * self.movedir.x + forward.y * self.movedir.y + forward.z * self.movedir.z;
|
|
8600
|
+
use_on = dot > 0;
|
|
8601
|
+
}
|
|
8602
|
+
const storage = fog_value_storage;
|
|
8603
|
+
if (self.spawnflags & SPAWNFLAG_FOG_AFFECT_FOG) {
|
|
8604
|
+
if (other.client.pers) {
|
|
8605
|
+
if (use_on) {
|
|
8606
|
+
other.client.pers.wanted_fog = {
|
|
8607
|
+
density: storage.fog_density || 0,
|
|
8608
|
+
r: storage.fog_color?.[0] || 0,
|
|
8609
|
+
g: storage.fog_color?.[1] || 0,
|
|
8610
|
+
b: storage.fog_color?.[2] || 0,
|
|
8611
|
+
sky_factor: storage.fog_sky_factor || 0
|
|
8612
|
+
};
|
|
8613
|
+
} else {
|
|
8614
|
+
other.client.pers.wanted_fog = {
|
|
8615
|
+
density: storage.fog_density_off || 0,
|
|
8616
|
+
r: storage.fog_color_off?.[0] || 0,
|
|
8617
|
+
g: storage.fog_color_off?.[1] || 0,
|
|
8618
|
+
b: storage.fog_color_off?.[2] || 0,
|
|
8619
|
+
sky_factor: storage.fog_sky_factor_off || 0
|
|
8620
|
+
};
|
|
8621
|
+
}
|
|
8622
|
+
}
|
|
8623
|
+
}
|
|
8624
|
+
}
|
|
8625
|
+
function registerTriggerFog(registry) {
|
|
8626
|
+
registry.register("trigger_fog", (entity, context) => {
|
|
8627
|
+
entity.solid = 1 /* Trigger */;
|
|
8628
|
+
entity.movetype = 0 /* None */;
|
|
8629
|
+
entity.svflags |= 1 /* NoClient */;
|
|
8630
|
+
const entAny = entity;
|
|
8631
|
+
const kv = context.keyValues;
|
|
8632
|
+
entAny.fog_density = parseFloat(kv.fog_density) || 0;
|
|
8633
|
+
entAny.fog_color = kv.fog_color ? kv.fog_color.split(" ").map(parseFloat) : [0, 0, 0];
|
|
8634
|
+
entAny.fog_sky_factor = parseFloat(kv.fog_sky_factor) || 0;
|
|
8635
|
+
entAny.fog_density_off = parseFloat(kv.fog_density_off) || 0;
|
|
8636
|
+
entAny.fog_color_off = kv.fog_color_off ? kv.fog_color_off.split(" ").map(parseFloat) : [0, 0, 0];
|
|
8637
|
+
entAny.fog_sky_factor_off = parseFloat(kv.fog_sky_factor_off) || 0;
|
|
8638
|
+
if (entity.target) {
|
|
8639
|
+
entity.movetype = 0 /* None */;
|
|
8640
|
+
entity.movetarget = null;
|
|
8641
|
+
}
|
|
8642
|
+
if (!entity.delay) entity.delay = 0.5;
|
|
8643
|
+
entity.touch = (self, other) => trigger_fog_touch(self, other, context.entities);
|
|
8644
|
+
});
|
|
8645
|
+
}
|
|
8646
|
+
|
|
8647
|
+
// src/entities/triggers/flashlight.ts
|
|
8648
|
+
var registerTriggerFlashlight = (registry) => {
|
|
8649
|
+
registry.register("trigger_flashlight", (self, context) => {
|
|
8650
|
+
self.solid = 1 /* Trigger */;
|
|
8651
|
+
self.movetype = 0;
|
|
8652
|
+
self.svflags |= 1 /* NoClient */;
|
|
8653
|
+
self.touch = (self2, other, plane, surf) => {
|
|
8654
|
+
if (!other || !other.client) return;
|
|
8655
|
+
const style = self2.style || 0;
|
|
8656
|
+
let sound = "";
|
|
8657
|
+
if (style === 0) {
|
|
8658
|
+
if (other.flags & 4194304 /* Flashlight */) {
|
|
8659
|
+
other.flags &= ~4194304 /* Flashlight */;
|
|
8660
|
+
sound = "items/flashlight_off.wav";
|
|
8661
|
+
} else {
|
|
8662
|
+
other.flags |= 4194304 /* Flashlight */;
|
|
8663
|
+
sound = "items/flashlight_on.wav";
|
|
8664
|
+
}
|
|
8665
|
+
} else if (style === 1) {
|
|
8666
|
+
if (!(other.flags & 4194304 /* Flashlight */)) {
|
|
8667
|
+
other.flags |= 4194304 /* Flashlight */;
|
|
8668
|
+
sound = "items/flashlight_on.wav";
|
|
8669
|
+
}
|
|
8670
|
+
} else if (style === 2) {
|
|
8671
|
+
if (other.flags & 4194304 /* Flashlight */) {
|
|
8672
|
+
other.flags &= ~4194304 /* Flashlight */;
|
|
8673
|
+
sound = "items/flashlight_off.wav";
|
|
8674
|
+
}
|
|
8675
|
+
}
|
|
8676
|
+
if (other.flags & 4194304 /* Flashlight */) {
|
|
8677
|
+
other.renderfx |= RenderFx.Flashlight;
|
|
8678
|
+
} else {
|
|
8679
|
+
other.renderfx &= ~RenderFx.Flashlight;
|
|
8680
|
+
}
|
|
8681
|
+
if (sound) {
|
|
8682
|
+
context.entities.sound(other, 0, sound, 1, 3, 0);
|
|
8683
|
+
}
|
|
8684
|
+
};
|
|
8685
|
+
context.entities.linkentity(self);
|
|
8686
|
+
});
|
|
8687
|
+
};
|
|
8688
|
+
|
|
8689
|
+
// src/entities/triggers/secret.ts
|
|
8690
|
+
var SECRET_SPAWNFLAGS = {
|
|
8691
|
+
Once: 1 << 0
|
|
8692
|
+
};
|
|
8693
|
+
function triggerSecretTouch(self, other, entities) {
|
|
8694
|
+
if (!other || !other.client) {
|
|
8695
|
+
return;
|
|
8696
|
+
}
|
|
8697
|
+
if (self.timestamp > entities.timeSeconds) {
|
|
8698
|
+
return;
|
|
8699
|
+
}
|
|
8700
|
+
self.timestamp = entities.timeSeconds + 1;
|
|
8701
|
+
if (!self.message) {
|
|
8702
|
+
self.message = "You found a secret area!";
|
|
8703
|
+
}
|
|
8704
|
+
if (other.client) {
|
|
8705
|
+
entities.engine.centerprintf?.(other, self.message);
|
|
8706
|
+
entities.sound(other, 0, "misc/secret.wav", 1, 1, 0);
|
|
8707
|
+
}
|
|
8708
|
+
if (self.spawnflags & SECRET_SPAWNFLAGS.Once) {
|
|
8709
|
+
entities.free(self);
|
|
8710
|
+
}
|
|
8711
|
+
}
|
|
8712
|
+
function registerTriggerSecret(registry) {
|
|
8713
|
+
registry.register("trigger_secret", (entity, context) => {
|
|
8714
|
+
entity.movetype = 0 /* None */;
|
|
8715
|
+
entity.solid = 1 /* Trigger */;
|
|
8716
|
+
entity.svflags |= 1 /* NoClient */;
|
|
8717
|
+
entity.movedir = setMovedir(entity.angles);
|
|
8718
|
+
entity.angles = { x: 0, y: 0, z: 0 };
|
|
8719
|
+
if (entity.targetname) {
|
|
8720
|
+
entity.solid = 0 /* Not */;
|
|
8721
|
+
entity.use = (self) => {
|
|
8722
|
+
self.solid = 1 /* Trigger */;
|
|
8723
|
+
self.use = void 0;
|
|
8724
|
+
};
|
|
8725
|
+
}
|
|
8726
|
+
entity.touch = (self, other) => triggerSecretTouch(self, other, context.entities);
|
|
8727
|
+
});
|
|
8728
|
+
}
|
|
8729
|
+
|
|
8730
|
+
// src/entities/triggers/look.ts
|
|
8731
|
+
var LOOK_SPAWNFLAGS = {
|
|
8732
|
+
LookAway: 1 << 0
|
|
8733
|
+
};
|
|
8734
|
+
function triggerLookThink(self, entities) {
|
|
8735
|
+
let fired = false;
|
|
8736
|
+
const players = entities.findByClassname("player");
|
|
8737
|
+
for (const player of players) {
|
|
8738
|
+
if (player.health <= 0) continue;
|
|
8739
|
+
const vec = subtractVec3(self.origin, player.origin);
|
|
8740
|
+
const dist = Math.sqrt(dotVec3(vec, vec));
|
|
8741
|
+
const dir = normalizeVec3(vec);
|
|
8742
|
+
const forward = angleVectors(player.angles).forward;
|
|
8743
|
+
const dot = dotVec3(forward, dir);
|
|
8744
|
+
const fov = self.fov || 0.9;
|
|
8745
|
+
if (dot >= fov) {
|
|
8746
|
+
fired = true;
|
|
8747
|
+
self.activator = player;
|
|
8748
|
+
entities.useTargets(self, player);
|
|
8749
|
+
break;
|
|
8750
|
+
}
|
|
8751
|
+
}
|
|
8752
|
+
if (fired) {
|
|
8753
|
+
entities.free(self);
|
|
8754
|
+
} else {
|
|
8755
|
+
entities.scheduleThink(self, entities.timeSeconds + 0.1);
|
|
8756
|
+
}
|
|
8757
|
+
}
|
|
8758
|
+
function registerTriggerLook(registry) {
|
|
8759
|
+
registry.register("trigger_look", (entity, context) => {
|
|
8760
|
+
entity.movetype = 0 /* None */;
|
|
8761
|
+
entity.solid = 0 /* Not */;
|
|
8762
|
+
entity.svflags |= 1 /* NoClient */;
|
|
8763
|
+
entity.movedir = setMovedir(entity.angles);
|
|
8764
|
+
if (!entity.fov) entity.fov = 0.9;
|
|
8765
|
+
entity.think = (self) => triggerLookThink(self, context.entities);
|
|
8766
|
+
context.entities.scheduleThink(entity, context.entities.timeSeconds + 0.1);
|
|
8767
|
+
});
|
|
8768
|
+
}
|
|
8769
|
+
|
|
8770
|
+
// src/entities/triggers/bad_area.ts
|
|
8650
8771
|
function badAreaTouch(self, other) {
|
|
8651
8772
|
if (!other) return;
|
|
8652
8773
|
if (other.takedamage) {
|
|
@@ -8665,6 +8786,27 @@ function registerBadArea(registry) {
|
|
|
8665
8786
|
});
|
|
8666
8787
|
}
|
|
8667
8788
|
|
|
8789
|
+
// src/entities/triggers/index.ts
|
|
8790
|
+
function registerTriggerSpawns(registry) {
|
|
8791
|
+
registerTriggerMultiple(registry);
|
|
8792
|
+
registerTriggerOnce(registry);
|
|
8793
|
+
registerTriggerRelay(registry);
|
|
8794
|
+
registerTriggerAlways(registry);
|
|
8795
|
+
registerTriggerCounter(registry);
|
|
8796
|
+
registerTriggerKey(registry);
|
|
8797
|
+
registerTriggerPush(registry);
|
|
8798
|
+
registerTriggerHurt(registry);
|
|
8799
|
+
registerTriggerTeleport(registry);
|
|
8800
|
+
registerTriggerGravity(registry);
|
|
8801
|
+
registerTriggerElevator(registry);
|
|
8802
|
+
registerTriggerMonsterJump(registry);
|
|
8803
|
+
registerTriggerFog(registry);
|
|
8804
|
+
registerTriggerFlashlight(registry);
|
|
8805
|
+
registerTriggerSecret(registry);
|
|
8806
|
+
registerTriggerLook(registry);
|
|
8807
|
+
registerBadArea(registry);
|
|
8808
|
+
}
|
|
8809
|
+
|
|
8668
8810
|
// src/combat/weapons/state.ts
|
|
8669
8811
|
var WeaponStateEnum = /* @__PURE__ */ ((WeaponStateEnum2) => {
|
|
8670
8812
|
WeaponStateEnum2[WeaponStateEnum2["WEAPON_READY"] = 0] = "WEAPON_READY";
|