2015-08-18 16:48:21 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
["ace_addCargo", LINKFUNC(addCargoItem)] 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
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
private _loaded = [_item, _vehicle] call FUNC(loadItem); // returns true if successful
|
2015-09-27 16:19:40 +00:00
|
|
|
|
|
|
|
// Show hint as feedback
|
2023-11-17 23:07:28 +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
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
[[_hint, _itemName, _vehicleName], 3] call EFUNC(common,displayTextStructured);
|
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", {
|
2024-02-07 12:16:18 +00:00
|
|
|
params ["_item", "_vehicle", ["_unloader", objNull], ["_place", []]];
|
|
|
|
TRACE_4("UnloadCargo EH",_item,_vehicle,_unloader,_place);
|
2016-02-23 21:05:15 +00:00
|
|
|
|
2024-02-07 12:16:18 +00:00
|
|
|
private _unloaded = [_item, _vehicle, _unloader, _place] call FUNC(unloadItem); // returns true if successful
|
2015-09-27 16:19:40 +00:00
|
|
|
|
|
|
|
// Show hint as feedback
|
2023-11-17 23:07:28 +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
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
[[_hint, _itemName, _vehicleName], 3] 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);
|
|
|
|
};
|
2016-05-22 15:29:05 +00:00
|
|
|
}] call CBA_fnc_addEventHandler;
|
2016-02-23 21:05:15 +00:00
|
|
|
|
2024-02-07 12:16:18 +00:00
|
|
|
// Direction must be set before setting position according to wiki
|
|
|
|
[QGVAR(setDirAndUnload), {
|
|
|
|
params ["_item", "_emptyPosAGL", "_direction"];
|
|
|
|
|
|
|
|
_item setDir _direction;
|
|
|
|
|
|
|
|
[QGVAR(serverUnload), [_item, _emptyPosAGL]] call CBA_fnc_serverEvent;
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
|
|
|
|
// hideObjectGlobal must be executed before setPos to ensure light objects are rendered correctly
|
|
|
|
// Do both on server to ensure they are executed in the correct order
|
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
|
|
|
|
2024-02-07 12:16:18 +00:00
|
|
|
// Let objects remain invulernable for a short while after placement
|
|
|
|
[EFUNC(common,statusEffect_set), [_item, "blockDamage", QUOTE(ADDON), false], 2] call CBA_fnc_waitAndExecute;
|
2016-05-22 15:29:05 +00:00
|
|
|
}] call CBA_fnc_addEventHandler;
|
2017-05-31 22:54:57 +00:00
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
[QGVAR(paradropItem), {
|
|
|
|
params ["_item", "_vehicle", ["_showHint", true]];
|
2017-05-31 22:54:57 +00:00
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
private _unloaded = [_item, _vehicle, _showHint] call FUNC(paradropItem);
|
|
|
|
|
|
|
|
if (_unloaded && {GVAR(openAfterUnload) in [2, 3]}) then {
|
|
|
|
GVAR(interactionVehicle) = _vehicle;
|
|
|
|
GVAR(interactionParadrop) = true;
|
|
|
|
createDialog QGVAR(menu);
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
|
|
|
|
// Private events to handle adding actions globally via public functions
|
|
|
|
[QGVAR(initObject), LINKFUNC(initObject)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(initVehicle), LINKFUNC(initVehicle)] call CBA_fnc_addEventHandler;
|
2018-02-24 18:39:03 +00:00
|
|
|
|
|
|
|
GVAR(vehicleAction) = [
|
2023-11-17 23:07:28 +00:00
|
|
|
QGVAR(openMenu), LLSTRING(openMenu), "",
|
2018-02-24 18:39:03 +00:00
|
|
|
{
|
|
|
|
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
|
|
|
|
GVAR(interactionVehicle) = _target;
|
|
|
|
GVAR(interactionParadrop) = false;
|
|
|
|
createDialog QGVAR(menu);
|
|
|
|
},
|
|
|
|
{
|
|
|
|
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
|
|
|
|
GVAR(enable) &&
|
|
|
|
{alive _target} &&
|
2023-11-17 23:07:28 +00:00
|
|
|
{locked _target < 2} &&
|
|
|
|
{(_target getVariable [QGVAR(hasCargo), getNumber (configOf _target >> QGVAR(hasCargo)) == 1])} &&
|
2023-11-11 12:03:32 +00:00
|
|
|
{[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} &&
|
2023-11-17 23:07:28 +00:00
|
|
|
{[_player, _target] call EFUNC(interaction,canInteractWithVehicleCrew)} &&
|
|
|
|
{([_player, _target] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}
|
2018-02-24 18:39:03 +00:00
|
|
|
}
|
|
|
|
] call EFUNC(interact_menu,createAction);
|
|
|
|
|
2021-10-12 22:42:38 +00:00
|
|
|
GVAR(objectActions) = [
|
2023-11-17 23:07:28 +00:00
|
|
|
[QGVAR(renameObject), LELSTRING(common,rename), "\a3\Modules_F_Curator\Data\iconMissionName_ca.paa",
|
2021-10-12 22:42:38 +00:00
|
|
|
{
|
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)} &&
|
|
|
|
{alive _target} &&
|
2023-11-17 23:07:28 +00:00
|
|
|
{_target getVariable [QGVAR(canLoad), getNumber (configOf _target >> QGVAR(canLoad)) == 1]} &&
|
|
|
|
{!(_target getVariable [QGVAR(noRename), getNumber (configOf _target >> QGVAR(noRename)) == 1])} &&
|
2021-10-12 22:42:38 +00:00
|
|
|
{[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} &&
|
2023-11-17 23:07:28 +00:00
|
|
|
{[_player, _target] call EFUNC(interaction,canInteractWithVehicleCrew)}
|
2021-10-12 22:42:38 +00:00
|
|
|
}
|
|
|
|
] call EFUNC(interact_menu,createAction),
|
2023-11-17 23:07:28 +00:00
|
|
|
[QGVAR(load), LLSTRING(loadObject), "a3\ui_f\data\IGUI\Cfg\Actions\loadVehicle_ca.paa",
|
2021-10-12 22:42:38 +00:00
|
|
|
{
|
2023-11-17 23:07:28 +00:00
|
|
|
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
|
2021-10-12 22:42:38 +00:00
|
|
|
[_player, _target] call FUNC(startLoadIn);
|
|
|
|
},
|
|
|
|
{
|
|
|
|
//IGNORE_PRIVATE_WARNING ["_target", "_player"];
|
|
|
|
GVAR(enable) &&
|
|
|
|
{alive _target} &&
|
2023-11-17 23:07:28 +00:00
|
|
|
{locked _target < 2} &&
|
|
|
|
{_target getVariable [QGVAR(canLoad), getNumber (configOf _target >> QGVAR(canLoad)) == 1]} &&
|
2021-10-12 22:42:38 +00:00
|
|
|
{[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} &&
|
2023-11-11 12:03:32 +00:00
|
|
|
{[_player, _target] call EFUNC(interaction,canInteractWithVehicleCrew)} &&
|
2023-11-17 23:07:28 +00:00
|
|
|
{((nearestObjects [_target, GVAR(cargoHolderTypes), MAX_LOAD_DISTANCE + 10]) findIf {
|
|
|
|
_x != _target &&
|
|
|
|
{alive _x} &&
|
|
|
|
{locked _x < 2} &&
|
|
|
|
{_x getVariable [QGVAR(hasCargo), getNumber (configOf _x >> QGVAR(hasCargo)) == 1]} &&
|
2021-10-12 22:42:38 +00:00
|
|
|
{([_target, _x] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}
|
2023-11-17 23:07:28 +00:00
|
|
|
}) != -1}
|
2021-10-12 22:42:38 +00:00
|
|
|
},
|
|
|
|
LINKFUNC(addCargoVehiclesActions)
|
|
|
|
] call EFUNC(interact_menu,createAction)
|
|
|
|
];
|
2018-02-24 18:39:03 +00:00
|
|
|
|
2023-11-17 23:07:28 +00:00
|
|
|
// Find all remaining configured classes and init them, see XEH_preStart.sqf
|
2019-02-17 17:41:05 +00:00
|
|
|
private _vehicleClassesAddAction = call (uiNamespace getVariable [QGVAR(initializedVehicleClasses), {[]}]);
|
2023-11-17 23:07:28 +00:00
|
|
|
|
2019-02-17 17:41:05 +00:00
|
|
|
{
|
|
|
|
[_x, 0, ["ACE_MainActions"], GVAR(vehicleAction)] call EFUNC(interact_menu,addActionToClass);
|
|
|
|
} forEach _vehicleClassesAddAction;
|
2023-11-17 23:07:28 +00:00
|
|
|
|
2019-02-17 17:41:05 +00:00
|
|
|
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), {[]}]);
|
2023-11-17 23:07:28 +00:00
|
|
|
|
2018-02-24 18:39:03 +00:00
|
|
|
{
|
2021-10-12 22:42:38 +00:00
|
|
|
private _objectClass = _x;
|
2023-11-17 23:07:28 +00:00
|
|
|
|
2021-10-12 22:42:38 +00:00
|
|
|
{
|
|
|
|
[_objectClass, 0, ["ACE_MainActions"], _x] call EFUNC(interact_menu,addActionToClass);
|
|
|
|
} forEach GVAR(objectActions);
|
2019-02-17 17:41:05 +00:00
|
|
|
} forEach _objectClassesAddAction;
|
2023-11-17 23:07:28 +00:00
|
|
|
|
2019-02-17 17:41:05 +00:00
|
|
|
GVAR(initializedItemClasses) append _objectClassesAddAction;
|
|
|
|
|
|
|
|
private _vehicleClassesAddClassEH = call (uiNamespace getVariable [QGVAR(vehicleClasses_classEH), {[]}]);
|
2023-11-17 23:07:28 +00:00
|
|
|
|
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), {[]}]);
|
2023-11-17 23:07:28 +00:00
|
|
|
|
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", {
|
2023-10-02 15:05:56 +00:00
|
|
|
params ["_target", "_bodyBag", "_isGrave"];
|
2023-11-17 23:07:28 +00:00
|
|
|
|
2023-10-02 15:05:56 +00:00
|
|
|
if (_isGrave) exitWith {}; // assume graves aren't cargo
|
2023-11-17 23:07:28 +00:00
|
|
|
|
2021-10-24 18:01:21 +00:00
|
|
|
_bodyBag setVariable [QGVAR(customName), [_target, false, true] call EFUNC(common,getName), true];
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
};
|
2024-02-07 12:16:18 +00:00
|
|
|
|
|
|
|
// Set variables, even on machines without interfaces, just to be safe
|
|
|
|
GVAR(selectedItem) = objNull;
|
|
|
|
GVAR(itemPreviewObject) = objNull;
|
|
|
|
GVAR(deployPFH) = -1;
|
|
|
|
GVAR(deployDistance) = -1;
|
|
|
|
GVAR(deployDirection) = 0;
|
|
|
|
GVAR(deployHeight) = 0;
|
|
|
|
GVAR(canDeploy) = false;
|
|
|
|
|
|
|
|
if (!hasInterface) exitWith {};
|
|
|
|
|
|
|
|
// Cancel object deployment if interact menu opened
|
|
|
|
["ace_interactMenuOpened", {ACE_player call FUNC(handleDeployInterrupt)}] call CBA_fnc_addEventHandler;
|
|
|
|
|
|
|
|
// Cancel deploy on player change. This does work when returning to lobby, but not when hard disconnecting
|
|
|
|
["unit", LINKFUNC(handleDeployInterrupt)] call CBA_fnc_addPlayerEventHandler;
|
|
|
|
["vehicle", {(_this select 0) call FUNC(handleDeployInterrupt)}] call CBA_fnc_addPlayerEventHandler;
|
|
|
|
["weapon", {(_this select 0) call FUNC(handleDeployInterrupt)}] call CBA_fnc_addPlayerEventHandler;
|
|
|
|
|
|
|
|
// When changing feature cameras, stop deployment
|
|
|
|
["featureCamera", {(_this select 0) call FUNC(handleDeployInterrupt)}] call CBA_fnc_addPlayerEventHandler;
|
|
|
|
|
|
|
|
// Handle falling unconscious while trying to deploy
|
|
|
|
["ace_unconscious", {(_this select 0) call FUNC(handleDeployInterrupt)}] call CBA_fnc_addEventHandler;
|
|
|
|
|
|
|
|
// Handle surrendering and handcuffing
|
|
|
|
["ace_captiveStatusChanged", {
|
|
|
|
params ["_unit", "_state"];
|
|
|
|
|
|
|
|
// If surrendered or handcuffed, stop deployment
|
|
|
|
if (_state) then {
|
|
|
|
_unit call FUNC(handleDeployInterrupt);
|
|
|
|
};
|
|
|
|
}] call CBA_fnc_addEventHandler;
|