@korial29/tiny-fps 0.196.1 → 0.196.2
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 +40 -38
- package/dist/local.js +1 -1
- package/dist/server.js +65 -54
- package/dist/types/client/combat.d.ts +1 -1
- package/dist/types/client/gun.d.ts +3 -1
- package/dist/types/client/hud.d.ts +1 -1
- package/dist/types/client/input.d.ts +4 -5
- package/dist/types/client/render.d.ts +1 -1
- package/dist/types/client/xeno.d.ts +4 -3
- package/dist/types/shared/blade.d.ts +2 -2
- package/dist/types/shared/constants.d.ts +1 -3
- package/dist/types/shared/kit.d.ts +2 -0
- package/dist/types/shared/physics.d.ts +3 -2
- package/dist/types/shared/types.d.ts +4 -0
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -108,7 +108,7 @@ var PUNCHES = [
|
|
|
108
108
|
* the top of its wind-up (`hold`) it charges as a cut does (HEAVY, swingOf()), and the strike takes
|
|
109
109
|
* more the longer it charged (TAIL_HP, sting()). A double click of the right button (KEY.SPECIAL
|
|
110
110
|
* with it) is its special: a sweep's is the SPIN, the tail whipped all round the body; the stab's
|
|
111
|
-
* and the lash's the LEAP, up TAIL_LEAP m/s and down on the foe
|
|
111
|
+
* and the lash's the LEAP, up TAIL_LEAP m/s once released and down on the foe; each takes its own
|
|
112
112
|
* `hp`. The xenomorph's `cut` reads this table: CLAW_L and CLAW_R are its claws, at their place in it.
|
|
113
113
|
*/
|
|
114
114
|
/**
|
|
@@ -170,7 +170,7 @@ var TAILS = [
|
|
|
170
170
|
reach: 2.6,
|
|
171
171
|
arc: Math.PI,
|
|
172
172
|
hp: 3,
|
|
173
|
-
hold:
|
|
173
|
+
hold: 18,
|
|
174
174
|
knock: 0
|
|
175
175
|
},
|
|
176
176
|
{
|
|
@@ -179,7 +179,7 @@ var TAILS = [
|
|
|
179
179
|
reach: 2.8,
|
|
180
180
|
arc: .6,
|
|
181
181
|
hp: 5,
|
|
182
|
-
hold:
|
|
182
|
+
hold: 32,
|
|
183
183
|
knock: 0
|
|
184
184
|
}
|
|
185
185
|
];
|
|
@@ -610,7 +610,9 @@ var KEY = {
|
|
|
610
610
|
/** Set while the player wants the laser rifle in hand (4 or the wheel), with BLADE and RAIL clear. Ignored without it. */
|
|
611
611
|
RIFLE: 8192,
|
|
612
612
|
/** Press to get into the rover at hand, or out of the one he rides. */
|
|
613
|
-
USE: 16384
|
|
613
|
+
USE: 16384,
|
|
614
|
+
/** Select bare hands even while carrying a weapon. */
|
|
615
|
+
FISTS: 32768
|
|
614
616
|
};
|
|
615
617
|
/**
|
|
616
618
|
* The katana's cuts (PlayerState.cut, constants CUTS), chosen by the keys held when FIRE starts
|
|
@@ -787,6 +789,7 @@ var KITS = [
|
|
|
787
789
|
slow: .55,
|
|
788
790
|
accel: 1,
|
|
789
791
|
parry: PARRY,
|
|
792
|
+
katana: true,
|
|
790
793
|
hp: 8,
|
|
791
794
|
gear: true,
|
|
792
795
|
xeno: false
|
|
@@ -1018,6 +1021,7 @@ var STILL = {
|
|
|
1018
1021
|
hits: 0,
|
|
1019
1022
|
blade: false,
|
|
1020
1023
|
wield: false,
|
|
1024
|
+
fists: false,
|
|
1021
1025
|
swing: 0,
|
|
1022
1026
|
cut: 0,
|
|
1023
1027
|
zap: false,
|
|
@@ -1039,7 +1043,7 @@ var STILL = {
|
|
|
1039
1043
|
fall: 0
|
|
1040
1044
|
};
|
|
1041
1045
|
/** A player standing on spawn point n of a team (modulo the count): the red team's by default. */
|
|
1042
|
-
var spawn = (id, w, n, team = 0) => {
|
|
1046
|
+
var spawn = (id, w, n, team = 0, kit = KITS[0]) => {
|
|
1043
1047
|
const { spawns } = w.def.teams[team];
|
|
1044
1048
|
const [x, y, z, yaw] = spawns[(n % spawns.length + spawns.length) % spawns.length];
|
|
1045
1049
|
return {
|
|
@@ -1051,16 +1055,19 @@ var spawn = (id, w, n, team = 0) => {
|
|
|
1051
1055
|
yaw: norm(yaw),
|
|
1052
1056
|
pitch: 0,
|
|
1053
1057
|
ground: true,
|
|
1054
|
-
...STILL
|
|
1058
|
+
...STILL,
|
|
1059
|
+
hp: kit.hp,
|
|
1060
|
+
blade: !!kit.katana,
|
|
1061
|
+
wield: !!kit.katana
|
|
1055
1062
|
};
|
|
1056
1063
|
};
|
|
1057
1064
|
/**
|
|
1058
1065
|
* Puts the player back at the spawn of his id in his team, looking where he looked, with full
|
|
1059
1066
|
* health and no gun (EV.RESPAWN). The shot and hit counters go on: a reset would read as a shot.
|
|
1060
1067
|
*/
|
|
1061
|
-
var respawn = (p, w, team) => {
|
|
1068
|
+
var respawn = (p, w, team, kit = KITS[0]) => {
|
|
1062
1069
|
const { yaw, pitch, id, shots, hits } = p;
|
|
1063
|
-
Object.assign(p, spawn(id, w, id, team), {
|
|
1070
|
+
Object.assign(p, spawn(id, w, id, team, kit), {
|
|
1064
1071
|
yaw,
|
|
1065
1072
|
pitch,
|
|
1066
1073
|
shots,
|
|
@@ -1863,7 +1870,7 @@ var move = (p, i, w, team = 0, bodies = [], kit = KITS[0]) => {
|
|
|
1863
1870
|
fz,
|
|
1864
1871
|
bodies,
|
|
1865
1872
|
kit,
|
|
1866
|
-
pace: !p.wield && (p.ammo >= 0 || (p.rail ?? -1) >= 0 || (p.rifle ?? -1) >= 0) ? kit.slow : 1
|
|
1873
|
+
pace: !p.fists && !p.wield && (p.ammo >= 0 || (p.rail ?? -1) >= 0 || (p.rifle ?? -1) >= 0) ? kit.slow : 1
|
|
1867
1874
|
};
|
|
1868
1875
|
const before = p.mode;
|
|
1869
1876
|
p.ev = 0;
|
|
@@ -1882,7 +1889,7 @@ var move = (p, i, w, team = 0, bodies = [], kit = KITS[0]) => {
|
|
|
1882
1889
|
p.slow--;
|
|
1883
1890
|
cap(p, 3);
|
|
1884
1891
|
}
|
|
1885
|
-
if (p.y < w.def.floor) respawn(p, w, team);
|
|
1892
|
+
if (p.y < w.def.floor) respawn(p, w, team, kit);
|
|
1886
1893
|
p.t = p.mode === before ? Math.min(255, p.t + 1) : p.t;
|
|
1887
1894
|
p.buffer = Math.max(0, p.buffer - 1);
|
|
1888
1895
|
if (p.mode === MODE.AIR && before === MODE.AIR) p.coyote = Math.max(0, p.coyote - 1);
|
|
@@ -1944,15 +1951,15 @@ var swingOf = (p, table = CUTS) => {
|
|
|
1944
1951
|
} : c;
|
|
1945
1952
|
};
|
|
1946
1953
|
/**
|
|
1947
|
-
* The health a xenomorph's swing `p` takes:
|
|
1948
|
-
*
|
|
1954
|
+
* The health a xenomorph's swing `p` takes: its base damage on a tap, and for a tail strike
|
|
1955
|
+
* up to TAIL_HP[1] on a full charge (`charge`
|
|
1949
1956
|
* stays through the release, gun.ts).
|
|
1950
1957
|
*/
|
|
1951
1958
|
var sting = (p) => {
|
|
1952
1959
|
const c = TAILS[p.cut ?? 0];
|
|
1953
1960
|
if (c.hold < 0) return c.hp;
|
|
1954
1961
|
const k = p.heavy ? Math.min(p.charge ?? 0, HEAVY_MAX) / HEAVY_MAX : 0;
|
|
1955
|
-
return
|
|
1962
|
+
return c.hp + Math.round((TAIL_HP[1] - c.hp) * k);
|
|
1956
1963
|
};
|
|
1957
1964
|
/**
|
|
1958
1965
|
* The enemies the cut of `p` (`p.cut`, `p` the state after the step that struck) hits, of `foes`
|
|
@@ -6771,10 +6778,7 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
|
|
|
6771
6778
|
p.zapping = false;
|
|
6772
6779
|
p.zap = !!p.stun && !!p.zap;
|
|
6773
6780
|
if (down) {
|
|
6774
|
-
if (p.down > 0 && !--p.down)
|
|
6775
|
-
respawn(p, w, team);
|
|
6776
|
-
p.hp = kit.hp;
|
|
6777
|
-
}
|
|
6781
|
+
if (p.down > 0 && !--p.down) respawn(p, w, team, kit);
|
|
6778
6782
|
return STRIKE.NONE;
|
|
6779
6783
|
}
|
|
6780
6784
|
if (locked) return duel(p, i);
|
|
@@ -6792,7 +6796,7 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
|
|
|
6792
6796
|
];
|
|
6793
6797
|
if (armed && gear && inside && !p.rack) [p.ammo, p.mag] = [kit.ammo, kit.mag];
|
|
6794
6798
|
p.rack = inside;
|
|
6795
|
-
p.blade = !!p.blade || armed && gear && !!blade && within(p, blade, 1.2);
|
|
6799
|
+
p.blade = !!kit.katana || !!p.blade || armed && gear && !!blade && within(p, blade, 1.2);
|
|
6796
6800
|
const inRail = !!rail && within(p, rail, 1.2);
|
|
6797
6801
|
if (armed && gear && inRail && !p.inRail) [p.rail, p.cap] = [kit.rail, kit.cap];
|
|
6798
6802
|
p.inRail = inRail;
|
|
@@ -6816,9 +6820,12 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
|
|
|
6816
6820
|
const busy = p.mode === MODE.HANG || p.mode === MODE.CLIMB;
|
|
6817
6821
|
const table = kit.xeno ? TAILS : CUTS;
|
|
6818
6822
|
const { ticks, hold } = table[p.cut ?? 0];
|
|
6819
|
-
const top = !!p.swing && !p.heavy && ticks -
|
|
6820
|
-
|
|
6821
|
-
|
|
6823
|
+
const top = !!p.swing && !p.heavy && ticks - p.swing === hold;
|
|
6824
|
+
const free = armed && !busy;
|
|
6825
|
+
const holding = !!(i.keys & (kit.xeno ? KEY.BLADE : KEY.FIRE));
|
|
6826
|
+
if (kit.xeno && top && !free) [p.swing, p.charge] = [0, 0];
|
|
6827
|
+
else if (top && free && holding && (p.wield || kit.xeno)) p.charge = Math.min((p.charge ?? 0) + 1, HEAVY_MAX);
|
|
6828
|
+
else if (top && free && (p.charge ?? 0) >= HEAVY_TAP) {
|
|
6822
6829
|
[p.heavy, p.charge] = [true, kit.xeno ? p.charge : 0];
|
|
6823
6830
|
p.swing = swingOf(p, table).ticks;
|
|
6824
6831
|
} else {
|
|
@@ -6831,6 +6838,10 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
|
|
|
6831
6838
|
p.heavy = !!p.swing && !!p.heavy;
|
|
6832
6839
|
p.charge = kit.xeno && !p.heavy ? 0 : p.charge;
|
|
6833
6840
|
}
|
|
6841
|
+
if (kit.xeno && top && free && !holding && p.cut === STING.LEAP && p.mode === MODE.GROUND) {
|
|
6842
|
+
p.vy = 10;
|
|
6843
|
+
p.ev |= EV.JUMP;
|
|
6844
|
+
}
|
|
6834
6845
|
p.mag = Math.min(p.mag ?? 0, Math.max(p.ammo, 0));
|
|
6835
6846
|
const has = [
|
|
6836
6847
|
p.ammo >= 0,
|
|
@@ -6839,14 +6850,16 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
|
|
|
6839
6850
|
(p.rifle ?? -1) >= 0
|
|
6840
6851
|
];
|
|
6841
6852
|
const want = i.keys & KEY.BLADE ? 1 : i.keys & KEY.RAIL ? 2 : i.keys & KEY.RIFLE ? 3 : 0;
|
|
6842
|
-
const
|
|
6843
|
-
|
|
6844
|
-
|
|
6853
|
+
const fists = gear && !!(i.keys & KEY.FISTS) && !(p.swing && p.wield);
|
|
6854
|
+
const hand = p.swing && p.wield ? 1 : fists ? -1 : has[want] ? want : has.indexOf(true);
|
|
6855
|
+
if (hand != (p.fists ? -1 : p.rifled ? 3 : p.railed ? 2 : +!!p.wield)) p.reload = 0;
|
|
6856
|
+
if (p.swing && hand >= 0 && !p.wield) p.swing = 0;
|
|
6857
|
+
[p.wield, p.railed, p.rifled, p.fists] = [
|
|
6845
6858
|
hand == 1,
|
|
6846
6859
|
hand == 2,
|
|
6847
|
-
hand == 3
|
|
6860
|
+
hand == 3,
|
|
6861
|
+
fists
|
|
6848
6862
|
];
|
|
6849
|
-
if (p.swing && hand >= 0 && !p.blade) p.swing = 0;
|
|
6850
6863
|
if (!armed) {
|
|
6851
6864
|
[p.charge, p.reload] = [kit.xeno ? p.charge : 0, 0];
|
|
6852
6865
|
return STRIKE.NONE;
|
|
@@ -6870,7 +6883,7 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
|
|
|
6870
6883
|
const [load, full] = [p[key] ?? 0, Math.min(size, carried)];
|
|
6871
6884
|
if (p.reload) {
|
|
6872
6885
|
if (!--p.reload) p[key] = full;
|
|
6873
|
-
} else if (hand
|
|
6886
|
+
} else if (hand >= 0 && hand != 1 && !busy && load < full && (!load || i.keys & KEY.RELOAD)) [p.reload, p.charge] = [ticks2, 0];
|
|
6874
6887
|
const bare = hand < 0;
|
|
6875
6888
|
const c = kit.xeno ? swingOf(p, TAILS) : bare ? PUNCHES[p.cut ?? 0] ?? PUNCHES[0] : swingOf(p);
|
|
6876
6889
|
if (p.swing && c.ticks - p.swing === c.strike) return STRIKE.CUT;
|
|
@@ -6878,7 +6891,7 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
|
|
|
6878
6891
|
beast(p, i, fresh, busy);
|
|
6879
6892
|
return STRIKE.NONE;
|
|
6880
6893
|
}
|
|
6881
|
-
if (p.wield && !top || p.railed || p.rifled || busy || p.reload || !p.wield && !p.mag) p.charge = 0;
|
|
6894
|
+
if (bare || p.wield && !top || p.railed || p.rifled || busy || p.reload || !p.wield && !p.mag) p.charge = 0;
|
|
6882
6895
|
if (p.rifled && i.keys & KEY.SPECIAL && !busy && p.nades && !p.lob) {
|
|
6883
6896
|
p.nades--;
|
|
6884
6897
|
[p.lob, p.cool] = [60, 7];
|
|
@@ -6940,16 +6953,16 @@ var step = (p, i, w, team, armed = true, bodies = [], kit = KITS[0]) => {
|
|
|
6940
6953
|
* The xenomorph's blows: FIRE swipes the left claws, then the right while it goes on, a fresh press
|
|
6941
6954
|
* after a swipe's strike throwing the next at once (BLOW). The right button (KEY.BLADE) strikes with
|
|
6942
6955
|
* the tail as FIRE cuts with the katana (TAILS): by the keys (cutOf()), its special with SPECIAL (a
|
|
6943
|
-
* double click), which
|
|
6944
|
-
*
|
|
6956
|
+
* double click), which can replace the first tap before it strikes. All tail attacks pause
|
|
6957
|
+
* at their wind-up while the button is held. On a wall the hands are free.
|
|
6945
6958
|
*/
|
|
6946
6959
|
var beast = (p, i, fresh, busy) => {
|
|
6947
6960
|
if (busy) return;
|
|
6948
6961
|
const c = TAILS[p.cut ?? 0];
|
|
6949
6962
|
const claw = p.cut === BLOW.CLAW_L || p.cut === BLOW.CLAW_R;
|
|
6950
6963
|
const tail = !!(i.keys & KEY.BLADE);
|
|
6951
|
-
const
|
|
6952
|
-
const special = tail && !!(i.keys & KEY.SPECIAL) && !!p.swing && !claw && !p.heavy && (p.cut ?? 0) < 4 &&
|
|
6964
|
+
const elapsed = c.ticks - (p.swing ?? 0);
|
|
6965
|
+
const special = tail && !!(i.keys & KEY.SPECIAL) && !!p.swing && !claw && !p.heavy && (p.cut ?? 0) < 4 && elapsed < c.strike;
|
|
6953
6966
|
if (tail && (!p.swing && !p.charge || special)) {
|
|
6954
6967
|
const base = cutOf(i.keys);
|
|
6955
6968
|
p.cut = i.keys & KEY.SPECIAL ? base === CUT.LEFT || base === CUT.RIGHT ? STING.SPIN : STING.LEAP : base;
|
|
@@ -6958,10 +6971,6 @@ var beast = (p, i, fresh, busy) => {
|
|
|
6958
6971
|
TAILS[p.cut].ticks,
|
|
6959
6972
|
0
|
|
6960
6973
|
];
|
|
6961
|
-
if (p.cut === STING.LEAP && p.mode === MODE.GROUND) {
|
|
6962
|
-
p.vy = 10;
|
|
6963
|
-
p.ev |= EV.JUMP;
|
|
6964
|
-
}
|
|
6965
6974
|
} else if (i.keys & KEY.FIRE && (!p.swing || fresh && claw && c.ticks - p.swing > c.strike)) {
|
|
6966
6975
|
p.cut = p.cut === BLOW.CLAW_L ? BLOW.CLAW_R : BLOW.CLAW_L;
|
|
6967
6976
|
[p.heavy, p.swing] = [false, TAILS[p.cut].ticks];
|
|
@@ -7809,7 +7818,7 @@ var Sortie = class {
|
|
|
7809
7818
|
}
|
|
7810
7819
|
};
|
|
7811
7820
|
// src/shared/bot.ts
|
|
7812
|
-
var { FORWARD, BACK, LEFT, RIGHT, JUMP, SPRINT, DASH, CROUCH, FIRE, RELOAD } = KEY;
|
|
7821
|
+
var { FORWARD, BACK, LEFT, RIGHT, JUMP, SPRINT, DASH, CROUCH, FIRE, RELOAD, BLADE, SPECIAL } = KEY;
|
|
7813
7822
|
/** How far a bot shoots, metres, and how far it sees an enemy to fight. */
|
|
7814
7823
|
var RANGE = 35;
|
|
7815
7824
|
/** Radians off the target a bot still shoots. */
|
|
@@ -8096,6 +8105,7 @@ var Bot = class {
|
|
|
8096
8105
|
/** The input of this tick. */
|
|
8097
8106
|
think(s) {
|
|
8098
8107
|
const i = this.decide(s);
|
|
8108
|
+
if (s.kit?.katana && s.me.state.blade && !s.me.state.down) i.keys |= BLADE;
|
|
8099
8109
|
this.keys = i.keys;
|
|
8100
8110
|
return i;
|
|
8101
8111
|
}
|
|
@@ -8290,7 +8300,7 @@ var Bot = class {
|
|
|
8290
8300
|
return this.sortie.board;
|
|
8291
8301
|
}
|
|
8292
8302
|
const gear = s.kit?.gear ?? true;
|
|
8293
|
-
if (p.ammo < 0 && gear && home.rack && flat(p.x, p.z, home.rack[0], home.rack[2]) < ARM) {
|
|
8303
|
+
if (p.ammo < 0 && gear && !s.kit?.katana && home.rack && flat(p.x, p.z, home.rack[0], home.rack[2]) < ARM) {
|
|
8294
8304
|
this.why = "gun rack";
|
|
8295
8305
|
return home.rack;
|
|
8296
8306
|
}
|
|
@@ -8299,7 +8309,7 @@ var Bot = class {
|
|
|
8299
8309
|
p.y + eyeHeight(p),
|
|
8300
8310
|
p.z
|
|
8301
8311
|
];
|
|
8302
|
-
const prey = gear ? void 0 : others.find((o) => o.team !== team && !o.state.down && Math.abs(o.state.y - p.y) < HUNT_Y && flat(p.x, p.z, o.state.x, o.state.z) < HUNT && !hidden(world, eye, [
|
|
8312
|
+
const prey = gear && !s.kit?.katana ? void 0 : others.find((o) => o.team !== team && !o.state.down && Math.abs(o.state.y - p.y) < HUNT_Y && flat(p.x, p.z, o.state.x, o.state.z) < HUNT && !hidden(world, eye, [
|
|
8303
8313
|
o.state.x,
|
|
8304
8314
|
o.state.y + 1.2,
|
|
8305
8315
|
o.state.z
|
|
@@ -8692,6 +8702,7 @@ var Bot = class {
|
|
|
8692
8702
|
}
|
|
8693
8703
|
this.met.set(foe.id, this.ticks);
|
|
8694
8704
|
const d = flat(p.x, p.z, q.x, q.z);
|
|
8705
|
+
const blade = !!s.kit?.katana && !!p.blade;
|
|
8695
8706
|
const v = this.speed;
|
|
8696
8707
|
const k = this.persona.track;
|
|
8697
8708
|
[v[0], v[1], v[2]] = [
|
|
@@ -8699,7 +8710,7 @@ var Bot = class {
|
|
|
8699
8710
|
v[1] + (q.vy - v[1]) * k,
|
|
8700
8711
|
v[2] + (q.vz - v[2]) * k
|
|
8701
8712
|
];
|
|
8702
|
-
const lead = this.persona.lead * d / (p.rifled ? 400 : 80);
|
|
8713
|
+
const lead = blade ? 0 : this.persona.lead * d / (p.rifled ? 400 : 80);
|
|
8703
8714
|
const [tx, ty, tz] = [
|
|
8704
8715
|
q.x + v[0] * lead,
|
|
8705
8716
|
q.y + 1.1 + v[1] * lead,
|
|
@@ -8719,6 +8730,10 @@ var Bot = class {
|
|
|
8719
8730
|
this.pitch = Math.atan2(ty - eye[1], Math.max(d, .1)) + this.errUp;
|
|
8720
8731
|
const ready = this.ticks - this.since > this.persona.react && Math.abs(turn(this.aim, want)) < CONE;
|
|
8721
8732
|
if (foe.id === carrier && d < TACKLE && p.ground && !(p.held & DASH)) return { keys: FORWARD | DASH };
|
|
8733
|
+
if (blade) {
|
|
8734
|
+
const inReach = d < CUTS[CUT.SLASH].reach && Math.abs(q.y - p.y) < HUNT_Y;
|
|
8735
|
+
return { keys: ready && inReach && !p.swing ? this.rnd() < .25 ? SPECIAL : FIRE : 0 };
|
|
8736
|
+
}
|
|
8722
8737
|
const armed = p.ammo > 0 && (p.mag ?? 0) > 0 && !p.wield;
|
|
8723
8738
|
const pull = armed && d < RANGE || !armed && d < 1.4;
|
|
8724
8739
|
if (!warning && ready && pull) this.hunting = foe.id;
|
|
@@ -9082,7 +9097,7 @@ var decodeInput = (buf) => {
|
|
|
9082
9097
|
if (v.getUint8(0) !== 1) return null;
|
|
9083
9098
|
return {
|
|
9084
9099
|
seq: v.getUint16(1),
|
|
9085
|
-
keys: v.getUint16(3)
|
|
9100
|
+
keys: v.getUint16(3),
|
|
9086
9101
|
yaw: fromTurn(v.getUint16(5)),
|
|
9087
9102
|
pitch: fromPitch(v.getInt16(7)),
|
|
9088
9103
|
view: (v.getUint16(9) * 256 + v.getUint8(11)) / 256
|
|
@@ -9139,7 +9154,7 @@ var encodeSnapshot = (s) => {
|
|
|
9139
9154
|
v.setUint8(o + 54, p.slow ?? 0);
|
|
9140
9155
|
v.setUint8(o + 55, p.mag ?? 0);
|
|
9141
9156
|
v.setUint8(o + 56, p.cap ?? 0);
|
|
9142
|
-
v.setUint8(o + 57, p.reload ?? 0);
|
|
9157
|
+
v.setUint8(o + 57, (p.reload ?? 0) | +!!p.fists << 7);
|
|
9143
9158
|
v.setUint8(o + 58, (p.rifle ?? -1) + 1);
|
|
9144
9159
|
v.setUint8(o + 59, p.clip ?? 0);
|
|
9145
9160
|
v.setUint8(o + 60, p.heat ?? 0);
|
|
@@ -9840,6 +9855,7 @@ var Room = class {
|
|
|
9840
9855
|
reload: 0,
|
|
9841
9856
|
blade: false,
|
|
9842
9857
|
wield: false,
|
|
9858
|
+
fists: false,
|
|
9843
9859
|
swing: 0,
|
|
9844
9860
|
lost: LIMB.NONE,
|
|
9845
9861
|
fell,
|
|
@@ -9985,7 +10001,7 @@ var Room = class {
|
|
|
9985
10001
|
* `p` drew it) takes the cut's hp, and its crew none of it.
|
|
9986
10002
|
*/
|
|
9987
10003
|
cut(p, view) {
|
|
9988
|
-
if (!p.state.blade) {
|
|
10004
|
+
if (!p.state.wield && (!p.state.blade || p.state.fists)) {
|
|
9989
10005
|
this.punch(p, view);
|
|
9990
10006
|
return;
|
|
9991
10007
|
}
|
|
@@ -10390,8 +10406,7 @@ var Room = class {
|
|
|
10390
10406
|
/** The rover fell under the kill floor: who was aboard is back at a spawn, it is parked again. */
|
|
10391
10407
|
sink(r) {
|
|
10392
10408
|
for (const p of this.players()) if (this.seatOf(p)[0] === r) {
|
|
10393
|
-
respawn(p.state, this.world, p.info.team);
|
|
10394
|
-
p.state.hp = this.kit(p).hp;
|
|
10409
|
+
respawn(p.state, this.world, p.info.team, this.kit(p));
|
|
10395
10410
|
this.ctf.moved(p.state);
|
|
10396
10411
|
}
|
|
10397
10412
|
this.renew(this.rovers.indexOf(r));
|
|
@@ -10568,12 +10583,12 @@ var Room = class {
|
|
|
10568
10583
|
}
|
|
10569
10584
|
}
|
|
10570
10585
|
/** The first spawn point of the team with none of `others` within SPAWN_CLEAR, else the next one round-robin. */
|
|
10571
|
-
place(id, team, others) {
|
|
10586
|
+
place(id, team, others, kit) {
|
|
10572
10587
|
const n = this.world.def.teams[team].spawns.findIndex((_, k) => {
|
|
10573
10588
|
const { x, z } = spawn(id, this.world, k, team);
|
|
10574
10589
|
return !others.some((o) => Math.hypot(o.x - x, o.z - z) < SPAWN_CLEAR);
|
|
10575
10590
|
});
|
|
10576
|
-
return spawn(id, this.world, n < 0 ? this.rr[team]++ : n, team);
|
|
10591
|
+
return spawn(id, this.world, n < 0 ? this.rr[team]++ : n, team, kit);
|
|
10577
10592
|
}
|
|
10578
10593
|
/** The match is over: everyone gets the result and what each player did. */
|
|
10579
10594
|
end(players) {
|
|
@@ -10603,10 +10618,9 @@ var Room = class {
|
|
|
10603
10618
|
for (const p of players) {
|
|
10604
10619
|
const { shots, hits } = p.state;
|
|
10605
10620
|
p.state = {
|
|
10606
|
-
...this.place(p.info.id, p.info.team, put),
|
|
10621
|
+
...this.place(p.info.id, p.info.team, put, this.kit(p)),
|
|
10607
10622
|
shots,
|
|
10608
|
-
hits
|
|
10609
|
-
hp: this.kit(p).hp
|
|
10623
|
+
hits
|
|
10610
10624
|
};
|
|
10611
10625
|
put.push(p.state);
|
|
10612
10626
|
this.ctf.place(p.info.id, p.state);
|
|
@@ -10775,10 +10789,7 @@ var Room = class {
|
|
|
10775
10789
|
...chosen(picked),
|
|
10776
10790
|
...bot ? { bot } : {}
|
|
10777
10791
|
},
|
|
10778
|
-
state:
|
|
10779
|
-
...this.place(id, team, players.map((p) => p.state)),
|
|
10780
|
-
hp: kitOf(chosen(picked).role, this.world.def).hp
|
|
10781
|
-
},
|
|
10792
|
+
state: this.place(id, team, players.map((p) => p.state), kitOf(chosen(picked).role, this.world.def)),
|
|
10782
10793
|
since: this.joins++,
|
|
10783
10794
|
bank: 10,
|
|
10784
10795
|
ack: 65535,
|
|
@@ -36,7 +36,7 @@ export interface Combat {
|
|
|
36
36
|
/** Shots between two states of a player, a u8 counter that wraps. */
|
|
37
37
|
export declare const fired: (a?: PlayerState, b?: PlayerState) => number;
|
|
38
38
|
/** What the katana's sounds read of a player: the swing, the cut and whether it is in hand. */
|
|
39
|
-
type Blade = Pick<PlayerState, 'swing' | 'cut' | 'wield' | 'blade' | 'heavy' | 'down' | 'railed' | 'ammo' | 'reload' | 'rifled' | 'hot' | 'hits'>;
|
|
39
|
+
type Blade = Pick<PlayerState, 'swing' | 'cut' | 'wield' | 'blade' | 'fists' | 'heavy' | 'down' | 'railed' | 'ammo' | 'reload' | 'rifled' | 'hot' | 'hits'>;
|
|
40
40
|
/**
|
|
41
41
|
* The CUT of a swing that started between two states of a player, or -1: `swing` jumped up (it
|
|
42
42
|
* only counts down), or the cut changed under a running one.
|
|
@@ -111,12 +111,14 @@ export declare const GUN_ON: {
|
|
|
111
111
|
*/
|
|
112
112
|
export declare const PRESS = 0.45;
|
|
113
113
|
export declare const pressAt: (kind: number) => number;
|
|
114
|
+
/** The selected weapon slot, or -1 when bare-handed or down. */
|
|
115
|
+
export declare const handOf: (p: Pick<PlayerState, "down" | "fists" | "wield" | "rifled" | "railed" | "ammo">) => number;
|
|
114
116
|
/**
|
|
115
117
|
* A tracker of the weapons each player has had in hand since taking them: true when the weapon in
|
|
116
118
|
* `p`'s hand comes to it for the first time, the only time it is switched on (the user,
|
|
117
119
|
* 2026-11-09). A weapon the player no longer carries (lost going down) is forgotten.
|
|
118
120
|
*/
|
|
119
|
-
export declare const firsts: () => (p: Pick<PlayerState, "id" | "ammo" | "blade" | "rail" | "rifle" | "down" | "wield" | "rifled" | "railed">) => boolean;
|
|
121
|
+
export declare const firsts: () => (p: Pick<PlayerState, "id" | "ammo" | "fists" | "blade" | "rail" | "rifle" | "down" | "wield" | "rifled" | "railed">) => boolean;
|
|
120
122
|
/**
|
|
121
123
|
* The rail gun's capsule `t` after the gun came to hand, the left hand on it at `at`: turned a
|
|
122
124
|
* quarter of a turn to tune it on (the user, 2026-11-09), radians, as the screw turns it.
|
|
@@ -94,7 +94,7 @@ export interface Hud {
|
|
|
94
94
|
* `nades` left in its launcher as dots after the count, hollow for the ones spent. `armor` shows
|
|
95
95
|
* as gold pips after the health's, only the ones he has.
|
|
96
96
|
*/
|
|
97
|
-
vitals(hp: number, ammo: number, blade?: boolean, wield?: boolean, rail?: number, railed?: boolean, loaded?: number, swapping?: boolean, rifle?: number, rifled?: boolean, nades?: number, armor?: number): void;
|
|
97
|
+
vitals(hp: number, ammo: number, blade?: boolean, wield?: boolean, rail?: number, railed?: boolean, loaded?: number, swapping?: boolean, rifle?: number, rifled?: boolean, nades?: number, armor?: number, fists?: boolean): void;
|
|
98
98
|
/** The health the own player's class has at most (Kit.hp): as many pips. */
|
|
99
99
|
life(max: number): void;
|
|
100
100
|
/** A hit marker on the crosshair for a moment: a ball or a cut of the own player hit. */
|
|
@@ -11,26 +11,25 @@ export declare const keyBit: (code: string) => number;
|
|
|
11
11
|
export declare const DOUBLE_CLICK_MS = 300;
|
|
12
12
|
/** The wheel swaps the weapon at most this often (ms): a trackpad's flick is a hundred events, one swap. */
|
|
13
13
|
export declare const WHEEL_MS = 250;
|
|
14
|
-
/** The weapon chosen: 1
|
|
14
|
+
/** The weapon chosen: 1 through 5 on the keyboard. */
|
|
15
15
|
export declare const WEAPON: {
|
|
16
16
|
readonly GUN: 0;
|
|
17
17
|
readonly BLADE: 1;
|
|
18
18
|
readonly RAIL: 2;
|
|
19
19
|
readonly RIFLE: 3;
|
|
20
|
+
readonly FISTS: 4;
|
|
20
21
|
};
|
|
21
22
|
/** The choice after a key: 1 the gun, 2 the katana, 3 the rail gun, 4 the laser rifle, any other key keeps it. */
|
|
22
23
|
export declare const picked: (weapon: number, code: string) => number;
|
|
23
24
|
/** Which of the gun, the katana, the rail gun and the laser rifle a player has; all of them when there is no state yet. */
|
|
24
25
|
export declare const owned: (p?: PlayerState) => boolean[];
|
|
25
26
|
/**
|
|
26
|
-
*
|
|
27
|
-
* it, once; losing every weapon (going down) goes back to the gun; anything else, the gun picked
|
|
28
|
-
* up included, keeps it.
|
|
27
|
+
* Follow the spawn's weapon and switch to newly picked-up special weapons unless fists are selected.
|
|
29
28
|
*/
|
|
30
29
|
export declare const chosen: (weapon: number, was?: PlayerState, now?: PlayerState) => number;
|
|
31
30
|
/** The keys of a step with KEY.BLADE set while the katana is the choice, KEY.RAIL while the rail gun is, KEY.RIFLE while the rifle is. */
|
|
32
31
|
export declare const withWeapon: (keys: number, weapon: number) => number;
|
|
33
|
-
/** The choice the wheel turns to, `dir` 1 or -1: the next weapon he has,
|
|
32
|
+
/** The choice the wheel turns to, `dir` 1 or -1: the next weapon he has, including fists. */
|
|
34
33
|
export declare const turned: (weapon: number, dir: number, have: boolean[]) => number;
|
|
35
34
|
/** Live look angles and held keys; the loop reads them once per step and per frame. */
|
|
36
35
|
export interface Controls {
|
|
@@ -178,7 +178,7 @@ export interface Renderer {
|
|
|
178
178
|
parried(id: number, late: number): void;
|
|
179
179
|
/** The xenomorph's vision (the own player is one): a grey-blue world, the enemies in sight glowing. */
|
|
180
180
|
vision(on: boolean): void;
|
|
181
|
-
/**
|
|
181
|
+
/** Let eligible glory kill targets flash during play. */
|
|
182
182
|
edge(on: boolean): void;
|
|
183
183
|
/** 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`. */
|
|
184
184
|
wear(builds: ReadonlyMap<number, number>, looks?: ReadonlyMap<number, Choice>): void;
|
|
@@ -21,7 +21,7 @@ export declare const TAIL: {
|
|
|
21
21
|
* forward down into the view), its turn about the pelvis' up (radians, to its left: through its
|
|
22
22
|
* right side, a tail pointing back turns forward), its lean to the right, its reach (as a share of
|
|
23
23
|
* its length, a whip stretched), how much of the hook at its tip it keeps, how far its root
|
|
24
|
-
* rises
|
|
24
|
+
* rises, how far it coils in an S, and how strongly its tip follows the aim.
|
|
25
25
|
*/
|
|
26
26
|
export type Lash = readonly [
|
|
27
27
|
sting: number,
|
|
@@ -30,7 +30,8 @@ export type Lash = readonly [
|
|
|
30
30
|
reach: number,
|
|
31
31
|
hook: number,
|
|
32
32
|
rise: number,
|
|
33
|
-
coil?: number
|
|
33
|
+
coil?: number,
|
|
34
|
+
aim?: number
|
|
34
35
|
];
|
|
35
36
|
/** At rest: behind, hooked. */
|
|
36
37
|
export declare const HOOKED: Lash;
|
|
@@ -106,7 +107,7 @@ export declare const backOf: (lod: number) => Back;
|
|
|
106
107
|
* (blade()), glowing in the team's `color`. Written straight into `out`. `lod` 0 far, 1 near, 3 close.
|
|
107
108
|
* `fours` (0 to 1): how far the body is on all fours (fours.ts).
|
|
108
109
|
*/
|
|
109
|
-
export declare const tail: (out: Out, s: Solved, t: number, run: number, lash: Lash, color: number[], lod: number, fours?: number) => void;
|
|
110
|
+
export declare const tail: (out: Out, s: Solved, t: number, run: number, lash: Lash, color: number[], lod: number, fours?: number, look?: Pick<PlayerState, "yaw" | "pitch">) => void;
|
|
110
111
|
/** Bone: its claws and teeth, nothing else. */
|
|
111
112
|
export declare const BONE: number[];
|
|
112
113
|
/** Its claws, hands and feet (the user, 2026-11-17: less white): a dull horn, darker than bone. */
|
|
@@ -31,8 +31,8 @@ export declare const swingOf: (p: Pick<PlayerState, "cut" | "heavy">, table?: ty
|
|
|
31
31
|
hold: number;
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
|
-
* The health a xenomorph's swing `p` takes:
|
|
35
|
-
*
|
|
34
|
+
* The health a xenomorph's swing `p` takes: its base damage on a tap, and for a tail strike
|
|
35
|
+
* up to TAIL_HP[1] on a full charge (`charge`
|
|
36
36
|
* stays through the release, gun.ts).
|
|
37
37
|
*/
|
|
38
38
|
export declare const sting: (p: Pick<PlayerState, "cut" | "heavy" | "charge">) => number;
|
|
@@ -234,7 +234,7 @@ export declare const PUNCHES: {
|
|
|
234
234
|
* the top of its wind-up (`hold`) it charges as a cut does (HEAVY, swingOf()), and the strike takes
|
|
235
235
|
* more the longer it charged (TAIL_HP, sting()). A double click of the right button (KEY.SPECIAL
|
|
236
236
|
* with it) is its special: a sweep's is the SPIN, the tail whipped all round the body; the stab's
|
|
237
|
-
* and the lash's the LEAP, up TAIL_LEAP m/s and down on the foe
|
|
237
|
+
* and the lash's the LEAP, up TAIL_LEAP m/s once released and down on the foe; each takes its own
|
|
238
238
|
* `hp`. The xenomorph's `cut` reads this table: CLAW_L and CLAW_R are its claws, at their place in it.
|
|
239
239
|
*/
|
|
240
240
|
/**
|
|
@@ -419,8 +419,6 @@ export declare const HEAVY_HP: number, HEAVY_REACH: number, HEAVY_ARC: number;
|
|
|
419
419
|
*/
|
|
420
420
|
export declare const ARC_SPEED: number, ARC_RANGE: number, ARC_R: number;
|
|
421
421
|
export declare const FLOOR_TICKS: number, ARC_KNOCK: number;
|
|
422
|
-
/** Ticks into a cut's swing in which a double click's second press still turns it into its special. */
|
|
423
|
-
export declare const SPECIAL_LATE = 18;
|
|
424
422
|
/** The lunge's throw along the look (m/s), held for the burst of a dash: it spends the dash. */
|
|
425
423
|
export declare const LUNGE_SPEED = 13;
|
|
426
424
|
/** The leap's jump (m/s up), from a floor only: 1.4 m up and down in 45 ticks, the blow (LEAP's strike) just before the landing. */
|
|
@@ -41,6 +41,8 @@ export interface Kit {
|
|
|
41
41
|
hp: number;
|
|
42
42
|
/** Whether the racks give him their weapons and he wears the armour pickups. */
|
|
43
43
|
gear: boolean;
|
|
44
|
+
/** Carries a katana from spawn. */
|
|
45
|
+
katana?: boolean;
|
|
44
46
|
/**
|
|
45
47
|
* The xenomorph's body: claws and a tail for weapons (PUNCHES from BLOW.CLAW_L), clinging to the
|
|
46
48
|
* walls (MODE.CLING), a dash's burst that pins an enemy it reaches, acid for blood (room.ts).
|
|
@@ -37,6 +37,7 @@ export declare const STILL: {
|
|
|
37
37
|
hits: number;
|
|
38
38
|
blade: boolean;
|
|
39
39
|
wield: boolean;
|
|
40
|
+
fists: boolean;
|
|
40
41
|
swing: number;
|
|
41
42
|
cut: number;
|
|
42
43
|
zap: boolean;
|
|
@@ -58,12 +59,12 @@ export declare const STILL: {
|
|
|
58
59
|
fall: number;
|
|
59
60
|
};
|
|
60
61
|
/** A player standing on spawn point n of a team (modulo the count): the red team's by default. */
|
|
61
|
-
export declare const spawn: (id: number, w: World, n: number, team?: number) => PlayerState;
|
|
62
|
+
export declare const spawn: (id: number, w: World, n: number, team?: number, kit?: Kit) => PlayerState;
|
|
62
63
|
/**
|
|
63
64
|
* Puts the player back at the spawn of his id in his team, looking where he looked, with full
|
|
64
65
|
* health and no gun (EV.RESPAWN). The shot and hit counters go on: a reset would read as a shot.
|
|
65
66
|
*/
|
|
66
|
-
export declare const respawn: (p: PlayerState, w: World, team: number) => void;
|
|
67
|
+
export declare const respawn: (p: PlayerState, w: World, team: number, kit?: Kit) => void;
|
|
67
68
|
/** The height of the cylinder in this mode. */
|
|
68
69
|
export declare const heightOf: (p: Pick<PlayerState, "mode">) => number;
|
|
69
70
|
/** The camera height above the feet in this mode. */
|
|
@@ -74,6 +74,8 @@ export declare const KEY: {
|
|
|
74
74
|
readonly RIFLE: 8192;
|
|
75
75
|
/** Press to get into the rover at hand, or out of the one he rides. */
|
|
76
76
|
readonly USE: 16384;
|
|
77
|
+
/** Select bare hands even while carrying a weapon. */
|
|
78
|
+
readonly FISTS: 32768;
|
|
77
79
|
};
|
|
78
80
|
/**
|
|
79
81
|
* The katana's cuts (PlayerState.cut, constants CUTS), chosen by the keys held when FIRE starts
|
|
@@ -267,6 +269,8 @@ export interface PlayerState {
|
|
|
267
269
|
blade?: boolean;
|
|
268
270
|
/** The katana is in hand rather than the gun (see KEY.BLADE). Absent reads false. */
|
|
269
271
|
wield?: boolean;
|
|
272
|
+
/** Bare hands selected explicitly; carried weapons remain available. */
|
|
273
|
+
fists?: boolean;
|
|
270
274
|
/** Ticks left in the katana's swing, CUTS[cut].ticks at its start, 0 when ready. Absent reads 0. */
|
|
271
275
|
swing?: number;
|
|
272
276
|
/** CUT of the running or last swing. Absent reads 0. */
|
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.196.
|
|
5
|
+
"version": "0.196.2",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|