@korial29/tiny-fps 0.202.4 → 0.203.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.js +6 -6
- package/dist/local.js +1 -1
- package/dist/server.js +74 -3
- package/dist/types/client/beams.d.ts +2 -0
- package/dist/types/client/combat.d.ts +1 -1
- package/dist/types/client/gait.d.ts +1 -1
- package/dist/types/client/hud.d.ts +3 -1
- package/dist/types/shared/constants.d.ts +13 -0
- package/dist/types/shared/gun.d.ts +1 -0
- package/dist/types/shared/room.d.ts +6 -0
- package/dist/types/shared/types.d.ts +4 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -381,6 +381,18 @@ var [NECK, HIPS, MIDLINE] = [
|
|
|
381
381
|
*/
|
|
382
382
|
var PARRY = .7;
|
|
383
383
|
var PARRY_SIDE = 1.2;
|
|
384
|
+
/**
|
|
385
|
+
* The rail gun's ring (the user, 2026-11-23): G or the right button with it in hand spends RING_COST
|
|
386
|
+
* ticks of the capsule in one discharge round the player, which overheats the gun (HEAT_MAX, 2 s to
|
|
387
|
+
* cool; the user asked for a smaller one than the first 6 m). Every enemy within RING_R metres on the floor plane and RING_H of his height, in sight of
|
|
388
|
+
* his chest, takes 1 hp, is drained as the bolt drains (RAIL_TICKS, slowed under SLOW_SPEED) and
|
|
389
|
+
* shocked as a katana shocks (SHOCK_TICKS, thrown out of the ring).
|
|
390
|
+
*/
|
|
391
|
+
var [RING_COST, RING_R, RING_H] = [
|
|
392
|
+
20,
|
|
393
|
+
4,
|
|
394
|
+
2.5
|
|
395
|
+
];
|
|
384
396
|
var RIFLE_DRIFT = .012;
|
|
385
397
|
var RULES = {
|
|
386
398
|
maxPlayers: 16,
|
|
@@ -599,7 +611,8 @@ var KEY = {
|
|
|
599
611
|
/**
|
|
600
612
|
* Set for one step by G or the right button (the client's choice): with the katana in hand, the
|
|
601
613
|
* special of the cut the keys give (see CUT); with the laser rifle in hand, a grenade from its
|
|
602
|
-
* launcher
|
|
614
|
+
* launcher; with the pistol, a burst of BURST shots; with the rail gun, a discharge all round
|
|
615
|
+
* (RING_R).
|
|
603
616
|
*/
|
|
604
617
|
SPECIAL: 1024,
|
|
605
618
|
/**
|
|
@@ -6785,7 +6798,8 @@ var STRIKE = {
|
|
|
6785
6798
|
RAIL: 3,
|
|
6786
6799
|
LASER: 4,
|
|
6787
6800
|
NADE: 5,
|
|
6788
|
-
DISK: 6
|
|
6801
|
+
DISK: 6,
|
|
6802
|
+
RING: 7
|
|
6789
6803
|
};
|
|
6790
6804
|
/**
|
|
6791
6805
|
* One input: the move, then the weapons. Returns what struck on this step (STRIKE), for the host to
|
|
@@ -6835,6 +6849,7 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
|
|
|
6835
6849
|
p.hot = !!p.hot && p.heat > 0;
|
|
6836
6850
|
p.zapping = false;
|
|
6837
6851
|
p.zap = !!p.stun && !!p.zap;
|
|
6852
|
+
if (down || locked) p.burst = 0;
|
|
6838
6853
|
if (down) {
|
|
6839
6854
|
if (p.down > 0 && !--p.down) respawn(p, w, team, kit);
|
|
6840
6855
|
return STRIKE.NONE;
|
|
@@ -6953,6 +6968,24 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
|
|
|
6953
6968
|
return STRIKE.NONE;
|
|
6954
6969
|
}
|
|
6955
6970
|
if (bare || p.wield && !top || p.railed || p.rifled || busy || p.reload || !p.wield && !p.mag) p.charge = 0;
|
|
6971
|
+
const pistol = hand == 0 && !busy && !p.reload && !p.charge && !!p.mag;
|
|
6972
|
+
p.burst = pistol ? p.burst ?? 0 : 0;
|
|
6973
|
+
if (pistol && !p.cool && (p.burst || i.keys & KEY.SPECIAL)) {
|
|
6974
|
+
p.burst = (p.burst || 3) - 1;
|
|
6975
|
+
p.power = 1;
|
|
6976
|
+
p.ammo--;
|
|
6977
|
+
p.mag--;
|
|
6978
|
+
p.shots = p.shots + 1 & 255;
|
|
6979
|
+
p.cool = p.burst ? Math.ceil(kit.cool / 2) : Math.min(15, kit.cool * 2);
|
|
6980
|
+
return STRIKE.SHOT;
|
|
6981
|
+
}
|
|
6982
|
+
if (p.railed && i.keys & KEY.SPECIAL && !busy && !p.reload && !p.hot && p.cap >= RING_COST) {
|
|
6983
|
+
p.rail -= RING_COST;
|
|
6984
|
+
p.cap -= RING_COST;
|
|
6985
|
+
[p.heat, p.hot] = [120, true];
|
|
6986
|
+
p.shots = p.shots + 1 & 255;
|
|
6987
|
+
return STRIKE.RING;
|
|
6988
|
+
}
|
|
6956
6989
|
if (p.rifled && i.keys & KEY.SPECIAL && !busy && p.nades && !p.lob) {
|
|
6957
6990
|
p.nades--;
|
|
6958
6991
|
[p.lob, p.cool] = [60, 7];
|
|
@@ -9295,7 +9328,7 @@ function encodeSnapshot(s, meta) {
|
|
|
9295
9328
|
v.setUint8(o + 44, p.hits);
|
|
9296
9329
|
v.setUint8(o + 45, (p.swing ?? 0) & 63 | ((p.cut ?? 0) & 3) << 6);
|
|
9297
9330
|
v.setUint8(o + 46, (p.lost ?? 0) & 7 | ((p.cut ?? 0) & 4) << 1 | (p.fried ? 16 : 0) | (p.heavy ? 32 : 0) | (p.armor ?? 0) << 6);
|
|
9298
|
-
v.setUint8(o + 47, p.down ? p.fell ?? 0 : p.charge ?? 0);
|
|
9331
|
+
v.setUint8(o + 47, p.down ? p.fell ?? 0 : (p.charge ?? 0) | (p.burst ?? 0) << 6);
|
|
9299
9332
|
v.setUint8(o + 48, p.lock ?? 0);
|
|
9300
9333
|
v.setUint8(o + 49, (p.foe ?? 0) & 15 | (p.dashes & 2) << 3 | (p.hp & 8) << 2 | (p.mode & 8) << 3 | (p.pressed ? 128 : 0));
|
|
9301
9334
|
v.setUint8(o + 50, p.pushes ?? 0);
|
|
@@ -9704,6 +9737,7 @@ var Room = class {
|
|
|
9704
9737
|
else if (struck === STRIKE.RAIL) this.rail(p, input.view);
|
|
9705
9738
|
else if (struck === STRIKE.LASER) this.shoot(p, input.view);
|
|
9706
9739
|
else if (struck === STRIKE.NADE) this.shoot(p, input.view, lob(p.state, p.info.team));
|
|
9740
|
+
else if (struck === STRIKE.RING) this.ring(p, input.view);
|
|
9707
9741
|
else if (struck === STRIKE.DISK) this.shoot(p, input.view, disk(p.state, p.info.team));
|
|
9708
9742
|
Object.assign(p.state, here);
|
|
9709
9743
|
if (use && r && p.state.mode === MODE.RIDE) leave(p.state, r, 1, this.world);
|
|
@@ -10428,6 +10462,43 @@ var Room = class {
|
|
|
10428
10462
|
const foe = this.players().find((q) => q.info.id === target.id);
|
|
10429
10463
|
if (foe) this.shot(foe, 3, p, aimed.d[0], aimed.d[2]);
|
|
10430
10464
|
}
|
|
10465
|
+
/**
|
|
10466
|
+
* The rail gun's ring of `p` at the view tick `view`: every enemy within RING_R of him as `p` drew
|
|
10467
|
+
* him, within RING_H of his height and in sight of his chest, is drained as the bolt drains (a
|
|
10468
|
+
* first hp at once) and, still up and in no lock, shocked out of the ring. One hit for `p`.
|
|
10469
|
+
*/
|
|
10470
|
+
ring(p, view) {
|
|
10471
|
+
const me = p.state;
|
|
10472
|
+
const c = [
|
|
10473
|
+
me.x,
|
|
10474
|
+
me.y + 1,
|
|
10475
|
+
me.z
|
|
10476
|
+
];
|
|
10477
|
+
let hit = false;
|
|
10478
|
+
for (const seen of this.enemies(p, view)) {
|
|
10479
|
+
const foe = this.players().find((q) => q.info.id === seen.id);
|
|
10480
|
+
const [dx, dz] = [seen.x - me.x, seen.z - me.z];
|
|
10481
|
+
const d = Math.hypot(dx, dz);
|
|
10482
|
+
if (!foe || d > RING_R + .4 || Math.abs(seen.y - me.y) > RING_H || hidden(this.world, c, [
|
|
10483
|
+
seen.x,
|
|
10484
|
+
seen.y + 1,
|
|
10485
|
+
seen.z
|
|
10486
|
+
])) continue;
|
|
10487
|
+
hit = true;
|
|
10488
|
+
[foe.burn, foe.railer, foe.state.slow] = [
|
|
10489
|
+
0,
|
|
10490
|
+
p,
|
|
10491
|
+
180
|
|
10492
|
+
];
|
|
10493
|
+
this.fry(foe);
|
|
10494
|
+
if (!foe.state.down && !foe.state.lock) {
|
|
10495
|
+
stumble(foe.state, dx / (d || 1), dz / (d || 1), 24, 4);
|
|
10496
|
+
foe.state.zap = true;
|
|
10497
|
+
foe.by = p.info.id;
|
|
10498
|
+
}
|
|
10499
|
+
}
|
|
10500
|
+
if (hit) me.hits = me.hits + 1 & 255;
|
|
10501
|
+
}
|
|
10431
10502
|
/** 1 hp of the bolt's drain to `foe`, as his railer deals it; if it puts him down he is disintegrated (`fried`). */
|
|
10432
10503
|
fry(foe) {
|
|
10433
10504
|
const r = foe.railer?.state ?? foe.state;
|
|
@@ -35,6 +35,8 @@ export interface Tracer {
|
|
|
35
35
|
blast(at: Vec3, size?: number): void;
|
|
36
36
|
/** A shock wave from `at`: a ring of fire flat on the ground, out to `r` metres as it fades. */
|
|
37
37
|
ring(at: Vec3, r: number): void;
|
|
38
|
+
/** The rail gun's discharge round `at` (the feet): a loop of lightning out to `r` metres and bolts out to it, flickering as it fades. */
|
|
39
|
+
tesla(at: Vec3, r: number): void;
|
|
38
40
|
/**
|
|
39
41
|
* A short jagged bolt from `a` to `b` with a fork off its kink, gone in a twentieth of a second:
|
|
40
42
|
* an arc on a damaged hull, `wide` times as thick as the katana's bolts.
|
|
@@ -58,7 +58,7 @@ export declare const dreadful: (was: {
|
|
|
58
58
|
life: number;
|
|
59
59
|
vy: number;
|
|
60
60
|
}, p: PlayerState) => boolean;
|
|
61
|
-
export declare const createCombat: (world: World, audio: Pick<Audio, "play"> & Partial<Pick<Audio, "loop">>, hud: Pick<Hud, "vitals" | "hit" | "down">, fx: Pick<Effects, "fire" | "cut" | "wound" | "lie" | "quake" | "blow" | "punch">, tracer: Pick<Tracer, "flash" | "burst" | "blast" | "orbs" | "update" | "mount" | "crackle" | "charging" | "lightning">, ctl: {
|
|
61
|
+
export declare const createCombat: (world: World, audio: Pick<Audio, "play"> & Partial<Pick<Audio, "loop">>, hud: Pick<Hud, "vitals" | "hit" | "down">, fx: Pick<Effects, "fire" | "cut" | "wound" | "lie" | "quake" | "blow" | "punch">, tracer: Pick<Tracer, "flash" | "burst" | "blast" | "orbs" | "update" | "mount" | "crackle" | "charging" | "lightning" | "tesla">, ctl: {
|
|
62
62
|
pitch: number;
|
|
63
63
|
}, balls: Pick<Balls, "fire" | "frame">,
|
|
64
64
|
/** The muzzle of a runner's long gun as last drawn, from his feet (Renderer.muzzle()). */
|
|
@@ -16,7 +16,7 @@ export interface Gait {
|
|
|
16
16
|
* Moves to the state `p` after dt seconds. Without `floor` the feet stand on y = p.y. `seat` is
|
|
17
17
|
* where a player who rides sits: without it he sits level, a rider, facing his look.
|
|
18
18
|
*/
|
|
19
|
-
update(p: PlayerState, dt: number, floor?: Floor, seat?: Seat): void;
|
|
19
|
+
update(p: PlayerState, dt: number, floor?: Floor, seat?: Seat, clock?: number): void;
|
|
20
20
|
/** The pose now: one object, rewritten by each call. */
|
|
21
21
|
pose(): Pose;
|
|
22
22
|
/** Stride phase, in cycles: the left foot lands at 0 and the right one at a half. */
|
|
@@ -62,7 +62,9 @@ export interface Hud {
|
|
|
62
62
|
*/
|
|
63
63
|
cast(pick: (c: Choice & {
|
|
64
64
|
body: number;
|
|
65
|
-
}) => void): HTMLCanvasElement;
|
|
65
|
+
}) => void, preview?: (active: boolean) => void): HTMLCanvasElement;
|
|
66
|
+
/** Shows the loader over the character portrait while its deferred render is pending. */
|
|
67
|
+
previewLoading(loading: boolean): void;
|
|
66
68
|
/** The pictures of the haircuts on offer, in their order (HEAD_PX square): the own head with each. */
|
|
67
69
|
heads(): HTMLCanvasElement[];
|
|
68
70
|
/** The own player's magazines, as his class holds them (Kit's mag, cap, clip): the spare ones counted by them. */
|
|
@@ -347,6 +347,11 @@ export declare const GUN_COOLDOWN = 7;
|
|
|
347
347
|
export declare const CHARGE_TAP = 10;
|
|
348
348
|
export declare const CHARGE_TICKS = 60;
|
|
349
349
|
export declare const CHARGE_MAX = 5;
|
|
350
|
+
/**
|
|
351
|
+
* The pistol's burst (the user, 2026-11-23): G or the right button with it in hand fires BURST plain
|
|
352
|
+
* shots, half its cooldown apart, then waits twice its cooldown (15 ticks at most: `cool` has 4 bits).
|
|
353
|
+
*/
|
|
354
|
+
export declare const BURST = 3;
|
|
350
355
|
/** Metres a shot reaches: a plasma ball that has flown this far is gone. */
|
|
351
356
|
export declare const GUN_RANGE = 80;
|
|
352
357
|
/**
|
|
@@ -501,6 +506,14 @@ export declare const RAIL_RANGE = 30;
|
|
|
501
506
|
export declare const HEAT_MAX = 120;
|
|
502
507
|
export declare const HEAT_COOL = 2;
|
|
503
508
|
export declare const HEAT_LOCK = 0;
|
|
509
|
+
/**
|
|
510
|
+
* The rail gun's ring (the user, 2026-11-23): G or the right button with it in hand spends RING_COST
|
|
511
|
+
* ticks of the capsule in one discharge round the player, which overheats the gun (HEAT_MAX, 2 s to
|
|
512
|
+
* cool; the user asked for a smaller one than the first 6 m). Every enemy within RING_R metres on the floor plane and RING_H of his height, in sight of
|
|
513
|
+
* his chest, takes 1 hp, is drained as the bolt drains (RAIL_TICKS, slowed under SLOW_SPEED) and
|
|
514
|
+
* shocked as a katana shocks (SHOCK_TICKS, thrown out of the ring).
|
|
515
|
+
*/
|
|
516
|
+
export declare const RING_COST: number, RING_R: number, RING_H: number;
|
|
504
517
|
export declare const RAIL_TICKS = 180;
|
|
505
518
|
export declare const RAIL_DRAIN = 60;
|
|
506
519
|
export declare const SLOW_SPEED = 3;
|
|
@@ -198,6 +198,12 @@ export declare class Room {
|
|
|
198
198
|
private shoulderTarget;
|
|
199
199
|
/** Fires only after an uninterrupted three-second target lock; damage is three HP. */
|
|
200
200
|
private shoulder;
|
|
201
|
+
/**
|
|
202
|
+
* The rail gun's ring of `p` at the view tick `view`: every enemy within RING_R of him as `p` drew
|
|
203
|
+
* him, within RING_H of his height and in sight of his chest, is drained as the bolt drains (a
|
|
204
|
+
* first hp at once) and, still up and in no lock, shocked out of the ring. One hit for `p`.
|
|
205
|
+
*/
|
|
206
|
+
private ring;
|
|
201
207
|
/** 1 hp of the bolt's drain to `foe`, as his railer deals it; if it puts him down he is disintegrated (`fried`). */
|
|
202
208
|
private fry;
|
|
203
209
|
/**
|
|
@@ -60,7 +60,8 @@ export declare const KEY: {
|
|
|
60
60
|
/**
|
|
61
61
|
* Set for one step by G or the right button (the client's choice): with the katana in hand, the
|
|
62
62
|
* special of the cut the keys give (see CUT); with the laser rifle in hand, a grenade from its
|
|
63
|
-
* launcher
|
|
63
|
+
* launcher; with the pistol, a burst of BURST shots; with the rail gun, a discharge all round
|
|
64
|
+
* (RING_R).
|
|
64
65
|
*/
|
|
65
66
|
readonly SPECIAL: 1024;
|
|
66
67
|
/**
|
|
@@ -256,6 +257,8 @@ export interface PlayerState {
|
|
|
256
257
|
inRifle?: boolean;
|
|
257
258
|
/** Ticks FIRE has been held with the gun, up to CHARGE_TICKS, 0 when not charging. Absent reads 0. */
|
|
258
259
|
charge?: number;
|
|
260
|
+
/** Shots left in the pistol's burst (G), 0 to BURST - 1. Absent reads 0. */
|
|
261
|
+
burst?: number;
|
|
259
262
|
/** The strength of the last shot, 1 to CHARGE_MAX: the shots it spent and the health it takes. Set by the step that fires; not on the wire. */
|
|
260
263
|
power?: number;
|
|
261
264
|
/** Standing inside the circle of the team's rack as of the last step: the gun is filled on arrival only. Absent reads false. */
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@korial29/tiny-fps",
|
|
3
3
|
"description": "Tiny multiplayer first-person rooftop game for the browser: raw WebGL, zero runtime dependencies, WebSocket or same-browser multi-tab play.",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.203.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|