From 5d9960856e67e56946048dff26fca19241c4697a Mon Sep 17 00:00:00 2001 From: Space V <40030799+ahcenezdh@users.noreply.github.com> Date: Sun, 22 Sep 2024 18:09:15 +0200 Subject: [PATCH] feat(boat/anchor): update anchor natives (#1193) Co-authored-by: Dillon Skaggs --- VEHICLE/CanAnchorBoatHere.md | 76 +++++++++++--- VEHICLE/CanAnchorBoatHereIgnorePlayers.md | 61 ++++++++++++ VEHICLE/CanAnchorBoatHere_2.md | 19 ---- VEHICLE/IsBoatAnchored.md | 25 +++++ VEHICLE/IsBoatAnchoredAndFrozen.md | 19 ---- VEHICLE/SetBoatAnchor.md | 99 ++++++++++++++++--- VEHICLE/SetBoatFrozenWhenAnchored.md | 16 --- VEHICLE/SetBoatLowLodAnchorDistance.md | 51 ++++++++++ VEHICLE/SetBoatMovementResistance.md | 15 --- ...tBoatRemainsAnchoredWhilePlayerIsDriver.md | 50 ++++++++++ VEHICLE/SetForceLowLodAnchorMode.md | 22 +++++ VEHICLE/SetForcedBoatLocationWhenAnchored.md | 20 ---- 12 files changed, 355 insertions(+), 118 deletions(-) create mode 100644 VEHICLE/CanAnchorBoatHereIgnorePlayers.md delete mode 100644 VEHICLE/CanAnchorBoatHere_2.md create mode 100644 VEHICLE/IsBoatAnchored.md delete mode 100644 VEHICLE/IsBoatAnchoredAndFrozen.md delete mode 100644 VEHICLE/SetBoatFrozenWhenAnchored.md create mode 100644 VEHICLE/SetBoatLowLodAnchorDistance.md delete mode 100644 VEHICLE/SetBoatMovementResistance.md create mode 100644 VEHICLE/SetBoatRemainsAnchoredWhilePlayerIsDriver.md create mode 100644 VEHICLE/SetForceLowLodAnchorMode.md delete mode 100644 VEHICLE/SetForcedBoatLocationWhenAnchored.md diff --git a/VEHICLE/CanAnchorBoatHere.md b/VEHICLE/CanAnchorBoatHere.md index c8c686762..c64a79c50 100644 --- a/VEHICLE/CanAnchorBoatHere.md +++ b/VEHICLE/CanAnchorBoatHere.md @@ -1,15 +1,61 @@ ---- -ns: VEHICLE -aliases: ["0x2467A2D807D37CA3","_GET_BOAT_ANCHOR","_CAN_BOAT_BE_ANCHORED"] ---- -## CAN_ANCHOR_BOAT_HERE - -```c -// 0x26C10ECBDA5D043B 0xE97A4F5E -BOOL CAN_ANCHOR_BOAT_HERE(Vehicle vehicle); -``` - -## Parameters -* **vehicle**: - -## Return value +--- +ns: VEHICLE +aliases: ["0x2467A2D807D37CA3","_GET_BOAT_ANCHOR","_CAN_BOAT_BE_ANCHORED"] +--- +## CAN_ANCHOR_BOAT_HERE + +```c +// 0x26C10ECBDA5D043B 0xE97A4F5E +BOOL CAN_ANCHOR_BOAT_HERE(Vehicle boat); +``` + +Checks if a boat can be anchored at its present position without possibly intersecting collision later. + +``` +NativeDB Introduced: v323 +``` + +## Parameters +* **boat**: The boat to check. + +## Return value +Returns `true` if the boat can be safely anchored at its current position, `false` otherwise. + +## Examples +```lua +local boat = GetVehiclePedIsIn(PlayerPedId(), false) +if not boat or not IsThisModelABoat(GetEntityModel(boat)) then return end + +if CanAnchorBoatHere(boat) then + print("It's safe to anchor the boat here") +else + print("It's not safe to anchor the boat at this location") +end +``` + +```js +const boat = GetVehiclePedIsIn(PlayerPedId(), false); +if (!boat || !IsThisModelABoat(GetEntityModel(boat))) return; + +if (CanAnchorBoatHere(boat)) { + console.log("It's safe to anchor the boat here"); +} else { + console.log("It's not safe to anchor the boat at this location"); +} +``` + +```cs +using static CitizenFX.Core.Native.API; + +int boat = GetVehiclePedIsIn(PlayerPedId(), false); +if (boat == 0 || !IsThisModelABoat(GetEntityModel(boat))) return; + +if (CanAnchorBoatHere(boat)) +{ + Debug.WriteLine("It's safe to anchor the boat here"); +} +else +{ + Debug.WriteLine("It's not safe to anchor the boat at this location"); +} +``` \ No newline at end of file diff --git a/VEHICLE/CanAnchorBoatHereIgnorePlayers.md b/VEHICLE/CanAnchorBoatHereIgnorePlayers.md new file mode 100644 index 000000000..479a824bb --- /dev/null +++ b/VEHICLE/CanAnchorBoatHereIgnorePlayers.md @@ -0,0 +1,61 @@ +--- +ns: VEHICLE +aliases: ["_CAN_BOAT_BE_ANCHORED_2", "_CAN_ANCHOR_BOAT_HERE_2"] +--- +## CAN_ANCHOR_BOAT_HERE_IGNORE_PLAYERS + +```c +// 0x24F4121D07579880 +BOOL CAN_ANCHOR_BOAT_HERE_IGNORE_PLAYERS(Vehicle boat); +``` + +Checks if a boat can be anchored at its present position, ignoring any players standing on the boat. + +``` +NativeDB Introduced: v678 +``` + +## Parameters +* **boat**: The boat to check. + +## Return value +Returns `true` if the boat can be safely anchored at its current position (ignoring players on the boat), `false` otherwise. + +## Examples +```lua +local boat = GetVehiclePedIsIn(PlayerPedId(), false) +if not boat or not IsThisModelABoat(GetEntityModel(boat)) then return end + +if CanAnchorBoatHereIgnorePlayers(boat) then + print("It's safe to anchor the boat here, ignoring players on the boat") +else + print("It's not safe to anchor the boat at this location, even ignoring players") +end +``` + +```js +const boat = GetVehiclePedIsIn(PlayerPedId(), false); +if (!boat || !IsThisModelABoat(GetEntityModel(boat))) return; + +if (CanAnchorBoatHereIgnorePlayers(boat)) { + console.log("It's safe to anchor the boat here, ignoring players on the boat"); +} else { + console.log("It's not safe to anchor the boat at this location, even ignoring players"); +} +``` + +```cs +using static CitizenFX.Core.Native.API; + +int boat = GetVehiclePedIsIn(PlayerPedId(), false); +if (boat == 0 || !IsThisModelABoat(GetEntityModel(boat))) return; + +if (CanAnchorBoatHereIgnorePlayers(boat)) +{ + Debug.WriteLine("It's safe to anchor the boat here, ignoring players on the boat"); +} +else +{ + Debug.WriteLine("It's not safe to anchor the boat at this location, even ignoring players"); +} +``` \ No newline at end of file diff --git a/VEHICLE/CanAnchorBoatHere_2.md b/VEHICLE/CanAnchorBoatHere_2.md deleted file mode 100644 index 8bc56bfe3..000000000 --- a/VEHICLE/CanAnchorBoatHere_2.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -ns: VEHICLE -aliases: ["_CAN_BOAT_BE_ANCHORED_2"] ---- -## _CAN_ANCHOR_BOAT_HERE_2 - -```c -// 0x24F4121D07579880 -BOOL _CAN_ANCHOR_BOAT_HERE_2(Vehicle vehicle); -``` - -``` -Differs from 0x26C10ECBDA5D043B in that 0x140EFCC10 (1604 retail) is called with a2 = true. - -NativeDB Introduced: v678 -``` - -## Parameters -* **vehicle**: diff --git a/VEHICLE/IsBoatAnchored.md b/VEHICLE/IsBoatAnchored.md new file mode 100644 index 000000000..5c5c2d92b --- /dev/null +++ b/VEHICLE/IsBoatAnchored.md @@ -0,0 +1,25 @@ +--- +ns: VEHICLE +aliases: ["0xB0AD1238A709B1A2", "_IS_BOAT_ANCHORED_AND_FROZEN"] +--- +## IS_BOAT_ANCHORED + +```c +// 0xB0AD1238A709B1A2 +BOOL IS_BOAT_ANCHORED(Vehicle boat); +``` + +Checks if a boat is currently anchored. + +This native is a getter for [SET_BOAT_ANCHOR](#_0x75DBEC174AEEAD10). + + +``` +NativeDB Introduced: v573 +``` + +## Parameters +* **boat**: The boat to check. + +## Return value +Returns `true` if the boat is currently anchored, `false` otherwise. \ No newline at end of file diff --git a/VEHICLE/IsBoatAnchoredAndFrozen.md b/VEHICLE/IsBoatAnchoredAndFrozen.md deleted file mode 100644 index 9b314555d..000000000 --- a/VEHICLE/IsBoatAnchoredAndFrozen.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -ns: VEHICLE -aliases: ["0xB0AD1238A709B1A2"] ---- -## _IS_BOAT_ANCHORED_AND_FROZEN - -```c -// 0xB0AD1238A709B1A2 -BOOL _IS_BOAT_ANCHORED_AND_FROZEN(Vehicle vehicle); -``` - -``` -IS_* -``` - -## Parameters -* **vehicle**: - -## Return value diff --git a/VEHICLE/SetBoatAnchor.md b/VEHICLE/SetBoatAnchor.md index 965c5b3ad..3ba98ec2d 100644 --- a/VEHICLE/SetBoatAnchor.md +++ b/VEHICLE/SetBoatAnchor.md @@ -1,14 +1,85 @@ ---- -ns: VEHICLE ---- -## SET_BOAT_ANCHOR - -```c -// 0x75DBEC174AEEAD10 0xA3906284 -void SET_BOAT_ANCHOR(Vehicle vehicle, BOOL toggle); -``` - -## Parameters -* **vehicle**: -* **toggle**: - +--- +ns: VEHICLE +--- +## SET_BOAT_ANCHOR + +```c +// 0x75DBEC174AEEAD10 0xA3906284 +void SET_BOAT_ANCHOR(Vehicle boat, BOOL toggle); +``` + +Sets the anchor state for a boat. + +``` +NativeDB Introduced: v323 +``` + +**Note**: You might want to check if you can use your anchor before with [CAN_ANCHOR_BOAT_HERE](#_0x26C10ECBDA5D043B). + +## Parameters +* **boat**: The target boat. +* **toggle**: Set the anchor state `true` deploys the anchor, false `raises` it. + +## Examples +```lua +local boat = GetVehiclePedIsIn(PlayerPedId(), false) +if not boat or not IsThisModelABoat(GetEntityModel(boat)) then return end + +-- Check if we can anchor the boat here +if CanAnchorBoatHere(boat) then + -- Deploy the boat's anchor + SetBoatAnchor(boat, true) + + -- Wait for 10 seconds + Wait(10000) + + -- Raise the boat's anchor + SetBoatAnchor(boat, false) +else + print("Cannot anchor the boat at this location") +end +``` + +```js +const boat = GetVehiclePedIsIn(PlayerPedId(), false); +if (!boat || !IsThisModelABoat(GetEntityModel(boat))) return; + +// Check if we can anchor the boat here +if (CanAnchorBoatHere(boat)) { + // Deploy the boat's anchor + SetBoatAnchor(boat, true); + + // Wait for 10 seconds + await new Promise(resolve => setTimeout(resolve, 10000)); + + // Raise the boat's anchor + SetBoatAnchor(boat, false); +} else { + console.log("Cannot anchor the boat at this location"); +} +``` + +```cs +using CitizenFX.Core; +using static CitizenFX.Core.Native.API; + +int boat = GetVehiclePedIsIn(PlayerPedId(), false); +if (boat == 0 || !IsThisModelABoat(GetEntityModel(boat))) return; + +// Check if we can anchor the boat here +if (CanAnchorBoatHere(boat)) +{ + // Deploy the boat's anchor + SetBoatAnchor(boat, true); + + // Wait for 10 seconds + await BaseScript.Delay(10000); + + // Raise the boat's anchor + SetBoatAnchor(boat, false); +} +else +{ + Debug.WriteLine("Cannot anchor the boat at this location"); +} +``` \ No newline at end of file diff --git a/VEHICLE/SetBoatFrozenWhenAnchored.md b/VEHICLE/SetBoatFrozenWhenAnchored.md deleted file mode 100644 index 43b1fcd7c..000000000 --- a/VEHICLE/SetBoatFrozenWhenAnchored.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -ns: VEHICLE -aliases: ["0xE3EBAAE484798530"] ---- -## _SET_BOAT_FROZEN_WHEN_ANCHORED - -```c -// 0xE3EBAAE484798530 0x0ED84792 -void _SET_BOAT_FROZEN_WHEN_ANCHORED(Vehicle vehicle, BOOL toggle); -``` - - -## Parameters -* **vehicle**: -* **toggle**: - diff --git a/VEHICLE/SetBoatLowLodAnchorDistance.md b/VEHICLE/SetBoatLowLodAnchorDistance.md new file mode 100644 index 000000000..eea829634 --- /dev/null +++ b/VEHICLE/SetBoatLowLodAnchorDistance.md @@ -0,0 +1,51 @@ +--- +ns: VEHICLE +aliases: ["0xE842A9398079BD82","_SET_BOAT_ANCHOR_BUOYANCY_COEFFICIENT", "_SET_BOAT_MOVEMENT_RESISTANCE"] +--- +## SET_BOAT_LOW_LOD_ANCHOR_DISTANCE + +```c +// 0xE842A9398079BD82 0x66FA450C +void SET_BOAT_LOW_LOD_ANCHOR_DISTANCE(Vehicle boat, float value); +``` + +Sets the distance from the player at which anchored boats switch between high and low LOD (Level of Detail) buoyancy mode. + +``` +NativeDB Introduced: v323 +``` + +## Parameters +* **boat**: The target boat. +* **value**: The distance at which the LOD switch occurs. Set to `-1.0` to reset the LOD distance to the default value. + +## Examples + +```lua +local boat = GetVehiclePedIsIn(PlayerPedId(), false) +if not boat or not IsThisModelABoat(GetEntityModel(boat)) then return end + +-- Set the low LOD anchor distance to 100 units +SetBoatLowLodAnchorDistance(boat, 100.0) +print("Set low LOD anchor distance to 100 units") +``` + +```js +const boat = GetVehiclePedIsIn(PlayerPedId(), false); +if (!boat || !IsThisModelABoat(GetEntityModel(boat))) return; + +// Set the low LOD anchor distance to 100 units +SetBoatLowLodAnchorDistance(boat, 100.0); +console.log("Set low LOD anchor distance to 100 units"); +``` + +```cs +using static CitizenFX.Core.Native.API; + +int boat = GetVehiclePedIsIn(PlayerPedId(), false); +if (boat == 0 || !IsThisModelABoat(GetEntityModel(boat))) return; + +// Set the low LOD anchor distance to 100 units +SetBoatLowLodAnchorDistance(boat, 100.0f); +Debug.WriteLine("Set low LOD anchor distance to 100 units"); +``` \ No newline at end of file diff --git a/VEHICLE/SetBoatMovementResistance.md b/VEHICLE/SetBoatMovementResistance.md deleted file mode 100644 index 758dbbfa5..000000000 --- a/VEHICLE/SetBoatMovementResistance.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -ns: VEHICLE -aliases: ["0xE842A9398079BD82","_SET_BOAT_ANCHOR_BUOYANCY_COEFFICIENT"] ---- -## _SET_BOAT_MOVEMENT_RESISTANCE - -```c -// 0xE842A9398079BD82 0x66FA450C -void _SET_BOAT_MOVEMENT_RESISTANCE(Vehicle vehicle, float value); -``` - -## Parameters -* **vehicle**: -* **value**: - diff --git a/VEHICLE/SetBoatRemainsAnchoredWhilePlayerIsDriver.md b/VEHICLE/SetBoatRemainsAnchoredWhilePlayerIsDriver.md new file mode 100644 index 000000000..58c9f87e6 --- /dev/null +++ b/VEHICLE/SetBoatRemainsAnchoredWhilePlayerIsDriver.md @@ -0,0 +1,50 @@ +--- +ns: VEHICLE +aliases: ["0xE3EBAAE484798530", "_SET_BOAT_FROZEN_WHEN_ANCHORED"] +--- +## SET_BOAT_REMAINS_ANCHORED_WHILE_PLAYER_IS_DRIVER + +```c +// 0xE3EBAAE484798530 0x0ED84792 +void SET_BOAT_REMAINS_ANCHORED_WHILE_PLAYER_IS_DRIVER(Vehicle boat, BOOL toggle); +``` + +Sets whether a boat should remain anchored even when a player is driving it. + +**Note**: This native is always used with [SET_BOAT_ANCHOR](#_0x75DBEC174AEEAD10). + +``` +NativeDB Introduced: v323 +``` + + +## Parameters +* **boat**: The target boat. +* **toggle**: Set the anchoring behavior. If `true`, the boat will remain anchored even when a player is driving. If `false`, normal anchoring behavior applies (anchor is raised when a player drives). + +## Examples +```lua +local boat = GetVehiclePedIsIn(PlayerPedId(), false) +if not boat or not IsThisModelABoat(GetEntityModel(boat)) then return end + +SetBoatRemainsAnchoredWhilePlayerIsDriver(boat, true) +SetBoatAnchor(boat, true) +``` + +```js +const boat = GetVehiclePedIsIn(PlayerPedId(), false); +if (!boat || !IsThisModelABoat(GetEntityModel(boat))) return; + +SetBoatRemainsAnchoredWhilePlayerIsDriver(boat, true); +SetBoatAnchor(boat, true); +``` + +```cs +using static CitizenFX.Core.Native.API; + +int boat = GetVehiclePedIsIn(PlayerPedId(), false); +if (boat == 0 || !IsThisModelABoat(GetEntityModel(boat))) return; + +SetBoatRemainsAnchoredWhilePlayerIsDriver(boat, true); +SetBoatAnchor(boat, true); +``` \ No newline at end of file diff --git a/VEHICLE/SetForceLowLodAnchorMode.md b/VEHICLE/SetForceLowLodAnchorMode.md new file mode 100644 index 000000000..962fe30ae --- /dev/null +++ b/VEHICLE/SetForceLowLodAnchorMode.md @@ -0,0 +1,22 @@ +--- +ns: VEHICLE +aliases: ["0xB28B1FE5BFADD7F5", "_SET_FORCED_BOAT_LOCATION_WHEN_ANCHORED"] +--- +## SET_FORCE_LOW_LOD_ANCHOR_MODE + +```c +// 0xB28B1FE5BFADD7F5 0xA739012A +void SET_FORCE_LOW_LOD_ANCHOR_MODE(Vehicle boat, BOOL toggle); +``` + +Sets whether a boat should remain in the non-physical, low LOD anchor mode even when a player is driving it. + +**Note**: This native requires [SET_BOAT_REMAINS_ANCHORED_WHILE_PLAYER_IS_DRIVER](#_0xE3EBAAE484798530) to be set to `true` to work properly. + +``` +NativeDB Introduced: v323 +``` + +## Parameters +* **boat**: The target boat. +* **toggle**: Set the forced low LOD anchor mode. If `true`, the boat will remain in low LOD anchor mode even when a player is driving. \ No newline at end of file diff --git a/VEHICLE/SetForcedBoatLocationWhenAnchored.md b/VEHICLE/SetForcedBoatLocationWhenAnchored.md deleted file mode 100644 index a5bcda84f..000000000 --- a/VEHICLE/SetForcedBoatLocationWhenAnchored.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -ns: VEHICLE -aliases: ["0xB28B1FE5BFADD7F5"] ---- -## _SET_FORCED_BOAT_LOCATION_WHEN_ANCHORED - -```c -// 0xB28B1FE5BFADD7F5 0xA739012A -void _SET_FORCED_BOAT_LOCATION_WHEN_ANCHORED(Vehicle vehicle, BOOL toggle); -``` - -``` -X,Y position of boat is frozen in place when anchored and its engine disabled, only the Z value changes. Requires 0xE3EBAAE484798530 to be set to true. -SET_FORCED_ZENITH_QUADTREE? -``` - -## Parameters -* **vehicle**: -* **toggle**: -