ACE3/addons/refuel/functions/fnc_makeJerryCan.sqf
Dystopian 7c65f8503d
Refuel - Add enable setting (#7613)
* Add enable setting

* Exclude man class init

* Fix multiplayer terrain pump fuel sync

* Add terrain pumps positions

* Add vanilla fuel cargo restoring before destroying

* Add Livonia positions by bux

* Fix terrain pumps destruction

* Improve settings init

* Fix double settings category

* Check enabled var in public functions

* Fix fnc_makeSource

* Handle recent CUP Terrains changes

* Update includes

* Fix issues introduced in #9133

* Change warning

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Optimisations and cleanup

- Use hashmaps wherever possible
- Reduced pump search radius by ~30%
- Sorted pumps alphabetically and sorted positions by "smallest" first, for consistency

* Add init debug trace

* compileScript in dev

* yoda conditions & DFUNC macro

* Wait until CBA settings are ready

* Update Chernarus 2020 and add more maps configs

* Remove vanilla fuel cargo restoring before destroying

---------

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
2024-05-23 21:47:19 +02:00

131 lines
3.8 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: GitHawk
* Makes an object into a jerry can.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Fuel amount (in liters) <NUMBER>
*
* Return Value:
* None
*
* Example:
* [can] call ace_refuel_fnc_makeJerryCan
*
* Public: Yes
*/
// Only run this after the settings are initialized
if !(EGVAR(common,settingsInitFinished)) exitWith {
EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(makeJerryCan), _this];
};
if (!GVAR(enabled)) exitWith {};
params [["_target", objNull, [objNull]], ["_fuelAmount", 20, [0]]];
if (isNull _target ||
{_target isKindOf "AllVehicles"} ||
{_target getVariable [QGVAR(jerryCan), false]}) exitWith {};
_target setVariable [QGVAR(jerryCan), true];
_target setVariable [QGVAR(source), _target];
_target setVariable [QGVAR(capacity), _fuelAmount];
if (isServer) then {
[_target, _fuelAmount] call FUNC(setFuel); // has global effects
[QGVAR(jerryCanInitalized), [_target]] call CBA_fnc_globalevent;
};
// Main Action
private _action = [QGVAR(Refuel),
localize LSTRING(Refuel),
QPATHTOF(ui\icon_refuel_interact.paa),
{},
{true},
{},
[],
[0, 0, 0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction);
[_target, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToObject);
// Add pickup
_action = [QGVAR(PickUpNozzle),
localize LSTRING(TakeFuelCanister),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(takeNozzle)},
{[_player, _target] call FUNC(canTakeNozzle)},
{},
[],
[0, 0, 0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction);
[_target, 0, ["ACE_MainActions", QGVAR(Refuel)], _action] call EFUNC(interact_menu,addActionToObject);
// Add turnOn
_action = [QGVAR(TurnOn),
localize LSTRING(TurnOn),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(turnOn)},
{[_player, _target] call FUNC(canTurnOn)},
{},
[],
[0, 0, 0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction);
[_target, 0, ["ACE_MainActions", QGVAR(Refuel)], _action] call EFUNC(interact_menu,addActionToObject);
// Add turnOn container
_action = [QGVAR(TurnOn_Container),
localize LSTRING(TurnOn_Container),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target, true] call FUNC(turnOn)},
{[_player, _target, true] call FUNC(canTurnOn)},
{},
[],
[0, 0, 0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction);
[_target, 0, ["ACE_MainActions", QGVAR(Refuel)], _action] call EFUNC(interact_menu,addActionToObject);
// Add check fuel
_action = [QGVAR(CheckFuel),
localize LSTRING(CheckFuel),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(checkFuel)},
{[_player, _target] call FUNC(canCheckFuel)},
{},
[],
[0,0,0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction);
[_target, 0, ["ACE_MainActions", QGVAR(Refuel)], _action] call EFUNC(interact_menu,addActionToObject);
// Add turnOff
_action = [QGVAR(TurnOff),
localize LSTRING(TurnOff),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(turnOff)},
{[_player, _target] call FUNC(canTurnOff)},
{},
[],
[0, 0, 0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction);
[_target, 0, ["ACE_MainActions", QGVAR(Refuel)], _action] call EFUNC(interact_menu,addActionToObject);
// Add disconnect
_action = [QGVAR(Disconnect),
localize LSTRING(DisconnectFuelCanister),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(disconnect)},
{[_player, _target] call FUNC(canDisconnect)},
{},
[],
[0, 0, 0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction);
[_target, 0, ["ACE_MainActions", QGVAR(Refuel)], _action] call EFUNC(interact_menu,addActionToObject);