Vehicles - Add configurable engine startup delay (#8327)

* Add configurable engine startup delay

* add suggested change

Add space char

Co-authored-by: Dystopian <sddex@ya.ru>

* Squashed commit of the following:

commit 14f5483d8fa49d36effa8b18a3df392ed39b19da
Author: Serg Vergun <1197314+severgun@users.noreply.github.com>
Date:   Fri Jul 23 20:23:52 2021 +0300

    Add 0 cap and update docs

commit e3ce7f273882b3f4e2cba916c39b506f857b20db
Author: severgun <sewergun@gmail.com>
Date:   Fri Jul 23 12:42:42 2021 +0300

    add parentheses

commit b36eedc61b5e6bb868c37901bd4191767fbdaff8
Author: severgun <sewergun@gmail.com>
Date:   Fri Jul 23 12:34:30 2021 +0300

    Add ability to set engine startup delay per vehicle by script

* Change function name

* add suggested exitWith condition

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* Update docs/wiki/framework/vehicles-framework.md

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

Co-authored-by: Dystopian <sddex@ya.ru>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
Serg Vergun 2021-07-27 20:47:07 +03:00 committed by GitHub
parent fafd7b3928
commit fa6da1ae7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 86 additions and 3 deletions

View File

@ -16,7 +16,9 @@ class CfgVehicles {
class CommanderOptics;//: NewTurret {};
};
class Car: LandVehicle {};
class Car: LandVehicle {
GVAR(engineStartDelay) = 1.3;
};
class Tank: LandVehicle {
class Turrets {

View File

@ -1,3 +1,4 @@
PREP(speedLimiter);
PREP(startEngine);
PREP(setVehicleStartDelay);

View File

@ -0,0 +1,23 @@
#include "script_component.hpp"
/*
* Author: severgun
* Set engine startup delay to specific vehicle.
*
* Arguments:
* 0: Vehicle <OBJECT>
* 1: Delay (seconds) <NUMBER>
*
* Return Value:
* None
*
* Example:
* [hemmt, 3.2] call ace_vehicles_fnc_setVehicleStartDelay
*
* Public: Yes
*/
params [["_veh", objNull, [objNull]], ["_delay", 0, [99]]];
if (isNull _veh || {!(_veh isKindOf "AllVehicles")}) exitWith {};
_veh setVariable [QGVAR(engineStartDelay), _delay max 0, true];

View File

@ -20,6 +20,9 @@ params ["_vehicle", "_isEngineOn"];
if (!_isEngineOn || {floor abs speed _vehicle > 0 || {!isNull isVehicleCargo _vehicle}}) exitWith {};
private _startupDelay = _vehicle getVariable [QGVAR(engineStartDelay), getNumber (configOf _vehicle >> QGVAR(engineStartDelay))];
if (_startupDelay <= 0) exitWith {};
[{
params ["_args", "_idPFH"];
_args params ["_vehicle", "_time", "_direction"];
@ -29,4 +32,4 @@ if (!_isEngineOn || {floor abs speed _vehicle > 0 || {!isNull isVehicleCargo _ve
_vehicle setVelocity [0, 0, 0];
_vehicle setVectorDirAndUp _direction;
} , 0, [_vehicle, CBA_missionTime + STARTUP_DELAY, [vectorDir _vehicle, vectorUp _vehicle]]] call CBA_fnc_addPerFrameHandler;
} , 0, [_vehicle, CBA_missionTime + _startupDelay, [vectorDir _vehicle, vectorUp _vehicle]]] call CBA_fnc_addPerFrameHandler;

View File

@ -20,4 +20,3 @@
#define MOUSE_SCROLL_DOWN 0xF9
#define FUEL_FACTOR 0.165 // fuel capacity = range in km * FUEL_FACTOR
#define STARTUP_DELAY 1.3

View File

@ -0,0 +1,55 @@
---
layout: wiki
title: Vehicles Framework
description: Explains how to set-up vehicles startup delay.
group: framework
order: 5
parent: wiki
mod: ace
version:
major: 3
minor: 14
patch: 0
---
## 1. Engine startup delay
The engine has to be started before the vehicle can move. Delay can be configured per class via config or per vehicle via script.
By default starting the engine takes aprox. 1 to 2 seconds.
### 1.1 Setting the startup delay by config
```cpp
class CfgVehicles {
class MyFuelTruck {
ace_vehicles_engineStartDelay = 3; // Startup delay in seconds
};
class MyCar {
ace_vehicles_engineStartDelay = 2.2;
};
class MyElectricCar {
ace_vehicles_engineStartDelay = 0.1;
};
};
```
### 1.2 Setting the startup delay by script
`ace_vehicles_fnc_setVehicleStartDelay`
Has global effects.
| Arguments | Type | Optional (default value)
---| --------- | ---- | ------------------------
0 | Vehicle | Object | Required
1 | Delay (in seconds) | Number | Required
**R** | None | None | Return value
#### 1.2.1 Example
`[myCar, 2.2] call ace_vehicles_fnc_setVehicleStartDelay;`
| Arguments | Explanation
---| --------- | -----------
0 | `myCar` | My car object
1 | `2.2` | New startup delay