2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2017-09-10 19:43:03 +00:00
|
|
|
/*
|
|
|
|
* Author: Dystopian
|
|
|
|
* Makes an object into a refuel source.
|
|
|
|
* Run on server only.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Fuel Source <OBJECT>
|
|
|
|
* 1: Fuel amount (in liters) <NUMBER> (default: 0)
|
|
|
|
* 2: Hooks positions <ARRAY> (default: [[0,0,0]])
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [cursorObject, 100] call ace_refuel_fnc_makeSource
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!isServer) exitWith {};
|
|
|
|
|
|
|
|
// Only run this after the settings are initialized
|
|
|
|
if !(EGVAR(common,settingsInitFinished)) exitWith {
|
|
|
|
EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(makeSource), _this];
|
|
|
|
};
|
|
|
|
|
2024-05-23 19:47:19 +00:00
|
|
|
if (!GVAR(enabled)) exitWith {};
|
|
|
|
|
2017-09-10 19:43:03 +00:00
|
|
|
params [
|
|
|
|
["_source", objNull, [objNull]],
|
|
|
|
["_fuelCargo", 0, [0]],
|
|
|
|
["_hooks", nil, [[]]]
|
|
|
|
];
|
|
|
|
|
2024-05-23 19:47:19 +00:00
|
|
|
private _fuelCargoConfig = _source call FUNC(getFuelCargo);
|
|
|
|
|
|
|
|
TRACE_4("makeSource",_source,_fuelCargo,_hooks,_fuelCargoConfig);
|
2017-09-10 19:43:03 +00:00
|
|
|
|
|
|
|
if (
|
|
|
|
isNull _source
|
|
|
|
|| {_fuelCargo < 0 && {!(_fuelCargo in [REFUEL_INFINITE_FUEL, REFUEL_DISABLED_FUEL])}}
|
2024-05-23 19:47:19 +00:00
|
|
|
|| {_fuelCargo == REFUEL_DISABLED_FUEL && {_fuelCargoConfig == REFUEL_DISABLED_FUEL}}
|
2017-09-10 19:43:03 +00:00
|
|
|
) exitWith {};
|
|
|
|
|
2023-02-17 02:06:11 +00:00
|
|
|
private _capacity = if (_fuelCargo < 0) then {_fuelCargo} else {_fuelCargoConfig max _fuelCargo};
|
|
|
|
|
|
|
|
_source setVariable [QGVAR(capacity), _capacity, true];
|
2017-09-10 19:43:03 +00:00
|
|
|
|
|
|
|
if (_fuelCargo == REFUEL_DISABLED_FUEL) exitWith {};
|
|
|
|
|
2023-02-17 02:06:11 +00:00
|
|
|
[_source, _fuelCargo] call FUNC(setFuel);
|
|
|
|
|
2017-09-10 19:43:03 +00:00
|
|
|
if (
|
|
|
|
!isNil "_hooks"
|
|
|
|
&& {_hooks isEqualTypeAll []}
|
|
|
|
&& {0 == {!(_x isEqualTypeParams [0,0,0]) || {3 < count _x}} count _hooks}
|
|
|
|
) then {
|
|
|
|
_source setVariable [QGVAR(hooks), _hooks, true];
|
|
|
|
};
|
|
|
|
|
2023-02-18 02:49:57 +00:00
|
|
|
// only add if menu doesn't already exist
|
2024-05-23 19:47:19 +00:00
|
|
|
if (_fuelCargoConfig != REFUEL_DISABLED_FUEL || {!isNil {_source getVariable QGVAR(initSource_jipID)}}) exitWith {};
|
|
|
|
|
|
|
|
private _jipID = [QGVAR(initSource), [_source]] call CBA_fnc_globalEventJIP;
|
|
|
|
[_jipID, _source] call CBA_fnc_removeGlobalEventJIP;
|
|
|
|
_source setVariable [QGVAR(initSource_jipID), _jipID];
|
2017-09-10 19:43:03 +00:00
|
|
|
|
2023-02-18 02:49:57 +00:00
|
|
|
[QGVAR(sourceInitialized), [_source]] call CBA_fnc_globalEvent;
|