2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-03-10 21:01:46 +00:00
|
|
|
/*
|
2018-07-13 16:30:13 +00:00
|
|
|
* Author: PabstMirror, mharis001
|
|
|
|
* Dynamically adds "Cut Fence" actions to nearby fences when interact_menu is opened.
|
|
|
|
* Called by the "ace_interactMenuOpened" event.
|
2015-03-10 21:01:46 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2018-07-13 16:30:13 +00:00
|
|
|
* Interact Menu Type (0 - World, 1 - Self) <NUMBER>
|
2015-03-10 21:01:46 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
2015-03-10 21:01:46 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2015-03-11 17:45:01 +00:00
|
|
|
* [0] call ace_logistics_wirecutter_fnc_interactEH
|
2015-03-10 21:01:46 +00:00
|
|
|
*
|
2018-07-13 16:30:13 +00:00
|
|
|
* Public: No
|
2015-03-10 21:01:46 +00:00
|
|
|
*/
|
|
|
|
|
2015-08-23 23:39:08 +00:00
|
|
|
params ["_interactionType"];
|
2015-03-11 17:45:01 +00:00
|
|
|
|
2018-07-13 16:30:13 +00:00
|
|
|
// Ignore self-interaction menu or mounted vehicle interaction
|
|
|
|
// For performance reasons only add PFH if player has wirecutter item
|
|
|
|
// If player somehow gets a wirecutter during keyDown, they will just have to reopen menu
|
|
|
|
if (
|
|
|
|
_interactionType != 0
|
|
|
|
|| {vehicle ACE_player != ACE_player}
|
2018-07-27 17:26:26 +00:00
|
|
|
|| {!HAS_WIRECUTTER(ACE_player)}
|
2018-07-13 16:30:13 +00:00
|
|
|
) exitWith {};
|
2015-03-10 21:01:46 +00:00
|
|
|
|
2018-07-13 16:30:13 +00:00
|
|
|
TRACE_1("Starting wirecuter interact PFH",_interactionType);
|
2015-08-24 03:55:43 +00:00
|
|
|
|
2015-03-10 21:01:46 +00:00
|
|
|
[{
|
2018-07-13 16:30:13 +00:00
|
|
|
BEGIN_COUNTER(interactEH);
|
|
|
|
params ["_args", "_pfhID"];
|
2015-08-23 23:39:08 +00:00
|
|
|
_args params ["_setPosition", "_addedHelpers", "_fencesHelped"];
|
2015-03-10 21:01:46 +00:00
|
|
|
|
|
|
|
if (!EGVAR(interact_menu,keyDown)) then {
|
2018-07-13 16:30:13 +00:00
|
|
|
{deleteVehicle _x} forEach _addedHelpers;
|
|
|
|
[_pfhID] call CBA_fnc_removePerFrameHandler;
|
2015-03-10 21:01:46 +00:00
|
|
|
} else {
|
2018-07-13 16:30:13 +00:00
|
|
|
// Prevent rare error when ending mission with interact key down
|
|
|
|
if (isNull ACE_player) exitWith {};
|
2015-03-10 21:01:46 +00:00
|
|
|
|
2018-07-13 16:30:13 +00:00
|
|
|
// Rescan if player has moved more than 5 meters from last position
|
|
|
|
if (getPosASL ACE_player distanceSqr _setPosition > 25) then {
|
2017-10-10 14:39:59 +00:00
|
|
|
private _fncStatement = {
|
2015-08-23 23:39:08 +00:00
|
|
|
params ["", "_player", "_attachedFence"];
|
2018-07-13 16:30:13 +00:00
|
|
|
|
2015-03-29 17:08:01 +00:00
|
|
|
[_player, _attachedFence] call FUNC(cutDownFence);
|
2015-03-10 21:01:46 +00:00
|
|
|
};
|
2017-10-10 14:39:59 +00:00
|
|
|
private _fncCondition = {
|
2016-06-15 00:32:30 +00:00
|
|
|
params ["_helper", "_player", "_attachedFence"];
|
2015-03-10 21:01:46 +00:00
|
|
|
|
2018-07-13 16:30:13 +00:00
|
|
|
!isNull _attachedFence
|
|
|
|
&& {damage _attachedFence < 1}
|
2018-07-27 17:26:26 +00:00
|
|
|
&& {HAS_WIRECUTTER(_player)}
|
2018-07-13 16:30:13 +00:00
|
|
|
&& {[_player, _attachedFence, ["isNotSwimming"]] call EFUNC(common,canInteractWith)}
|
|
|
|
&& {
|
|
|
|
// Custom LOS check for fence
|
2021-10-10 13:37:05 +00:00
|
|
|
private _headPos = _player modelToWorldVisualWorld (_player selectionPosition "pilot");
|
|
|
|
!lineIntersects [_headPos, _helper modelToWorldVisualWorld [0, 0, 1.25], _attachedFence, _player]
|
2018-07-13 16:30:13 +00:00
|
|
|
|| {!lineIntersects [_headPos, getPosASL _attachedFence, _attachedFence, _player]}
|
|
|
|
}
|
|
|
|
};
|
2015-03-10 21:01:46 +00:00
|
|
|
{
|
2018-07-13 16:30:13 +00:00
|
|
|
if (!(_x in _fencesHelped) && {_x call FUNC(isFence)}) then {
|
|
|
|
_fencesHelped pushBack _x;
|
|
|
|
private _helper = "ACE_LogicDummy" createVehicleLocal [0, 0, 0];
|
|
|
|
private _action = [QGVAR(helperCutFence), localize LSTRING(CutFence), QPATHTOF(ui\wirecutter_ca.paa), _fncStatement, _fncCondition, {}, _x, {[0, 0, 0]}, 5.5, [false, false, false, false, true]] call EFUNC(interact_menu,createAction);
|
|
|
|
[_helper, 0, [], _action] call EFUNC(interact_menu,addActionToObject);
|
|
|
|
_helper setPosASL (getPosASL _x vectorAdd [0, 0, 1.25]);
|
|
|
|
_addedHelpers pushBack _helper;
|
2015-03-10 21:01:46 +00:00
|
|
|
};
|
2018-07-13 16:30:13 +00:00
|
|
|
} forEach nearestObjects [ACE_player, [], 15];
|
2015-03-10 21:01:46 +00:00
|
|
|
|
2018-07-13 16:30:13 +00:00
|
|
|
_args set [0, getPosASL ACE_player];
|
2015-03-10 21:01:46 +00:00
|
|
|
};
|
|
|
|
};
|
2018-07-13 16:30:13 +00:00
|
|
|
END_COUNTER(interactEH);
|
|
|
|
}, 0.5, [getPosASL ACE_player vectorAdd [-100, 0, 0], [], []]] call CBA_fnc_addPerFrameHandler;
|