Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tweak(docs/native): Update Task Native Enums & Params #1130

Merged
merged 20 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
789e703
tweak(docs/native): Update Other Mission Flags
DonHulieo Jun 12, 2024
48247ea
fix(docs/native): Fix Typos & Add `None` Flag
DonHulieo Jun 12, 2024
d5fec3d
tweak(docs/native): Add Driving Flag Values
DonHulieo Jun 12, 2024
cbfbd48
fix(docs/native): Fix Incorrect Param Name
DonHulieo Jun 12, 2024
d86b73f
tweak(docs/native): Remove Native Doc & Add Lua Ex
DonHulieo Jun 13, 2024
c4429d5
tweak(docs/native): Add Lua Ex & Remove Old Doc
DonHulieo Jun 13, 2024
f2fda71
tweak(docs/native): Comment Consistency
DonHulieo Jun 13, 2024
6d516f1
tweak(docs/native): Remove `cs_type`
DonHulieo Jun 13, 2024
65ef628
tweak(docs/native): Fix `cs_type` Name
DonHulieo Jun 13, 2024
397044e
tweak(docs/native): Add Lua Ex & Remove Old Docs
DonHulieo Jun 13, 2024
a08c6fa
tweak(docs/native): Change Comment Layout
DonHulieo Jun 13, 2024
beef14a
tweak(docs/native): Add Lua Ex & Remove Old Docs
DonHulieo Jun 13, 2024
bf0fb2c
tweak(docs/native): Change Styling to Match PR
DonHulieo Jun 13, 2024
beaec6a
fix(docs/native): Fix Wording for Non-Optional Param
DonHulieo Jun 13, 2024
9bcbced
tweak(docs/native): Update Refs to Driving Style
DonHulieo Jun 13, 2024
fe8b6d8
tweak(docs/native): Update Other Vehicle Missions
DonHulieo Jun 13, 2024
b9a88a3
tweak(docs/native): Change Local Names in Ex
DonHulieo Jun 13, 2024
875c7ff
fix(docs/native): Release Model & Fix Ex Spacing
DonHulieo Jun 13, 2024
462a459
Keep enum names consistent
AvarianKnight Aug 7, 2024
65b9708
Keep enum names consistent
AvarianKnight Aug 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 74 additions & 9 deletions TASK/SetDriveTaskDrivingStyle.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,81 @@ ns: TASK
void SET_DRIVE_TASK_DRIVING_STYLE(Ped ped, int drivingStyle);
```

```
This native is used to set the driving style for specific ped.
Driving styles id seems to be:
786468
262144
786469
http://gtaforums.com/topic/822314-guide-driving-styles/
Sets the driving style for a ped currently performing a driving task.

Each flag in the `eVehicleDrivingFlags` enum can be combined to create a driving style, with each enabling or disabling a specific driving behavior. The driving style can be set to one of the predefined driving styles, or a custom driving style can be created by combining the flags. This can be done by using the bitwise OR operator (`|`) to combine the flags or by adding the decimal values of the flags together.

```c
enum eVehicleDrivingFlags
{
None = 0,
StopForVehicles = 1,
StopForPeds = 2,
SwerveAroundAllVehicles = 4,
SteerAroundStationaryVehicles = 8,
SteerAroundPeds = 16,
SteerAroundObjects = 32,
DontSteerAroundPlayerPed = 64,
StopAtTrafficLights = 128,
GoOffRoadWhenAvoiding = 256,
AllowGoingWrongWay = 512,
Reverse = 1024,
UseWanderFallbackInsteadOfStraightLine = 2048,
AvoidRestrictedAreas = 4096,
PreventBackgroundPathfinding = 8192,
AdjustCruiseSpeedBasedOnRoadSpeed = 16384,
UseShortCutLinks = 262144,
ChangeLanesAroundObstructions = 524288,
UseSwitchedOffNodes = 2097152,
PreferNavmeshRoute = 4194304,
PlaneTaxiMode = 8388608,
ForceStraightLine = 16777216,
UseStringPullingAtJunctions = 33554432,
TryToAvoidHighways = 536870912,
ForceJoinInRoadDirection = 1073741824,
StopAtDestination = 2147483648,
// StopForVehicles | StopForPeds | SteerAroundObjects | SteerAroundStationaryVehicles | StopAtTrafficLights | UseShortCutLinks | ChangeLanesAroundObstructions
DrivingModeStopForVehicles = 786603,
// StopForVehicles | StopForPeds | StopAtTrafficLights | UseShortCutLinks
DrivingModeStopForVehiclesStrict = 262275,
// SwerveAroundAllVehicles | SteerAroundObjects | UseShortCutLinks | ChangeLanesAroundObstructions | StopForVehicles
DrivingModeAvoidVehicles = 786469,
// SwerveAroundAllVehicles | SteerAroundObjects | UseShortCutLinks | ChangeLanesAroundObstructions
DrivingModeAvoidVehiclesReckless = 786468,
// StopForVehicles | SteerAroundStationaryVehicles | StopForPeds | SteerAroundObjects | UseShortCutLinks | ChangeLanesAroundObstructions
DrivingModeStopForVehiclesIgnoreLights = 786475,
// SwerveAroundAllVehicles | StopAtTrafficLights | SteerAroundObjects | UseShortCutLinks | ChangeLanesAroundObstructions | StopForVehicles
DrivingModeAvoidVehiclesObeyLights = 786597,
// SwerveAroundAllVehicles | StopAtTrafficLights | StopForPeds | SteerAroundObjects | UseShortCutLinks | ChangeLanesAroundObstructions | StopForVehicles
DrivingModeAvoidVehiclesStopForPedsObeyLights = 786599,
}
```

## Parameters
* **ped**:
* **drivingStyle**:
* **ped**: The ped to have their driving style set.
* **drivingStyle**: The driving style (see `eVehicleDrivingFlags`).

## Examples

```lua
local vehicle_model = `adder`
RequestModel(vehicle_model)
repeat Wait(0) until HasModelLoaded(vehicle_model)

local ped = PlayerPedId() -- Player needs to be in a vehicle for this to work
local coords = GetEntityCoords(ped) - GetEntityForwardVector(ped) * 15.0
AvarianKnight marked this conversation as resolved.
Show resolved Hide resolved
local vehicle = CreateVehicle(vehicle_model, coords.x, coords.y, coords.z, GetEntityHeading(ped), true, false)
SetModelAsNoLongerNeeded(vehicle_model) -- Allow the game engine to clear the model from memory

local ped_model = `a_m_m_skater_01`
RequestModel(ped_model)
repeat Wait(0) until HasModelLoaded(ped_model)

local driver = CreatePedInsideVehicle(vehicle, 0, ped_model, -1, true, false)
SetModelAsNoLongerNeeded(ped_model) -- Allow the game engine to clear the model from memory

TaskVehicleChase(driver, ped)
SetDriveTaskDrivingStyle(driver, 786468)
-- Driving Style: DrivingModeAvoidVehiclesReckless
SetPedKeepTask(driver, true)
```
58 changes: 37 additions & 21 deletions TASK/TaskBoatMission.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,14 @@ ns: TASK
void TASK_BOAT_MISSION(Ped ped, Vehicle boat, Vehicle vehicleTarget, Ped pedTarget, float x, float y, float z, int missionType, float speed, int drivingStyle, float radius, int missionFlags);
```

All parameters except driver and boat are optional, with `pedTarget`, `vehicleTarget`, `x`, `y`, `z` being dependent on `missionType` (ie. Attack/Flee mission types require a target ped/vehicle, whereas GoTo mission types require either `x`, `y`, `z` or a target ped/vehicle).
All parameters except ped and boat are optional, with `pedTarget`, `vehicleTarget`, `x`, `y`, `z` being dependent on `missionType` (ie. Attack/Flee mission types require a target ped/vehicle, whereas GoTo mission types require either `x`, `y`, `z` or a target ped/vehicle).

If you don't want to use a parameter; pass `0.0f` for `x`, `y` and `z`, `0` for `pedTarget`, `vehicleTarget` and other int parameters, and `-1.0f` for the remaining float parameters.

```
You need to call PED::SET_BLOCKING_OF_NON_TEMPORARY_EVENTS after TASK_BOAT_MISSION in order for the task to execute.
Working example
float vehicleMaxSpeed = VEHICLE::_GET_VEHICLE_MAX_SPEED(ENTITY::GET_ENTITY_MODEL(pedVehicle));
TASK::TASK_BOAT_MISSION(pedDriver, pedVehicle, 0, 0, waypointCoord.x, waypointCoord.y, waypointCoord.z, 4, vehicleMaxSpeed, 786469, -1.0, 7);
PED::SET_BLOCKING_OF_NON_TEMPORARY_EVENTS(pedDriver, 1);
P8 appears to be driving style flag - see gtaforums.com/topic/822314-guide-driving-styles/ for documentation
```

```c
enum BoatMissionFlags
enum eBoatMissionFlags
{
None = 0,
StopAtEnd = 1,
StopAtShore = 2,
AvoidShore = 4,
Expand All @@ -47,13 +39,37 @@ enum BoatMissionFlags
## Parameters
* **ped**: The ped to be tasked.
* **boat**: The boats' entity handle.
* **vehicleTarget**: The target vehicle (default is 0)
* **pedTarget**: The target ped (default is 0)
* **x**: The x coordinate of the target (default is 0.0f)
* **y**: The y coordinate of the target (default is 0.0f)
* **z**: The z coordinate of the target (default is 0.0f)
* **missionType**: The mission type (default is 0)
* **speed**: The speed in m/s (default is -1.0f)
* **drivingStyle**: The driving style (default is 0)
* **radius**: The radius of when the task will be completed (default is -1.0f)
* **missionFlags**: The mission flags (default is 0) (see `BoatMissionFlags`)
* **vehicleTarget**: The target vehicle (default is 0).
* **pedTarget**: The target ped (default is 0).
* **x**: The x coordinate of the target (default is 0.0f).
* **y**: The y coordinate of the target (default is 0.0f).
* **z**: The z coordinate of the target (default is 0.0f).
* **missionType**: The mission type (default is 0) (see [TaskVehicleMission](#_0x659427E0EF36BCDE)).
* **speed**: The speed in m/s (default is -1.0f).
* **drivingStyle**: The driving style (default is 0) (see [SetDriveTaskDrivingStyle](#_0xDACE1BE37D88AF67)).
* **radius**: The radius of when the task will be completed (default is -1.0f).
* **missionFlags**: The mission flags (default is 0) (see `eBoatMissionFlags`).

## Examples

```lua
local boat_model = `tropic`
RequestModel(boat_model)
repeat Wait(0) until HasModelLoaded(boat_model)

local ped = PlayerPedId() -- Player needs to be in open water & in a boat for this to work
local coords = GetEntityCoords(ped) - GetEntityForwardVector(ped) * 15.0
local vehicle = CreateVehicle(boat_model, coords.x, coords.y, coords.z, GetEntityHeading(ped), true, false)
SetModelAsNoLongerNeeded(boat_model) -- Allow the game engine to clear the model from memory

local ped_model = `a_m_m_skater_01`
RequestModel(ped_model)
repeat Wait(0) until HasModelLoaded(ped_model)

local driver = CreatePedInsideVehicle(vehicle, 0, ped_model, -1, true, false)
SetModelAsNoLongerNeeded(ped_model) -- Allow the game engine to clear the model from memory

TaskBoatMission(driver, vehicle, GetVehiclePedIsIn(ped, false), 0, 0.0, 0.0, 0.0, 7, -1.0, 786468, -1.0, 1044)
-- Mission Type: Follow | Drive Style: DrivingModeAvoidVehiclesReckless | Mission Flags: AvoidShore | NeverStop | NeverPause
SetPedKeepTask(driver, true)
```
100 changes: 66 additions & 34 deletions TASK/TaskHeliMission.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,75 @@ ns: TASK

```c
// 0xDAD029E187A2BEB4 0x0C143E97
void TASK_HELI_MISSION(Ped pilot, Vehicle aircraft, Vehicle targetVehicle, Ped targetPed, float destinationX, float destinationY, float destinationZ, int missionFlag, float maxSpeed, float landingRadius, float targetHeading, int unk1, int unk2, cs_type(Hash) float unk3, int landingFlags);
void TASK_HELI_MISSION(Ped ped, Vehicle heli, Vehicle vehicleTarget, Ped pedTarget, float x, float y, float z, int missionType, float speed, float radius, float heading, cs_type(int) float height, float minHeight, cs_type(Hash) float slowDist, int missionFlags);
```

```
Needs more research.
Default value of p13 is -1.0 or 0xBF800000.
Default value of p14 is 0.
Modified examples from "fm_mission_controller.ysc", line ~203551:
TASK::TASK_HELI_MISSION(ped, vehicle, 0, 0, posX, posY, posZ, 4, 1.0, -1.0, -1.0, 10, 10, 5.0, 0);
TASK::TASK_HELI_MISSION(ped, vehicle, 0, 0, posX, posY, posZ, 4, 1.0, -1.0, -1.0, 0, ?, 5.0, 4096);
int mode seams to set mission type 4 = coords target, 23 = ped target.
int 14 set to 32 = ped will land at destination.
My findings:
mode 4 or 7 forces heli to snap to the heading set
8 makes the heli flee from the ped.
9 circles around ped with angle set
10, 11 normal + imitate ped heading
20 makes the heli land when he's near the ped. It won't resume chasing.
21 emulates an helicopter crash
23 makes the heli circle erratically around ped
I change p2 to 'vehicleToFollow' as it seems to work like the task natives to set targets. In the heli_taxi script where as the merryweather heli takes you to your waypoint it has no need to follow a vehicle or a ped, so of course both have 0 set.
All parameters except ped, heli and speed are optional, with `pedTarget`, `vehicleTarget`, `x`, `y`, `z` being dependent on `missionType` (ie. Attack/Flee mission types require a target ped/vehicle, whereas GoTo mission types require either `x`, `y`, `z` or a target ped/vehicle).

If you don't want to use a parameter; pass `0.0f` for `x`, `y` and `z`, `0` for `pedTarget`, `vehicleTarget`, `0` for other int parameters, and `-1.0f` for the remaining float parameters.

```c
enum eHeliMissionFlags
{
None = 0,
AttainRequestedOrientation = 1,
DontModifyOrientation = 2,
DontModifyPitch = 4,
DontModifyThrottle = 8,
DontModifyRoll = 16,
LandOnArrival = 32,
DontDoAvoidance = 64,
StartEngineImmediately = 128,
ForceHeightMapAvoidance = 256,
DontClampProbesToDestination = 512,
EnableTimeslicingWhenPossible = 1024,
CircleOppositeDirection = 2048,
MaintainHeightAboveTerrain = 4096,
IgnoreHiddenEntitiesDuringLand = 8192,
DisableAllHeightMapAvoidance = 16384,
// ForceHeightMapAvoidance | DontDoAvoidance
HeightMapOnlyAvoidance = 320,
}
```

## Parameters
* **pilot**:
* **aircraft**:
* **targetVehicle**:
* **targetPed**:
* **destinationX**:
* **destinationY**:
* **destinationZ**:
* **missionFlag**:
* **maxSpeed**:
* **landingRadius**:
* **targetHeading**:
* **unk1**:
* **unk2**:
* **unk3**:
* **landingFlags**:
* **ped**: The ped to be tasked.
* **heli**: The helicopters' entity handle.
* **vehicleTarget**: The target vehicle (default is 0).
* **pedTarget**: The target ped (default is 0).
* **x**: The x coordinate of the target (default is 0.0f).
* **y**: The y coordinate of the target (default is 0.0f).
* **z**: The z coordinate of the target (default is 0.0f).
* **missionType**: The mission type (default is 0) (see [TaskVehicleMission](#_0x659427E0EF36BCDE)).
* **speed**: The speed in m/s.
* **radius**: The radius of when the task will be completed (default is -1.0f).
* **heading**: The heading the helicopter will face at task completion (default is -1.0f).
* **height**: The height the helicopter will fly at (default is -1.0f).
* **minHeight**: The height the helicopter will not fly below (default is -1.0f).
* **slowDist**: The distance to the target at which the helicopter will slow down (default is -1.0f).
* **missionFlags**: The mission flags (default is 0) (see `eHeliMissionFlags`).

## Examples

```lua
local heli_model = `akula`
RequestModel(heli_model)
repeat Wait(0) until HasModelLoaded(heli_model)

local ped = PlayerPedId() -- Player needs to be outside for this to work
local coords = GetEntityCoords(ped) + GetEntityForwardVector(ped) * 100.0
local heli = CreateVehicle(heli_model, coords.x, coords.y, coords.z + 50.0, GetEntityHeading(ped) - 180.0, true, false)
SetModelAsNoLongerNeeded(heli_model) -- Allow the game engine to clear the model from memory
SetHeliBladesFullSpeed(heli)

local ped_model = `a_m_m_skater_01`
RequestModel(ped_model)
repeat Wait(0) until HasModelLoaded(ped_model)

local pilot = CreatePedInsideVehicle(heli, 0, ped_model, -1, true, false)
SetModelAsNoLongerNeeded(ped_model) -- Allow the game engine to clear the model from memory

TaskHeliMission(pilot, heli, 0, 0, coords.x, coords.y, coords.z, 19, 10.0, -1.0, -1.0, -1.0, -1.0, -1.0, 96)
-- Mission Type: Land | Mission Flags: LandOnArrival | DontDoAvoidance
SetPedKeepTask(pilot, true)
```
4 changes: 2 additions & 2 deletions TASK/TaskVehicleDriveToCoordLongrange.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ns: TASK

```c
// 0x158BB33F920D360C 0x1490182A
void TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE(Ped ped, Vehicle vehicle, float x, float y, float z, float speed, int driveMode, float stopRange);
void TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE(Ped ped, Vehicle vehicle, float x, float y, float z, float speed, int drivingStyle, float stopRange);
```

You can let your character drive to the destination at the speed and driving style you set. You can use map marks to set the destination.
Expand All @@ -17,7 +17,7 @@ You can let your character drive to the destination at the speed and driving sty
* **y**: Destination Y coordinate.
* **z**: Destination Z coordinate.
* **speed**: Speed of driving.
* **driveMode**: More info can be found [here](https://vespura.com/fivem/drivingstyle/)
* **drivingStyle**: The driving style (default is 0) (see [SetDriveTaskDrivingStyle](#_0xDACE1BE37D88AF67)).
* **stopRange**: Stops in the specific range near the destination. 20.0 works fine.

## Examples
Expand Down
2 changes: 1 addition & 1 deletion TASK/TaskVehicleDriveWander.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Drive randomly with no destination set.
* **ped**: Ped id for the task.
* **vehicle**: Vehicle entity id for the task.
* **speed**: Speed of driving.
* **drivingStyle**: More info can be found [here](https://vespura.com/fivem/drivingstyle/)
* **drivingStyle**: The driving style (default is 0) (see [SetDriveTaskDrivingStyle](#_0xDACE1BE37D88AF67)).

## Examples
```cs
Expand Down
2 changes: 1 addition & 1 deletion TASK/TaskVehicleEscort.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Driving Styles guide: gtaforums.com/topic/822314-guide-driving-styles/
* **targetVehicle**:
* **mode**:
* **speed**:
* **drivingStyle**:
* **drivingStyle**: The driving style (default is 0) (see [SetDriveTaskDrivingStyle](#_0xDACE1BE37D88AF67)).
* **minDistance**:
* **p7**:
* **noRoadsDistance**:
Expand Down
2 changes: 1 addition & 1 deletion TASK/TaskVehicleFollow.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ drivingStyle: http://gtaforums.com/topic/822314-guide-driving-styles/
* **vehicle**:
* **targetEntity**:
* **speed**:
* **drivingStyle**:
* **drivingStyle**: The driving style (default is 0) (see [SetDriveTaskDrivingStyle](#_0xDACE1BE37D88AF67)).
* **minDistance**:

Loading
Loading