@nativewrappers/redm 0.0.63 → 0.0.65
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/entities/BaseEntity.d.ts +50 -0
- package/entities/BaseEntity.js +54 -18
- package/entities/Ped.d.ts +4 -5
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +2 -3
package/entities/BaseEntity.d.ts
CHANGED
|
@@ -2,16 +2,66 @@ import { Vector3 } from "../../common/utils";
|
|
|
2
2
|
export declare class BaseEntity {
|
|
3
3
|
private handle;
|
|
4
4
|
constructor(entHandle: number);
|
|
5
|
+
/**
|
|
6
|
+
* Replaces the current handle for the entity used on, this hsould be used sparringly, mainly
|
|
7
|
+
* in situations where you're going to reuse an entity over and over and don't want to make a
|
|
8
|
+
* new entity every time.
|
|
9
|
+
*
|
|
10
|
+
* **WARNING**: This does no checks, if you provide it an invalid entity it will use it
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const REUSABLE_ENTITY = new Entity(entityHandle);
|
|
14
|
+
*
|
|
15
|
+
* onNet("entityHandler", (entNetId: number) => {
|
|
16
|
+
* // if no net entity we should ignore
|
|
17
|
+
* if (!NetworkDoesEntityExistWithNetworkId(entNetId)) return;
|
|
18
|
+
*
|
|
19
|
+
* // Reuse our entity so we don't have to initialize a new one
|
|
20
|
+
* REUSABLE_ENTITY.replaceHandle(NetworkGetEntityFromNetworkId(entNetId));
|
|
21
|
+
* // Do something with REUSABLE_ENTITY entity
|
|
22
|
+
* })
|
|
23
|
+
```
|
|
24
|
+
*/
|
|
5
25
|
replaceHandle(newHandle: number): void;
|
|
26
|
+
/**
|
|
27
|
+
* @returns the network for the specified entity, this doesn't check if the entity is networked, you should use {@link BaseEntity.IsNetworked}
|
|
28
|
+
*/
|
|
29
|
+
get NetworkId(): number;
|
|
30
|
+
/**
|
|
31
|
+
* @returns `true` if the current entity is networked, false otherwise
|
|
32
|
+
*/
|
|
33
|
+
get IsNetworked(): boolean;
|
|
6
34
|
/**
|
|
7
35
|
* @returns Returns true if the entity handle is not 0 and exists in the game engine
|
|
8
36
|
*/
|
|
9
37
|
get Exists(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* @returns The entitys current handle.
|
|
40
|
+
*/
|
|
10
41
|
get Handle(): number;
|
|
42
|
+
/**
|
|
43
|
+
* @param amount the health to set the health to, setting to `0` will kill the entity, if using on a {@link Ped} you should check the MaxHealth before setting.
|
|
44
|
+
*/
|
|
11
45
|
set Health(amount: number);
|
|
46
|
+
/**
|
|
47
|
+
* @returns the amount of health the current {@link BaseEntity} has
|
|
48
|
+
*/
|
|
12
49
|
get Health(): number;
|
|
50
|
+
/**
|
|
51
|
+
* @returns the heading of the current {@link BaseEntity}
|
|
52
|
+
*/
|
|
13
53
|
get Heading(): number;
|
|
54
|
+
/**
|
|
55
|
+
* @param heading sets the entitys heading to the specified heading, this can be in the range of 0..360
|
|
56
|
+
*/
|
|
14
57
|
set Heading(heading: number);
|
|
58
|
+
/**
|
|
59
|
+
* @returns the position of the current Entity
|
|
60
|
+
*/
|
|
15
61
|
get Position(): Vector3;
|
|
62
|
+
/**
|
|
63
|
+
* You should (almost) always try to load the collisions before setting the entitys position if going a long distance.
|
|
64
|
+
* @param pos sets the position for the current ped
|
|
65
|
+
*/
|
|
16
66
|
set Position(pos: Vector3);
|
|
17
67
|
}
|
package/entities/BaseEntity.js
CHANGED
|
@@ -4,51 +4,87 @@ export class BaseEntity {
|
|
|
4
4
|
constructor(entHandle) {
|
|
5
5
|
this.handle = entHandle;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Replaces the current handle for the entity used on, this hsould be used sparringly, mainly
|
|
9
|
+
* in situations where you're going to reuse an entity over and over and don't want to make a
|
|
10
|
+
* new entity every time.
|
|
11
|
+
*
|
|
12
|
+
* **WARNING**: This does no checks, if you provide it an invalid entity it will use it
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* const REUSABLE_ENTITY = new Entity(entityHandle);
|
|
16
|
+
*
|
|
17
|
+
* onNet("entityHandler", (entNetId: number) => {
|
|
18
|
+
* // if no net entity we should ignore
|
|
19
|
+
* if (!NetworkDoesEntityExistWithNetworkId(entNetId)) return;
|
|
20
|
+
*
|
|
21
|
+
* // Reuse our entity so we don't have to initialize a new one
|
|
22
|
+
* REUSABLE_ENTITY.replaceHandle(NetworkGetEntityFromNetworkId(entNetId));
|
|
23
|
+
* // Do something with REUSABLE_ENTITY entity
|
|
24
|
+
* })
|
|
25
|
+
```
|
|
26
|
+
*/
|
|
25
27
|
replaceHandle(newHandle) {
|
|
26
28
|
this.handle = newHandle;
|
|
27
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* @returns the network for the specified entity, this doesn't check if the entity is networked, you should use {@link BaseEntity.IsNetworked}
|
|
32
|
+
*/
|
|
33
|
+
get NetworkId() {
|
|
34
|
+
return NetworkGetNetworkIdFromEntity(this.Handle);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @returns `true` if the current entity is networked, false otherwise
|
|
38
|
+
*/
|
|
39
|
+
get IsNetworked() {
|
|
40
|
+
return NetworkGetEntityIsNetworked(this.Handle);
|
|
41
|
+
}
|
|
28
42
|
/**
|
|
29
43
|
* @returns Returns true if the entity handle is not 0 and exists in the game engine
|
|
30
44
|
*/
|
|
31
45
|
get Exists() {
|
|
32
46
|
return this.handle !== 0 && DoesEntityExist(this.Handle);
|
|
33
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* @returns The entitys current handle.
|
|
50
|
+
*/
|
|
34
51
|
get Handle() {
|
|
35
52
|
return this.handle;
|
|
36
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* @param amount the health to set the health to, setting to `0` will kill the entity, if using on a {@link Ped} you should check the MaxHealth before setting.
|
|
56
|
+
*/
|
|
37
57
|
set Health(amount) {
|
|
38
58
|
SetEntityHealth(this.Handle, amount, 0);
|
|
39
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* @returns the amount of health the current {@link BaseEntity} has
|
|
62
|
+
*/
|
|
40
63
|
get Health() {
|
|
41
64
|
return GetEntityHealth(this.Handle);
|
|
42
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* @returns the heading of the current {@link BaseEntity}
|
|
68
|
+
*/
|
|
43
69
|
get Heading() {
|
|
44
70
|
return GetEntityHeading(this.Handle);
|
|
45
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* @param heading sets the entitys heading to the specified heading, this can be in the range of 0..360
|
|
74
|
+
*/
|
|
46
75
|
set Heading(heading) {
|
|
47
76
|
SetEntityHeading(this.Handle, heading);
|
|
48
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* @returns the position of the current Entity
|
|
80
|
+
*/
|
|
49
81
|
get Position() {
|
|
50
82
|
return Vector3.fromArray(GetEntityCoords(this.handle, true, true));
|
|
51
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* You should (almost) always try to load the collisions before setting the entitys position if going a long distance.
|
|
86
|
+
* @param pos sets the position for the current ped
|
|
87
|
+
*/
|
|
52
88
|
set Position(pos) {
|
|
53
89
|
SetEntityCoords(this.handle, pos.x, pos.y, pos.z, false, false, false, false);
|
|
54
90
|
}
|
package/entities/Ped.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { Vector3 } from "../utils";
|
|
|
5
5
|
import { BaseEntity } from "./BaseEntity";
|
|
6
6
|
import { Vehicle } from "./Vehicle";
|
|
7
7
|
import { Player } from "./Player";
|
|
8
|
-
export type OptionalPed = Ped | null;
|
|
9
8
|
export declare class Ped extends BaseEntity {
|
|
10
9
|
private attributes;
|
|
11
10
|
constructor(handle: number);
|
|
@@ -50,15 +49,15 @@ export declare class Ped extends BaseEntity {
|
|
|
50
49
|
/**
|
|
51
50
|
* @returns the last mount that this ped was on, or null if it doesn't exist
|
|
52
51
|
*/
|
|
53
|
-
get Mount():
|
|
52
|
+
get Mount(): Ped | null;
|
|
54
53
|
/**
|
|
55
54
|
* returns the horse that this ped is leading
|
|
56
55
|
*/
|
|
57
|
-
get LeadingHorse():
|
|
56
|
+
get LeadingHorse(): Ped | null;
|
|
58
57
|
/**
|
|
59
58
|
* returns the owner of the current animal
|
|
60
59
|
*/
|
|
61
|
-
get Owner():
|
|
60
|
+
get Owner(): Ped | null;
|
|
62
61
|
get TamingState(): TamingState;
|
|
63
62
|
get IsInteractingWithAnimal(): boolean;
|
|
64
63
|
get IsSittingInAnyVehicle(): boolean;
|
|
@@ -149,7 +148,7 @@ export declare class Ped extends BaseEntity {
|
|
|
149
148
|
* @param amount - the amount of armour to add to the ped
|
|
150
149
|
*/
|
|
151
150
|
addArmour(amount: number): void;
|
|
152
|
-
applyDamage(damageAmount: number, boneId?: number, pedKiller?:
|
|
151
|
+
applyDamage(damageAmount: number, boneId?: number, pedKiller?: Ped | null): void;
|
|
153
152
|
/**
|
|
154
153
|
* @param damagePack - the damage decal to apply see [here](https://github.com/femga/rdr3_discoveries/blob/master/peds_customization/ped_decals.lua) for more documentation
|
|
155
154
|
* @param damage - the damage to apply
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nativewrappers/redm",
|
|
3
3
|
"description": "Native wrappers and utilities for use with RedM.",
|
|
4
|
-
"author": "Remco Troost <d0p3t>",
|
|
5
4
|
"license": "MIT",
|
|
6
5
|
"type": "module",
|
|
7
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.65",
|
|
8
7
|
"repository": {
|
|
9
8
|
"type": "git",
|
|
10
9
|
"url": "https://github.com/nativewrappers/nativewrappers.git"
|
|
@@ -28,6 +27,6 @@
|
|
|
28
27
|
".": "./index.js"
|
|
29
28
|
},
|
|
30
29
|
"dependencies": {
|
|
31
|
-
"@nativewrappers/common": "0.0.
|
|
30
|
+
"@nativewrappers/common": "0.0.65"
|
|
32
31
|
}
|
|
33
32
|
}
|