@korial29/tiny-fps 0.25.0 → 0.26.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/README.md +1 -1
- package/dist/index.js +13 -13
- package/dist/local.js +1 -1
- package/dist/server.js +1078 -857
- package/dist/types/client/beams.d.ts +19 -0
- package/dist/types/client/body.d.ts +12 -2
- package/dist/types/client/combat.d.ts +28 -0
- package/dist/types/client/effects.d.ts +8 -0
- package/dist/types/client/flag.d.ts +11 -0
- package/dist/types/client/gait.d.ts +8 -2
- package/dist/types/client/gun.d.ts +21 -0
- package/dist/types/client/hud.d.ts +8 -1
- package/dist/types/client/input.d.ts +1 -1
- package/dist/types/client/props.d.ts +7 -0
- package/dist/types/client/render.d.ts +5 -2
- package/dist/types/client/sfx.d.ts +8 -0
- package/dist/types/client/soldier.d.ts +3 -0
- package/dist/types/shared/constants.d.ts +20 -0
- package/dist/types/shared/gun.d.ts +22 -0
- package/dist/types/shared/physics.d.ts +12 -0
- package/dist/types/shared/protocol.d.ts +4 -4
- package/dist/types/shared/room.d.ts +10 -0
- package/dist/types/shared/types.d.ts +17 -0
- package/dist/types/shared/world.d.ts +4 -0
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -3,10 +3,13 @@ import { WebSocketServer } from "ws";
|
|
|
3
3
|
/** Player cylinder. */
|
|
4
4
|
var PLAYER_R = .4;
|
|
5
5
|
var PLAYER_H = 1.8;
|
|
6
|
+
/** Camera height above the feet. */
|
|
7
|
+
var EYE = 1.6;
|
|
6
8
|
/** Pitch is clamped to ±MAX_PITCH radians, just short of straight up or down. */
|
|
7
9
|
var MAX_PITCH = 1.55;
|
|
8
10
|
/** Height of the cylinder when sliding or crouching, and the eye in it. */
|
|
9
11
|
var LOW_H = .9;
|
|
12
|
+
var LOW_EYE = .7;
|
|
10
13
|
/** Speed from which a crouch is a slide (above RUN_SPEED: only a sprint slides). */
|
|
11
14
|
var SLIDE_MIN_SPEED = 7.5;
|
|
12
15
|
/** Speed lost along the wall, m/s². */
|
|
@@ -51,7 +54,9 @@ var KEY = {
|
|
|
51
54
|
/** Press to dash. */
|
|
52
55
|
DASH: 64,
|
|
53
56
|
/** Hold to crouch, or to slide when fast. */
|
|
54
|
-
CROUCH: 128
|
|
57
|
+
CROUCH: 128,
|
|
58
|
+
/** Hold to fire the gun: one shot every GUN_COOLDOWN ticks while there is ammo. */
|
|
59
|
+
FIRE: 256
|
|
55
60
|
};
|
|
56
61
|
/** The movement state of a player: what the body is doing, one of these. */
|
|
57
62
|
var MODE = {
|
|
@@ -436,795 +441,20 @@ var Ctf = class {
|
|
|
436
441
|
};
|
|
437
442
|
/** Whether the player's body reaches the flag foot at `at`: close enough, and overlapping its height. */
|
|
438
443
|
var touches = (p, at) => Math.hypot(p.x - at[0], p.z - at[2]) < 1.5 && p.y < at[1] + 2.2 && p.y + 1.8 > at[1];
|
|
439
|
-
// src/shared/
|
|
440
|
-
|
|
441
|
-
var
|
|
442
|
-
/**
|
|
443
|
-
var
|
|
444
|
-
min: [
|
|
445
|
-
x0,
|
|
446
|
-
BASE,
|
|
447
|
-
z0
|
|
448
|
-
],
|
|
449
|
-
max: [
|
|
450
|
-
x1,
|
|
451
|
-
top,
|
|
452
|
-
z1
|
|
453
|
-
],
|
|
454
|
-
top: TEX.CONCRETE,
|
|
455
|
-
side
|
|
456
|
-
});
|
|
457
|
-
/** Any box, corners (x0, y0, z0) and (x1, y1, z1). */
|
|
458
|
-
var box = ([x0, y0, z0], [x1, y1, z1], top, side = top, tint) => ({
|
|
459
|
-
min: [
|
|
460
|
-
x0,
|
|
461
|
-
y0,
|
|
462
|
-
z0
|
|
463
|
-
],
|
|
464
|
-
max: [
|
|
465
|
-
x1,
|
|
466
|
-
y1,
|
|
467
|
-
z1
|
|
468
|
-
],
|
|
469
|
-
top,
|
|
470
|
-
side,
|
|
471
|
-
tint
|
|
472
|
-
});
|
|
473
|
-
/** Six steps of 0.4 m, 1 m deep and 2 m wide (x 12 to 14) from z down to z - 6, on a roof at y. */
|
|
474
|
-
var stair = (z, y) => [
|
|
475
|
-
1,
|
|
476
|
-
2,
|
|
477
|
-
3,
|
|
478
|
-
4,
|
|
479
|
-
5,
|
|
480
|
-
6
|
|
481
|
-
].map((k) => box([
|
|
482
|
-
12,
|
|
483
|
-
y,
|
|
484
|
-
z - k
|
|
485
|
-
], [
|
|
486
|
-
14,
|
|
487
|
-
y + .4 * k,
|
|
488
|
-
z - k + 1
|
|
489
|
-
], TEX.CONCRETE));
|
|
490
|
-
[
|
|
491
|
-
roof(4, 57.7, 24, 76, 10),
|
|
492
|
-
roof(4, 36, 24, 53.5, 10, TEX.GLASS),
|
|
493
|
-
roof(4, 20, 24, 36, 12.4),
|
|
494
|
-
roof(4, -5, 24, 7, 12.4, TEX.GLASS),
|
|
495
|
-
roof(27, 20, 47, 50, 8),
|
|
496
|
-
roof(27, 60, 47, 76, 8, TEX.BRICK),
|
|
497
|
-
box([
|
|
498
|
-
9,
|
|
499
|
-
12.2,
|
|
500
|
-
39
|
|
501
|
-
], [
|
|
502
|
-
19,
|
|
503
|
-
12.6,
|
|
504
|
-
47
|
|
505
|
-
], TEX.STEEL),
|
|
506
|
-
...stair(53, 10),
|
|
507
|
-
box([
|
|
508
|
-
5,
|
|
509
|
-
10,
|
|
510
|
-
42
|
|
511
|
-
], [
|
|
512
|
-
5.5,
|
|
513
|
-
14,
|
|
514
|
-
42.5
|
|
515
|
-
], TEX.STEEL),
|
|
516
|
-
box([
|
|
517
|
-
5,
|
|
518
|
-
10,
|
|
519
|
-
50
|
|
520
|
-
], [
|
|
521
|
-
5.5,
|
|
522
|
-
14,
|
|
523
|
-
50.5
|
|
524
|
-
], TEX.STEEL),
|
|
525
|
-
box([
|
|
526
|
-
8,
|
|
527
|
-
12.4,
|
|
528
|
-
24
|
|
529
|
-
], [
|
|
530
|
-
20,
|
|
531
|
-
12.85,
|
|
532
|
-
24.45
|
|
533
|
-
], TEX.STEEL),
|
|
534
|
-
box([
|
|
535
|
-
36,
|
|
536
|
-
8,
|
|
537
|
-
22
|
|
538
|
-
], [
|
|
539
|
-
37,
|
|
540
|
-
14.5,
|
|
541
|
-
48
|
|
542
|
-
], TEX.PAINT, TEX.PAINT, [
|
|
543
|
-
.15,
|
|
544
|
-
.72,
|
|
545
|
-
.62
|
|
546
|
-
]),
|
|
547
|
-
box([
|
|
548
|
-
30,
|
|
549
|
-
8,
|
|
550
|
-
28
|
|
551
|
-
], [
|
|
552
|
-
34,
|
|
553
|
-
10,
|
|
554
|
-
32
|
|
555
|
-
], TEX.CONCRETE),
|
|
556
|
-
box([
|
|
557
|
-
40,
|
|
558
|
-
8,
|
|
559
|
-
30
|
|
560
|
-
], [
|
|
561
|
-
44,
|
|
562
|
-
10.2,
|
|
563
|
-
34
|
|
564
|
-
], TEX.PAINT, TEX.PAINT, [
|
|
565
|
-
1,
|
|
566
|
-
.3,
|
|
567
|
-
.06
|
|
568
|
-
]),
|
|
569
|
-
box([
|
|
570
|
-
28,
|
|
571
|
-
9.2,
|
|
572
|
-
44
|
|
573
|
-
], [
|
|
574
|
-
35,
|
|
575
|
-
12,
|
|
576
|
-
46
|
|
577
|
-
], TEX.STEEL, TEX.PAINT, [
|
|
578
|
-
.2,
|
|
579
|
-
.42,
|
|
580
|
-
1
|
|
581
|
-
]),
|
|
582
|
-
box([
|
|
583
|
-
41.5,
|
|
584
|
-
7.6,
|
|
585
|
-
50
|
|
586
|
-
], [
|
|
587
|
-
42,
|
|
588
|
-
8,
|
|
589
|
-
60
|
|
590
|
-
], TEX.STEEL),
|
|
591
|
-
box([
|
|
592
|
-
30,
|
|
593
|
-
8,
|
|
594
|
-
64
|
|
595
|
-
], [
|
|
596
|
-
34,
|
|
597
|
-
9.6,
|
|
598
|
-
68
|
|
599
|
-
], TEX.PAINT, TEX.PAINT, [
|
|
600
|
-
.2,
|
|
601
|
-
.8,
|
|
602
|
-
.3
|
|
603
|
-
])
|
|
604
|
-
];
|
|
605
|
-
/** The map is 240 m long: a point at z has its twin at ZED - z. */
|
|
606
|
-
var ZED = 240;
|
|
607
|
-
/** Team colours as brush tints: the flip swaps one for the other, so a red accent has a blue twin. */
|
|
608
|
-
var RED = [
|
|
609
|
-
1,
|
|
610
|
-
.22,
|
|
611
|
-
.26
|
|
612
|
-
];
|
|
613
|
-
var BLUE = [
|
|
614
|
-
.2,
|
|
615
|
-
.46,
|
|
616
|
-
1
|
|
617
|
-
];
|
|
618
|
-
var ORANGE = [
|
|
619
|
-
1,
|
|
620
|
-
.42,
|
|
621
|
-
.08
|
|
622
|
-
];
|
|
623
|
-
var TEAL = [
|
|
624
|
-
.12,
|
|
625
|
-
.7,
|
|
626
|
-
.62
|
|
627
|
-
];
|
|
628
|
-
/** An accent: a slab of tinted paint, corners (x0, y0, z0) and (x1, y1, z1). */
|
|
629
|
-
var pad = (x0, y0, z0, x1, y1, z1, tint) => box([
|
|
630
|
-
x0,
|
|
631
|
-
y0,
|
|
632
|
-
z0
|
|
633
|
-
], [
|
|
634
|
-
x1,
|
|
635
|
-
y1,
|
|
636
|
-
z1
|
|
637
|
-
], TEX.PAINT, TEX.PAINT, tint);
|
|
444
|
+
// src/shared/physics.ts
|
|
445
|
+
var DT = 1 / 60;
|
|
446
|
+
var TAU = Math.PI * 2;
|
|
447
|
+
/** Overlaps smaller than this are rounding noise, not contact. */
|
|
448
|
+
var EPS = 1e-6;
|
|
638
449
|
/**
|
|
639
|
-
*
|
|
640
|
-
*
|
|
450
|
+
* Feet this close below a floor still stand on it (rounding of y must not sink a player into
|
|
451
|
+
* the floor or flip a step test), and a fall that ends this close above a floor
|
|
452
|
+
* lands on it.
|
|
641
453
|
*/
|
|
642
|
-
var
|
|
643
|
-
const n = Math.ceil((top - y) / .46);
|
|
644
|
-
return Array.from({ length: n }, (_, i) => {
|
|
645
|
-
const [s0, s1] = [a + (b - a) * i / n, a + (b - a) * (i + 1) / n].sort((p, q) => p - q);
|
|
646
|
-
const up = y + (top - y) * (i + 1) / n;
|
|
647
|
-
return axis === 0 ? box([
|
|
648
|
-
s0,
|
|
649
|
-
low,
|
|
650
|
-
w0
|
|
651
|
-
], [
|
|
652
|
-
s1,
|
|
653
|
-
up,
|
|
654
|
-
w1
|
|
655
|
-
], TEX.CONCRETE) : box([
|
|
656
|
-
w0,
|
|
657
|
-
low,
|
|
658
|
-
s0
|
|
659
|
-
], [
|
|
660
|
-
w1,
|
|
661
|
-
up,
|
|
662
|
-
s1
|
|
663
|
-
], TEX.CONCRETE);
|
|
664
|
-
});
|
|
665
|
-
};
|
|
454
|
+
var SKIN = .01;
|
|
666
455
|
/**
|
|
667
|
-
* A
|
|
668
|
-
*
|
|
669
|
-
*/
|
|
670
|
-
var ladder = (x, z, dx, dz, d, low, tops) => tops.map((top, k) => box([
|
|
671
|
-
x + k * dx,
|
|
672
|
-
low,
|
|
673
|
-
z + k * dz
|
|
674
|
-
], [
|
|
675
|
-
x + k * dx + 4,
|
|
676
|
-
top,
|
|
677
|
-
z + k * dz + d
|
|
678
|
-
], TEX.STEEL, TEX.CONCRETE));
|
|
679
|
-
/** Red's half: z from 120 to 240, then flipped. */
|
|
680
|
-
var half = [
|
|
681
|
-
roof(12, 212, 52, 240, 26, TEX.GLASS),
|
|
682
|
-
pad(12, 26, 212, 52, 26.12, 212.5, RED),
|
|
683
|
-
pad(12, 26, 239.5, 52, 26.12, 240, RED),
|
|
684
|
-
pad(12, 26, 212.5, 12.5, 26.12, 239.5, RED),
|
|
685
|
-
pad(51.5, 26, 212.5, 52, 26.12, 239.5, RED),
|
|
686
|
-
pad(11.6, 12, 222, 12, 25.8, 232, RED),
|
|
687
|
-
pad(28, 12, 211.4, 31, 25.5, 212, RED),
|
|
688
|
-
box([
|
|
689
|
-
19,
|
|
690
|
-
26,
|
|
691
|
-
222
|
|
692
|
-
], [
|
|
693
|
-
22,
|
|
694
|
-
27.4,
|
|
695
|
-
225
|
|
696
|
-
], TEX.STEEL),
|
|
697
|
-
box([
|
|
698
|
-
42,
|
|
699
|
-
26,
|
|
700
|
-
222
|
|
701
|
-
], [
|
|
702
|
-
45,
|
|
703
|
-
27.4,
|
|
704
|
-
225
|
|
705
|
-
], TEX.STEEL),
|
|
706
|
-
box([
|
|
707
|
-
29,
|
|
708
|
-
26,
|
|
709
|
-
229
|
|
710
|
-
], [
|
|
711
|
-
35,
|
|
712
|
-
27.1,
|
|
713
|
-
229.6
|
|
714
|
-
], TEX.CONCRETE),
|
|
715
|
-
roof(6, 164, 26, 201, 26, TEX.GLASS),
|
|
716
|
-
roof(6, 134, 26, 147, 26, TEX.GLASS),
|
|
717
|
-
roof(6, 201, 26, 212, 19),
|
|
718
|
-
roof(15, 147, 26, 164, 19),
|
|
719
|
-
box([
|
|
720
|
-
14,
|
|
721
|
-
26,
|
|
722
|
-
164
|
|
723
|
-
], [
|
|
724
|
-
15,
|
|
725
|
-
32,
|
|
726
|
-
196
|
|
727
|
-
], TEX.PAINT, TEX.PAINT, TEAL),
|
|
728
|
-
box([
|
|
729
|
-
14,
|
|
730
|
-
18,
|
|
731
|
-
147
|
|
732
|
-
], [
|
|
733
|
-
15,
|
|
734
|
-
32,
|
|
735
|
-
164
|
|
736
|
-
], TEX.PAINT, TEX.PAINT, TEAL),
|
|
737
|
-
box([
|
|
738
|
-
14,
|
|
739
|
-
26,
|
|
740
|
-
134
|
|
741
|
-
], [
|
|
742
|
-
15,
|
|
743
|
-
32,
|
|
744
|
-
147
|
|
745
|
-
], TEX.PAINT, TEX.PAINT, TEAL),
|
|
746
|
-
...ladder(6, 201, 7, 0, 4, 19, [
|
|
747
|
-
21.2,
|
|
748
|
-
23.4,
|
|
749
|
-
25
|
|
750
|
-
]),
|
|
751
|
-
...[
|
|
752
|
-
[
|
|
753
|
-
18,
|
|
754
|
-
152,
|
|
755
|
-
22,
|
|
756
|
-
156,
|
|
757
|
-
21.2
|
|
758
|
-
],
|
|
759
|
-
[
|
|
760
|
-
18,
|
|
761
|
-
158,
|
|
762
|
-
22,
|
|
763
|
-
162,
|
|
764
|
-
23.4
|
|
765
|
-
],
|
|
766
|
-
[
|
|
767
|
-
23,
|
|
768
|
-
160,
|
|
769
|
-
26,
|
|
770
|
-
164,
|
|
771
|
-
25
|
|
772
|
-
]
|
|
773
|
-
].map(([x0, z0, x1, z1, top]) => box([
|
|
774
|
-
x0,
|
|
775
|
-
19,
|
|
776
|
-
z0
|
|
777
|
-
], [
|
|
778
|
-
x1,
|
|
779
|
-
top,
|
|
780
|
-
z1
|
|
781
|
-
], TEX.STEEL, TEX.CONCRETE)),
|
|
782
|
-
box([
|
|
783
|
-
20,
|
|
784
|
-
26,
|
|
785
|
-
178
|
|
786
|
-
], [
|
|
787
|
-
23,
|
|
788
|
-
27.3,
|
|
789
|
-
181
|
|
790
|
-
], TEX.STEEL),
|
|
791
|
-
box([
|
|
792
|
-
8,
|
|
793
|
-
26,
|
|
794
|
-
176
|
|
795
|
-
], [
|
|
796
|
-
11,
|
|
797
|
-
27.2,
|
|
798
|
-
179
|
|
799
|
-
], TEX.STEEL),
|
|
800
|
-
box([
|
|
801
|
-
8,
|
|
802
|
-
26,
|
|
803
|
-
190
|
|
804
|
-
], [
|
|
805
|
-
11,
|
|
806
|
-
27.3,
|
|
807
|
-
193
|
|
808
|
-
], TEX.STEEL),
|
|
809
|
-
box([
|
|
810
|
-
20,
|
|
811
|
-
26,
|
|
812
|
-
140
|
|
813
|
-
], [
|
|
814
|
-
23,
|
|
815
|
-
27.3,
|
|
816
|
-
143
|
|
817
|
-
], TEX.STEEL),
|
|
818
|
-
roof(32, 186, 76, 209, 19),
|
|
819
|
-
pad(32, 19, 207.5, 76, 19.1, 209, RED),
|
|
820
|
-
...ladder(33, 209, 7, 0, 3, 19, [
|
|
821
|
-
21.2,
|
|
822
|
-
23.4,
|
|
823
|
-
25
|
|
824
|
-
]),
|
|
825
|
-
...[
|
|
826
|
-
[
|
|
827
|
-
28,
|
|
828
|
-
196,
|
|
829
|
-
32,
|
|
830
|
-
200,
|
|
831
|
-
21.2
|
|
832
|
-
],
|
|
833
|
-
[
|
|
834
|
-
28,
|
|
835
|
-
190,
|
|
836
|
-
32,
|
|
837
|
-
194,
|
|
838
|
-
23.4
|
|
839
|
-
],
|
|
840
|
-
[
|
|
841
|
-
26,
|
|
842
|
-
184,
|
|
843
|
-
30,
|
|
844
|
-
188,
|
|
845
|
-
25
|
|
846
|
-
]
|
|
847
|
-
].map(([x0, z0, x1, z1, top]) => box([
|
|
848
|
-
x0,
|
|
849
|
-
BASE,
|
|
850
|
-
z0
|
|
851
|
-
], [
|
|
852
|
-
x1,
|
|
853
|
-
top,
|
|
854
|
-
z1
|
|
855
|
-
], TEX.STEEL, TEX.CONCRETE)),
|
|
856
|
-
roof(32, 166, 64, 182, 21.2, TEX.GLASS),
|
|
857
|
-
roof(32, 140, 64, 161, 19),
|
|
858
|
-
box([
|
|
859
|
-
40,
|
|
860
|
-
21.2,
|
|
861
|
-
172
|
|
862
|
-
], [
|
|
863
|
-
44,
|
|
864
|
-
22.6,
|
|
865
|
-
176
|
|
866
|
-
], TEX.STEEL),
|
|
867
|
-
box([
|
|
868
|
-
52,
|
|
869
|
-
19,
|
|
870
|
-
148
|
|
871
|
-
], [
|
|
872
|
-
57,
|
|
873
|
-
20.3,
|
|
874
|
-
151
|
|
875
|
-
], TEX.STEEL),
|
|
876
|
-
box([
|
|
877
|
-
38,
|
|
878
|
-
19,
|
|
879
|
-
196
|
|
880
|
-
], [
|
|
881
|
-
41,
|
|
882
|
-
20.4,
|
|
883
|
-
199
|
|
884
|
-
], TEX.STEEL),
|
|
885
|
-
box([
|
|
886
|
-
60,
|
|
887
|
-
19,
|
|
888
|
-
200
|
|
889
|
-
], [
|
|
890
|
-
63,
|
|
891
|
-
20.4,
|
|
892
|
-
203
|
|
893
|
-
], TEX.STEEL),
|
|
894
|
-
box([
|
|
895
|
-
52,
|
|
896
|
-
19,
|
|
897
|
-
190
|
|
898
|
-
], [
|
|
899
|
-
58,
|
|
900
|
-
20.6,
|
|
901
|
-
194
|
|
902
|
-
], TEX.STEEL),
|
|
903
|
-
box([
|
|
904
|
-
66,
|
|
905
|
-
19,
|
|
906
|
-
204
|
|
907
|
-
], [
|
|
908
|
-
72,
|
|
909
|
-
20.2,
|
|
910
|
-
207
|
|
911
|
-
], TEX.STEEL),
|
|
912
|
-
box([
|
|
913
|
-
56,
|
|
914
|
-
21.2,
|
|
915
|
-
170
|
|
916
|
-
], [
|
|
917
|
-
60,
|
|
918
|
-
22.4,
|
|
919
|
-
174
|
|
920
|
-
], TEX.STEEL),
|
|
921
|
-
box([
|
|
922
|
-
34,
|
|
923
|
-
19,
|
|
924
|
-
152
|
|
925
|
-
], [
|
|
926
|
-
37,
|
|
927
|
-
20.3,
|
|
928
|
-
156
|
|
929
|
-
], TEX.STEEL),
|
|
930
|
-
...ladder(36, 135, 18, 0, 3, 15, [17.2, 17.2]),
|
|
931
|
-
...ladder(6.5, 129, 6, 0, 4, 15, [
|
|
932
|
-
17.2,
|
|
933
|
-
19.4,
|
|
934
|
-
21.6,
|
|
935
|
-
23.8
|
|
936
|
-
]),
|
|
937
|
-
roof(76, 213, 100, 240, 14.5, TEX.STEEL),
|
|
938
|
-
pad(76, 14.5, 238.5, 100, 14.6, 240, RED),
|
|
939
|
-
roof(76, 185, 100, 209, 14.5),
|
|
940
|
-
roof(76, 138, 100, 181, 14.5, TEX.GLASS),
|
|
941
|
-
box([
|
|
942
|
-
80,
|
|
943
|
-
15.7,
|
|
944
|
-
158
|
|
945
|
-
], [
|
|
946
|
-
96,
|
|
947
|
-
17.7,
|
|
948
|
-
162
|
|
949
|
-
], TEX.STEEL, TEX.PAINT, ORANGE),
|
|
950
|
-
box([
|
|
951
|
-
82,
|
|
952
|
-
14.5,
|
|
953
|
-
234
|
|
954
|
-
], [
|
|
955
|
-
85,
|
|
956
|
-
15.9,
|
|
957
|
-
237
|
|
958
|
-
], TEX.STEEL),
|
|
959
|
-
box([
|
|
960
|
-
91,
|
|
961
|
-
14.5,
|
|
962
|
-
190
|
|
963
|
-
], [
|
|
964
|
-
94,
|
|
965
|
-
15.9,
|
|
966
|
-
193
|
|
967
|
-
], TEX.STEEL),
|
|
968
|
-
box([
|
|
969
|
-
80,
|
|
970
|
-
14.5,
|
|
971
|
-
204
|
|
972
|
-
], [
|
|
973
|
-
83,
|
|
974
|
-
15.6,
|
|
975
|
-
207
|
|
976
|
-
], TEX.STEEL),
|
|
977
|
-
box([
|
|
978
|
-
78,
|
|
979
|
-
14.5,
|
|
980
|
-
170
|
|
981
|
-
], [
|
|
982
|
-
81,
|
|
983
|
-
15.9,
|
|
984
|
-
173
|
|
985
|
-
], TEX.STEEL),
|
|
986
|
-
box([
|
|
987
|
-
92,
|
|
988
|
-
14.5,
|
|
989
|
-
146
|
|
990
|
-
], [
|
|
991
|
-
95,
|
|
992
|
-
15.7,
|
|
993
|
-
149
|
|
994
|
-
], TEX.STEEL),
|
|
995
|
-
box([
|
|
996
|
-
92,
|
|
997
|
-
14.5,
|
|
998
|
-
222
|
|
999
|
-
], [
|
|
1000
|
-
96,
|
|
1001
|
-
15.8,
|
|
1002
|
-
226
|
|
1003
|
-
], TEX.STEEL),
|
|
1004
|
-
...stairs(0, 76, 52, 226, 232, 14.5, 26),
|
|
1005
|
-
...stairs(0, 85, 76, 196, 202, 14.5, 19, 14.5)
|
|
1006
|
-
];
|
|
1007
|
-
/** What stands on the centre line, symmetric as written: the plaza, its dais and canopy, the beam. */
|
|
1008
|
-
var centre = [
|
|
1009
|
-
roof(6, 106, 62, 134, 15),
|
|
1010
|
-
roof(62, 106, 100, 134, 14.5),
|
|
1011
|
-
box([
|
|
1012
|
-
34,
|
|
1013
|
-
15,
|
|
1014
|
-
112
|
|
1015
|
-
], [
|
|
1016
|
-
54,
|
|
1017
|
-
17.2,
|
|
1018
|
-
128
|
|
1019
|
-
], TEX.CONCRETE),
|
|
1020
|
-
pad(38, 17.2, 116, 50, 17.3, 124, ORANGE),
|
|
1021
|
-
...[
|
|
1022
|
-
[35, 113],
|
|
1023
|
-
[35, 126.2],
|
|
1024
|
-
[51, 113],
|
|
1025
|
-
[51, 126.2]
|
|
1026
|
-
].map(([x, z]) => box([
|
|
1027
|
-
x,
|
|
1028
|
-
17.2,
|
|
1029
|
-
z
|
|
1030
|
-
], [
|
|
1031
|
-
x + .8,
|
|
1032
|
-
21.5,
|
|
1033
|
-
z + .8
|
|
1034
|
-
], TEX.STEEL)),
|
|
1035
|
-
box([
|
|
1036
|
-
34.6,
|
|
1037
|
-
21.5,
|
|
1038
|
-
112.6
|
|
1039
|
-
], [
|
|
1040
|
-
52.2,
|
|
1041
|
-
21.9,
|
|
1042
|
-
127.4
|
|
1043
|
-
], TEX.GLASS),
|
|
1044
|
-
box([
|
|
1045
|
-
14,
|
|
1046
|
-
15,
|
|
1047
|
-
114
|
|
1048
|
-
], [
|
|
1049
|
-
17,
|
|
1050
|
-
16.5,
|
|
1051
|
-
117
|
|
1052
|
-
], TEX.STEEL),
|
|
1053
|
-
box([
|
|
1054
|
-
14,
|
|
1055
|
-
15,
|
|
1056
|
-
123
|
|
1057
|
-
], [
|
|
1058
|
-
17,
|
|
1059
|
-
16.5,
|
|
1060
|
-
126
|
|
1061
|
-
], TEX.STEEL),
|
|
1062
|
-
box([
|
|
1063
|
-
56,
|
|
1064
|
-
15,
|
|
1065
|
-
114
|
|
1066
|
-
], [
|
|
1067
|
-
59,
|
|
1068
|
-
16.5,
|
|
1069
|
-
117
|
|
1070
|
-
], TEX.STEEL),
|
|
1071
|
-
box([
|
|
1072
|
-
56,
|
|
1073
|
-
15,
|
|
1074
|
-
123
|
|
1075
|
-
], [
|
|
1076
|
-
59,
|
|
1077
|
-
16.5,
|
|
1078
|
-
126
|
|
1079
|
-
], TEX.STEEL),
|
|
1080
|
-
box([
|
|
1081
|
-
15.35,
|
|
1082
|
-
25.5,
|
|
1083
|
-
106
|
|
1084
|
-
], [
|
|
1085
|
-
15.85,
|
|
1086
|
-
26,
|
|
1087
|
-
134
|
|
1088
|
-
], TEX.STEEL),
|
|
1089
|
-
box([
|
|
1090
|
-
70,
|
|
1091
|
-
14.5,
|
|
1092
|
-
108
|
|
1093
|
-
], [
|
|
1094
|
-
70.8,
|
|
1095
|
-
38,
|
|
1096
|
-
108.8
|
|
1097
|
-
], TEX.STEEL),
|
|
1098
|
-
box([
|
|
1099
|
-
70,
|
|
1100
|
-
14.5,
|
|
1101
|
-
131.2
|
|
1102
|
-
], [
|
|
1103
|
-
70.8,
|
|
1104
|
-
38,
|
|
1105
|
-
132
|
|
1106
|
-
], TEX.STEEL),
|
|
1107
|
-
box([
|
|
1108
|
-
66,
|
|
1109
|
-
14.5,
|
|
1110
|
-
110
|
|
1111
|
-
], [
|
|
1112
|
-
69,
|
|
1113
|
-
15.9,
|
|
1114
|
-
113
|
|
1115
|
-
], TEX.STEEL),
|
|
1116
|
-
box([
|
|
1117
|
-
66,
|
|
1118
|
-
14.5,
|
|
1119
|
-
127
|
|
1120
|
-
], [
|
|
1121
|
-
69,
|
|
1122
|
-
15.9,
|
|
1123
|
-
130
|
|
1124
|
-
], TEX.STEEL)
|
|
1125
|
-
];
|
|
1126
|
-
/** The twin of a brush across the centre line. */
|
|
1127
|
-
var flip = (b) => ({
|
|
1128
|
-
...b,
|
|
1129
|
-
min: [
|
|
1130
|
-
b.min[0],
|
|
1131
|
-
b.min[1],
|
|
1132
|
-
ZED - b.max[2]
|
|
1133
|
-
],
|
|
1134
|
-
max: [
|
|
1135
|
-
b.max[0],
|
|
1136
|
-
b.max[1],
|
|
1137
|
-
ZED - b.min[2]
|
|
1138
|
-
],
|
|
1139
|
-
tint: b.tint === RED ? BLUE : b.tint
|
|
1140
|
-
});
|
|
1141
|
-
/** Where a team starts: two rows facing the other end. */
|
|
1142
|
-
var row = (yaw, z, z2) => [...[
|
|
1143
|
-
16,
|
|
1144
|
-
22,
|
|
1145
|
-
28,
|
|
1146
|
-
34,
|
|
1147
|
-
40
|
|
1148
|
-
].map((x) => [
|
|
1149
|
-
x,
|
|
1150
|
-
26,
|
|
1151
|
-
z,
|
|
1152
|
-
yaw
|
|
1153
|
-
]), ...[
|
|
1154
|
-
19,
|
|
1155
|
-
31,
|
|
1156
|
-
43
|
|
1157
|
-
].map((x) => [
|
|
1158
|
-
x,
|
|
1159
|
-
26,
|
|
1160
|
-
z2,
|
|
1161
|
-
yaw
|
|
1162
|
-
])];
|
|
1163
|
-
var HIGHLINE = {
|
|
1164
|
-
name: "Highline",
|
|
1165
|
-
brushes: [
|
|
1166
|
-
...half,
|
|
1167
|
-
...half.map(flip),
|
|
1168
|
-
...centre
|
|
1169
|
-
],
|
|
1170
|
-
teams: [{
|
|
1171
|
-
base: [
|
|
1172
|
-
32,
|
|
1173
|
-
26,
|
|
1174
|
-
224
|
|
1175
|
-
],
|
|
1176
|
-
spawns: row(0, 236, 231)
|
|
1177
|
-
}, {
|
|
1178
|
-
base: [
|
|
1179
|
-
32,
|
|
1180
|
-
26,
|
|
1181
|
-
16
|
|
1182
|
-
],
|
|
1183
|
-
spawns: row(Math.PI, 4, 9)
|
|
1184
|
-
}],
|
|
1185
|
-
floor: -25,
|
|
1186
|
-
sun: {
|
|
1187
|
-
dir: [
|
|
1188
|
-
.8,
|
|
1189
|
-
.6,
|
|
1190
|
-
0
|
|
1191
|
-
],
|
|
1192
|
-
color: [
|
|
1193
|
-
2.6,
|
|
1194
|
-
2.3,
|
|
1195
|
-
1.8
|
|
1196
|
-
]
|
|
1197
|
-
},
|
|
1198
|
-
sky: [[
|
|
1199
|
-
.04,
|
|
1200
|
-
.2,
|
|
1201
|
-
.72
|
|
1202
|
-
], [
|
|
1203
|
-
.72,
|
|
1204
|
-
.86,
|
|
1205
|
-
.98
|
|
1206
|
-
]],
|
|
1207
|
-
fog: [
|
|
1208
|
-
.72,
|
|
1209
|
-
.86,
|
|
1210
|
-
.98,
|
|
1211
|
-
.0035
|
|
1212
|
-
]
|
|
1213
|
-
};
|
|
1214
|
-
// src/shared/physics.ts
|
|
1215
|
-
var DT = 1 / 60;
|
|
1216
|
-
var TAU = Math.PI * 2;
|
|
1217
|
-
/** Overlaps smaller than this are rounding noise, not contact. */
|
|
1218
|
-
var EPS = 1e-6;
|
|
1219
|
-
/**
|
|
1220
|
-
* Feet this close below a floor still stand on it (rounding of y must not sink a player into
|
|
1221
|
-
* the floor or flip a step test), and a fall that ends this close above a floor
|
|
1222
|
-
* lands on it.
|
|
1223
|
-
*/
|
|
1224
|
-
var SKIN = .01;
|
|
1225
|
-
/**
|
|
1226
|
-
* A circle this close to a box (1 mm) is touching it: a push leaves it exactly PLAYER_R away, and
|
|
1227
|
-
* the float32 position it is rounded to is a few micrometres off.
|
|
456
|
+
* A circle this close to a box (1 mm) is touching it: a push leaves it exactly PLAYER_R away, and
|
|
457
|
+
* the float32 position it is rounded to is a few micrometres off.
|
|
1228
458
|
*/
|
|
1229
459
|
var TOUCH = .001;
|
|
1230
460
|
/** An angle in [0, 2π). */
|
|
@@ -1259,6 +489,13 @@ var STILL = {
|
|
|
1259
489
|
coyote: 6,
|
|
1260
490
|
buffer: 0,
|
|
1261
491
|
held: 0,
|
|
492
|
+
hp: 5,
|
|
493
|
+
ammo: -1,
|
|
494
|
+
cool: 0,
|
|
495
|
+
rack: false,
|
|
496
|
+
down: 0,
|
|
497
|
+
shots: 0,
|
|
498
|
+
hits: 0,
|
|
1262
499
|
ev: 0,
|
|
1263
500
|
fall: 0
|
|
1264
501
|
};
|
|
@@ -1278,10 +515,26 @@ var spawn = (id, w, n, team = 0) => {
|
|
|
1278
515
|
...STILL
|
|
1279
516
|
};
|
|
1280
517
|
};
|
|
518
|
+
/**
|
|
519
|
+
* Puts the player back at the spawn of his id in his team, looking where he looked, with full
|
|
520
|
+
* health and no gun (EV.RESPAWN). The shot and hit counters go on: a reset would read as a shot.
|
|
521
|
+
*/
|
|
522
|
+
var respawn = (p, w, team) => {
|
|
523
|
+
const { yaw, pitch, id, shots, hits } = p;
|
|
524
|
+
Object.assign(p, spawn(id, w, id, team), {
|
|
525
|
+
yaw,
|
|
526
|
+
pitch,
|
|
527
|
+
shots,
|
|
528
|
+
hits,
|
|
529
|
+
ev: p.ev | EV.RESPAWN
|
|
530
|
+
});
|
|
531
|
+
};
|
|
1281
532
|
/** The modes with the feet on a floor: ground, slide and crouch. */
|
|
1282
533
|
var onFloor = (m) => m === MODE.GROUND || m === MODE.SLIDE || m === MODE.CROUCH;
|
|
1283
534
|
/** The height of the cylinder in this mode. */
|
|
1284
535
|
var heightOf = (p) => p.mode === MODE.SLIDE || p.mode === MODE.CROUCH ? LOW_H : PLAYER_H;
|
|
536
|
+
/** The camera height above the feet in this mode. */
|
|
537
|
+
var eyeHeight = (p) => p.mode === MODE.SLIDE || p.mode === MODE.CROUCH ? LOW_EYE : EYE;
|
|
1285
538
|
/** Horizontal speed, m/s. */
|
|
1286
539
|
var speedOf = (p) => len(p.vx, p.vz);
|
|
1287
540
|
/** Whether the brush stops a body of height h whose feet are at y when it walks sideways into it. */
|
|
@@ -1838,63 +1091,972 @@ var air = (p, w, c, burst) => {
|
|
|
1838
1091
|
cap(p, Math.max(before, 6));
|
|
1839
1092
|
};
|
|
1840
1093
|
/**
|
|
1841
|
-
* Applies one input for 1 / TICK_HZ s, in place: yaw and pitch from the input (pitch clamped to
|
|
1842
|
-
* MAX_PITCH), then the step of the current mode (see the top of the file). Feet under the world's
|
|
1843
|
-
* kill floor put the player back at a spawn of his `team` (EV.RESPAWN).
|
|
1094
|
+
* Applies one input for 1 / TICK_HZ s, in place: yaw and pitch from the input (pitch clamped to
|
|
1095
|
+
* MAX_PITCH), then the step of the current mode (see the top of the file). Feet under the world's
|
|
1096
|
+
* kill floor put the player back at a spawn of his `team` (EV.RESPAWN).
|
|
1097
|
+
*/
|
|
1098
|
+
var move = (p, i, w, team = 0) => {
|
|
1099
|
+
p.yaw = norm(i.yaw);
|
|
1100
|
+
p.pitch = Math.max(-MAX_PITCH, Math.min(MAX_PITCH, i.pitch));
|
|
1101
|
+
const f = (i.keys & KEY.FORWARD ? 1 : 0) - (i.keys & KEY.BACK ? 1 : 0);
|
|
1102
|
+
const s = (i.keys & KEY.RIGHT ? 1 : 0) - (i.keys & KEY.LEFT ? 1 : 0);
|
|
1103
|
+
const n = len(f, s) || 1;
|
|
1104
|
+
const [fx, fz] = forward(p.yaw);
|
|
1105
|
+
const pressed = (bit) => (i.keys & bit) !== 0 && (p.held & bit) === 0;
|
|
1106
|
+
const stumbling = p.stun > 0;
|
|
1107
|
+
const c = {
|
|
1108
|
+
keys: i.keys,
|
|
1109
|
+
stumble: stumbling,
|
|
1110
|
+
jump: !stumbling && pressed(KEY.JUMP),
|
|
1111
|
+
dash: !stumbling && pressed(KEY.DASH),
|
|
1112
|
+
fwd: f > 0,
|
|
1113
|
+
wx: (fx * f - fz * s) / n,
|
|
1114
|
+
wz: (fz * f + fx * s) / n,
|
|
1115
|
+
fx,
|
|
1116
|
+
fz
|
|
1117
|
+
};
|
|
1118
|
+
const before = p.mode;
|
|
1119
|
+
p.ev = 0;
|
|
1120
|
+
p.fall = 0;
|
|
1121
|
+
if (c.jump) p.buffer = 7;
|
|
1122
|
+
if (stumbling) p.stun--;
|
|
1123
|
+
if (p.dash > 0) {
|
|
1124
|
+
p.dash--;
|
|
1125
|
+
if (p.dash === 50) cap(p, 10);
|
|
1126
|
+
}
|
|
1127
|
+
if (p.mode === MODE.HANG) hang(p, w, c);
|
|
1128
|
+
if (p.mode === MODE.CLIMB) climb(p, w);
|
|
1129
|
+
else if (p.mode !== MODE.HANG) free(p, w, c);
|
|
1130
|
+
if (p.y < w.def.floor) respawn(p, w, team);
|
|
1131
|
+
p.t = p.mode === before ? Math.min(255, p.t + 1) : p.t;
|
|
1132
|
+
p.buffer = Math.max(0, p.buffer - 1);
|
|
1133
|
+
if (p.mode === MODE.AIR && before === MODE.AIR) p.coyote = Math.max(0, p.coyote - 1);
|
|
1134
|
+
p.held = i.keys & (KEY.JUMP | KEY.DASH);
|
|
1135
|
+
p.ground = onFloor(p.mode);
|
|
1136
|
+
p.x = f32(p.x);
|
|
1137
|
+
p.y = f32(p.y);
|
|
1138
|
+
p.z = f32(p.z);
|
|
1139
|
+
p.vx = f32(p.vx);
|
|
1140
|
+
p.vy = f32(p.vy);
|
|
1141
|
+
p.vz = f32(p.vz);
|
|
1142
|
+
p.edge = f32(p.edge);
|
|
1143
|
+
};
|
|
1144
|
+
// src/shared/gun.ts
|
|
1145
|
+
/** Whether the feet of `p` are within `r` of the point `at` on the floor plane and within PICK_H of its height. */
|
|
1146
|
+
var within = (p, at, r) => {
|
|
1147
|
+
const [dx, dz] = [p.x - at[0], p.z - at[2]];
|
|
1148
|
+
return dx * dx + dz * dz < r * r && Math.abs(p.y - at[1]) < 1;
|
|
1149
|
+
};
|
|
1150
|
+
/**
|
|
1151
|
+
* One input: the move, then the gun. Returns whether a shot went off, for the host to resolve it.
|
|
1152
|
+
* - Down: the keys are dropped, and when `down` runs out the player is back at a spawn.
|
|
1153
|
+
* - The team's rack fills the gun when the player steps into its circle (`rack` tells he is in it),
|
|
1154
|
+
* and again each time he comes back; staying gives nothing.
|
|
1155
|
+
* - The trigger: `cool` runs down, and at 0 a held FIRE with ammo fires, unless the hands are busy
|
|
1156
|
+
* (a hang, a climb). The look is the input's, so the shot goes where the player sees.
|
|
1157
|
+
* `armed` is false while the match is over: no gun, no rack.
|
|
1158
|
+
*/
|
|
1159
|
+
var step = (p, i, w, team, armed = true) => {
|
|
1160
|
+
const down = p.down > 0;
|
|
1161
|
+
move(p, down ? {
|
|
1162
|
+
...i,
|
|
1163
|
+
keys: 0
|
|
1164
|
+
} : i, w, team);
|
|
1165
|
+
if (down) {
|
|
1166
|
+
if (p.down > 0 && !--p.down) respawn(p, w, team);
|
|
1167
|
+
return false;
|
|
1168
|
+
}
|
|
1169
|
+
const rack = w.def.teams[team].rack;
|
|
1170
|
+
const inside = !!rack && within(p, rack, 1.2);
|
|
1171
|
+
if (armed && inside && !p.rack) p.ammo = 60;
|
|
1172
|
+
p.rack = inside;
|
|
1173
|
+
p.cool = Math.max(0, p.cool - 1);
|
|
1174
|
+
if (armed && i.keys & KEY.FIRE && !p.cool && p.ammo > 0 && p.mode !== MODE.HANG && p.mode !== MODE.CLIMB) {
|
|
1175
|
+
p.ammo--;
|
|
1176
|
+
p.shots = p.shots + 1 & 255;
|
|
1177
|
+
p.cool = 7;
|
|
1178
|
+
return true;
|
|
1179
|
+
}
|
|
1180
|
+
return false;
|
|
1181
|
+
};
|
|
1182
|
+
/** Distance at which the ray from `o` along the unit `d` enters the upright cylinder on `c`'s feet, `h` tall; Infinity on a miss. */
|
|
1183
|
+
var cylinder = (o, d, c, h) => {
|
|
1184
|
+
const [px, pz] = [o[0] - c.x, o[2] - c.z];
|
|
1185
|
+
const a = d[0] * d[0] + d[2] * d[2];
|
|
1186
|
+
const b = px * d[0] + pz * d[2];
|
|
1187
|
+
const q = b * b - a * (px * px + pz * pz - PLAYER_R * PLAYER_R);
|
|
1188
|
+
let [lo, hi] = [0, Infinity];
|
|
1189
|
+
if (a > 1e-12) {
|
|
1190
|
+
if (q < 0) return Infinity;
|
|
1191
|
+
[lo, hi] = [(-b - Math.sqrt(q)) / a, (-b + Math.sqrt(q)) / a];
|
|
1192
|
+
} else if (px * px + pz * pz > .4 * .4) return Infinity;
|
|
1193
|
+
const [y0, y1] = [c.y - o[1], c.y + h - o[1]];
|
|
1194
|
+
if (d[1]) [lo, hi] = [Math.max(lo, Math.min(y0 / d[1], y1 / d[1])), Math.min(hi, Math.max(y0 / d[1], y1 / d[1]))];
|
|
1195
|
+
else if (y0 > 0 || y1 < 0) return Infinity;
|
|
1196
|
+
return lo <= hi && hi >= 0 ? Math.max(lo, 0) : Infinity;
|
|
1197
|
+
};
|
|
1198
|
+
/**
|
|
1199
|
+
* The first of `foes` (the players he may hit, as he saw them) that the laser of `p` meets: from his
|
|
1200
|
+
* eye along his look, at most GUN_RANGE and not through a brush. `p` is the state after the input
|
|
1201
|
+
* that fired.
|
|
1202
|
+
*/
|
|
1203
|
+
var shoot = (w, p, foes) => {
|
|
1204
|
+
const o = [
|
|
1205
|
+
p.x,
|
|
1206
|
+
p.y + eyeHeight(p),
|
|
1207
|
+
p.z
|
|
1208
|
+
];
|
|
1209
|
+
const [sy, cy, sp, cp] = [
|
|
1210
|
+
Math.sin(p.yaw),
|
|
1211
|
+
Math.cos(p.yaw),
|
|
1212
|
+
Math.sin(p.pitch),
|
|
1213
|
+
Math.cos(p.pitch)
|
|
1214
|
+
];
|
|
1215
|
+
const d = [
|
|
1216
|
+
-sy * cp,
|
|
1217
|
+
sp,
|
|
1218
|
+
-cy * cp
|
|
1219
|
+
];
|
|
1220
|
+
let t = ray(w, o, d, 80);
|
|
1221
|
+
let hit;
|
|
1222
|
+
for (const f of foes) {
|
|
1223
|
+
const u = cylinder(o, d, f, heightOf(f));
|
|
1224
|
+
if (u < t) [t, hit] = [u, f];
|
|
1225
|
+
}
|
|
1226
|
+
return hit;
|
|
1227
|
+
};
|
|
1228
|
+
// src/shared/map.ts
|
|
1229
|
+
/** The bottom of every building: far below the kill floor, so nothing shows beneath a roof. */
|
|
1230
|
+
var BASE = -30;
|
|
1231
|
+
/** A building: the footprint x0..x1 by z0..z1 from the street up to a flat roof at `top`, white concrete over a facade. */
|
|
1232
|
+
var roof = (x0, z0, x1, z1, top, side = TEX.CONCRETE) => ({
|
|
1233
|
+
min: [
|
|
1234
|
+
x0,
|
|
1235
|
+
BASE,
|
|
1236
|
+
z0
|
|
1237
|
+
],
|
|
1238
|
+
max: [
|
|
1239
|
+
x1,
|
|
1240
|
+
top,
|
|
1241
|
+
z1
|
|
1242
|
+
],
|
|
1243
|
+
top: TEX.CONCRETE,
|
|
1244
|
+
side
|
|
1245
|
+
});
|
|
1246
|
+
/** Any box, corners (x0, y0, z0) and (x1, y1, z1). */
|
|
1247
|
+
var box = ([x0, y0, z0], [x1, y1, z1], top, side = top, tint) => ({
|
|
1248
|
+
min: [
|
|
1249
|
+
x0,
|
|
1250
|
+
y0,
|
|
1251
|
+
z0
|
|
1252
|
+
],
|
|
1253
|
+
max: [
|
|
1254
|
+
x1,
|
|
1255
|
+
y1,
|
|
1256
|
+
z1
|
|
1257
|
+
],
|
|
1258
|
+
top,
|
|
1259
|
+
side,
|
|
1260
|
+
tint
|
|
1261
|
+
});
|
|
1262
|
+
/** Six steps of 0.4 m, 1 m deep and 2 m wide (x 12 to 14) from z down to z - 6, on a roof at y. */
|
|
1263
|
+
var stair = (z, y) => [
|
|
1264
|
+
1,
|
|
1265
|
+
2,
|
|
1266
|
+
3,
|
|
1267
|
+
4,
|
|
1268
|
+
5,
|
|
1269
|
+
6
|
|
1270
|
+
].map((k) => box([
|
|
1271
|
+
12,
|
|
1272
|
+
y,
|
|
1273
|
+
z - k
|
|
1274
|
+
], [
|
|
1275
|
+
14,
|
|
1276
|
+
y + .4 * k,
|
|
1277
|
+
z - k + 1
|
|
1278
|
+
], TEX.CONCRETE));
|
|
1279
|
+
[
|
|
1280
|
+
roof(4, 57.7, 24, 76, 10),
|
|
1281
|
+
roof(4, 36, 24, 53.5, 10, TEX.GLASS),
|
|
1282
|
+
roof(4, 20, 24, 36, 12.4),
|
|
1283
|
+
roof(4, -5, 24, 7, 12.4, TEX.GLASS),
|
|
1284
|
+
roof(27, 20, 47, 50, 8),
|
|
1285
|
+
roof(27, 60, 47, 76, 8, TEX.BRICK),
|
|
1286
|
+
box([
|
|
1287
|
+
9,
|
|
1288
|
+
12.2,
|
|
1289
|
+
39
|
|
1290
|
+
], [
|
|
1291
|
+
19,
|
|
1292
|
+
12.6,
|
|
1293
|
+
47
|
|
1294
|
+
], TEX.STEEL),
|
|
1295
|
+
...stair(53, 10),
|
|
1296
|
+
box([
|
|
1297
|
+
5,
|
|
1298
|
+
10,
|
|
1299
|
+
42
|
|
1300
|
+
], [
|
|
1301
|
+
5.5,
|
|
1302
|
+
14,
|
|
1303
|
+
42.5
|
|
1304
|
+
], TEX.STEEL),
|
|
1305
|
+
box([
|
|
1306
|
+
5,
|
|
1307
|
+
10,
|
|
1308
|
+
50
|
|
1309
|
+
], [
|
|
1310
|
+
5.5,
|
|
1311
|
+
14,
|
|
1312
|
+
50.5
|
|
1313
|
+
], TEX.STEEL),
|
|
1314
|
+
box([
|
|
1315
|
+
8,
|
|
1316
|
+
12.4,
|
|
1317
|
+
24
|
|
1318
|
+
], [
|
|
1319
|
+
20,
|
|
1320
|
+
12.85,
|
|
1321
|
+
24.45
|
|
1322
|
+
], TEX.STEEL),
|
|
1323
|
+
box([
|
|
1324
|
+
36,
|
|
1325
|
+
8,
|
|
1326
|
+
22
|
|
1327
|
+
], [
|
|
1328
|
+
37,
|
|
1329
|
+
14.5,
|
|
1330
|
+
48
|
|
1331
|
+
], TEX.PAINT, TEX.PAINT, [
|
|
1332
|
+
.15,
|
|
1333
|
+
.72,
|
|
1334
|
+
.62
|
|
1335
|
+
]),
|
|
1336
|
+
box([
|
|
1337
|
+
30,
|
|
1338
|
+
8,
|
|
1339
|
+
28
|
|
1340
|
+
], [
|
|
1341
|
+
34,
|
|
1342
|
+
10,
|
|
1343
|
+
32
|
|
1344
|
+
], TEX.CONCRETE),
|
|
1345
|
+
box([
|
|
1346
|
+
40,
|
|
1347
|
+
8,
|
|
1348
|
+
30
|
|
1349
|
+
], [
|
|
1350
|
+
44,
|
|
1351
|
+
10.2,
|
|
1352
|
+
34
|
|
1353
|
+
], TEX.PAINT, TEX.PAINT, [
|
|
1354
|
+
1,
|
|
1355
|
+
.3,
|
|
1356
|
+
.06
|
|
1357
|
+
]),
|
|
1358
|
+
box([
|
|
1359
|
+
28,
|
|
1360
|
+
9.2,
|
|
1361
|
+
44
|
|
1362
|
+
], [
|
|
1363
|
+
35,
|
|
1364
|
+
12,
|
|
1365
|
+
46
|
|
1366
|
+
], TEX.STEEL, TEX.PAINT, [
|
|
1367
|
+
.2,
|
|
1368
|
+
.42,
|
|
1369
|
+
1
|
|
1370
|
+
]),
|
|
1371
|
+
box([
|
|
1372
|
+
41.5,
|
|
1373
|
+
7.6,
|
|
1374
|
+
50
|
|
1375
|
+
], [
|
|
1376
|
+
42,
|
|
1377
|
+
8,
|
|
1378
|
+
60
|
|
1379
|
+
], TEX.STEEL),
|
|
1380
|
+
box([
|
|
1381
|
+
30,
|
|
1382
|
+
8,
|
|
1383
|
+
64
|
|
1384
|
+
], [
|
|
1385
|
+
34,
|
|
1386
|
+
9.6,
|
|
1387
|
+
68
|
|
1388
|
+
], TEX.PAINT, TEX.PAINT, [
|
|
1389
|
+
.2,
|
|
1390
|
+
.8,
|
|
1391
|
+
.3
|
|
1392
|
+
])
|
|
1393
|
+
];
|
|
1394
|
+
/** The map is 240 m long: a point at z has its twin at ZED - z. */
|
|
1395
|
+
var ZED = 240;
|
|
1396
|
+
/** Team colours as brush tints: the flip swaps one for the other, so a red accent has a blue twin. */
|
|
1397
|
+
var RED = [
|
|
1398
|
+
1,
|
|
1399
|
+
.22,
|
|
1400
|
+
.26
|
|
1401
|
+
];
|
|
1402
|
+
var BLUE = [
|
|
1403
|
+
.2,
|
|
1404
|
+
.46,
|
|
1405
|
+
1
|
|
1406
|
+
];
|
|
1407
|
+
var ORANGE = [
|
|
1408
|
+
1,
|
|
1409
|
+
.42,
|
|
1410
|
+
.08
|
|
1411
|
+
];
|
|
1412
|
+
var TEAL = [
|
|
1413
|
+
.12,
|
|
1414
|
+
.7,
|
|
1415
|
+
.62
|
|
1416
|
+
];
|
|
1417
|
+
/** An accent: a slab of tinted paint, corners (x0, y0, z0) and (x1, y1, z1). */
|
|
1418
|
+
var pad = (x0, y0, z0, x1, y1, z1, tint) => box([
|
|
1419
|
+
x0,
|
|
1420
|
+
y0,
|
|
1421
|
+
z0
|
|
1422
|
+
], [
|
|
1423
|
+
x1,
|
|
1424
|
+
y1,
|
|
1425
|
+
z1
|
|
1426
|
+
], TEX.PAINT, TEX.PAINT, tint);
|
|
1427
|
+
/**
|
|
1428
|
+
* A column of stairs: from `a` to `b` along `axis` (0 for x, 2 for z), across `w0` to `w1` on the
|
|
1429
|
+
* other one, rising from `y` to `top` in steps of at most 0.46 m, each step a solid from `low`.
|
|
1430
|
+
*/
|
|
1431
|
+
var stairs = (axis, a, b, w0, w1, y, top, low = BASE) => {
|
|
1432
|
+
const n = Math.ceil((top - y) / .46);
|
|
1433
|
+
return Array.from({ length: n }, (_, i) => {
|
|
1434
|
+
const [s0, s1] = [a + (b - a) * i / n, a + (b - a) * (i + 1) / n].sort((p, q) => p - q);
|
|
1435
|
+
const up = y + (top - y) * (i + 1) / n;
|
|
1436
|
+
return axis === 0 ? box([
|
|
1437
|
+
s0,
|
|
1438
|
+
low,
|
|
1439
|
+
w0
|
|
1440
|
+
], [
|
|
1441
|
+
s1,
|
|
1442
|
+
up,
|
|
1443
|
+
w1
|
|
1444
|
+
], TEX.CONCRETE) : box([
|
|
1445
|
+
w0,
|
|
1446
|
+
low,
|
|
1447
|
+
s0
|
|
1448
|
+
], [
|
|
1449
|
+
w1,
|
|
1450
|
+
up,
|
|
1451
|
+
s1
|
|
1452
|
+
], TEX.CONCRETE);
|
|
1453
|
+
});
|
|
1454
|
+
};
|
|
1455
|
+
/**
|
|
1456
|
+
* A ledge ladder: one platform 4 m wide and `d` deep per top in `tops`, the first at (x, z), each
|
|
1457
|
+
* next one (dx, dz) further, over the roof at `low`. The hands catch the face of each from the one before.
|
|
1458
|
+
*/
|
|
1459
|
+
var ladder = (x, z, dx, dz, d, low, tops) => tops.map((top, k) => box([
|
|
1460
|
+
x + k * dx,
|
|
1461
|
+
low,
|
|
1462
|
+
z + k * dz
|
|
1463
|
+
], [
|
|
1464
|
+
x + k * dx + 4,
|
|
1465
|
+
top,
|
|
1466
|
+
z + k * dz + d
|
|
1467
|
+
], TEX.STEEL, TEX.CONCRETE));
|
|
1468
|
+
/** Red's half: z from 120 to 240, then flipped. */
|
|
1469
|
+
var half = [
|
|
1470
|
+
roof(12, 212, 52, 240, 26, TEX.GLASS),
|
|
1471
|
+
pad(12, 26, 212, 52, 26.12, 212.5, RED),
|
|
1472
|
+
pad(12, 26, 239.5, 52, 26.12, 240, RED),
|
|
1473
|
+
pad(12, 26, 212.5, 12.5, 26.12, 239.5, RED),
|
|
1474
|
+
pad(51.5, 26, 212.5, 52, 26.12, 239.5, RED),
|
|
1475
|
+
pad(11.6, 12, 222, 12, 25.8, 232, RED),
|
|
1476
|
+
pad(28, 12, 211.4, 31, 25.5, 212, RED),
|
|
1477
|
+
box([
|
|
1478
|
+
19,
|
|
1479
|
+
26,
|
|
1480
|
+
222
|
|
1481
|
+
], [
|
|
1482
|
+
22,
|
|
1483
|
+
27.4,
|
|
1484
|
+
225
|
|
1485
|
+
], TEX.STEEL),
|
|
1486
|
+
box([
|
|
1487
|
+
42,
|
|
1488
|
+
26,
|
|
1489
|
+
222
|
|
1490
|
+
], [
|
|
1491
|
+
45,
|
|
1492
|
+
27.4,
|
|
1493
|
+
225
|
|
1494
|
+
], TEX.STEEL),
|
|
1495
|
+
box([
|
|
1496
|
+
29,
|
|
1497
|
+
26,
|
|
1498
|
+
229
|
|
1499
|
+
], [
|
|
1500
|
+
35,
|
|
1501
|
+
27.1,
|
|
1502
|
+
229.6
|
|
1503
|
+
], TEX.CONCRETE),
|
|
1504
|
+
roof(6, 164, 26, 201, 26, TEX.GLASS),
|
|
1505
|
+
roof(6, 134, 26, 147, 26, TEX.GLASS),
|
|
1506
|
+
roof(6, 201, 26, 212, 19),
|
|
1507
|
+
roof(15, 147, 26, 164, 19),
|
|
1508
|
+
box([
|
|
1509
|
+
14,
|
|
1510
|
+
26,
|
|
1511
|
+
164
|
|
1512
|
+
], [
|
|
1513
|
+
15,
|
|
1514
|
+
32,
|
|
1515
|
+
196
|
|
1516
|
+
], TEX.PAINT, TEX.PAINT, TEAL),
|
|
1517
|
+
box([
|
|
1518
|
+
14,
|
|
1519
|
+
18,
|
|
1520
|
+
147
|
|
1521
|
+
], [
|
|
1522
|
+
15,
|
|
1523
|
+
32,
|
|
1524
|
+
164
|
|
1525
|
+
], TEX.PAINT, TEX.PAINT, TEAL),
|
|
1526
|
+
box([
|
|
1527
|
+
14,
|
|
1528
|
+
26,
|
|
1529
|
+
134
|
|
1530
|
+
], [
|
|
1531
|
+
15,
|
|
1532
|
+
32,
|
|
1533
|
+
147
|
|
1534
|
+
], TEX.PAINT, TEX.PAINT, TEAL),
|
|
1535
|
+
...ladder(6, 201, 7, 0, 4, 19, [
|
|
1536
|
+
21.2,
|
|
1537
|
+
23.4,
|
|
1538
|
+
25
|
|
1539
|
+
]),
|
|
1540
|
+
...[
|
|
1541
|
+
[
|
|
1542
|
+
18,
|
|
1543
|
+
152,
|
|
1544
|
+
22,
|
|
1545
|
+
156,
|
|
1546
|
+
21.2
|
|
1547
|
+
],
|
|
1548
|
+
[
|
|
1549
|
+
18,
|
|
1550
|
+
158,
|
|
1551
|
+
22,
|
|
1552
|
+
162,
|
|
1553
|
+
23.4
|
|
1554
|
+
],
|
|
1555
|
+
[
|
|
1556
|
+
23,
|
|
1557
|
+
160,
|
|
1558
|
+
26,
|
|
1559
|
+
164,
|
|
1560
|
+
25
|
|
1561
|
+
]
|
|
1562
|
+
].map(([x0, z0, x1, z1, top]) => box([
|
|
1563
|
+
x0,
|
|
1564
|
+
19,
|
|
1565
|
+
z0
|
|
1566
|
+
], [
|
|
1567
|
+
x1,
|
|
1568
|
+
top,
|
|
1569
|
+
z1
|
|
1570
|
+
], TEX.STEEL, TEX.CONCRETE)),
|
|
1571
|
+
box([
|
|
1572
|
+
20,
|
|
1573
|
+
26,
|
|
1574
|
+
178
|
|
1575
|
+
], [
|
|
1576
|
+
23,
|
|
1577
|
+
27.3,
|
|
1578
|
+
181
|
|
1579
|
+
], TEX.STEEL),
|
|
1580
|
+
box([
|
|
1581
|
+
8,
|
|
1582
|
+
26,
|
|
1583
|
+
176
|
|
1584
|
+
], [
|
|
1585
|
+
11,
|
|
1586
|
+
27.2,
|
|
1587
|
+
179
|
|
1588
|
+
], TEX.STEEL),
|
|
1589
|
+
box([
|
|
1590
|
+
8,
|
|
1591
|
+
26,
|
|
1592
|
+
190
|
|
1593
|
+
], [
|
|
1594
|
+
11,
|
|
1595
|
+
27.3,
|
|
1596
|
+
193
|
|
1597
|
+
], TEX.STEEL),
|
|
1598
|
+
box([
|
|
1599
|
+
20,
|
|
1600
|
+
26,
|
|
1601
|
+
140
|
|
1602
|
+
], [
|
|
1603
|
+
23,
|
|
1604
|
+
27.3,
|
|
1605
|
+
143
|
|
1606
|
+
], TEX.STEEL),
|
|
1607
|
+
roof(32, 186, 76, 209, 19),
|
|
1608
|
+
pad(32, 19, 207.5, 76, 19.1, 209, RED),
|
|
1609
|
+
...ladder(33, 209, 7, 0, 3, 19, [
|
|
1610
|
+
21.2,
|
|
1611
|
+
23.4,
|
|
1612
|
+
25
|
|
1613
|
+
]),
|
|
1614
|
+
...[
|
|
1615
|
+
[
|
|
1616
|
+
28,
|
|
1617
|
+
196,
|
|
1618
|
+
32,
|
|
1619
|
+
200,
|
|
1620
|
+
21.2
|
|
1621
|
+
],
|
|
1622
|
+
[
|
|
1623
|
+
28,
|
|
1624
|
+
190,
|
|
1625
|
+
32,
|
|
1626
|
+
194,
|
|
1627
|
+
23.4
|
|
1628
|
+
],
|
|
1629
|
+
[
|
|
1630
|
+
26,
|
|
1631
|
+
184,
|
|
1632
|
+
30,
|
|
1633
|
+
188,
|
|
1634
|
+
25
|
|
1635
|
+
]
|
|
1636
|
+
].map(([x0, z0, x1, z1, top]) => box([
|
|
1637
|
+
x0,
|
|
1638
|
+
BASE,
|
|
1639
|
+
z0
|
|
1640
|
+
], [
|
|
1641
|
+
x1,
|
|
1642
|
+
top,
|
|
1643
|
+
z1
|
|
1644
|
+
], TEX.STEEL, TEX.CONCRETE)),
|
|
1645
|
+
roof(32, 166, 64, 182, 21.2, TEX.GLASS),
|
|
1646
|
+
roof(32, 140, 64, 161, 19),
|
|
1647
|
+
box([
|
|
1648
|
+
40,
|
|
1649
|
+
21.2,
|
|
1650
|
+
172
|
|
1651
|
+
], [
|
|
1652
|
+
44,
|
|
1653
|
+
22.6,
|
|
1654
|
+
176
|
|
1655
|
+
], TEX.STEEL),
|
|
1656
|
+
box([
|
|
1657
|
+
52,
|
|
1658
|
+
19,
|
|
1659
|
+
148
|
|
1660
|
+
], [
|
|
1661
|
+
57,
|
|
1662
|
+
20.3,
|
|
1663
|
+
151
|
|
1664
|
+
], TEX.STEEL),
|
|
1665
|
+
box([
|
|
1666
|
+
38,
|
|
1667
|
+
19,
|
|
1668
|
+
196
|
|
1669
|
+
], [
|
|
1670
|
+
41,
|
|
1671
|
+
20.4,
|
|
1672
|
+
199
|
|
1673
|
+
], TEX.STEEL),
|
|
1674
|
+
box([
|
|
1675
|
+
60,
|
|
1676
|
+
19,
|
|
1677
|
+
200
|
|
1678
|
+
], [
|
|
1679
|
+
63,
|
|
1680
|
+
20.4,
|
|
1681
|
+
203
|
|
1682
|
+
], TEX.STEEL),
|
|
1683
|
+
box([
|
|
1684
|
+
52,
|
|
1685
|
+
19,
|
|
1686
|
+
190
|
|
1687
|
+
], [
|
|
1688
|
+
58,
|
|
1689
|
+
20.6,
|
|
1690
|
+
194
|
|
1691
|
+
], TEX.STEEL),
|
|
1692
|
+
box([
|
|
1693
|
+
66,
|
|
1694
|
+
19,
|
|
1695
|
+
204
|
|
1696
|
+
], [
|
|
1697
|
+
72,
|
|
1698
|
+
20.2,
|
|
1699
|
+
207
|
|
1700
|
+
], TEX.STEEL),
|
|
1701
|
+
box([
|
|
1702
|
+
56,
|
|
1703
|
+
21.2,
|
|
1704
|
+
170
|
|
1705
|
+
], [
|
|
1706
|
+
60,
|
|
1707
|
+
22.4,
|
|
1708
|
+
174
|
|
1709
|
+
], TEX.STEEL),
|
|
1710
|
+
box([
|
|
1711
|
+
34,
|
|
1712
|
+
19,
|
|
1713
|
+
152
|
|
1714
|
+
], [
|
|
1715
|
+
37,
|
|
1716
|
+
20.3,
|
|
1717
|
+
156
|
|
1718
|
+
], TEX.STEEL),
|
|
1719
|
+
...ladder(36, 135, 18, 0, 3, 15, [17.2, 17.2]),
|
|
1720
|
+
...ladder(6.5, 129, 6, 0, 4, 15, [
|
|
1721
|
+
17.2,
|
|
1722
|
+
19.4,
|
|
1723
|
+
21.6,
|
|
1724
|
+
23.8
|
|
1725
|
+
]),
|
|
1726
|
+
roof(76, 213, 100, 240, 14.5, TEX.STEEL),
|
|
1727
|
+
pad(76, 14.5, 238.5, 100, 14.6, 240, RED),
|
|
1728
|
+
roof(76, 185, 100, 209, 14.5),
|
|
1729
|
+
roof(76, 138, 100, 181, 14.5, TEX.GLASS),
|
|
1730
|
+
box([
|
|
1731
|
+
80,
|
|
1732
|
+
15.7,
|
|
1733
|
+
158
|
|
1734
|
+
], [
|
|
1735
|
+
96,
|
|
1736
|
+
17.7,
|
|
1737
|
+
162
|
|
1738
|
+
], TEX.STEEL, TEX.PAINT, ORANGE),
|
|
1739
|
+
box([
|
|
1740
|
+
82,
|
|
1741
|
+
14.5,
|
|
1742
|
+
234
|
|
1743
|
+
], [
|
|
1744
|
+
85,
|
|
1745
|
+
15.9,
|
|
1746
|
+
237
|
|
1747
|
+
], TEX.STEEL),
|
|
1748
|
+
box([
|
|
1749
|
+
91,
|
|
1750
|
+
14.5,
|
|
1751
|
+
190
|
|
1752
|
+
], [
|
|
1753
|
+
94,
|
|
1754
|
+
15.9,
|
|
1755
|
+
193
|
|
1756
|
+
], TEX.STEEL),
|
|
1757
|
+
box([
|
|
1758
|
+
80,
|
|
1759
|
+
14.5,
|
|
1760
|
+
204
|
|
1761
|
+
], [
|
|
1762
|
+
83,
|
|
1763
|
+
15.6,
|
|
1764
|
+
207
|
|
1765
|
+
], TEX.STEEL),
|
|
1766
|
+
box([
|
|
1767
|
+
78,
|
|
1768
|
+
14.5,
|
|
1769
|
+
170
|
|
1770
|
+
], [
|
|
1771
|
+
81,
|
|
1772
|
+
15.9,
|
|
1773
|
+
173
|
|
1774
|
+
], TEX.STEEL),
|
|
1775
|
+
box([
|
|
1776
|
+
92,
|
|
1777
|
+
14.5,
|
|
1778
|
+
146
|
|
1779
|
+
], [
|
|
1780
|
+
95,
|
|
1781
|
+
15.7,
|
|
1782
|
+
149
|
|
1783
|
+
], TEX.STEEL),
|
|
1784
|
+
box([
|
|
1785
|
+
92,
|
|
1786
|
+
14.5,
|
|
1787
|
+
222
|
|
1788
|
+
], [
|
|
1789
|
+
96,
|
|
1790
|
+
15.8,
|
|
1791
|
+
226
|
|
1792
|
+
], TEX.STEEL),
|
|
1793
|
+
...stairs(0, 76, 52, 226, 232, 14.5, 26),
|
|
1794
|
+
...stairs(0, 85, 76, 196, 202, 14.5, 19, 14.5)
|
|
1795
|
+
];
|
|
1796
|
+
/** What stands on the centre line, symmetric as written: the plaza, its dais and canopy, the beam. */
|
|
1797
|
+
var centre = [
|
|
1798
|
+
roof(6, 106, 62, 134, 15),
|
|
1799
|
+
roof(62, 106, 100, 134, 14.5),
|
|
1800
|
+
box([
|
|
1801
|
+
34,
|
|
1802
|
+
15,
|
|
1803
|
+
112
|
|
1804
|
+
], [
|
|
1805
|
+
54,
|
|
1806
|
+
17.2,
|
|
1807
|
+
128
|
|
1808
|
+
], TEX.CONCRETE),
|
|
1809
|
+
pad(38, 17.2, 116, 50, 17.3, 124, ORANGE),
|
|
1810
|
+
...[
|
|
1811
|
+
[35, 113],
|
|
1812
|
+
[35, 126.2],
|
|
1813
|
+
[51, 113],
|
|
1814
|
+
[51, 126.2]
|
|
1815
|
+
].map(([x, z]) => box([
|
|
1816
|
+
x,
|
|
1817
|
+
17.2,
|
|
1818
|
+
z
|
|
1819
|
+
], [
|
|
1820
|
+
x + .8,
|
|
1821
|
+
21.5,
|
|
1822
|
+
z + .8
|
|
1823
|
+
], TEX.STEEL)),
|
|
1824
|
+
box([
|
|
1825
|
+
34.6,
|
|
1826
|
+
21.5,
|
|
1827
|
+
112.6
|
|
1828
|
+
], [
|
|
1829
|
+
52.2,
|
|
1830
|
+
21.9,
|
|
1831
|
+
127.4
|
|
1832
|
+
], TEX.GLASS),
|
|
1833
|
+
box([
|
|
1834
|
+
14,
|
|
1835
|
+
15,
|
|
1836
|
+
114
|
|
1837
|
+
], [
|
|
1838
|
+
17,
|
|
1839
|
+
16.5,
|
|
1840
|
+
117
|
|
1841
|
+
], TEX.STEEL),
|
|
1842
|
+
box([
|
|
1843
|
+
14,
|
|
1844
|
+
15,
|
|
1845
|
+
123
|
|
1846
|
+
], [
|
|
1847
|
+
17,
|
|
1848
|
+
16.5,
|
|
1849
|
+
126
|
|
1850
|
+
], TEX.STEEL),
|
|
1851
|
+
box([
|
|
1852
|
+
56,
|
|
1853
|
+
15,
|
|
1854
|
+
114
|
|
1855
|
+
], [
|
|
1856
|
+
59,
|
|
1857
|
+
16.5,
|
|
1858
|
+
117
|
|
1859
|
+
], TEX.STEEL),
|
|
1860
|
+
box([
|
|
1861
|
+
56,
|
|
1862
|
+
15,
|
|
1863
|
+
123
|
|
1864
|
+
], [
|
|
1865
|
+
59,
|
|
1866
|
+
16.5,
|
|
1867
|
+
126
|
|
1868
|
+
], TEX.STEEL),
|
|
1869
|
+
box([
|
|
1870
|
+
15.35,
|
|
1871
|
+
25.5,
|
|
1872
|
+
106
|
|
1873
|
+
], [
|
|
1874
|
+
15.85,
|
|
1875
|
+
26,
|
|
1876
|
+
134
|
|
1877
|
+
], TEX.STEEL),
|
|
1878
|
+
box([
|
|
1879
|
+
70,
|
|
1880
|
+
14.5,
|
|
1881
|
+
108
|
|
1882
|
+
], [
|
|
1883
|
+
70.8,
|
|
1884
|
+
38,
|
|
1885
|
+
108.8
|
|
1886
|
+
], TEX.STEEL),
|
|
1887
|
+
box([
|
|
1888
|
+
70,
|
|
1889
|
+
14.5,
|
|
1890
|
+
131.2
|
|
1891
|
+
], [
|
|
1892
|
+
70.8,
|
|
1893
|
+
38,
|
|
1894
|
+
132
|
|
1895
|
+
], TEX.STEEL),
|
|
1896
|
+
box([
|
|
1897
|
+
66,
|
|
1898
|
+
14.5,
|
|
1899
|
+
110
|
|
1900
|
+
], [
|
|
1901
|
+
69,
|
|
1902
|
+
15.9,
|
|
1903
|
+
113
|
|
1904
|
+
], TEX.STEEL),
|
|
1905
|
+
box([
|
|
1906
|
+
66,
|
|
1907
|
+
14.5,
|
|
1908
|
+
127
|
|
1909
|
+
], [
|
|
1910
|
+
69,
|
|
1911
|
+
15.9,
|
|
1912
|
+
130
|
|
1913
|
+
], TEX.STEEL)
|
|
1914
|
+
];
|
|
1915
|
+
/** The twin of a brush across the centre line. */
|
|
1916
|
+
var flip = (b) => ({
|
|
1917
|
+
...b,
|
|
1918
|
+
min: [
|
|
1919
|
+
b.min[0],
|
|
1920
|
+
b.min[1],
|
|
1921
|
+
ZED - b.max[2]
|
|
1922
|
+
],
|
|
1923
|
+
max: [
|
|
1924
|
+
b.max[0],
|
|
1925
|
+
b.max[1],
|
|
1926
|
+
ZED - b.min[2]
|
|
1927
|
+
],
|
|
1928
|
+
tint: b.tint === RED ? BLUE : b.tint
|
|
1929
|
+
});
|
|
1930
|
+
/** Where a team starts: two rows facing the other end. */
|
|
1931
|
+
var row = (yaw, z, z2) => [...[
|
|
1932
|
+
16,
|
|
1933
|
+
22,
|
|
1934
|
+
28,
|
|
1935
|
+
34,
|
|
1936
|
+
40
|
|
1937
|
+
].map((x) => [
|
|
1938
|
+
x,
|
|
1939
|
+
26,
|
|
1940
|
+
z,
|
|
1941
|
+
yaw
|
|
1942
|
+
]), ...[
|
|
1943
|
+
19,
|
|
1944
|
+
31,
|
|
1945
|
+
43
|
|
1946
|
+
].map((x) => [
|
|
1947
|
+
x,
|
|
1948
|
+
26,
|
|
1949
|
+
z2,
|
|
1950
|
+
yaw
|
|
1951
|
+
])];
|
|
1952
|
+
/**
|
|
1953
|
+
* Health packs in red's half, one per stretch of a route: the Spine, the Midtown roofs (two) and
|
|
1954
|
+
* the Lowline, each away from the edges and the cover. Their twins are across the line, and the
|
|
1955
|
+
* plaza has a pair of its own.
|
|
1844
1956
|
*/
|
|
1845
|
-
var
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1957
|
+
var PACKS = [
|
|
1958
|
+
[
|
|
1959
|
+
20,
|
|
1960
|
+
26,
|
|
1961
|
+
190
|
|
1962
|
+
],
|
|
1963
|
+
[
|
|
1964
|
+
48,
|
|
1965
|
+
21.2,
|
|
1966
|
+
172
|
|
1967
|
+
],
|
|
1968
|
+
[
|
|
1969
|
+
48,
|
|
1970
|
+
19,
|
|
1971
|
+
200
|
|
1972
|
+
],
|
|
1973
|
+
[
|
|
1974
|
+
88,
|
|
1975
|
+
14.5,
|
|
1976
|
+
198
|
|
1977
|
+
]
|
|
1978
|
+
];
|
|
1979
|
+
var HIGHLINE = {
|
|
1980
|
+
name: "Highline",
|
|
1981
|
+
brushes: [
|
|
1982
|
+
...half,
|
|
1983
|
+
...half.map(flip),
|
|
1984
|
+
...centre
|
|
1985
|
+
],
|
|
1986
|
+
teams: [{
|
|
1987
|
+
base: [
|
|
1988
|
+
32,
|
|
1989
|
+
26,
|
|
1990
|
+
224
|
|
1991
|
+
],
|
|
1992
|
+
spawns: row(0, 236, 231),
|
|
1993
|
+
rack: [
|
|
1994
|
+
47,
|
|
1995
|
+
26,
|
|
1996
|
+
234
|
|
1997
|
+
]
|
|
1998
|
+
}, {
|
|
1999
|
+
base: [
|
|
2000
|
+
32,
|
|
2001
|
+
26,
|
|
2002
|
+
16
|
|
2003
|
+
],
|
|
2004
|
+
spawns: row(Math.PI, 4, 9),
|
|
2005
|
+
rack: [
|
|
2006
|
+
47,
|
|
2007
|
+
26,
|
|
2008
|
+
6
|
|
2009
|
+
]
|
|
2010
|
+
}],
|
|
2011
|
+
packs: [
|
|
2012
|
+
...PACKS,
|
|
2013
|
+
...PACKS.map(([x, y, z]) => [
|
|
2014
|
+
x,
|
|
2015
|
+
y,
|
|
2016
|
+
ZED - z
|
|
2017
|
+
]),
|
|
2018
|
+
[
|
|
2019
|
+
24,
|
|
2020
|
+
15,
|
|
2021
|
+
112
|
|
2022
|
+
],
|
|
2023
|
+
[
|
|
2024
|
+
24,
|
|
2025
|
+
15,
|
|
2026
|
+
128
|
|
2027
|
+
]
|
|
2028
|
+
],
|
|
2029
|
+
floor: -25,
|
|
2030
|
+
sun: {
|
|
2031
|
+
dir: [
|
|
2032
|
+
.8,
|
|
2033
|
+
.6,
|
|
2034
|
+
0
|
|
2035
|
+
],
|
|
2036
|
+
color: [
|
|
2037
|
+
2.6,
|
|
2038
|
+
2.3,
|
|
2039
|
+
1.8
|
|
2040
|
+
]
|
|
2041
|
+
},
|
|
2042
|
+
sky: [[
|
|
2043
|
+
.04,
|
|
2044
|
+
.2,
|
|
2045
|
+
.72
|
|
2046
|
+
], [
|
|
2047
|
+
.72,
|
|
2048
|
+
.86,
|
|
2049
|
+
.98
|
|
2050
|
+
]],
|
|
2051
|
+
fog: [
|
|
2052
|
+
.72,
|
|
2053
|
+
.86,
|
|
2054
|
+
.98,
|
|
2055
|
+
.0035
|
|
2056
|
+
]
|
|
1897
2057
|
};
|
|
2058
|
+
/** The no-gun value of the ammo's 7 bits. */
|
|
2059
|
+
var NO_GUN = 127;
|
|
1898
2060
|
/** A flag's resting place on the wire: 1/16 m in an i16, so ±2 km. */
|
|
1899
2061
|
var POS = 16;
|
|
1900
2062
|
var TURN = 65536 / (2 * Math.PI);
|
|
@@ -1907,27 +2069,27 @@ var fromPitch = (w) => w / 1e4;
|
|
|
1907
2069
|
var fromTurn = (w) => w / TURN;
|
|
1908
2070
|
/** Null on anything that is not a well-formed input frame. */
|
|
1909
2071
|
var decodeInput = (buf) => {
|
|
1910
|
-
if (buf.byteLength !==
|
|
2072
|
+
if (buf.byteLength !== 12) return null;
|
|
1911
2073
|
const v = new DataView(buf);
|
|
1912
2074
|
if (v.getUint8(0) !== 1) return null;
|
|
1913
2075
|
return {
|
|
1914
2076
|
seq: v.getUint16(1),
|
|
1915
|
-
keys: v.
|
|
1916
|
-
yaw: fromTurn(v.getUint16(
|
|
1917
|
-
pitch: fromPitch(v.getInt16(
|
|
1918
|
-
view: (v.getUint16(
|
|
2077
|
+
keys: v.getUint16(3) & 511,
|
|
2078
|
+
yaw: fromTurn(v.getUint16(5)),
|
|
2079
|
+
pitch: fromPitch(v.getInt16(7)),
|
|
2080
|
+
view: (v.getUint16(9) * 256 + v.getUint8(11)) / 256
|
|
1919
2081
|
};
|
|
1920
2082
|
};
|
|
1921
2083
|
/** Bytes of a flag on the wire, by its state. */
|
|
1922
2084
|
var flagBytes = (state) => state === FLAG.CARRIED ? 2 : state === FLAG.DROPPED ? 8 : 1;
|
|
1923
2085
|
var encodeSnapshot = (s) => {
|
|
1924
|
-
const end = 4 +
|
|
1925
|
-
const v = new DataView(new ArrayBuffer(end +
|
|
2086
|
+
const end = 4 + 45 * s.players.length;
|
|
2087
|
+
const v = new DataView(new ArrayBuffer(end + 8 + s.flags.reduce((n, f) => n + flagBytes(f.state), 0)));
|
|
1926
2088
|
v.setUint8(0, 2);
|
|
1927
2089
|
v.setUint16(1, s.tick & 65535);
|
|
1928
2090
|
v.setUint8(3, s.players.length);
|
|
1929
2091
|
s.players.forEach((p, i) => {
|
|
1930
|
-
const o = 4 + i *
|
|
2092
|
+
const o = 4 + i * 45;
|
|
1931
2093
|
v.setUint8(o, p.id);
|
|
1932
2094
|
v.setFloat32(o + 1, p.x);
|
|
1933
2095
|
v.setFloat32(o + 5, p.y);
|
|
@@ -1944,11 +2106,17 @@ var encodeSnapshot = (s) => {
|
|
|
1944
2106
|
v.setUint8(o + 37, p.dash | (p.by >> 2 & 3) << 6);
|
|
1945
2107
|
v.setUint8(o + 38, p.coyote & 7 | (p.buffer & 7) << 3 | (p.held & KEY.JUMP ? 64 : 0) | (p.held & KEY.DASH ? 128 : 0));
|
|
1946
2108
|
v.setUint8(o + 39, p.stun | (p.by & 3) << 6);
|
|
2109
|
+
const gun = p.hp | p.cool << 3 | (p.ammo < 0 ? NO_GUN : p.ammo) << 6 | p.down << 13 | +!!p.rack << 20;
|
|
2110
|
+
v.setUint8(o + 40, gun >> 16);
|
|
2111
|
+
v.setUint16(o + 41, gun & 65535);
|
|
2112
|
+
v.setUint8(o + 43, p.shots);
|
|
2113
|
+
v.setUint8(o + 44, p.hits);
|
|
1947
2114
|
});
|
|
1948
2115
|
v.setUint8(end, s.score[0]);
|
|
1949
2116
|
v.setUint8(end + 1, s.score[1]);
|
|
1950
2117
|
v.setUint16(end + 2, s.clock & 32767 | (s.over ? 32768 : 0));
|
|
1951
|
-
|
|
2118
|
+
v.setUint32(end + 4, s.packs ?? 0);
|
|
2119
|
+
let o = end + 8;
|
|
1952
2120
|
for (const f of s.flags) {
|
|
1953
2121
|
v.setUint8(o, f.state);
|
|
1954
2122
|
if (f.state === FLAG.CARRIED) v.setUint8(o + 1, f.by);
|
|
@@ -2026,6 +2194,8 @@ var Room = class {
|
|
|
2026
2194
|
rules;
|
|
2027
2195
|
/** Round-robin cursor over the spawn points of each team, used once they are all taken. */
|
|
2028
2196
|
rr = [0, 0];
|
|
2197
|
+
/** Ticks before each health pack of the map is back: 0 when it is there to take. */
|
|
2198
|
+
gone;
|
|
2029
2199
|
/** Missing rules fall back to RULES. */
|
|
2030
2200
|
constructor(rules = {}, map = HIGHLINE) {
|
|
2031
2201
|
this.rules = {
|
|
@@ -2034,6 +2204,7 @@ var Room = class {
|
|
|
2034
2204
|
};
|
|
2035
2205
|
this.world = build(map);
|
|
2036
2206
|
this.ctf = new Ctf(this.world, this.rules);
|
|
2207
|
+
this.gone = (map.packs ?? []).map(() => 0);
|
|
2037
2208
|
}
|
|
2038
2209
|
/** Number of joined players. */
|
|
2039
2210
|
get size() {
|
|
@@ -2054,9 +2225,10 @@ var Room = class {
|
|
|
2054
2225
|
const input = p && decodeInput(data);
|
|
2055
2226
|
if (input && p.bank > 0) {
|
|
2056
2227
|
p.bank--;
|
|
2057
|
-
|
|
2228
|
+
const fired = step(p.state, input, this.world, p.info.team, !this.ctf.over);
|
|
2058
2229
|
this.ctf.moved(p.state);
|
|
2059
2230
|
this.tackle(p, input.view);
|
|
2231
|
+
if (fired) this.shoot(p, input.view);
|
|
2060
2232
|
p.ack = input.seq;
|
|
2061
2233
|
}
|
|
2062
2234
|
}
|
|
@@ -2066,7 +2238,10 @@ var Room = class {
|
|
|
2066
2238
|
this.peers.delete(conn);
|
|
2067
2239
|
if (p) {
|
|
2068
2240
|
this.ctf.leave(p.info.id);
|
|
2069
|
-
if (!this.size)
|
|
2241
|
+
if (!this.size) {
|
|
2242
|
+
this.ctf.reset();
|
|
2243
|
+
this.gone.fill(0);
|
|
2244
|
+
}
|
|
2070
2245
|
this.roster();
|
|
2071
2246
|
}
|
|
2072
2247
|
}
|
|
@@ -2084,7 +2259,8 @@ var Room = class {
|
|
|
2084
2259
|
if (!players.length) return;
|
|
2085
2260
|
const now = ++this.ticks;
|
|
2086
2261
|
for (const p of players) p.bank = Math.min(10, p.bank + 1);
|
|
2087
|
-
|
|
2262
|
+
this.heal(players);
|
|
2263
|
+
const turn = this.ctf.tick(players.filter((p) => !p.state.down).map((p) => ({
|
|
2088
2264
|
id: p.info.id,
|
|
2089
2265
|
team: p.info.team,
|
|
2090
2266
|
state: p.state
|
|
@@ -2104,7 +2280,8 @@ var Room = class {
|
|
|
2104
2280
|
ack: p.ack,
|
|
2105
2281
|
by: p.state.stun ? p.by : 0
|
|
2106
2282
|
})),
|
|
2107
|
-
...this.ctf.wire()
|
|
2283
|
+
...this.ctf.wire(),
|
|
2284
|
+
packs: this.gone.reduce((m, t, k) => t ? m : m | 1 << k, 0) >>> 0
|
|
2108
2285
|
});
|
|
2109
2286
|
players.forEach((p) => p.conn.send(snap));
|
|
2110
2287
|
}
|
|
@@ -2172,7 +2349,7 @@ var Room = class {
|
|
|
2172
2349
|
*/
|
|
2173
2350
|
tackle(p, view) {
|
|
2174
2351
|
const me = p.state;
|
|
2175
|
-
if (!tackling(me) || this.ticks - p.tackled < 30) return;
|
|
2352
|
+
if (me.down || !tackling(me) || this.ticks - p.tackled < 30) return;
|
|
2176
2353
|
const foes = this.players().filter((q) => q.info.team !== p.info.team);
|
|
2177
2354
|
const hit = this.rewind(p.info.id, view).find((seen) => reaches(me, seen) && foes.some((q) => q.info.id === seen.id && this.ctf.carrying(q.info.id) >= 0));
|
|
2178
2355
|
const foe = foes.find((q) => q.info.id === hit?.id);
|
|
@@ -2183,6 +2360,44 @@ var Room = class {
|
|
|
2183
2360
|
foe.by = p.info.id;
|
|
2184
2361
|
p.tackled = this.ticks;
|
|
2185
2362
|
}
|
|
2363
|
+
/**
|
|
2364
|
+
* A shot of `p` went off at the view tick `view`: it hits the first enemy on its way as `p` drew
|
|
2365
|
+
* him (lag compensation), unless he lies down now or did then. A hit takes 1 hp; the last one puts
|
|
2366
|
+
* him down: he lies where he fell, without the gun, and a flag he carries drops with the lock.
|
|
2367
|
+
*/
|
|
2368
|
+
shoot(p, view) {
|
|
2369
|
+
const peers = this.players();
|
|
2370
|
+
const foes = this.rewind(p.info.id, view).filter((seen) => {
|
|
2371
|
+
const q = peers.find((r) => r.info.id === seen.id);
|
|
2372
|
+
return q && q.info.team !== p.info.team && !q.state.down && !seen.down;
|
|
2373
|
+
});
|
|
2374
|
+
const foe = peers.find((q) => q.info.id === shoot(this.world, p.state, foes)?.id);
|
|
2375
|
+
if (!foe) return;
|
|
2376
|
+
p.state.hits = p.state.hits + 1 & 255;
|
|
2377
|
+
if (--foe.state.hp <= 0) {
|
|
2378
|
+
Object.assign(foe.state, {
|
|
2379
|
+
hp: 0,
|
|
2380
|
+
down: 120,
|
|
2381
|
+
ammo: -1,
|
|
2382
|
+
cool: 0
|
|
2383
|
+
});
|
|
2384
|
+
this.ctf.drop(foe.state);
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
/** The packs: one that is gone comes back after PACK_BACK s; a hurt player standing at one takes it. */
|
|
2388
|
+
heal(players) {
|
|
2389
|
+
this.world.def.packs?.forEach((at, k) => {
|
|
2390
|
+
if (this.gone[k] > 0) {
|
|
2391
|
+
this.gone[k]--;
|
|
2392
|
+
return;
|
|
2393
|
+
}
|
|
2394
|
+
const p = players.find((q) => q.state.hp < 5 && !q.state.down && within(q.state, at, .9));
|
|
2395
|
+
if (p) {
|
|
2396
|
+
p.state.hp = Math.min(5, p.state.hp + 2);
|
|
2397
|
+
this.gone[k] = 1200;
|
|
2398
|
+
}
|
|
2399
|
+
});
|
|
2400
|
+
}
|
|
2186
2401
|
/** The first spawn point of the team with none of `others` within SPAWN_CLEAR, else the next one round-robin. */
|
|
2187
2402
|
place(id, team, others) {
|
|
2188
2403
|
const n = this.world.def.teams[team].spawns.findIndex((_, k) => {
|
|
@@ -2212,8 +2427,14 @@ var Room = class {
|
|
|
2212
2427
|
restart(players) {
|
|
2213
2428
|
const put = [];
|
|
2214
2429
|
this.rr = [0, 0];
|
|
2430
|
+
this.gone.fill(0);
|
|
2215
2431
|
for (const p of players) {
|
|
2216
|
-
|
|
2432
|
+
const { shots, hits } = p.state;
|
|
2433
|
+
p.state = {
|
|
2434
|
+
...this.place(p.info.id, p.info.team, put),
|
|
2435
|
+
shots,
|
|
2436
|
+
hits
|
|
2437
|
+
};
|
|
2217
2438
|
put.push(p.state);
|
|
2218
2439
|
this.ctf.place(p.info.id, p.state);
|
|
2219
2440
|
}
|