mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
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:
parent
2973ea5814
commit
60cab0af6b
@ -21,6 +21,7 @@ class CfgVehicles {
|
||||
};
|
||||
};
|
||||
MACRO_HASRESERVE
|
||||
GVAR(failureDelay) = 2;
|
||||
};
|
||||
class ParachuteWest: ParachuteBase {
|
||||
MACRO_HASRESERVE
|
||||
|
@ -1,4 +1,5 @@
|
||||
PREP(cutParachute);
|
||||
PREP(handleFailureChance);
|
||||
PREP(handleInfoDisplayChanged);
|
||||
PREP(handleReserve);
|
||||
PREP(hideAltimeter);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
26
addons/parachute/functions/fnc_handleFailureChance.sqf
Normal file
26
addons/parachute/functions/fnc_handleFailureChance.sqf
Normal 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;
|
||||
};
|
@ -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>
|
||||
|
@ -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)
|
||||
};
|
||||
};
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user