Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo - Add unloading of cargo to killed vehicles #10017

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions addons/cargo/functions/fnc_handleDestroyed.sqf
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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.
Drofseh marked this conversation as resolved.
Show resolved Hide resolved

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 {
Drofseh marked this conversation as resolved.
Show resolved Hide resolved
[_x, _object] call ace_cargo_fnc_unloadItem;
Drofseh marked this conversation as resolved.
Show resolved Hide resolved
} else {
detach _x;
deleteVehicle _x;
};
};
} forEach _loaded;

Expand Down
10 changes: 10 additions & 0 deletions addons/cargo/initSettings.inc.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Drofseh marked this conversation as resolved.
Show resolved Hide resolved
1,
{[QGVAR(unloadOnKilled), _this, true] call EFUNC(common,cbaSettings_settingChanged)}
johnb432 marked this conversation as resolved.
Show resolved Hide resolved
] call CBA_fnc_addSetting;

[
QGVAR(openAfterUnload),
"LIST",
Expand Down
6 changes: 6 additions & 0 deletions addons/cargo/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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. [Only Objects]</English>
Drofseh marked this conversation as resolved.
Show resolved Hide resolved
</Key>
<Key ID="STR_ACE_Cargo_loadTimeCoefficient">
<English>Load Time Coefficient</English>
<German>Ladezeitmultiplikator</German>
Expand Down