2015-08-18 16:48:21 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2016-06-24 15:12:19 +00:00
|
|
|
["ace_addCargo", {_this call FUNC(addCargoItem)}] call CBA_fnc_addEventHandler;
|
2021-10-10 13:37:16 +00:00
|
|
|
[QGVAR(paradropItem), {
|
|
|
|
params ["_item", "_vehicle"];
|
|
|
|
|
|
|
|
private _unloaded = [_item, _vehicle] call FUNC(paradropItem);
|
|
|
|
|
|
|
|
if (_unloaded && {GVAR(openAfterUnload) in [2, 3]}) then {
|
|
|
|
GVAR(interactionVehicle) = _vehicle;
|
|
|
|
GVAR(interactionParadrop) = true;
|
|
|
|
createDialog QGVAR(menu);
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
2015-09-27 16:19:40 +00:00
|
|
|
|
2016-05-24 13:13:11 +00:00
|
|
|
["ace_loadCargo", {
|
2016-02-23 23:24:51 +00:00
|
|
|
params ["_item", "_vehicle"];
|
2016-01-27 20:56:25 +00:00
|
|
|
TRACE_2("LoadCargo EH",_item,_vehicle);
|
2015-09-27 16:19:40 +00:00
|
|
|
|
2016-01-19 03:53:48 +00:00
|
|
|
private _loaded = [_item, _vehicle] call FUNC(loadItem);
|
2015-09-27 16:19:40 +00:00
|
|
|
|
|
|
|
// Show hint as feedback
|
2016-01-19 03:53:48 +00:00
|
|
|
private _hint = [LSTRING(LoadingFailed), LSTRING(LoadedItem)] select _loaded;
|
2021-10-12 22:42:38 +00:00
|
|
|
private _itemName = [_item, true] call FUNC(getNameItem);
|
2021-02-18 18:58:08 +00:00
|
|
|
private _vehicleName = getText (configOf _vehicle >> "displayName");
|
2015-09-27 16:19:40 +00:00
|
|
|
|
2016-06-04 10:12:56 +00:00
|
|
|
[[_hint, _itemName, _vehicleName], 3.0] call EFUNC(common,displayTextStructured);
|
2015-09-27 16:19:40 +00:00
|
|
|
|
|
|
|
if (_loaded) then {
|
|
|
|
// Invoke listenable event
|
2016-05-24 13:13:11 +00:00
|
|
|
["ace_cargoLoaded", [_item, _vehicle]] call CBA_fnc_globalEvent;
|
2015-09-27 16:19:40 +00:00
|
|
|
};
|
2016-05-22 15:29:05 +00:00
|
|
|
}] call CBA_fnc_addEventHandler;
|
2015-09-27 16:19:40 +00:00
|
|
|
|
2016-05-24 17:22:48 +00:00
|
|
|
["ace_unloadCargo", {
|
2016-02-23 23:24:51 +00:00
|
|
|
params ["_item", "_vehicle", ["_unloader", objNull]];
|
2016-01-27 20:56:25 +00:00
|
|
|
TRACE_3("UnloadCargo EH",_item,_vehicle,_unloader);
|
2016-02-23 21:05:15 +00:00
|
|
|
|
2016-01-27 20:56:25 +00:00
|
|
|
private _unloaded = [_item, _vehicle, _unloader] call FUNC(unloadItem); //returns true if sucessful
|
2015-09-27 16:19:40 +00:00
|
|
|
|
|
|
|
// Show hint as feedback
|
2016-01-19 03:53:48 +00:00
|
|
|
private _hint = [LSTRING(UnloadingFailed), LSTRING(UnloadedItem)] select _unloaded;
|
2021-10-12 22:42:38 +00:00
|
|
|
private _itemName = [_item, true] call FUNC(getNameItem);
|
2021-02-18 18:58:08 +00:00
|
|
|
private _vehicleName = getText (configOf _vehicle >> "displayName");
|
2015-09-27 16:19:40 +00:00
|
|
|
|
2016-06-04 10:12:56 +00:00
|
|
|
[[_hint, _itemName, _vehicleName], 3.0] call EFUNC(common,displayTextStructured);
|
2015-09-27 16:19:40 +00:00
|
|
|
|
2021-10-10 13:37:16 +00:00
|
|
|
if (_unloaded && {GVAR(openAfterUnload) in [1, 3]}) then {
|
|
|
|
GVAR(interactionVehicle) = _vehicle;
|
|
|
|
GVAR(interactionParadrop) = false;
|
|
|
|
createDialog QGVAR(menu);
|
|
|
|
};
|
2015-09-27 16:19:40 +00:00
|
|
|
|
|
|
|
// TOOO maybe drag/carry the unloaded item?
|
2016-05-22 15:29:05 +00:00
|
|
|
}] call CBA_fnc_addEventHandler;
|
2016-02-23 21:05:15 +00:00
|
|
|
|
2016-05-24 17:22:48 +00:00
|
|
|
[QGVAR(serverUnload), {
|
2016-02-23 21:05:15 +00:00
|
|
|
params ["_item", "_emptyPosAGL"];
|
|
|
|
|
|
|
|
_item hideObjectGlobal false;
|
|
|
|
_item setPosASL (AGLtoASL _emptyPosAGL);
|
2017-08-22 18:27:11 +00:00
|
|
|
|
2020-10-10 16:58:38 +00:00
|
|
|
[_item, "blockDamage", "ACE_cargo", false] call EFUNC(common,statusEffect_set);
|
2016-05-22 15:29:05 +00:00
|
|
|
}] call CBA_fnc_addEventHandler;
|
2017-05-31 22:54:57 +00:00
|
|
|
|
|
|
|
// Private events to handle adding actions globally via public functions
|
|
|
|
[QGVAR(initObject), DFUNC(initObject)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(initVehicle), DFUNC(initVehicle)] call CBA_fnc_addEventHandler;
|
|
|
|
|
2018-02-24 18:39:03 +00:00
|
|
|
|
|
|
|
GVAR(vehicleAction) = [
|
|
|
|
QGVAR(openMenu), localize LSTRING(openMenu), "",
|
|
|
|
{
|
|
|
|
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
|
|
|
|
GVAR(interactionVehicle) = _target;
|
|
|
|
GVAR(interactionParadrop) = false;
|
|
|
|
createDialog QGVAR(menu);
|
|
|
|
},
|
|
|
|
{
|
|
|
|
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
|
|
|
|
GVAR(enable) &&
|
2021-02-18 18:58:08 +00:00
|
|
|
{(_target getVariable [QGVAR(hasCargo), getNumber (configOf _target >> QGVAR(hasCargo)) == 1])} &&
|
2018-02-24 18:39:03 +00:00
|
|
|
{locked _target < 2} &&
|
|
|
|
{([_player, _target] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE} &&
|
|
|
|
{alive _target} &&
|
|
|
|
{[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)}
|
|
|
|
}
|
|
|
|
] call EFUNC(interact_menu,createAction);
|
|
|
|
|
2021-10-12 22:42:38 +00:00
|
|
|
GVAR(objectActions) = [
|
|
|
|
[QGVAR(renameObject), LELSTRING(common,rename), "", //TODO: add icon, maybe a pencil couldn't find it before.
|
|
|
|
{
|
2021-10-17 05:48:31 +00:00
|
|
|
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
|
2021-10-12 22:42:38 +00:00
|
|
|
GVAR(interactionVehicle) = _target;
|
|
|
|
createDialog QGVAR(renameMenu);
|
|
|
|
},
|
|
|
|
{
|
|
|
|
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
|
|
|
|
GVAR(enable) &&
|
|
|
|
{GVAR(enableRename)} &&
|
|
|
|
{(_target getVariable [QGVAR(canLoad), getNumber (configOf _target >> QGVAR(canLoad))]) in [true, 1]} &&
|
|
|
|
{alive _target} &&
|
|
|
|
{[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} &&
|
2021-10-25 23:27:56 +00:00
|
|
|
{(getNumber ((configOf _target) >> QGVAR(noRename))) == 0}
|
2021-10-12 22:42:38 +00:00
|
|
|
}
|
|
|
|
] call EFUNC(interact_menu,createAction),
|
|
|
|
[QGVAR(load), localize LSTRING(loadObject), "a3\ui_f\data\IGUI\Cfg\Actions\loadVehicle_ca.paa",
|
|
|
|
{
|
|
|
|
params ["_target", "_player"];
|
|
|
|
[_player, _target] call FUNC(startLoadIn);
|
|
|
|
},
|
|
|
|
{
|
|
|
|
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
|
|
|
|
GVAR(enable) &&
|
|
|
|
{(_target getVariable [QGVAR(canLoad), getNumber (configOf _target >> QGVAR(canLoad))]) in [true, 1]} &&
|
|
|
|
{locked _target < 2} &&
|
|
|
|
{alive _target} &&
|
|
|
|
{[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} &&
|
|
|
|
{((nearestObjects [_target, GVAR(cargoHolderTypes), (MAX_LOAD_DISTANCE + 10)]) findIf {
|
|
|
|
private _hasCargoConfig = 1 == getNumber (configOf _x >> QGVAR(hasCargo));
|
|
|
|
private _hasCargoPublic = _x getVariable [QGVAR(hasCargo), false];
|
|
|
|
(_hasCargoConfig || {_hasCargoPublic}) && {_x != _target} && {alive _x} && {locked _x < 2} &&
|
|
|
|
{([_target, _x] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}
|
|
|
|
}) > -1}
|
|
|
|
},
|
|
|
|
LINKFUNC(addCargoVehiclesActions)
|
|
|
|
] call EFUNC(interact_menu,createAction)
|
|
|
|
];
|
2018-02-24 18:39:03 +00:00
|
|
|
|
2019-02-17 17:41:05 +00:00
|
|
|
// find all remaining configured classes and init them, see XEH_preStart.sqf
|
|
|
|
private _vehicleClassesAddAction = call (uiNamespace getVariable [QGVAR(initializedVehicleClasses), {[]}]);
|
|
|
|
{
|
|
|
|
[_x, 0, ["ACE_MainActions"], GVAR(vehicleAction)] call EFUNC(interact_menu,addActionToClass);
|
|
|
|
} forEach _vehicleClassesAddAction;
|
|
|
|
GVAR(initializedVehicleClasses) append _vehicleClassesAddAction;
|
2018-02-24 18:39:03 +00:00
|
|
|
|
2019-02-17 17:41:05 +00:00
|
|
|
private _objectClassesAddAction = call (uiNamespace getVariable [QGVAR(initializedItemClasses), {[]}]);
|
2018-02-24 18:39:03 +00:00
|
|
|
{
|
2021-10-12 22:42:38 +00:00
|
|
|
private _objectClass = _x;
|
|
|
|
{
|
|
|
|
[_objectClass, 0, ["ACE_MainActions"], _x] call EFUNC(interact_menu,addActionToClass);
|
|
|
|
} forEach GVAR(objectActions);
|
2019-02-17 17:41:05 +00:00
|
|
|
} forEach _objectClassesAddAction;
|
|
|
|
GVAR(initializedItemClasses) append _objectClassesAddAction;
|
|
|
|
|
|
|
|
private _vehicleClassesAddClassEH = call (uiNamespace getVariable [QGVAR(vehicleClasses_classEH), {[]}]);
|
2018-02-24 18:39:03 +00:00
|
|
|
{
|
2019-02-17 17:41:05 +00:00
|
|
|
[_x, "initPost", DFUNC(initVehicle), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
|
|
|
} forEach _vehicleClassesAddClassEH;
|
2018-02-24 18:39:03 +00:00
|
|
|
|
2019-02-17 17:41:05 +00:00
|
|
|
private _objectClassesAddClassEH = call (uiNamespace getVariable [QGVAR(objectClasses_classEH), {[]}]);
|
2018-02-24 18:39:03 +00:00
|
|
|
{
|
2019-02-17 17:41:05 +00:00
|
|
|
[_x, "initPost", DFUNC(initObject), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
|
|
|
} forEach _objectClassesAddClassEH;
|
2021-10-24 18:01:21 +00:00
|
|
|
|
|
|
|
if (isServer) then {
|
|
|
|
["ace_placedInBodyBag", {
|
|
|
|
params ["_target", "_bodyBag"];
|
|
|
|
_bodyBag setVariable [QGVAR(customName), [_target, false, true] call EFUNC(common,getName), true];
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
};
|