mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Cargo Cleanup, Add makeLoadable
This commit is contained in:
parent
b99be6122b
commit
3d4fc66bb1
@ -12,7 +12,9 @@ class Extended_PostInit_EventHandlers {
|
|||||||
|
|
||||||
class Extended_Killed_EventHandlers {
|
class Extended_Killed_EventHandlers {
|
||||||
class All {
|
class All {
|
||||||
init = QUOTE(call FUNC(handleDestroyed));
|
class ADDON {
|
||||||
|
serverKilled = QUOTE(call FUNC(handleDestroyed));
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ class CfgVehicles {
|
|||||||
GVAR(space) = 0;
|
GVAR(space) = 0;
|
||||||
GVAR(hasCargo) = 0;
|
GVAR(hasCargo) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// boats
|
// boats
|
||||||
class Ship;
|
class Ship;
|
||||||
class Ship_F: Ship {
|
class Ship_F: Ship {
|
||||||
@ -245,7 +245,7 @@ class CfgVehicles {
|
|||||||
class RoadBarrier_F: RoadCone_F {
|
class RoadBarrier_F: RoadCone_F {
|
||||||
GVAR(size) = 2;
|
GVAR(size) = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Scrapyard_base_F;
|
class Scrapyard_base_F;
|
||||||
class Land_PaperBox_closed_F: Scrapyard_base_F {
|
class Land_PaperBox_closed_F: Scrapyard_base_F {
|
||||||
|
@ -4,14 +4,13 @@
|
|||||||
|
|
||||||
["LoadCargo", {
|
["LoadCargo", {
|
||||||
(_this select 0) params ["_item","_vehicle"];
|
(_this select 0) params ["_item","_vehicle"];
|
||||||
private ["_loaded", "_hint", "_itemName", "_vehicleName"];
|
|
||||||
|
|
||||||
_loaded = [_item, _vehicle] call FUNC(loadItem);
|
private _loaded = [_item, _vehicle] call FUNC(loadItem);
|
||||||
|
|
||||||
// Show hint as feedback
|
// Show hint as feedback
|
||||||
_hint = [LSTRING(LoadingFailed), LSTRING(LoadedItem)] select _loaded;
|
private _hint = [LSTRING(LoadingFailed), LSTRING(LoadedItem)] select _loaded;
|
||||||
_itemName = getText (configFile >> "CfgVehicles" >> typeOf _item >> "displayName");
|
private _itemName = getText (configFile >> "CfgVehicles" >> typeOf _item >> "displayName");
|
||||||
_vehicleName = getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName");
|
private _vehicleName = getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName");
|
||||||
|
|
||||||
["displayTextStructured", [[_hint, _itemName, _vehicleName], 3.0]] call EFUNC(common,localEvent);
|
["displayTextStructured", [[_hint, _itemName, _vehicleName], 3.0]] call EFUNC(common,localEvent);
|
||||||
|
|
||||||
@ -23,16 +22,15 @@
|
|||||||
|
|
||||||
["UnloadCargo", {
|
["UnloadCargo", {
|
||||||
(_this select 0) params ["_item","_vehicle"];
|
(_this select 0) params ["_item","_vehicle"];
|
||||||
private ["_unloaded", "_itemClass", "_hint", "_itemName", "_vehicleName"];
|
|
||||||
|
|
||||||
_unloaded = [_item, _vehicle] call FUNC(unloadItem);
|
private _unloaded = [_item, _vehicle] call FUNC(unloadItem);
|
||||||
|
|
||||||
_itemClass = if (_item isEqualType "") then {_item} else {typeOf _item};
|
private _itemClass = if (_item isEqualType "") then {_item} else {typeOf _item};
|
||||||
|
|
||||||
// Show hint as feedback
|
// Show hint as feedback
|
||||||
_hint = [LSTRING(UnloadingFailed), LSTRING(UnloadedItem)] select _unloaded;
|
private _hint = [LSTRING(UnloadingFailed), LSTRING(UnloadedItem)] select _unloaded;
|
||||||
_itemName = getText (configFile >> "CfgVehicles" >> _itemClass >> "displayName");
|
private _itemName = getText (configFile >> "CfgVehicles" >> _itemClass >> "displayName");
|
||||||
_vehicleName = getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName");
|
private _vehicleName = getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName");
|
||||||
|
|
||||||
["displayTextStructured", [[_hint, _itemName, _vehicleName], 3.0]] call EFUNC(common,localEvent);
|
["displayTextStructured", [[_hint, _itemName, _vehicleName], 3.0]] call EFUNC(common,localEvent);
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ PREP(handleDestroyed);
|
|||||||
PREP(initObject);
|
PREP(initObject);
|
||||||
PREP(initVehicle);
|
PREP(initVehicle);
|
||||||
PREP(loadItem);
|
PREP(loadItem);
|
||||||
|
PREP(makeLoadable);
|
||||||
PREP(moduleSettings);
|
PREP(moduleSettings);
|
||||||
PREP(onMenuOpen);
|
PREP(onMenuOpen);
|
||||||
PREP(startLoadIn);
|
PREP(startLoadIn);
|
||||||
@ -21,5 +22,6 @@ PREP(unloadItem);
|
|||||||
PREP(validateCargoSpace);
|
PREP(validateCargoSpace);
|
||||||
|
|
||||||
GVAR(initializedItemClasses) = [];
|
GVAR(initializedItemClasses) = [];
|
||||||
|
GVAR(initializedVehicleClasses) = [];
|
||||||
|
|
||||||
ADDON = true;
|
ADDON = true;
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_player", "_object"];
|
params ["_player", "_object"];
|
||||||
|
TRACE_2("params",_player,_object);
|
||||||
|
|
||||||
if (!([_player, _object, []] call EFUNC(common,canInteractWith))) exitWith {false};
|
if (!([_player, _object, []] call EFUNC(common,canInteractWith))) exitWith {false};
|
||||||
|
|
||||||
private ["_nearestVehicle"];
|
private _nearestVehicle = [_player] call FUNC(findNearestVehicle);
|
||||||
_nearestVehicle = [_player] call FUNC(findNearestVehicle);
|
|
||||||
|
|
||||||
if (_nearestVehicle isKindOf "Cargo_Base_F" || isNull _nearestVehicle) then {
|
if (_nearestVehicle isKindOf "Cargo_Base_F" || isNull _nearestVehicle) then {
|
||||||
{
|
{
|
||||||
|
@ -18,11 +18,10 @@
|
|||||||
|
|
||||||
params [["_item", "", [objNull,""]], "_vehicle"];
|
params [["_item", "", [objNull,""]], "_vehicle"];
|
||||||
|
|
||||||
if (speed _vehicle > 1 || (((getPos _vehicle) select 2) > 3)) exitWith {false};
|
if (speed _vehicle > 1 || {((getPos _vehicle) select 2) > 3}) exitWith {false};
|
||||||
|
|
||||||
private ["_itemSize", "_validItem"];
|
|
||||||
_itemSize = [_item] call FUNC(getSizeItem);
|
|
||||||
|
|
||||||
|
private _itemSize = [_item] call FUNC(getSizeItem);
|
||||||
|
private _validItem = false;
|
||||||
if (_item isEqualType "") then {
|
if (_item isEqualType "") then {
|
||||||
_validItem =
|
_validItem =
|
||||||
isClass (configFile >> "CfgVehicles" >> _item) &&
|
isClass (configFile >> "CfgVehicles" >> _item) &&
|
||||||
|
@ -17,15 +17,15 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_item", "_vehicle"];
|
params ["_item", "_vehicle"];
|
||||||
private ["_loaded", "_itemClass", "_validVehiclestate", "_emptyPos"];
|
TRACE_2("params",_item,_vehicle);
|
||||||
|
|
||||||
_loaded = _vehicle getVariable [QGVAR(loaded), []];
|
private _loaded = _vehicle getVariable [QGVAR(loaded), []];
|
||||||
if !(_item in _loaded) exitWith {false};
|
if !(_item in _loaded) exitWith {false};
|
||||||
|
|
||||||
_itemClass = if (_item isEqualType "") then {_item} else {typeOf _item};
|
private _itemClass = if (_item isEqualType "") then {_item} else {typeOf _item};
|
||||||
|
|
||||||
_validVehiclestate = true;
|
private _validVehiclestate = true;
|
||||||
_emptyPos = [];
|
private _emptyPos = [];
|
||||||
if (_vehicle isKindOf "Ship" ) then {
|
if (_vehicle isKindOf "Ship" ) then {
|
||||||
if !(speed _vehicle <1 && {(((getPosATL _vehicle) select 2) < 2)}) then {_validVehiclestate = false};
|
if !(speed _vehicle <1 && {(((getPosATL _vehicle) select 2) < 2)}) then {_validVehiclestate = false};
|
||||||
_emptyPos = ((getPosASL _vehicle) call EFUNC(common,ASLtoPosition) findEmptyPosition [0, 15, _itemClass]); // TODO: if spot is underwater pick another spot.
|
_emptyPos = ((getPosASL _vehicle) call EFUNC(common,ASLtoPosition) findEmptyPosition [0, 15, _itemClass]); // TODO: if spot is underwater pick another spot.
|
||||||
|
@ -15,23 +15,21 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_loadCar", "_loadHelicopter", "_loadTank", "_loadShip", "_loadContainer"];
|
|
||||||
|
|
||||||
params ["_unit"];
|
params ["_unit"];
|
||||||
|
|
||||||
_loadCar = nearestObject [_unit, "car"];
|
private _loadCar = nearestObject [_unit, "car"];
|
||||||
if (_unit distance _loadCar <= MAX_LOAD_DISTANCE) exitWith {_loadCar};
|
if (_unit distance _loadCar <= MAX_LOAD_DISTANCE) exitWith {_loadCar};
|
||||||
|
|
||||||
_loadHelicopter = nearestObject [_unit, "air"];
|
private _loadHelicopter = nearestObject [_unit, "air"];
|
||||||
if (_unit distance _loadHelicopter <= MAX_LOAD_DISTANCE) exitWith {_loadHelicopter};
|
if (_unit distance _loadHelicopter <= MAX_LOAD_DISTANCE) exitWith {_loadHelicopter};
|
||||||
|
|
||||||
_loadTank = nearestObject [_unit, "tank"];
|
private _loadTank = nearestObject [_unit, "tank"];
|
||||||
if (_unit distance _loadTank <= MAX_LOAD_DISTANCE) exitWith {_loadTank};
|
if (_unit distance _loadTank <= MAX_LOAD_DISTANCE) exitWith {_loadTank};
|
||||||
|
|
||||||
_loadShip = nearestObject [_unit, "ship"];
|
private _loadShip = nearestObject [_unit, "ship"];
|
||||||
if (_unit distance _loadShip <= MAX_LOAD_DISTANCE) exitWith {_loadShip};
|
if (_unit distance _loadShip <= MAX_LOAD_DISTANCE) exitWith {_loadShip};
|
||||||
|
|
||||||
_loadContainer = nearestObject [_unit,"Cargo_base_F"];
|
private _loadContainer = nearestObject [_unit,"Cargo_base_F"];
|
||||||
if (_unit distance _loadContainer <= MAX_LOAD_DISTANCE) exitWith {_loadContainer};
|
if (_unit distance _loadContainer <= MAX_LOAD_DISTANCE) exitWith {_loadContainer};
|
||||||
|
|
||||||
objNull
|
objNull
|
||||||
|
@ -16,5 +16,6 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_object"];
|
params ["_object"];
|
||||||
|
// TRACE_1("params",_object);
|
||||||
|
|
||||||
_object getVariable [QGVAR(space), getNumber (configFile >> "CfgVehicles" >> typeOf _object >> QGVAR(space))]
|
_object getVariable [QGVAR(space), getNumber (configFile >> "CfgVehicles" >> typeOf _object >> QGVAR(space))]
|
||||||
|
@ -16,22 +16,23 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_item"];
|
params ["_item"];
|
||||||
private ["_isVirtual","_itemClass","_config"];
|
|
||||||
scopeName "return";
|
scopeName "return";
|
||||||
|
|
||||||
_isVirtual = (_item isEqualType "");
|
private _isVirtual = (_item isEqualType "");
|
||||||
_itemClass = if (_isVirtual) then {_item} else {typeOf _item};
|
private _itemClass = if (_isVirtual) then {_item} else {typeOf _item};
|
||||||
_config = (configFile >> "CfgVehicles" >> _itemClass >> QGVAR(size));
|
private _config = (configFile >> "CfgVehicles" >> _itemClass >> QGVAR(size));
|
||||||
|
|
||||||
if (_isVirtual) then {
|
if (_isVirtual) then {
|
||||||
if (isNumber _config) then {
|
if (isNumber _config) then {
|
||||||
(getNumber _config) breakOut "return";
|
(getNumber _config) breakOut "return";
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
_config = (configFile >> "CfgVehicles" >> typeOf _item >> QGVAR(size));
|
if (!isNil {_item getVariable QGVAR(size)}) then {
|
||||||
|
(_item getVariable QGVAR(size)) breakOut "return";
|
||||||
|
};
|
||||||
if (isNumber _config) then {
|
if (isNumber _config) then {
|
||||||
(_item getVariable [QGVAR(size), getNumber _config]) breakOut "return";
|
(getNumber _config) breakOut "return";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Glowbal
|
* Author: Glowbal
|
||||||
* Handle object being destroyed.
|
* Handle object being destroyed. Only runs on server.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Object <OBJECT>
|
* 0: Object <OBJECT>
|
||||||
@ -16,10 +16,9 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_vehicle"];
|
params ["_vehicle"];
|
||||||
|
TRACE_1("params",_vehicle);
|
||||||
|
|
||||||
private["_loaded"];
|
private _loaded = _vehicle getVariable [QGVAR(loaded), []];
|
||||||
|
|
||||||
_loaded = _vehicle getVariable [QGVAR(loaded), []];
|
|
||||||
if (_loaded isEqualTo []) exitWith {};
|
if (_loaded isEqualTo []) exitWith {};
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -27,6 +26,7 @@ if (_loaded isEqualTo []) exitWith {};
|
|||||||
if (_x isEqualType objNull) then {
|
if (_x isEqualType objNull) then {
|
||||||
deleteVehicle _x;
|
deleteVehicle _x;
|
||||||
};
|
};
|
||||||
|
nil
|
||||||
} count _loaded;
|
} count _loaded;
|
||||||
|
|
||||||
[_vehicle] call FUNC(validateCargoSpace);
|
[_vehicle] call FUNC(validateCargoSpace);
|
||||||
|
@ -16,15 +16,31 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_object"];
|
params ["_object"];
|
||||||
|
private _type = typeOf _object;
|
||||||
|
TRACE_2("params",_object,_type);
|
||||||
|
|
||||||
if (getNumber (configFile >> "CfgVehicles" >> typeOf _object >> QGVAR(canLoad)) != 1) exitWith {};
|
if ((_object getVariable [QGVAR(canLoad), getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(canLoad))]) != 1) exitWith {};
|
||||||
|
|
||||||
private ["_type", "_action"];
|
|
||||||
_type = typeOf _object;
|
|
||||||
|
|
||||||
// do nothing if the class is already initialized
|
// do nothing if the class is already initialized
|
||||||
if (_type in GVAR(initializedItemClasses)) exitWith {};
|
if (_type in GVAR(initializedItemClasses)) exitWith {};
|
||||||
GVAR(initializedItemClasses) pushBack _type;
|
GVAR(initializedItemClasses) pushBack _type;
|
||||||
|
|
||||||
_action = [QGVAR(load), localize LSTRING(loadObject), QUOTE(PATHTOF(UI\Icon_load.paa)), {[_player, _target] call FUNC(startLoadIn)}, {GVAR(enable) && {[_player, _target] call FUNC(canLoad)}}] call EFUNC(interact_menu,createAction);
|
TRACE_1("Adding load cargo action to class", _type);
|
||||||
|
|
||||||
|
private _condition = {
|
||||||
|
GVAR(enable) &&
|
||||||
|
{(_target getVariable [QGVAR(canLoad), getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(canLoad))]) == 1} &&
|
||||||
|
{locked _target < 2} &&
|
||||||
|
{alive _target} &&
|
||||||
|
{[_player, _target, []] call EFUNC(common,canInteractWith)}
|
||||||
|
};
|
||||||
|
private _statement = {
|
||||||
|
params ["_target", "_player"];
|
||||||
|
[_player, _target] call FUNC(startLoadIn);
|
||||||
|
};
|
||||||
|
private _text = localize LSTRING(loadObject);
|
||||||
|
private _icon = QUOTE(PATHTOF(UI\Icon_load.paa));
|
||||||
|
|
||||||
|
private _action = [QGVAR(load), _text, _icon, _statement, _condition] call EFUNC(interact_menu,createAction);
|
||||||
[_type, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToClass);
|
[_type, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToClass);
|
||||||
|
|
||||||
|
@ -18,9 +18,7 @@
|
|||||||
params ["_vehicle"];
|
params ["_vehicle"];
|
||||||
TRACE_1("params", _vehicle);
|
TRACE_1("params", _vehicle);
|
||||||
|
|
||||||
private ["_type", "_initializedClasses"];
|
private _type = typeOf _vehicle;
|
||||||
_type = typeOf _vehicle;
|
|
||||||
_initializedClasses = GETMVAR(GVAR(initializedClasses),[]);
|
|
||||||
|
|
||||||
if (isServer) then {
|
if (isServer) then {
|
||||||
{
|
{
|
||||||
@ -35,21 +33,24 @@ if (isServer) then {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// do nothing if the class is already initialized
|
// do nothing if the class is already initialized
|
||||||
if (_type in _initializedClasses) exitWith {};
|
if (_type in GVAR(initializedVehicleClasses)) exitWith {};
|
||||||
// set class as initialized
|
// set class as initialized
|
||||||
_initializedClasses pushBack _type;
|
GVAR(initializedVehicleClasses) pushBack _type;
|
||||||
SETMVAR(GVAR(initializedClasses),_initializedClasses);
|
|
||||||
|
|
||||||
|
if (!hasInterface) exitWith {};
|
||||||
if (getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) != 1) exitWith {};
|
if (getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) != 1) exitWith {};
|
||||||
|
|
||||||
private ["_text", "_condition", "_statement", "_icon", "_action"];
|
TRACE_1("Adding unload cargo action to class", _type);
|
||||||
_condition = {
|
|
||||||
params ["_target", "_player"];
|
private _condition = {
|
||||||
GVAR(enable) && {locked _target < 2} && {alive _target} && {[_player, _target, []] call EFUNC(common,canInteractWith)}
|
GVAR(enable) && {locked _target < 2} && {alive _target} && {[_player, _target, []] call EFUNC(common,canInteractWith)}
|
||||||
};
|
};
|
||||||
_text = localize LSTRING(openMenu);
|
private _statement = {
|
||||||
_statement = {GVAR(interactionVehicle) = _target; createDialog QGVAR(menu);};
|
GVAR(interactionVehicle) = _target;
|
||||||
_icon = "";
|
createDialog QGVAR(menu);
|
||||||
|
};
|
||||||
|
private _text = localize LSTRING(openMenu);
|
||||||
|
private _icon = "";
|
||||||
|
|
||||||
_action = [QGVAR(openMenu), _text, _icon, _statement, _condition] call EFUNC(interact_menu,createAction);
|
private _action = [QGVAR(openMenu), _text, _icon, _statement, _condition] call EFUNC(interact_menu,createAction);
|
||||||
[_type, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToClass);
|
[_type, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToClass);
|
||||||
|
@ -19,18 +19,17 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params [["_item","",[objNull,""]], ["_vehicle",objNull,[objNull]]];
|
params [["_item","",[objNull,""]], ["_vehicle",objNull,[objNull]]];
|
||||||
private ["_loaded", "_space", "_itemSize"];
|
|
||||||
|
|
||||||
if !([_item, _vehicle] call FUNC(canLoadItemIn)) exitWith {false};
|
if !([_item, _vehicle] call FUNC(canLoadItemIn)) exitWith {false};
|
||||||
|
|
||||||
_loaded = _vehicle getVariable [QGVAR(loaded), []];
|
private _loaded = _vehicle getVariable [QGVAR(loaded), []];
|
||||||
_loaded pushBack _item;
|
_loaded pushBack _item;
|
||||||
_vehicle setVariable [QGVAR(loaded), _loaded, true];
|
_vehicle setVariable [QGVAR(loaded), _loaded, true];
|
||||||
|
|
||||||
TRACE_1("added to loaded array",_loaded);
|
TRACE_1("added to loaded array",_loaded);
|
||||||
|
|
||||||
_space = [_vehicle] call FUNC(getCargoSpaceLeft);
|
private _space = [_vehicle] call FUNC(getCargoSpaceLeft);
|
||||||
_itemSize = [_item] call FUNC(getSizeItem);
|
private _itemSize = [_item] call FUNC(getSizeItem);
|
||||||
_vehicle setVariable [QGVAR(space), _space - _itemSize, true];
|
_vehicle setVariable [QGVAR(space), _space - _itemSize, true];
|
||||||
|
|
||||||
if (_item isEqualType objNull) then {
|
if (_item isEqualType objNull) then {
|
||||||
|
47
addons/cargo/functions/fnc_makeLoadable.sqf
Normal file
47
addons/cargo/functions/fnc_makeLoadable.sqf
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Author: PabstMirror
|
||||||
|
* Makes any object loadable. Needs to be called on all machines.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Object <OBJECT>
|
||||||
|
* 1: Set as loadable (default: true) <BOOL><SCALAR>
|
||||||
|
* 2: Size. (default: 1) <NUMBER>
|
||||||
|
*
|
||||||
|
* Return value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [cursorTarget, true, 1] call ace_cargo_fnc_makeLoadable
|
||||||
|
*
|
||||||
|
* Public: Yes
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
params [["_object", objNull, [objNull]], ["_canLoad", true, [false, 0]], ["_setSize", 1, [0]]];
|
||||||
|
TRACE_3("params",_object,_canLoad,_setSize);
|
||||||
|
|
||||||
|
if (isNull _object) exitWith {TRACE_1("null",_object);};
|
||||||
|
private _type = typeOf _object;
|
||||||
|
private _cfgCanLoad = getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(canLoad));
|
||||||
|
private _curSize = [_object] call FUNC(getSizeItem);
|
||||||
|
|
||||||
|
_canLoad = [0, 1] select _canLoad; //convert true/false to scalar
|
||||||
|
|
||||||
|
if ((_canLoad == 1) && {_setSize <= 0}) exitWith {
|
||||||
|
ACE_LOGERROR("ace_cargo_fnc_makeLoadable (size <= 0) when making loadable");
|
||||||
|
};
|
||||||
|
|
||||||
|
TRACE_2("setVar if different from config",_canLoad,_cfgCanLoad);
|
||||||
|
if (_canLoad != _cfgCanLoad) then {
|
||||||
|
_object setVariable [QGVAR(canLoad), _canLoad];
|
||||||
|
};
|
||||||
|
|
||||||
|
TRACE_2("setVar if different from config",_setSize,_curSize);
|
||||||
|
if (_setSize != _curSize) then {
|
||||||
|
_object setVariable [QGVAR(size), _setSize];
|
||||||
|
};
|
||||||
|
|
||||||
|
//Add the load actions to the object class if not already added
|
||||||
|
[_object] call FUNC(initObject);
|
||||||
|
|
||||||
|
nil
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
if (!isServer) exitWith {};
|
if (!isServer) exitWith {};
|
||||||
|
|
||||||
params ["_logic", "_units", "_activated"];
|
params ["_logic", "", "_activated"];
|
||||||
|
|
||||||
if (!_activated) exitWith {};
|
if (!_activated) exitWith {};
|
||||||
|
|
||||||
|
@ -22,25 +22,24 @@ params ["_display"];
|
|||||||
uiNamespace setVariable [QGVAR(menuDisplay), _display];
|
uiNamespace setVariable [QGVAR(menuDisplay), _display];
|
||||||
|
|
||||||
[{
|
[{
|
||||||
private ["_display","_loaded", "_ctrl", "_class", "_label"];
|
|
||||||
disableSerialization;
|
disableSerialization;
|
||||||
_display = uiNamespace getVariable QGVAR(menuDisplay);
|
private _display = uiNamespace getVariable QGVAR(menuDisplay);
|
||||||
if (isnil "_display") exitWith {
|
if (isnil "_display") exitWith {
|
||||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isNull GVAR(interactionVehicle) || ACE_player distance GVAR(interactionVehicle) >= 10) exitWith {
|
if (isNull GVAR(interactionVehicle) || {ACE_player distance GVAR(interactionVehicle) >= 10}) exitWith {
|
||||||
closeDialog 0;
|
closeDialog 0;
|
||||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
_loaded = GVAR(interactionVehicle) getVariable [QGVAR(loaded), []];
|
private _loaded = GVAR(interactionVehicle) getVariable [QGVAR(loaded), []];
|
||||||
_ctrl = _display displayCtrl 100;
|
private _ctrl = _display displayCtrl 100;
|
||||||
_label = _display displayCtrl 2;
|
private _label = _display displayCtrl 2;
|
||||||
|
|
||||||
lbClear _ctrl;
|
lbClear _ctrl;
|
||||||
{
|
{
|
||||||
_class = if (_x isEqualType "") then {_x} else {typeOf _x};
|
private _class = if (_x isEqualType "") then {_x} else {typeOf _x};
|
||||||
_ctrl lbAdd (getText(configfile >> "CfgVehicles" >> _class >> "displayName"));
|
_ctrl lbAdd (getText(configfile >> "CfgVehicles" >> _class >> "displayName"));
|
||||||
true
|
true
|
||||||
} count _loaded;
|
} count _loaded;
|
||||||
|
@ -3,38 +3,46 @@
|
|||||||
* Start load item.
|
* Start load item.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Object <OBJECT>
|
* 0: Player <OBJECT>
|
||||||
|
* 1: Object <OBJECT>
|
||||||
*
|
*
|
||||||
* Return value:
|
* Return value:
|
||||||
* Object loaded <BOOL>
|
* Load ProgressBar Started <BOOL>
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [object] call ace_cargo_fnc_starLoadIn
|
* [player, cursorTarget] call ace_cargo_fnc_startLoadIn
|
||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_player", "_object"];
|
params ["_player", "_object"];
|
||||||
private ["_vehicle", "_size", "_displayName"];
|
TRACE_2("params",_player,_object);
|
||||||
|
|
||||||
_vehicle = [_player] call FUNC(findNearestVehicle);
|
private _vehicle = [_player] call FUNC(findNearestVehicle);
|
||||||
|
|
||||||
if (isNull _vehicle || _vehicle isKindOf "Cargo_Base_F") then {
|
if ((isNull _vehicle) || {_vehicle isKindOf "Cargo_Base_F"}) then {
|
||||||
{
|
{
|
||||||
if ([_object, _x] call FUNC(canLoadItemIn)) exitWith {_vehicle = _x};
|
if ([_object, _x] call FUNC(canLoadItemIn)) exitWith {_vehicle = _x};
|
||||||
} forEach (nearestObjects [_player, ["Cargo_base_F", "Land_PaperBox_closed_F"], MAX_LOAD_DISTANCE]);
|
} forEach (nearestObjects [_player, ["Cargo_base_F", "Land_PaperBox_closed_F"], MAX_LOAD_DISTANCE]);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isNull _vehicle) exitWith {false};
|
if (isNull _vehicle) exitWith {
|
||||||
|
TRACE_3("Could not find vehicle",_player,_object,_vehicle);
|
||||||
|
false
|
||||||
|
};
|
||||||
|
|
||||||
|
_return = false;
|
||||||
// Start progress bar
|
// Start progress bar
|
||||||
if ([_object, _vehicle] call FUNC(canLoadItemIn)) then {
|
if ([_object, _vehicle] call FUNC(canLoadItemIn)) then {
|
||||||
_size = [_object] call FUNC(getSizeItem);
|
private _size = [_object] call FUNC(getSizeItem);
|
||||||
|
|
||||||
[5 * _size, [_object,_vehicle], "LoadCargo", {}, localize LSTRING(LoadingItem)] call EFUNC(common,progressBar);
|
[5 * _size, [_object,_vehicle], "LoadCargo", {}, localize LSTRING(LoadingItem)] call EFUNC(common,progressBar);
|
||||||
|
_return = true;
|
||||||
} else {
|
} else {
|
||||||
_displayName = getText (configFile >> "CfgVehicles" >> typeOf _object >> "displayName");
|
private _displayName = getText (configFile >> "CfgVehicles" >> typeOf _object >> "displayName");
|
||||||
|
|
||||||
["displayTextStructured", [[LSTRING(LoadingFailed), _displayName], 3.0]] call EFUNC(common,localEvent);
|
["displayTextStructured", [[LSTRING(LoadingFailed), _displayName], 3.0]] call EFUNC(common,localEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_return
|
||||||
|
@ -15,34 +15,29 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_display", "_loaded", "_ctrl", "_selected", "_item"];
|
|
||||||
|
|
||||||
disableSerialization;
|
disableSerialization;
|
||||||
|
|
||||||
_display = uiNamespace getVariable QGVAR(menuDisplay);
|
private _display = uiNamespace getVariable QGVAR(menuDisplay);
|
||||||
if (isNil "_display") exitWith {};
|
if (isNil "_display") exitWith {};
|
||||||
|
|
||||||
_loaded = GVAR(interactionVehicle) getVariable [QGVAR(loaded), []];
|
private _loaded = GVAR(interactionVehicle) getVariable [QGVAR(loaded), []];
|
||||||
if (count _loaded == 0) exitWith {};
|
if (_loaded isEqualTo []) exitWith {};
|
||||||
|
|
||||||
_ctrl = _display displayCtrl 100;
|
private _ctrl = _display displayCtrl 100;
|
||||||
|
|
||||||
_selected = (lbCurSel _ctrl) max 0;
|
private _selected = (lbCurSel _ctrl) max 0;
|
||||||
|
|
||||||
if (count _loaded <= _selected) exitWith {};
|
if (count _loaded <= _selected) exitWith {};
|
||||||
_item = _loaded select _selected;
|
private _item = _loaded select _selected; //This can be an object or a classname string
|
||||||
|
|
||||||
|
|
||||||
// Start progress bar
|
// Start progress bar
|
||||||
private ["_size", "_itemClass", "_displayName"];
|
|
||||||
|
|
||||||
if ([_item, GVAR(interactionVehicle)] call FUNC(canUnloadItem)) then {
|
if ([_item, GVAR(interactionVehicle)] call FUNC(canUnloadItem)) then {
|
||||||
_size = [_item] call FUNC(getSizeItem);
|
private _size = [_item] call FUNC(getSizeItem);
|
||||||
|
|
||||||
[5 * _size, [_item, GVAR(interactionVehicle)], "UnloadCargo", {}, localize LSTRING(UnloadingItem)] call EFUNC(common,progressBar);
|
[5 * _size, [_item, GVAR(interactionVehicle)], "UnloadCargo", {}, localize LSTRING(UnloadingItem)] call EFUNC(common,progressBar);
|
||||||
} else {
|
} else {
|
||||||
_itemClass = if (_item isEqualType "") then {_item} else {typeOf _item};
|
private _itemClass = if (_item isEqualType "") then {_item} else {typeOf _item};
|
||||||
_displayName = getText (configFile >> "CfgVehicles" >> _itemClass >> "displayName");
|
private _displayName = getText (configFile >> "CfgVehicles" >> _itemClass >> "displayName");
|
||||||
|
|
||||||
["displayTextStructured", [[LSTRING(UnloadingFailed), _displayName], 3.0]] call EFUNC(common,localEvent);
|
["displayTextStructured", [[LSTRING(UnloadingFailed), _displayName], 3.0]] call EFUNC(common,localEvent);
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_item", "_vehicle"];
|
params ["_item", "_vehicle"];
|
||||||
private ["_loaded", "_space", "_itemSize", "_emptyPos", "_validVehiclestate"];
|
TRACE_2("params",_item,_vehicle);
|
||||||
|
|
||||||
if !([_item, _vehicle] call FUNC(canUnloadItem)) exitWith {
|
if !([_item, _vehicle] call FUNC(canUnloadItem)) exitWith {
|
||||||
false
|
false
|
||||||
@ -25,8 +25,8 @@ if !([_item, _vehicle] call FUNC(canUnloadItem)) exitWith {
|
|||||||
|
|
||||||
_itemClass = if (_item isEqualType "") then {_item} else {typeOf _item};
|
_itemClass = if (_item isEqualType "") then {_item} else {typeOf _item};
|
||||||
|
|
||||||
_validVehiclestate = true;
|
private _validVehiclestate = true;
|
||||||
_emptyPos = [];
|
private _emptyPos = [];
|
||||||
if (_vehicle isKindOf "Ship" ) then {
|
if (_vehicle isKindOf "Ship" ) then {
|
||||||
if !(speed _vehicle <1 && {(((getPosATL _vehicle) select 2) < 2)}) then {_validVehiclestate = false};
|
if !(speed _vehicle <1 && {(((getPosATL _vehicle) select 2) < 2)}) then {_validVehiclestate = false};
|
||||||
TRACE_1("SHIP Ground Check", getPosATL _vehicle );
|
TRACE_1("SHIP Ground Check", getPosATL _vehicle );
|
||||||
@ -45,16 +45,14 @@ if (_vehicle isKindOf "Ship" ) then {
|
|||||||
};
|
};
|
||||||
|
|
||||||
TRACE_1("getPosASL Vehicle Check", getPosASL _vehicle);
|
TRACE_1("getPosASL Vehicle Check", getPosASL _vehicle);
|
||||||
if (!_validVehiclestate) exitWith {false};
|
if ((!_validVehiclestate) || {_emptyPos isEqualTo []}) exitWith {false};
|
||||||
|
|
||||||
if (count _emptyPos == 0) exitWith {false};
|
private _loaded = _vehicle getVariable [QGVAR(loaded), []];
|
||||||
|
|
||||||
_loaded = _vehicle getVariable [QGVAR(loaded), []];
|
|
||||||
_loaded deleteAt (_loaded find _item);
|
_loaded deleteAt (_loaded find _item);
|
||||||
_vehicle setVariable [QGVAR(loaded), _loaded, true];
|
_vehicle setVariable [QGVAR(loaded), _loaded, true];
|
||||||
|
|
||||||
_space = [_vehicle] call FUNC(getCargoSpaceLeft);
|
private _space = [_vehicle] call FUNC(getCargoSpaceLeft);
|
||||||
_itemSize = [_item] call FUNC(getSizeItem);
|
private _itemSize = [_item] call FUNC(getSizeItem);
|
||||||
_vehicle setVariable [QGVAR(space), (_space + _itemSize), true];
|
_vehicle setVariable [QGVAR(space), (_space + _itemSize), true];
|
||||||
|
|
||||||
if (_item isEqualType objNull) then {
|
if (_item isEqualType objNull) then {
|
||||||
|
@ -15,14 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_loaded", "_newLoaded", "_totalSpaceOccupied"];
|
|
||||||
|
|
||||||
params ["_vehicle"];
|
params ["_vehicle"];
|
||||||
|
TRACE_1("params",_vehicle);
|
||||||
|
|
||||||
_loaded = _vehicle getVariable [QGVAR(loaded), []];
|
private _loaded = _vehicle getVariable [QGVAR(loaded), []];
|
||||||
|
|
||||||
_newLoaded = [];
|
private _newLoaded = [];
|
||||||
_totalSpaceOccupied = 0;
|
private _totalSpaceOccupied = 0;
|
||||||
{
|
{
|
||||||
if ((_x isEqualType "") || {!isNull _x}) then {
|
if ((_x isEqualType "") || {!isNull _x}) then {
|
||||||
_newLoaded pushback _x;
|
_newLoaded pushback _x;
|
||||||
|
Loading…
Reference in New Issue
Block a user