Parachute - Add failure chance (#8226)

* Initial push

* disable forgotten define

* Improve exitWith check

* Requested/suggested changes

* Requested changes

* Requested changes
This commit is contained in:
JoramD 2021-05-01 05:48:02 +02:00 committed by PabstMirror
parent 4726108c8e
commit 00eead47c1
7 changed files with 55 additions and 1 deletions

View File

@ -21,6 +21,7 @@ class CfgVehicles {
};
};
MACRO_HASRESERVE
GVAR(failureDelay) = 2;
};
class ParachuteWest: ParachuteBase {
MACRO_HASRESERVE

View File

@ -1,4 +1,5 @@
PREP(cutParachute);
PREP(handleFailureChance);
PREP(handleInfoDisplayChanged);
PREP(handleReserve);
PREP(hideAltimeter);

View File

@ -38,3 +38,5 @@ if (!hasInterface) exitWith {};
// Don't show vanilla speed and height when in expert mode
["ace_infoDisplayChanged", {_this call FUNC(handleInfoDisplayChanged)}] call CBA_fnc_addEventHandler;
["vehicle", {_this call FUNC(handleFailureChance)}] call CBA_fnc_addPlayerEventHandler;

View File

@ -18,4 +18,13 @@ PREP_RECOMPILE_END;
{[QGVAR(hideAltimeter), _this, false] call EFUNC(common,cbaSettings_settingChanged)}
] call CBA_fnc_addSetting;
[
QGVAR(failureChance),
"SLIDER",
LSTRING(FailureChance),
["ACE Uncategorized", localize "str_dn_parachute"],
[0, 1, 0, 2, true],
1
] call CBA_fnc_addSetting;
ADDON = true;

View File

@ -0,0 +1,26 @@
#include "script_component.hpp"
/*
* Author: JoramD
* Handles percentage chance parachute failure.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Vehicle <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, vehicle player] call ace_parachute_fnc_handleFailureChance
*
* Public: No
*/
params ["_unit", "_vehicle"];
if !(_vehicle isKindOf "ParachuteBase") exitWith {};
if (random 1 < GVAR(failureChance)) then {
private _failureDelay = getNumber (configOf _vehicle >> QGVAR(failureDelay));
[FUNC(cutParachute), [_unit, _vehicle], _failureDelay] call CBA_fnc_waitAndExecute;
};

View File

@ -133,5 +133,8 @@
<Spanish>Oculta la altitud y la velocidad que se muestran en caída libre o en paracaídas.</Spanish>
<Turkish>Serbest düşme veya paraşütle atlama sırasında gösterilen yüksekliği ve hızı gizler.</Turkish>
</Key>
<Key ID="STR_ACE_Parachute_FailureChance">
<English>Parachute Failure Chance</English>
</Key>
</Package>
</Project>

View File

@ -16,9 +16,21 @@ version:
```cpp
class CfgVehicles {
class BananaParachute {
class ParachuteBase;
class BananaParachute: ParachuteBase {
ace_hasReserveParachute = 1; // Add reserve parachute (1-enabled, 0-disabled)
ace_reserveParachute = "ACE_ReserveParachute"; // Classname of the reserve parachute
};
};
```
## 2. Adding failure cut delay
```cpp
class CfgVehicles {
class ParachuteBase;
class BananaParachute: ParachuteBase {
ace_parachute_failureDelay = 2; // Add delay before parachute fails (time in seconds)
};
};
```