@adatechnology/game-test-room 0.24.0 → 0.25.1
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/dist/index.d.ts +3 -1
- package/dist/index.global.js +188 -25
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +73 -11
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createDestruction, JOINT_DEFAULTS, resolveStrings as resolveDestructionStrings } from "@adatechnology/game-destruction";
|
|
3
3
|
import { createAudioEngine, createAudioSink, loadKitSamples, loadUserSamples } from "@adatechnology/game-audio";
|
|
4
4
|
import { createDestructionRenderer, createDestructionSound, dragSoundKey, impactKey, impactSoundKeys, specFromObject3D } from "@adatechnology/game-destruction-three";
|
|
5
|
-
import { bodyMass, KNOCK_CHEST, knockOf, surfaceOfMaterial } from "@adatechnology/game-contracts";
|
|
5
|
+
import { bodyMass, KNOCK_CHEST, KNOCK_DOWN_SPEED, knockOf, surfaceOfMaterial } from "@adatechnology/game-contracts";
|
|
6
6
|
|
|
7
7
|
// src/body-sounds.ts
|
|
8
8
|
import { BODY_FOLEY_BANK } from "@adatechnology/game-audio";
|
|
@@ -812,7 +812,17 @@ function createExplosives(context) {
|
|
|
812
812
|
if (onPlayer.zone !== "none") {
|
|
813
813
|
action("blast_player", translate("act.blast_player", { weapon: weaponName, zone: translate(`blast.zone.${onPlayer.zone}`), distance: format(onPlayer.distance, 1), stun: format(onPlayer.stunSeconds, 1) }), { data: { ...onPlayer } });
|
|
814
814
|
}
|
|
815
|
-
context.emitHost({
|
|
815
|
+
context.emitHost({
|
|
816
|
+
type: "explosion",
|
|
817
|
+
source: projectile.weapon,
|
|
818
|
+
point: detonation.point,
|
|
819
|
+
energy: detonation.energy,
|
|
820
|
+
radius: reach,
|
|
821
|
+
cause: detonation.cause,
|
|
822
|
+
explosive: detonation.explosive,
|
|
823
|
+
lethalRadius: detonation.lethalRadius,
|
|
824
|
+
...detonation.tnt !== void 0 ? { tnt: detonation.tnt } : {}
|
|
825
|
+
});
|
|
816
826
|
if (detonation.fire) context.startFire(projectile.weapon, detonation.point, detonation.fire, detonation.cause === "impact");
|
|
817
827
|
};
|
|
818
828
|
const detonateBare = (projectile, isImpact) => {
|
|
@@ -2148,6 +2158,9 @@ var LYING_EYE = 0.3;
|
|
|
2148
2158
|
var LYING_PITCH = 1.05;
|
|
2149
2159
|
var LYING_ROLL = 0.35;
|
|
2150
2160
|
var LYING_PITCH_FACE_DOWN = -1.05;
|
|
2161
|
+
var STUN_PITCH = 0.05;
|
|
2162
|
+
var STUN_ROLL = 0.08;
|
|
2163
|
+
var STUN_FULL = 2;
|
|
2151
2164
|
function createPlayer(THREE, o) {
|
|
2152
2165
|
const cam = o.camera;
|
|
2153
2166
|
let yaw = 0;
|
|
@@ -2187,11 +2200,16 @@ function createPlayer(THREE, o) {
|
|
|
2187
2200
|
};
|
|
2188
2201
|
let knocked = null;
|
|
2189
2202
|
let knockedForward = false;
|
|
2203
|
+
let stunLeft = 0;
|
|
2204
|
+
let stunPhase = 0;
|
|
2190
2205
|
let rollSide = 1;
|
|
2191
2206
|
const apply = () => {
|
|
2192
2207
|
const lying = knocked?.lying ?? 0;
|
|
2193
2208
|
const fallen = lying * lying * (3 - 2 * lying);
|
|
2194
|
-
|
|
2209
|
+
const sway = Math.min(1, stunLeft / STUN_FULL);
|
|
2210
|
+
const swayPitch = STUN_PITCH * sway * Math.sin(stunPhase * 1.3);
|
|
2211
|
+
const swayRoll = STUN_ROLL * sway * Math.sin(stunPhase * 0.9 + 1);
|
|
2212
|
+
euler.set(pitch + ((knockedForward ? LYING_PITCH_FACE_DOWN : LYING_PITCH) - pitch) * fallen + swayPitch, yaw, LYING_ROLL * rollSide * fallen + swayRoll, "YXZ");
|
|
2195
2213
|
cam.quaternion.setFromEuler(euler);
|
|
2196
2214
|
const standing = eye - CROUCH_DROP * crouch - bend;
|
|
2197
2215
|
cam.position.set(px.x, floorLevel + y + standing + (LYING_EYE - standing) * fallen, px.z);
|
|
@@ -2465,11 +2483,15 @@ function createPlayer(THREE, o) {
|
|
|
2465
2483
|
knocked.velocity = [knocked.velocity[0] + next.velocity[0], knocked.velocity[1] + next.velocity[1], knocked.velocity[2] + next.velocity[2]];
|
|
2466
2484
|
knocked.airborne || (knocked.airborne = next.airborne);
|
|
2467
2485
|
knocked.down || (knocked.down = next.down);
|
|
2486
|
+
knocked.wounded || (knocked.wounded = next.wounded);
|
|
2487
|
+
knocked.lieLeft = Math.max(knocked.lieLeft, next.lieLeft);
|
|
2468
2488
|
} else knocked = { ...next, velocity: [...next.velocity] };
|
|
2489
|
+
stunLeft = Math.max(stunLeft, next.stunSeconds ?? 0);
|
|
2469
2490
|
if (next.down) {
|
|
2470
|
-
const
|
|
2491
|
+
const away = next.away && (next.away[0] !== 0 || next.away[2] !== 0) ? next.away : next.velocity;
|
|
2492
|
+
const right = Math.cos(yaw) * away[0] - Math.sin(yaw) * away[2];
|
|
2471
2493
|
rollSide = right >= 0 ? -1 : 1;
|
|
2472
|
-
knockedForward = -Math.sin(yaw) *
|
|
2494
|
+
knockedForward = -Math.sin(yaw) * away[0] - Math.cos(yaw) * away[2] > 0;
|
|
2473
2495
|
crouchLatched = false;
|
|
2474
2496
|
}
|
|
2475
2497
|
if (knocked.airborne) vy = Math.max(vy, knocked.velocity[1]);
|
|
@@ -2480,7 +2502,14 @@ function createPlayer(THREE, o) {
|
|
|
2480
2502
|
get knockedForward() {
|
|
2481
2503
|
return knockedForward;
|
|
2482
2504
|
},
|
|
2505
|
+
get stunned() {
|
|
2506
|
+
return stunLeft;
|
|
2507
|
+
},
|
|
2483
2508
|
update(dt) {
|
|
2509
|
+
if (stunLeft > 0) {
|
|
2510
|
+
stunLeft = Math.max(0, stunLeft - dt);
|
|
2511
|
+
stunPhase += dt * 2.4;
|
|
2512
|
+
}
|
|
2484
2513
|
if (knocked) {
|
|
2485
2514
|
stepKnocked(dt);
|
|
2486
2515
|
return;
|
|
@@ -3520,6 +3549,9 @@ var en = {
|
|
|
3520
3549
|
"act.player_slammed": "The player was thrown into {what} at {speed} m/s",
|
|
3521
3550
|
"act.player_fell": "The player hit the floor at {speed} m/s",
|
|
3522
3551
|
"act.player_shoved": "The blast pushed the player at {speed} m/s ({reach}% got through the cover)",
|
|
3552
|
+
"act.player_wounded": "The blast felled the player where they stood, {distance} m from it: badly wounded, stunned for {stun} s ({reach}% got through the cover)",
|
|
3553
|
+
"act.player_thrown_wounded": "The blast threw the player at {speed} m/s, {distance} m from it: badly wounded, stunned for {stun} s ({reach}% got through the cover)",
|
|
3554
|
+
"act.player_stunned": "The blast stunned the player for {stun} s, {distance} m from it: dizzy, ears ringing",
|
|
3523
3555
|
"act.came_apart": "{name} came apart: what stayed is loose and falls",
|
|
3524
3556
|
"act.shoved": "{name} stands free: the shots moved it",
|
|
3525
3557
|
"act.impact": "{name} hit {where} at {speed} m/s: {energy} J of blunt damage",
|
|
@@ -3882,6 +3914,9 @@ var ptBR = {
|
|
|
3882
3914
|
"act.player_slammed": "O jogador foi arremessado contra {what} a {speed} m/s",
|
|
3883
3915
|
"act.player_fell": "O jogador bateu no ch\xE3o a {speed} m/s",
|
|
3884
3916
|
"act.player_shoved": "A explos\xE3o empurrou o jogador a {speed} m/s ({reach}% passou pela cobertura)",
|
|
3917
|
+
"act.player_wounded": "A explos\xE3o derrubou o jogador onde estava, a {distance} m dela: ferido gravemente, atordoado por {stun} s ({reach}% passou pela cobertura)",
|
|
3918
|
+
"act.player_thrown_wounded": "A explos\xE3o arremessou o jogador a {speed} m/s, a {distance} m dela: ferido gravemente, atordoado por {stun} s ({reach}% passou pela cobertura)",
|
|
3919
|
+
"act.player_stunned": "A explos\xE3o atordoou o jogador por {stun} s, a {distance} m dela: tonto, com os ouvidos zumbindo",
|
|
3885
3920
|
"act.came_apart": "{name} se desmontou: o que ficou est\xE1 solto e cai",
|
|
3886
3921
|
"act.shoved": "{name} estava solto no ch\xE3o: os tiros o moveram",
|
|
3887
3922
|
"act.impact": "{name} bateu em {where} a {speed} m/s: {energy} J de dano de impacto",
|
|
@@ -5611,7 +5646,19 @@ function createTestRoom(options) {
|
|
|
5611
5646
|
for (const ev of batch) {
|
|
5612
5647
|
if (ev.type === "leak") puncture(ev);
|
|
5613
5648
|
else if (ev.type === "ignite") igniteNear(ev.point, 0.9);
|
|
5614
|
-
else if (ev.type === "explode")
|
|
5649
|
+
else if (ev.type === "explode") {
|
|
5650
|
+
emitHost({
|
|
5651
|
+
type: "explosion",
|
|
5652
|
+
source: ev.object,
|
|
5653
|
+
point: ev.point,
|
|
5654
|
+
energy: ev.energy,
|
|
5655
|
+
radius: ev.radius,
|
|
5656
|
+
cause: "part",
|
|
5657
|
+
...ev.effect !== void 0 ? { explosive: ev.effect } : {},
|
|
5658
|
+
...ev.tnt !== void 0 ? { tnt: ev.tnt } : {},
|
|
5659
|
+
...ev.lethalRadius !== void 0 ? { lethalRadius: ev.lethalRadius } : {}
|
|
5660
|
+
});
|
|
5661
|
+
}
|
|
5615
5662
|
fire("event", ev);
|
|
5616
5663
|
options.onEvent?.(ev);
|
|
5617
5664
|
}
|
|
@@ -6307,14 +6354,27 @@ function createTestRoom(options) {
|
|
|
6307
6354
|
const knockPlayer = (event) => {
|
|
6308
6355
|
if (seating.seat) return;
|
|
6309
6356
|
const feet = [player.x, player.feet, player.z];
|
|
6310
|
-
const
|
|
6311
|
-
const
|
|
6357
|
+
const chest = [feet[0], feet[1] + KNOCK_CHEST, feet[2]];
|
|
6358
|
+
const reach = world.blastReach(event.point, chest, event.source ? { ignore: [event.source] } : {});
|
|
6359
|
+
const blast = {
|
|
6360
|
+
point: event.point,
|
|
6361
|
+
energy: event.energy,
|
|
6362
|
+
radius: event.radius,
|
|
6363
|
+
reach,
|
|
6364
|
+
...event.tnt !== void 0 ? { tnt: event.tnt } : {},
|
|
6365
|
+
...event.lethalRadius !== void 0 ? { lethalRadius: event.lethalRadius } : {}
|
|
6366
|
+
};
|
|
6367
|
+
const knock = knockOf(blast, feet, playerMass, options.blastShove, options.blastImpulse);
|
|
6312
6368
|
if (!knock) return;
|
|
6313
6369
|
player.knock(knock);
|
|
6314
6370
|
const speed = Math.hypot(knock.velocity[0], knock.velocity[1], knock.velocity[2]);
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
}
|
|
6371
|
+
const distance = Math.hypot(chest[0] - event.point[0], chest[1] - event.point[1], chest[2] - event.point[2]);
|
|
6372
|
+
const data = { speed, reach, distance, down: knock.down, wounded: Boolean(knock.wounded), stunSeconds: knock.stunSeconds ?? 0, source: event.source };
|
|
6373
|
+
const values = { speed: num(speed, 1), reach: num(reach * 100, 0), distance: num(distance, 1), stun: num(knock.stunSeconds ?? 0, 1) };
|
|
6374
|
+
if (knock.wounded) action("player_wounded", t(speed >= KNOCK_DOWN_SPEED ? "act.player_thrown_wounded" : "act.player_wounded", values), { data });
|
|
6375
|
+
else if (knock.down) action("player_knocked_down", t("act.knocked_down", values), { data });
|
|
6376
|
+
else if (speed > 0) action("player_shoved", t("act.player_shoved", values), { data });
|
|
6377
|
+
else action("player_stunned", t("act.player_stunned", values), { data });
|
|
6318
6378
|
};
|
|
6319
6379
|
const avatarState = { speed: 0, running: false, crouch: false, down: false, armed: false, pitch: 0 };
|
|
6320
6380
|
let feetPrev = null;
|
|
@@ -8274,6 +8334,8 @@ function createTestRoom(options) {
|
|
|
8274
8334
|
let handle = null;
|
|
8275
8335
|
return {
|
|
8276
8336
|
id: `vfx:${id}`,
|
|
8337
|
+
// the room was drawn in every fog state just before: each frame of a blast draws the effects alone
|
|
8338
|
+
root: () => vfx.root,
|
|
8277
8339
|
play() {
|
|
8278
8340
|
handle = vfx.play({ effect: id, point: [0, 0.1, -4], direction: [0, 1, 0], normal: [0, 1, 0] });
|
|
8279
8341
|
},
|