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;
|
2016-08-27 08:14:54 +00:00
|
|
|
[QGVAR(paradropItem), {_this call FUNC(paradropItem)}] 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;
|
|
|
|
private _itemName = getText (configFile >> "CfgVehicles" >> typeOf _item >> "displayName");
|
|
|
|
private _vehicleName = getText (configFile >> "CfgVehicles" >> typeOf _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
|
|
|
|
2016-01-19 03:53:48 +00:00
|
|
|
private _itemClass = if (_item isEqualType "") then {_item} else {typeOf _item};
|
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;
|
|
|
|
private _itemName = getText (configFile >> "CfgVehicles" >> _itemClass >> "displayName");
|
|
|
|
private _vehicleName = getText (configFile >> "CfgVehicles" >> typeOf _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 (_unloaded) then {
|
|
|
|
// Invoke listenable event
|
2016-05-24 13:13:11 +00:00
|
|
|
["ace_cargoUnloaded", [_item, _vehicle]] call CBA_fnc_globalEvent;
|
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
|
|
|
|
|
|
|
if ((getText (configFile >> "CfgVehicles" >> (typeOf _item) >> "simulation")) == "carx") then {
|
|
|
|
TRACE_1("re-enabling car damage",_item);
|
|
|
|
[_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) &&
|
|
|
|
{(_target getVariable [QGVAR(hasCargo), getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(hasCargo)) == 1])} &&
|
|
|
|
{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);
|
|
|
|
|
|
|
|
GVAR(objectAction) = [
|
|
|
|
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 (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(canLoad))]) in [true, 1]} &&
|
|
|
|
{locked _target < 2} &&
|
|
|
|
{alive _target} &&
|
|
|
|
{[_player, _target, ["isNotSwimming"]] call EFUNC(common,canInteractWith)} &&
|
|
|
|
{0 < {
|
|
|
|
private _type = typeOf _x;
|
|
|
|
private _hasCargoPublic = _x getVariable [QGVAR(hasCargo), false];
|
|
|
|
private _hasCargoConfig = getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) == 1;
|
|
|
|
(_hasCargoPublic || _hasCargoConfig) && {_x != _target} &&
|
|
|
|
{([_target, _x] call EFUNC(interaction,getInteractionDistance)) < MAX_LOAD_DISTANCE}
|
|
|
|
} count (nearestObjects [_player, GVAR(cargoHolderTypes), (MAX_LOAD_DISTANCE + 10)])}
|
|
|
|
},
|
|
|
|
LINKFUNC(addCargoVehiclesActions)
|
|
|
|
] call EFUNC(interact_menu,createAction);
|
|
|
|
|
|
|
|
|
|
|
|
private _initVehicleClasses = ["ThingX", "LandVehicle", "Air", "Ship_F"];
|
|
|
|
private _initObjectClasses = ["ThingX", "StaticWeapon"];
|
|
|
|
{
|
|
|
|
[_x, "initPost", DFUNC(initVehicle), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
|
|
|
} forEach _initVehicleClasses;
|
|
|
|
{
|
|
|
|
[_x, "initPost", DFUNC(initObject), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
|
|
|
} forEach _initObjectClasses;
|
|
|
|
|
|
|
|
// find all remaining configured classes and init them
|
|
|
|
{
|
|
|
|
private _class = configName _x;
|
|
|
|
// init vehicle
|
|
|
|
if (
|
|
|
|
1 == getNumber (_x >> QGVAR(hasCargo))
|
|
|
|
&& {{if (_class isKindOf _x) exitWith {false}; true} forEach _initVehicleClasses}
|
|
|
|
) then {
|
|
|
|
if (_class isKindOf "Static") then {
|
|
|
|
if (2 == getNumber (_x >> "scope")) then {
|
|
|
|
[_class, 0, ["ACE_MainActions"], GVAR(vehicleAction)] call EFUNC(interact_menu,addActionToClass);
|
|
|
|
GVAR(initializedVehicleClasses) pushBack _class;
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
[_class, "initPost", DFUNC(initVehicle), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
|
|
|
_initVehicleClasses pushBack _class;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
// init object
|
|
|
|
if (
|
|
|
|
1 == getNumber (_x >> QGVAR(canLoad))
|
|
|
|
&& {{if (_class isKindOf _x) exitWith {false}; true} forEach _initObjectClasses}
|
|
|
|
) then {
|
|
|
|
if (_class isKindOf "Static") then {
|
|
|
|
if (2 == getNumber (_x >> "scope")) then {
|
|
|
|
[_class, 0, ["ACE_MainActions"], GVAR(objectAction)] call EFUNC(interact_menu,addActionToClass);
|
|
|
|
GVAR(initializedItemClasses) pushBack _class;
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
[_class, "initPost", DFUNC(initObject), nil, nil, true] call CBA_fnc_addClassEventHandler;
|
|
|
|
_initObjectClasses pushBack _class;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} forEach ("true" configClasses (configFile >> "CfgVehicles"));
|