Set up and integrated HEMTT for easier dev workflow. Adjusted core addon name 'logistics' to 'main'. Fixed several issues caught by HEMTT
This commit is contained in:
1 parent
00eee092c3
commit
8ef33973bd
61 files changed
+4002
-82
No files matched your search
@@ -0,0 +1,44 @@
|
||||
#include "..\..\script_component.hpp"
|
||||
/*
|
||||
* 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 <OBJECT>
|
||||
* 1: Engineering Bay <OBJECT>
|
||||
*
|
||||
* 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
|
||||
];
|
||||
@@ -0,0 +1,48 @@
|
||||
#include "..\..\script_component.hpp"
|
||||
/*
|
||||
* Author: Clarky
|
||||
* Description:
|
||||
* Describe the function
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Linked HQ <OBJECT>
|
||||
* 1: Engineering Bay <OBJECT>
|
||||
*
|
||||
* Usage:
|
||||
* [_object, _integer] call CLF_fnc_template
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Clarky
|
||||
* Usage:
|
||||
* [hq, this] call CLRK_fnc_initVehicleFactoryInteractions;
|
||||
*
|
||||
* Intended to run locally on each client.
|
||||
*
|
||||
*/
|
||||
|
||||
params ["_engineering"];
|
||||
|
||||
_engineering addAction [
|
||||
"<t color='#71BDA6'>Open Vehicle Engineering</t>",
|
||||
|
||||
{
|
||||
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
|
||||
];
|
||||
@@ -0,0 +1,57 @@
|
||||
#include "..\..\script_component.hpp"
|
||||
/*
|
||||
* 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 <OBJECT>
|
||||
* 1: Side <STR>
|
||||
*
|
||||
* 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
|
||||
];
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Author: Clarky
|
||||
* Usage:
|
||||
* [this] call CLRK_fnc_initBaseHQInteractions;
|
||||
*
|
||||
* Intended to run locally on each client.
|
||||
*
|
||||
*/
|
||||
|
||||
params ["_fob"];
|
||||
|
||||
_fob addAction [
|
||||
"<t color='#FFD700'>Check Total Materiel</t>",
|
||||
|
||||
{
|
||||
params ["_target", "_caller"];
|
||||
[
|
||||
"CLRK_MaterielCheck",
|
||||
[
|
||||
_target,
|
||||
_caller
|
||||
]
|
||||
] call CBA_fnc_serverEvent;
|
||||
},
|
||||
nil,
|
||||
1,
|
||||
true,
|
||||
false,
|
||||
"",
|
||||
"true",
|
||||
6
|
||||
];
|
||||
@@ -0,0 +1,131 @@
|
||||
#include "..\..\script_component.hpp"
|
||||
/*
|
||||
* 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 <OBJECT>
|
||||
* 1: Side <STR>
|
||||
* 2: Conversion Rate <INT>
|
||||
*
|
||||
* 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 (_amountToConvert <= 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;
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Author: Clarky
|
||||
* Usage:
|
||||
* [this] call CLRK_fnc_initBaseHQInteractions;
|
||||
*
|
||||
* Intended to run locally on each client.
|
||||
*
|
||||
*/
|
||||
|
||||
params ["_factory"];
|
||||
|
||||
|
||||
_factory addAction [
|
||||
"<t color='#b96331'>Check Total Ore</t>",
|
||||
|
||||
{
|
||||
params ["_target", "_caller"];
|
||||
[
|
||||
"CLRK_OreCheck",
|
||||
[
|
||||
_target,
|
||||
_caller
|
||||
]
|
||||
] call CBA_fnc_serverEvent;
|
||||
},
|
||||
nil,
|
||||
1,
|
||||
true,
|
||||
false,
|
||||
"",
|
||||
"true",
|
||||
6
|
||||
];
|
||||
|
||||
_factory addAction [
|
||||
"<t color='#FFD700'>Check Total Materiel</t>",
|
||||
|
||||
{
|
||||
params ["_target", "_caller"];
|
||||
[
|
||||
"CLRK_MaterielCheck",
|
||||
[
|
||||
_target,
|
||||
_caller
|
||||
]
|
||||
] call CBA_fnc_serverEvent;
|
||||
},
|
||||
nil,
|
||||
1,
|
||||
true,
|
||||
false,
|
||||
"",
|
||||
"true",
|
||||
6
|
||||
];
|
||||
@@ -0,0 +1,97 @@
|
||||
#include "..\..\script_component.hpp"
|
||||
/*
|
||||
* 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 <OBJECT>
|
||||
* 1: Side <STR>
|
||||
*
|
||||
* 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) do
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
_name = GVAR(baseNames) select GVAR(bluforBaseIndex);
|
||||
_hq setVariable ["baseName", _name, true];
|
||||
INC(GVAR(bluforBaseIndex));
|
||||
};
|
||||
case 2:
|
||||
{
|
||||
_name = GVAR(baseNames) select GVAR(opforBaseIndex);
|
||||
_hq setVariable ["baseName", _name, true];
|
||||
INC(GVAR(opforBaseIndex));
|
||||
};
|
||||
case 3:
|
||||
{
|
||||
_name = GVAR(baseNames) select GVAR(independentBaseIndex);
|
||||
_hq setVariable ["baseName", _name, true];
|
||||
INC(GVAR(independentBaseIndex));
|
||||
};
|
||||
case 4:
|
||||
{
|
||||
_name = GVAR(baseNames) select GVAR(civilianBaseIndex);
|
||||
_hq setVariable ["baseName", _name, true];
|
||||
INC(GVAR(civilianBaseIndex));
|
||||
};
|
||||
};
|
||||
|
||||
private _baseMarker = createMarker [format ["%1 [HQ]", _name], _hq];
|
||||
_baseMarker setMarkerShapeLocal "ICON";
|
||||
_baseMarker setMarkerTypeLocal "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
|
||||
];
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Author: Clarky
|
||||
* Usage:
|
||||
* [this] call CLRK_fnc_initBaseHQInteractions;
|
||||
*
|
||||
* Intended to run locally on each client.
|
||||
*
|
||||
*/
|
||||
|
||||
params ["_hq"];
|
||||
|
||||
_hq addAction [
|
||||
"<t color='#FFD700'>Check Total Materiel</t>",
|
||||
|
||||
{
|
||||
params ["_target", "_caller"];
|
||||
[
|
||||
"CLRK_MaterielCheck",
|
||||
[
|
||||
_target,
|
||||
_caller
|
||||
]
|
||||
] call CBA_fnc_serverEvent;
|
||||
},
|
||||
nil,
|
||||
1,
|
||||
true,
|
||||
false,
|
||||
"",
|
||||
"true",
|
||||
6
|
||||
];
|
||||
|
||||
_hq addAction [
|
||||
"<t color='#55cbda'>Check Fortify Budget</t>",
|
||||
{
|
||||
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 [
|
||||
"<t color='#da55ce'>Add Fortify Budget - $100</t>",
|
||||
{
|
||||
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
|
||||
];
|
||||
@@ -0,0 +1,84 @@
|
||||
#include "..\..\script_component.hpp"
|
||||
/*
|
||||
* 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 <OBJECT>
|
||||
* 1: Depot <OBJECT>
|
||||
* 2: Max Materiel <INT>
|
||||
* 3: Current Materiel <INT>
|
||||
* 4: Generation Rate <INT>
|
||||
*
|
||||
* 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 ["generationRate", _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 "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", "_generationRate"];
|
||||
|
||||
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 =
|
||||
(_generationRate min _freeSpace);
|
||||
|
||||
_depot setVariable [
|
||||
"currentMateriel",
|
||||
_depotCurrent + _amount,
|
||||
true
|
||||
];
|
||||
},
|
||||
30,
|
||||
[_depot, _generationRate]
|
||||
] call CBA_fnc_addPerFrameHandler;
|
||||
};
|
||||
@@ -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 [
|
||||
"<t color='#FFD700'>Check Materiel Status</t>",
|
||||
|
||||
{
|
||||
params ["_target", "_caller"];
|
||||
|
||||
private _current =
|
||||
_target getVariable ["currentMateriel", 0];
|
||||
|
||||
private _max =
|
||||
_target getVariable ["maxMateriel", 300];
|
||||
|
||||
[
|
||||
"CLRK_ShowMessage",
|
||||
[
|
||||
3,
|
||||
1,
|
||||
format
|
||||
[
|
||||
"SUPPLY DEPOT STORAGE<br />Materiel: %1 / %2",
|
||||
_current,
|
||||
_max
|
||||
]
|
||||
],
|
||||
_caller
|
||||
] call CBA_fnc_targetEvent;
|
||||
},
|
||||
nil,
|
||||
1,
|
||||
true,
|
||||
false,
|
||||
"",
|
||||
"true",
|
||||
6
|
||||
];
|
||||
@@ -0,0 +1,84 @@
|
||||
#include "..\..\script_component.hpp"
|
||||
/*
|
||||
* 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 <OBJECT>
|
||||
* 1: Depot <OBJECT>
|
||||
* 2: Max Ore <INT>
|
||||
* 3: Current Ore <INT>
|
||||
* 4: Generation Rate <INT>
|
||||
*
|
||||
* 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 ["generationRate", _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 =
|
||||
(_generationRate min _freeSpace);
|
||||
|
||||
_depot setVariable [
|
||||
"currentOre",
|
||||
_depotCurrent + _amount,
|
||||
true
|
||||
];
|
||||
},
|
||||
30,
|
||||
[_depot, _generationRate]
|
||||
] call CBA_fnc_addPerFrameHandler;
|
||||
};
|
||||
@@ -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 [
|
||||
"<t color='#b96331'>Check Ore Status</t>",
|
||||
|
||||
{
|
||||
params ["_target", "_caller"];
|
||||
|
||||
private _current =
|
||||
_target getVariable ["currentOre", 0];
|
||||
|
||||
private _max =
|
||||
_target getVariable ["maxOre", 300];
|
||||
|
||||
[
|
||||
"CLRK_ShowMessage",
|
||||
[
|
||||
3,
|
||||
1,
|
||||
format
|
||||
[
|
||||
"ORE DEPOT STORAGE<br />Ore: %1 / %2",
|
||||
_current,
|
||||
_max
|
||||
]
|
||||
],
|
||||
_caller
|
||||
] call CBA_fnc_targetEvent;
|
||||
},
|
||||
nil,
|
||||
1,
|
||||
true,
|
||||
false,
|
||||
"",
|
||||
"true",
|
||||
6
|
||||
];
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "..\..\script_component.hpp"
|
||||
/*
|
||||
* 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 <OBJECT>
|
||||
* 1: Max Load <INT>
|
||||
* 2: Current Materiel <INT>
|
||||
* 3: Current Ore <INT>
|
||||
* 4: Transfer Rate <INT>
|
||||
*
|
||||
* 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", _maxLoad, true];
|
||||
_vehicle setVariable ["currentMateriel", _currentMateriel, true];
|
||||
_vehicle setVariable ["currentOre", _currentOre, true];
|
||||
_vehicle setVariable ["transferRate", _transferRate, true];
|
||||
|
||||
[_vehicle] remoteExecCall [
|
||||
"CLF_fnc_initSupplyVehicleInteractions",
|
||||
0,
|
||||
true
|
||||
];
|
||||
|
||||
@@ -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 [
|
||||
"<t color='#FFD700'>Check Storage Status</t>",
|
||||
{
|
||||
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<br />Materiel: %1<br />Ore: %2<br />Capacity: %3 / %4<br />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
|
||||
"<t color='#c4ff22'>Load Materiel</t>", // 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
|
||||
"<t color='#c4ff22'>Unload Materiel</t>", // 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
|
||||
"<t color='#b96331'>Load Ore</t>", // 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
|
||||
"<t color='#b96331'>Unload Ore</t>", // 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;
|
||||
Reference in new issue
Block a user