mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
8b53b4f0d0
Moved macros to function Fixed MP bugs Changed class history of nozzle
66 lines
2.4 KiB
Plaintext
66 lines
2.4 KiB
Plaintext
/*
|
|
* Author: GitHawk et.al.
|
|
* Connect a fuel nozzle.
|
|
* With code from ace_attach
|
|
*
|
|
* Arguments:
|
|
* 0: Unit <OBJECT>
|
|
* 1: Target <OBJECT>
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [player, tank] call ace_refuel_fnc_connectNozzle
|
|
*
|
|
* Public: No
|
|
*/
|
|
#include "script_component.hpp"
|
|
|
|
#define PLACE_WAITING -1
|
|
#define PLACE_CANCEL 0
|
|
#define PLACE_APPROVE 1
|
|
|
|
private ["_nozzle", "_actionID"];
|
|
params ["_unit", "_target"];
|
|
|
|
_nozzle = _unit getVariable [QGVAR(nozzle), objNull];
|
|
if (isNull _nozzle) exitWith {};
|
|
|
|
GVAR(placeAction) = PLACE_WAITING;
|
|
|
|
[{[localize LSTRING(Connect_Action), ""] call EFUNC(interaction,showMouseHint)}, []] call EFUNC(common,execNextFrame);
|
|
_unit setVariable [QGVAR(placeActionEH), [_unit, "DefaultAction", {true}, {GVAR(placeAction) = PLACE_APPROVE;}] call EFUNC(common,AddActionEventHandler)];
|
|
|
|
_actionID = _unit addAction [format ["<t color='#FF0000'>%1</t>", localize LSTRING(Cancel)], {GVAR(placeAction) = PLACE_CANCEL;}];
|
|
|
|
[{
|
|
private["_virtualPos", "_virtualPosASL", "_lineInterection"];
|
|
params ["_args","_pfID"];
|
|
_args params ["_unit", "_target", "_nozzle", "_actionID"];
|
|
|
|
_virtualPosASL = (eyePos _unit) vectorAdd (positionCameraToWorld [0,0,0.6]) vectorDiff (positionCameraToWorld [0,0,0]);
|
|
if (cameraView == "EXTERNAL") then {
|
|
_virtualPosASL = _virtualPosASL vectorAdd ((positionCameraToWorld [0.3,0,0]) vectorDiff (positionCameraToWorld [0,0,0]));
|
|
};
|
|
_virtualPos = _virtualPosASL call EFUNC(common,ASLToPosition);
|
|
_lineInterection = lineIntersects [eyePos ace_player, _virtualPosASL, ace_player];
|
|
|
|
//Don't allow placing in a bad position:
|
|
if (_lineInterection && {GVAR(placeAction) == PLACE_APPROVE}) then {GVAR(placeAction) = PLACE_WAITING;};
|
|
|
|
if ((GVAR(placeAction) != PLACE_WAITING) ||
|
|
{_unit != ace_player} ||
|
|
{!([_unit, _target, []] call EFUNC(common,canInteractWith))}) then {
|
|
|
|
[_pfID] call CBA_fnc_removePerFrameHandler;
|
|
[] call EFUNC(interaction,hideMouseHint);
|
|
[_unit, "DefaultAction", (_unit getVariable [QGVAR(placeActionEH), -1])] call EFUNC(common,removeActionEventHandler);
|
|
_unit removeAction _actionID;
|
|
|
|
if (GVAR(placeAction) == PLACE_APPROVE) then {
|
|
[_unit, _target, _virtualPos, _nozzle] call FUNC(ConnectNozzleAction);
|
|
};
|
|
}; // TODO add model like in attach/functions/fnc_attach
|
|
}, 0, [_unit, _target, _nozzle, _actionID] ] call cba_fnc_addPerFrameHandler;
|