AiParams.allowDriveVehicle 2
When enabled (default), an AI soldier at the wheel drives the vehicle wherever its squad orders send it. Disable it and a vehicle with this soldier as driver stays where it is: it no longer drives to objectives or repositions, self-propelled artillery included. It still turns to bring its gun onto a target and the gunners keep firing. Tracked vehicles turn on the spot, wheeled ones need a little back and forth to turn.Made for vehicles placed in the mission editor that must hold their position, such as an in-world artillery battery. Put the call in the script of the AI spawner that crews the vehicle, so every crew member has it whoever ends up at the wheel, and combine it with allowLeaveVehicle(false) to keep the crew aboard.The value is sent to the other clients and to late joiners like the other AI parameters, and the spawner script runs again on the new owner after a host migration. A player can still drive the vehicle. enableAiBehaviour does not change this parameter.
Return value
| Return Type | Description |
|---|---|
| void | This function doesn't return anything |
Parameters
| Parameter | Type | Description |
|---|---|---|
| 1 | bool | False: the vehicle this soldier drives stays where it is. True (default): the AI drives normally. |
Examples
Artillery vehicle that never leaves its spot (network safe)
-- script of the AI spawner that crews the vehicle
local ai = myself().getAiParams()
ai.allowDriveVehicle(false) -- the crew never drives the vehicle away
ai.allowLeaveVehicle(false) -- and never dismounts on its own