From 67479b733e19fb6ecef60e342eee41451e44084d Mon Sep 17 00:00:00 2001 From: commy2 Date: Sun, 29 Mar 2015 15:20:39 +0200 Subject: [PATCH 01/12] add PBO to load things into vehicles --- addons/cargo/$PBOPREFIX$ | 1 + addons/cargo/CfgEventHandlers.hpp | 6 ++++++ addons/cargo/XEH_preInit.sqf | 7 +++++++ addons/cargo/config.cpp | 15 +++++++++++++++ addons/cargo/functions/fnc_empty.sqf | 3 +++ addons/cargo/functions/script_component.hpp | 1 + addons/cargo/script_component.hpp | 12 ++++++++++++ 7 files changed, 45 insertions(+) create mode 100644 addons/cargo/$PBOPREFIX$ create mode 100644 addons/cargo/CfgEventHandlers.hpp create mode 100644 addons/cargo/XEH_preInit.sqf create mode 100644 addons/cargo/config.cpp create mode 100644 addons/cargo/functions/fnc_empty.sqf create mode 100644 addons/cargo/functions/script_component.hpp create mode 100644 addons/cargo/script_component.hpp diff --git a/addons/cargo/$PBOPREFIX$ b/addons/cargo/$PBOPREFIX$ new file mode 100644 index 0000000000..74e5e4186e --- /dev/null +++ b/addons/cargo/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\cargo \ No newline at end of file diff --git a/addons/cargo/CfgEventHandlers.hpp b/addons/cargo/CfgEventHandlers.hpp new file mode 100644 index 0000000000..f0a9f14d91 --- /dev/null +++ b/addons/cargo/CfgEventHandlers.hpp @@ -0,0 +1,6 @@ + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/cargo/XEH_preInit.sqf b/addons/cargo/XEH_preInit.sqf new file mode 100644 index 0000000000..69abb46fa9 --- /dev/null +++ b/addons/cargo/XEH_preInit.sqf @@ -0,0 +1,7 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(empty); + +ADDON = true; diff --git a/addons/cargo/config.cpp b/addons/cargo/config.cpp new file mode 100644 index 0000000000..7e6cb24ff2 --- /dev/null +++ b/addons/cargo/config.cpp @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common","ace_interaction","ace_interact_menu"}; + author[] = {"commy2"}; + authorUrl = "https://github.com/commy2"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" diff --git a/addons/cargo/functions/fnc_empty.sqf b/addons/cargo/functions/fnc_empty.sqf new file mode 100644 index 0000000000..c60a82b2d8 --- /dev/null +++ b/addons/cargo/functions/fnc_empty.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +diag_log text format["This is here as an example!!!"]; diff --git a/addons/cargo/functions/script_component.hpp b/addons/cargo/functions/script_component.hpp new file mode 100644 index 0000000000..bd91738fd3 --- /dev/null +++ b/addons/cargo/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\cargo\script_component.hpp" \ No newline at end of file diff --git a/addons/cargo/script_component.hpp b/addons/cargo/script_component.hpp new file mode 100644 index 0000000000..fea5a6601b --- /dev/null +++ b/addons/cargo/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT cargo +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_CARGO + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_ENABLED_CARGO + #define DEBUG_SETTINGS DEBUG_ENABLED_CARGO +#endif + +#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file From c016d01414a23a2549b146db32a12f551aa63025 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Mon, 10 Aug 2015 23:07:47 +0200 Subject: [PATCH 02/12] Initial load in cargo module --- addons/cargo/CfgEventHandlers.hpp | 48 ++++++++ addons/cargo/CfgVehicles.hpp | 63 +++++++++++ addons/cargo/XEH_preInit.sqf | 21 +++- addons/cargo/config.cpp | 8 +- addons/cargo/functions/fnc_canLoad.sqf | 23 ++++ addons/cargo/functions/fnc_canLoadItemIn.sqf | 23 ++++ addons/cargo/functions/fnc_canUnloadItem.sqf | 39 +++++++ addons/cargo/functions/fnc_empty.sqf | 3 - .../functions/fnc_findNearestVehicle.sqf | 31 ++++++ .../cargo/functions/fnc_getCargoSpaceLeft.sqf | 17 +++ addons/cargo/functions/fnc_getSizeItem.sqf | 20 ++++ .../cargo/functions/fnc_handleDestroyed.sqf | 27 +++++ addons/cargo/functions/fnc_initObject.sqf | 28 +++++ addons/cargo/functions/fnc_initVehicle.sqf | 39 +++++++ addons/cargo/functions/fnc_loadItem.sqf | 34 ++++++ addons/cargo/functions/fnc_onMenuOpen.sqf | 44 ++++++++ addons/cargo/functions/fnc_startLoadIn.sqf | 22 ++++ addons/cargo/functions/fnc_startUnload.sqf | 31 ++++++ addons/cargo/functions/fnc_unloadItem.sqf | 63 +++++++++++ .../functions/fnc_validateCargoSpace.sqf | 31 ++++++ addons/cargo/menu.hpp | 104 ++++++++++++++++++ addons/cargo/script_component.hpp | 4 +- addons/cargo/stringtable.xml | 20 ++++ 23 files changed, 735 insertions(+), 8 deletions(-) create mode 100644 addons/cargo/CfgVehicles.hpp create mode 100644 addons/cargo/functions/fnc_canLoad.sqf create mode 100644 addons/cargo/functions/fnc_canLoadItemIn.sqf create mode 100644 addons/cargo/functions/fnc_canUnloadItem.sqf delete mode 100644 addons/cargo/functions/fnc_empty.sqf create mode 100644 addons/cargo/functions/fnc_findNearestVehicle.sqf create mode 100644 addons/cargo/functions/fnc_getCargoSpaceLeft.sqf create mode 100644 addons/cargo/functions/fnc_getSizeItem.sqf create mode 100644 addons/cargo/functions/fnc_handleDestroyed.sqf create mode 100644 addons/cargo/functions/fnc_initObject.sqf create mode 100644 addons/cargo/functions/fnc_initVehicle.sqf create mode 100644 addons/cargo/functions/fnc_loadItem.sqf create mode 100644 addons/cargo/functions/fnc_onMenuOpen.sqf create mode 100644 addons/cargo/functions/fnc_startLoadIn.sqf create mode 100644 addons/cargo/functions/fnc_startUnload.sqf create mode 100644 addons/cargo/functions/fnc_unloadItem.sqf create mode 100644 addons/cargo/functions/fnc_validateCargoSpace.sqf create mode 100644 addons/cargo/menu.hpp create mode 100644 addons/cargo/stringtable.xml diff --git a/addons/cargo/CfgEventHandlers.hpp b/addons/cargo/CfgEventHandlers.hpp index f0a9f14d91..603e156c50 100644 --- a/addons/cargo/CfgEventHandlers.hpp +++ b/addons/cargo/CfgEventHandlers.hpp @@ -4,3 +4,51 @@ class Extended_PreInit_EventHandlers { init = QUOTE(call COMPILE_FILE(XEH_preInit)); }; }; + +class Extended_Killed_EventHandlers { + class All { + init = QUOTE(call FUNC(handleDestroyed)); + }; +}; + +class Extended_Init_EventHandlers { + class StaticWeapon { + class ADDON { + init = QUOTE(_this call DFUNC(initObject)); + }; + }; + class ReammoBox_F { + class ADDON { + init = QUOTE(_this call DFUNC(initObject)); + }; + }; + class Car { + class ADDON { + init = QUOTE(_this call DFUNC(initVehicle)); + }; + }; + + class Tank { + class ADDON { + init = QUOTE(_this call DFUNC(initVehicle)); + }; + }; + + class Helicopter { + class ADDON { + init = QUOTE(_this call DFUNC(initVehicle)); + }; + }; + + class Plane { + class ADDON { + init = QUOTE(_this call DFUNC(initVehicle)); + }; + }; + + class Ship_F { + class ADDON { + init = QUOTE(_this call DFUNC(initVehicle)); + }; + }; +}; diff --git a/addons/cargo/CfgVehicles.hpp b/addons/cargo/CfgVehicles.hpp new file mode 100644 index 0000000000..d9113bd295 --- /dev/null +++ b/addons/cargo/CfgVehicles.hpp @@ -0,0 +1,63 @@ + +class CfgVehicles { + class LandVehicle; + class Car: LandVehicle { + GVAR(space) = 4; + GVAR(hasCargo) = 1; + }; + + class Tank: LandVehicle { + GVAR(space) = 4; + GVAR(hasCargo) = 1; + }; + class Car_F; + class Truck_F: Car_F { + GVAR(space) = 8; + GVAR(hasCargo) = 1; + }; + + class Air; + // Repair helicopters + class Helicopter: Air { + GVAR(space) = 8; + GVAR(hasCargo) = 1; + }; + + class Heli_Transport_02_base_F; + class I_Heli_Transport_02_F : Heli_Transport_02_base_F { + GVAR(space) = 20; + GVAR(hasCargo) = 1; + }; + + // Repair fixed wing aircraft + class Plane: Air { + GVAR(space) = 4; + GVAR(hasCargo) = 1; + }; + + // boats + class Ship; + class Ship_F: Ship { + GVAR(space) = 4; + GVAR(hasCargo) = 1; + }; + + // Static weapons + class StaticWeapon: LandVehicle { + GVAR(size) = 2; // 1 = small, 2 = large + GVAR(canLoad) = 1; + }; + + class StaticMortar; + class Mortar_01_base_F: StaticMortar { + GVAR(size) = 2; // 1 = small, 2 = large + GVAR(canLoad) = 1; + }; + + // Ammo boxes + class ThingX; + class ReammoBox_F: ThingX { + GVAR(size) = 2; // 1 = small, 2 = large + GVAR(canLoad) = 1; + }; +}; diff --git a/addons/cargo/XEH_preInit.sqf b/addons/cargo/XEH_preInit.sqf index 69abb46fa9..067d131717 100644 --- a/addons/cargo/XEH_preInit.sqf +++ b/addons/cargo/XEH_preInit.sqf @@ -2,6 +2,25 @@ ADDON = false; -PREP(empty); +PREP(canLoadItemIn); +PREP(canUnloadItem); +PREP(canLoad); +PREP(findNearestVehicle); +PREP(getCargoSpaceLeft); +PREP(GetSizeItem); +PREP(initObject); +PREP(initVehicle); +PREP(handleDestroyed); +PREP(loadItem); +PREP(onMenuOpen); +PREP(unloadItem); +PREP(validateCargoSpace); +PREP(startLoadIn); +PREP(startUnload); +GVAR(initializedItemClasses) = []; + +if (isServer) then { + ["cargo_hideItem", {(_this select 0) hideObjectGlobal (_this select 1);}] call EFUNC(common,addEventHandler); +}; ADDON = true; diff --git a/addons/cargo/config.cpp b/addons/cargo/config.cpp index 7e6cb24ff2..3f1438a2f2 100644 --- a/addons/cargo/config.cpp +++ b/addons/cargo/config.cpp @@ -5,11 +5,13 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"ace_common","ace_interaction","ace_interact_menu"}; - author[] = {"commy2"}; - authorUrl = "https://github.com/commy2"; + requiredAddons[] = {"ace_interaction"}; + author[] = {"commy2", "Glowbal"}; + authorUrl = "https://ace3mod.com/"; VERSION_CONFIG; }; }; #include "CfgEventHandlers.hpp" +#include "CfgVehicles.hpp" +#include "menu.hpp" \ No newline at end of file diff --git a/addons/cargo/functions/fnc_canLoad.sqf b/addons/cargo/functions/fnc_canLoad.sqf new file mode 100644 index 0000000000..1b6488da6b --- /dev/null +++ b/addons/cargo/functions/fnc_canLoad.sqf @@ -0,0 +1,23 @@ +/* + * Author: Glowbal + * Check if player can load item into the nearest vehicle + * + * Arguments: + * 0: Player + * 1: Object to load + * + * Return value: + * Can load + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_player", "_object"]; + +private ["_nearestVehicle"]; +_nearestVehicle = [_player] call FUNC(findNearestVehicle); +if (isNull _nearestVehicle) exitwith {false}; + +[_object, _nearestVehicle] call FUNC(canLoadItemIn); diff --git a/addons/cargo/functions/fnc_canLoadItemIn.sqf b/addons/cargo/functions/fnc_canLoadItemIn.sqf new file mode 100644 index 0000000000..e777e2dd53 --- /dev/null +++ b/addons/cargo/functions/fnc_canLoadItemIn.sqf @@ -0,0 +1,23 @@ +/* + * Author: Glowbal + * Check if item can be loaded into other Object + * + * Arguments: + * 0: Any object + * 1: Object + * + * Return value: + * Can load in + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_item", "_vehicle"]; + +if (speed _vehicle > 1 || (((getPos _vehicle) select 2) > 3)) exitwith {false}; + +private "_itemSize"; +_itemSize = ([_item] call FUNC(getSizeItem)); +_itemSize > 0 && {alive _item && alive _vehicle} && {(_item distance _vehicle <= MAX_LOAD_DISTANCE)} && {_itemSize <= ([_vehicle] call FUNC(getCargoSpaceLeft))}; diff --git a/addons/cargo/functions/fnc_canUnloadItem.sqf b/addons/cargo/functions/fnc_canUnloadItem.sqf new file mode 100644 index 0000000000..2770528a63 --- /dev/null +++ b/addons/cargo/functions/fnc_canUnloadItem.sqf @@ -0,0 +1,39 @@ +/* + * Author: Glowbal, ViperMaul + * Check if item can be unloaded + * + * Arguments: + * 0: loaded object + * 1: Object + * + * Return value: + * Can be unloaded + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_loaded", "_position", "_validVehiclestate", "_emptyPos"]; +params ["_item", "_vehicle"]; +_loaded = _vehicle getvariable [QGVAR(loaded), []]; +if !(_item in _loaded) exitwith {false}; + +_validVehiclestate = true; +_emptyPos = []; +if (_vehicle isKindOf "Ship" ) then { + if !(speed _vehicle <1 && {(((getPosATL _vehicle) select 2) < 2)}) then {_validVehiclestate = false}; + _emptyPos = ((getPosASL _vehicle) call EFUNC(common,ASLtoPosition) findEmptyPosition [0, 15, typeOf _item]); // TODO: if spot is underwater pick another spot. +} else { + if (_vehicle isKindOf "Air" ) then { + if !(speed _vehicle <1 && {isTouchingGround _vehicle}) then {_validVehiclestate = false}; + _emptyPos = (getPosASL _vehicle) call EFUNC(common,ASLtoPosition); + _emptyPos = [(_emptyPos select 0) + random(5), (_emptyPos select 1) + random(5), _emptyPos select 2 ]; + } else { + if !(speed _vehicle <1 && {(((getPosATL _vehicle) select 2) < 2)}) then {_validVehiclestate = false}; + _emptyPos = ((getPosASL _vehicle) call EFUNC(common,ASLtoPosition) findEmptyPosition [0, 15, typeOf _item]); + }; +}; + +if (!_validVehiclestate) exitwith { false }; +(count _emptyPos != 0); diff --git a/addons/cargo/functions/fnc_empty.sqf b/addons/cargo/functions/fnc_empty.sqf deleted file mode 100644 index c60a82b2d8..0000000000 --- a/addons/cargo/functions/fnc_empty.sqf +++ /dev/null @@ -1,3 +0,0 @@ -#include "script_component.hpp" - -diag_log text format["This is here as an example!!!"]; diff --git a/addons/cargo/functions/fnc_findNearestVehicle.sqf b/addons/cargo/functions/fnc_findNearestVehicle.sqf new file mode 100644 index 0000000000..7828eca8a9 --- /dev/null +++ b/addons/cargo/functions/fnc_findNearestVehicle.sqf @@ -0,0 +1,31 @@ +/* + * Author: Glowbal + * Get nearest vehicle, priority car, air, tank, ship + * + * Arguments: + * 0: Object + * + * Return value: + * Can load + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_vehicle"]; +params ["_unit"]; + +_vehicle = nearestObject [_unit, "car"]; +if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle}; + +_loadhelicopter = nearestObject [_unit, "air"]; +if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle}; + +_loadtank = nearestObject [_unit, "tank"]; +if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle}; + +_loadtank = nearestObject [_unit, "ship"]; +if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle}; + +objNull; diff --git a/addons/cargo/functions/fnc_getCargoSpaceLeft.sqf b/addons/cargo/functions/fnc_getCargoSpaceLeft.sqf new file mode 100644 index 0000000000..3c50e24ad3 --- /dev/null +++ b/addons/cargo/functions/fnc_getCargoSpaceLeft.sqf @@ -0,0 +1,17 @@ +/* + * Author: Glowbal + * Get the cargo space left on object + * + * Arguments: + * 0: Object + * + * Return value: + * Cargo space left + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_vehicle"]; +_vehicle getvariable [QGVAR(space), getNumber (configFile >> "CfgVehicles" >> typeof _vehicle >> QGVAR(space))]; diff --git a/addons/cargo/functions/fnc_getSizeItem.sqf b/addons/cargo/functions/fnc_getSizeItem.sqf new file mode 100644 index 0000000000..3d079d6b3a --- /dev/null +++ b/addons/cargo/functions/fnc_getSizeItem.sqf @@ -0,0 +1,20 @@ +/* + * Author: Glowbal + * Get the cargo size of an object + * + * Arguments: + * 0: Object + * + * Return value: + * Cargo size. -1 is not a size defined + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_item"]; +if (isNumber (configFile >> "CfgVehicles" >> typeof _item >> QGVAR(size))) exitwith { + _item getvariable [QGVAR(size), getNumber (configFile >> "CfgVehicles" >> typeof _item >> QGVAR(size))]; +}; +-1; diff --git a/addons/cargo/functions/fnc_handleDestroyed.sqf b/addons/cargo/functions/fnc_handleDestroyed.sqf new file mode 100644 index 0000000000..54d4f1103b --- /dev/null +++ b/addons/cargo/functions/fnc_handleDestroyed.sqf @@ -0,0 +1,27 @@ +/* + * Author: Glowbal + * Handle object being destroyed + * + * Arguments: + * 0: Object + * + * Return value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_vehicle"]; + +_loaded = _vehicle getvariable [QGVAR(loaded), []]; +if (count _loaded == 0) exitwith {}; + +{ + // TODO deleteVehicle or just delete vehicle? Do we want to be able to recover destroyed equipment? + deleteVehicle _x; + //_x setDamage 1; +}foreach _loaded; + +[_vehicle] call FUNC(validateCargoSpace); diff --git a/addons/cargo/functions/fnc_initObject.sqf b/addons/cargo/functions/fnc_initObject.sqf new file mode 100644 index 0000000000..98aeb5afea --- /dev/null +++ b/addons/cargo/functions/fnc_initObject.sqf @@ -0,0 +1,28 @@ +/* + * Author: Glowbal + * Initialize variables for loadable objects. Called from init EH. + * + * Arguments: + * 0: Any object + * + * Return value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_object"]; + +if (getNumber (configFile >> "CfgVehicles" >> typeOf _object >> QGVAR(canLoad)) != 1) exitwith {}; + +private ["_type", "_action"]; +_type = typeOf _object; + +// do nothing if the class is already initialized +if (_type in GVAR(initializedItemClasses)) exitWith {}; +GVAR(initializedItemClasses) pushBack _type; + +_action = [QGVAR(load), localize LSTRING(loadObject), "", {[_player, _target] call FUNC(startLoadIn)}, {[_player, _target] call FUNC(canLoad)}] call EFUNC(interact_menu,createAction); +[_type, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToClass); diff --git a/addons/cargo/functions/fnc_initVehicle.sqf b/addons/cargo/functions/fnc_initVehicle.sqf new file mode 100644 index 0000000000..241b23eb83 --- /dev/null +++ b/addons/cargo/functions/fnc_initVehicle.sqf @@ -0,0 +1,39 @@ +/* + * Author: Glowbal + * initalize vehicle. Adds open caro menu action if available + * + * Arguments: + * 0: vehicle + * + * Return Value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_vehicle"]; +TRACE_1("params", _vehicle); + +private ["_type", "_initializedClasses"]; + +_type = typeOf _vehicle; +_initializedClasses = GETMVAR(GVAR(initializedClasses),[]); + +// do nothing if the class is already initialized +if (_type in _initializedClasses) exitWith {}; +// set class as initialized +_initializedClasses pushBack _type; +SETMVAR(GVAR(initializedClasses),_initializedClasses); + +if (getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) != 1) exitwith {}; + +private ["_text", "_condition", "_statement", "_icon", "_action"]; +_text = localize "STR_ACE_Cargo_openMenu"; +_condition = {true}; +_statement = {diag_log format["_target %1", _target];GVAR(interactionVehicle) = _target; createDialog QGVAR(menu);}; +_icon = ""; + +_action = [QGVAR(openMenu), _text, _icon, _statement, _condition] call EFUNC(interact_menu,createAction); +[_type, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToClass); diff --git a/addons/cargo/functions/fnc_loadItem.sqf b/addons/cargo/functions/fnc_loadItem.sqf new file mode 100644 index 0000000000..0abebdd43c --- /dev/null +++ b/addons/cargo/functions/fnc_loadItem.sqf @@ -0,0 +1,34 @@ +/* + * Author: Glowbal + * Load object into vehicle + * + * Arguments: + * 0: Object + * 1: Vehicle + * + * Return value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_loaded", "_space", "_itemSize"]; +params ["_item", "_vehicle"]; + +if !([_item, _vehicle] call FUNC(canLoadItemIn)) exitwith {false}; + +_loaded = _vehicle getvariable [QGVAR(loaded), []]; +_loaded pushback _item; +_vehicle setvariable [QGVAR(loaded), _loaded, true]; + +_space = [_vehicle] call FUNC(getCargoSpaceLeft); +_itemSize = [_item] call FUNC(getSizeItem); +_vehicle setvariable [QGVAR(space), _space - _itemSize, true]; + +detach _item; +_item attachTo [_vehicle,[0,0,100]]; +["cargo_hideItem", [_item, true]] call EFUNC(common,serverEvent); + +true; diff --git a/addons/cargo/functions/fnc_onMenuOpen.sqf b/addons/cargo/functions/fnc_onMenuOpen.sqf new file mode 100644 index 0000000000..e51e6ee2e8 --- /dev/null +++ b/addons/cargo/functions/fnc_onMenuOpen.sqf @@ -0,0 +1,44 @@ +/* + * Author: Glowbal + * Handle the UI data display + * + * Arguments: + * 0: display + * + * Return value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +disableSerialization; +params["_display"]; + +uiNamespace setvariable [QGVAR(menuDisplay), _display]; + +[{ + private ["_display","_loaded", "_ctrl", "_label"]; + disableSerialization; + _display = uiNamespace getvariable QGVAR(menuDisplay); + if (isnil "_display") exitwith { + [_this select 1] call CBA_fnc_removePerFrameHandler; + }; + + if (isNull GVAR(interactionVehicle) || ACE_player distance GVAR(interactionVehicle) >= 10) exitwith { + closeDialog 0; + [_this select 1] call CBA_fnc_removePerFrameHandler; + }; + + _loaded = GVAR(interactionVehicle) getvariable [QGVAR(loaded), []]; + _ctrl = _display displayCtrl 100; + _label = _display displayCtrl 2; + + lbClear _ctrl; + { + _ctrl lbAdd (getText(configfile >> "CfgVehicles" >> typeOf _x >> "displayName")); + }foreach _loaded; + + _label ctrlSetText format[localize "STR_ACE_Cargo_labelSpace", [GVAR(interactionVehicle)] call DFUNC(getCargoSpaceLeft)]; +}, 0, []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/cargo/functions/fnc_startLoadIn.sqf b/addons/cargo/functions/fnc_startLoadIn.sqf new file mode 100644 index 0000000000..ae6a5ec934 --- /dev/null +++ b/addons/cargo/functions/fnc_startLoadIn.sqf @@ -0,0 +1,22 @@ +/* + * Author: Glowbal + * Start load item + * + * Arguments: + * 0: Any object + * + * Return value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_player", "_object"]; + +private ["_nearestVehicle"]; +_nearestVehicle = [_player] call FUNC(findNearestVehicle); + +if (isNull _nearestVehicle) exitwith {false}; +[_object, _nearestVehicle] call FUNC(loadItem); diff --git a/addons/cargo/functions/fnc_startUnload.sqf b/addons/cargo/functions/fnc_startUnload.sqf new file mode 100644 index 0000000000..03bad9299b --- /dev/null +++ b/addons/cargo/functions/fnc_startUnload.sqf @@ -0,0 +1,31 @@ +/* + * Author: Glowbal + * Start unload action + * + * Arguments: + * None + * + * Return value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_display", "_loaded", "_ctrl", "_selected", "_item"]; +disableSerialization; +_display = uiNamespace getvariable QGVAR(menuDisplay); +if (isnil "_display") exitwith {}; + +_loaded = GVAR(interactionVehicle) getvariable [QGVAR(loaded), []]; +if (count _loaded == 0) exitwith {}; + +_ctrl = _display displayCtrl 100; + +_selected = (lbCurSel _ctrl) max 0; + +if (count _loaded <= _selected) exitwith {systemChat format["count: %1 %2", count _loaded, _selected]}; +_item = _loaded select _selected; + +[_item, GVAR(interactionVehicle)] call FUNC(unloadItem); diff --git a/addons/cargo/functions/fnc_unloadItem.sqf b/addons/cargo/functions/fnc_unloadItem.sqf new file mode 100644 index 0000000000..fcc2a07796 --- /dev/null +++ b/addons/cargo/functions/fnc_unloadItem.sqf @@ -0,0 +1,63 @@ +/* + * Author: Glowbal, ViperMaul + * Unload object from vehicle + * + * Arguments: + * 0: Object + * 1: Vehicle + * + * Return value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_loaded", "_space", "_itemSize", "_emptyPos", "_validVehiclestate"]; +params ["_item", "_vehicle"]; + +if !([_item, _vehicle] call FUNC(canUnloadItem)) exitwith { + systemChat format["Can not unload item"]; + false +}; + +_validVehiclestate = true; +_emptyPos = []; +if (_vehicle isKindOf "Ship" ) then { + if !(speed _vehicle <1 && {(((getPosATL _vehicle) select 2) < 2)}) then {_validVehiclestate = false}; + TRACE_1("SHIP Ground Check", getPosATL _vehicle ); + _emptyPos = ((getPosASL _vehicle) call EFUNC(common,ASLtoPosition) findEmptyPosition [0, 15, typeOf _item]); // TODO: if spot is underwater pick another spot. +} else { + if (_vehicle isKindOf "Air" ) then { + if !(speed _vehicle <1 && {isTouchingGround _vehicle}) then {_validVehiclestate = false}; + TRACE_1("Vehicle Ground Check", isTouchingGround _vehicle); + _emptyPos = (getPosASL _vehicle) call EFUNC(common,ASLtoPosition); + _emptyPos = [(_emptyPos select 0) + random(5), (_emptyPos select 1) + random(5), _emptyPos select 2 ]; + } else { + if !(speed _vehicle <1 && {(((getPosATL _vehicle) select 2) < 2)}) then {_validVehiclestate = false}; + TRACE_1("Vehicle Ground Check", isTouchingGround _vehicle); + _emptyPos = ((getPosASL _vehicle) call EFUNC(common,ASLtoPosition) findEmptyPosition [0, 13, typeOf _item]); + }; +}; + +TRACE_1("getPosASL Vehicle Check", getPosASL _vehicle); +if (!_validVehiclestate) exitwith { false }; + +if (count _emptyPos == 0) exitwith { false}; //consider displaying text saying there are no safe places to exit the vehicle + +_loaded = _vehicle getvariable [QGVAR(loaded), []]; +_loaded = _loaded - [_item]; +_vehicle setvariable [QGVAR(loaded), _loaded, true]; + +_space = [_vehicle] call FUNC(getCargoSpaceLeft); +_itemSize = [_item] call FUNC(getSizeItem); +_vehicle setvariable [QGVAR(space), _space + _itemSize, true]; + +detach _item; +_item setPosASL (_emptyPos call EFUNC(common,PositiontoASL)); +["cargo_hideItem", [_item, false]] call EFUNC(common,serverEvent); + +// TOOO maybe drag/carry the unloaded item? + +true; diff --git a/addons/cargo/functions/fnc_validateCargoSpace.sqf b/addons/cargo/functions/fnc_validateCargoSpace.sqf new file mode 100644 index 0000000000..34ac1ef981 --- /dev/null +++ b/addons/cargo/functions/fnc_validateCargoSpace.sqf @@ -0,0 +1,31 @@ +/* + * Author: Glowbal + * Validate the vehicle cargo space + * + * Arguments: + * 0: Object + * + * Return value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_loaded", "_newLoaded", "_totalSpaceOccupied"]; +params ["_vehicle"]; +_loaded = _vehicle getvariable [QGVAR(loaded), []]; +_newLoaded = []; +_totalSpaceOccupied = 0; +{ + if !(isNull _x) then { + _newLoaded pushback _x; + _totalSpaceOccupied = _totalSpaceOccupied + ([_x] call FUNC(getSizeItem)); + }; +}foreach _loaded; + +if (count _loaded != count _newLoaded) then { + _vehicle setvariable [QGVAR(loaded), _newLoaded, true]; +}; +_vehicle setvariable [QGVAR(space), getNumber (configFile >> "CfgVehicles" >> typeof _vehicle >> QGVAR(space)) - _totalSpaceOccupied, true]; diff --git a/addons/cargo/menu.hpp b/addons/cargo/menu.hpp new file mode 100644 index 0000000000..35976d19ad --- /dev/null +++ b/addons/cargo/menu.hpp @@ -0,0 +1,104 @@ + +#include "\z\ace\addons\common\define.hpp" + +class GVAR(menu) { + idd = 314614; + movingEnable = true; + onLoad = QUOTE([_this select 0] call FUNC(onMenuOpen)); + onUnload = QUOTE(uiNamespace setvariable [ARR_2(QUOTE(QGVAR(menuDisplay)),nil)];); + class controlsBackground { + class HeaderBackground: ACE_gui_backgroundBase{ + idc = -1; + SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)"; + x = "13 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)"; + y = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)"; + w = "13 * (((safezoneW / safezoneH) min 1.2) / 40)"; + h = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; + text = "#(argb,8,8,3)color(0,0,0,0)"; + }; + class CenterBackground: HeaderBackground { + y = "2.1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)"; + h = "14 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; + text = "#(argb,8,8,3)color(0,0,0,0.8)"; + colorText[] = {0, 0, 0, "(profilenamespace getvariable ['GUI_BCG_RGB_A',0.9])"}; + colorBackground[] = {0,0,0,"(profilenamespace getvariable ['GUI_BCG_RGB_A',0.9])"}; + }; + }; + + class controls { + class HeaderName { + idc = 1; + type = CT_STATIC; + x = "13 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)"; + y = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)"; + w = "13 * (((safezoneW / safezoneH) min 1.2) / 40)"; + h = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; + style = ST_LEFT + ST_SHADOW; + font = "PuristaMedium"; + SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)"; + colorText[] = {0.95, 0.95, 0.95, 0.75}; + colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.69])","(profilenamespace getvariable ['GUI_BCG_RGB_G',0.75])","(profilenamespace getvariable ['GUI_BCG_RGB_B',0.5])", "(profilenamespace getvariable ['GUI_BCG_RGB_A',0.9])"}; + text = CSTRING(cargoMenu); + }; + class SubHeader: HeaderName { + idc = 2; + x = "13 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)"; + y = "2.5 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)"; + w = "13 * (((safezoneW / safezoneH) min 1.2) / 40)"; + h = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; + style = ST_CENTER; + colorText[] = {1, 1, 1.0, 0.9}; + colorBackground[] = {0,0,0,0}; + SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1.2)"; + text = ""; + }; + class cargoList: ACE_gui_listBoxBase { + idc = 100; + x = "13.1 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)"; + y = "4 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)"; + w = "12.8 * (((safezoneW / safezoneH) min 1.2) / 40)"; + h = "10 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; + SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 0.7)"; + rowHeight = 0.03; + colorBackground[] = {0, 0, 0, 0.2}; + colorText[] = {1, 1, 1, 1.0}; + colorScrollbar[] = {0.95, 0.95, 0.95, 1}; + colorSelect[] = {1, 1, 1, 1.0}; + colorSelect2[] = {1, 1, 1, 1.0}; + colorSelectBackground[] = {0.3, 0.3, 0.3, 1.0}; + colorSelectBackground2[] = {0.3, 0.3, 0.3, 1.0}; + }; + class btnUnload: ACE_gui_buttonBase { + text = "Cancel"; + idc = 11; + x = "13.1 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)"; + y = "14.1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) + (safezoneY + (safezoneH - (((safezoneW / safezoneH) min 1.2) / 1.2))/2)"; + w = "5 * (((safezoneW / safezoneH) min 1.2) / 40)"; + h = "1 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; + size = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)"; + SizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 0.7)"; + animTextureNormal = "#(argb,8,8,3)color(0,0,0,0.9)"; + animTextureDisabled = "#(argb,8,8,3)color(0,0,0,0.8)"; + animTextureOver = "#(argb,8,8,3)color(1,1,1,1)"; + animTextureFocused = "#(argb,8,8,3)color(1,1,1,1)"; + animTexturePressed = "#(argb,8,8,3)color(1,1,1,1)"; + animTextureDefault = "#(argb,8,8,3)color(1,1,1,1)"; + color[] = {1, 1, 1, 1}; + color2[] = {0,0,0, 1}; + colorBackgroundFocused[] = {1,1,1,1}; + colorBackground[] = {1,1,1,1}; + colorbackground2[] = {1,1,1,1}; + colorDisabled[] = {1,1,1,1}; + colorFocused[] = {0,0,0,1}; + periodFocus = 1; + periodOver = 1; + action = QUOTE(closeDialog 0); + }; + class btnCancel: btnUnload { + text = CSTRING(unloadObject); + idc = 12; + x = "20.9 * (((safezoneW / safezoneH) min 1.2) / 40) + (safezoneX + (safezoneW - ((safezoneW / safezoneH) min 1.2))/2)"; + action = QUOTE([] call FUNC(startUnload);); + }; + }; +}; \ No newline at end of file diff --git a/addons/cargo/script_component.hpp b/addons/cargo/script_component.hpp index fea5a6601b..9716d7a536 100644 --- a/addons/cargo/script_component.hpp +++ b/addons/cargo/script_component.hpp @@ -9,4 +9,6 @@ #define DEBUG_SETTINGS DEBUG_ENABLED_CARGO #endif -#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file +#include "\z\ace\addons\main\script_macros.hpp" + +#define MAX_LOAD_DISTANCE 10 diff --git a/addons/cargo/stringtable.xml b/addons/cargo/stringtable.xml new file mode 100644 index 0000000000..e547ae9553 --- /dev/null +++ b/addons/cargo/stringtable.xml @@ -0,0 +1,20 @@ + + + + + Load object + + + Unload object + + + Cargo Menu + + + Cargo Menu + + + Cargo space left: %1 + + + From ffa476bee2e0598f5487d85303a4209d65edcfe9 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Mon, 10 Aug 2015 23:16:58 +0200 Subject: [PATCH 03/12] Improved action display text --- addons/cargo/stringtable.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/cargo/stringtable.xml b/addons/cargo/stringtable.xml index e547ae9553..7f9a7411c8 100644 --- a/addons/cargo/stringtable.xml +++ b/addons/cargo/stringtable.xml @@ -2,13 +2,13 @@ - Load object + Load - Unload object + Unload - Cargo Menu + Cargo Cargo Menu From abc732ac35eca09d9423c8ff777618dfbd234486 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Tue, 11 Aug 2015 23:18:01 +0200 Subject: [PATCH 04/12] Added support for cargo configuration on vehicle spawn --- addons/cargo/CfgVehicles.hpp | 9 +++++++++ addons/cargo/functions/fnc_initVehicle.sqf | 23 +++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/addons/cargo/CfgVehicles.hpp b/addons/cargo/CfgVehicles.hpp index d9113bd295..c9eff0caf6 100644 --- a/addons/cargo/CfgVehicles.hpp +++ b/addons/cargo/CfgVehicles.hpp @@ -4,6 +4,15 @@ class CfgVehicles { class Car: LandVehicle { GVAR(space) = 4; GVAR(hasCargo) = 1; + class ACE_Cargo { + /* + class Cargo { + class ACE_medicalSupplyCrate { + type = "ACE_medicalSupplyCrate"; + amount = 1; + };*/ + }; + }; }; class Tank: LandVehicle { diff --git a/addons/cargo/functions/fnc_initVehicle.sqf b/addons/cargo/functions/fnc_initVehicle.sqf index 241b23eb83..28648a75ba 100644 --- a/addons/cargo/functions/fnc_initVehicle.sqf +++ b/addons/cargo/functions/fnc_initVehicle.sqf @@ -17,10 +17,31 @@ params ["_vehicle"]; TRACE_1("params", _vehicle); private ["_type", "_initializedClasses"]; - _type = typeOf _vehicle; _initializedClasses = GETMVAR(GVAR(initializedClasses),[]); + +if (isServer) then { + { + if (isClass _x) then { + private ["_className", "_amount","_position","_object"]; + _className = getText (_x >> "type"); + _amount = getNumber (_x >> "amount"); + _position = getPos _vehicle; + _position set [2, (_position select 2) + 7.5]; + _position set [1, (_position select 1) + 1]; + for "_i" from 1 to _amount do { + _object = createVehicle [_className, _position, [], 0, "CAN_COLLIDE"]; + if !([_object, _vehicle] call FUNC(loadItem)) exitwith { + deleteVehicle _object; + }; + }; + }; + nil + }count ("true" configClasses (configFile >> "CfgVehicles" >> _type >> "ACE_Cargo" >> "Cargo")); +}; + + // do nothing if the class is already initialized if (_type in _initializedClasses) exitWith {}; // set class as initialized From c4ed18f39f5e8dfc37f8c99ab79afc666d25d299 Mon Sep 17 00:00:00 2001 From: jokoho48 Date: Fri, 14 Aug 2015 18:07:31 +0200 Subject: [PATCH 05/12] Fix findNearestVehicle dont return BOOL Fix that findNearestVehicle dont return any time the nearest car Small Performance Improvement in getSizeItem/handleDestroyed/startUnload Enhance Some legibility --- addons/cargo/XEH_preInit.sqf | 2 +- .../cargo/functions/fnc_findNearestVehicle.sqf | 18 +++++++++--------- addons/cargo/functions/fnc_getSizeItem.sqf | 11 ++++++----- addons/cargo/functions/fnc_handleDestroyed.sqf | 2 +- addons/cargo/functions/fnc_initVehicle.sqf | 4 ++-- addons/cargo/functions/fnc_onMenuOpen.sqf | 3 ++- addons/cargo/functions/fnc_startUnload.sqf | 7 ++++--- addons/cargo/functions/fnc_unloadItem.sqf | 4 ++-- .../cargo/functions/fnc_validateCargoSpace.sqf | 3 ++- 9 files changed, 29 insertions(+), 25 deletions(-) diff --git a/addons/cargo/XEH_preInit.sqf b/addons/cargo/XEH_preInit.sqf index 067d131717..b6c5342042 100644 --- a/addons/cargo/XEH_preInit.sqf +++ b/addons/cargo/XEH_preInit.sqf @@ -20,7 +20,7 @@ PREP(startUnload); GVAR(initializedItemClasses) = []; if (isServer) then { - ["cargo_hideItem", {(_this select 0) hideObjectGlobal (_this select 1);}] call EFUNC(common,addEventHandler); + ["cargo_hideItem", {params ["_object", "_status"]; _object hideObjectGlobal _status;}] call EFUNC(common,addEventHandler); }; ADDON = true; diff --git a/addons/cargo/functions/fnc_findNearestVehicle.sqf b/addons/cargo/functions/fnc_findNearestVehicle.sqf index 7828eca8a9..0db9b307e7 100644 --- a/addons/cargo/functions/fnc_findNearestVehicle.sqf +++ b/addons/cargo/functions/fnc_findNearestVehicle.sqf @@ -6,26 +6,26 @@ * 0: Object * * Return value: - * Can load + * Vehicle that is in Distance * * Public: No */ #include "script_component.hpp" -private ["_vehicle"]; +private ["_loadCar", "_loadHelicopter", "_loadTank", "_loadShip"]; params ["_unit"]; -_vehicle = nearestObject [_unit, "car"]; +_loadCar = nearestObject [_unit, "car"]; if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle}; -_loadhelicopter = nearestObject [_unit, "air"]; -if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle}; +_loadHelicopter = nearestObject [_unit, "air"]; +if (_unit distance _loadHelicopter <= MAX_LOAD_DISTANCE) exitwith {_loadHelicopter}; -_loadtank = nearestObject [_unit, "tank"]; -if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle}; +_loadTank = nearestObject [_unit, "tank"]; +if (_unit distance _loadTank <= MAX_LOAD_DISTANCE) exitwith {_loadTank}; -_loadtank = nearestObject [_unit, "ship"]; -if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle}; +_loadShip = nearestObject [_unit, "ship"]; +if (_unit distance _loadShip <= MAX_LOAD_DISTANCE) exitwith {_loadShip}; objNull; diff --git a/addons/cargo/functions/fnc_getSizeItem.sqf b/addons/cargo/functions/fnc_getSizeItem.sqf index 3d079d6b3a..92ad306652 100644 --- a/addons/cargo/functions/fnc_getSizeItem.sqf +++ b/addons/cargo/functions/fnc_getSizeItem.sqf @@ -6,15 +6,16 @@ * 0: Object * * Return value: - * Cargo size. -1 is not a size defined + * Cargo size. (default: -1) * * Public: No */ #include "script_component.hpp" -params ["_item"]; -if (isNumber (configFile >> "CfgVehicles" >> typeof _item >> QGVAR(size))) exitwith { - _item getvariable [QGVAR(size), getNumber (configFile >> "CfgVehicles" >> typeof _item >> QGVAR(size))]; +params ["_item", "_config"]; +_config = (configFile >> "CfgVehicles" >> typeof _item >> QGVAR(size)); +if (isNumber (_config)) exitwith { + _item getvariable [QGVAR(size), getNumber (_config)]; }; --1; +-1 diff --git a/addons/cargo/functions/fnc_handleDestroyed.sqf b/addons/cargo/functions/fnc_handleDestroyed.sqf index 54d4f1103b..b235631a89 100644 --- a/addons/cargo/functions/fnc_handleDestroyed.sqf +++ b/addons/cargo/functions/fnc_handleDestroyed.sqf @@ -22,6 +22,6 @@ if (count _loaded == 0) exitwith {}; // TODO deleteVehicle or just delete vehicle? Do we want to be able to recover destroyed equipment? deleteVehicle _x; //_x setDamage 1; -}foreach _loaded; +} count _loaded; [_vehicle] call FUNC(validateCargoSpace); diff --git a/addons/cargo/functions/fnc_initVehicle.sqf b/addons/cargo/functions/fnc_initVehicle.sqf index 28648a75ba..39750e78fc 100644 --- a/addons/cargo/functions/fnc_initVehicle.sqf +++ b/addons/cargo/functions/fnc_initVehicle.sqf @@ -28,8 +28,8 @@ if (isServer) then { _className = getText (_x >> "type"); _amount = getNumber (_x >> "amount"); _position = getPos _vehicle; - _position set [2, (_position select 2) + 7.5]; _position set [1, (_position select 1) + 1]; + _position set [2, (_position select 2) + 7.5]; for "_i" from 1 to _amount do { _object = createVehicle [_className, _position, [], 0, "CAN_COLLIDE"]; if !([_object, _vehicle] call FUNC(loadItem)) exitwith { @@ -38,7 +38,7 @@ if (isServer) then { }; }; nil - }count ("true" configClasses (configFile >> "CfgVehicles" >> _type >> "ACE_Cargo" >> "Cargo")); + } count ("true" configClasses (configFile >> "CfgVehicles" >> _type >> "ACE_Cargo" >> "Cargo")); }; diff --git a/addons/cargo/functions/fnc_onMenuOpen.sqf b/addons/cargo/functions/fnc_onMenuOpen.sqf index e51e6ee2e8..766a22f612 100644 --- a/addons/cargo/functions/fnc_onMenuOpen.sqf +++ b/addons/cargo/functions/fnc_onMenuOpen.sqf @@ -38,7 +38,8 @@ uiNamespace setvariable [QGVAR(menuDisplay), _display]; lbClear _ctrl; { _ctrl lbAdd (getText(configfile >> "CfgVehicles" >> typeOf _x >> "displayName")); - }foreach _loaded; + true + } count _loaded; _label ctrlSetText format[localize "STR_ACE_Cargo_labelSpace", [GVAR(interactionVehicle)] call DFUNC(getCargoSpaceLeft)]; }, 0, []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/cargo/functions/fnc_startUnload.sqf b/addons/cargo/functions/fnc_startUnload.sqf index 03bad9299b..9b654838ef 100644 --- a/addons/cargo/functions/fnc_startUnload.sqf +++ b/addons/cargo/functions/fnc_startUnload.sqf @@ -13,19 +13,20 @@ #include "script_component.hpp" -private ["_display", "_loaded", "_ctrl", "_selected", "_item"]; +private ["_display", "_loaded", "_loadedCount", "_ctrl", "_selected", "_item"]; disableSerialization; _display = uiNamespace getvariable QGVAR(menuDisplay); if (isnil "_display") exitwith {}; _loaded = GVAR(interactionVehicle) getvariable [QGVAR(loaded), []]; -if (count _loaded == 0) exitwith {}; +_loadedCount = count _loaded; +if (_loadedCount == 0) exitwith {}; _ctrl = _display displayCtrl 100; _selected = (lbCurSel _ctrl) max 0; -if (count _loaded <= _selected) exitwith {systemChat format["count: %1 %2", count _loaded, _selected]}; +if (_loadedCount <= _selected) exitwith {systemChat format["count: %1 %2", _loadedCount, _selected]}; _item = _loaded select _selected; [_item, GVAR(interactionVehicle)] call FUNC(unloadItem); diff --git a/addons/cargo/functions/fnc_unloadItem.sqf b/addons/cargo/functions/fnc_unloadItem.sqf index fcc2a07796..16248f879d 100644 --- a/addons/cargo/functions/fnc_unloadItem.sqf +++ b/addons/cargo/functions/fnc_unloadItem.sqf @@ -44,7 +44,7 @@ if (_vehicle isKindOf "Ship" ) then { TRACE_1("getPosASL Vehicle Check", getPosASL _vehicle); if (!_validVehiclestate) exitwith { false }; -if (count _emptyPos == 0) exitwith { false}; //consider displaying text saying there are no safe places to exit the vehicle +if (count _emptyPos == 0) exitwith { false }; //consider displaying text saying there are no safe places to exit the vehicle _loaded = _vehicle getvariable [QGVAR(loaded), []]; _loaded = _loaded - [_item]; @@ -52,7 +52,7 @@ _vehicle setvariable [QGVAR(loaded), _loaded, true]; _space = [_vehicle] call FUNC(getCargoSpaceLeft); _itemSize = [_item] call FUNC(getSizeItem); -_vehicle setvariable [QGVAR(space), _space + _itemSize, true]; +_vehicle setvariable [QGVAR(space), (_space + _itemSize), true]; detach _item; _item setPosASL (_emptyPos call EFUNC(common,PositiontoASL)); diff --git a/addons/cargo/functions/fnc_validateCargoSpace.sqf b/addons/cargo/functions/fnc_validateCargoSpace.sqf index 34ac1ef981..6452e850bc 100644 --- a/addons/cargo/functions/fnc_validateCargoSpace.sqf +++ b/addons/cargo/functions/fnc_validateCargoSpace.sqf @@ -23,7 +23,8 @@ _totalSpaceOccupied = 0; _newLoaded pushback _x; _totalSpaceOccupied = _totalSpaceOccupied + ([_x] call FUNC(getSizeItem)); }; -}foreach _loaded; + true +} count _loaded; if (count _loaded != count _newLoaded) then { _vehicle setvariable [QGVAR(loaded), _newLoaded, true]; From ec5a1f038a8e2864ba66f2c479800d840f79bfb5 Mon Sep 17 00:00:00 2001 From: Joko Date: Fri, 14 Aug 2015 18:42:22 +0200 Subject: [PATCH 06/12] fix Typo issue --- addons/cargo/functions/fnc_getSizeItem.sqf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/cargo/functions/fnc_getSizeItem.sqf b/addons/cargo/functions/fnc_getSizeItem.sqf index 92ad306652..02e5313217 100644 --- a/addons/cargo/functions/fnc_getSizeItem.sqf +++ b/addons/cargo/functions/fnc_getSizeItem.sqf @@ -13,7 +13,8 @@ #include "script_component.hpp" -params ["_item", "_config"]; +private "_config"; +params ["_item"]; _config = (configFile >> "CfgVehicles" >> typeof _item >> QGVAR(size)); if (isNumber (_config)) exitwith { _item getvariable [QGVAR(size), getNumber (_config)]; From 55ad706761f17799a5d0eea45a49273cd3892dfe Mon Sep 17 00:00:00 2001 From: Glowbal Date: Fri, 14 Aug 2015 22:00:55 +0200 Subject: [PATCH 07/12] fixed car check - invalid variable name --- addons/cargo/functions/fnc_findNearestVehicle.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/cargo/functions/fnc_findNearestVehicle.sqf b/addons/cargo/functions/fnc_findNearestVehicle.sqf index 0db9b307e7..e7da6faa46 100644 --- a/addons/cargo/functions/fnc_findNearestVehicle.sqf +++ b/addons/cargo/functions/fnc_findNearestVehicle.sqf @@ -17,7 +17,7 @@ private ["_loadCar", "_loadHelicopter", "_loadTank", "_loadShip"]; params ["_unit"]; _loadCar = nearestObject [_unit, "car"]; -if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle}; +if (_unit distance _loadCar <= MAX_LOAD_DISTANCE) exitwith {_loadCar}; _loadHelicopter = nearestObject [_unit, "air"]; if (_unit distance _loadHelicopter <= MAX_LOAD_DISTANCE) exitwith {_loadHelicopter}; From 96ec435d0d3c4af5dba5a682dbc1bf6323d7e96b Mon Sep 17 00:00:00 2001 From: Glowbal Date: Fri, 14 Aug 2015 22:01:14 +0200 Subject: [PATCH 08/12] Added load in cargo containers --- addons/cargo/CfgEventHandlers.hpp | 17 ++ addons/cargo/CfgVehicles.hpp | 185 +++++++++++++++++- addons/cargo/functions/fnc_canLoad.sqf | 8 + .../functions/fnc_findNearestVehicle.sqf | 5 +- addons/cargo/functions/fnc_initVehicle.sqf | 4 +- addons/cargo/functions/fnc_startLoadIn.sqf | 7 + addons/cargo/functions/fnc_startUnload.sqf | 7 +- addons/cargo/functions/fnc_unloadItem.sqf | 1 - 8 files changed, 223 insertions(+), 11 deletions(-) diff --git a/addons/cargo/CfgEventHandlers.hpp b/addons/cargo/CfgEventHandlers.hpp index 603e156c50..c6fa4c6819 100644 --- a/addons/cargo/CfgEventHandlers.hpp +++ b/addons/cargo/CfgEventHandlers.hpp @@ -22,6 +22,23 @@ class Extended_Init_EventHandlers { init = QUOTE(_this call DFUNC(initObject)); }; }; + + class Cargo_base_F { + class ADDON { + init = QUOTE(_this call DFUNC(initObject); _this call DFUNC(initVehicle)); + }; + }; + class CargoNet_01_box_F { + class ADDON { + init = QUOTE(_this call DFUNC(initObject); _this call DFUNC(initVehicle)); + }; + }; + class Land_CargoBox_V1_F { + class ADDON { + init = QUOTE(_this call DFUNC(initObject); _this call DFUNC(initVehicle)); + }; + }; + class Car { class ADDON { init = QUOTE(_this call DFUNC(initVehicle)); diff --git a/addons/cargo/CfgVehicles.hpp b/addons/cargo/CfgVehicles.hpp index c9eff0caf6..25fbb7de43 100644 --- a/addons/cargo/CfgVehicles.hpp +++ b/addons/cargo/CfgVehicles.hpp @@ -10,8 +10,8 @@ class CfgVehicles { class ACE_medicalSupplyCrate { type = "ACE_medicalSupplyCrate"; amount = 1; - };*/ - }; + }; + };*/ }; }; @@ -69,4 +69,185 @@ class CfgVehicles { GVAR(size) = 2; // 1 = small, 2 = large GVAR(canLoad) = 1; }; + class Cargo_base_F: ThingX { + GVAR(space) = 4; + GVAR(hasCargo) = 1; + GVAR(size) = 4; + GVAR(canLoad) = 1; + class ACE_Actions { + class ACE_MainActions { + displayName = ECSTRING(interaction,MainAction); + distance = 5; + condition = QUOTE(true); + statement = ""; + icon = "\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa"; + selection = ""; + }; + }; + }; + class Cargo10_base_F: Cargo_base_F { + GVAR(space) = 14; + GVAR(size) = 15; + XEH_ENABLED; + }; + class Land_Cargo20_blue_F: Cargo_base_F { + GVAR(space) = 49; + GVAR(size) = 50; + XEH_ENABLED; + }; + class Land_Cargo20_brick_red_F: Cargo_base_F { + GVAR(space) = 49; + GVAR(size) = 50; + XEH_ENABLED; + }; + class Land_Cargo20_cyan_F: Cargo_base_F { + GVAR(space) = 49; + GVAR(size) = 50; + XEH_ENABLED; + }; + class Land_Cargo20_grey_F: Cargo_base_F { + GVAR(space) = 49; + GVAR(size) = 50; + XEH_ENABLED; + }; + class Land_Cargo20_light_blue_F: Cargo_base_F { + GVAR(space) = 49; + GVAR(size) = 50; + XEH_ENABLED; + }; + class Land_Cargo20_light_green_F: Cargo_base_F { + GVAR(space) = 49; + GVAR(size) = 50; + XEH_ENABLED; + }; + class Land_Cargo20_military_green_F: Cargo_base_F { + GVAR(space) = 49; + GVAR(size) = 50; + XEH_ENABLED; + }; + class Land_Cargo20_military_ruins_F: Cargo_base_F { + GVAR(space) = 49; + GVAR(size) = 50; + XEH_ENABLED; + }; + class Land_Cargo20_orange_F: Cargo_base_F { + GVAR(space) = 49; + GVAR(size) = 50; + XEH_ENABLED; + }; + class Land_Cargo20_red_F: Cargo_base_F { + GVAR(space) = 49; + GVAR(size) = 50; + XEH_ENABLED; + }; + class Land_Cargo20_sand_F: Cargo_base_F { + GVAR(space) = 49; + GVAR(size) = 50; + XEH_ENABLED; + }; + class Land_Cargo20_vr_F: Cargo_base_F { + GVAR(space) = 49; + GVAR(size) = 50; + XEH_ENABLED; + }; + class Land_Cargo20_white_F: Cargo_base_F { + GVAR(space) = 49; + GVAR(size) = 50; + XEH_ENABLED; + }; + class Land_Cargo20_yellow_F: Cargo_base_F { + GVAR(space) = 49; + GVAR(size) = 50; + XEH_ENABLED; + }; + + + class Land_Cargo40_blue_F: Cargo_base_F { + GVAR(space) = 99; + GVAR(size) = 100; + XEH_ENABLED; + }; + class Land_Cargo40_brick_red_F: Cargo_base_F { + GVAR(space) = 99; + GVAR(size) = 100; + XEH_ENABLED; + }; + class Land_Cargo40_cyan_F: Cargo_base_F { + GVAR(space) = 99; + GVAR(size) = 100; + XEH_ENABLED; + }; + class Land_Cargo40_grey_F: Cargo_base_F { + GVAR(space) = 99; + GVAR(size) = 100; + XEH_ENABLED; + }; + class Land_Cargo40_light_blue_F: Cargo_base_F { + GVAR(space) = 99; + GVAR(size) = 100; + XEH_ENABLED; + }; + class Land_Cargo40_light_green_F: Cargo_base_F { + GVAR(space) = 99; + GVAR(size) = 100; + XEH_ENABLED; + }; + class Land_Cargo40_military_green_F: Cargo_base_F { + GVAR(space) = 99; + GVAR(size) = 100; + XEH_ENABLED; + }; + class Land_Cargo40_military_ruins_F: Cargo_base_F { + GVAR(space) = 99; + GVAR(size) = 100; + XEH_ENABLED; + }; + class Land_Cargo40_orange_F: Cargo_base_F { + GVAR(space) = 99; + GVAR(size) = 100; + XEH_ENABLED; + }; + class Land_Cargo40_red_F: Cargo_base_F { + GVAR(space) = 99; + GVAR(size) = 100; + XEH_ENABLED; + }; + class Land_Cargo40_sand_F: Cargo_base_F { + GVAR(space) = 99; + GVAR(size) = 100; + XEH_ENABLED; + }; + class Land_Cargo40_vr_F: Cargo_base_F { + GVAR(space) = 99; + GVAR(size) = 100; + XEH_ENABLED; + }; + class Land_Cargo40_white_F: Cargo_base_F { + GVAR(space) = 99; + GVAR(size) = 100; + XEH_ENABLED; + }; + class Land_Cargo40_yellow_F: Cargo_base_F { + GVAR(space) = 99; + GVAR(size) = 100; + XEH_ENABLED; + }; + // small + class Land_CargoBox_V1_F: ThingX { + GVAR(space) = 7; + GVAR(hasCargo) = 1; + GVAR(size) = 7; + XEH_ENABLED; + class ACE_Actions { + class ACE_MainActions { + displayName = ECSTRING(interaction,MainAction); + distance = 5; + condition = QUOTE(true); + statement = ""; + icon = "\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa"; + selection = ""; + }; + }; + }; + }; diff --git a/addons/cargo/functions/fnc_canLoad.sqf b/addons/cargo/functions/fnc_canLoad.sqf index 1b6488da6b..8c96663d04 100644 --- a/addons/cargo/functions/fnc_canLoad.sqf +++ b/addons/cargo/functions/fnc_canLoad.sqf @@ -18,6 +18,14 @@ params ["_player", "_object"]; private ["_nearestVehicle"]; _nearestVehicle = [_player] call FUNC(findNearestVehicle); + +if (_nearestVehicle isKindOf "Cargo_Base_F" || isNull _nearestVehicle) then { + + { + if ([_object, _x] call FUNC(canLoadItemIn)) exitwith {_nearestVehicle = _x}; + }foreach (nearestObjects [_player, ["Cargo_base_F"], MAX_LOAD_DISTANCE]); +}; + if (isNull _nearestVehicle) exitwith {false}; [_object, _nearestVehicle] call FUNC(canLoadItemIn); diff --git a/addons/cargo/functions/fnc_findNearestVehicle.sqf b/addons/cargo/functions/fnc_findNearestVehicle.sqf index e7da6faa46..40f554adc1 100644 --- a/addons/cargo/functions/fnc_findNearestVehicle.sqf +++ b/addons/cargo/functions/fnc_findNearestVehicle.sqf @@ -13,7 +13,7 @@ #include "script_component.hpp" -private ["_loadCar", "_loadHelicopter", "_loadTank", "_loadShip"]; +private ["_loadCar", "_loadHelicopter", "_loadTank", "_loadShip", "_loadContainer"]; params ["_unit"]; _loadCar = nearestObject [_unit, "car"]; @@ -28,4 +28,7 @@ if (_unit distance _loadTank <= MAX_LOAD_DISTANCE) exitwith {_loadTank}; _loadShip = nearestObject [_unit, "ship"]; if (_unit distance _loadShip <= MAX_LOAD_DISTANCE) exitwith {_loadShip}; +_loadContainer = nearestObject [_unit,"Cargo_base_F"]; +if (_unit distance _loadContainer <= MAX_LOAD_DISTANCE) exitwith {_loadContainer}; + objNull; diff --git a/addons/cargo/functions/fnc_initVehicle.sqf b/addons/cargo/functions/fnc_initVehicle.sqf index 39750e78fc..9653f756b2 100644 --- a/addons/cargo/functions/fnc_initVehicle.sqf +++ b/addons/cargo/functions/fnc_initVehicle.sqf @@ -20,7 +20,6 @@ private ["_type", "_initializedClasses"]; _type = typeOf _vehicle; _initializedClasses = GETMVAR(GVAR(initializedClasses),[]); - if (isServer) then { { if (isClass _x) then { @@ -41,7 +40,6 @@ if (isServer) then { } count ("true" configClasses (configFile >> "CfgVehicles" >> _type >> "ACE_Cargo" >> "Cargo")); }; - // do nothing if the class is already initialized if (_type in _initializedClasses) exitWith {}; // set class as initialized @@ -53,7 +51,7 @@ if (getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) != 1) ex private ["_text", "_condition", "_statement", "_icon", "_action"]; _text = localize "STR_ACE_Cargo_openMenu"; _condition = {true}; -_statement = {diag_log format["_target %1", _target];GVAR(interactionVehicle) = _target; createDialog QGVAR(menu);}; +_statement = {GVAR(interactionVehicle) = _target; createDialog QGVAR(menu);}; _icon = ""; _action = [QGVAR(openMenu), _text, _icon, _statement, _condition] call EFUNC(interact_menu,createAction); diff --git a/addons/cargo/functions/fnc_startLoadIn.sqf b/addons/cargo/functions/fnc_startLoadIn.sqf index ae6a5ec934..c2707eecb6 100644 --- a/addons/cargo/functions/fnc_startLoadIn.sqf +++ b/addons/cargo/functions/fnc_startLoadIn.sqf @@ -18,5 +18,12 @@ params ["_player", "_object"]; private ["_nearestVehicle"]; _nearestVehicle = [_player] call FUNC(findNearestVehicle); +if (isNull _nearestVehicle || _nearestVehicle isKindOf "Cargo_Base_F") then { + + { + if ([_item, _x] call FUNC(canLoadItemIn)) exitwith {_nearestVehicle = _x}; + }foreach (nearestObjects [_player, ["Cargo_base_F"], MAX_LOAD_DISTANCE]); +}; + if (isNull _nearestVehicle) exitwith {false}; [_object, _nearestVehicle] call FUNC(loadItem); diff --git a/addons/cargo/functions/fnc_startUnload.sqf b/addons/cargo/functions/fnc_startUnload.sqf index 9b654838ef..615c1cafbd 100644 --- a/addons/cargo/functions/fnc_startUnload.sqf +++ b/addons/cargo/functions/fnc_startUnload.sqf @@ -13,20 +13,19 @@ #include "script_component.hpp" -private ["_display", "_loaded", "_loadedCount", "_ctrl", "_selected", "_item"]; +private ["_display", "_loaded", "_ctrl", "_selected", "_item"]; disableSerialization; _display = uiNamespace getvariable QGVAR(menuDisplay); if (isnil "_display") exitwith {}; _loaded = GVAR(interactionVehicle) getvariable [QGVAR(loaded), []]; -_loadedCount = count _loaded; -if (_loadedCount == 0) exitwith {}; +if (count _loaded == 0) exitwith {}; _ctrl = _display displayCtrl 100; _selected = (lbCurSel _ctrl) max 0; -if (_loadedCount <= _selected) exitwith {systemChat format["count: %1 %2", _loadedCount, _selected]}; +if (count _loaded <= _selected) exitwith {}; _item = _loaded select _selected; [_item, GVAR(interactionVehicle)] call FUNC(unloadItem); diff --git a/addons/cargo/functions/fnc_unloadItem.sqf b/addons/cargo/functions/fnc_unloadItem.sqf index 16248f879d..0209c5256e 100644 --- a/addons/cargo/functions/fnc_unloadItem.sqf +++ b/addons/cargo/functions/fnc_unloadItem.sqf @@ -18,7 +18,6 @@ private ["_loaded", "_space", "_itemSize", "_emptyPos", "_validVehiclestate"]; params ["_item", "_vehicle"]; if !([_item, _vehicle] call FUNC(canUnloadItem)) exitwith { - systemChat format["Can not unload item"]; false }; From 2062f5dcb6d9894bece0e09af2c2e6872e9c3786 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Fri, 14 Aug 2015 22:07:49 +0200 Subject: [PATCH 09/12] fixed incorrect variable name --- addons/cargo/functions/fnc_startLoadIn.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/cargo/functions/fnc_startLoadIn.sqf b/addons/cargo/functions/fnc_startLoadIn.sqf index c2707eecb6..acef2a91b5 100644 --- a/addons/cargo/functions/fnc_startLoadIn.sqf +++ b/addons/cargo/functions/fnc_startLoadIn.sqf @@ -21,7 +21,7 @@ _nearestVehicle = [_player] call FUNC(findNearestVehicle); if (isNull _nearestVehicle || _nearestVehicle isKindOf "Cargo_Base_F") then { { - if ([_item, _x] call FUNC(canLoadItemIn)) exitwith {_nearestVehicle = _x}; + if ([_object, _x] call FUNC(canLoadItemIn)) exitwith {_nearestVehicle = _x}; }foreach (nearestObjects [_player, ["Cargo_base_F"], MAX_LOAD_DISTANCE]); }; From 21400b01741f244400378ddab058c4f8b40f3e4f Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 14 Aug 2015 15:46:51 -0500 Subject: [PATCH 10/12] UBC, privates, LSTRING --- addons/cargo/CfgVehicles.hpp | 5 +++-- addons/cargo/functions/fnc_canLoadItemIn.sqf | 4 ++-- addons/cargo/functions/fnc_canUnloadItem.sqf | 2 +- addons/cargo/functions/fnc_handleDestroyed.sqf | 2 ++ addons/cargo/functions/fnc_initVehicle.sqf | 2 +- addons/cargo/functions/fnc_onMenuOpen.sqf | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/addons/cargo/CfgVehicles.hpp b/addons/cargo/CfgVehicles.hpp index 25fbb7de43..0335566d0d 100644 --- a/addons/cargo/CfgVehicles.hpp +++ b/addons/cargo/CfgVehicles.hpp @@ -125,7 +125,8 @@ class CfgVehicles { GVAR(size) = 50; XEH_ENABLED; }; - class Land_Cargo20_military_ruins_F: Cargo_base_F { + class Ruins_F; + class Land_Cargo20_military_ruins_F: Ruins_F { GVAR(space) = 49; GVAR(size) = 50; XEH_ENABLED; @@ -197,7 +198,7 @@ class CfgVehicles { GVAR(size) = 100; XEH_ENABLED; }; - class Land_Cargo40_military_ruins_F: Cargo_base_F { + class Land_Cargo40_military_ruins_F: Ruins_F { GVAR(space) = 99; GVAR(size) = 100; XEH_ENABLED; diff --git a/addons/cargo/functions/fnc_canLoadItemIn.sqf b/addons/cargo/functions/fnc_canLoadItemIn.sqf index e777e2dd53..5d844cc91c 100644 --- a/addons/cargo/functions/fnc_canLoadItemIn.sqf +++ b/addons/cargo/functions/fnc_canLoadItemIn.sqf @@ -3,8 +3,8 @@ * Check if item can be loaded into other Object * * Arguments: - * 0: Any object - * 1: Object + * 0: Item Object + * 1: Holder Object (vehicle) * * Return value: * Can load in diff --git a/addons/cargo/functions/fnc_canUnloadItem.sqf b/addons/cargo/functions/fnc_canUnloadItem.sqf index 2770528a63..74b4c1bb9e 100644 --- a/addons/cargo/functions/fnc_canUnloadItem.sqf +++ b/addons/cargo/functions/fnc_canUnloadItem.sqf @@ -14,7 +14,7 @@ #include "script_component.hpp" -private ["_loaded", "_position", "_validVehiclestate", "_emptyPos"]; +private ["_loaded", "_validVehiclestate", "_emptyPos"]; params ["_item", "_vehicle"]; _loaded = _vehicle getvariable [QGVAR(loaded), []]; if !(_item in _loaded) exitwith {false}; diff --git a/addons/cargo/functions/fnc_handleDestroyed.sqf b/addons/cargo/functions/fnc_handleDestroyed.sqf index b235631a89..25e7a6a4e0 100644 --- a/addons/cargo/functions/fnc_handleDestroyed.sqf +++ b/addons/cargo/functions/fnc_handleDestroyed.sqf @@ -15,6 +15,8 @@ params ["_vehicle"]; +private["_loaded"]; + _loaded = _vehicle getvariable [QGVAR(loaded), []]; if (count _loaded == 0) exitwith {}; diff --git a/addons/cargo/functions/fnc_initVehicle.sqf b/addons/cargo/functions/fnc_initVehicle.sqf index 9653f756b2..15f03c9253 100644 --- a/addons/cargo/functions/fnc_initVehicle.sqf +++ b/addons/cargo/functions/fnc_initVehicle.sqf @@ -49,7 +49,7 @@ SETMVAR(GVAR(initializedClasses),_initializedClasses); if (getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) != 1) exitwith {}; private ["_text", "_condition", "_statement", "_icon", "_action"]; -_text = localize "STR_ACE_Cargo_openMenu"; +_text = localize LSTRING(openMenu); _condition = {true}; _statement = {GVAR(interactionVehicle) = _target; createDialog QGVAR(menu);}; _icon = ""; diff --git a/addons/cargo/functions/fnc_onMenuOpen.sqf b/addons/cargo/functions/fnc_onMenuOpen.sqf index 766a22f612..8c3bbfecf2 100644 --- a/addons/cargo/functions/fnc_onMenuOpen.sqf +++ b/addons/cargo/functions/fnc_onMenuOpen.sqf @@ -41,5 +41,5 @@ uiNamespace setvariable [QGVAR(menuDisplay), _display]; true } count _loaded; - _label ctrlSetText format[localize "STR_ACE_Cargo_labelSpace", [GVAR(interactionVehicle)] call DFUNC(getCargoSpaceLeft)]; + _label ctrlSetText format[localize LSTRING(labelSpace), [GVAR(interactionVehicle)] call DFUNC(getCargoSpaceLeft)]; }, 0, []] call CBA_fnc_addPerFrameHandler; From d8084e20d7dec155d6d64ce1c5a882688f241261 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sat, 15 Aug 2015 09:50:00 +0200 Subject: [PATCH 11/12] Added cargo settings and settings module. --- addons/cargo/ACE_Settings.hpp | 9 ++++++ addons/cargo/CfgVehicles.hpp | 27 ++++++++++++++++++ addons/cargo/UI/Icon_Module_Cargo_ca.paa | Bin 0 -> 5625 bytes addons/cargo/UI/Icon_load.paa | Bin 0 -> 5625 bytes addons/cargo/XEH_preInit.sqf | 1 + addons/cargo/functions/fnc_initObject.sqf | 2 +- addons/cargo/functions/fnc_initVehicle.sqf | 2 +- addons/cargo/functions/fnc_moduleSettings.sqf | 21 ++++++++++++++ addons/cargo/stringtable.xml | 15 ++++++++++ .../Icon_Module_png/Icon_Module_Cargo_ca.png | Bin 0 -> 703 bytes 10 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 addons/cargo/ACE_Settings.hpp create mode 100644 addons/cargo/UI/Icon_Module_Cargo_ca.paa create mode 100644 addons/cargo/UI/Icon_load.paa create mode 100644 addons/cargo/functions/fnc_moduleSettings.sqf create mode 100644 extras/assets/icons/Icon_Module_png/Icon_Module_Cargo_ca.png diff --git a/addons/cargo/ACE_Settings.hpp b/addons/cargo/ACE_Settings.hpp new file mode 100644 index 0000000000..300add74d2 --- /dev/null +++ b/addons/cargo/ACE_Settings.hpp @@ -0,0 +1,9 @@ +class ACE_Settings { + class GVAR(enable) { + displayName = CSTRING(ModuleSettings_enable); + description = CSTRING(ModuleSettings_enable_desc); + typeName = "BOOL"; + value = 1; + category = CSTRING(settingsCategory); + }; +}; diff --git a/addons/cargo/CfgVehicles.hpp b/addons/cargo/CfgVehicles.hpp index 25fbb7de43..9811feb219 100644 --- a/addons/cargo/CfgVehicles.hpp +++ b/addons/cargo/CfgVehicles.hpp @@ -1,5 +1,32 @@ class CfgVehicles { + + class ACE_Module; + class ACE_moduleCargoSettings: ACE_Module { + scope = 2; + displayName = CSTRING(SettingsModule_DisplayName); + icon = QUOTE(PATHTOF(UI\Icon_Module_Medical_ca.paa)); + category = "ACE"; + function = QUOTE(DFUNC(moduleSettings)); + functionPriority = 1; + isGlobal = 1; + isTriggerActivated = 0; + author = ECSTRING(common,ACETeam); + class Arguments { + class enable { + displayName = CSTRING(ModuleSettings_enable); + description = CSTRING(ModuleSettings_enable_desc); + typeName = "BOOL"; + defaultValue = 1; + }; + }; + class ModuleDescription { + description = CSTRING(SettingsModule_Desc); + sync[] = {}; + }; + }; + + class LandVehicle; class Car: LandVehicle { GVAR(space) = 4; diff --git a/addons/cargo/UI/Icon_Module_Cargo_ca.paa b/addons/cargo/UI/Icon_Module_Cargo_ca.paa new file mode 100644 index 0000000000000000000000000000000000000000..a292fb4227366641a7d9066c7ae573602050c2c6 GIT binary patch literal 5625 zcmd^DUuauZ7(a=(W*tpiX063EHr-+!qbiEDD;?y9LE6Ad2iv-d3a0fzafwuL_+ZVA z6^c;T5K%;0_n@zCwUh(;(u)CKWWtz8N_-f&;b0rojyjmhuHScW&&fF_B(ZcU;tu!1 z{oU_7-~W5gcTa;gG!#C5cxWuF5kd-uLd?de!Xt<+7>I|$M>G+ zlGBy=tNP02%lTCKYhg>xzcYdR@0gPo^93ALuwsAx^AG-mMLd24imMi`R{u`^WqFV? zNq$v~0Tkl{#XnrCcckJF?CH20Dwr(=uHQ{y zbAS*qx{-T*{N7)Qml*!#@1ytd83)>;`v2Uo(RItZ{TQRS{odV~Ta4!!R_&k7eK(&S zn9o+CtNh!=C&53l|LeF5&I|sl^7kt7XkRYQ70x7h{aDR7L)*{n4}3q@xmv|vRsL)a zoc|B|uiD$F#N&~R-lkP3VdlTeUkmTJ|F1yt(-_ZR+pSO`n}m{ufwp>XP%ps}t|K-D z`LnB#{7~U1rmt4Kwo7+CNhh*Gz7p@aUWNUP=P!ZHp78zG8y`C3JuT|rs(yB??yU}PqTQo+IWPwAzPKFel{MZjdAbCHlx&* zb#3&G@9QfaJNUw(;^k1$!|ZYUWd0sop8F|ASM{m5_i4G!Xe!EWVd}J>qax+Ce{9XCcJ^ZuM%@j1i<9s*hFemp$qorj;H$T$gK#9|J z6WkE^-R(5)qZ5Nnerk@sG5Gv59PhgcX=v%>VQl(>dh_4K^;~O)hp(Kk)hVp%*zme3r((>bum#)I?U6 c{aJG4ZH6^iQ6Zk^+sKK`jwR&t}>_~tm+^Bs~cq;D3nEu`)3peicN{^A2%3m>mQSE0w zuZQtF8Ui@p3^1Vp{D$A^h6Wk{TDVW6R02?ZM9Un6lL?LCf9_n#m+shu5^f_ZfQNfM zs^{zG@5T@Ideok;o4*_1-}U(S`MUYL@x5J-TJhaJWu)^)`bB=;zd1!X_%`DW9fVtR zjQKaAdc3~%s1;v#{JXE5d+$;_bBXzI78%zkM_P0EVeFp2cD(v}+$~?}G0acf;7c5z ze;?&*@<+xJbf4JPeL`mZ+-{P8@-<`Ml|kb& zb&}7nD0l1IxO_cC9J;PM<)A1IY)0C9z&IE-`okR0=9|$%wy9wG_dxfj$bTElhjWJp zZvUCt&-j;HiQ9BdgM7L9@A|d-Myd42qbzU!{qdIE>2#j49iKUKEce~XnU0e)m2#n} z+4^|p=I6kyx6+xsNj^pIMSe1V*x%-xNZ!Gp=ZokhNqWMy9-Gb-#|wuuR{fM3X@AL&~S9>-hn zT8~F&gMoQ0VU}}zl~~Z%Y&l-xdN}zbwB)R})-&bL=d;((tTtWmeG`k{=*Rq#WkqSe z9xcoq!IH&6cl=k4AW#Y4L!5QkADhSIM+@go?>2vqmtvwpIFYdVn0Ko`N~&>iM&t|G zzpCq*52QZa&oF;z3!kS9z|!-N81rvqGorO)w1@e%=bQfa91ae$e@$6GKeSqtL2Q?+ ze>Tqbard~q{(0Vmdj6mP!;$|8L~#4DstAF#wb0EwVM_CAukm-9U#+~-AKkG>LomxWy}#(;??6}etuUQ>DfW{?Y4N!V%xyhHcy1@hhx#=&(Wfv zu_s)vzg^h#Jjrr9zVdkf{s|=$y1w%nZu3afQy(aDTRu09RS_Dw+Lb99c3XGq`jH!3 zq90jpyYI7+p!u^*`gL;r8qX(tT7r%=Na}9ObX_6;);6mupad32hjODuY%AxcL-?w3~^b0ZiI*=(@d6s&LD*4jH9 z+nlPZ?bbGD*5Aq)4W?45rj8M+7qLy^E?nUcwZw?vkvY)~HzsfBUL_d~r|$AtxK9aX zJVfy8oWnRoe+5b?G)DwaPBn5nq1Jnr#3%#kN%ajgj^G99WB0%G_G9V?$BlH@@LG?F ze<#-PmqqJsDIoMe#x$DtHd);@K!d70HI#kf+5JOk_4*Oj&wD@_<6ZpUR9yNQj^Mez#%*evUHPzM@-_ceNY`Y~*i zM&LMNbi-jb9z8ekep{cwUazD!oc&?XEDQ>q&1xwbe^GHgH@sz}XS?3X(zJIm0CW5U DND8iv literal 0 HcmV?d00001 diff --git a/addons/cargo/XEH_preInit.sqf b/addons/cargo/XEH_preInit.sqf index b6c5342042..f0cf3357cd 100644 --- a/addons/cargo/XEH_preInit.sqf +++ b/addons/cargo/XEH_preInit.sqf @@ -11,6 +11,7 @@ PREP(GetSizeItem); PREP(initObject); PREP(initVehicle); PREP(handleDestroyed); +PREP(moduleSettings); PREP(loadItem); PREP(onMenuOpen); PREP(unloadItem); diff --git a/addons/cargo/functions/fnc_initObject.sqf b/addons/cargo/functions/fnc_initObject.sqf index 98aeb5afea..07131da341 100644 --- a/addons/cargo/functions/fnc_initObject.sqf +++ b/addons/cargo/functions/fnc_initObject.sqf @@ -24,5 +24,5 @@ _type = typeOf _object; if (_type in GVAR(initializedItemClasses)) exitWith {}; GVAR(initializedItemClasses) pushBack _type; -_action = [QGVAR(load), localize LSTRING(loadObject), "", {[_player, _target] call FUNC(startLoadIn)}, {[_player, _target] call FUNC(canLoad)}] call EFUNC(interact_menu,createAction); +_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); [_type, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToClass); diff --git a/addons/cargo/functions/fnc_initVehicle.sqf b/addons/cargo/functions/fnc_initVehicle.sqf index 9653f756b2..7a03d3a1de 100644 --- a/addons/cargo/functions/fnc_initVehicle.sqf +++ b/addons/cargo/functions/fnc_initVehicle.sqf @@ -50,7 +50,7 @@ if (getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) != 1) ex private ["_text", "_condition", "_statement", "_icon", "_action"]; _text = localize "STR_ACE_Cargo_openMenu"; -_condition = {true}; +_condition = {GVAR(enable)}; _statement = {GVAR(interactionVehicle) = _target; createDialog QGVAR(menu);}; _icon = ""; diff --git a/addons/cargo/functions/fnc_moduleSettings.sqf b/addons/cargo/functions/fnc_moduleSettings.sqf new file mode 100644 index 0000000000..bb876c2840 --- /dev/null +++ b/addons/cargo/functions/fnc_moduleSettings.sqf @@ -0,0 +1,21 @@ +/* + * Author: Glowbal + * Module for adjusting the cargo settings + * + * Arguments: + * 0: The module logic + * 1: units + * 2: activated + * + * Return Value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_logic", "_units", "_activated"]; +if !(_activated) exitWith {}; + +[_logic, QGVAR(enable), "enable"] call EFUNC(common,readSettingFromModule); diff --git a/addons/cargo/stringtable.xml b/addons/cargo/stringtable.xml index 7f9a7411c8..eab51350a3 100644 --- a/addons/cargo/stringtable.xml +++ b/addons/cargo/stringtable.xml @@ -16,5 +16,20 @@ Cargo space left: %1 + + Cargo + + + Enable Cargo + + + Enable the load in cargo module + + + Cargo Settings + + + Configure the cargo module settings + diff --git a/extras/assets/icons/Icon_Module_png/Icon_Module_Cargo_ca.png b/extras/assets/icons/Icon_Module_png/Icon_Module_Cargo_ca.png new file mode 100644 index 0000000000000000000000000000000000000000..0209ed8676973410916331cc53e3cbb716c439b3 GIT binary patch literal 703 zcmV;w0zmzVP))h{< zhDQL$rDxy3`Lc~rYnj^J##J1} z;U4?kz3BWSE-m33es)l&wjy|{BU4rq(}`lU8@&pAPgJNhw<-ouhb=NQRX#jcgMIAlUqy4s>p+1FSCc zj3n2#p!~nuwpR&2=bC;;#dIF80)VH<+Rj%z`7u0M6?fP0K_pYZ-6bm?(^>?ij$3PD ltL$ntAT~(_00BUA<3Gq4b|t6EH6Q>0002ovPDHLkV1kr|E}sAZ literal 0 HcmV?d00001 From 317c73a80e94a4748b45778675d1dff4f63beed7 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sat, 15 Aug 2015 10:22:44 +0200 Subject: [PATCH 12/12] Added Land_PaperBox_closed_F fixed initOBject --- addons/cargo/CfgEventHandlers.hpp | 9 +++++++++ addons/cargo/CfgVehicles.hpp | 22 +++++++++++++++++++++- addons/cargo/config.cpp | 3 ++- addons/cargo/functions/fnc_canLoad.sqf | 2 +- addons/cargo/functions/fnc_initObject.sqf | 2 +- addons/cargo/functions/fnc_startLoadIn.sqf | 2 +- 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/addons/cargo/CfgEventHandlers.hpp b/addons/cargo/CfgEventHandlers.hpp index c6fa4c6819..f5dd29da0e 100644 --- a/addons/cargo/CfgEventHandlers.hpp +++ b/addons/cargo/CfgEventHandlers.hpp @@ -17,6 +17,7 @@ class Extended_Init_EventHandlers { init = QUOTE(_this call DFUNC(initObject)); }; }; + class ReammoBox_F { class ADDON { init = QUOTE(_this call DFUNC(initObject)); @@ -28,17 +29,25 @@ class Extended_Init_EventHandlers { init = QUOTE(_this call DFUNC(initObject); _this call DFUNC(initVehicle)); }; }; + class CargoNet_01_box_F { class ADDON { init = QUOTE(_this call DFUNC(initObject); _this call DFUNC(initVehicle)); }; }; + class Land_CargoBox_V1_F { class ADDON { init = QUOTE(_this call DFUNC(initObject); _this call DFUNC(initVehicle)); }; }; + class Land_PaperBox_closed_F { + class ADDON { + init = QUOTE(_this call DFUNC(initObject); _this call DFUNC(initVehicle)); + }; + }; + class Car { class ADDON { init = QUOTE(_this call DFUNC(initVehicle)); diff --git a/addons/cargo/CfgVehicles.hpp b/addons/cargo/CfgVehicles.hpp index 767c414361..d8df9e7da9 100644 --- a/addons/cargo/CfgVehicles.hpp +++ b/addons/cargo/CfgVehicles.hpp @@ -5,7 +5,7 @@ class CfgVehicles { class ACE_moduleCargoSettings: ACE_Module { scope = 2; displayName = CSTRING(SettingsModule_DisplayName); - icon = QUOTE(PATHTOF(UI\Icon_Module_Medical_ca.paa)); + icon = QUOTE(PATHTOF(UI\Icon_Module_Cargo_ca.paa)); category = "ACE"; function = QUOTE(DFUNC(moduleSettings)); functionPriority = 1; @@ -96,6 +96,26 @@ class CfgVehicles { GVAR(size) = 2; // 1 = small, 2 = large GVAR(canLoad) = 1; }; + + class Scrapyard_base_F; + class Land_PaperBox_closed_F: Scrapyard_base_F { + GVAR(space) = 10; + GVAR(hasCargo) = 1; + GVAR(size) = 11; + GVAR(canLoad) = 1; + XEH_ENABLED; + class ACE_Actions { + class ACE_MainActions { + displayName = ECSTRING(interaction,MainAction); + distance = 5; + condition = QUOTE(true); + statement = ""; + icon = "\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa"; + selection = ""; + }; + }; + }; + class Cargo_base_F: ThingX { GVAR(space) = 4; GVAR(hasCargo) = 1; diff --git a/addons/cargo/config.cpp b/addons/cargo/config.cpp index 3f1438a2f2..2972e8ef1b 100644 --- a/addons/cargo/config.cpp +++ b/addons/cargo/config.cpp @@ -14,4 +14,5 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" -#include "menu.hpp" \ No newline at end of file +#include "menu.hpp" +#include "ACE_Settings.hpp" diff --git a/addons/cargo/functions/fnc_canLoad.sqf b/addons/cargo/functions/fnc_canLoad.sqf index 8c96663d04..88391e80da 100644 --- a/addons/cargo/functions/fnc_canLoad.sqf +++ b/addons/cargo/functions/fnc_canLoad.sqf @@ -23,7 +23,7 @@ if (_nearestVehicle isKindOf "Cargo_Base_F" || isNull _nearestVehicle) then { { if ([_object, _x] call FUNC(canLoadItemIn)) exitwith {_nearestVehicle = _x}; - }foreach (nearestObjects [_player, ["Cargo_base_F"], MAX_LOAD_DISTANCE]); + }foreach (nearestObjects [_player, ["Cargo_base_F", "Land_PaperBox_closed_F"], MAX_LOAD_DISTANCE]); }; if (isNull _nearestVehicle) exitwith {false}; diff --git a/addons/cargo/functions/fnc_initObject.sqf b/addons/cargo/functions/fnc_initObject.sqf index 07131da341..c834bcf7b0 100644 --- a/addons/cargo/functions/fnc_initObject.sqf +++ b/addons/cargo/functions/fnc_initObject.sqf @@ -24,5 +24,5 @@ _type = typeOf _object; if (_type in GVAR(initializedItemClasses)) exitWith {}; 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); +_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); [_type, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToClass); diff --git a/addons/cargo/functions/fnc_startLoadIn.sqf b/addons/cargo/functions/fnc_startLoadIn.sqf index acef2a91b5..0da44ba04c 100644 --- a/addons/cargo/functions/fnc_startLoadIn.sqf +++ b/addons/cargo/functions/fnc_startLoadIn.sqf @@ -22,7 +22,7 @@ if (isNull _nearestVehicle || _nearestVehicle isKindOf "Cargo_Base_F") then { { if ([_object, _x] call FUNC(canLoadItemIn)) exitwith {_nearestVehicle = _x}; - }foreach (nearestObjects [_player, ["Cargo_base_F"], MAX_LOAD_DISTANCE]); + }foreach (nearestObjects [_player, ["Cargo_base_F", "Land_PaperBox_closed_F"], MAX_LOAD_DISTANCE]); }; if (isNull _nearestVehicle) exitwith {false};