mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Cargo - Support of object without ace_cargo_size
defined in config or -1
config value (#6364)
* Add: Now findUnloadPosition support also cargo object - use of ace_cargo_fnc_getSizeItem to determine size of item - prefer the config way instead of manually set size - This will also take into account object manually added to the cargo system with ace_cargo_fnc_setsize - use the cargo object for ace_cargo_fnc_unloadItem. * FIX: old work around * FIX: error when cargo module is not loaded * As suggested by @orbis2358 This fix handle the case when cargo module is not loaded for scheduled and unscheduled environnement. * Use ACE framework to check if module is present * FIX: EFUNC and isEqualto - _itemSize here is always number - here we are in common module (addons/common/functions/fnc_findUnloadPosition) so FUNC is ace_common_fnc * FIX case where config value is `-1` - if the config value is -1, get the `ace_cargo_size` from the `ace_cargo_fnc_getSizeItem - https://github.com/acemod/ACE3/issues/6357#issuecomment-393525374
This commit is contained in:
parent
a4e0e83972
commit
f9943658e9
@ -20,10 +20,8 @@
|
||||
params ["_item", "_vehicle", ["_unloader", objNull]];
|
||||
TRACE_3("params",_item,_vehicle,_unloader);
|
||||
|
||||
private _itemClass = if (_item isEqualType "") then {_item} else {typeOf _item};
|
||||
|
||||
//This covers testing vehicle stability and finding a safe position
|
||||
private _emptyPosAGL = [_vehicle, _itemClass, _unloader] call EFUNC(common,findUnloadPosition);
|
||||
private _emptyPosAGL = [_vehicle, _item, _unloader] call EFUNC(common,findUnloadPosition);
|
||||
TRACE_1("findUnloadPosition",_emptyPosAGL);
|
||||
|
||||
if ((count _emptyPosAGL) != 3) exitWith {
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Source Vehicle <OBJECT>
|
||||
* 1: Cargo Classname <STRING>
|
||||
* 1: Cargo <OBJECT> or <STRING>
|
||||
* 2: Unloader (player) <OBJECT> (default: objNull)
|
||||
* 3: Max Distance (meters) <NUMBER> (default: 10)
|
||||
* 4: Check Vehicle is Stable <BOOL> (default: true)
|
||||
@ -27,8 +27,8 @@
|
||||
//Manual collision tests (count and radius):
|
||||
#define COL_TEST_COUNT 12
|
||||
|
||||
params ["_vehicle", "_typeOfCargo", ["_theUnloader", objNull], ["_maxDistance", 10], ["_checkVehicleIsStable", true]];
|
||||
TRACE_5("params",_vehicle,_typeOfCargo,_theUnloader,_maxDistance,_checkVehicleIsStable);
|
||||
params ["_vehicle", "_cargo", ["_theUnloader", objNull], ["_maxDistance", 10], ["_checkVehicleIsStable", true]];
|
||||
TRACE_5("params",_vehicle,_cargo,_theUnloader,_maxDistance,_checkVehicleIsStable);
|
||||
|
||||
scopeName "main";
|
||||
|
||||
@ -40,12 +40,22 @@ if (_checkVehicleIsStable) then {
|
||||
};
|
||||
|
||||
private _radiusOfItem = 1;
|
||||
if (_typeOfCargo isKindOf "CAManBase") then {
|
||||
if (_cargo isKindOf "CAManBase") then {
|
||||
_radiusOfItem = 1.1;
|
||||
} else {
|
||||
//`sizeOf` is unreliable, and does not work with object types that don't exist on map, so estimate size based on cargo size
|
||||
if (isNumber (configFile >> "CfgVehicles" >> _typeOfCargo >> QEGVAR(cargo,size))) then {
|
||||
_radiusOfItem = (((getNumber (configFile >> "CfgVehicles" >> _typeOfCargo >> QEGVAR(cargo,size))) ^ 0.35) max 0.75);
|
||||
private _typeOfCargo = if (_cargo isEqualType "") then {_cargo} else {typeOf _cargo};
|
||||
private _itemSize = if (isNumber (configFile >> "CfgVehicles" >> _typeOfCargo >> QEGVAR(cargo,size)) && {getNumber (configFile >> "CfgVehicles" >> _typeOfCargo >> QEGVAR(cargo,size)) != -1}) then {
|
||||
getNumber (configFile >> "CfgVehicles" >> _typeOfCargo >> QEGVAR(cargo,size));
|
||||
} else {
|
||||
if (["ace_cargo"] call FUNC(isModLoaded)) then {
|
||||
[_cargo] call EFUNC(cargo,getSizeItem);
|
||||
} else {
|
||||
_radiusOfItem;
|
||||
};
|
||||
};
|
||||
if (_itemSize != -1) then {
|
||||
_radiusOfItem = (_itemSize ^ 0.35) max 0.75;
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user