288 lines
8.7 KiB
Plaintext
288 lines
8.7 KiB
Plaintext
/*
|
||
* 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;
|