@sagl/server 0.0.0-stage → 0.1.0-next.49
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/LICENSE +21 -0
- package/README.md +61 -2
- package/dist/actions.d.ts +46 -0
- package/dist/actions.js +80 -0
- package/dist/actions.js.map +1 -0
- package/dist/animations.d.ts +32 -0
- package/dist/animations.js +95 -0
- package/dist/animations.js.map +1 -0
- package/dist/audio.d.ts +180 -0
- package/dist/audio.js +353 -0
- package/dist/audio.js.map +1 -0
- package/dist/audio_effects.d.ts +219 -0
- package/dist/audio_effects.js +84 -0
- package/dist/audio_effects.js.map +1 -0
- package/dist/camera.d.ts +188 -0
- package/dist/camera.js +247 -0
- package/dist/camera.js.map +1 -0
- package/dist/claims.d.ts +27 -0
- package/dist/claims.js +48 -0
- package/dist/claims.js.map +1 -0
- package/dist/commands.d.ts +135 -0
- package/dist/commands.js +373 -0
- package/dist/commands.js.map +1 -0
- package/dist/console.d.ts +21 -0
- package/dist/console.js +100 -0
- package/dist/console.js.map +1 -0
- package/dist/constants.d.ts +654 -0
- package/dist/constants.js +657 -0
- package/dist/constants.js.map +1 -0
- package/dist/cutscene.d.ts +47 -0
- package/dist/cutscene.js +190 -0
- package/dist/cutscene.js.map +1 -0
- package/dist/draw.d.ts +106 -0
- package/dist/draw.js +132 -0
- package/dist/draw.js.map +1 -0
- package/dist/effects.d.ts +91 -0
- package/dist/effects.js +116 -0
- package/dist/effects.js.map +1 -0
- package/dist/gangzones.d.ts +47 -0
- package/dist/gangzones.js +122 -0
- package/dist/gangzones.js.map +1 -0
- package/dist/geo.d.ts +11 -0
- package/dist/geo.js +25 -0
- package/dist/geo.js.map +1 -0
- package/dist/hud.d.ts +159 -0
- package/dist/hud.js +247 -0
- package/dist/hud.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction.d.ts +81 -0
- package/dist/interaction.js +143 -0
- package/dist/interaction.js.map +1 -0
- package/dist/junctions.d.ts +1 -0
- package/dist/junctions.js +330 -0
- package/dist/junctions.js.map +1 -0
- package/dist/map.d.ts +55 -0
- package/dist/map.js +71 -0
- package/dist/map.js.map +1 -0
- package/dist/menu.d.ts +96 -0
- package/dist/menu.js +129 -0
- package/dist/menu.js.map +1 -0
- package/dist/mission.d.ts +482 -0
- package/dist/mission.js +1258 -0
- package/dist/mission.js.map +1 -0
- package/dist/models.d.ts +56 -0
- package/dist/models.js +71 -0
- package/dist/models.js.map +1 -0
- package/dist/modshop.d.ts +229 -0
- package/dist/modshop.js +904 -0
- package/dist/modshop.js.map +1 -0
- package/dist/modshop_data.d.ts +44 -0
- package/dist/modshop_data.js +287 -0
- package/dist/modshop_data.js.map +1 -0
- package/dist/native.d.ts +809 -0
- package/dist/native.js +27 -0
- package/dist/native.js.map +1 -0
- package/dist/objects.d.ts +249 -0
- package/dist/objects.js +455 -0
- package/dist/objects.js.map +1 -0
- package/dist/paint.d.ts +124 -0
- package/dist/paint.js +84 -0
- package/dist/paint.js.map +1 -0
- package/dist/paynspray.d.ts +44 -0
- package/dist/paynspray.js +177 -0
- package/dist/paynspray.js.map +1 -0
- package/dist/ped.d.ts +335 -0
- package/dist/ped.js +536 -0
- package/dist/ped.js.map +1 -0
- package/dist/player.d.ts +685 -0
- package/dist/player.js +1163 -0
- package/dist/player.js.map +1 -0
- package/dist/screeneffects.d.ts +99 -0
- package/dist/screeneffects.js +257 -0
- package/dist/screeneffects.js.map +1 -0
- package/dist/scripts.d.ts +69 -0
- package/dist/scripts.js +125 -0
- package/dist/scripts.js.map +1 -0
- package/dist/server.d.ts +713 -0
- package/dist/server.js +1080 -0
- package/dist/server.js.map +1 -0
- package/dist/shopblips.d.ts +9 -0
- package/dist/shopblips.js +30 -0
- package/dist/shopblips.js.map +1 -0
- package/dist/special.d.ts +33 -0
- package/dist/special.js +26 -0
- package/dist/special.js.map +1 -0
- package/dist/splash.d.ts +42 -0
- package/dist/splash.js +55 -0
- package/dist/splash.js.map +1 -0
- package/dist/text.d.ts +19 -0
- package/dist/text.js +25 -0
- package/dist/text.js.map +1 -0
- package/dist/ui.d.ts +141 -0
- package/dist/ui.js +243 -0
- package/dist/ui.js.map +1 -0
- package/dist/vehicle.d.ts +306 -0
- package/dist/vehicle.js +612 -0
- package/dist/vehicle.js.map +1 -0
- package/dist/vehiclecolors.d.ts +26 -0
- package/dist/vehiclecolors.js +49 -0
- package/dist/vehiclecolors.js.map +1 -0
- package/dist/world.d.ts +222 -0
- package/dist/world.js +227 -0
- package/dist/world.js.map +1 -0
- package/dist/zone.d.ts +89 -0
- package/dist/zone.js +140 -0
- package/dist/zone.js.map +1 -0
- package/package.json +33 -4
package/dist/effects.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { GameObject, Broadcast } from "./objects.js";
|
|
2
|
+
import { mapColor } from "./map.js";
|
|
3
|
+
import { Ped } from "./ped.js";
|
|
4
|
+
import { Player } from "./player.js";
|
|
5
|
+
import { Vehicle } from "./vehicle.js";
|
|
6
|
+
/** An effect (`server.effects.play()`). */
|
|
7
|
+
export class Effect {
|
|
8
|
+
id;
|
|
9
|
+
name;
|
|
10
|
+
#b;
|
|
11
|
+
#playing = true;
|
|
12
|
+
#forget;
|
|
13
|
+
/** @internal */
|
|
14
|
+
constructor(id, name, b, forget) {
|
|
15
|
+
this.id = id;
|
|
16
|
+
this.name = name;
|
|
17
|
+
this.#b = b;
|
|
18
|
+
this.#forget = forget;
|
|
19
|
+
}
|
|
20
|
+
/** False once stopped. A one-off effect stays "playing" until stopped, as far as the server knows. */
|
|
21
|
+
get playing() {
|
|
22
|
+
return this.#playing;
|
|
23
|
+
}
|
|
24
|
+
/** Stops it (its last particles fade out). */
|
|
25
|
+
stop() {
|
|
26
|
+
if (!this.#playing)
|
|
27
|
+
return;
|
|
28
|
+
this.#playing = false;
|
|
29
|
+
this.#b.sendAll({ stop: true });
|
|
30
|
+
this.#forget(this);
|
|
31
|
+
}
|
|
32
|
+
/** @internal */
|
|
33
|
+
replay(player) {
|
|
34
|
+
this.#b.replay(player);
|
|
35
|
+
}
|
|
36
|
+
/** @internal */
|
|
37
|
+
get loops() {
|
|
38
|
+
return this.#b.spec.loop === true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* `server.effects`: the game's particle effects, by name (`"explosion_crate"`,
|
|
43
|
+
* `"fire"`, `"riot_smoke"`...: the game's effects.fxp), and puffs of
|
|
44
|
+
* coloured dust.
|
|
45
|
+
*/
|
|
46
|
+
export class ServerEffects {
|
|
47
|
+
#native;
|
|
48
|
+
#players;
|
|
49
|
+
#next = 1;
|
|
50
|
+
#loops = new Map();
|
|
51
|
+
/** @internal */
|
|
52
|
+
constructor(native, players) {
|
|
53
|
+
this.#native = native;
|
|
54
|
+
this.#players = players;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Plays one of the game's effects, at a spot or on something it follows.
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* server.effects.play("explosion_crate", crate.position);
|
|
61
|
+
* const fire = server.effects.play("fire", car, { loop: true, offset: { x: 0, y: 2, z: 0.5 } });
|
|
62
|
+
* fire.stop();
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
play(name, at, options = {}) {
|
|
66
|
+
if (!/^[A-Za-z0-9_]{1,31}$/.test(name))
|
|
67
|
+
throw new RangeError(`not an effect name: "${name}"`);
|
|
68
|
+
const id = this.#next++;
|
|
69
|
+
const spec = { id, name, loop: options.loop ?? false, ...this.#where(at, options.offset) };
|
|
70
|
+
// A one-off is for those here now; a loop for those joining later too.
|
|
71
|
+
const b = new Broadcast((p, s) => this.#native.effect(p.id, s), this.#players, options.to, spec);
|
|
72
|
+
const effect = new Effect(id, name, b, (e) => this.#loops.delete(e.id));
|
|
73
|
+
if (spec.loop && !options.to)
|
|
74
|
+
this.#loops.set(id, effect);
|
|
75
|
+
return effect;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Puffs of coloured dust (the game's smoke, tinted): a Pay 'n' Spray's
|
|
79
|
+
* cloud, a car skidding on sand.
|
|
80
|
+
*
|
|
81
|
+
* ```ts
|
|
82
|
+
* server.effects.dust(car, { color: "#c03030", count: 40, spread: 2.5, size: 1.5 });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
dust(at, options = {}) {
|
|
86
|
+
const spec = {
|
|
87
|
+
id: this.#next++, ...this.#where(at, options.offset),
|
|
88
|
+
color: options.color === undefined ? 0xffffffff : mapColor(options.color, 0xffffffff),
|
|
89
|
+
size: options.size ?? 1, count: Math.max(1, Math.min(200, Math.trunc(options.count ?? 20))),
|
|
90
|
+
spread: options.spread ?? 1, rise: options.rise ?? 0.3, life: options.life ?? 1,
|
|
91
|
+
carColor: options.carColor === undefined ? 0 : Math.max(0, Math.min(127, Math.trunc(options.carColor))) + 1,
|
|
92
|
+
};
|
|
93
|
+
for (const p of options.to ?? this.#players()) {
|
|
94
|
+
if (p.connected)
|
|
95
|
+
this.#native.effect(p.id, spec);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
#where(at, offset) {
|
|
99
|
+
const o = offset ?? { x: 0, y: 0, z: 0 };
|
|
100
|
+
if (at instanceof Player)
|
|
101
|
+
return { on: 2, target: at.id, ...o };
|
|
102
|
+
if (at instanceof Vehicle)
|
|
103
|
+
return { on: 3, target: at.id, ...o };
|
|
104
|
+
if (at instanceof Ped)
|
|
105
|
+
return { on: 1, target: at.id, ...o };
|
|
106
|
+
if (at instanceof GameObject)
|
|
107
|
+
return { on: 4, target: at.id, ...o };
|
|
108
|
+
return { x: at.x + o.x, y: at.y + o.y, z: at.z + o.z };
|
|
109
|
+
}
|
|
110
|
+
/** @internal A player joined: the loops playing for everyone. */
|
|
111
|
+
replay(player) {
|
|
112
|
+
for (const e of this.#loops.values())
|
|
113
|
+
e.replay(player);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# s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0 +1,47 @@
|
|
|
1
|
+
import { type MapColor } from "./map.js";
|
|
2
|
+
import type { NativeServer } from "./native.js";
|
|
3
|
+
import type { Player } from "./player.js";
|
|
4
|
+
/** Where a gang zone is: two opposite corners on the map. */
|
|
5
|
+
export interface GangZoneArea {
|
|
6
|
+
minX: number;
|
|
7
|
+
minY: number;
|
|
8
|
+
maxX: number;
|
|
9
|
+
maxY: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A coloured rectangle on the radar and the maps (SA-MP's gang zones:
|
|
13
|
+
* turfs, no-go areas), seen by the players it's shown to. Colours are
|
|
14
|
+
* 0xRRGGBBAA or "#RRGGBB[AA]"; a see-through alpha suits them.
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* const turf = server.createGangZone({ minX: 2400, minY: -1750, maxX: 2550, maxY: -1630 }, 0x00ff0060);
|
|
18
|
+
* turf.show(); // everyone, players joining later too
|
|
19
|
+
* turf.flash(0xff000080); // under attack
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class GangZone {
|
|
23
|
+
#private;
|
|
24
|
+
readonly id: number;
|
|
25
|
+
readonly area: GangZoneArea;
|
|
26
|
+
/** @internal */
|
|
27
|
+
constructor(native: NativeServer, players: () => Player[], id: number, area: GangZoneArea, color: MapColor, forget: () => void);
|
|
28
|
+
/** Its colour (0xRRGGBBAA); setting it changes it for everyone who sees it. */
|
|
29
|
+
get color(): number;
|
|
30
|
+
set color(color: MapColor);
|
|
31
|
+
/** Shows it to one player, or (none given) everyone, players joining later too. */
|
|
32
|
+
show(player?: Player): this;
|
|
33
|
+
/** Hides it from one player, or (none given) everyone. */
|
|
34
|
+
hide(player?: Player): this;
|
|
35
|
+
/** Flashes it between its colour and `color`, for everyone who sees it. */
|
|
36
|
+
flash(color: MapColor): this;
|
|
37
|
+
/** Stops it flashing. */
|
|
38
|
+
stopFlash(): this;
|
|
39
|
+
/** Whether `player` sees it. */
|
|
40
|
+
shownTo(player: Player): boolean;
|
|
41
|
+
/** Takes it away from everyone, for good. */
|
|
42
|
+
destroy(): void;
|
|
43
|
+
/** @internal A player joined: they see it if it's everyone's. */
|
|
44
|
+
replay(player: Player): void;
|
|
45
|
+
/** @internal A player left. */
|
|
46
|
+
forget(player: Player): void;
|
|
47
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { mapColor } from "./map.js";
|
|
2
|
+
/**
|
|
3
|
+
* A coloured rectangle on the radar and the maps (SA-MP's gang zones:
|
|
4
|
+
* turfs, no-go areas), seen by the players it's shown to. Colours are
|
|
5
|
+
* 0xRRGGBBAA or "#RRGGBB[AA]"; a see-through alpha suits them.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const turf = server.createGangZone({ minX: 2400, minY: -1750, maxX: 2550, maxY: -1630 }, 0x00ff0060);
|
|
9
|
+
* turf.show(); // everyone, players joining later too
|
|
10
|
+
* turf.flash(0xff000080); // under attack
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export class GangZone {
|
|
14
|
+
id;
|
|
15
|
+
area;
|
|
16
|
+
#native;
|
|
17
|
+
#players;
|
|
18
|
+
#color;
|
|
19
|
+
#flash = null;
|
|
20
|
+
#everyone = false;
|
|
21
|
+
#shown = new Set();
|
|
22
|
+
#destroyed = false;
|
|
23
|
+
#forget;
|
|
24
|
+
/** @internal */
|
|
25
|
+
constructor(native, players, id, area, color, forget) {
|
|
26
|
+
this.#native = native;
|
|
27
|
+
this.#players = players;
|
|
28
|
+
this.#forget = forget;
|
|
29
|
+
this.id = id;
|
|
30
|
+
this.area = {
|
|
31
|
+
minX: Math.min(area.minX, area.maxX), maxX: Math.max(area.minX, area.maxX),
|
|
32
|
+
minY: Math.min(area.minY, area.maxY), maxY: Math.max(area.minY, area.maxY),
|
|
33
|
+
};
|
|
34
|
+
this.#color = mapColor(color, 0xffffff80);
|
|
35
|
+
}
|
|
36
|
+
/** Its colour (0xRRGGBBAA); setting it changes it for everyone who sees it. */
|
|
37
|
+
get color() {
|
|
38
|
+
return this.#color;
|
|
39
|
+
}
|
|
40
|
+
set color(color) {
|
|
41
|
+
this.#color = mapColor(color, 0xffffff80);
|
|
42
|
+
this.#resend();
|
|
43
|
+
}
|
|
44
|
+
/** Shows it to one player, or (none given) everyone, players joining later too. */
|
|
45
|
+
show(player) {
|
|
46
|
+
if (this.#destroyed)
|
|
47
|
+
return this;
|
|
48
|
+
if (player)
|
|
49
|
+
this.#shown.add(player);
|
|
50
|
+
else
|
|
51
|
+
this.#everyone = true;
|
|
52
|
+
for (const p of player ? [player] : this.#players())
|
|
53
|
+
this.#send(p);
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
/** Hides it from one player, or (none given) everyone. */
|
|
57
|
+
hide(player) {
|
|
58
|
+
if (player) {
|
|
59
|
+
this.#shown.delete(player);
|
|
60
|
+
if (this.#everyone)
|
|
61
|
+
return this; // everyone's still includes them
|
|
62
|
+
this.#remove(player);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.#everyone = false;
|
|
66
|
+
this.#shown.clear();
|
|
67
|
+
for (const p of this.#players())
|
|
68
|
+
this.#remove(p);
|
|
69
|
+
}
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
/** Flashes it between its colour and `color`, for everyone who sees it. */
|
|
73
|
+
flash(color) {
|
|
74
|
+
this.#flash = mapColor(color, 0xff000080);
|
|
75
|
+
this.#resend();
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
/** Stops it flashing. */
|
|
79
|
+
stopFlash() {
|
|
80
|
+
this.#flash = null;
|
|
81
|
+
this.#resend();
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
/** Whether `player` sees it. */
|
|
85
|
+
shownTo(player) {
|
|
86
|
+
return !this.#destroyed && (this.#everyone || this.#shown.has(player));
|
|
87
|
+
}
|
|
88
|
+
/** Takes it away from everyone, for good. */
|
|
89
|
+
destroy() {
|
|
90
|
+
if (this.#destroyed)
|
|
91
|
+
return;
|
|
92
|
+
this.hide();
|
|
93
|
+
this.#destroyed = true;
|
|
94
|
+
this.#forget();
|
|
95
|
+
}
|
|
96
|
+
/** @internal A player joined: they see it if it's everyone's. */
|
|
97
|
+
replay(player) {
|
|
98
|
+
if (this.shownTo(player))
|
|
99
|
+
this.#send(player);
|
|
100
|
+
}
|
|
101
|
+
/** @internal A player left. */
|
|
102
|
+
forget(player) {
|
|
103
|
+
this.#shown.delete(player);
|
|
104
|
+
}
|
|
105
|
+
#resend() {
|
|
106
|
+
for (const p of this.#players())
|
|
107
|
+
if (this.shownTo(p))
|
|
108
|
+
this.#send(p);
|
|
109
|
+
}
|
|
110
|
+
#send(player) {
|
|
111
|
+
if (!player.connected)
|
|
112
|
+
return;
|
|
113
|
+
const a = this.area;
|
|
114
|
+
this.#native.gangZone(player.id, { id: this.id, remove: false, minX: a.minX, minY: a.minY, maxX: a.maxX, maxY: a.maxY,
|
|
115
|
+
color: this.#color, flashing: this.#flash !== null, flashColor: this.#flash ?? 0 });
|
|
116
|
+
}
|
|
117
|
+
#remove(player) {
|
|
118
|
+
if (player.connected)
|
|
119
|
+
this.#native.gangZone(player.id, { id: this.id, remove: true, minX: 0, minY: 0, maxX: 0, maxY: 0, color: 0, flashing: false, flashColor: 0 });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=gangzones.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gangzones.js","sourceRoot":"","sources":["../src/gangzones.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,UAAU,CAAC;AAYnD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,QAAQ;IACV,EAAE,CAAS;IACX,IAAI,CAAe;IAC5B,OAAO,CAAe;IACtB,QAAQ,CAAiB;IACzB,MAAM,CAAS;IACf,MAAM,GAAkB,IAAI,CAAC;IAC7B,SAAS,GAAG,KAAK,CAAC;I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O,CAAC,MAAc;QACpB,IAAI,MAAM,CAAC,SAAS;YAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC;IACtK,CAAC;CACF"}
|
package/dist/geo.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Vector3 } from "./player.js";
|
|
2
|
+
/** How far apart two points are (m). */
|
|
3
|
+
export declare function distance(a: Vector3, b: Vector3): number;
|
|
4
|
+
/** How far apart two points are on the map, ignoring height (m). */
|
|
5
|
+
export declare function distance2d(a: Vector3, b: Vector3): number;
|
|
6
|
+
/** The way a heading points, as a unit vector on the map (`z` 0). */
|
|
7
|
+
export declare function headingVector(heading: number): Vector3;
|
|
8
|
+
/** The heading from `from` towards `to` (degrees). */
|
|
9
|
+
export declare function headingTo(from: Vector3, to: Vector3): number;
|
|
10
|
+
/** `at` moved `distance` m along `heading` (and `up` m up). */
|
|
11
|
+
export declare function along(at: Vector3, heading: number, distance: number, up?: number): Vector3;
|
package/dist/geo.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Small geometry helpers for scripts: distances and headings as the game
|
|
2
|
+
// has them (degrees, 0 north, anticlockwise).
|
|
3
|
+
/** How far apart two points are (m). */
|
|
4
|
+
export function distance(a, b) {
|
|
5
|
+
return Math.hypot(a.x - b.x, a.y - b.y, a.z - b.z);
|
|
6
|
+
}
|
|
7
|
+
/** How far apart two points are on the map, ignoring height (m). */
|
|
8
|
+
export function distance2d(a, b) {
|
|
9
|
+
return Math.hypot(a.x - b.x, a.y - b.y);
|
|
10
|
+
}
|
|
11
|
+
/** The way a heading points, as a unit vector on the map (`z` 0). */
|
|
12
|
+
export function headingVector(heading) {
|
|
13
|
+
const h = (heading * Math.PI) / 180;
|
|
14
|
+
return { x: -Math.sin(h), y: Math.cos(h), z: 0 };
|
|
15
|
+
}
|
|
16
|
+
/** The heading from `from` towards `to` (degrees). */
|
|
17
|
+
export function headingTo(from, to) {
|
|
18
|
+
return ((Math.atan2(-(to.x - from.x), to.y - from.y) * 180) / Math.PI + 360) % 360;
|
|
19
|
+
}
|
|
20
|
+
/** `at` moved `distance` m along `heading` (and `up` m up). */
|
|
21
|
+
export function along(at, heading, distance, up = 0) {
|
|
22
|
+
const v = headingVector(heading);
|
|
23
|
+
return { x: at.x + v.x * distance, y: at.y + v.y * distance, z: at.z + up };
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=geo.js.map
|
package/dist/geo.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geo.js","sourceRoot":"","sources":["../src/geo.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,8CAA8C;AAI9C,wCAAwC;AACxC,MAAM,UAAU,QAAQ,CAAC,CAAU,EAAE,CAAU;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,UAAU,CAAC,CAAU,EAAE,CAAU;IAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,MAAM,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IACpC,OAAO,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACnD,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,SAAS,CAAC,IAAa,EAAE,EAAW;IAClD,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACrF,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,KAAK,CAAC,EAAW,EAAE,OAAe,EAAE,QAAgB,EAAE,EAAE,GAAG,CAAC;IAC1E,MAAM,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACjC,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;AAC9E,CAAC"}
|
package/dist/hud.d.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { NativeServer } from "./native.js";
|
|
2
|
+
import { type MapColor } from "./map.js";
|
|
3
|
+
import type { Player, Vector3 } from "./player.js";
|
|
4
|
+
import { Ped } from "./ped.js";
|
|
5
|
+
import { Vehicle } from "./vehicle.js";
|
|
6
|
+
/** The game's blip colours, or `"#RRGGBB[AA]"` / 0xRRGGBBAA. */
|
|
7
|
+
export type BlipColor = "red" | "green" | "blue" | "white" | "yellow" | "purple" | "cyan" | "threat" | "destination" | MapColor;
|
|
8
|
+
export interface BlipOptions {
|
|
9
|
+
/** Default `"destination"` for a spot (the game's yellow), `"blue"` for peds and vehicles (friendly). */
|
|
10
|
+
color?: BlipColor;
|
|
11
|
+
/**
|
|
12
|
+
* `"both"` (the default): the radar blip and the 3D marker (the cylinder at
|
|
13
|
+
* a spot, the arrow over a ped or vehicle); `"blip"` or `"marker"` alone.
|
|
14
|
+
*/
|
|
15
|
+
display?: "both" | "blip" | "marker";
|
|
16
|
+
/** 1-4. */
|
|
17
|
+
scale?: number;
|
|
18
|
+
/** Dims and brightens twice a second, on the radar and the maps: a phone ringing, something urgent. */
|
|
19
|
+
pulse?: boolean;
|
|
20
|
+
/** Spots only: one of the game's radar sprites (1-63) instead of a plain blip and marker. */
|
|
21
|
+
sprite?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Spots only: on the radar only near it, never on its edge, as the game's
|
|
24
|
+
* shops and garages (Pay 'n' Spray, Ammu-Nation); the pause map shows it
|
|
25
|
+
* anywhere.
|
|
26
|
+
*/
|
|
27
|
+
shortRange?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** A blip on one player's radar (`player.hud.blip()`). */
|
|
30
|
+
export declare class Blip {
|
|
31
|
+
#private;
|
|
32
|
+
readonly id: number;
|
|
33
|
+
/** @internal */
|
|
34
|
+
constructor(hud: PlayerHud, id: number, spec: NonNullable<Parameters<NativeServer["setBlip"]>[2]>, options?: BlipOptions);
|
|
35
|
+
/** Changes the options given; the others stay as they are. */
|
|
36
|
+
set(options: BlipOptions): this;
|
|
37
|
+
remove(): void;
|
|
38
|
+
}
|
|
39
|
+
/** A timer or counter on one player's HUD (`player.hud.counter()`, `.timer()`). */
|
|
40
|
+
export declare class HudCounter {
|
|
41
|
+
#private;
|
|
42
|
+
readonly id: number;
|
|
43
|
+
/** @internal */
|
|
44
|
+
constructor(native: NativeServer, player: number, id: number, spec: NonNullable<Parameters<NativeServer["hudCounter"]>[2]>);
|
|
45
|
+
/** The number (a counter), the time left (a timer, ms), or how full (a bar). */
|
|
46
|
+
set value(value: number);
|
|
47
|
+
get value(): number;
|
|
48
|
+
/**
|
|
49
|
+
* A timer held still (showing `value`, the time left) or counting again
|
|
50
|
+
* from it.
|
|
51
|
+
*/
|
|
52
|
+
setPaused(paused: boolean, value: number): void;
|
|
53
|
+
/** Changes its label. */
|
|
54
|
+
set label(label: string);
|
|
55
|
+
remove(): void;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* One player's mission HUD: radar blips (with the game's markers),
|
|
59
|
+
* objective text, big text, timers and counters, and the mission result
|
|
60
|
+
* screen. `player.hud`.
|
|
61
|
+
*/
|
|
62
|
+
/** Parts of the game's HUD (`player.hud.set`): true shows, false hides. */
|
|
63
|
+
export interface HudParts {
|
|
64
|
+
/** The whole HUD (the radar too). */
|
|
65
|
+
visible?: boolean;
|
|
66
|
+
radar?: boolean;
|
|
67
|
+
/** The area's name as they enter it. */
|
|
68
|
+
areaNames?: boolean;
|
|
69
|
+
/** A vehicle's name as they get in. */
|
|
70
|
+
vehicleNames?: boolean;
|
|
71
|
+
clock?: boolean;
|
|
72
|
+
/** The health bar (top right). */
|
|
73
|
+
health?: boolean;
|
|
74
|
+
/** The armour bar. */
|
|
75
|
+
armour?: boolean;
|
|
76
|
+
/** The chat (not part of `visible`, which is the game's HUD). */
|
|
77
|
+
chat?: boolean;
|
|
78
|
+
}
|
|
79
|
+
export declare class PlayerHud {
|
|
80
|
+
#private;
|
|
81
|
+
/** @internal */
|
|
82
|
+
constructor(native: NativeServer, player: number);
|
|
83
|
+
/**
|
|
84
|
+
* Shows or hides parts of the game's HUD for them; parts left out stay
|
|
85
|
+
* as they are. A client script can hide parts too (`sagl.hud.set`): a
|
|
86
|
+
* part shows only if neither hides it.
|
|
87
|
+
*
|
|
88
|
+
* ```ts
|
|
89
|
+
* player.hud.set({ visible: false }); // a login screen: nothing over the shot
|
|
90
|
+
* player.hud.set({ visible: true, clock: false }); // back, without the clock
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
set(parts: HudParts): void;
|
|
94
|
+
/** Which parts show (as the server set them). */
|
|
95
|
+
get parts(): Required<HudParts>;
|
|
96
|
+
/** @internal */
|
|
97
|
+
send(id: number, spec: Parameters<NativeServer["setBlip"]>[2]): void;
|
|
98
|
+
/**
|
|
99
|
+
* A blip on their radar: on a spot (with the game's cylinder marker), or
|
|
100
|
+
* on a ped, vehicle or player (an arrow over them), following it.
|
|
101
|
+
*/
|
|
102
|
+
blip(target: Vector3 | Ped | Vehicle | Player, options?: BlipOptions): Blip;
|
|
103
|
+
/**
|
|
104
|
+
* The objective, at the bottom of their screen in the game's mission text
|
|
105
|
+
* style, for `ms` (default: about as long as reading it takes; `Infinity`:
|
|
106
|
+
* until replaced or cleared).
|
|
107
|
+
*/
|
|
108
|
+
objective(text: string, ms?: number): void;
|
|
109
|
+
/**
|
|
110
|
+
* The game's help box, top left (its hints: "Press F to ..."), for `ms`
|
|
111
|
+
* (default: about as long as reading it takes; `Infinity`: until replaced
|
|
112
|
+
* or cleared). Game codes and `gxt()` work. An interaction's prompt shows
|
|
113
|
+
* over it while one's in reach.
|
|
114
|
+
*/
|
|
115
|
+
help(text: string, ms?: number): void;
|
|
116
|
+
/** Clears the help box. */
|
|
117
|
+
clearHelp(): void;
|
|
118
|
+
/** Clears the objective. */
|
|
119
|
+
clearObjective(): void;
|
|
120
|
+
/**
|
|
121
|
+
* A notice in the middle of their screen, as the game's garages and
|
|
122
|
+
* shops give ("New engine and paint job: $100"), for `ms` (default 4000).
|
|
123
|
+
* Game codes and `gxt()` work.
|
|
124
|
+
*/
|
|
125
|
+
notice(text: string, ms?: number): void;
|
|
126
|
+
/**
|
|
127
|
+
* The game's own big text, in one of its seven styles, as SA-MP's
|
|
128
|
+
* GameTextForPlayer (the same numbers): 0 big in the middle (mission
|
|
129
|
+
* passed), 1 bottom right (the time, money), 2 white in the middle,
|
|
130
|
+
* 3 smaller in the middle, 4 smaller, a bit higher, 5 small white in the
|
|
131
|
+
* middle, 6 light blue at the top. Game codes (`~r~`, `~n~`...) and
|
|
132
|
+
* `gxt()` work. `ms` default 3000.
|
|
133
|
+
*
|
|
134
|
+
* ```ts
|
|
135
|
+
* player.hud.gameText("~g~Welcome~n~~w~to Los Santos", 3000, GameTextStyle.Middle);
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
gameText(text: string, ms?: number, style?: number): void;
|
|
139
|
+
/** Big text in the middle of their screen, for `ms`. */
|
|
140
|
+
bigText(text: string, ms?: number): void;
|
|
141
|
+
/** A counter under their money: `label value` (`value/max` with `max`), or a bar. */
|
|
142
|
+
counter(label: string, options?: {
|
|
143
|
+
value?: number;
|
|
144
|
+
max?: number;
|
|
145
|
+
bar?: boolean;
|
|
146
|
+
color?: MapColor;
|
|
147
|
+
}): HudCounter;
|
|
148
|
+
/** A timer under their money, counting down from `ms` (or up from it, `countUp`). */
|
|
149
|
+
timer(label: string, ms: number, options?: {
|
|
150
|
+
countUp?: boolean;
|
|
151
|
+
color?: MapColor;
|
|
152
|
+
}): HudCounter;
|
|
153
|
+
/** "MISSION PASSED!" with the game's tune, and `subtitle` under it (the reward: "$2500"). */
|
|
154
|
+
missionPassed(subtitle?: string): void;
|
|
155
|
+
/** "MISSION FAILED!", and `subtitle` under it (why). */
|
|
156
|
+
missionFailed(subtitle?: string): void;
|
|
157
|
+
/** A result screen of your own: `title` ("1st place!"), and `subtitle` under it. */
|
|
158
|
+
missionResult(title: string, subtitle?: string): void;
|
|
159
|
+
}
|