Add: getVehicleCargo and differentiate normal "CargoNet_01_box_F" and ACE "CargoNet_01_box_F"

This commit is contained in:
Vdauphin 2020-11-07 10:44:07 +01:00
parent 0bf95f7917
commit d8118ac3aa
5 changed files with 29 additions and 5 deletions

View File

@ -5,6 +5,7 @@ PREP(canShowUnloadAllVehicles);
PREP(canUnloadItem);
PREP(getCargoSpaceLeft);
PREP(getSizeItem);
PREP(getVehicleCargo);
PREP(handleDeleted);
PREP(handleDestroyed);
PREP(initObject);

View File

@ -23,4 +23,4 @@ params [
driver _vehicle isEqualTo _unit &&
{isClass (configOf _vehicle >> "VehicleTransport" >> "Carrier")} &&
{!(getVehicleCargo _vehicle - (_vehicle getVariable [QGVAR(loaded), []]) isEqualTo [])}
{!([_vehicle] call ace_cargo_fnc_getVehicleCargo isEqualTo [])}

View File

@ -0,0 +1,22 @@
#include "script_component.hpp"
/*
* Author: Vdauphin
* Get vehicle in cargo.
*
* Arguments:
* 0: Vehicle <OBJECT>
*
* Return Value:
* Loaded vehicles not part of ACE Cargo <ARRAY>
*
* Example:
* [vehicle player] call ace_cargo_fnc_getVehicleCargo
*
* Public: No
*/
params ["_vehicle"];
(getVehicleCargo _vehicle - (_vehicle getVariable [QGVAR(loaded), []])) select {
!(_x getVariable [QGVAR(isCargoNet), false])
}

View File

@ -41,14 +41,14 @@ if (_item isEqualType objNull) then {
(_vehicle canVehicleCargo _item) isEqualTo [false, true] && // Could be loaded if _vehicle was empty
{_vehicleCargo findIf {
!(_x in _loaded) && // Don't use ViV if ViV was used outside of ACE Cargo
!(typeOf _x isEqualTo "CargoNet_01_box_F")
!(_x getVariable [QGVAR(isCargoNet), false])
} isEqualTo -1}
) then {
private _cargoNet = createVehicle ["CargoNet_01_box_F", [0, 0, 0], [], 0, "CAN_COLLIDE"];
if ((_vehicle canVehicleCargo _cargoNet) select 1) then {
while {!(_vehicle setVehicleCargo _cargoNet)} do { // Move ViV cargo to ACE Cargo
private _itemViV = _vehicleCargo deleteAt 0;
if (typeOf _itemViV isEqualTo "CargoNet_01_box_F") exitWith { // The vehicle is already full of "CargoNet_01_box_F")
if (_itemViV getVariable [QGVAR(isCargoNet), false]) exitWith { // The vehicle is already full of cargo net
deleteVehicle _cargoNet;
_item setVariable [QGVAR(cargoNet), _itemViV, true];
};
@ -62,6 +62,7 @@ if (_item isEqualType objNull) then {
[_itemViV, "blockDamage", "ACE_cargo", true] call EFUNC(common,statusEffect_set);
};
if !(isNull _cargoNet) then {
_cargoNet setVariable [QGVAR(isCargoNet), true, true];
_item setVariable [QGVAR(cargoNet), _cargoNet, true];
};
} else {

View File

@ -7,7 +7,7 @@
* 0: Vehicle <OBJECT>
*
* Return Value:
* Loaded vehiclesnot part of ACE Cargo <ARRAY>
* Loaded vehicles not part of ACE Cargo <ARRAY>
*
* Example:
* [vehicle player] call ace_cargo_fnc_unloadAllVehicles
@ -17,7 +17,7 @@
params ["_vehicle"];
private _loadedVehicles = getVehicleCargo _vehicle - (_vehicle getVariable [QGVAR(loaded), []]);
private _loadedVehicles = [_vehicle] call ace_cargo_fnc_getVehicleCargo;
private _unloadingInterval = getNumber (configOf _vehicle >> "VehicleTransport" >> "Carrier" >> "unloadingInterval");
{
[{objnull setVehicleCargo _this}, _x, _forEachIndex * _unloadingInterval] call CBA_fnc_waitAndExecute;