@nodemod/core 1.0.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 +60 -0
- package/dist/core/cmd.d.ts +148 -0
- package/dist/core/cmd.d.ts.map +1 -0
- package/dist/core/cmd.js +177 -0
- package/dist/core/cmd.js.map +1 -0
- package/dist/core/menu.d.ts +300 -0
- package/dist/core/menu.d.ts.map +1 -0
- package/dist/core/menu.js +449 -0
- package/dist/core/menu.js.map +1 -0
- package/dist/core/msg.d.ts +300 -0
- package/dist/core/msg.d.ts.map +1 -0
- package/dist/core/msg.js +374 -0
- package/dist/core/msg.js.map +1 -0
- package/dist/core/resource.d.ts +137 -0
- package/dist/core/resource.d.ts.map +1 -0
- package/dist/core/resource.js +171 -0
- package/dist/core/resource.js.map +1 -0
- package/dist/core/sound.d.ts +262 -0
- package/dist/core/sound.d.ts.map +1 -0
- package/dist/core/sound.js +300 -0
- package/dist/core/sound.js.map +1 -0
- package/dist/enhanced/entity.d.ts +263 -0
- package/dist/enhanced/entity.d.ts.map +1 -0
- package/dist/enhanced/entity.js +447 -0
- package/dist/enhanced/entity.js.map +1 -0
- package/dist/enhanced/events.d.ts +257 -0
- package/dist/enhanced/events.d.ts.map +1 -0
- package/dist/enhanced/events.js +350 -0
- package/dist/enhanced/events.js.map +1 -0
- package/dist/enhanced/player.d.ts +272 -0
- package/dist/enhanced/player.d.ts.map +1 -0
- package/dist/enhanced/player.js +389 -0
- package/dist/enhanced/player.js.map +1 -0
- package/dist/enhanced/trace.d.ts +198 -0
- package/dist/enhanced/trace.d.ts.map +1 -0
- package/dist/enhanced/trace.js +311 -0
- package/dist/enhanced/trace.js.map +1 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +120 -0
- package/dist/index.js.map +1 -0
- package/dist/native/cvar.d.ts +49 -0
- package/dist/native/cvar.d.ts.map +1 -0
- package/dist/native/cvar.js +169 -0
- package/dist/native/cvar.js.map +1 -0
- package/dist/native/file.d.ts +221 -0
- package/dist/native/file.d.ts.map +1 -0
- package/dist/native/file.js +353 -0
- package/dist/native/file.js.map +1 -0
- package/dist/types/dll.d.ts +109 -0
- package/dist/types/engine.d.ts +319 -0
- package/dist/types/enums.d.ts +434 -0
- package/dist/types/events.d.ts +2432 -0
- package/dist/types/index.d.ts +38 -0
- package/dist/types/structures.d.ts +1144 -0
- package/dist/utils/util.d.ts +202 -0
- package/dist/utils/util.d.ts.map +1 -0
- package/dist/utils/util.js +318 -0
- package/dist/utils/util.js.map +1 -0
- package/package.json +167 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for trace operations.
|
|
3
|
+
*/
|
|
4
|
+
export interface TraceOptions {
|
|
5
|
+
/** Trace flags for filtering what to ignore (use nodemod.IGNORE constants) */
|
|
6
|
+
flags?: number;
|
|
7
|
+
/** Entity to ignore during the trace */
|
|
8
|
+
ignore?: nodemod.Entity | null;
|
|
9
|
+
/** Hull size for hull-based traces (use nodemod.HULL constants) */
|
|
10
|
+
hullSize?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Enhanced trace result with additional computed properties and convenience flags.
|
|
14
|
+
*/
|
|
15
|
+
export interface EnhancedTraceResult extends nodemod.TraceResult {
|
|
16
|
+
/** Distance traveled before hitting something */
|
|
17
|
+
distance?: number;
|
|
18
|
+
/** Exact 3D coordinates where the trace hit */
|
|
19
|
+
hitPoint?: number[];
|
|
20
|
+
/** Whether the trace hit something before reaching the end */
|
|
21
|
+
didHit: boolean;
|
|
22
|
+
/** Whether the trace hit the sky */
|
|
23
|
+
hitSky: boolean;
|
|
24
|
+
/** Whether the trace hit water */
|
|
25
|
+
hitWater: boolean;
|
|
26
|
+
/** Entity that was hit (if any) */
|
|
27
|
+
hitEntity?: nodemod.Entity | null;
|
|
28
|
+
/** Whether the trace hit a solid surface */
|
|
29
|
+
hitSurface: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Detailed information about the contents of a specific point in space.
|
|
33
|
+
*/
|
|
34
|
+
export interface PointContentsResult {
|
|
35
|
+
/** Raw contents value from the engine */
|
|
36
|
+
contents: number;
|
|
37
|
+
/** Whether the point is in empty space */
|
|
38
|
+
isEmpty: boolean;
|
|
39
|
+
/** Whether the point is inside a solid object */
|
|
40
|
+
isSolid: boolean;
|
|
41
|
+
/** Whether the point is in water */
|
|
42
|
+
isWater: boolean;
|
|
43
|
+
/** Whether the point is in slime */
|
|
44
|
+
isSlime: boolean;
|
|
45
|
+
/** Whether the point is in lava */
|
|
46
|
+
isLava: boolean;
|
|
47
|
+
/** Whether the point is in the sky */
|
|
48
|
+
isSky: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Advanced tracing and physics utilities for line-of-sight, collision detection, and spatial analysis.
|
|
52
|
+
* Provides enhanced trace operations with convenient result parsing and batch processing capabilities.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* // Basic line tracing
|
|
57
|
+
* const trace = nodemodCore.trace.line([0, 0, 100], [100, 100, 100]);
|
|
58
|
+
* if (trace?.didHit) {
|
|
59
|
+
* console.log(`Hit something at distance: ${trace.distance}`);
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* // Line of sight check
|
|
63
|
+
* const canSee = nodemodCore.trace.canSee(player1, player2);
|
|
64
|
+
* console.log(`Players can see each other: ${canSee}`);
|
|
65
|
+
*
|
|
66
|
+
* // Find ground below position
|
|
67
|
+
* const ground = nodemodCore.trace.findGround([100, 100, 500]);
|
|
68
|
+
* if (ground?.didHit) {
|
|
69
|
+
* console.log(`Ground is at: ${ground.hitPoint}`);
|
|
70
|
+
* }
|
|
71
|
+
*
|
|
72
|
+
* // Check point contents
|
|
73
|
+
* const contents = nodemodCore.trace.pointContents([50, 50, 50]);
|
|
74
|
+
* if (contents.isWater) {
|
|
75
|
+
* console.log('Point is underwater');
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export default class NodemodTrace {
|
|
80
|
+
/**
|
|
81
|
+
* Performs a line trace between two points with enhanced options and result parsing.
|
|
82
|
+
*
|
|
83
|
+
* @param start - Starting point [x, y, z]
|
|
84
|
+
* @param end - Ending point [x, y, z]
|
|
85
|
+
* @param options - Trace configuration options
|
|
86
|
+
* @returns Enhanced trace result with additional computed properties
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* // Basic line trace
|
|
91
|
+
* const trace = nodemodCore.trace.line([0, 0, 0], [100, 0, 0]);
|
|
92
|
+
*
|
|
93
|
+
* // Trace ignoring monsters
|
|
94
|
+
* const trace2 = nodemodCore.trace.line([0, 0, 0], [100, 0, 0], {
|
|
95
|
+
* flags: nodemod.IGNORE.MONSTERS
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* // Hull-based trace
|
|
99
|
+
* const trace3 = nodemodCore.trace.line([0, 0, 0], [100, 0, 0], {
|
|
100
|
+
* hullSize: nodemod.HULL.HUMAN,
|
|
101
|
+
* ignore: player
|
|
102
|
+
* });
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
line(start: number[], end: number[], options?: TraceOptions): EnhancedTraceResult | null;
|
|
106
|
+
fromEntity(entity: nodemod.Entity | number, target: nodemod.Entity | number[], options?: TraceOptions): EnhancedTraceResult | null;
|
|
107
|
+
/**
|
|
108
|
+
* Checks if one entity has line of sight to another entity.
|
|
109
|
+
* Automatically adjusts for entity view offset and target positioning.
|
|
110
|
+
*
|
|
111
|
+
* @param entity1 - Source entity or entity index
|
|
112
|
+
* @param entity2 - Target entity or entity index
|
|
113
|
+
* @param options - Trace configuration options
|
|
114
|
+
* @returns True if entity1 can see entity2, false otherwise
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* // Check if player can see another player
|
|
119
|
+
* const canSee = nodemodCore.trace.canSee(player1, player2);
|
|
120
|
+
* if (canSee) {
|
|
121
|
+
* console.log('Player 1 can see Player 2');
|
|
122
|
+
* }
|
|
123
|
+
*
|
|
124
|
+
* // Check line of sight ignoring other players
|
|
125
|
+
* const canSeeIgnoringPlayers = nodemodCore.trace.canSee(sniper, target, {
|
|
126
|
+
* flags: nodemod.IGNORE.MONSTERS
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
canSee(entity1: nodemod.Entity | number, entity2: nodemod.Entity | number, options?: TraceOptions): boolean;
|
|
131
|
+
findGround(origin: number[], distance?: number): EnhancedTraceResult | null;
|
|
132
|
+
sphere(start: number[], end: number[], radius: number, options?: TraceOptions): EnhancedTraceResult | null;
|
|
133
|
+
monsterHull(entity: nodemod.Entity, start: number[], end: number[], options?: TraceOptions): nodemod.TraceMonsterHullResult;
|
|
134
|
+
texture(entity: nodemod.Entity, start: number[], end: number[]): string;
|
|
135
|
+
projectile(entity: nodemod.Entity, ignore?: nodemod.Entity | null): EnhancedTraceResult | null;
|
|
136
|
+
/**
|
|
137
|
+
* Analyzes the contents of a specific point in 3D space.
|
|
138
|
+
* Useful for checking if a position is in water, solid matter, or empty space.
|
|
139
|
+
*
|
|
140
|
+
* @param point - 3D coordinates [x, y, z] to check
|
|
141
|
+
* @returns Detailed information about what exists at that point
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* // Check if a position is safe for teleporting
|
|
146
|
+
* const contents = nodemodCore.trace.pointContents([100, 200, 300]);
|
|
147
|
+
* if (contents.isEmpty) {
|
|
148
|
+
* console.log('Safe to teleport');
|
|
149
|
+
* } else if (contents.isWater) {
|
|
150
|
+
* console.log('Position is underwater');
|
|
151
|
+
* } else if (contents.isSolid) {
|
|
152
|
+
* console.log('Position is inside a wall');
|
|
153
|
+
* }
|
|
154
|
+
*
|
|
155
|
+
* // Check multiple points
|
|
156
|
+
* const positions = [[0,0,0], [100,100,100], [200,200,200]];
|
|
157
|
+
* positions.forEach((pos, i) => {
|
|
158
|
+
* const result = nodemodCore.trace.pointContents(pos);
|
|
159
|
+
* console.log(`Point ${i}: ${result.isEmpty ? 'empty' : 'occupied'}`);
|
|
160
|
+
* });
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
pointContents(point: number[]): PointContentsResult;
|
|
164
|
+
enhanceTraceResult(result: nodemod.TraceResult | null, start?: number[] | null, end?: number[] | null): EnhancedTraceResult | null;
|
|
165
|
+
multiLine(traces: Array<{
|
|
166
|
+
start: number[];
|
|
167
|
+
end: number[];
|
|
168
|
+
options?: TraceOptions;
|
|
169
|
+
} | [number[], number[], TraceOptions?]>): Array<EnhancedTraceResult | null>;
|
|
170
|
+
findClosestSurface(origin: number[], direction: number[], maxDistance?: number): EnhancedTraceResult | null;
|
|
171
|
+
traceCardinal(origin: number[], distance?: number): Record<string, EnhancedTraceResult | null>;
|
|
172
|
+
/**
|
|
173
|
+
* Checks if a rectangular area is clear of obstacles by testing all corners.
|
|
174
|
+
* Useful for verifying if there's enough space to place objects or teleport players.
|
|
175
|
+
*
|
|
176
|
+
* @param center - Center point of the area [x, y, z]
|
|
177
|
+
* @param size - Dimensions of the area [width, length, height] (default: [64, 64, 64])
|
|
178
|
+
* @returns True if the entire area is clear, false if any part is blocked
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* // Check if there's space for a player
|
|
183
|
+
* const playerSize = [32, 32, 72]; // Typical player dimensions
|
|
184
|
+
* const isClear = nodemodCore.trace.isAreaClear([100, 200, 300], playerSize);
|
|
185
|
+
* if (isClear) {
|
|
186
|
+
* console.log('Safe to spawn player here');
|
|
187
|
+
* }
|
|
188
|
+
*
|
|
189
|
+
* // Check default 64x64x64 area
|
|
190
|
+
* const canPlaceItem = nodemodCore.trace.isAreaClear([50, 50, 50]);
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
isAreaClear(center: number[], size?: number[]): boolean;
|
|
194
|
+
normalizeVector(vector: number[]): number[];
|
|
195
|
+
vectorLength(vector: number[]): number;
|
|
196
|
+
vectorDistance(v1: number[], v2: number[]): number;
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/enhanced/trace.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAC/B,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,OAAO,CAAC,WAAW;IAC9D,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,8DAA8D;IAC9D,MAAM,EAAE,OAAO,CAAC;IAChB,oCAAoC;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,kCAAkC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,mCAAmC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAClC,4CAA4C;IAC5C,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,0CAA0C;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,mCAAmC;IACnC,MAAM,EAAE,OAAO,C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|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Advanced tracing and physics utilities for line-of-sight, collision detection, and spatial analysis.
|
|
5
|
+
* Provides enhanced trace operations with convenient result parsing and batch processing capabilities.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Basic line tracing
|
|
10
|
+
* const trace = nodemodCore.trace.line([0, 0, 100], [100, 100, 100]);
|
|
11
|
+
* if (trace?.didHit) {
|
|
12
|
+
* console.log(`Hit something at distance: ${trace.distance}`);
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* // Line of sight check
|
|
16
|
+
* const canSee = nodemodCore.trace.canSee(player1, player2);
|
|
17
|
+
* console.log(`Players can see each other: ${canSee}`);
|
|
18
|
+
*
|
|
19
|
+
* // Find ground below position
|
|
20
|
+
* const ground = nodemodCore.trace.findGround([100, 100, 500]);
|
|
21
|
+
* if (ground?.didHit) {
|
|
22
|
+
* console.log(`Ground is at: ${ground.hitPoint}`);
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* // Check point contents
|
|
26
|
+
* const contents = nodemodCore.trace.pointContents([50, 50, 50]);
|
|
27
|
+
* if (contents.isWater) {
|
|
28
|
+
* console.log('Point is underwater');
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
class NodemodTrace {
|
|
33
|
+
/**
|
|
34
|
+
* Performs a line trace between two points with enhanced options and result parsing.
|
|
35
|
+
*
|
|
36
|
+
* @param start - Starting point [x, y, z]
|
|
37
|
+
* @param end - Ending point [x, y, z]
|
|
38
|
+
* @param options - Trace configuration options
|
|
39
|
+
* @returns Enhanced trace result with additional computed properties
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* // Basic line trace
|
|
44
|
+
* const trace = nodemodCore.trace.line([0, 0, 0], [100, 0, 0]);
|
|
45
|
+
*
|
|
46
|
+
* // Trace ignoring monsters
|
|
47
|
+
* const trace2 = nodemodCore.trace.line([0, 0, 0], [100, 0, 0], {
|
|
48
|
+
* flags: nodemod.IGNORE.MONSTERS
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* // Hull-based trace
|
|
52
|
+
* const trace3 = nodemodCore.trace.line([0, 0, 0], [100, 0, 0], {
|
|
53
|
+
* hullSize: nodemod.HULL.HUMAN,
|
|
54
|
+
* ignore: player
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
line(start, end, options = {}) {
|
|
59
|
+
const { flags = 0, ignore = null, hullSize = 0 } = options;
|
|
60
|
+
let result;
|
|
61
|
+
if (hullSize > 0) {
|
|
62
|
+
// traceHull requires Entity, not Entity | null
|
|
63
|
+
const ignoreEntity = ignore || nodemod.eng.pEntityOfEntIndex(0); // Use world entity as fallback
|
|
64
|
+
result = nodemod.eng.traceHull(start, end, flags, hullSize, ignoreEntity);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
result = nodemod.eng.traceLine(start, end, flags, ignore || null);
|
|
68
|
+
}
|
|
69
|
+
return this.enhanceTraceResult(result, start, end);
|
|
70
|
+
}
|
|
71
|
+
// Trace from entity to point
|
|
72
|
+
fromEntity(entity, target, options = {}) {
|
|
73
|
+
const entityObj = typeof entity === 'number' ?
|
|
74
|
+
nodemod.eng.pEntityOfEntIndex(entity) : entity;
|
|
75
|
+
if (!entityObj)
|
|
76
|
+
return null;
|
|
77
|
+
const start = [
|
|
78
|
+
entityObj.origin[0],
|
|
79
|
+
entityObj.origin[1],
|
|
80
|
+
entityObj.origin[2] + (entityObj.view_ofs?.[2] || 0)
|
|
81
|
+
];
|
|
82
|
+
const end = Array.isArray(target) ? target : [
|
|
83
|
+
target.origin[0],
|
|
84
|
+
target.origin[1],
|
|
85
|
+
target.origin[2] + 16
|
|
86
|
+
];
|
|
87
|
+
return this.line(start, end, { ...options, ignore: entityObj });
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Checks if one entity has line of sight to another entity.
|
|
91
|
+
* Automatically adjusts for entity view offset and target positioning.
|
|
92
|
+
*
|
|
93
|
+
* @param entity1 - Source entity or entity index
|
|
94
|
+
* @param entity2 - Target entity or entity index
|
|
95
|
+
* @param options - Trace configuration options
|
|
96
|
+
* @returns True if entity1 can see entity2, false otherwise
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* // Check if player can see another player
|
|
101
|
+
* const canSee = nodemodCore.trace.canSee(player1, player2);
|
|
102
|
+
* if (canSee) {
|
|
103
|
+
* console.log('Player 1 can see Player 2');
|
|
104
|
+
* }
|
|
105
|
+
*
|
|
106
|
+
* // Check line of sight ignoring other players
|
|
107
|
+
* const canSeeIgnoringPlayers = nodemodCore.trace.canSee(sniper, target, {
|
|
108
|
+
* flags: nodemod.IGNORE.MONSTERS
|
|
109
|
+
* });
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
canSee(entity1, entity2, options = {}) {
|
|
113
|
+
const entity2Obj = typeof entity2 === 'number' ? nodemod.eng.pEntityOfEntIndex(entity2) : entity2;
|
|
114
|
+
if (!entity2Obj)
|
|
115
|
+
return false;
|
|
116
|
+
const trace = this.fromEntity(entity1, entity2Obj, options);
|
|
117
|
+
return trace !== null && (trace.fraction >= 1.0 || trace.hitEntity === entity2);
|
|
118
|
+
}
|
|
119
|
+
// Trace downward to find ground
|
|
120
|
+
findGround(origin, distance = 4096) {
|
|
121
|
+
const start = [...origin];
|
|
122
|
+
const end = [origin[0], origin[1], origin[2] - distance];
|
|
123
|
+
return this.line(start, end, { flags: 1 /* nodemod.IGNORE.MONSTERS */ });
|
|
124
|
+
}
|
|
125
|
+
// Trace sphere/hull
|
|
126
|
+
sphere(start, end, radius, options = {}) {
|
|
127
|
+
// traceSphere requires Entity, not Entity | null, so provide a fallback
|
|
128
|
+
const ignoreEntity = options.ignore || nodemod.eng.pEntityOfEntIndex(0); // Use world entity as fallback
|
|
129
|
+
const result = nodemod.eng.traceSphere(start, end, options.flags || 0, radius, ignoreEntity);
|
|
130
|
+
return this.enhanceTraceResult(result, start, end);
|
|
131
|
+
}
|
|
132
|
+
// Trace with monster hull
|
|
133
|
+
monsterHull(entity, start, end, options = {}) {
|
|
134
|
+
// traceMonsterHull requires Entity, not Entity | null
|
|
135
|
+
const ignoreEntity = options.ignore || nodemod.eng.pEntityOfEntIndex(0); // Use world entity as fallback
|
|
136
|
+
return nodemod.eng.traceMonsterHull(entity, start, end, options.flags || 0, ignoreEntity);
|
|
137
|
+
}
|
|
138
|
+
// Trace for texture information
|
|
139
|
+
texture(entity, start, end) {
|
|
140
|
+
return nodemod.eng.traceTexture(entity, start, end);
|
|
141
|
+
}
|
|
142
|
+
// Trace projectile path
|
|
143
|
+
projectile(entity, ignore = null) {
|
|
144
|
+
const result = nodemod.eng.traceToss(entity, ignore || entity);
|
|
145
|
+
return this.enhanceTraceResult(result);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Analyzes the contents of a specific point in 3D space.
|
|
149
|
+
* Useful for checking if a position is in water, solid matter, or empty space.
|
|
150
|
+
*
|
|
151
|
+
* @param point - 3D coordinates [x, y, z] to check
|
|
152
|
+
* @returns Detailed information about what exists at that point
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* // Check if a position is safe for teleporting
|
|
157
|
+
* const contents = nodemodCore.trace.pointContents([100, 200, 300]);
|
|
158
|
+
* if (contents.isEmpty) {
|
|
159
|
+
* console.log('Safe to teleport');
|
|
160
|
+
* } else if (contents.isWater) {
|
|
161
|
+
* console.log('Position is underwater');
|
|
162
|
+
* } else if (contents.isSolid) {
|
|
163
|
+
* console.log('Position is inside a wall');
|
|
164
|
+
* }
|
|
165
|
+
*
|
|
166
|
+
* // Check multiple points
|
|
167
|
+
* const positions = [[0,0,0], [100,100,100], [200,200,200]];
|
|
168
|
+
* positions.forEach((pos, i) => {
|
|
169
|
+
* const result = nodemodCore.trace.pointContents(pos);
|
|
170
|
+
* console.log(`Point ${i}: ${result.isEmpty ? 'empty' : 'occupied'}`);
|
|
171
|
+
* });
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
pointContents(point) {
|
|
175
|
+
const contents = nodemod.eng.pointContents(point);
|
|
176
|
+
return {
|
|
177
|
+
contents,
|
|
178
|
+
isEmpty: contents === -1 /* nodemod.CONTENTS.EMPTY */,
|
|
179
|
+
isSolid: contents === -2 /* nodemod.CONTENTS.SOLID */,
|
|
180
|
+
isWater: contents === -3 /* nodemod.CONTENTS.WATER */,
|
|
181
|
+
isSlime: contents === -4 /* nodemod.CONTENTS.SLIME */,
|
|
182
|
+
isLava: contents === -5 /* nodemod.CONTENTS.LAVA */,
|
|
183
|
+
isSky: contents === -6 /* nodemod.CONTENTS.SKY */
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
// Enhanced trace result with utility methods
|
|
187
|
+
enhanceTraceResult(result, start = null, end = null) {
|
|
188
|
+
if (!result)
|
|
189
|
+
return null;
|
|
190
|
+
const distance = start && end ? (() => {
|
|
191
|
+
const dx = end[0] - start[0];
|
|
192
|
+
const dy = end[1] - start[1];
|
|
193
|
+
const dz = end[2] - start[2];
|
|
194
|
+
const totalDistance = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
195
|
+
return totalDistance * result.fraction;
|
|
196
|
+
})() : result.fraction;
|
|
197
|
+
const hitPoint = start && end ? [
|
|
198
|
+
start[0] + (end[0] - start[0]) * result.fraction,
|
|
199
|
+
start[1] + (end[1] - start[1]) * result.fraction,
|
|
200
|
+
start[2] + (end[2] - start[2]) * result.fraction
|
|
201
|
+
] : result.endPos;
|
|
202
|
+
return {
|
|
203
|
+
...result,
|
|
204
|
+
distance,
|
|
205
|
+
hitPoint,
|
|
206
|
+
didHit: result.fraction < 1.0,
|
|
207
|
+
hitSky: result.inOpen,
|
|
208
|
+
hitWater: result.inWater,
|
|
209
|
+
hitEntity: result.hit,
|
|
210
|
+
hitSurface: result.fraction < 1.0 && !!result.planeNormal
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
// Batch tracing utilities
|
|
214
|
+
// Trace multiple lines at once
|
|
215
|
+
multiLine(traces) {
|
|
216
|
+
return traces.map((trace) => {
|
|
217
|
+
if (Array.isArray(trace)) {
|
|
218
|
+
return this.line(trace[0], trace[1], trace[2] || {});
|
|
219
|
+
}
|
|
220
|
+
return this.line(trace.start, trace.end, trace.options || {});
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
// Find closest surface in direction
|
|
224
|
+
findClosestSurface(origin, direction, maxDistance = 4096) {
|
|
225
|
+
const normalized = this.normalizeVector(direction);
|
|
226
|
+
const end = [
|
|
227
|
+
origin[0] + normalized[0] * maxDistance,
|
|
228
|
+
origin[1] + normalized[1] * maxDistance,
|
|
229
|
+
origin[2] + normalized[2] * maxDistance
|
|
230
|
+
];
|
|
231
|
+
return this.line(origin, end);
|
|
232
|
+
}
|
|
233
|
+
// Trace in all cardinal directions
|
|
234
|
+
traceCardinal(origin, distance = 512) {
|
|
235
|
+
const directions = [
|
|
236
|
+
[1, 0, 0], // East
|
|
237
|
+
[-1, 0, 0], // West
|
|
238
|
+
[0, 1, 0], // North
|
|
239
|
+
[0, -1, 0], // South
|
|
240
|
+
[0, 0, 1], // Up
|
|
241
|
+
[0, 0, -1] // Down
|
|
242
|
+
];
|
|
243
|
+
const results = {};
|
|
244
|
+
const labels = ['east', 'west', 'north', 'south', 'up', 'down'];
|
|
245
|
+
directions.forEach((dir, i) => {
|
|
246
|
+
const end = [
|
|
247
|
+
origin[0] + dir[0] * distance,
|
|
248
|
+
origin[1] + dir[1] * distance,
|
|
249
|
+
origin[2] + dir[2] * distance
|
|
250
|
+
];
|
|
251
|
+
results[labels[i]] = this.line(origin, end);
|
|
252
|
+
});
|
|
253
|
+
return results;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Checks if a rectangular area is clear of obstacles by testing all corners.
|
|
257
|
+
* Useful for verifying if there's enough space to place objects or teleport players.
|
|
258
|
+
*
|
|
259
|
+
* @param center - Center point of the area [x, y, z]
|
|
260
|
+
* @param size - Dimensions of the area [width, length, height] (default: [64, 64, 64])
|
|
261
|
+
* @returns True if the entire area is clear, false if any part is blocked
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* // Check if there's space for a player
|
|
266
|
+
* const playerSize = [32, 32, 72]; // Typical player dimensions
|
|
267
|
+
* const isClear = nodemodCore.trace.isAreaClear([100, 200, 300], playerSize);
|
|
268
|
+
* if (isClear) {
|
|
269
|
+
* console.log('Safe to spawn player here');
|
|
270
|
+
* }
|
|
271
|
+
*
|
|
272
|
+
* // Check default 64x64x64 area
|
|
273
|
+
* const canPlaceItem = nodemodCore.trace.isAreaClear([50, 50, 50]);
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
isAreaClear(center, size = [64, 64, 64]) {
|
|
277
|
+
const halfSize = [size[0] / 2, size[1] / 2, size[2] / 2];
|
|
278
|
+
const corners = [
|
|
279
|
+
[center[0] - halfSize[0], center[1] - halfSize[1], center[2] - halfSize[2]],
|
|
280
|
+
[center[0] + halfSize[0], center[1] - halfSize[1], center[2] - halfSize[2]],
|
|
281
|
+
[center[0] - halfSize[0], center[1] + halfSize[1], center[2] - halfSize[2]],
|
|
282
|
+
[center[0] + halfSize[0], center[1] + halfSize[1], center[2] - halfSize[2]],
|
|
283
|
+
[center[0] - halfSize[0], center[1] - halfSize[1], center[2] + halfSize[2]],
|
|
284
|
+
[center[0] + halfSize[0], center[1] - halfSize[1], center[2] + halfSize[2]],
|
|
285
|
+
[center[0] - halfSize[0], center[1] + halfSize[1], center[2] + halfSize[2]],
|
|
286
|
+
[center[0] + halfSize[0], center[1] + halfSize[1], center[2] + halfSize[2]]
|
|
287
|
+
];
|
|
288
|
+
return corners.every(corner => {
|
|
289
|
+
const contents = this.pointContents(corner);
|
|
290
|
+
return contents.isEmpty;
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
// Vector utilities
|
|
294
|
+
normalizeVector(vector) {
|
|
295
|
+
const length = Math.sqrt(vector[0] * vector[0] + vector[1] * vector[1] + vector[2] * vector[2]);
|
|
296
|
+
if (length === 0)
|
|
297
|
+
return [0, 0, 0];
|
|
298
|
+
return [vector[0] / length, vector[1] / length, vector[2] / length];
|
|
299
|
+
}
|
|
300
|
+
vectorLength(vector) {
|
|
301
|
+
return Math.sqrt(vector[0] * vector[0] + vector[1] * vector[1] + vector[2] * vector[2]);
|
|
302
|
+
}
|
|
303
|
+
vectorDistance(v1, v2) {
|
|
304
|
+
const dx = v2[0] - v1[0];
|
|
305
|
+
const dy = v2[1] - v1[1];
|
|
306
|
+
const dz = v2[2] - v1[2];
|
|
307
|
+
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
exports.default = NodemodTrace;
|
|
311
|
+
//# sourceMappingURL=trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../src/enhanced/trace.ts"],"names":[],"mappings":";;AAoDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAqB,YAAY;IAE/B;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,IAAI,CAAC,KAAe,EAAE,GAAa,EAAE,UAAwB,EAAE;QAC7D,MAAM,EACJ,KAAK,GAAG,CAAC,EACT,MAAM,GAAG,IAAI,EACb,QAAQ,GAAG,CAAC,EACb,GAAG,OAAO,CAAC;QAEZ,IAAI,MAA2B,CAAC;QAEhC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;YACjB,+CAA+C;YAC/C,MAAM,YAAY,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,+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AAM,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;IACtE,CAAC;IAED,YAAY,CAAC,MAAgB;QAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1F,CAAC;IAED,cAAc,CAAC,EAAY,EAAE,EAAY;QACvC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACzB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IAChD,CAAC;CACF;AApUD,+BAoUC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/// <reference path="./types/index.d.ts" />
|
|
2
|
+
import NodemodCmd from './core/cmd';
|
|
3
|
+
import NodemodMenu from './core/menu';
|
|
4
|
+
import NodemodMsg from './core/msg';
|
|
5
|
+
import NodemodResource from './core/resource';
|
|
6
|
+
import NodemodSound from './core/sound';
|
|
7
|
+
import NodemodCVar from './native/cvar';
|
|
8
|
+
import NodemodFile from './native/file';
|
|
9
|
+
import NodemodEvents from './enhanced/events';
|
|
10
|
+
import NodemodPlayer from './enhanced/player';
|
|
11
|
+
import NodemodEntity from './enhanced/entity';
|
|
12
|
+
import NodemodTrace from './enhanced/trace';
|
|
13
|
+
import NodemodUtil from './utils/util';
|
|
14
|
+
/**
|
|
15
|
+
* Main NodeMod Core class providing unified access to all NodeMod services
|
|
16
|
+
*
|
|
17
|
+
* This class serves as the central hub for all NodeMod functionality, providing
|
|
18
|
+
* easy access to various services including messaging, entity management,
|
|
19
|
+
* player utilities, and Half-Life engine interactions.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // Access the global nodemodCore instance
|
|
24
|
+
* nodemodCore.util.messageAll("Hello world!");
|
|
25
|
+
* nodemodCore.player.getAll().forEach(player => {
|
|
26
|
+
* console.log(`Player: ${player.name}`);
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare class NodemodCore {
|
|
31
|
+
/** Console variable management service */
|
|
32
|
+
readonly cvar: NodemodCVar;
|
|
33
|
+
/** File system operations service */
|
|
34
|
+
readonly file: NodemodFile;
|
|
35
|
+
/** Network messaging service */
|
|
36
|
+
readonly msg: NodemodMsg;
|
|
37
|
+
/** General utility functions */
|
|
38
|
+
readonly util: NodemodUtil;
|
|
39
|
+
/** Sound management service */
|
|
40
|
+
readonly sound: NodemodSound;
|
|
41
|
+
/** Command registration and handling service */
|
|
42
|
+
readonly cmd: NodemodCmd;
|
|
43
|
+
/** Resource management service */
|
|
44
|
+
readonly resource: NodemodResource;
|
|
45
|
+
/** Menu creation and display service */
|
|
46
|
+
readonly menu: NodemodMenu;
|
|
47
|
+
/** Event handling service */
|
|
48
|
+
readonly events: NodemodEvents;
|
|
49
|
+
/** Player management and utilities */
|
|
50
|
+
readonly player: NodemodPlayer;
|
|
51
|
+
/** Entity management and utilities */
|
|
52
|
+
readonly entity: NodemodEntity;
|
|
53
|
+
/** Trace and collision detection service */
|
|
54
|
+
readonly trace: NodemodTrace;
|
|
55
|
+
/** Current working directory of the game server */
|
|
56
|
+
get cwd(): string;
|
|
57
|
+
/** Current map name */
|
|
58
|
+
get mapname(): string;
|
|
59
|
+
/** Current server time */
|
|
60
|
+
get time(): number;
|
|
61
|
+
/** Array of all connected player entities */
|
|
62
|
+
get players(): nodemod.Entity[];
|
|
63
|
+
/**
|
|
64
|
+
* Get the message ID for a user message name
|
|
65
|
+
* @param msgName The name of the user message
|
|
66
|
+
* @returns The message ID
|
|
67
|
+
*/
|
|
68
|
+
getUserMsgId(msgName: string): number;
|
|
69
|
+
/**
|
|
70
|
+
* Get the message name for a user message ID
|
|
71
|
+
* @param msgId The message ID
|
|
72
|
+
* @returns The message name
|
|
73
|
+
*/
|
|
74
|
+
getUserMsgName(msgId: number): string;
|
|
75
|
+
/**
|
|
76
|
+
* Set the metamod result for the current hook
|
|
77
|
+
* @param result The metamod result constant
|
|
78
|
+
*/
|
|
79
|
+
setMetaResult(result: nodemod.META_RES): void;
|
|
80
|
+
/**
|
|
81
|
+
* Continue server execution (used with metamod hooks)
|
|
82
|
+
*/
|
|
83
|
+
continueServer(): void;
|
|
84
|
+
constructor();
|
|
85
|
+
}
|
|
86
|
+
declare const nodemodCore: NodemodCore;
|
|
87
|
+
export default nodemodCore;
|
|
88
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,eAAe,MAAM,iBAAiB,CAAC;AAC9C,OAAO,YAAY,MAAM,cAAc,CAAC;AAGxC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,WAAW,MAAM,eAAe,CAAC;AAGxC,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9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