@korial29/tiny-fps 0.170.0 → 0.172.0
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 +31 -31
- package/dist/local.js +1 -1
- package/dist/server.js +55 -5
- package/dist/types/client/body.d.ts +6 -3
- package/dist/types/client/katana.d.ts +20 -0
- package/dist/types/client/render.d.ts +2 -0
- package/dist/types/client/soldier.d.ts +5 -1
- package/dist/types/shared/blade.d.ts +10 -1
- package/dist/types/shared/constants.d.ts +7 -0
- package/dist/types/shared/kit.d.ts +10 -0
- package/dist/types/shared/plasma.d.ts +2 -0
- package/dist/types/shared/room.d.ts +7 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -329,6 +329,12 @@ var [NECK, HIPS, MIDLINE] = [
|
|
|
329
329
|
.45,
|
|
330
330
|
.12
|
|
331
331
|
];
|
|
332
|
+
/**
|
|
333
|
+
* The ninja's parry (the user, 2026-11-16): with the katana in hand, a ball (not a grenade or an arc)
|
|
334
|
+
* that comes at him within PARRY_ARC radians of his facing is struck back PARRY of the time (Kit.parry),
|
|
335
|
+
* along his look.
|
|
336
|
+
*/
|
|
337
|
+
var PARRY = .7;
|
|
332
338
|
var RIFLE_DRIFT = .012;
|
|
333
339
|
var RULES = {
|
|
334
340
|
maxPlayers: 16,
|
|
@@ -703,6 +709,7 @@ var MARINE = {
|
|
|
703
709
|
damage: 1,
|
|
704
710
|
slow: 1,
|
|
705
711
|
accel: 1,
|
|
712
|
+
parry: 0,
|
|
706
713
|
hp: 8,
|
|
707
714
|
gear: true,
|
|
708
715
|
xeno: false
|
|
@@ -729,6 +736,7 @@ var KITS = [
|
|
|
729
736
|
damage: .5,
|
|
730
737
|
slow: .55,
|
|
731
738
|
accel: 1,
|
|
739
|
+
parry: PARRY,
|
|
732
740
|
hp: 8,
|
|
733
741
|
gear: true,
|
|
734
742
|
xeno: false
|
|
@@ -1832,6 +1840,26 @@ var move = (p, i, w, team = 0, bodies = [], kit = KITS[0]) => {
|
|
|
1832
1840
|
/** Where on the body the blade is, as a share of its height: the chest, which a brush must not cover. */
|
|
1833
1841
|
var CHEST = .7;
|
|
1834
1842
|
/**
|
|
1843
|
+
* Whether `p` can meet the ball `b` that reached him with the katana: in hand and idle (not in a
|
|
1844
|
+
* cut, a punch or charging one: the user, 2026-11-16), on his feet (not hanging, climbing, seated or
|
|
1845
|
+
* stumbling), a ball (not a grenade or an arc) coming at him within PARRY_ARC radians of his facing.
|
|
1846
|
+
* Whether he does is his kit's chance (Kit.parry, room.ts).
|
|
1847
|
+
*/
|
|
1848
|
+
var fends = (p, b) => {
|
|
1849
|
+
if (!p.wield || p.swing || p.charge || p.stun > 0 || b.arc || b.power === 7) return false;
|
|
1850
|
+
if (p.mode === MODE.HANG || p.mode === MODE.CLIMB || p.mode === MODE.RIDE) return false;
|
|
1851
|
+
const [fx, fz] = forward(p.yaw);
|
|
1852
|
+
const h = Math.sqrt(b.dx * b.dx + b.dz * b.dz);
|
|
1853
|
+
return h > 1e-6 && -(b.dx * fx + b.dz * fz) >= Math.cos(1.2) * h;
|
|
1854
|
+
};
|
|
1855
|
+
/** A number in [0, 1) from integers, the same for the same ones: the host's dice, which tests can replay. */
|
|
1856
|
+
var roll = (...n) => {
|
|
1857
|
+
let h = 2166136261;
|
|
1858
|
+
for (const v of n) h = Math.imul(h ^ v, 16777619);
|
|
1859
|
+
h = Math.imul(h ^ h >>> 15, 739982445);
|
|
1860
|
+
return ((h ^ h >>> 12) >>> 0) / 2 ** 32;
|
|
1861
|
+
};
|
|
1862
|
+
/**
|
|
1835
1863
|
* The cut the keys held when FIRE starts a swing give: LEFT or RIGHT, one of them, cuts across from
|
|
1836
1864
|
* that side; else FORWARD thrusts; else (back or no key) it slashes. Both sides held are neither.
|
|
1837
1865
|
*/
|
|
@@ -9023,10 +9051,10 @@ var Room = class {
|
|
|
9023
9051
|
/**
|
|
9024
9052
|
* `hp` of a gun's damage to `foe` from `by`: as his class deals it (Kit.damage, a ninja's half), the
|
|
9025
9053
|
* half points kept on `foe` toward the next, the hit going (dx, dz). True when he went down; `how`
|
|
9026
|
-
* is the FRAG then.
|
|
9054
|
+
* is the FRAG then. A ball sent back (`back`) hurts in full whoever sent it.
|
|
9027
9055
|
*/
|
|
9028
|
-
shot(foe, hp, by, dx, dz, how = FRAG.GUN) {
|
|
9029
|
-
const bank = (foe.halves ?? 0) + hp * 2 * (by ?
|
|
9056
|
+
shot(foe, hp, by, dx, dz, how = FRAG.GUN, back = false) {
|
|
9057
|
+
const bank = (foe.halves ?? 0) + hp * 2 * (by && !back ? this.kit(by).damage : 1);
|
|
9030
9058
|
foe.halves = bank % 2;
|
|
9031
9059
|
return bank >= 2 && this.harm(foe, Math.floor(bank / 2), by, how, felled(FALL$1.SHOT, dx, dz));
|
|
9032
9060
|
}
|
|
@@ -9143,12 +9171,16 @@ var Room = class {
|
|
|
9143
9171
|
}
|
|
9144
9172
|
const foe = foes.find((q) => q.state === hit);
|
|
9145
9173
|
if (!foe) return;
|
|
9174
|
+
if (fends(foe.state, b) && roll(this.ticks, b.by, b.id, foe.info.id) < this.kit(foe).parry) {
|
|
9175
|
+
this.deflect(foe, b);
|
|
9176
|
+
return;
|
|
9177
|
+
}
|
|
9146
9178
|
if (by) by.state.hits = by.state.hits + 1 & 255;
|
|
9147
9179
|
if (b.power === 6) this.shot(foe, BOLT_HP, by, b.dx, b.dz);
|
|
9148
9180
|
else if (b.power === 0) {
|
|
9149
9181
|
foe.graze = ((foe.graze ?? 0) + 1) % 2;
|
|
9150
|
-
if (!foe.graze) this.shot(foe, 1, by, b.dx, b.dz);
|
|
9151
|
-
} else if (!b.arc) this.shot(foe, b.power ?? 1, by, b.dx, b.dz);
|
|
9182
|
+
if (!foe.graze) this.shot(foe, 1, by, b.dx, b.dz, FRAG.GUN, b.back);
|
|
9183
|
+
} else if (!b.arc) this.shot(foe, b.power ?? 1, by, b.dx, b.dz, FRAG.GUN, b.back);
|
|
9152
9184
|
else if (this.harm(foe, CUTS[b.arc].hp, by, FRAG.BLADE, felled(FALL$1.STRUCK, b.dx, b.dz))) {
|
|
9153
9185
|
const from = by && {
|
|
9154
9186
|
...by.state,
|
|
@@ -9170,6 +9202,24 @@ var Room = class {
|
|
|
9170
9202
|
}
|
|
9171
9203
|
}
|
|
9172
9204
|
/**
|
|
9205
|
+
* The katana of `p` met the ball `b`: it ends on the blade (its burst, no hit), and one as strong
|
|
9206
|
+
* leaves his eye along his look, his own and his team's, its range full again. Its id runs on from
|
|
9207
|
+
* his `shots` by 64 plus his parries: the sum only grows, so it names no ball of his still in flight.
|
|
9208
|
+
*/
|
|
9209
|
+
deflect(p, b) {
|
|
9210
|
+
p.parries = (p.parries ?? 0) + 1 & 255;
|
|
9211
|
+
this.shoot(p, this.ticks, {
|
|
9212
|
+
...launch$1({
|
|
9213
|
+
...p.state,
|
|
9214
|
+
rifled: false
|
|
9215
|
+
}, p.info.team),
|
|
9216
|
+
id: p.state.shots + 64 + p.parries & 255,
|
|
9217
|
+
power: b.power ?? 1,
|
|
9218
|
+
left: b.power === 0 ? 60 : 80,
|
|
9219
|
+
back: true
|
|
9220
|
+
});
|
|
9221
|
+
}
|
|
9222
|
+
/**
|
|
9173
9223
|
* A cut of `p` struck at the view tick `view`: every enemy it reaches as `p` drew him is hit
|
|
9174
9224
|
* (`strike`), and the `hits` count goes up once. Each takes the cut's hp; one it does not put
|
|
9175
9225
|
* down is shocked: a stumble of SHOCK_TICKS thrown SHOCK_KNOCK m/s the way the blade throws him, with
|
|
@@ -19,6 +19,8 @@ export interface Body {
|
|
|
19
19
|
muzzle(): Vec3;
|
|
20
20
|
/** How far a share of the trunk's twist in a cut has turned the body as of the last update (radians, trunk()): the drawn view turns with it. */
|
|
21
21
|
spun(): number;
|
|
22
|
+
/** The katana in hand just struck a ball back: it snaps into the parry (DEFLECT, katana.ts) and eases back. */
|
|
23
|
+
parried(): void;
|
|
22
24
|
/** Its gait's footsteps so far and stride phase (Gait.steps, Gait.phase): the sounds of its steps and the bob of the view go with its feet. */
|
|
23
25
|
readonly steps: number;
|
|
24
26
|
readonly phase: number;
|
|
@@ -81,10 +83,11 @@ far?: boolean) => void;
|
|
|
81
83
|
* fixed way about the handle (from `at`, `g` and the elbows' `poles`) and its forearm carrying on
|
|
82
84
|
* along its fingers, so that each elbow is a forearm's length back from its wrist. The piece goes
|
|
83
85
|
* the least way from where the cut puts it (a radian of the blade weighs as 3 m of the hands) to
|
|
84
|
-
* where both elbows are an upper arm's length from their shoulders
|
|
85
|
-
*
|
|
86
|
+
* where both elbows are an upper arm's length from their shoulders; `turn` is what a radian of the
|
|
87
|
+
* blade weighs against a metre of the hands, as a freedom (a parry holds its line: less). Returns
|
|
88
|
+
* the grip, the blade, and the fingers of the right hand and of the left.
|
|
86
89
|
*/
|
|
87
|
-
export declare const clasp: (s: Solved, at: Vec3, g: Vec3, poles: [Vec3, Vec3]) => [Vec3, Vec3, Vec3, Vec3];
|
|
90
|
+
export declare const clasp: (s: Solved, at: Vec3, g: Vec3, poles: [Vec3, Vec3], turn?: number) => [Vec3, Vec3, Vec3, Vec3];
|
|
88
91
|
/** The woman's hand to the man's, about the wrist (SCALE in skin.ts has her glove's). */
|
|
89
92
|
export declare const HAND_F = 0.92;
|
|
90
93
|
/** The xenomorph's hands against the man's, about the wrist. */
|
|
@@ -53,6 +53,26 @@ export declare const GUARD: number[];
|
|
|
53
53
|
export declare const LOCK: number[];
|
|
54
54
|
/** The lock's hold shaking with the clock `t` (s), the hands out by `push` (0 to 1) of 6 cm: a press drives the blade on. */
|
|
55
55
|
export declare const locked: (t: number, push?: number) => number[];
|
|
56
|
+
/**
|
|
57
|
+
* The parry (the user, 2026-11-16), in the own view: the katana across the whole view, from its
|
|
58
|
+
* bottom right corner to its top left, its edge to the shot. The grip is asked for past the arms'
|
|
59
|
+
* reach on the right: clasp() keeps the wrists straight and pulls the fists in to the bottom middle,
|
|
60
|
+
* the hilt toward the corner.
|
|
61
|
+
*/
|
|
62
|
+
export declare const DEFLECT: number[];
|
|
63
|
+
/**
|
|
64
|
+
* The runner's parry, from his eye like CARRY (soldier.ts), low so that it guards him: the hands
|
|
65
|
+
* before the belly and the blade forward and across the trunk to the height of the left shoulder.
|
|
66
|
+
* With the wrists straight (clasp()), a blade turned more across or upright lifts the hands to the
|
|
67
|
+
* chest and the block over it.
|
|
68
|
+
*/
|
|
69
|
+
export declare const DEFLECT_LOW: number[];
|
|
70
|
+
/** Seconds of a parry: to the block in PARRY_IN, eased back to the hold by PARRY_OUT. */
|
|
71
|
+
export declare const PARRY_IN: number, PARRY_OUT: number;
|
|
72
|
+
/** How far into DEFLECT a hold is `s` seconds after the blade met a ball (it peaks at PARRY_IN): 0 to 1 and back to 0. */
|
|
73
|
+
export declare const parrying: (s: number) => number;
|
|
74
|
+
/** The grip and blade `k` (as stroke() gives them) taken `e` of the way to the parry `to`, the blade a unit again: a new array. */
|
|
75
|
+
export declare const deflect: (k: number[], e: number, to?: number[]) => number[];
|
|
56
76
|
/** The grip and the blade direction (x, y, z each) of cut `cut` at `p` of the swing: one array, rewritten by each call. */
|
|
57
77
|
export declare const stroke: (cut: number, p: number) => number[];
|
|
58
78
|
/** The trunk's [twist, bend, lean] (radians, see TRUNK) of cut `cut` at `p` of its swing: one array, rewritten by each call. */
|
|
@@ -149,6 +149,8 @@ export interface Renderer {
|
|
|
149
149
|
muzzle(id: number): Vec3 | undefined;
|
|
150
150
|
/** The runners of the players `ids` grin for a moment: their team has captured. */
|
|
151
151
|
cheer(ids: number[]): void;
|
|
152
|
+
/** The katana of player `id` struck a ball back, seen `late` s before he is drawn there: his runner parries. */
|
|
153
|
+
parried(id: number, late: number): void;
|
|
152
154
|
/** The xenomorph's vision (the own player is one): a grey-blue world, the enemies in sight glowing. */
|
|
153
155
|
vision(on: boolean): void;
|
|
154
156
|
/** The body of each player (PlayerInfo.body, BODY), from the roster: the man's for one not in it; and the skin and haircut he picked, his id's for one not in `looks`. */
|
|
@@ -17,6 +17,8 @@ export interface Runner {
|
|
|
17
17
|
gait: Gait;
|
|
18
18
|
/** The xenomorph's gait on all fours (fours.ts): none for the others. */
|
|
19
19
|
fours?: Fours;
|
|
20
|
+
/** Posed to threaten, the xenomorph of the menu's picture (menace()). */
|
|
21
|
+
menace?: boolean;
|
|
20
22
|
/** How much of a dash it is in, eased from 0 to 1: the length of the streaks. */
|
|
21
23
|
dash: number;
|
|
22
24
|
/** Seconds since its last shot, and how far its gun arm is raised to aim, eased from 0 to 1. */
|
|
@@ -26,6 +28,8 @@ export interface Runner {
|
|
|
26
28
|
focus: Vec3;
|
|
27
29
|
/** How far through its katana cut it is, -1 when it is not cutting, the light the blade leaves and the clock of its crackle. */
|
|
28
30
|
prog: number;
|
|
31
|
+
/** Seconds since his katana struck a ball back (DEFLECT, katana.ts), from below 0 when it is yet to be drawn. */
|
|
32
|
+
parry: number;
|
|
29
33
|
trail: Trail;
|
|
30
34
|
t: number;
|
|
31
35
|
/** The limb a katana's cut took off, while he is down (see limbs.ts). */
|
|
@@ -118,7 +122,7 @@ export declare const lowered: (r: Runner) => number;
|
|
|
118
122
|
* seen from the runner's eye (the share `e` of it, so that it is drawn from the guard and back to
|
|
119
123
|
* it), and the trunk twisting, bending and leaning through it (trunk()).
|
|
120
124
|
*/
|
|
121
|
-
export declare const brandish: (from: Pose, p: PlayerState, prog: number, ph: number, t?: number) => Pose;
|
|
125
|
+
export declare const brandish: (from: Pose, p: PlayerState, prog: number, ph: number, t?: number, parry?: number) => Pose;
|
|
122
126
|
/**
|
|
123
127
|
* How closed the hands of `p` are, left then right (hand() in body.ts: 0 flat, 0.9 round a grip, 1
|
|
124
128
|
* a fist), as the own body closes its own: round what they hold and on the wheel, fists with
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { CUTS } from './constants';
|
|
2
|
-
import type { PlayerState } from './types';
|
|
2
|
+
import type { Ball, PlayerState } from './types';
|
|
3
3
|
import type { World } from './world';
|
|
4
4
|
/** Where on the body the blade is, as a share of its height: the chest, which a brush must not cover. */
|
|
5
5
|
export declare const CHEST = 0.7;
|
|
6
|
+
/**
|
|
7
|
+
* Whether `p` can meet the ball `b` that reached him with the katana: in hand and idle (not in a
|
|
8
|
+
* cut, a punch or charging one: the user, 2026-11-16), on his feet (not hanging, climbing, seated or
|
|
9
|
+
* stumbling), a ball (not a grenade or an arc) coming at him within PARRY_ARC radians of his facing.
|
|
10
|
+
* Whether he does is his kit's chance (Kit.parry, room.ts).
|
|
11
|
+
*/
|
|
12
|
+
export declare const fends: (p: PlayerState, b: Ball) => boolean;
|
|
13
|
+
/** A number in [0, 1) from integers, the same for the same ones: the host's dice, which tests can replay. */
|
|
14
|
+
export declare const roll: (...n: number[]) => number;
|
|
6
15
|
/**
|
|
7
16
|
* The cut the keys held when FIRE starts a swing give: LEFT or RIGHT, one of them, cuts across from
|
|
8
17
|
* that side; else FORWARD thrusts; else (back or no key) it slashes. Both sides held are neither.
|
|
@@ -391,6 +391,13 @@ export declare const NECK: number, HIPS: number, MIDLINE: number;
|
|
|
391
391
|
*/
|
|
392
392
|
export declare const SHOCK_TICKS = 24;
|
|
393
393
|
export declare const SHOCK_KNOCK = 4;
|
|
394
|
+
/**
|
|
395
|
+
* The ninja's parry (the user, 2026-11-16): with the katana in hand, a ball (not a grenade or an arc)
|
|
396
|
+
* that comes at him within PARRY_ARC radians of his facing is struck back PARRY of the time (Kit.parry),
|
|
397
|
+
* along his look.
|
|
398
|
+
*/
|
|
399
|
+
export declare const PARRY = 0.7;
|
|
400
|
+
export declare const PARRY_ARC = 1.2;
|
|
394
401
|
/**
|
|
395
402
|
* The saber lock (the user, 2026-11-07, after Jedi Outcast): two foes whose cuts strike within
|
|
396
403
|
* LOCK_WINDOW ticks (0.15 s) of each other, each in the other's reach and facing him (within
|
|
@@ -33,6 +33,8 @@ export interface Kit {
|
|
|
33
33
|
slow: number;
|
|
34
34
|
/** The ground's accelerations (ACCEL, SPRINT_ACCEL), as a share of the marine's. */
|
|
35
35
|
accel: number;
|
|
36
|
+
/** The chance his katana in hand strikes back a ball that comes at him from in front (room.ts). */
|
|
37
|
+
parry: number;
|
|
36
38
|
/** Health at a spawn, and what the packs heal up to. */
|
|
37
39
|
hp: number;
|
|
38
40
|
/** Whether the racks give him their weapons and he wears the armour pickups. */
|
|
@@ -54,4 +56,12 @@ export declare const DASH_GAP = 16;
|
|
|
54
56
|
export declare const rolesOf: (def: Pick<WorldDef, "helmets">) => number[];
|
|
55
57
|
/** The class a player plays on the map: his `role` when the map offers it, else the map's default. */
|
|
56
58
|
export declare const roleOf: (role: number | undefined, def: Pick<WorldDef, "helmets">) => number;
|
|
59
|
+
/**
|
|
60
|
+
* The build (BODY) a player is drawn with: the one picked, but the xenomorph's skin is cut on the
|
|
61
|
+
* man's skeleton (the user, 2026-11-16: no gender for it). The choice is kept for another class.
|
|
62
|
+
*/
|
|
63
|
+
export declare const buildOf: (p: {
|
|
64
|
+
role?: number;
|
|
65
|
+
body?: number;
|
|
66
|
+
}, def: Pick<WorldDef, "helmets">) => number;
|
|
57
67
|
export declare const kitOf: (role: number | undefined, def: Pick<WorldDef, "helmets">) => Kit;
|
|
@@ -10,6 +10,8 @@ export declare const PLASMA_LAG = 12;
|
|
|
10
10
|
export interface Flying extends Ball {
|
|
11
11
|
team: number;
|
|
12
12
|
left: number;
|
|
13
|
+
/** A ninja's katana sent it back: it hurts as the shot that came, not as his guns. */
|
|
14
|
+
back?: boolean;
|
|
13
15
|
}
|
|
14
16
|
/** How far shot `n` of the laser rifle drifts off the look, yaw and pitch: a pattern within RIFLE_DRIFT, the same for the host and every client. */
|
|
15
17
|
export declare const drift: (n: number) => [number, number];
|
|
@@ -124,7 +124,7 @@ export declare class Room {
|
|
|
124
124
|
/**
|
|
125
125
|
* `hp` of a gun's damage to `foe` from `by`: as his class deals it (Kit.damage, a ninja's half), the
|
|
126
126
|
* half points kept on `foe` toward the next, the hit going (dx, dz). True when he went down; `how`
|
|
127
|
-
* is the FRAG then.
|
|
127
|
+
* is the FRAG then. A ball sent back (`back`) hurts in full whoever sent it.
|
|
128
128
|
*/
|
|
129
129
|
private shot;
|
|
130
130
|
/**
|
|
@@ -150,6 +150,12 @@ export declare class Room {
|
|
|
150
150
|
* (ram()) hurts the hull, not the crew behind it.
|
|
151
151
|
*/
|
|
152
152
|
private fly;
|
|
153
|
+
/**
|
|
154
|
+
* The katana of `p` met the ball `b`: it ends on the blade (its burst, no hit), and one as strong
|
|
155
|
+
* leaves his eye along his look, his own and his team's, its range full again. Its id runs on from
|
|
156
|
+
* his `shots` by 64 plus his parries: the sum only grows, so it names no ball of his still in flight.
|
|
157
|
+
*/
|
|
158
|
+
private deflect;
|
|
153
159
|
/**
|
|
154
160
|
* A cut of `p` struck at the view tick `view`: every enemy it reaches as `p` drew him is hit
|
|
155
161
|
* (`strike`), and the `hits` count goes up once. Each takes the cut's hp; one it does not put
|
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.172.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|