quake2ts 0.0.464 → 0.0.465
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 +15 -15
- 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 +395 -385
- package/packages/game/dist/cjs/index.cjs.map +1 -1
- package/packages/game/dist/esm/index.js +395 -385
- package/packages/game/dist/esm/index.js.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/game/dist/types/physics/movement.d.ts.map +1 -1
|
@@ -3975,6 +3975,333 @@ function checkTriggers(ent, system) {
|
|
|
3975
3975
|
}
|
|
3976
3976
|
}
|
|
3977
3977
|
|
|
3978
|
+
// src/combat/specialDamage.ts
|
|
3979
|
+
init_esm();
|
|
3980
|
+
|
|
3981
|
+
// src/combat/damage.ts
|
|
3982
|
+
init_esm();
|
|
3983
|
+
init_armor();
|
|
3984
|
+
init_damageFlags();
|
|
3985
|
+
init_esm();
|
|
3986
|
+
|
|
3987
|
+
// src/imports.ts
|
|
3988
|
+
var MulticastType = /* @__PURE__ */ ((MulticastType2) => {
|
|
3989
|
+
MulticastType2[MulticastType2["All"] = 0] = "All";
|
|
3990
|
+
MulticastType2[MulticastType2["Pvs"] = 1] = "Pvs";
|
|
3991
|
+
MulticastType2[MulticastType2["Phs"] = 2] = "Phs";
|
|
3992
|
+
return MulticastType2;
|
|
3993
|
+
})(MulticastType || {});
|
|
3994
|
+
|
|
3995
|
+
// src/combat/damage.ts
|
|
3996
|
+
var EntityDamageFlags = /* @__PURE__ */ ((EntityDamageFlags2) => {
|
|
3997
|
+
EntityDamageFlags2[EntityDamageFlags2["GODMODE"] = 1] = "GODMODE";
|
|
3998
|
+
EntityDamageFlags2[EntityDamageFlags2["IMMORTAL"] = 2] = "IMMORTAL";
|
|
3999
|
+
EntityDamageFlags2[EntityDamageFlags2["NO_KNOCKBACK"] = 4] = "NO_KNOCKBACK";
|
|
4000
|
+
EntityDamageFlags2[EntityDamageFlags2["NO_DAMAGE_EFFECTS"] = 8] = "NO_DAMAGE_EFFECTS";
|
|
4001
|
+
return EntityDamageFlags2;
|
|
4002
|
+
})(EntityDamageFlags || {});
|
|
4003
|
+
function getDamageModifier(attacker, time) {
|
|
4004
|
+
if (!attacker) {
|
|
4005
|
+
return 1;
|
|
4006
|
+
}
|
|
4007
|
+
const client = attacker.client;
|
|
4008
|
+
if (!client) {
|
|
4009
|
+
return 1;
|
|
4010
|
+
}
|
|
4011
|
+
let modifier = 1;
|
|
4012
|
+
if (client.quad_time && client.quad_time > time) {
|
|
4013
|
+
modifier *= 4;
|
|
4014
|
+
}
|
|
4015
|
+
if (client.double_time && client.double_time > time) {
|
|
4016
|
+
modifier *= 2;
|
|
4017
|
+
}
|
|
4018
|
+
return modifier;
|
|
4019
|
+
}
|
|
4020
|
+
function applyKnockback(targ, attacker, dir, knockback, dflags) {
|
|
4021
|
+
const hasNoKnockback = hasAnyDamageFlag(dflags, 8 /* NO_KNOCKBACK */) || ((targ.flags ?? 0) & 4 /* NO_KNOCKBACK */) !== 0;
|
|
4022
|
+
if (hasNoKnockback || knockback === 0) {
|
|
4023
|
+
return { x: 0, y: 0, z: 0 };
|
|
4024
|
+
}
|
|
4025
|
+
const mass = Math.max(50, targ.mass ?? 200);
|
|
4026
|
+
const normalized = normalizeVec3(dir);
|
|
4027
|
+
const scale = attacker === targ ? 1600 : 500;
|
|
4028
|
+
const delta = scaleVec3(normalized, scale * knockback / mass);
|
|
4029
|
+
targ.velocity = addVec3(targ.velocity, delta);
|
|
4030
|
+
return delta;
|
|
4031
|
+
}
|
|
4032
|
+
function applyProtection(targ, point, normal, damage, dflags) {
|
|
4033
|
+
let take = damage;
|
|
4034
|
+
let psave = 0;
|
|
4035
|
+
let asave = 0;
|
|
4036
|
+
let remainingCells;
|
|
4037
|
+
let remainingArmor;
|
|
4038
|
+
if (targ.powerArmor) {
|
|
4039
|
+
const result = applyPowerArmor(damage, dflags, point, normal, targ.powerArmor);
|
|
4040
|
+
psave = result.saved;
|
|
4041
|
+
remainingCells = result.remainingCells;
|
|
4042
|
+
take -= psave;
|
|
4043
|
+
}
|
|
4044
|
+
if (targ.regularArmor) {
|
|
4045
|
+
const result = applyRegularArmor(take, dflags, targ.regularArmor);
|
|
4046
|
+
asave = result.saved;
|
|
4047
|
+
remainingArmor = result.remainingArmor;
|
|
4048
|
+
take -= asave;
|
|
4049
|
+
}
|
|
4050
|
+
return [Math.max(0, take), psave, asave, remainingCells, remainingArmor];
|
|
4051
|
+
}
|
|
4052
|
+
function targetCenter(ent) {
|
|
4053
|
+
if (ent.mins && ent.maxs) {
|
|
4054
|
+
return {
|
|
4055
|
+
x: ent.origin.x + (ent.mins.x + ent.maxs.x) * 0.5,
|
|
4056
|
+
y: ent.origin.y + (ent.mins.y + ent.maxs.y) * 0.5,
|
|
4057
|
+
z: ent.origin.z + (ent.mins.z + ent.maxs.z) * 0.5
|
|
4058
|
+
};
|
|
4059
|
+
}
|
|
4060
|
+
return ent.origin;
|
|
4061
|
+
}
|
|
4062
|
+
function T_Damage(targ, inflictor, attacker, dir, point, normal, damage, knockback, dflags, mod, time, multicast) {
|
|
4063
|
+
if (!targ.takedamage) {
|
|
4064
|
+
return null;
|
|
4065
|
+
}
|
|
4066
|
+
const modifier = getDamageModifier(attacker, time);
|
|
4067
|
+
const modifiedDamage = damage * modifier;
|
|
4068
|
+
const modifiedKnockback = knockback * modifier;
|
|
4069
|
+
const protectedByGod = !hasAnyDamageFlag(dflags, 32 /* NO_PROTECTION */) && ((targ.flags ?? 0) & 1 /* GODMODE */) !== 0 && modifiedDamage > 0;
|
|
4070
|
+
if (protectedByGod) {
|
|
4071
|
+
return {
|
|
4072
|
+
take: 0,
|
|
4073
|
+
psave: 0,
|
|
4074
|
+
asave: modifiedDamage,
|
|
4075
|
+
knocked: { x: 0, y: 0, z: 0 },
|
|
4076
|
+
killed: false
|
|
4077
|
+
};
|
|
4078
|
+
}
|
|
4079
|
+
const knocked = applyKnockback(targ, attacker, dir, modifiedKnockback, dflags);
|
|
4080
|
+
let [take, psave, asave, remainingCells, remainingArmor] = applyProtection(targ, point, normal, modifiedDamage, dflags);
|
|
4081
|
+
if (targ.monsterinfo && targ.monsterinfo.freeze_time > time && modifiedDamage > 0) {
|
|
4082
|
+
take = targ.health + 100;
|
|
4083
|
+
psave = 0;
|
|
4084
|
+
asave = 0;
|
|
4085
|
+
}
|
|
4086
|
+
if (targ.powerArmor && remainingCells !== void 0) {
|
|
4087
|
+
targ.powerArmor.cellCount = remainingCells;
|
|
4088
|
+
}
|
|
4089
|
+
if (targ.regularArmor) {
|
|
4090
|
+
targ.regularArmor.armorCount = remainingArmor ?? targ.regularArmor.armorCount;
|
|
4091
|
+
}
|
|
4092
|
+
let actualTake = take;
|
|
4093
|
+
if (actualTake > 0) {
|
|
4094
|
+
targ.health -= actualTake;
|
|
4095
|
+
if (multicast && !hasAnyDamageFlag(dflags, 1024 /* NO_DAMAGE_EFFECTS */)) {
|
|
4096
|
+
if (targ.classname === "player" || targ.monsterinfo) {
|
|
4097
|
+
multicast(point, 1 /* Pvs */, ServerCommand.temp_entity, TempEntity.BLOOD, point, normal);
|
|
4098
|
+
} else {
|
|
4099
|
+
}
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
const killed = targ.health <= 0;
|
|
4103
|
+
if (killed) {
|
|
4104
|
+
if (targ.flags && targ.flags & 2 /* IMMORTAL */) {
|
|
4105
|
+
targ.health = Math.max(1, targ.health);
|
|
4106
|
+
} else if (targ.die) {
|
|
4107
|
+
targ.die(targ, inflictor, attacker, actualTake, point, mod);
|
|
4108
|
+
}
|
|
4109
|
+
} else if (actualTake > 0 && targ.pain) {
|
|
4110
|
+
targ.pain(targ, attacker, knockback, actualTake, mod);
|
|
4111
|
+
}
|
|
4112
|
+
return { take: actualTake, psave, asave, knocked, killed, remainingCells, remainingArmor };
|
|
4113
|
+
}
|
|
4114
|
+
function T_RadiusDamage(entities, inflictor, attacker, damage, ignore, radius, dflags, mod, time, options = {}, multicast) {
|
|
4115
|
+
const hits = [];
|
|
4116
|
+
const inflictorCenter = targetCenter(inflictor);
|
|
4117
|
+
const canDamage = options.canDamage ?? (() => true);
|
|
4118
|
+
for (const ent of entities) {
|
|
4119
|
+
if (ent === ignore || !ent.takedamage || !canDamage(ent, inflictor)) {
|
|
4120
|
+
continue;
|
|
4121
|
+
}
|
|
4122
|
+
const entCenter = ent.mins && ent.maxs ? closestPointToBox(inflictorCenter, addVec3(ent.origin, ent.mins), addVec3(ent.origin, ent.maxs)) : targetCenter(ent);
|
|
4123
|
+
const toTarget = subtractVec3(inflictorCenter, entCenter);
|
|
4124
|
+
const distance4 = lengthVec3(toTarget);
|
|
4125
|
+
if (radius > 0 && distance4 > radius) {
|
|
4126
|
+
continue;
|
|
4127
|
+
}
|
|
4128
|
+
const points = damage - 0.5 * distance4;
|
|
4129
|
+
if (points <= 0) {
|
|
4130
|
+
continue;
|
|
4131
|
+
}
|
|
4132
|
+
let adjustedDamage = points;
|
|
4133
|
+
if (ent === attacker) {
|
|
4134
|
+
adjustedDamage = points * 0.5;
|
|
4135
|
+
}
|
|
4136
|
+
const adjustedKnockback = adjustedDamage;
|
|
4137
|
+
const dir = normalizeVec3(subtractVec3(ent.origin, inflictorCenter));
|
|
4138
|
+
const result = T_Damage(ent, inflictor, attacker, dir, entCenter, dir, adjustedDamage, adjustedKnockback, dflags | 1 /* RADIUS */, mod, time, multicast);
|
|
4139
|
+
hits.push({ target: ent, result, appliedDamage: adjustedDamage });
|
|
4140
|
+
}
|
|
4141
|
+
return hits;
|
|
4142
|
+
}
|
|
4143
|
+
|
|
4144
|
+
// src/combat/specialDamage.ts
|
|
4145
|
+
var ZERO2 = { x: 0, y: 0, z: 0 };
|
|
4146
|
+
var EnvironmentalFlags = /* @__PURE__ */ ((EnvironmentalFlags2) => {
|
|
4147
|
+
EnvironmentalFlags2[EnvironmentalFlags2["IN_WATER"] = 1] = "IN_WATER";
|
|
4148
|
+
EnvironmentalFlags2[EnvironmentalFlags2["IMMUNE_LAVA"] = 2] = "IMMUNE_LAVA";
|
|
4149
|
+
EnvironmentalFlags2[EnvironmentalFlags2["IMMUNE_SLIME"] = 4] = "IMMUNE_SLIME";
|
|
4150
|
+
return EnvironmentalFlags2;
|
|
4151
|
+
})(EnvironmentalFlags || {});
|
|
4152
|
+
function applyDamageEvent(target, amount, mod, time) {
|
|
4153
|
+
return T_Damage(target, null, null, ZERO2, target.origin, ZERO2, amount, 0, 2 /* NO_ARMOR */, mod, time);
|
|
4154
|
+
}
|
|
4155
|
+
function applyEnvironmentalDamage(target, nowMs) {
|
|
4156
|
+
const events = [];
|
|
4157
|
+
let flags = target.environmentFlags ?? 0;
|
|
4158
|
+
let enteredWater = false;
|
|
4159
|
+
let leftWater = false;
|
|
4160
|
+
if (target.waterlevel === WaterLevel.None) {
|
|
4161
|
+
if ((flags & 1 /* IN_WATER */) !== 0) {
|
|
4162
|
+
flags &= ~1 /* IN_WATER */;
|
|
4163
|
+
leftWater = true;
|
|
4164
|
+
}
|
|
4165
|
+
if (target.airFinished < nowMs && target.painDebounceTime <= nowMs) {
|
|
4166
|
+
const elapsedSeconds = Math.floor((nowMs - target.airFinished) / 1e3);
|
|
4167
|
+
const amount = Math.min(15, 2 + 2 * elapsedSeconds);
|
|
4168
|
+
const result = applyDamageEvent(target, amount, 17 /* WATER */, nowMs / 1e3);
|
|
4169
|
+
target.painDebounceTime = nowMs + 1e3;
|
|
4170
|
+
events.push({ mod: 17 /* WATER */, amount, result });
|
|
4171
|
+
}
|
|
4172
|
+
} else {
|
|
4173
|
+
target.airFinished = nowMs + 9e3;
|
|
4174
|
+
if ((flags & 1 /* IN_WATER */) === 0) {
|
|
4175
|
+
flags |= 1 /* IN_WATER */;
|
|
4176
|
+
enteredWater = true;
|
|
4177
|
+
target.damageDebounceTime = 0;
|
|
4178
|
+
}
|
|
4179
|
+
if (target.damageDebounceTime <= nowMs) {
|
|
4180
|
+
if ((target.watertype & CONTENTS_LAVA) !== 0 && (flags & 2 /* IMMUNE_LAVA */) === 0) {
|
|
4181
|
+
const amount = 10 * target.waterlevel;
|
|
4182
|
+
const result = applyDamageEvent(target, amount, 19 /* LAVA */, nowMs / 1e3);
|
|
4183
|
+
target.damageDebounceTime = nowMs + 100;
|
|
4184
|
+
events.push({ mod: 19 /* LAVA */, amount, result });
|
|
4185
|
+
} else if ((target.watertype & CONTENTS_SLIME) !== 0 && (flags & 4 /* IMMUNE_SLIME */) === 0) {
|
|
4186
|
+
const amount = 4 * target.waterlevel;
|
|
4187
|
+
const result = applyDamageEvent(target, amount, 18 /* SLIME */, nowMs / 1e3);
|
|
4188
|
+
target.damageDebounceTime = nowMs + 100;
|
|
4189
|
+
events.push({ mod: 18 /* SLIME */, amount, result });
|
|
4190
|
+
}
|
|
4191
|
+
}
|
|
4192
|
+
}
|
|
4193
|
+
target.environmentFlags = flags;
|
|
4194
|
+
return { events, enteredWater, leftWater };
|
|
4195
|
+
}
|
|
4196
|
+
function calculateFallingDamage(context) {
|
|
4197
|
+
const {
|
|
4198
|
+
impactDelta,
|
|
4199
|
+
waterLevel,
|
|
4200
|
+
onLadder = false,
|
|
4201
|
+
isDead = false,
|
|
4202
|
+
isPlayerModel = true,
|
|
4203
|
+
isNoClip = false,
|
|
4204
|
+
grappleBlockingFallDamage = false,
|
|
4205
|
+
clampFreeFall = false,
|
|
4206
|
+
skipDamage = false
|
|
4207
|
+
} = context;
|
|
4208
|
+
if (isDead || !isPlayerModel || isNoClip || grappleBlockingFallDamage || waterLevel === WaterLevel.Under) {
|
|
4209
|
+
return { damage: 0, event: null, fallValue: 0, adjustedDelta: 0 };
|
|
4210
|
+
}
|
|
4211
|
+
let delta = impactDelta * impactDelta * 1e-4;
|
|
4212
|
+
if (waterLevel === WaterLevel.Waist) {
|
|
4213
|
+
delta *= 0.25;
|
|
4214
|
+
} else if (waterLevel === WaterLevel.Feet) {
|
|
4215
|
+
delta *= 0.5;
|
|
4216
|
+
}
|
|
4217
|
+
if (clampFreeFall) {
|
|
4218
|
+
delta = Math.min(30, delta);
|
|
4219
|
+
}
|
|
4220
|
+
if (delta < 1) {
|
|
4221
|
+
return { damage: 0, event: null, fallValue: 0, adjustedDelta: delta };
|
|
4222
|
+
}
|
|
4223
|
+
let event = null;
|
|
4224
|
+
let damage = 0;
|
|
4225
|
+
let fallValue = 0;
|
|
4226
|
+
if (delta < 15) {
|
|
4227
|
+
event = onLadder ? null : "footstep";
|
|
4228
|
+
} else {
|
|
4229
|
+
fallValue = Math.min(delta * 0.5, 40);
|
|
4230
|
+
if (delta > 30) {
|
|
4231
|
+
event = delta >= 55 ? "fallfar" : "fall";
|
|
4232
|
+
damage = Math.max(1, (delta - 30) * 0.5);
|
|
4233
|
+
} else {
|
|
4234
|
+
event = "fallshort";
|
|
4235
|
+
}
|
|
4236
|
+
}
|
|
4237
|
+
if (skipDamage) {
|
|
4238
|
+
damage = 0;
|
|
4239
|
+
}
|
|
4240
|
+
return { damage, event, fallValue, adjustedDelta: delta };
|
|
4241
|
+
}
|
|
4242
|
+
function applyFallingDamage(target, context) {
|
|
4243
|
+
const result = calculateFallingDamage(context);
|
|
4244
|
+
if (result.damage > 0 && !context.skipDamage) {
|
|
4245
|
+
T_Damage(
|
|
4246
|
+
target,
|
|
4247
|
+
null,
|
|
4248
|
+
null,
|
|
4249
|
+
{ x: 0, y: 0, z: 1 },
|
|
4250
|
+
target.origin,
|
|
4251
|
+
ZERO2,
|
|
4252
|
+
result.damage,
|
|
4253
|
+
0,
|
|
4254
|
+
2 /* NO_ARMOR */,
|
|
4255
|
+
23 /* FALLING */,
|
|
4256
|
+
0
|
|
4257
|
+
);
|
|
4258
|
+
}
|
|
4259
|
+
return result;
|
|
4260
|
+
}
|
|
4261
|
+
function applyCrushDamage(crusher, target, options = {}) {
|
|
4262
|
+
const nonLivingDamage = options.nonLivingDamage ?? 1e5;
|
|
4263
|
+
const gibDamage = options.gibDamage ?? 100;
|
|
4264
|
+
const baseDamage = options.baseDamage ?? crusher.dmg ?? 10;
|
|
4265
|
+
const amount = !target.isMonster && !target.isClient ? nonLivingDamage : target.health < 1 ? gibDamage : baseDamage;
|
|
4266
|
+
const result = T_Damage(target, crusher, crusher, ZERO2, target.origin, ZERO2, amount, 1, 0 /* NONE */, 20 /* CRUSH */, 0);
|
|
4267
|
+
return { amount, result };
|
|
4268
|
+
}
|
|
4269
|
+
function absoluteBounds(ent) {
|
|
4270
|
+
const mins = ent.mins ?? ZERO2;
|
|
4271
|
+
const maxs = ent.maxs ?? ZERO2;
|
|
4272
|
+
return {
|
|
4273
|
+
mins: addVec3(ent.origin, mins),
|
|
4274
|
+
maxs: addVec3(ent.origin, maxs)
|
|
4275
|
+
};
|
|
4276
|
+
}
|
|
4277
|
+
function killBox(teleporter, targets, options = {}) {
|
|
4278
|
+
if (teleporter.movetype === 1 /* Noclip */) {
|
|
4279
|
+
return { events: [], cleared: true };
|
|
4280
|
+
}
|
|
4281
|
+
const mod = options.mod ?? 21 /* TELEFRAG */;
|
|
4282
|
+
const teleBounds = absoluteBounds(teleporter);
|
|
4283
|
+
const events = [];
|
|
4284
|
+
let cleared = true;
|
|
4285
|
+
for (const target of targets) {
|
|
4286
|
+
if (target === teleporter || target.inUse === false) {
|
|
4287
|
+
continue;
|
|
4288
|
+
}
|
|
4289
|
+
const solidity = target.solid ?? 0 /* Not */;
|
|
4290
|
+
if (!target.takedamage || solidity === 0 /* Not */ || solidity === 1 /* Trigger */ || solidity === 3 /* Bsp */) {
|
|
4291
|
+
continue;
|
|
4292
|
+
}
|
|
4293
|
+
if (!boxesIntersect(teleBounds, absoluteBounds(target))) {
|
|
4294
|
+
continue;
|
|
4295
|
+
}
|
|
4296
|
+
const result = T_Damage(target, teleporter, teleporter, ZERO2, target.origin, ZERO2, 1e5, 0, 32 /* NO_PROTECTION */, mod, 0);
|
|
4297
|
+
events.push({ target, result });
|
|
4298
|
+
if (!result || !result.killed || target.health > 0) {
|
|
4299
|
+
cleared = false;
|
|
4300
|
+
}
|
|
4301
|
+
}
|
|
4302
|
+
return { events, cleared };
|
|
4303
|
+
}
|
|
4304
|
+
|
|
3978
4305
|
// src/physics/movement.ts
|
|
3979
4306
|
var WATER_FRICTION = 2;
|
|
3980
4307
|
var WATER_GRAVITY_SCALE = 0.1;
|
|
@@ -4064,6 +4391,14 @@ function runStep(ent, system, imports, gravity, frametime) {
|
|
|
4064
4391
|
}
|
|
4065
4392
|
timeLeft -= timeLeft * trace.fraction;
|
|
4066
4393
|
if (trace.plane) {
|
|
4394
|
+
if (trace.plane.normal.z > 0.7 && velocity.z < 0) {
|
|
4395
|
+
const impactDelta = Math.abs(velocity.z);
|
|
4396
|
+
applyFallingDamage(ent, {
|
|
4397
|
+
impactDelta,
|
|
4398
|
+
waterLevel: ent.waterlevel,
|
|
4399
|
+
isDead: ent.deadflag !== 0
|
|
4400
|
+
});
|
|
4401
|
+
}
|
|
4067
4402
|
velocity = clipVelocityVec3(velocity, trace.plane.normal, 1);
|
|
4068
4403
|
}
|
|
4069
4404
|
const speed = velocity.x * velocity.x + velocity.y * velocity.y + velocity.z * velocity.z;
|
|
@@ -5190,239 +5525,76 @@ var EntitySystem = class {
|
|
|
5190
5525
|
}
|
|
5191
5526
|
for (const ref of pendingEntityRefs) {
|
|
5192
5527
|
const target = ref.targetIndex === null ? null : indexToEntity.get(ref.targetIndex) ?? null;
|
|
5193
|
-
assignField(ref.entity, ref.name, target);
|
|
5194
|
-
}
|
|
5195
|
-
this.thinkScheduler.restore(snapshot.thinks, (index) => indexToEntity.get(index));
|
|
5196
|
-
}
|
|
5197
|
-
runTouches() {
|
|
5198
|
-
const world = this.pool.world;
|
|
5199
|
-
const activeEntities = [];
|
|
5200
|
-
for (const entity of this.pool) {
|
|
5201
|
-
if (entity === world) continue;
|
|
5202
|
-
if (!entity.inUse || entity.freePending || entity.solid === 0 /* Not */) continue;
|
|
5203
|
-
activeEntities.push(entity);
|
|
5204
|
-
}
|
|
5205
|
-
for (const first of activeEntities) {
|
|
5206
|
-
const candidates = this.findInBox(first.absmin, first.absmax);
|
|
5207
|
-
const firstBounds = computeBounds(first);
|
|
5208
|
-
for (const second of candidates) {
|
|
5209
|
-
if (first === second) continue;
|
|
5210
|
-
if (!first.touch) continue;
|
|
5211
|
-
const secondBounds = computeBounds(second);
|
|
5212
|
-
if (!boundsIntersect(firstBounds, secondBounds)) continue;
|
|
5213
|
-
first.touch(first, second);
|
|
5214
|
-
}
|
|
5215
|
-
}
|
|
5216
|
-
}
|
|
5217
|
-
registerTarget(entity) {
|
|
5218
|
-
if (!entity.targetname) {
|
|
5219
|
-
return;
|
|
5220
|
-
}
|
|
5221
|
-
let bucket = this.targetNameIndex.get(entity.targetname);
|
|
5222
|
-
if (!bucket) {
|
|
5223
|
-
bucket = /* @__PURE__ */ new Set();
|
|
5224
|
-
this.targetNameIndex.set(entity.targetname, bucket);
|
|
5225
|
-
}
|
|
5226
|
-
bucket.add(entity);
|
|
5227
|
-
}
|
|
5228
|
-
unregisterTarget(entity) {
|
|
5229
|
-
if (!entity.targetname) {
|
|
5230
|
-
return;
|
|
5231
|
-
}
|
|
5232
|
-
const bucket = this.targetNameIndex.get(entity.targetname);
|
|
5233
|
-
if (!bucket) {
|
|
5234
|
-
return;
|
|
5235
|
-
}
|
|
5236
|
-
bucket.delete(entity);
|
|
5237
|
-
if (bucket.size === 0) {
|
|
5238
|
-
this.targetNameIndex.delete(entity.targetname);
|
|
5239
|
-
}
|
|
5240
|
-
}
|
|
5241
|
-
useTargetsImmediate(entity, activator) {
|
|
5242
|
-
if (entity.target) {
|
|
5243
|
-
for (const target of this.findByTargetName(entity.target)) {
|
|
5244
|
-
if (target === entity) {
|
|
5245
|
-
continue;
|
|
5246
|
-
}
|
|
5247
|
-
target.use?.(target, entity, activator);
|
|
5248
|
-
}
|
|
5249
|
-
}
|
|
5250
|
-
if (entity.killtarget) {
|
|
5251
|
-
for (const victim of this.findByTargetName(entity.killtarget)) {
|
|
5252
|
-
if (victim === entity) {
|
|
5253
|
-
continue;
|
|
5254
|
-
}
|
|
5255
|
-
this.free(victim);
|
|
5256
|
-
}
|
|
5257
|
-
}
|
|
5258
|
-
}
|
|
5259
|
-
};
|
|
5260
|
-
|
|
5261
|
-
// src/entities/misc.ts
|
|
5262
|
-
init_esm();
|
|
5263
|
-
|
|
5264
|
-
// src/combat/damage.ts
|
|
5265
|
-
init_esm();
|
|
5266
|
-
init_armor();
|
|
5267
|
-
init_damageFlags();
|
|
5268
|
-
init_esm();
|
|
5269
|
-
|
|
5270
|
-
// src/imports.ts
|
|
5271
|
-
var MulticastType = /* @__PURE__ */ ((MulticastType2) => {
|
|
5272
|
-
MulticastType2[MulticastType2["All"] = 0] = "All";
|
|
5273
|
-
MulticastType2[MulticastType2["Pvs"] = 1] = "Pvs";
|
|
5274
|
-
MulticastType2[MulticastType2["Phs"] = 2] = "Phs";
|
|
5275
|
-
return MulticastType2;
|
|
5276
|
-
})(MulticastType || {});
|
|
5277
|
-
|
|
5278
|
-
// src/combat/damage.ts
|
|
5279
|
-
var EntityDamageFlags = /* @__PURE__ */ ((EntityDamageFlags2) => {
|
|
5280
|
-
EntityDamageFlags2[EntityDamageFlags2["GODMODE"] = 1] = "GODMODE";
|
|
5281
|
-
EntityDamageFlags2[EntityDamageFlags2["IMMORTAL"] = 2] = "IMMORTAL";
|
|
5282
|
-
EntityDamageFlags2[EntityDamageFlags2["NO_KNOCKBACK"] = 4] = "NO_KNOCKBACK";
|
|
5283
|
-
EntityDamageFlags2[EntityDamageFlags2["NO_DAMAGE_EFFECTS"] = 8] = "NO_DAMAGE_EFFECTS";
|
|
5284
|
-
return EntityDamageFlags2;
|
|
5285
|
-
})(EntityDamageFlags || {});
|
|
5286
|
-
function getDamageModifier(attacker, time) {
|
|
5287
|
-
if (!attacker) {
|
|
5288
|
-
return 1;
|
|
5289
|
-
}
|
|
5290
|
-
const client = attacker.client;
|
|
5291
|
-
if (!client) {
|
|
5292
|
-
return 1;
|
|
5293
|
-
}
|
|
5294
|
-
let modifier = 1;
|
|
5295
|
-
if (client.quad_time && client.quad_time > time) {
|
|
5296
|
-
modifier *= 4;
|
|
5297
|
-
}
|
|
5298
|
-
if (client.double_time && client.double_time > time) {
|
|
5299
|
-
modifier *= 2;
|
|
5300
|
-
}
|
|
5301
|
-
return modifier;
|
|
5302
|
-
}
|
|
5303
|
-
function applyKnockback(targ, attacker, dir, knockback, dflags) {
|
|
5304
|
-
const hasNoKnockback = hasAnyDamageFlag(dflags, 8 /* NO_KNOCKBACK */) || ((targ.flags ?? 0) & 4 /* NO_KNOCKBACK */) !== 0;
|
|
5305
|
-
if (hasNoKnockback || knockback === 0) {
|
|
5306
|
-
return { x: 0, y: 0, z: 0 };
|
|
5307
|
-
}
|
|
5308
|
-
const mass = Math.max(50, targ.mass ?? 200);
|
|
5309
|
-
const normalized = normalizeVec3(dir);
|
|
5310
|
-
const scale = attacker === targ ? 1600 : 500;
|
|
5311
|
-
const delta = scaleVec3(normalized, scale * knockback / mass);
|
|
5312
|
-
targ.velocity = addVec3(targ.velocity, delta);
|
|
5313
|
-
return delta;
|
|
5314
|
-
}
|
|
5315
|
-
function applyProtection(targ, point, normal, damage, dflags) {
|
|
5316
|
-
let take = damage;
|
|
5317
|
-
let psave = 0;
|
|
5318
|
-
let asave = 0;
|
|
5319
|
-
let remainingCells;
|
|
5320
|
-
let remainingArmor;
|
|
5321
|
-
if (targ.powerArmor) {
|
|
5322
|
-
const result = applyPowerArmor(damage, dflags, point, normal, targ.powerArmor);
|
|
5323
|
-
psave = result.saved;
|
|
5324
|
-
remainingCells = result.remainingCells;
|
|
5325
|
-
take -= psave;
|
|
5326
|
-
}
|
|
5327
|
-
if (targ.regularArmor) {
|
|
5328
|
-
const result = applyRegularArmor(take, dflags, targ.regularArmor);
|
|
5329
|
-
asave = result.saved;
|
|
5330
|
-
remainingArmor = result.remainingArmor;
|
|
5331
|
-
take -= asave;
|
|
5332
|
-
}
|
|
5333
|
-
return [Math.max(0, take), psave, asave, remainingCells, remainingArmor];
|
|
5334
|
-
}
|
|
5335
|
-
function targetCenter(ent) {
|
|
5336
|
-
if (ent.mins && ent.maxs) {
|
|
5337
|
-
return {
|
|
5338
|
-
x: ent.origin.x + (ent.mins.x + ent.maxs.x) * 0.5,
|
|
5339
|
-
y: ent.origin.y + (ent.mins.y + ent.maxs.y) * 0.5,
|
|
5340
|
-
z: ent.origin.z + (ent.mins.z + ent.maxs.z) * 0.5
|
|
5341
|
-
};
|
|
5342
|
-
}
|
|
5343
|
-
return ent.origin;
|
|
5344
|
-
}
|
|
5345
|
-
function T_Damage(targ, inflictor, attacker, dir, point, normal, damage, knockback, dflags, mod, time, multicast) {
|
|
5346
|
-
if (!targ.takedamage) {
|
|
5347
|
-
return null;
|
|
5348
|
-
}
|
|
5349
|
-
const modifier = getDamageModifier(attacker, time);
|
|
5350
|
-
const modifiedDamage = damage * modifier;
|
|
5351
|
-
const modifiedKnockback = knockback * modifier;
|
|
5352
|
-
const protectedByGod = !hasAnyDamageFlag(dflags, 32 /* NO_PROTECTION */) && ((targ.flags ?? 0) & 1 /* GODMODE */) !== 0 && modifiedDamage > 0;
|
|
5353
|
-
if (protectedByGod) {
|
|
5354
|
-
return {
|
|
5355
|
-
take: 0,
|
|
5356
|
-
psave: 0,
|
|
5357
|
-
asave: modifiedDamage,
|
|
5358
|
-
knocked: { x: 0, y: 0, z: 0 },
|
|
5359
|
-
killed: false
|
|
5360
|
-
};
|
|
5361
|
-
}
|
|
5362
|
-
const knocked = applyKnockback(targ, attacker, dir, modifiedKnockback, dflags);
|
|
5363
|
-
let [take, psave, asave, remainingCells, remainingArmor] = applyProtection(targ, point, normal, modifiedDamage, dflags);
|
|
5364
|
-
if (targ.monsterinfo && targ.monsterinfo.freeze_time > time && modifiedDamage > 0) {
|
|
5365
|
-
take = targ.health + 100;
|
|
5366
|
-
psave = 0;
|
|
5367
|
-
asave = 0;
|
|
5368
|
-
}
|
|
5369
|
-
if (targ.powerArmor && remainingCells !== void 0) {
|
|
5370
|
-
targ.powerArmor.cellCount = remainingCells;
|
|
5371
|
-
}
|
|
5372
|
-
if (targ.regularArmor) {
|
|
5373
|
-
targ.regularArmor.armorCount = remainingArmor ?? targ.regularArmor.armorCount;
|
|
5374
|
-
}
|
|
5375
|
-
let actualTake = take;
|
|
5376
|
-
if (actualTake > 0) {
|
|
5377
|
-
targ.health -= actualTake;
|
|
5378
|
-
if (multicast && !hasAnyDamageFlag(dflags, 1024 /* NO_DAMAGE_EFFECTS */)) {
|
|
5379
|
-
if (targ.classname === "player" || targ.monsterinfo) {
|
|
5380
|
-
multicast(point, 1 /* Pvs */, ServerCommand.temp_entity, TempEntity.BLOOD, point, normal);
|
|
5381
|
-
} else {
|
|
5528
|
+
assignField(ref.entity, ref.name, target);
|
|
5529
|
+
}
|
|
5530
|
+
this.thinkScheduler.restore(snapshot.thinks, (index) => indexToEntity.get(index));
|
|
5531
|
+
}
|
|
5532
|
+
runTouches() {
|
|
5533
|
+
const world = this.pool.world;
|
|
5534
|
+
const activeEntities = [];
|
|
5535
|
+
for (const entity of this.pool) {
|
|
5536
|
+
if (entity === world) continue;
|
|
5537
|
+
if (!entity.inUse || entity.freePending || entity.solid === 0 /* Not */) continue;
|
|
5538
|
+
activeEntities.push(entity);
|
|
5539
|
+
}
|
|
5540
|
+
for (const first of activeEntities) {
|
|
5541
|
+
const candidates = this.findInBox(first.absmin, first.absmax);
|
|
5542
|
+
const firstBounds = computeBounds(first);
|
|
5543
|
+
for (const second of candidates) {
|
|
5544
|
+
if (first === second) continue;
|
|
5545
|
+
if (!first.touch) continue;
|
|
5546
|
+
const secondBounds = computeBounds(second);
|
|
5547
|
+
if (!boundsIntersect(firstBounds, secondBounds)) continue;
|
|
5548
|
+
first.touch(first, second);
|
|
5382
5549
|
}
|
|
5383
5550
|
}
|
|
5384
5551
|
}
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
targ.health = Math.max(1, targ.health);
|
|
5389
|
-
} else if (targ.die) {
|
|
5390
|
-
targ.die(targ, inflictor, attacker, actualTake, point, mod);
|
|
5552
|
+
registerTarget(entity) {
|
|
5553
|
+
if (!entity.targetname) {
|
|
5554
|
+
return;
|
|
5391
5555
|
}
|
|
5392
|
-
|
|
5393
|
-
|
|
5556
|
+
let bucket = this.targetNameIndex.get(entity.targetname);
|
|
5557
|
+
if (!bucket) {
|
|
5558
|
+
bucket = /* @__PURE__ */ new Set();
|
|
5559
|
+
this.targetNameIndex.set(entity.targetname, bucket);
|
|
5560
|
+
}
|
|
5561
|
+
bucket.add(entity);
|
|
5394
5562
|
}
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
const hits = [];
|
|
5399
|
-
const inflictorCenter = targetCenter(inflictor);
|
|
5400
|
-
const canDamage = options.canDamage ?? (() => true);
|
|
5401
|
-
for (const ent of entities) {
|
|
5402
|
-
if (ent === ignore || !ent.takedamage || !canDamage(ent, inflictor)) {
|
|
5403
|
-
continue;
|
|
5563
|
+
unregisterTarget(entity) {
|
|
5564
|
+
if (!entity.targetname) {
|
|
5565
|
+
return;
|
|
5404
5566
|
}
|
|
5405
|
-
const
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
if (radius > 0 && distance4 > radius) {
|
|
5409
|
-
continue;
|
|
5567
|
+
const bucket = this.targetNameIndex.get(entity.targetname);
|
|
5568
|
+
if (!bucket) {
|
|
5569
|
+
return;
|
|
5410
5570
|
}
|
|
5411
|
-
|
|
5412
|
-
if (
|
|
5413
|
-
|
|
5571
|
+
bucket.delete(entity);
|
|
5572
|
+
if (bucket.size === 0) {
|
|
5573
|
+
this.targetNameIndex.delete(entity.targetname);
|
|
5414
5574
|
}
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5575
|
+
}
|
|
5576
|
+
useTargetsImmediate(entity, activator) {
|
|
5577
|
+
if (entity.target) {
|
|
5578
|
+
for (const target of this.findByTargetName(entity.target)) {
|
|
5579
|
+
if (target === entity) {
|
|
5580
|
+
continue;
|
|
5581
|
+
}
|
|
5582
|
+
target.use?.(target, entity, activator);
|
|
5583
|
+
}
|
|
5584
|
+
}
|
|
5585
|
+
if (entity.killtarget) {
|
|
5586
|
+
for (const victim of this.findByTargetName(entity.killtarget)) {
|
|
5587
|
+
if (victim === entity) {
|
|
5588
|
+
continue;
|
|
5589
|
+
}
|
|
5590
|
+
this.free(victim);
|
|
5591
|
+
}
|
|
5418
5592
|
}
|
|
5419
|
-
const adjustedKnockback = adjustedDamage;
|
|
5420
|
-
const dir = normalizeVec3(subtractVec3(ent.origin, inflictorCenter));
|
|
5421
|
-
const result = T_Damage(ent, inflictor, attacker, dir, entCenter, dir, adjustedDamage, adjustedKnockback, dflags | 1 /* RADIUS */, mod, time, multicast);
|
|
5422
|
-
hits.push({ target: ent, result, appliedDamage: adjustedDamage });
|
|
5423
5593
|
}
|
|
5424
|
-
|
|
5425
|
-
|
|
5594
|
+
};
|
|
5595
|
+
|
|
5596
|
+
// src/entities/misc.ts
|
|
5597
|
+
init_esm();
|
|
5426
5598
|
|
|
5427
5599
|
// src/entities/misc/flyers.ts
|
|
5428
5600
|
init_esm();
|
|
@@ -25826,168 +25998,6 @@ function populatePlayerStats(player, timeSeconds) {
|
|
|
25826
25998
|
// src/index.ts
|
|
25827
25999
|
init_esm();
|
|
25828
26000
|
|
|
25829
|
-
// src/combat/specialDamage.ts
|
|
25830
|
-
init_esm();
|
|
25831
|
-
var ZERO2 = { x: 0, y: 0, z: 0 };
|
|
25832
|
-
var EnvironmentalFlags = /* @__PURE__ */ ((EnvironmentalFlags2) => {
|
|
25833
|
-
EnvironmentalFlags2[EnvironmentalFlags2["IN_WATER"] = 1] = "IN_WATER";
|
|
25834
|
-
EnvironmentalFlags2[EnvironmentalFlags2["IMMUNE_LAVA"] = 2] = "IMMUNE_LAVA";
|
|
25835
|
-
EnvironmentalFlags2[EnvironmentalFlags2["IMMUNE_SLIME"] = 4] = "IMMUNE_SLIME";
|
|
25836
|
-
return EnvironmentalFlags2;
|
|
25837
|
-
})(EnvironmentalFlags || {});
|
|
25838
|
-
function applyDamageEvent(target, amount, mod, time) {
|
|
25839
|
-
return T_Damage(target, null, null, ZERO2, target.origin, ZERO2, amount, 0, 2 /* NO_ARMOR */, mod, time);
|
|
25840
|
-
}
|
|
25841
|
-
function applyEnvironmentalDamage(target, nowMs) {
|
|
25842
|
-
const events = [];
|
|
25843
|
-
let flags = target.environmentFlags ?? 0;
|
|
25844
|
-
let enteredWater = false;
|
|
25845
|
-
let leftWater = false;
|
|
25846
|
-
if (target.waterlevel === WaterLevel.None) {
|
|
25847
|
-
if ((flags & 1 /* IN_WATER */) !== 0) {
|
|
25848
|
-
flags &= ~1 /* IN_WATER */;
|
|
25849
|
-
leftWater = true;
|
|
25850
|
-
}
|
|
25851
|
-
if (target.airFinished < nowMs && target.painDebounceTime <= nowMs) {
|
|
25852
|
-
const elapsedSeconds = Math.floor((nowMs - target.airFinished) / 1e3);
|
|
25853
|
-
const amount = Math.min(15, 2 + 2 * elapsedSeconds);
|
|
25854
|
-
const result = applyDamageEvent(target, amount, 17 /* WATER */, nowMs / 1e3);
|
|
25855
|
-
target.painDebounceTime = nowMs + 1e3;
|
|
25856
|
-
events.push({ mod: 17 /* WATER */, amount, result });
|
|
25857
|
-
}
|
|
25858
|
-
} else {
|
|
25859
|
-
target.airFinished = nowMs + 9e3;
|
|
25860
|
-
if ((flags & 1 /* IN_WATER */) === 0) {
|
|
25861
|
-
flags |= 1 /* IN_WATER */;
|
|
25862
|
-
enteredWater = true;
|
|
25863
|
-
target.damageDebounceTime = 0;
|
|
25864
|
-
}
|
|
25865
|
-
if (target.damageDebounceTime <= nowMs) {
|
|
25866
|
-
if ((target.watertype & CONTENTS_LAVA) !== 0 && (flags & 2 /* IMMUNE_LAVA */) === 0) {
|
|
25867
|
-
const amount = 10 * target.waterlevel;
|
|
25868
|
-
const result = applyDamageEvent(target, amount, 19 /* LAVA */, nowMs / 1e3);
|
|
25869
|
-
target.damageDebounceTime = nowMs + 100;
|
|
25870
|
-
events.push({ mod: 19 /* LAVA */, amount, result });
|
|
25871
|
-
} else if ((target.watertype & CONTENTS_SLIME) !== 0 && (flags & 4 /* IMMUNE_SLIME */) === 0) {
|
|
25872
|
-
const amount = 4 * target.waterlevel;
|
|
25873
|
-
const result = applyDamageEvent(target, amount, 18 /* SLIME */, nowMs / 1e3);
|
|
25874
|
-
target.damageDebounceTime = nowMs + 100;
|
|
25875
|
-
events.push({ mod: 18 /* SLIME */, amount, result });
|
|
25876
|
-
}
|
|
25877
|
-
}
|
|
25878
|
-
}
|
|
25879
|
-
target.environmentFlags = flags;
|
|
25880
|
-
return { events, enteredWater, leftWater };
|
|
25881
|
-
}
|
|
25882
|
-
function calculateFallingDamage(context) {
|
|
25883
|
-
const {
|
|
25884
|
-
impactDelta,
|
|
25885
|
-
waterLevel,
|
|
25886
|
-
onLadder = false,
|
|
25887
|
-
isDead = false,
|
|
25888
|
-
isPlayerModel = true,
|
|
25889
|
-
isNoClip = false,
|
|
25890
|
-
grappleBlockingFallDamage = false,
|
|
25891
|
-
clampFreeFall = false,
|
|
25892
|
-
skipDamage = false
|
|
25893
|
-
} = context;
|
|
25894
|
-
if (isDead || !isPlayerModel || isNoClip || grappleBlockingFallDamage || waterLevel === WaterLevel.Under) {
|
|
25895
|
-
return { damage: 0, event: null, fallValue: 0, adjustedDelta: 0 };
|
|
25896
|
-
}
|
|
25897
|
-
let delta = impactDelta * impactDelta * 1e-4;
|
|
25898
|
-
if (waterLevel === WaterLevel.Waist) {
|
|
25899
|
-
delta *= 0.25;
|
|
25900
|
-
} else if (waterLevel === WaterLevel.Feet) {
|
|
25901
|
-
delta *= 0.5;
|
|
25902
|
-
}
|
|
25903
|
-
if (clampFreeFall) {
|
|
25904
|
-
delta = Math.min(30, delta);
|
|
25905
|
-
}
|
|
25906
|
-
if (delta < 1) {
|
|
25907
|
-
return { damage: 0, event: null, fallValue: 0, adjustedDelta: delta };
|
|
25908
|
-
}
|
|
25909
|
-
let event = null;
|
|
25910
|
-
let damage = 0;
|
|
25911
|
-
let fallValue = 0;
|
|
25912
|
-
if (delta < 15) {
|
|
25913
|
-
event = onLadder ? null : "footstep";
|
|
25914
|
-
} else {
|
|
25915
|
-
fallValue = Math.min(delta * 0.5, 40);
|
|
25916
|
-
if (delta > 30) {
|
|
25917
|
-
event = delta >= 55 ? "fallfar" : "fall";
|
|
25918
|
-
damage = Math.max(1, (delta - 30) * 0.5);
|
|
25919
|
-
} else {
|
|
25920
|
-
event = "fallshort";
|
|
25921
|
-
}
|
|
25922
|
-
}
|
|
25923
|
-
if (skipDamage) {
|
|
25924
|
-
damage = 0;
|
|
25925
|
-
}
|
|
25926
|
-
return { damage, event, fallValue, adjustedDelta: delta };
|
|
25927
|
-
}
|
|
25928
|
-
function applyFallingDamage(target, context) {
|
|
25929
|
-
const result = calculateFallingDamage(context);
|
|
25930
|
-
if (result.damage > 0 && !context.skipDamage) {
|
|
25931
|
-
T_Damage(
|
|
25932
|
-
target,
|
|
25933
|
-
null,
|
|
25934
|
-
null,
|
|
25935
|
-
{ x: 0, y: 0, z: 1 },
|
|
25936
|
-
target.origin,
|
|
25937
|
-
ZERO2,
|
|
25938
|
-
result.damage,
|
|
25939
|
-
0,
|
|
25940
|
-
2 /* NO_ARMOR */,
|
|
25941
|
-
23 /* FALLING */,
|
|
25942
|
-
0
|
|
25943
|
-
);
|
|
25944
|
-
}
|
|
25945
|
-
return result;
|
|
25946
|
-
}
|
|
25947
|
-
function applyCrushDamage(crusher, target, options = {}) {
|
|
25948
|
-
const nonLivingDamage = options.nonLivingDamage ?? 1e5;
|
|
25949
|
-
const gibDamage = options.gibDamage ?? 100;
|
|
25950
|
-
const baseDamage = options.baseDamage ?? crusher.dmg ?? 10;
|
|
25951
|
-
const amount = !target.isMonster && !target.isClient ? nonLivingDamage : target.health < 1 ? gibDamage : baseDamage;
|
|
25952
|
-
const result = T_Damage(target, crusher, crusher, ZERO2, target.origin, ZERO2, amount, 1, 0 /* NONE */, 20 /* CRUSH */, 0);
|
|
25953
|
-
return { amount, result };
|
|
25954
|
-
}
|
|
25955
|
-
function absoluteBounds(ent) {
|
|
25956
|
-
const mins = ent.mins ?? ZERO2;
|
|
25957
|
-
const maxs = ent.maxs ?? ZERO2;
|
|
25958
|
-
return {
|
|
25959
|
-
mins: addVec3(ent.origin, mins),
|
|
25960
|
-
maxs: addVec3(ent.origin, maxs)
|
|
25961
|
-
};
|
|
25962
|
-
}
|
|
25963
|
-
function killBox(teleporter, targets, options = {}) {
|
|
25964
|
-
if (teleporter.movetype === 1 /* Noclip */) {
|
|
25965
|
-
return { events: [], cleared: true };
|
|
25966
|
-
}
|
|
25967
|
-
const mod = options.mod ?? 21 /* TELEFRAG */;
|
|
25968
|
-
const teleBounds = absoluteBounds(teleporter);
|
|
25969
|
-
const events = [];
|
|
25970
|
-
let cleared = true;
|
|
25971
|
-
for (const target of targets) {
|
|
25972
|
-
if (target === teleporter || target.inUse === false) {
|
|
25973
|
-
continue;
|
|
25974
|
-
}
|
|
25975
|
-
const solidity = target.solid ?? 0 /* Not */;
|
|
25976
|
-
if (!target.takedamage || solidity === 0 /* Not */ || solidity === 1 /* Trigger */ || solidity === 3 /* Bsp */) {
|
|
25977
|
-
continue;
|
|
25978
|
-
}
|
|
25979
|
-
if (!boxesIntersect(teleBounds, absoluteBounds(target))) {
|
|
25980
|
-
continue;
|
|
25981
|
-
}
|
|
25982
|
-
const result = T_Damage(target, teleporter, teleporter, ZERO2, target.origin, ZERO2, 1e5, 0, 32 /* NO_PROTECTION */, mod, 0);
|
|
25983
|
-
events.push({ target, result });
|
|
25984
|
-
if (!result || !result.killed || target.health > 0) {
|
|
25985
|
-
cleared = false;
|
|
25986
|
-
}
|
|
25987
|
-
}
|
|
25988
|
-
return { events, cleared };
|
|
25989
|
-
}
|
|
25990
|
-
|
|
25991
26001
|
// src/combat/weapon.ts
|
|
25992
26002
|
var WeaponType = /* @__PURE__ */ ((WeaponType2) => {
|
|
25993
26003
|
WeaponType2[WeaponType2["BLASTER"] = 0] = "BLASTER";
|