diff --git a/Addons/logistics.pbo b/Addons/logistics.pbo new file mode 100644 index 0000000..65d6965 Binary files /dev/null and b/Addons/logistics.pbo differ diff --git a/Addons/logistics/$PBOPREFIX$ b/Addons/logistics/$PBOPREFIX$ new file mode 100644 index 0000000..d5220d8 --- /dev/null +++ b/Addons/logistics/$PBOPREFIX$ @@ -0,0 +1 @@ +z\clf\addons\logistics \ No newline at end of file diff --git a/Addons/logistics/CfgEditorSubcategories.hpp b/Addons/logistics/CfgEditorSubcategories.hpp new file mode 100644 index 0000000..16b3c53 --- /dev/null +++ b/Addons/logistics/CfgEditorSubcategories.hpp @@ -0,0 +1,7 @@ +/* +class CfgEditorSubcategories { + class GVAR(subcategory) { + displayName = CSTRING(Category_Logistics); + }; +}; +*/ \ No newline at end of file diff --git a/Addons/logistics/CfgEventHandlers.hpp b/Addons/logistics/CfgEventHandlers.hpp new file mode 100644 index 0000000..9b0c4a6 --- /dev/null +++ b/Addons/logistics/CfgEventHandlers.hpp @@ -0,0 +1,8 @@ +class Extended_PreInit_EventHandlers +{ + class CLF_PreInit + { + // init = "call compile preprocessFileLineNumbers 'logistics\\XEH_preInit.sqf'"; + init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); + } +} \ No newline at end of file diff --git a/Addons/logistics/CfgModuleCategories.hpp b/Addons/logistics/CfgModuleCategories.hpp new file mode 100644 index 0000000..e982328 --- /dev/null +++ b/Addons/logistics/CfgModuleCategories.hpp @@ -0,0 +1,11 @@ +class CfgFactionClasses { + class NO_CATEGORY; + class CLF: NO_CATEGORY { + displayName = "Clarkson's Logi"; + priority = 2; + side = 7; + }; + //class CLF_Logistics: CLF { + // displayName = "CLF - Logistics"; + //}; +}; \ No newline at end of file diff --git a/Addons/logistics/XEH_PREP.hpp b/Addons/logistics/XEH_PREP.hpp new file mode 100644 index 0000000..1fd5a99 --- /dev/null +++ b/Addons/logistics/XEH_PREP.hpp @@ -0,0 +1,31 @@ + +// Root folder functions +PREP(vehicleLoadMateriel); +PREP(vehicleLoadOre); +PREP(vehicleUnloadMateriel); +PREP(vehicleUnloadOre); + +// Init folder functions +PREP_S(initEngineeringBay,init) +PREP_S(initEngineeringBayInteractions,init) +PREP_S(initFactory,init) +PREP_S(initFactoryInteractions,init) +PREP_S(initFOB,init) +PREP_S(initFOBInteractions,init) +PREP_S(initHQ,init) +PREP_S(initHQInteractions,init) +PREP_S(initMaterielDepot,init) +PREP_S(initMaterielDepotInteractions,init) +PREP_S(initOreDepot,init) +PREP_S(initOreDepotInteractions,init) +PREP_S(initSupplyVehicle,init) +PREP_S(initSupplyVehicleInteractions,init) + +// Module folder functions +PREP_S(moduleInitEngineeringBay,modules) +PREP_S(moduleInitFactory,modules) +PREP_S(moduleInitFOB,modules) +PREP_S(moduleInitHQ,modules) +PREP_S(moduleInitMaterielDepot,modules) +PREP_S(moduleInitOreDepot,modules) +PREP_S(moduleInitSupplyVehicle,modules) diff --git a/Addons/logistics/XEH_postInit.sqf b/Addons/logistics/XEH_postInit.sqf new file mode 100644 index 0000000..84f2529 --- /dev/null +++ b/Addons/logistics/XEH_postInit.sqf @@ -0,0 +1 @@ +#include "script_component.hpp" \ No newline at end of file diff --git a/Addons/logistics/XEH_preInit.sqf b/Addons/logistics/XEH_preInit.sqf index e69de29..5ae1813 100644 --- a/Addons/logistics/XEH_preInit.sqf +++ b/Addons/logistics/XEH_preInit.sqf @@ -0,0 +1,51 @@ +#include "script_component.hpp" +/* +// Example -- Registering a CBA Setting or compiling functions +[ + "My_Setting_Name", + "CHECKBOX", + ["My Setting", "Tooltip description"], + "My Category", + false, + 1, + {params ["_value"];} +] call CBA_settings_fnc_init; +*/ + +// Setting up for auto-naming of new bases etc. in mission +GVAR(baseNames) = [ + "Alpha", + "Bravo", + "Charlie", + "Delta", + "Echo", + "Foxtrot", + "Golf", + "Hotel", + "India", + "Jericho", + "Kilo", + "Lima", + "Mike", + "November", + "Oscar", + "Papa", + "Quebec", + "Romeo", + "Sierra", + "Tango", + "Uniform", + "Victor", + "Whiskey", + "X-ray", + "Yankee", + "Zulu" +]; + +// Initialise base indices for auto-assigning new base names +GVAR(bluforBaseIndex) = 0; +GVAR(opforBaseIndex) = 0; +GVAR(independentBaseIndex) = 0; +GVAR(civilianBaseIndex) = 0; + +#include "initSettings.inc.sqf" \ No newline at end of file diff --git a/Addons/logistics/XEH_preStart.sqf b/Addons/logistics/XEH_preStart.sqf new file mode 100644 index 0000000..76b104a --- /dev/null +++ b/Addons/logistics/XEH_preStart.sqf @@ -0,0 +1,4 @@ +#include "script_component.hpp" + +#include "XEH_PREP.hpp" + diff --git a/Addons/logistics/cfgFunctions.hpp b/Addons/logistics/cfgFunctions.hpp index e69de29..5efe153 100644 --- a/Addons/logistics/cfgFunctions.hpp +++ b/Addons/logistics/cfgFunctions.hpp @@ -0,0 +1,40 @@ + +/* +class CfgFunctions +{ + class CLF + { + tag = "CLF"; + + class LogisticsFunctions + { + file = "logistics\functions"; + + class vehicleLoadMateriel {}; + class vehicleLoadOre {}; + class vehicleUnloadMateriel {}; + class vehicleUnloadOre {}; + }; + class LogisticsInitFunctions + { + file = "logistics\functions\init"; + + class initEngineeringBay {}; + class initEngineeringBayInteractions {}; + class initFactory {}; + class initFactoryInteractions {}; + class initFOB {}; + class initFOBInteractions {}; + class initHQ {}; + class initHQInteractions {}; + class initMaterielDepot {}; + class initMaterielDepotInteractions {}; + class initOreDepot {}; + class initOreDepotInteractions {}; + class initSupplyVehicle {}; + class initSupplyVehicleInteractions {}; + }; + }; +}; + +*/ \ No newline at end of file diff --git a/Addons/logistics/cfgVehicles.hpp b/Addons/logistics/cfgVehicles.hpp index e69de29..ab6dc08 100644 --- a/Addons/logistics/cfgVehicles.hpp +++ b/Addons/logistics/cfgVehicles.hpp @@ -0,0 +1,75 @@ +class CfgVehicles +{ + // Declaring custom zeus/3den modules + class Logic; + class Module_F: Logic + { + class AttributesBase + { + class Default; + class Edit; + class Combo; + class Checkbox; + class ModuleDescription; + class Units; + }; + + // Description base classes (for more information see below): + class ModuleDescription + { + class Anything; + }; + }; + + // Base module class for any initialisation modules + class CLF_Init_Base: Module_F + { + scope = 2; + scopeCurator = 2; + isGlobal = 0; + isTriggerActivated = 1; + isDisposable = 1; + // is3DEN = 1; + curatorCanAttach = 1; + canSetArea = 0; // Allows for setting the area values in the Attributes menu in 3DEN + canSetAreaShape = 0; // Allows for setting "Rectangle" or "Ellipse" in Attributes menu in 3DEN + canSetAreaHeight = 0; // Allows for setting height or Z value in Attributes menu in 3DEN + }; + + class CLF_Init_HQ: CLF_Init_Base + { + author = "Clarky"; + displayName = "Initialise HQ"; + //icon = ""; + category = "CLF" + function = FUNC(moduleInitHQ); + functionPriority = 1; + + class Attributes : AttributesBase + { + class Side: Combo + { + displayName = "HQ Team"; + property = "CLF_Module_Base_Side"; + typeName = "STRING"; + tooltip = "Which team this object will be assigned to."; + defaultValue = 1; + + class Values + { + class westSide { name = "$STR_WEST"; value = 1; }; + class eastSide { name = "$STR_east"; value = 2; }; + class indSide { name = "$STR_guerrila"; value = 3; }; + class civSide { name = "$STR_civilian"; value = 4; } + }; + }; + + class ModuleDescription : ModuleDescription {}; + }; + + class ModuleDescription : ModuleDescription + { + description = "Initialises HQ object for given side." + }; + }; +}; diff --git a/Addons/logistics/config.cpp b/Addons/logistics/config.cpp index 01e2727..64d66de 100644 --- a/Addons/logistics/config.cpp +++ b/Addons/logistics/config.cpp @@ -1,17 +1,39 @@ +#include "script_component.hpp" class CfgPatches { class ClarkonsLogisticsFramework { - units[] = ; + units[] = { /*CLF_Init_Base*/ }; weapons[] = {}; - requiredVersion = 2.22; - requiredAddons[] = {"cba_main"}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = { + "cba_main", + "cba_xeh" + }; author = "Clarky"; + VERSION_CONFIG; }; }; -#include "cfgFunctions.hpp" -#include "cfgVehicles.hpp" +/* +class CfgMods { + class PREFIX { + dir = "@ace"; + name = "Advanced Combat Environment 3"; + picture = "A3\Ui_f\data\Logos\arma3_expansion_alpha_ca"; + hidePicture = "true"; + hideName = "true"; + actionName = "Website"; + action = CSTRING(URL); + description = "Issue Tracker: https://github.com/acemod/ACE3/issues"; + }; +}; +*/ + +#include "CfgEventHandlers.hpp" +#include "CfgFunctions.hpp" +#include "CfgVehicles.hpp" +#include "CfgModuleCategories.hpp" // #include "ui\gui.hpp" \ No newline at end of file diff --git a/Addons/logistics/fn_template.sqf b/Addons/logistics/fn_template.sqf new file mode 100644 index 0000000..559e7ff --- /dev/null +++ b/Addons/logistics/fn_template.sqf @@ -0,0 +1,16 @@ +/* + * Author: Clarky + * Description: + * Describe the function + * + * Arguments: + * 0: Object + * 1: Integer + * + * Usage: + * [_object, _integer] call CLF_fnc_template + * + */ + + params ["_object", "_integer"]; + diff --git a/Addons/logistics/functions/fn_vehicleLoadMateriel.sqf b/Addons/logistics/functions/fn_vehicleLoadMateriel.sqf new file mode 100644 index 0000000..1e8d64e --- /dev/null +++ b/Addons/logistics/functions/fn_vehicleLoadMateriel.sqf @@ -0,0 +1,88 @@ +/* + Author: Clarky + Usage: + [ + "CLRK_fnc_VehicleLoaded", + [_target, _caller, _depot] + ] call CBA_fnc_serverEvent; + + Intended to be run by an event handler call from a vehicle load action from a player on a valid supply vehicle + +*/ + +params ["_vehicle", "_player", "_depot"]; + +if (!isServer) exitWith {}; + +if (isNull _vehicle) exitWith {hint "Vehicle ain't exist";}; +if (isNull _player) exitWith {hint "Player ain't exist";}; +if (isNull _depot) exitWith {hint "Depot ain't exist";}; + +if !(_vehicle getVariable ["isSupplyVehicle", false]) exitWith {hint "Vehicle ain't supply vehicle";}; + +private _vehicleCurrentMateriel = + _vehicle getVariable ["currentMateriel", 0]; +private _vehicleCurrentOre = + _vehicle getVariable ["currentOre", 0]; + +private _vehicleMax = + _vehicle getVariable ["maxLoad", 300]; + +private _transferRate = + _vehicle getVariable ["transferRate", 50]; + +private _depotCurrent = + _depot getVariable ["currentMateriel", 0]; + +private _freeSpace = + _vehicleMax - (_vehicleCurrentMateriel + _vehicleCurrentOre); + +if (_freeSpace <= 0) exitWith { + + [ + "CLRK_ShowMessage", + [1, 0, "Vehicle is already full."], + _player + ] call CBA_fnc_targetEvent; +}; + +if (_depotCurrent <= 0) exitWith { + + [ + "CLRK_ShowMessage", + [2, 0, "Depot has no Materiel available."], + _player + ] call CBA_fnc_targetEvent; +}; + +private _amount = + (_transferRate min _freeSpace) + min _depotCurrent; + +_vehicle setVariable [ + "currentMateriel", + _vehicleCurrentMateriel + _amount, + true +]; + +_depot setVariable [ + "currentMateriel", + _depotCurrent - _amount, + true +]; + +[ + "CLRK_ShowMessage", + [ + 0, + 0, + format [ + "Loaded %1 Materiel. Vehicle now contains %2.
Current Load: %3/%4.", + _amount, + _vehicleCurrentMateriel + _amount, + _vehicleCurrentMateriel + _amount + _vehicleCurrentOre, + _vehicleMax + ] + ], + _player +] call CBA_fnc_targetEvent; diff --git a/Addons/logistics/functions/fn_vehicleLoadOre.sqf b/Addons/logistics/functions/fn_vehicleLoadOre.sqf new file mode 100644 index 0000000..37db9ca --- /dev/null +++ b/Addons/logistics/functions/fn_vehicleLoadOre.sqf @@ -0,0 +1,88 @@ +/* + Author: Clarky + Usage: + [ + "CLRK_fnc_VehicleLoaded", + [_target, _caller, _depot] + ] call CBA_fnc_serverEvent; + + Intended to be run by an event handler call from a vehicle load action from a player on a valid supply vehicle + +*/ + +params ["_vehicle", "_player", "_depot"]; + +if (!isServer) exitWith {}; + +if (isNull _vehicle) exitWith {hint "Vehicle ain't exist";}; +if (isNull _player) exitWith {hint "Player ain't exist";}; +if (isNull _depot) exitWith {hint "Depot ain't exist";}; + +if !(_vehicle getVariable ["isSupplyVehicle", false]) exitWith {hint "Vehicle ain't supply vehicle";}; + +private _vehicleCurrentMateriel = + _vehicle getVariable ["currentMateriel", 0]; +private _vehicleCurrentOre = + _vehicle getVariable ["currentOre", 0]; + +private _vehicleMax = + _vehicle getVariable ["maxLoad", 300]; + +private _transferRate = + _vehicle getVariable ["transferRate", 50]; + +private _depotCurrent = + _depot getVariable ["currentOre", 0]; + +private _freeSpace = + _vehicleMax - (_vehicleCurrentMateriel + _vehicleCurrentOre); + +if (_freeSpace <= 0) exitWith { + + [ + "CLRK_ShowMessage", + [1, 0, "Vehicle is already full."], + _player + ] call CBA_fnc_targetEvent; +}; + +if (_depotCurrent <= 0) exitWith { + + [ + "CLRK_ShowMessage", + [2, 0, "Depot has no Ore available."], + _player + ] call CBA_fnc_targetEvent; +}; + +private _amount = + (_transferRate min _freeSpace) + min _depotCurrent; + +_vehicle setVariable [ + "currentOre", + _vehicleCurrentOre + _amount, + true +]; + +_depot setVariable [ + "currentOre", + _depotCurrent - _amount, + true +]; + +[ + "CLRK_ShowMessage", + [ + 0, + 0, + format [ + "Loaded %1 Ore. Vehicle now contains %2.
Current Load: %3/%4.", + _amount, + _vehicleCurrentOre + _amount, + _vehicleCurrentOre + _amount + _vehicleCurrentMateriel, + _vehicleMax + ] + ], + _player +] call CBA_fnc_targetEvent; diff --git a/Addons/logistics/functions/fn_vehicleUnloadMateriel.sqf b/Addons/logistics/functions/fn_vehicleUnloadMateriel.sqf new file mode 100644 index 0000000..212365c --- /dev/null +++ b/Addons/logistics/functions/fn_vehicleUnloadMateriel.sqf @@ -0,0 +1,93 @@ +/* + Author: Clarky + Usage: + [ + "CLRK_fnc_VehicleUnloaded", + [_target, _caller, _depot] + ] call CBA_fnc_serverEvent; + + Intended to be run by an event handler call from a vehicle unload action from a player on a valid supply vehicle + +*/ + +params ["_vehicle", "_player", "_depot"]; + +if (!isServer) exitWith {}; + +if (isNull _vehicle) exitWith {hint "Vehicle ain't exist";}; +if (isNull _player) exitWith {hint "Player ain't exist";}; +if (isNull _depot) exitWith {hint "Depot ain't exist";}; + +if !(_vehicle getVariable ["isSupplyVehicle", false]) exitWith {hint "Vehicle ain't supply vehicle";}; + +private _vehicleCurrent = + _vehicle getVariable ["currentMateriel", 0]; + +private _transferRate = + _vehicle getVariable ["transferRate", 50]; + +private _depotCurrent = + _depot getVariable ["currentMateriel", 0]; + +private _depotMax = + _depot getVariable ["maxMateriel", 300]; + +private _freeSpace = + _depotMax - _depotCurrent; + +if (_freeSpace <= 0) exitWith { + + [ + "CLRK_ShowMessage", + [ + 1, + 0, + "Depot is already full." + ], + _player + ] call CBA_fnc_targetEvent; +}; + +if (_vehicleCurrent <= 0) exitWith { + + [ + "CLRK_ShowMessage", + [ + 2, + 0, + "Vehicle has no Materiel available." + ], + _player + ] call CBA_fnc_targetEvent; +}; + +private _amount = + (_transferRate min _freeSpace) + min _vehicleCurrent; + +_vehicle setVariable [ + "currentMateriel", + _vehicleCurrent - _amount, + true +]; + +_depot setVariable [ + "currentMateriel", + _depotCurrent + _amount, + true +]; + +[ + "CLRK_ShowMessage", + [ + 0, + 0, + format [ + "Unloaded %1 materiel. Depot now contains %2/%3.", + _amount, + _depot getVariable ["currentMateriel",0], + _depotMax + ] + ], + _player +] call CBA_fnc_targetEvent; diff --git a/Addons/logistics/functions/fn_vehicleUnloadOre.sqf b/Addons/logistics/functions/fn_vehicleUnloadOre.sqf new file mode 100644 index 0000000..6a98bc7 --- /dev/null +++ b/Addons/logistics/functions/fn_vehicleUnloadOre.sqf @@ -0,0 +1,93 @@ +/* + Author: Clarky + Usage: + [ + "CLRK_fnc_VehicleUnloaded", + [_target, _caller, _depot] + ] call CBA_fnc_serverEvent; + + Intended to be run by an event handler call from a vehicle unload action from a player on a valid supply vehicle + +*/ + +params ["_vehicle", "_player", "_depot"]; + +if (!isServer) exitWith {}; + +if (isNull _vehicle) exitWith {hint "Vehicle ain't exist";}; +if (isNull _player) exitWith {hint "Player ain't exist";}; +if (isNull _depot) exitWith {hint "Depot ain't exist";}; + +if !(_vehicle getVariable ["isSupplyVehicle", false]) exitWith {hint "Vehicle ain't supply vehicle";}; + +private _vehicleCurrent = + _vehicle getVariable ["currentOre", 0]; + +private _transferRate = + _vehicle getVariable ["transferRate", 50]; + +private _depotCurrent = + _depot getVariable ["currentOre", 0]; + +private _depotMax = + _depot getVariable ["maxOre", 300]; + +private _freeSpace = + _depotMax - _depotCurrent; + +if (_freeSpace <= 0) exitWith { + + [ + "CLRK_ShowMessage", + [ + 1, + 0, + "Depot is already full." + ], + _player + ] call CBA_fnc_targetEvent; +}; + +if (_vehicleCurrent <= 0) exitWith { + + [ + "CLRK_ShowMessage", + [ + 2, + 0, + "Vehicle has no Ore available." + ], + _player + ] call CBA_fnc_targetEvent; +}; + +private _amount = + (_transferRate min _freeSpace) + min _vehicleCurrent; + +_vehicle setVariable [ + "currentOre", + _vehicleCurrent - _amount, + true +]; + +_depot setVariable [ + "currentOre", + _depotCurrent + _amount, + true +]; + +[ + "CLRK_ShowMessage", + [ + 0, + 0, + format [ + "Unloaded %1 Ore. Depot now contains %2/%3.", + _amount, + _depot getVariable ["currentOre",0], + _depotMax + ] + ], + _player +] call CBA_fnc_targetEvent; diff --git a/Addons/logistics/functions/init/fn_initEngineeringBay.sqf b/Addons/logistics/functions/init/fn_initEngineeringBay.sqf new file mode 100644 index 0000000..be8f29e --- /dev/null +++ b/Addons/logistics/functions/init/fn_initEngineeringBay.sqf @@ -0,0 +1,43 @@ +/* + * Author: Clarky + * Description: + * Initialises an Engineering Bay. Intended to be called as a function by internal processes, or exposed as a module in Eden and Zeus + * + * Arguments: + * 0: Linked HQ + * 1: Engineering Bay + * + * Usage: + * [_hq, this] call CLRK_fnc_initEngineeringBay + * + */ + +params [["_hq", "", ["", objNull]], "_engineering"]; + +if (!isServer) exitWith {}; + +_engineering setVariable ["isEngineeringBay", true, true]; + +// Wait to run the initialisaion for mission start -- Prevents base push until HQ object is initialised +if (_hq isNotEqualTo "") then { + [ + { + params ["_engineering", "_hq"]; + _engineering setVariable ["hq", _hq, true]; + private _baseDetails = _hq getVariable "baseDetails"; + private _buildings = _baseDetails get "buildings"; + _buildings pushBack _engineering; + }, + [_engineering, _hq], + 2 + ] call CBA_fnc_waitAndExecute; +}; + +// Set object to invulnerable -- May be removed once base building is fully implemented. +[_engineering, false] remoteExec ["allowDamage", 0, true]; + +[_engineering] remoteExecCall [ + "CLF_fnc_initEngineeringBayInteractions", + 0, + true +]; \ No newline at end of file diff --git a/Addons/logistics/functions/init/fn_initEngineeringBayInteractions.sqf b/Addons/logistics/functions/init/fn_initEngineeringBayInteractions.sqf new file mode 100644 index 0000000..55e5f93 --- /dev/null +++ b/Addons/logistics/functions/init/fn_initEngineeringBayInteractions.sqf @@ -0,0 +1,33 @@ +/* + * Author: Clarky + * Usage: + * [hq, this] call CLRK_fnc_initVehicleFactoryInteractions; + *   + * Intended to run locally on each client. + * +*/ + +params ["_engineering"]; + +_factory addAction [ + "Open Vehicle Engineering", + + { + params ["_target", "_caller"]; + // Load up the HQ as a variable for the player to access once proceeding through to building a vehicle + private _hq = _target getVariable ["hq", ""]; + if (_hq isNotEqualTo "") then { + uiNamespace setVariable ["localHQ", _hq]; + createDialog "VehicleFactoryDialog"; + } else { + hint "No attached HQ."; + }; + }, + nil, + 1, + true, + false, + "", + "true", // Figure out a way to lock this to player side checks (macros?) + 6 +]; \ No newline at end of file diff --git a/Addons/logistics/functions/init/fn_initFOB.sqf b/Addons/logistics/functions/init/fn_initFOB.sqf new file mode 100644 index 0000000..68e4a5d --- /dev/null +++ b/Addons/logistics/functions/init/fn_initFOB.sqf @@ -0,0 +1,56 @@ +/* + * Author: Clarky + * Description: + * Initialises a FOB type base. Intended to be called as a function by internal processes, or exposed as a module in Eden and Zeus + * + * Arguments: + * 0: FOB + * 1: Side + * + * Usage: + * [this, side] call CLRK_fnc_initHQ + * + */ + +params ["_fob", "_side"]; + +if (!isServer) exitWith {}; + +waitUntil { !isNull _fob; }; + +_fob setVariable ["isFOB", true, true]; + +// Set object to invulnerable -- May be removed once base building is fully implemented. +[_fob, false] remoteExec ["allowDamage", 0, true]; + +/* +// Set BaseID +private _baseID = format [ + "BASE_%1_%2", + diag_tickTime, + random[0,50,100] +]; + +_fob setVariable [ + "baseID", + _baseID, + true +];*/ + +_fob setVariable [ + "baseDetails", + createHashMapFromArray [ + //["id", _baseID], + ["hq", _fob], + ["buildings", []], + ["side", _side] + ], + true +]; + +// Initialise base HQ interactions for all clients +[_fob] remoteExecCall [ + "CLF_fnc_initFOBInteractions", + 0, + true +]; \ No newline at end of file diff --git a/Addons/logistics/functions/init/fn_initFOBInteractions.sqf b/Addons/logistics/functions/init/fn_initFOBInteractions.sqf new file mode 100644 index 0000000..5a9f5f3 --- /dev/null +++ b/Addons/logistics/functions/init/fn_initFOBInteractions.sqf @@ -0,0 +1,32 @@ +/* + * Author: Clarky + * Usage: + * [this] call CLRK_fnc_initBaseHQInteractions; + *   + * Intended to run locally on each client. + * + */ + +params ["_fob"]; + +_fob addAction [ + "Check Total Materiel", + + { + params ["_target", "_caller"]; + [ + "CLRK_MaterielCheck", + [ + _target, + _caller + ] + ] call CBA_fnc_serverEvent; + }, + nil, + 1, + true, + false, + "", + "true", + 6 +]; diff --git a/Addons/logistics/functions/init/fn_initFactory.sqf b/Addons/logistics/functions/init/fn_initFactory.sqf new file mode 100644 index 0000000..47d1eed --- /dev/null +++ b/Addons/logistics/functions/init/fn_initFactory.sqf @@ -0,0 +1,130 @@ +/* + * Author: Clarky + * Description: + * Initialises a Factory type base. Intended to be called as a function by internal processes, or exposed as a module in Eden and Zeus + * + * Arguments: + * 0: Factory + * 1: Side + * 2: Conversion Rate + * + * Usage: + * [this, side, 500] call CLRK_fnc_initHQ + * + */ + +params ["_factory", "_side", "_conversionAmount"]; + +if (!isServer) exitWith {}; + +waitUntil { !isNull _factory; }; + +_factory setVariable ["isFactory", true, true]; +_factory setVariable ["conversionAmount", _conversionAmount, true]; + +// Set object to invulnerable -- May be removed once base building is fully implemented. +[_factory, false] remoteExec ["allowDamage", 0, true]; + +/* +// Set BaseID +private _baseID = format [ + "BASE_%1_%2", + diag_tickTime, + random[0,50,100] +]; + +_factory setVariable [ + "baseID", + _baseID, + true +];*/ + +_factory setVariable [ + "baseDetails", + createHashMapFromArray [ + //["id", _baseID], + ["hq", _factory], + ["buildings", []], + ["supplyDepots", []], + ["oreDepots", []], + ["side", _side] + ], + true +]; + +// Initialise base HQ interactions for all clients +[_factory] remoteExecCall [ + "CLF_fnc_initFactoryInteractions", + 0, + true +]; + +[ + { + params ["_args", "_handle"]; + _args params ["_factory", "_conversionAmount"]; + + if (!alive _factory || isNull _factory) then { + [_handle] call CBA_fnc_removePerFrameHandler; + }; + + // Fetch linked depots - Exit out if none found + private _baseDetails = _factory getVariable "baseDetails"; + private _supplyDepots = _baseDetails get "supplyDepots"; + private _oreDepots = _baseDetails get "oreDepots"; + + if (_supplyDepots isEqualTo [] || _oreDepots isEqualTo []) exitWith {}; + + // Fetch all requisite details from linked details - For both Ore and Materiel Depots + private _currentOre = 0; + { + _currentOre = _currentOre + (_x getVariable ["currentOre", 0]); + } forEach _oreDepots; + + if !(_currentOre > 0) exitWith {}; + + private _freeSpace = 0; + + { + private _depotMateriel = _x getVariable "currentMateriel"; + private _depotMax = _x getVariable "maxMateriel"; + _freeSpace = _freeSpace + (_depotMax - _depotMateriel); + } forEach _supplyDepots; + + private _amountToConvert = _conversionAmount min _currentOre min _freeSpace; + + if (_amountToConvert == 0) exitWith {}; + + private _removeOre = _amountToConvert; + + { + // Get currently looped depot's materiel and draw down from it + private _depotOre = _x getVariable "currentOre"; + private _reduceAmount = _removeOre min _depotOre; + + _x setVariable ["currentOre", _depotOre - _reduceAmount, true]; + + // Update remaining amount to reduce + _removeOre = _removeOre - _reduceAmount; + } forEach _oreDepots; + + { + // If the _amount is now at 0, exit the loop early + if (_amount <= 0) exitWith {}; + + // Get currently looped depot's materiel and draw down from it + private _depotMateriel = _x getVariable "currentMateriel"; + private _depotMax = _x getVariable "maxMateriel"; + private _freeSpace = _depotMax - _depotMateriel; + private _addAmount = _amountToConvert min _freeSpace; + + _x setVariable ["currentMateriel", _depotMateriel + _addAmount, true]; + + // Update remaining amount to reduce + _amountToConvert = _amountToConvert - _addAmount; + } forEach _supplyDepots; + }, + 30, + [_factory, _conversionAmount] +] call CBA_fnc_addPerFrameHandler; + diff --git a/Addons/logistics/functions/init/fn_initFactoryInteractions.sqf b/Addons/logistics/functions/init/fn_initFactoryInteractions.sqf new file mode 100644 index 0000000..be868c2 --- /dev/null +++ b/Addons/logistics/functions/init/fn_initFactoryInteractions.sqf @@ -0,0 +1,55 @@ +/* + * Author: Clarky + * Usage: + * [this] call CLRK_fnc_initBaseHQInteractions; + *   + * Intended to run locally on each client. + * + */ + +params ["_factory"]; + + +_factory addAction [ + "Check Total Ore", + + { + params ["_target", "_caller"]; + [ + "CLRK_OreCheck", + [ + _target, + _caller + ] + ] call CBA_fnc_serverEvent; + }, + nil, + 1, + true, + false, + "", + "true", + 6 +]; + +_factory addAction [ + "Check Total Materiel", + + { + params ["_target", "_caller"]; + [ + "CLRK_MaterielCheck", + [ + _target, + _caller + ] + ] call CBA_fnc_serverEvent; + }, + nil, + 1, + true, + false, + "", + "true", + 6 +]; \ No newline at end of file diff --git a/Addons/logistics/functions/init/fn_initHQ.sqf b/Addons/logistics/functions/init/fn_initHQ.sqf new file mode 100644 index 0000000..415f08f --- /dev/null +++ b/Addons/logistics/functions/init/fn_initHQ.sqf @@ -0,0 +1,96 @@ +/* + * Author: Clarky + * Description: + * Initialises a Headquarters type base. Intended to be called as a function by internal processes, or exposed as a module in Eden and Zeus + * + * Arguments: + * 0: HQ + * 1: Side + * + * Usage: + * [this, side] call CLRK_fnc_initHQ + * + */ + +params ["_hq", "_side"]; + +if (!isServer) exitWith {}; + +waitUntil { !isNull _hq; }; + +_hq setVariable ["isHQ", true, true]; + +// Set object to invulnerable -- May be removed once base building is fully implemented. +[_hq, false] remoteExec ["allowDamage", 0, true]; + +/* +// Set BaseID +private _baseID = format [ + "BASE_%1_%2", + diag_tickTime, + random[0,50,100] +]; + +_hq setVariable [ + "baseID", + _baseID, + true +];*/ + +private _name = "" + +switch (_side) +{ + case west: + { + _name = GVAR(baseNames) select GVAR(bluforBaseIndex); + _hq setVariable ["baseName", _name, true]; + INC(GVAR(bluforBaseIndex)); + } + case east: + { + _name = GVAR(baseNames) select GVAR(opforBaseIndex); + _hq setVariable ["baseName", _name, true]; + INC(GVAR(opforBaseIndex)); + } + case independent: + { + _name = GVAR(baseNames) select GVAR(independentBaseIndex); + _hq setVariable ["baseName", _name, true]; + INC(GVAR(independentBaseIndex)); + } + case civilian: + { + _name = GVAR(baseNames) select GVAR(civilianBaseIndex); + _hq setVariable ["baseName", _name, true]; + INC(GVAR(civilianBaseIndex)); + } +} + +private _baseMarker = createMarker [format ["%1 [HQ]", _name], _hq]; +_baseMarker setMarkerShape "ICON"; +_baseMarker setMarkerType "mil_dot"; +_baseMarker setMarkerText format ["%1 [HQ]", _name]; +// TODO - Set colour based on side. Also figure out better icon. + +_hq setVariable ["baseMarker", _baseMarker, true]; + +_hq setVariable [ + "baseDetails", + createHashMapFromArray [ + //["id", _baseID], + ["hq", _hq], + ["buildings", []], + ["supplyDepots", []], + ["oreDepots", []], + ["side", _side] + ], + true +]; + +// Initialise base HQ interactions for all clients +[_hq] remoteExecCall [ + QFUNC(initHQInteractions), + 0, + true +]; \ No newline at end of file diff --git a/Addons/logistics/functions/init/fn_initHQInteractions.sqf b/Addons/logistics/functions/init/fn_initHQInteractions.sqf new file mode 100644 index 0000000..d292c03 --- /dev/null +++ b/Addons/logistics/functions/init/fn_initHQInteractions.sqf @@ -0,0 +1,79 @@ +/* + * Author: Clarky + * Usage: + * [this] call CLRK_fnc_initBaseHQInteractions; + *   + * Intended to run locally on each client. + * + */ + +params ["_hq"]; + +_hq addAction [ + "Check Total Materiel", + + { + params ["_target", "_caller"]; + [ + "CLRK_MaterielCheck", + [ + _target, + _caller + ] + ] call CBA_fnc_serverEvent; + }, + nil, + 1, + true, + false, + "", + "true", + 6 +]; + +_hq addAction [ + "Check Fortify Budget", + { + params ["_target", "_caller"]; + private _msg = format ["Current Fortify Budget: %1", [side _caller] call ace_fortify_fnc_getBudget]; + [ + "CLRK_ShowMessage", + [ + 3, + 1, + _msg + ], + _caller + ] call CBA_fnc_targetEvent; + }, + nil, + 1, + true, + false, + "", + "true", // Figure out a way to lock this to player side checks (macros?) + 6 +]; + +_hq addAction [ + "Add Fortify Budget - $100", + { + params ["_target", "_caller"]; + + [ + "CLRK_FortifyBudgetAdd", + [ + _target, + _caller + ] + ] call CBA_fnc_serverEvent; + //[side _caller, 100, true] call ace_fortify_fnc_updateBudget; + }, + nil, + 1, + true, + false, + "", + "true", // Figure out a way to lock this to player side checks (macros?) + 6 +]; diff --git a/Addons/logistics/functions/init/fn_initMaterielDepot.sqf b/Addons/logistics/functions/init/fn_initMaterielDepot.sqf new file mode 100644 index 0000000..59ae556 --- /dev/null +++ b/Addons/logistics/functions/init/fn_initMaterielDepot.sqf @@ -0,0 +1,83 @@ +/* + * Author: Clarky + * Description: + * Initialises a Materiel Depot. Intended to be called as a function by internal processes, or exposed as a module in Eden and Zeus + * + * Arguments: + * 0: Linked HQ + * 1: Depot + * 2: Max Materiel + * 3: Current Materiel + * 4: Generation Rate + * + * Usage: + * [_base, this, 1000, 0, false, 0] call CLRK_fnc_initSupplyDepot + * + */ + +params [["_base", "", ["", objNull]], "_depot", "_maxMateriel", "_currentMateriel", "_generationRate"]; + +if (!isServer) exitWith {}; + +_depot setVariable ["isSupplyDepot", true, true]; +_depot setVariable ["maxMateriel", _maxMateriel, true]; +_depot setVariable ["currentMateriel", _currentMateriel, true]; +_depot setVariable ["materielRate", _materielRate, true]; + +// Wait to run the initialisaion for mission start -- Prevents base push until HQ object is initialised +if (_base isNotEqualTo "") then { + [ + { + params ["_depot", "_base"]; + _depot setVariable ["hq", _base, true]; + private _baseDetails = _base getVariable "baseDetails"; + private _depots = _baseDetails get "supplyDepots"; + _depots pushBack _depot; + }, + [_depot, _base], + 2 + ] call CBA_fnc_waitAndExecute; +}; + +// Set object to invulnerable -- May be removed once base building is fully implemented. +[_depot, false] remoteExec ["allowDamage", 0, true]; + +[_depot] remoteExecCall [ + "CLF_fnc_initSupplyDepotInteractions", + 0, + true +]; + +// If a generation rate was supplied, spawn in per frame handler to generate resources every 30 seconds +if (_generationRate > 0) then { + [ + { + params ["_args", "_handle"]; + _args params ["_depot", "_materielRate"]; + + if (!alive _depot || isNull _depot) then { + [_handle] call CBA_fnc_removePerFrameHandler; + }; + + private _depotCurrent = + _depot getVariable "currentMateriel"; + + private _depotMax = + _depot getVariable "maxMateriel"; + + private _freeSpace = + _depotMax - _depotCurrent; + + private _amount = + (_materielRate min _freeSpace); + + _depot setVariable [ + "currentMateriel", + _depotCurrent + _amount, + true + ]; + }, + 30, + [_depot, _materielRate] + ] call CBA_fnc_addPerFrameHandler; +}; diff --git a/Addons/logistics/functions/init/fn_initMaterielDepotInteractions.sqf b/Addons/logistics/functions/init/fn_initMaterielDepotInteractions.sqf new file mode 100644 index 0000000..e7f9658 --- /dev/null +++ b/Addons/logistics/functions/init/fn_initMaterielDepotInteractions.sqf @@ -0,0 +1,58 @@ +/* + Author: Clarky + Usage: + [this] call CLRK_fnc_initSupplyDepotInteractions; +   + Intended to run locally on each client. + +*/ + +params ["_depot"]; + +if (isNull _depot) exitWith {hint "Object ain't exist";}; +if !(_depot getVariable ["isSupplyDepot", false]) exitWith {hint "Object ain't supply depot";}; + +// Prevent duplicate actions if script runs again +if (_depot getVariable ["supplyInteractionsAdded", false]) exitWith {}; + +_depot setVariable ["supplyInteractionsAdded", true]; + +////////////////////////////////////////////////////////////////// +// INIT STATUS ACTION +////////////////////////////////////////////////////////////////// + +_depot addAction [ + "Check Materiel Status", + + { + params ["_target", "_caller"]; + + private _current = + _target getVariable ["currentMateriel", 0]; + + private _max = + _target getVariable ["maxMateriel", 300]; + + [ + "CLRK_ShowMessage", + [ + 3, + 1, + format + [ + "SUPPLY DEPOT STORAGE
Materiel: %1 / %2", + _current, + _max + ] + ], + _caller + ] call CBA_fnc_targetEvent; + }, + nil, + 1, + true, + false, + "", + "true", + 6 +]; \ No newline at end of file diff --git a/Addons/logistics/functions/init/fn_initOreDepot.sqf b/Addons/logistics/functions/init/fn_initOreDepot.sqf new file mode 100644 index 0000000..baf4281 --- /dev/null +++ b/Addons/logistics/functions/init/fn_initOreDepot.sqf @@ -0,0 +1,83 @@ +/* + * Author: Clarky + * Description: + * Initialises an Ore Depot. Intended to be called as a function by internal processes, or exposed as a module in Eden and Zeus + * + * Arguments: + * 0: Linked HQ + * 1: Depot + * 2: Max Ore + * 3: Current Ore + * 4: Generation Rate + * + * Usage: + * [_base, this, 1000, 0, false, 0] call CLRK_fnc_initOreDepot + * + */ + +params [["_base", "", ["", objNull]], "_depot", "_maxOre", "_currentOre", "_generationRate"]; + +if (!isServer) exitWith {}; + +_depot setVariable ["isOreDepot", true, true]; +_depot setVariable ["maxOre", _maxOre, true]; +_depot setVariable ["currentOre", _currentOre, true]; +_depot setVariable ["oreRate", _generationRate, true]; + +// Wait to run the initialisaion for mission start -- Prevents base push until HQ object is initialised +if (_base isNotEqualTo "") then { + [ + { + params ["_depot", "_base"]; + _depot setVariable ["hq", _base, true]; + private _baseDetails = _base getVariable "baseDetails"; + private _depots = _baseDetails get "oreDepots"; + _depots pushBack _depot; + }, + [_depot, _base], + 2 + ] call CBA_fnc_waitAndExecute; +}; + +// Set object to invulnerable -- May be removed once base building is fully implemented. +[_depot, false] remoteExec ["allowDamage", 0, true]; + +[_depot] remoteExecCall [ + "CLF_fnc_initOreDepotInteractions", + 0, + true +]; + +// If a generation rate was supplied, spawn in per frame handler to generate resources every 30 seconds +if (_generationRate > 0) then { + [ + { + params ["_args", "_handle"]; + _args params ["_depot", "_generationRate"]; + + if (!alive _depot || isNull _depot) then { + [_handle] call CBA_fnc_removePerFrameHandler; + }; + + private _depotCurrent = + _depot getVariable "currentOre"; + + private _depotMax = + _depot getVariable "maxOre"; + + private _freeSpace = + _depotMax - _depotCurrent; + + private _amount = + (_oreRate min _freeSpace); + + _depot setVariable [ + "currentOre", + _depotCurrent + _amount, + true + ]; + }, + 30, + [_depot, _oreRate] + ] call CBA_fnc_addPerFrameHandler; +}; diff --git a/Addons/logistics/functions/init/fn_initOreDepotInteractions.sqf b/Addons/logistics/functions/init/fn_initOreDepotInteractions.sqf new file mode 100644 index 0000000..bb27b63 --- /dev/null +++ b/Addons/logistics/functions/init/fn_initOreDepotInteractions.sqf @@ -0,0 +1,58 @@ +/* + Author: Clarky + Usage: + [this] call CLRK_fnc_initSupplyDepotInteractions; +   + Intended to run locally on each client. + +*/ + +params ["_depot"]; + +if (isNull _depot) exitWith {hint "Object ain't exist";}; +if !(_depot getVariable ["isOreDepot", false]) exitWith {hint "Object ain't ore depot";}; + +// Prevent duplicate actions if script runs again +if (_depot getVariable ["oreInteractionsAdded", false]) exitWith {}; + +_depot setVariable ["oreInteractionsAdded", true]; + +////////////////////////////////////////////////////////////////// +// INIT STATUS ACTION +////////////////////////////////////////////////////////////////// + +_depot addAction [ + "Check Ore Status", + + { + params ["_target", "_caller"]; + + private _current = + _target getVariable ["currentOre", 0]; + + private _max = + _target getVariable ["maxOre", 300]; + + [ + "CLRK_ShowMessage", + [ + 3, + 1, + format + [ + "ORE DEPOT STORAGE
Ore: %1 / %2", + _current, + _max + ] + ], + _caller + ] call CBA_fnc_targetEvent; + }, + nil, + 1, + true, + false, + "", + "true", + 6 +]; \ No newline at end of file diff --git a/Addons/logistics/functions/init/fn_initSupplyVehicle.sqf b/Addons/logistics/functions/init/fn_initSupplyVehicle.sqf new file mode 100644 index 0000000..1581926 --- /dev/null +++ b/Addons/logistics/functions/init/fn_initSupplyVehicle.sqf @@ -0,0 +1,33 @@ +/* + * Author: Clarky + * Description: + * Initialises a Supply Vehicle. Intended to be called as a function by internal processes, or exposed as a module in Eden and Zeus + * + * Arguments: + * 0: Vehicle + * 1: Max Load + * 2: Current Materiel + * 3: Current Ore + * 4: Transfer Rate + * + * Usage: + * [this, 500, 0, 0, 100] call CLRK_fnc_initSupplyVehicle + * + */ + +params ["_vehicle", "_maxLoad", "_currentMateriel", "_currentOre", "_transferRate"]; + +if (!isServer) exitWith {}; + +_vehicle setVariable ["isSupplyVehicle", true, true]; +_vehicle setVariable ["maxLoad", _maxMateriel, true]; +_vehicle setVariable ["currentMateriel", _currentMateriel, true]; +_vehicle setVariable ["currentOre", _currentOre, true]; +_vehicle setVariable ["transferRate", _transferRate, true]; + +[_vehicle] remoteExecCall [ + "CLF_fnc_initSupplyVehicleInteractions", + 0, + true +]; + diff --git a/Addons/logistics/functions/init/fn_initSupplyVehicleInteractions.sqf b/Addons/logistics/functions/init/fn_initSupplyVehicleInteractions.sqf new file mode 100644 index 0000000..e3facdf --- /dev/null +++ b/Addons/logistics/functions/init/fn_initSupplyVehicleInteractions.sqf @@ -0,0 +1,287 @@ +/* + * Author: Clarky + * Usage: + * [this] call CLRK_fnc_initSupplyVehicleInteractions; + *   + * Intended to run locally on each client. + * +*/ + +params ["_vehicle"]; + +if (isNull _vehicle) exitWith {hint "VEHICLE ERROR -- SUPPLY";}; +if !(_vehicle getVariable ["isSupplyVehicle", false]) exitWith {hint "SUPPLY VEHICLE INIT NOT FOUND";}; + +// Prevent duplicate actions if script runs again +if (_vehicle getVariable ["supplyInteractionsAdded", false]) exitWith {}; + +_vehicle setVariable ["supplyInteractionsAdded", true]; + +////////////////////////////////////////////////////////////////// +// INIT STATUS ACTION +////////////////////////////////////////////////////////////////// + +_vehicle addAction [ + "Check Storage Status", + { + params ["_target", "_caller"]; + + private _currentMateriel = + _target getVariable ["currentMateriel", 0]; + private _currentOre = + _target getVariable ["currentOre", 0]; + + private _max = + _target getVariable ["maxLoad", 300]; + + private _rate = + _target getVariable ["transferRate", 50]; + + [ + "CLRK_ShowMessage", + [ + 3, + 1, + format + [ + "SUPPLY VEHICLE STORAGE
Materiel: %1
Ore: %2
Capacity: %3 / %4
Transfer Rate: %5", + _currentMateriel, + _currentOre, + _currentMateriel + _currentOre, + _max, + _rate + ] + ], + _caller + ] call CBA_fnc_targetEvent; + }, + nil, + 1, + true, + false, + "", + "true", + 6 +]; + +////////////////////////////////////////////////////////////////// +// INIT LOAD ACTION +////////////////////////////////////////////////////////////////// + +/////////////////////////////////////// +// MATERIEL ACTIONS +/////////////////////////////////////// +[ + _vehicle, // Object the action is attached to + "Load Materiel", // Title of the action + "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa", // Idle icon shown on screen + "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa", // Progress icon shown on screen + "(([_this] call ace_common_fnc_isEngineer) || (missionNamespace getVariable 'allCanUseLogistics')) && + ( + (nearestObjects [_target, [], 15] findIf { + _x getVariable ['isSupplyDepot', false] + }) > -1 + ) && + (_target distance _this < 7)", // Condition for the action to be shown + "alive _target", // Condition for the action to progress + {}, // Code executed when action starts + {}, // Code executed on every progress tick + { + params ["_target", "_caller"]; + + private _depot = ( + nearestObjects [_target, [], 15] + select { + _x getVariable ["isSupplyDepot", false] + } + ) param [0, objNull]; + + if (isNull _depot) exitWith { + [ + "CLRK_ShowMessage", + [ + 1, + 0, + "No Materiel depot nearby." + ], + _caller + ] call CBA_fnc_targetEvent; + }; + + [ + "CLRK_VehicleLoadedMateriel", + [_target, _caller, _depot] + ] call CBA_fnc_serverEvent; + }, // Code executed on completion + {}, // Code executed on interrupted + [], // Arguments passed to the scripts as _this select 3 + 5, // Action duration in seconds + 0, // Priority + false, // Remove on completion + false, // Show in unconscious state + true // Show on screen +] call BIS_fnc_holdActionAdd; + +////////////////////////////////////////////////////////////////// +// INIT UNLOAD ACTION +////////////////////////////////////////////////////////////////// + +[ + _vehicle, // Object the action is attached to + "Unload Materiel", // Title of the action + "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_unloaddevice_ca.paa", // Idle icon shown on screen + "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_unloaddevice_ca.paa", // Progress icon shown on screen + "(([_this] call ace_common_fnc_isEngineer) || (missionNamespace getVariable 'allCanUseLogistics')) && + ( + (nearestObjects [_target, [], 15] findIf { + _x getVariable ['isSupplyDepot', false] + }) > -1 + ) && + (_target distance _this < 7)", // Condition for the action to be shown + "alive _target", // Condition for the action to progress + {}, // Code executed when action starts + {}, // Code executed on every progress tick + { + params ["_target", "_caller"]; + + private _depot = ( + nearestObjects [_target, [], 15] + select { + _x getVariable ["isSupplyDepot", false] + } + ) param [0, objNull]; + + if (isNull _depot) exitWith { + [ + "CLRK_ShowMessage", + [ + 1, + 0, + "No Materiel depot nearby." + ], + _caller + ] call CBA_fnc_targetEvent; + }; + + [ + "CLRK_VehicleUnloadedMateriel", + [_target, _caller, _depot] + ] call CBA_fnc_serverEvent; + }, // Code executed on completion + {}, // Code executed on interrupted + [], // Arguments passed to the scripts as _this select 3 + 5, // Action duration in seconds + 0, // Priority + false, // Remove on completion + false, // Show in unconscious state + true // Show on screen +] call BIS_fnc_holdActionAdd; + +/////////////////////////////////////// +// ORE ACTIONS +/////////////////////////////////////// +[ + _vehicle, // Object the action is attached to + "Load Ore", // Title of the action + "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa", // Idle icon shown on screen + "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa", // Progress icon shown on screen + "(([_this] call ace_common_fnc_isEngineer) || (missionNamespace getVariable 'allCanUseLogistics')) && + ( + (nearestObjects [_target, [], 15] findIf { + _x getVariable ['isOreDepot', false] + }) > -1 + ) && + (_target distance _this < 7)", // Condition for the action to be shown + "alive _target", // Condition for the action to progress + {}, // Code executed when action starts + {}, // Code executed on every progress tick + { + params ["_target", "_caller"]; + + private _depot = ( + nearestObjects [_target, [], 15] + select { + _x getVariable ["isOreDepot", false] + } + ) param [0, objNull]; + + if (isNull _depot) exitWith { + [ + "CLRK_ShowMessage", + [ + 1, + 0, + "No Ore depot nearby." + ], + _caller + ] call CBA_fnc_targetEvent; + }; + + [ + "CLRK_VehicleLoadedOre", + [_target, _caller, _depot] + ] call CBA_fnc_serverEvent; + }, // Code executed on completion + {}, // Code executed on interrupted + [], // Arguments passed to the scripts as _this select 3 + 5, // Action duration in seconds + 0, // Priority + false, // Remove on completion + false, // Show in unconscious state + true // Show on screen +] call BIS_fnc_holdActionAdd; + +////////////////////////////////////////////////////////////////// +// INIT UNLOAD ACTION +////////////////////////////////////////////////////////////////// + +[ + _vehicle, // Object the action is attached to + "Unload Ore", // Title of the action + "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_unloaddevice_ca.paa", // Idle icon shown on screen + "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_unloaddevice_ca.paa", // Progress icon shown on screen + "(([_this] call ace_common_fnc_isEngineer) || (missionNamespace getVariable 'allCanUseLogistics')) && + ( + (nearestObjects [_target, [], 15] findIf { + _x getVariable ['isOreDepot', false] + }) > -1 + ) && + (_target distance _this < 7)", // Condition for the action to be shown + "alive _target", // Condition for the action to progress + {}, // Code executed when action starts + {}, // Code executed on every progress tick + { + params ["_target", "_caller"]; + + private _depot = ( + nearestObjects [_target, [], 15] + select { + _x getVariable ["isOreDepot", false] + } + ) param [0, objNull]; + + if (isNull _depot) exitWith { + [ + "CLRK_ShowMessage", + [ + 1, + 0, + "No Ore depot nearby." + ], + _caller + ] call CBA_fnc_targetEvent; + }; + + [ + "CLRK_VehicleUnloadedOre", + [_target, _caller, _depot] + ] call CBA_fnc_serverEvent; + }, // Code executed on completion + {}, // Code executed on interrupted + [], // Arguments passed to the scripts as _this select 3 + 5, // Action duration in seconds + 0, // Priority + false, // Remove on completion + false, // Show in unconscious state + true // Show on screen +] call BIS_fnc_holdActionAdd; \ No newline at end of file diff --git a/Addons/logistics/functions/modules/fn_moduleInitEngineeringBay.sqf b/Addons/logistics/functions/modules/fn_moduleInitEngineeringBay.sqf new file mode 100644 index 0000000..e69de29 diff --git a/Addons/logistics/functions/modules/fn_moduleInitFOB.sqf b/Addons/logistics/functions/modules/fn_moduleInitFOB.sqf new file mode 100644 index 0000000..e69de29 diff --git a/Addons/logistics/functions/modules/fn_moduleInitFactory.sqf b/Addons/logistics/functions/modules/fn_moduleInitFactory.sqf new file mode 100644 index 0000000..e69de29 diff --git a/Addons/logistics/functions/modules/fn_moduleInitHQ.sqf b/Addons/logistics/functions/modules/fn_moduleInitHQ.sqf new file mode 100644 index 0000000..e6b0aba --- /dev/null +++ b/Addons/logistics/functions/modules/fn_moduleInitHQ.sqf @@ -0,0 +1,13 @@ +params [ + ["_logic", objNull, [objNull]], // Argument 0 is module logic + ["_units", [], [[]]], // Argument 1 is a list of affected units (affected by value selected in the 'class Units' argument)) + ["_activated", true, [true]] // True when the module was activated, false when it is deactivated (i.e., synced triggers are no longer active) +]; + +if (!_activated) exitWith {}; + +private _side = _logic getVariable ["Side", -1]; + +{ + [_x, _side] remoteExec [QFUNC(initHQ), 2]; +} forEach synchronizedObjects _logic; diff --git a/Addons/logistics/functions/modules/fn_moduleInitMaterielDepot.sqf b/Addons/logistics/functions/modules/fn_moduleInitMaterielDepot.sqf new file mode 100644 index 0000000..e69de29 diff --git a/Addons/logistics/functions/modules/fn_moduleInitOreDepot.sqf b/Addons/logistics/functions/modules/fn_moduleInitOreDepot.sqf new file mode 100644 index 0000000..e69de29 diff --git a/Addons/logistics/functions/modules/fn_moduleInitSupplyVehicle.sqf b/Addons/logistics/functions/modules/fn_moduleInitSupplyVehicle.sqf new file mode 100644 index 0000000..e69de29 diff --git a/Addons/logistics/initSettings.inc.sqf b/Addons/logistics/initSettings.inc.sqf new file mode 100644 index 0000000..e3b5142 --- /dev/null +++ b/Addons/logistics/initSettings.inc.sqf @@ -0,0 +1,13 @@ +/* +[ + QXGVAR(settingHint), + "LIST", + [LLSTRING(settingHint), LLSTRING(settingHintDesc)], + LLSTRING(settingsCategory), + [ + [0, 1, 2], + [LLSTRING(settingHintNone), LLSTRING(settingHintHasTool), LLSTRING(settingHintEveryone)], + 2 + ] +] call CBA_fnc_addSetting; +*/ \ No newline at end of file diff --git a/Addons/logistics/script_component.hpp b/Addons/logistics/script_component.hpp index 34a8a15..303375e 100644 --- a/Addons/logistics/script_component.hpp +++ b/Addons/logistics/script_component.hpp @@ -3,7 +3,7 @@ #include "\z\clf\addons\logistics\script_mod.hpp" // #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE +#define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS //#ifdef DEBUG_ENABLED_MAIN diff --git a/Addons/logistics/script_macros.hpp b/Addons/logistics/script_macros.hpp index e69de29..a62ce7d 100644 --- a/Addons/logistics/script_macros.hpp +++ b/Addons/logistics/script_macros.hpp @@ -0,0 +1,14 @@ +#include "\x\cba\addons\main\script_macros_common.hpp" +#include "\x\cba\addons\xeh\script_xeh.hpp" + +// New PREP macros +#undef PREP +#ifdef DISABLE_COMPILE_CACHE + // no compile cache + #define PREP(fncName) TRIPLES(ADDON,fnc,fncName) = compile preprocessFileLineNumbers QPATHTOF(functions\DOUBLES(fnc,fncName).sqf) + #define PREP_S(fncName,subfolder) TRIPLES(ADDON,fnc,fncName) = compile preprocessFileLineNumbers QPATHTOF(functions\subfolder\DOUBLES(fnc,fncName).sqf) +#else + // compile cache + #define PREP(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf), QFUNC(fncName)] call CBA_fnc_compileFunction + #define PREP_S(fncName,subfolder) [QPATHTOF(functions\subfolder\DOUBLES(fnc,fncName).sqf), QFUNC(fncName)] call CBA_fnc_compileFunction +#endif \ No newline at end of file diff --git a/Addons/logistics/script_mod.hpp b/Addons/logistics/script_mod.hpp index 483f9ed..8e61759 100644 --- a/Addons/logistics/script_mod.hpp +++ b/Addons/logistics/script_mod.hpp @@ -2,6 +2,9 @@ #define MAINPREFIX z #define PREFIX clf +#define SUBPREFIX addons + +#define ADDON DOUBLES(PREFIX,COMPONENT) #include "script_version.hpp" @@ -23,4 +26,4 @@ #else #define COMPONENT_NAME QUOTE(CLF - COMPONENT_BEAUTIFIED) #endif -*/ \ No newline at end of file +*/