From 7537a32edc2cb7e47343edd79a85d612450bb78b Mon Sep 17 00:00:00 2001 From: Laura Date: Sun, 22 Sep 2024 15:32:56 +0200 Subject: [PATCH 1/4] document 2 force natives --- ENTITY/ApplyForceToEntity.md | 92 ++++++++++-------------- ENTITY/ApplyForceToEntityCenterOfMass.md | 37 +++------- 2 files changed, 49 insertions(+), 80 deletions(-) diff --git a/ENTITY/ApplyForceToEntity.md b/ENTITY/ApplyForceToEntity.md index 0e990cae5..a8cbb9e81 100644 --- a/ENTITY/ApplyForceToEntity.md +++ b/ENTITY/ApplyForceToEntity.md @@ -5,78 +5,62 @@ ns: ENTITY ```c // 0xC5F68BE9613E2D18 0xC1C0855A -void APPLY_FORCE_TO_ENTITY(Entity entity, int forceType, float x, float y, float z, float offX, float offY, float offZ, int boneIndex, BOOL isDirectionRel, BOOL ignoreUpVec, BOOL isForceRel, BOOL p12, BOOL p13); +void APPLY_FORCE_TO_ENTITY(Entity entity, int forceType, float x, float y, float z, float offX, float offY, float offZ, int nComponent, BOOL bLocalForce, BOOL bLocalOffset, BOOL bScaleByMass, BOOL bPlayAudio, BOOL bScaleByTimeWarp); ``` -Applies a force to the specified entity. +Apply a force to an entity. -**List of force types (p1)**: - -``` -public enum ForceType -{ - MinForce = 0, - MaxForceRot = 1, - MinForce2 = 2, - MaxForceRot2 = 3, - ForceNoRot = 4, - ForceRotPlusForce = 5 +```cpp +enum eCommandApplyForceTypes { + APPLY_TYPE_FORCE = 0, + APPLY_TYPE_IMPULSE = 1, + APPLY_TYPE_EXTERNAL_FORCE = 2, + APPLY_TYPE_EXTERNAL_IMPULSE = 3, + APPLY_TYPE_TORQUE = 4, + APPLY_TYPE_ANGULAR_IMPULSE = 5 } ``` -Research/documentation on the gtaforums can be found [here](https://gtaforums.com/topic/885669-precisely-define-object-physics/) and [here](https://gtaforums.com/topic/887362-apply-forces-and-momentums-to-entityobject/). - - ## Parameters -* **entity**: The entity you want to apply a force on -* **forceType**: See native description above for a list of commonly used values -* **x**: Force amount (X) -* **y**: Force amount (Y) -* **z**: Force amount (Z) -* **offX**: Rotation/offset force (X) -* **offY**: Rotation/offset force (Y) -* **offZ**: Rotation/offset force (Z) -* **boneIndex**: (Often 0) Entity bone index -* **isDirectionRel**: (Usually false) Vector defined in local (body-fixed) coordinate frame -* **ignoreUpVec**: (Usually true) -* **isForceRel**: (Usually true) When true, force gets multiplied with the objects mass and different objects will have the same acceleration -* **p12**: (Usually false) -* **p13**: (Usually true) - +* **entity**: The entity handle +* **forceType**: The force type +* **x**: The x component of the force to apply +* **y**: The y component of the force to apply +* **z**: The z component of the force to apply +* **offX**: Offset from center of entity (X) +* **offY**: Offset from center of entity (Y) +* **offZ**: Offset from center of entity (Z) +* **nComponent**: Component of the entity to apply the force too. Only matters for breakable or articulated (ragdoll) physics. 0 means the root or parent component +* **bLocalForce**: Specifies whether the force vector passed in is in local or world coordinates. `true` means the force will get automatically transformed into world space before being applied +* **bLocalOffset**: Specifies whether the offset passed in is in local or world coordinates +* **bScaleByMass**: Specifies whether to scale the force by mass +* **bPlayAudio**: Specifies whether to play audio events related to the force being applied. The audio will depend on the entity type. Currently vehicles are the only entity types supported, and will play a suspension squeal depending on the magnitude of the force +* **bScaleByTimeWarp**: Specifies whether to scale the force by time warp. Default is `true` ## Examples ```lua -local forceTypes = { - MinForce = 0, - MaxForceRot = 1, - MinForce2 = 2, - MaxForceRot2 = 3, - ForceNoRot = 4, - ForceRotPlusForce = 5 -} - local entity = PlayerPedId() -local forceType = forceTypes.MaxForceRot2 +local forceType = 2 -- sends the entity straight up into the sky: local direction = vector3(0.0, 0.0, 15.0) -local rotation = vector3(0.0, 0.0, 0.0) -local boneIndex = 0 -local isDirectionRel = false -local ignoreUpVec = true -local isForceRel = true -local p12 = false -local p13 = true +local offset = vector3(0.0, 0.0, 0.0) +local component = 0 +local localForce = false +local localOffset = true +local scaleByMass = true +local playAudio = false +local scaleByTimeWarp = true ApplyForceToEntity( entity, forceType, direction, - rotation, + offset, boneIndex, - isDirectionRel, - ignoreUpVec, - isForceRel, - p12, - p13 + localForce, + localOffset, + scaleByMass, + playAudio, + scaleByTimeWarp ) ``` diff --git a/ENTITY/ApplyForceToEntityCenterOfMass.md b/ENTITY/ApplyForceToEntityCenterOfMass.md index 38485ce6f..0cb076f94 100644 --- a/ENTITY/ApplyForceToEntityCenterOfMass.md +++ b/ENTITY/ApplyForceToEntityCenterOfMass.md @@ -5,34 +5,19 @@ ns: ENTITY ```c // 0x18FF00FC7EFF559E 0x28924E98 -void APPLY_FORCE_TO_ENTITY_CENTER_OF_MASS(Entity entity, int forceType, float x, float y, float z, BOOL p5, BOOL isDirectionRel, BOOL isForceRel, BOOL p8); +void APPLY_FORCE_TO_ENTITY_CENTER_OF_MASS(Entity entity, int forceType, float x, float y, float z, cs_type(BOOL) int nComponent, BOOL bLocalForce, BOOL bScaleByMass, BOOL bApplyToChildren); ``` -``` -Applies a force to the specified entity. -**List of force types (p1)**: -public enum ForceType -{ - MinForce = 0, - MaxForceRot = 1, - MinForce2 = 2, - MaxForceRot2 = 3, - ForceNoRot = 4, - ForceRotPlusForce = 5 -} -Research/documentation on the gtaforums can be found here https://gtaforums.com/topic/885669-precisely-define-object-physics/) and here https://gtaforums.com/topic/887362-apply-forces-and-momentums-to-entityobject/. -p6/relative - makes the xyz force not relative to world coords, but to something else -p7/highForce - setting false will make the force really low -``` +Apply a force to an entity. ## Parameters -* **entity**: -* **forceType**: -* **x**: -* **y**: -* **z**: -* **p5**: -* **isDirectionRel**: -* **isForceRel**: -* **p8**: +* **entity**: The entity handle +* **forceType**: The force type, see [`APPLY_FORCE_TO_ENTITY`](#_0xC5F68BE9613E2D18) +* **x**: The x component of the force to apply +* **y**: The y component of the force to apply +* **z**: The z component of the force to apply +* **nComponent**: Component of the entity to apply the force too. Only matters for breakable or articulated (ragdoll) physics. 0 means the root or parent component +* **bLocalForce**: Specifies whether the force vector passed in is in local or world coordinates. `true` means the force will get automatically transformed into world space before being applied +* **bScaleByMass**: Specifies whether to scale the force by mass +* **bApplyToChildren**: Default `false`. If the force should be applied to any attached children From aa40cc3b0b04a5882167df91197ab64c4d8b6201 Mon Sep 17 00:00:00 2001 From: Laura Date: Fri, 11 Oct 2024 23:23:59 +0200 Subject: [PATCH 2/4] add back links --- ENTITY/ApplyForceToEntity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ENTITY/ApplyForceToEntity.md b/ENTITY/ApplyForceToEntity.md index a8cbb9e81..2051bb615 100644 --- a/ENTITY/ApplyForceToEntity.md +++ b/ENTITY/ApplyForceToEntity.md @@ -8,7 +8,7 @@ ns: ENTITY void APPLY_FORCE_TO_ENTITY(Entity entity, int forceType, float x, float y, float z, float offX, float offY, float offZ, int nComponent, BOOL bLocalForce, BOOL bLocalOffset, BOOL bScaleByMass, BOOL bPlayAudio, BOOL bScaleByTimeWarp); ``` -Apply a force to an entity. +Apply a force to an entity. More research/documentation on the gtaforums can be found [here](https://gtaforums.com/topic/885669-precisely-define-object-physics/) and [here](https://gtaforums.com/topic/887362-apply-forces-and-momentums-to-entityobject/). ```cpp enum eCommandApplyForceTypes { From 021e5dcd6d393e3f051280d0dcdb285b2e0cae2c Mon Sep 17 00:00:00 2001 From: Laura Date: Sat, 12 Oct 2024 01:15:23 +0200 Subject: [PATCH 3/4] add back links --- ENTITY/ApplyForceToEntityCenterOfMass.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ENTITY/ApplyForceToEntityCenterOfMass.md b/ENTITY/ApplyForceToEntityCenterOfMass.md index ac57f64c3..6267d1b9a 100644 --- a/ENTITY/ApplyForceToEntityCenterOfMass.md +++ b/ENTITY/ApplyForceToEntityCenterOfMass.md @@ -8,7 +8,7 @@ ns: ENTITY void APPLY_FORCE_TO_ENTITY_CENTER_OF_MASS(Entity entity, int forceType, float x, float y, float z, cs_type(BOOL) int nComponent, BOOL bLocalForce, BOOL bScaleByMass, BOOL bApplyToChildren); ``` -Apply a force to an entity. +Apply a force to an entity. More research/documentation on the gtaforums can be found [here](https://gtaforums.com/topic/885669-precisely-define-object-physics/) and [here](https://gtaforums.com/topic/887362-apply-forces-and-momentums-to-entityobject/). ## Parameters * **entity**: The entity handle From cdff88be6248f1f41c048c4f6090b879c128d4ae Mon Sep 17 00:00:00 2001 From: Laura Date: Mon, 28 Oct 2024 23:24:00 +0100 Subject: [PATCH 4/4] remove link --- ENTITY/ApplyForceToEntityCenterOfMass.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ENTITY/ApplyForceToEntityCenterOfMass.md b/ENTITY/ApplyForceToEntityCenterOfMass.md index 6267d1b9a..1a71ee00a 100644 --- a/ENTITY/ApplyForceToEntityCenterOfMass.md +++ b/ENTITY/ApplyForceToEntityCenterOfMass.md @@ -8,7 +8,7 @@ ns: ENTITY void APPLY_FORCE_TO_ENTITY_CENTER_OF_MASS(Entity entity, int forceType, float x, float y, float z, cs_type(BOOL) int nComponent, BOOL bLocalForce, BOOL bScaleByMass, BOOL bApplyToChildren); ``` -Apply a force to an entity. More research/documentation on the gtaforums can be found [here](https://gtaforums.com/topic/885669-precisely-define-object-physics/) and [here](https://gtaforums.com/topic/887362-apply-forces-and-momentums-to-entityobject/). +Apply a force to an entities center of mass. ## Parameters * **entity**: The entity handle