Add unloaded of cargo to killed vehicles

This commit is contained in:
Drofseh 2024-05-26 23:19:33 -07:00
parent be77ef233e
commit 5b519c561b
3 changed files with 27 additions and 3 deletions

View File

@ -1,6 +1,6 @@
#include "..\script_component.hpp"
/*
* Author: mharis001, Glowbal
* Author: mharis001, Glowbal, drofseh
* Handles an object being destroyed/deleted.
* If object contained loaded cargo, the cargo is deleted.
* If object was loaded cargo, it's removed from loaded cargo list.
@ -19,14 +19,22 @@
params ["_object"];
private _killed = false;
if (count _this > 1) then {_killed = true}; // The Killed event has 4 params. The Deleted event only has 1 param.
private _loaded = _object getVariable [QGVAR(loaded), []];
if (_loaded isNotEqualTo []) then {
// Delete all cargo
{
if (_x isEqualType objNull) then {
detach _x;
deleteVehicle _x;
if (_killed && {random 100 < GVAR(unloadOnKilled)}) then {
[_x, _object] call ace_cargo_fnc_unloadItem;
} else {
detach _x;
deleteVehicle _x;
};
};
} forEach _loaded;

View File

@ -30,6 +30,16 @@ private _category = [ELSTRING(main,Category_Logistics), LSTRING(openMenu)];
{[QGVAR(paradropTimeCoefficent), _this, true] call EFUNC(common,cbaSettings_settingChanged)}
] call CBA_fnc_addSetting;
[
QGVAR(unloadOnKilled),
"SLIDER",
[LSTRING(unloadOnKilled), LSTRING(unloadOnKilled_description)],
_category,
[0, 100, 1, 0],
1,
{[QGVAR(unloadOnKilled), _this, true] call EFUNC(common,cbaSettings_settingChanged)}
] call CBA_fnc_addSetting;
[
QGVAR(openAfterUnload),
"LIST",

View File

@ -498,6 +498,12 @@
<Czech>Upravuje jak dlouho výsadek trvá pro náklad.</Czech>
<Spanish>Modificador de tiempo de lanzamiento en paracaídas de un objeto cargado</Spanish>
</Key>
<Key ID="STR_ACE_Cargo_unloadOnKilled">
<English>Unload Cargo On Killed</English>
</Key>
<Key ID="STR_ACE_Cargo_unloadOnKilled_description">
<English>The chance for each cargo loaded into a vehicle to be unloaded if the vehicle is killed.</English>
</Key>
<Key ID="STR_ACE_Cargo_loadTimeCoefficient">
<English>Load Time Coefficient</English>
<German>Ladezeitmultiplikator</German>