ACE3/addons/refuel/functions/fnc_makeJerryCan.sqf

131 lines
3.8 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
2015-08-21 20:43:45 +00:00
/*
* 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
2015-08-21 20:43:45 +00:00
*/
// 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]]];
2015-08-21 20:43:45 +00:00
if (isNull _target ||
2015-12-21 16:54:52 +00:00
{_target isKindOf "AllVehicles"} ||
{_target getVariable [QGVAR(jerryCan), false]}) exitWith {};
2015-08-21 20:43:45 +00:00
_target setVariable [QGVAR(jerryCan), true];
_target setVariable [QGVAR(source), _target];
Refuel - Added ability to refuel fuel sources (#8981) * Simplify main fuel loop * Remove unecessary action macro * Add container refueling * Fuel counter behaviour is now consistent for both limited and unlimited fuel sources * Update maxFuel and refuelContainer whenever fueling begins * Update maxFuel and refuelContainer whenever fueling begins * Prevent loading of fuel sources into cargo when they have a nozzle connected to them * Added action to check how much fuel is left in a jerry can * Prevent jerry cans from being picked up if they have a nozzle connected to them * Added function to check if a nozzle can be connected to an object * Prevent fuel sources which have their nozzle deployed from being loaded * Compute both tank volumes inside of refuel instead of durring turn on * Didn't mean to delete these * Allow for user defined fuel capacities * Handle more edge cases with infinite fuel sources * Refuel - Prevent fuel sources from being dragged while they're refueling other things * Refuel - Added flow rate multiplier for refueling fuel sources * Refuel - Use FUNC instead of DFUNC for nozzle actions * Refuel - getCapacity should return REFUEL_DISABLED_FUEL instead of 0 when argument is not a fuel source * Refuel - Correctly reset fuel counter when fueling a new target * Refuel - Implemented all suggested changes * Refuel - Added newlines to end of files * Refuel - Added missing newline at end of XEH_PREP * Only setFuel once per jerry can creation Co-authored-by: PabstMirror <pabstmirror@gmail.com> * Calling getFuel will initialize the fuel source * Refuel - Add newline to end of file --------- Co-authored-by: BaerMitUmlaut <baermitumlaut@users.noreply.github.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2023-02-17 02:06:11 +00:00
_target setVariable [QGVAR(capacity), _fuelAmount];
if (isServer) then {
[_target, _fuelAmount] call FUNC(setFuel); // has global effects
2023-02-18 04:19:31 +00:00
[QGVAR(jerryCanInitalized), [_target]] call CBA_fnc_globalevent;
};
Refuel - Added ability to refuel fuel sources (#8981) * Simplify main fuel loop * Remove unecessary action macro * Add container refueling * Fuel counter behaviour is now consistent for both limited and unlimited fuel sources * Update maxFuel and refuelContainer whenever fueling begins * Update maxFuel and refuelContainer whenever fueling begins * Prevent loading of fuel sources into cargo when they have a nozzle connected to them * Added action to check how much fuel is left in a jerry can * Prevent jerry cans from being picked up if they have a nozzle connected to them * Added function to check if a nozzle can be connected to an object * Prevent fuel sources which have their nozzle deployed from being loaded * Compute both tank volumes inside of refuel instead of durring turn on * Didn't mean to delete these * Allow for user defined fuel capacities * Handle more edge cases with infinite fuel sources * Refuel - Prevent fuel sources from being dragged while they're refueling other things * Refuel - Added flow rate multiplier for refueling fuel sources * Refuel - Use FUNC instead of DFUNC for nozzle actions * Refuel - getCapacity should return REFUEL_DISABLED_FUEL instead of 0 when argument is not a fuel source * Refuel - Correctly reset fuel counter when fueling a new target * Refuel - Implemented all suggested changes * Refuel - Added newlines to end of files * Refuel - Added missing newline at end of XEH_PREP * Only setFuel once per jerry can creation Co-authored-by: PabstMirror <pabstmirror@gmail.com> * Calling getFuel will initialize the fuel source * Refuel - Add newline to end of file --------- Co-authored-by: BaerMitUmlaut <baermitumlaut@users.noreply.github.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2023-02-17 02:06:11 +00:00
2015-12-21 16:54:52 +00:00
// Main Action
private _action = [QGVAR(Refuel),
2015-12-21 16:54:52 +00:00
localize LSTRING(Refuel),
2016-04-08 18:34:50 +00:00
QPATHTOF(ui\icon_refuel_interact.paa),
2015-12-21 16:54:52 +00:00
{},
{true},
{},
[],
[0, 0, 0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction);
[_target, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToObject);
2015-12-21 16:54:52 +00:00
2015-08-21 20:43:45 +00:00
// Add pickup
_action = [QGVAR(PickUpNozzle),
localize LSTRING(TakeFuelCanister),
2016-04-08 18:34:50 +00:00
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(takeNozzle)},
2015-08-21 20:43:45 +00:00
{[_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);
2015-08-21 20:43:45 +00:00
// Add turnOn
_action = [QGVAR(TurnOn),
localize LSTRING(TurnOn),
2016-04-08 18:34:50 +00:00
QPATHTOF(ui\icon_refuel_interact.paa),
2015-08-21 20:43:45 +00:00
{[_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);
2015-08-21 20:43:45 +00:00
Refuel - Added ability to refuel fuel sources (#8981) * Simplify main fuel loop * Remove unecessary action macro * Add container refueling * Fuel counter behaviour is now consistent for both limited and unlimited fuel sources * Update maxFuel and refuelContainer whenever fueling begins * Update maxFuel and refuelContainer whenever fueling begins * Prevent loading of fuel sources into cargo when they have a nozzle connected to them * Added action to check how much fuel is left in a jerry can * Prevent jerry cans from being picked up if they have a nozzle connected to them * Added function to check if a nozzle can be connected to an object * Prevent fuel sources which have their nozzle deployed from being loaded * Compute both tank volumes inside of refuel instead of durring turn on * Didn't mean to delete these * Allow for user defined fuel capacities * Handle more edge cases with infinite fuel sources * Refuel - Prevent fuel sources from being dragged while they're refueling other things * Refuel - Added flow rate multiplier for refueling fuel sources * Refuel - Use FUNC instead of DFUNC for nozzle actions * Refuel - getCapacity should return REFUEL_DISABLED_FUEL instead of 0 when argument is not a fuel source * Refuel - Correctly reset fuel counter when fueling a new target * Refuel - Implemented all suggested changes * Refuel - Added newlines to end of files * Refuel - Added missing newline at end of XEH_PREP * Only setFuel once per jerry can creation Co-authored-by: PabstMirror <pabstmirror@gmail.com> * Calling getFuel will initialize the fuel source * Refuel - Add newline to end of file --------- Co-authored-by: BaerMitUmlaut <baermitumlaut@users.noreply.github.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2023-02-17 02:06:11 +00:00
// 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);
Refuel - Added ability to refuel fuel sources (#8981) * Simplify main fuel loop * Remove unecessary action macro * Add container refueling * Fuel counter behaviour is now consistent for both limited and unlimited fuel sources * Update maxFuel and refuelContainer whenever fueling begins * Update maxFuel and refuelContainer whenever fueling begins * Prevent loading of fuel sources into cargo when they have a nozzle connected to them * Added action to check how much fuel is left in a jerry can * Prevent jerry cans from being picked up if they have a nozzle connected to them * Added function to check if a nozzle can be connected to an object * Prevent fuel sources which have their nozzle deployed from being loaded * Compute both tank volumes inside of refuel instead of durring turn on * Didn't mean to delete these * Allow for user defined fuel capacities * Handle more edge cases with infinite fuel sources * Refuel - Prevent fuel sources from being dragged while they're refueling other things * Refuel - Added flow rate multiplier for refueling fuel sources * Refuel - Use FUNC instead of DFUNC for nozzle actions * Refuel - getCapacity should return REFUEL_DISABLED_FUEL instead of 0 when argument is not a fuel source * Refuel - Correctly reset fuel counter when fueling a new target * Refuel - Implemented all suggested changes * Refuel - Added newlines to end of files * Refuel - Added missing newline at end of XEH_PREP * Only setFuel once per jerry can creation Co-authored-by: PabstMirror <pabstmirror@gmail.com> * Calling getFuel will initialize the fuel source * Refuel - Add newline to end of file --------- Co-authored-by: BaerMitUmlaut <baermitumlaut@users.noreply.github.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2023-02-17 02:06:11 +00:00
[_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);
Refuel - Added ability to refuel fuel sources (#8981) * Simplify main fuel loop * Remove unecessary action macro * Add container refueling * Fuel counter behaviour is now consistent for both limited and unlimited fuel sources * Update maxFuel and refuelContainer whenever fueling begins * Update maxFuel and refuelContainer whenever fueling begins * Prevent loading of fuel sources into cargo when they have a nozzle connected to them * Added action to check how much fuel is left in a jerry can * Prevent jerry cans from being picked up if they have a nozzle connected to them * Added function to check if a nozzle can be connected to an object * Prevent fuel sources which have their nozzle deployed from being loaded * Compute both tank volumes inside of refuel instead of durring turn on * Didn't mean to delete these * Allow for user defined fuel capacities * Handle more edge cases with infinite fuel sources * Refuel - Prevent fuel sources from being dragged while they're refueling other things * Refuel - Added flow rate multiplier for refueling fuel sources * Refuel - Use FUNC instead of DFUNC for nozzle actions * Refuel - getCapacity should return REFUEL_DISABLED_FUEL instead of 0 when argument is not a fuel source * Refuel - Correctly reset fuel counter when fueling a new target * Refuel - Implemented all suggested changes * Refuel - Added newlines to end of files * Refuel - Added missing newline at end of XEH_PREP * Only setFuel once per jerry can creation Co-authored-by: PabstMirror <pabstmirror@gmail.com> * Calling getFuel will initialize the fuel source * Refuel - Add newline to end of file --------- Co-authored-by: BaerMitUmlaut <baermitumlaut@users.noreply.github.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2023-02-17 02:06:11 +00:00
[_target, 0, ["ACE_MainActions", QGVAR(Refuel)], _action] call EFUNC(interact_menu,addActionToObject);
2015-08-21 20:43:45 +00:00
// Add turnOff
_action = [QGVAR(TurnOff),
localize LSTRING(TurnOff),
2016-04-08 18:34:50 +00:00
QPATHTOF(ui\icon_refuel_interact.paa),
2015-08-21 20:43:45 +00:00
{[_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);
2015-08-21 20:43:45 +00:00
// Add disconnect
_action = [QGVAR(Disconnect),
localize LSTRING(DisconnectFuelCanister),
2016-04-08 18:34:50 +00:00
QPATHTOF(ui\icon_refuel_interact.paa),
2015-08-21 20:43:45 +00:00
{[_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);