Initial upload. Not currently functional as a mod. Includes some slightly refactored source code as well as the original mission this was debuted in zipped up as reference + example of usage.

This commit is contained in:
Clarky committed 2026-08-08 17:42:15 +10:00
commit 75b737230e
32 files changed
+2049

No files matched your search

@@ -0,0 +1,11 @@
/*
*
*
*
*
*/
// params ["_hq", "_vehicle", "_cost", "_buildTime", ];
// missionNamespace setVariable ["buildActive",false];
@@ -0,0 +1,19 @@
/*
*
*
*
*
*/
params ["_hq", "_vehicle", "_cost", "_player"];
deleteVehicle _vehicle;
[
"CLF_MaterielAdd",
[
_hq,
_cost,
_player
]
] call CBA_fnc_serverEvent;
+309
View File
@@ -0,0 +1,309 @@
/*
* Author: Clarky
* Usage:
* [_class, _cost, _buildTime, _specialisation] call CLF_fnc_factoryBuild;
*
* Intended to be called via the factoryConfirmSelection function
*
* Purpose:
* Begins the process of building a vehicle with player selection on the VehicleFactory dialog
*
*/
params ["_player", "_vehicleClass", "_cost", "_buildTime", "_specialisation", "_specialisationData"];
// Stow weapon at start of process
player action ["SWITCHWEAPON", player, player, -1];
private _rotation = getDir player;
missionNamespace setVariable ["previewRotation", _rotation];
private _confirm = false;
private _cancel = false;
private _hq = uiNamespace getVariable ["localHQ", ""];
if (_hq isEqualTo "") exitWith { hint "No local HQ"; };
// Spawn the vehicle locally - only player who clicked the dialog will see it at this stage
private _vehiclePreview = createVehicleLocal [
_vehicleClass,
[0, 0, 0],
[],
0,
"NONE"
];
_vehiclePreview disableCollisionWith _player;
//waitUntil { _vehiclePreview == _vehiclePreview };
// Disable all damage and simulation until build is confirmed
_vehiclePreview enableSimulation false;
_vehiclePreview enableSimulationGlobal false;
_vehiclePreview allowDamage false;
//_vehiclePreview setPhysicsCollisionFlag false;
removeAllActions _vehiclePreview;
_vehiclePreview setVehicleLock "LOCKED";
_vehiclePreview lockInventory true;
// Apply a slight tint/texture which will be used to show the player if it can be placed or not
_vehiclePreview setObjectTextureGlobal [0, "#(argb,8,8,3)color(0,1,0,0.35,ca)"];
// Load the 'display' handling input events
private _display = findDisplay 46;
private _mouseScroll = _display displayAddEventHandler [
// Handle mouse scroll wheel axis input
"MouseZChanged",
{
params ["_display", "_scroll"];
private _dir = missionNamespace getVariable ["previewRotation", 0];
_dir = _dir + (_scroll * 5);
missionNamespace setVariable ["previewRotation", _dir];
}
];
private _mouseInput = _display displayAddEventHandler [
// Handle LMB/RMB click
"MouseButtonDown",
{
params ["", "_button"];
switch (_button) do
{
case 0: // LMB
{
missionNamespace setVariable [
"confirmPlacement",
true
];
};
case 1: // RMB
{
missionNamespace setVariable [
"cancelPlacement",
true
];
};
};
false;
}
];
private _keyboardInput = _display displayAddEventHandler [
// Handle keyboard clicks as extra verification tools
"KeyDown",
{
params ["", "_key"];
switch (_key) do
{
case 28: // Enter
{
missionNamespace setVariable [
"confirmPlacement",
true
];
};
case 1: // Escape
{
missionNamespace setVariable [
"cancelPlacement",
true
];
};
};
false;
}
];
// Load up variables for closing out the build preview one way or the other
missionNamespace setVariable ["confirmPlacement",false];
missionNamespace setVariable ["cancelPlacement",false];
_previewUI = addMissionEventHandler [
"Draw3D",
{
//hint "sucessfully spawned preview";
if (missionNamespace getVariable ["confirmPlacement", false]) exitWith {};
if (missionNamespace getVariable ["cancelPlacement", false]) exitWith { hintSilent ""; };
hintSilent "VEHICLE CONSTRUCTION\n\nLMB: Confirm\nRMB: Cancel\nScrollwheel: Rotate";
/*
drawIcon3D [
"",
[1, 1, 1, 1],
positionCameraToWorld [0, 3, 0],
0,
0,
0,
"LMB: Place | RMB: Cancel | Scroll: Rotate",
2,
0.04,
"PuristaMedium"
];*/
}
];
// Spawn code that runs until the player
while { (player call ace_medical_fnc_isInStableCondition) && !_confirm && !_cancel } do
{
private _rotation = missionNamespace getVariable ["previewRotation", 0];
// Raycast out from player perspective to find location to place the preview vehicle
private _maxDistance = 15;
private _start = eyePos player;
private _direction = getCameraViewDirection player;
private _end = _start vectorAdd (
_direction vectorMultiply _maxDistance
);
private _hits = lineIntersectsSurfaces [
_start,
_end,
player,
_vehiclePreview,
true,
1,
"GEOM",
"NONE"
];
/////////////////////////////////////////////////////////////////////
// Validation on placement
/////////////////////////////////////////////////////////////////////
private _valid = false;
// Only proceed with updates to vehicle pos if we get a result back from the raycast
if (_hits isNotEqualTo []) then
{
private _groundPos = (_hits select 0) select 0;
//hint format ["Raycast Hit: %1", str _groundPos];
_vehiclePreview setDir _rotation;
_vehiclePreview setPosASL _groundPos;
_vehiclePreview setVectorUp surfaceNormal position _vehiclePreview;
private _nearbyObjects = _vehiclePreview nearObjects 7;
_nearbyObjects = _nearbyObjects - [_vehiclePreview];
{
if (
!(_x isKindOf "Man") &&
!(_x isKindOf "Items_base_F") &&
!(_x isKindOf "LandVehicle") &&
!(_x isKindOf "Air") &&
!(_x isKindOf "Ship") &&
!(_x isKindOf "Building") &&
!(_x isKindOf "StaticWeapon")
) then {
_nearbyObjects = _nearbyObjects - [_x];
}
} forEach _nearbyObjects;
//hint str _nearbyObjects;
private _collision = false;
// Bit quick and dirty but this should get the job done for now - checking for nearby objects near the preview vehicle
{
if (_vehiclePreview distance _x < 7) exitWith {
_collision = true;
}
} forEach _nearbyObjects;
//hint format ["%1", _nearbyObjects];
// If the raycast returns a point on terrain, and we reach this point and confirm there is no nearby objects going to potentially cause issues, mark _valid as true
if (!_collision) then {
_valid = true;
};
};
// else
// {
// private _terrainInferrence = screenToWorld [0.5, 0.5];
// _vehiclePreview setDir _rotation;
// _vehiclePreview setPosASL _terrainInferrence;
// }
/////////////////////////////////////////////////////////////////////
// Update texture according to current validity
/////////////////////////////////////////////////////////////////////
if (_valid) then
{
_vehiclePreview setObjectTextureGlobal [
0,
"#(argb,8,8,3)color(0,1,0,0.35,ca)"
];
}
else
{
_vehiclePreview setObjectTextureGlobal [
0,
"#(argb,8,8,3)color(1,0,0,0.35,ca)"
];
};
/////////////////////////////////////////////////////////////////////
// Check for updated input variables
/////////////////////////////////////////////////////////////////////
if (missionNamespace getVariable ["confirmPlacement", false]) then
{
if (_valid) then
{
_confirm = true;
} else {
// Reset confirm variable back to false, as otherwise this code will fire off at next available 'valid' opportunity
missionNamespace setVariable [
"confirmPlacement",
false
];
}
};
if (missionNamespace getVariable ["cancelPlacement", false]) then
{
_cancel = true;
};
uiSleep 0.01;
};
// Remove display eventhandlers to stop capturing inputs needlessly
_display displayRemoveEventHandler ["onMouseButtonDown", _mouseInput];
_display displayRemoveEventHandler ["MouseZChanged", _mouseScroll];
_display displayRemoveEventHandler ["KeyDown", _keyboardInput];
removeMissionEventHandler ["Draw3D", _previewUI];
private _pos = getPosATL _vehiclePreview;
private _up = surfaceNormal position _vehiclePreview;
// Cleanup _vehiclePreview
deleteVehicle _vehiclePreview;
// Proceed to call the build confirm function if valid from checks above
if (_confirm) then
{
[
"CLF_ConfirmFactoryBuildServer",
[
_hq,
_player,
_vehicleClass,
_pos,
missionNamespace getVariable ["previewRotation", 0],
_up,
_cost,
_buildTime,
_specialisation,
_specialisationData
]
] call CBA_fnc_serverEvent;
};
@@ -0,0 +1,111 @@
/*
* Author: Clarky
* Usage:
* [_hq, _vehicle, _cost, _buildTime] call CLF_fnc_factoryBuildConfirmClient;
*
*
*
* Purpose:
*
*
*/
params ["_hq", "_vehicle", "_cost", "_buildTime", "_player"];
missionNamespace setVariable ["buildActive", true];
missionNamespace setVariable ["cancelBuild", false];
_player playMoveNow "Acts_carFixingWheel";
private _endTime = time + _buildTime;
[_hq, _vehicle, _cost, _buildTime, _endTime, _player] spawn {
params ["_hq", "_vehicle", "_cost", "_buildTime", "_endTime", "_player"];
// Load the 'display' handling input events
private _display = findDisplay 46;
// Add an event handler to be able to cancel the build
private _keyboardCancel = _display displayAddEventHandler [
// Handle keyboard clicks as extra verification tools
"KeyDown",
{
params ["", "_key"];
switch (_key) do
{
case 1: // Escape
{
missionNamespace setVariable [
"cancelBuild",
true
];
};
};
false;
}
];
private _mouseCancel = _display displayAddEventHandler [
// Handle LMB/RMB click
"MouseButtonDown",
{
params ["", "_button"];
switch (_button) do
{
case 1: // RMB
{
missionNamespace setVariable [
"cancelBuild",
true
];
};
};
false;
}
];
waitUntil { animationState player == "Acts_carFixingWheel" };
while { missionNamespace getVariable ["buildActive", false]; } do {
private _remainingTIme = ceil (_endTime - time);
hintSilent format ["Remaining Build Time: %1\n\nRMB or ESC to cancel", _remainingTime max 0];
if (animationState player != "Acts_carFixingWheel" && (missionNamespace getVariable ["buildActive", false]) && (_vehicle getVariable "buildComplete")) then {
player playMoveNow "Acts_carFixingWheel";
};
if ((missionNamespace getVariable "cancelBuild") || !(alive _vehicle)) then {
[
"CLF_CancelFactoryBuildServer",
[
_hq,
_vehicle,
_cost,
_player
]
] call CBA_fnc_serverEvent;
missionNamespace setVariable ["buildActive", false];
};
if (_vehicle getVariable "buildComplete") then {
missionNamespace setVariable ["buildActive", false];
};
sleep 0.2;
if (!(missionNamespace getVariable ["buildActive", false])) then {
hintSilent "";
if (animationState player == "Acts_carFixingWheel") then {
player switchMove "";
};
_display displayRemoveEventHandler ["MouseButtonDown", _mouseCancel];
_display displayRemoveEventHandler ["KeyDown", _keyboardCancel];
}
};
};
@@ -0,0 +1,95 @@
/*
* Author: Clarky
* Usage:
* [] call CLF_fnc_factoryBuildConfirm;
*
* Intended to be called via the factoryBuild function once player confirms BIS_fnc_locations
*
* Purpose:
* Concludes the process of building a vehicle with player selection on the VehicleFactory dialog
*
*/
params ["_hq", "_player", "_vehicleClass", "_vehiclePreviewLocation", "_rotation", "_vectorUp", "_cost", "_buildTime", "_specialisation", "_specialisationData"];
// Check current materiel available at this base
private _currentMateriel = [_hq, _player] call CLF_fnc_materielCheck;
if (_currentMateriel > _cost) then {
// Function runs and consumes the required supplies, returns true if successful, OR returns false after giving a 'not enough supplies' message to the player (theoretically)
//[_hq, _cost, _player] remoteExec ["CLF_fnc_materielConsume", 2];
[
"CLF_MaterielConsume",
[
_hq,
_cost,
_player
]
] call CBA_fnc_serverEvent;
private _vehicle = createVehicle [_vehicleClass, _vehiclePreviewLocation, [], 0, "CAN_COLLIDE"];
waitUntil { _vehicle == _vehicle };
_vehicle allowDamage false;
_vehicle enableSimulationGlobal false;
_vehicle setDir _rotation;
_vehicle setVectorUp _vectorUp;
_vehicle setVehicleLock "LOCKED";
_vehicle lockInventory true;
_vehicle setVariable ["buildComplete", false, true];
[
"CLF_ConfirmFactoryVehicleClient",
[
_hq,
_vehicle,
_cost,
_buildTime,
_player
],
_player
] call CBA_fnc_targetEvent;
[
_vehicle,
_buildTime,
_specialisation,
_specialisationData
] spawn {
params ["_vehicle", "_buildTime", "_specialisation", "_specialisationData"];
sleep _buildTime;
if (isNull _vehicle) exitWith {};
_vehicle allowDamage true;
_vehicle enableSimulationGlobal true;
_vehicle setVehicleLock "UNLOCKED";
_vehicle lockInventory false;
_vehicle setVariable ["buildComplete", true, true];
switch (_specialisation) do {
case "SUPPLY": {
[
_vehicle,
_specialisationData select 0,
0,
_specialisationData select 1
] call CLF_fnc_initSupplyVehicle;
}
};
};
} else {
hintSilent "";
[
"CLF_ShowMessage",
[
1,
0,
"Not enough materiel."
],
_player
] call CBA_fnc_targetEvent;
}
@@ -0,0 +1,52 @@
/*
Author: Clarky
Usage:
[_class, _cost, _buildTime, _specialisation] call CLF_fnc_factoryConfirmSelection;
Intended to be called locally using the CONFIRM button in the VehicleFactory dialog
Purpose:
Confirms whether or not the build of a vehicle can commence
*/
//params ["_class", "_cost", "_buildTime", "_specialisation", "_specialisationData"];
// Fetch the display and listbox to find the selected row so we can reference its data
private _display = findDisplay 9999;
private _listBox = _display displayCtrl 1500;
private _row = lnbCurSelRow _listBox;
if (_row < 0) exitWith {hint "No vehicle was selected.";};
if (isNull player) exitWith {hint "ERR: No player found"};
if !(([player] call ace_common_fnc_isEngineer) || (missionNamespace getVariable "allCanUseLogistics")) exitWith {
[
"CLF_ShowMessage",
[
1,
1,
"No engineer privileges found."
],
player
] call CBA_fnc_targetEvent;
};
// Fetch vehicle data from the selected row and compile it so we can access it and pass it through to the build function
private _vehicleData =
call compile (_listBox lnbData [_row,0]);
_vehicleData params [
"_class",
"_cost",
"_buildTime",
"_specialisation",
"_specialisationData"
];
[player, _class, _cost, _buildTime, _specialisation, _specialisationData] spawn CLF_fnc_factoryBuild;
//hint str (_listBox lnbData [_row,0]);
//private _camera = "camera" camCreate getPosATL player;
//_camera cameraEffect ["internal", "back"];
//showCinemaBorder false;
+12
View File
@@ -0,0 +1,12 @@
/*
Author: Clarky
Usage:
[_caller] call CLF_fnc_canUseLogisticsSystem;
Intended to be run to return a true/false to check if a player can interact with the logistics system
*/
params ["_caller"];
private _isEngineer = (_caller getVariable ["ACE_isEngineer", 0]) > 0;
_isEngineer;
Whitespace-only changes.
+34
View File
@@ -0,0 +1,34 @@
/*
Author: Clarky
Usage:
["hq", "side"] call CLF_fnc_initBase;
Intended to run on the server to initialise a new base object - Typically when a new HQ is placed in the world
// DEPRECATED //
*/
/*
params ["_hq", "_side"];
waitUntil { !isNull _hq; };
private _baseID = format [
"BASE_%1",
diag_tickTime
];
_bases = missionNamespace getVariable "LogisticsBases";
_bases set [
_baseID,
createHashMapFromArray [
["id", _baseID],
["hq", _hq],
["buildings", []],
["depots", []],
["side", _side]
]
];
*/
+67
View File
@@ -0,0 +1,67 @@
/*
Author: Clarky
Usage:
[this, side] call CLF_fnc_initBaseHQ;
Intended to run on the server, which calls a CBA event handler that runs a client-level script for adding relevant interactions
Purpose:
Initialises a logistics base HQ. Adds the new base to the global base hashmap. Runs a child function to intialise clientside actions.
*/
params ["_hq", "_side"];
waitUntil { !isNull _hq; };
_hq setVariable ["isBaseHQ", true, true];
// _hq setVariable [];
// Set BaseID
private _baseID = format [
"BASE_%1",
diag_tickTime
];
_hq setVariable [
"baseID",
_baseID,
true
];
_hq setVariable [
"baseDetails",
createHashMapFromArray [
["id", _baseID],
["hq", _hq],
["buildings", []],
["depots", []],
["side", _side]
]
];
/*
// Fetch global mission Base Hashmap
private _bases = missionNamespace getVariable "LogisticsBases";
// Add new Base to global hashmap
_bases set [
_baseID,
createHashMapFromArray [
["id", _baseID],
["hq", _hq],
["buildings", []],
["depots", []],
["side", _side]
]
];
missionNamespace setVariable ["LogisticsBases", _bases, true];
*/
// Initialise base HQ interactions for all clients
[_hq] remoteExecCall [
"CLF_fnc_initBaseHQInteractions",
0,
true
];
+91
View File
@@ -0,0 +1,91 @@
/*
* Author: Clarky
* Usage:
* [this] call CLF_fnc_initBaseHQInteractions;
*  
* Intended to run locally on each client.
*
*/
params ["_hq"];
_hq addAction [
"<t color='#55cbda'>Check Fortify Budget</t>",
{
params ["_target", "_caller"];
hint format ["Current Fortify Budget: %1", [side _caller] call ace_fortify_fnc_getBudget];
[] spawn {
sleep 3;
hintSilent "";
}
},
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"];
// Check current materiel available at this base
private _currentMateriel = [_target, _caller] call CLF_fnc_materielCheck;
if (_currentMateriel > 100) then {
[
"CLF_MaterielConsume",
[
_target,
100,
_caller
]
] call CBA_fnc_serverEvent;
[
[
"CLF_FortifyBudgetAdd",
side _caller,
100
]
] call CBA_fnc_serverEvent;
} else {
[
"CLF_ShowMessage",
[
1,
0,
"Not enough materiel."
],
_player
] call CBA_fnc_targetEvent;
};
},
nil,
1,
true,
false,
"",
"true", // Figure out a way to lock this to player side checks (macros?)
6
];
/*
if (_depots isEqualTo []) exitWith {
[
"CLF_ShowMessage",
[
1,
0,
"No connected supply depots found."
],
_player
] call CBA_fnc_targetEvent;
// Return false;
false;
};
*/
+15
View File
@@ -0,0 +1,15 @@
/*
Author: Clarky
Usage:
call CLF_fnc_initSLogisticsSystem;
Intended to run on the server, on mission start, to create basic variables and logistics system handling services
*/
/*
// If LogisticsBases variable has not already been initialised, initalise it here
if ((missionNamespace getVariable ["LogisticsBases", ""]) isNotEqualTo "") then {
missionNamespace setVariable ["LogisticsBases", createHashMap, true];
};
*/
+65
View File
@@ -0,0 +1,65 @@
/*
Author: Clarky
Usage:
[this, 1000, 0, false, 0] call CLF_fnc_initSupplyDepot;
Intended to run on the server, which calls a CBA event handler that runs a client-level script for adding relevant interactions
*/
params [["_hq", "", ["", objNull]], "_depot", "_maxMateriel", "_currentMateriel", "_isGenerator", "_materielRate"];
_depot setVariable ["isSupplyDepot", true, true];
_depot setVariable ["maxMateriel", _maxMateriel, true];
_depot setVariable ["currentMateriel", _currentMateriel, true];
_depot setVariable ["isGenerator", _isGenerator, true];
_depot setVariable ["materielRate", _materielRate, true];
if (_hq isNotEqualTo "") then {
_depot setVariable ["hq", _hq, true];
private _baseDetails = _hq getVariable "baseDetails";
private _depots = _baseDetails get "depots";
_depots pushBack _depot;
//_hq setVariable ["baseDetails", _baseDetails];
};
[_depot] remoteExecCall [
"CLF_fnc_initSupplyDepotInteractions",
0,
true
];
if (_depot getVariable "isGenerator") then {
[_depot, _materielRate] spawn {
params ["_depot", "_materielRate"];
while {alive _depot} do {
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
];
sleep 30;
};
};
};
/*
[
"CLF_SupplyDepotCreated",
[_depot]
] call CBA_fnc_globalEventJIP;
*/
@@ -0,0 +1,58 @@
/*
Author: Clarky
Usage:
[this] call CLF_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];
[
"CLF_ShowMessage",
[
3,
1,
format
[
"SUPPLY DEPOT STORAGE<br />Materiel: %1 / %2",
_current,
_max
]
],
_caller
] call CBA_fnc_targetEvent;
},
nil,
1,
true,
false,
"",
"true",
6
];
+28
View File
@@ -0,0 +1,28 @@
/*
Author: Clarky
Usage:
[this, 300, 0, 50] call CLF_fnc_initSupplyVehicle;
Intended to run on the server, which calls a CBA event handler that runs a client-level script for adding relevant interactions
*/
params ["_vehicle", "_maxMateriel", "_currentMateriel", "_transferRate"];
_vehicle setVariable ["isSupplyVehicle", true, true];
_vehicle setVariable ["maxMateriel", _maxMateriel, true];
_vehicle setVariable ["currentMateriel", _currentMateriel, true];
_vehicle setVariable ["transferRate", _transferRate, true];
[_vehicle] remoteExecCall [
"CLF_fnc_initSupplyVehicleInteractions",
0,
true
];
/*
[
"CLF_SupplyVehicleCreated",
[_vehicle]
] call CBA_fnc_globalEventJIP;
*/
@@ -0,0 +1,169 @@
/*
* Author: Clarky
* Usage:
* [this] call CLF_fnc_initSupplyVehicleInteractions;
*  
* Intended to run locally on each client.
*
*/
params ["_vehicle"];
if (isNull _vehicle) exitWith {hint "Vehicle ain't exist";};
if !(_vehicle getVariable ["isSupplyVehicle", false]) exitWith {hint "Vehicle ain't supply vehicle";};
// 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 Materiel Status</t>",
{
params ["_target", "_caller"];
private _current =
_target getVariable ["currentMateriel", 0];
private _max =
_target getVariable ["maxMateriel", 300];
private _rate =
_target getVariable ["transferRate", 50];
[
"CLF_ShowMessage",
[
3,
1,
format
[
"SUPPLY VEHICLE STORAGE<br />Materiel: %1 / %2",
_current,
_max]
],
_caller
] call CBA_fnc_targetEvent;
},
nil,
1,
true,
false,
"",
"true",
6
];
//////////////////////////////////////////////////////////////////
// INIT LOAD ACTION
//////////////////////////////////////////////////////////////////
[
_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 {
[
"CLF_ShowMessage",
[
1,
0,
"No supply depot nearby."
],
_caller
] call CBA_fnc_targetEvent;
};
[
"CLF_VehicleLoaded",
[_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 {
[
"CLF_ShowMessage",
[
1,
0,
"No supply depot nearby."
],
_caller
] call CBA_fnc_targetEvent;
};
[
"CLF_VehicleUnloaded",
[_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;
+28
View File
@@ -0,0 +1,28 @@
/*
* Author: Clarky
* Usage:
* [this, 1000, 0, false, 0] call CLF_fnc_initVehicleFactory;
*
* Intended to run on the server, which calls a CBA event handler that runs a client-level script for adding relevant interactions
*
*/
params [["_hq", "", ["", objNull]], "_factory"];
waitUntil { !isNull _hq; };
_factory setVariable ["isVehicleFactory", true, true];
if (_hq isNotEqualTo "") then {
_factory setVariable ["hq", _hq, true];
private _baseDetails = _hq getVariable "baseDetails";
private _buildings = _baseDetails get "buildings";
_buildings pushBack _factory;
//_hq setVariable ["baseDetails", _baseDetails];
};
[_factory] remoteExecCall [
"CLF_fnc_initVehicleFactoryInteractions",
0,
true
];
@@ -0,0 +1,33 @@
/*
* Author: Clarky
* Usage:
* [hq, this] call CLF_fnc_initVehicleFactoryInteractions;
*  
* Intended to run locally on each client.
*
*/
params ["_factory"];
_factory addAction [
"<t color='#71BDA6'>Open Vehicle Factory</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
];
+47
View File
@@ -0,0 +1,47 @@
/*
* Author: Clarky
*
*
*
*
*/
params ["_hq", "_amount", "_player"];
// Grab all HQ/Base/Depots
private _baseDetails = _hq getVariable "baseDetails";
private _depots = _baseDetails get "depots";
if (_depots isEqualTo []) exitWith {
[
"CLF_ShowMessage",
[
1,
0,
"No connected supply depots found."
],
_player
] call CBA_fnc_targetEvent;
// Return false;
false;
};
// Loop through and add materiel to the depots
// Might work on a better way to do this eventually (i.e prioritising specific depots depending on reasons)
{
// 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 = _amount min _freeSpace;
_x setVariable ["currentMateriel", _depotMateriel + _addAmount, true];
// Update remaining amount to reduce
_amount = _amount - _addAmount;
} forEach _depots;
// Return true
true;
+29
View File
@@ -0,0 +1,29 @@
// temporary function - likely to be replaced in proper mod development context
params ["_hq", "_player"];
// Grab all Depots at the HQ
private _baseDetails = _hq getVariable "baseDetails";
private _depots = _baseDetails get "depots";
if (_depots isEqualTo []) exitWith {
[
"CLF_ShowMessage",
[
1,
0,
"No connected supply depots found."
],
_player
] call CBA_fnc_targetEvent;
// Return false;
false;
};
// Check current materiel available at this base
private _currentMateriel = 0;
{
_currentMateriel = _currentMateriel + (_x getVariable ["currentMateriel", 0]);
} forEach _depots;
// Return result
_currentMateriel;
+66
View File
@@ -0,0 +1,66 @@
/*
* Author: Clarky
*
*
*
*
*/
params ["_hq", "_amount", "_player"];
// Grab all Depots at the HQ
private _baseDetails = _hq getVariable "baseDetails";
private _depots = _baseDetails get "depots";
if (_depots isEqualTo []) exitWith {
[
"CLF_ShowMessage",
[
1,
0,
"No connected supply depots found."
],
_player
] call CBA_fnc_targetEvent;
// Return false;
false;
};
// Check current materiel available at this base
private _currentMateriel = 0;
{
_currentMateriel = _currentMateriel + (_x getVariable ["currentMateriel", 0]);
} forEach _depots;
if (_currentMateriel < _amount) exitWith {
[
"CLF_ShowMessage",
[
1,
0,
"Not enough materiel."
],
_player
] call CBA_fnc_targetEvent;
// Return false;
false;
};
// Loop through and subtract materiel from the depots
// Might work on a better way to do this eventually (i.e prioritising specific depots depending on reasons)
// By this point we have 100% checked and confirmed there is enough materiel to proceed with the requested supply consumption, so this SHOULD BE SAFE AND NOT ALLOW OVERCONSUMPTION :)
{
// 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 _reduceAmount = _depotMateriel min _amount;
_x setVariable ["currentMateriel", _depotMateriel - _reduceAmount, true];
// Update remaining amount to reduce
_amount = _amount - _reduceAmount;
} forEach _depots;
// Return true
true;
+85
View File
@@ -0,0 +1,85 @@
/*
Author: Clarky
Usage:
[
"CLF_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 _vehicleCurrent =
_vehicle getVariable ["currentMateriel", 0];
private _vehicleMax =
_vehicle getVariable ["maxMateriel", 300];
private _transferRate =
_vehicle getVariable ["transferRate", 50];
private _depotCurrent =
_depot getVariable ["currentMateriel", 0];
private _freeSpace =
_vehicleMax - _vehicleCurrent;
if (_freeSpace <= 0) exitWith {
[
"CLF_ShowMessage",
[1, 0, "Vehicle is already full."],
_player
] call CBA_fnc_targetEvent;
};
if (_depotCurrent <= 0) exitWith {
[
"CLF_ShowMessage",
[2, 0, "Depot has no materiel available."],
_player
] call CBA_fnc_targetEvent;
};
private _amount =
(_transferRate min _freeSpace)
min _depotCurrent;
_vehicle setVariable [
"currentMateriel",
_vehicleCurrent + _amount,
true
];
_depot setVariable [
"currentMateriel",
_depotCurrent - _amount,
true
];
[
"CLF_ShowMessage",
[
0,
0,
format [
"Loaded %1 materiel. Vehicle now contains %2/%3.",
_amount,
_vehicle getVariable ["currentMateriel",0],
_vehicleMax
]
],
_player
] call CBA_fnc_targetEvent;
+93
View File
@@ -0,0 +1,93 @@
/*
Author: Clarky
Usage:
[
"CLF_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 {
[
"CLF_ShowMessage",
[
1,
0,
"Depot is already full."
],
_player
] call CBA_fnc_targetEvent;
};
if (_vehicleCurrent <= 0) exitWith {
[
"CLF_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
];
[
"CLF_ShowMessage",
[
0,
0,
format [
"Unloaded %1 materiel. Depot now contains %2/%3.",
_amount,
_depot getVariable ["currentMateriel",0],
_depotMax
]
],
_player
] call CBA_fnc_targetEvent;