API ReferenceGE Extensionsflowgraphnodesvehicleai
AI Parameters
- **Node Name:** `AI Parameters`
Overview
- Node Name:
AI Parameters - Category:
repeat_p_duration - File:
extensions/flowgraph/nodes/vehicle/ai/aiParams.lua
Sets various AI driving parameters for a vehicle, including risk/aggression, speed, lane behavior, collision avoidance, and nitrous activation. Parameters are sent via queueLuaCommand each frame.
Pin Schema
Input Pins
| Pin | Type | Default | Description |
|---|---|---|---|
vehId | number | 0 | Vehicle ID (uses player vehicle if not specified) |
risk | number | 0.3 | Riskiness / aggression (0.1–2.0) |
routeSpeed | number | 0 | Route speed in m/s |
routeMode | string | "off" | Speed mode: off, set, limit |
drivabilityCO | number | 0 | Min drivability cutoff (hidden) |
inLane | bool | false | Whether to use lane driving |
avoidCars | bool | true | Whether to avoid collisions (hidden) |
forceRisk | bool | false | Force risk value for flee/chase modes (hidden) |
activateNitrous | bool | false | Activate/deactivate nitrous oxide (hidden) |
Internals
Key Methods
| Method | Description |
|---|---|
postInit() | Sets up slider for risk (0.1–2.0) and hard templates for routeMode |
work() | Sends AI parameter commands to the vehicle each frame |
AI Commands Sent
| Pin | Vehicle Lua Command |
|---|---|
risk | ai.setAggression(value) |
routeSpeed | ai.setSpeed(value) |
routeMode | ai.setSpeedMode(value) |
drivabilityCO | ai.setCutOffDrivability(value) |
inLane | ai.driveInLane("on"/"off") |
avoidCars | ai.setAvoidCars("on"/"off") |
forceRisk | ai.setAggressionMode("off"/"rubberBand") |
activateNitrous | Controls NOS controller + JATO input |
Nitrous Logic
When activateNitrous is true, the node:
- Sets
electrics.values.jatoInputto 1 (if available). - Checks the
nitrousOxideInjectioncontroller and toggles it on if not armed. - When false, reverses both operations.
How It Works
- Resolves the vehicle by ID or falls back to the player vehicle.
- For each non-nil input pin, queues the corresponding Lua command on the vehicle.
- Since category is
repeat_p_duration, commands are sent every frame (p_duration because ofqueueLuaCommandlatency). - Risk value is clamped between 0.1 and 2.0.
Usage Example
-- Set cautious AI with speed limit:
-- vehId = aiVehicleId
-- risk = 0.3
-- routeSpeed = 20 (20 m/s ≈ 72 km/h)
-- routeMode = "limit"
-- inLane = true
-- Aggressive chase setup:
-- risk = 1.5
-- forceRisk = true
-- avoidCars = falseKey Dependencies
ai.setAggression()/ai.setSpeed()/ai.setSpeedMode()- vehicle AI APIai.driveInLane()/ai.setAvoidCars()- vehicle AI behaviorcontroller.getController("nitrousOxideInjection")- NOS controller
See Also
- AI Arrive (Flowgraph Node) - Related reference
- AI Chase (Flowgraph Node) - Related reference
- AI Directly To (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide