2015-03-10 21:01:46 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
|
|
|
* When interact_menu starts rendering (from "interact_keyDown" event)
|
|
|
|
*
|
|
|
|
* Arguments:
|
2015-03-11 17:45:01 +00:00
|
|
|
* Interact Menu Type (0 - world, 1 - self) <NUMBER>
|
2015-03-10 21:01:46 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Nothing
|
|
|
|
*
|
|
|
|
* Example:
|
2015-03-11 17:45:01 +00:00
|
|
|
* [0] call ace_logistics_wirecutter_fnc_interactEH
|
2015-03-10 21:01:46 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-23 23:39:08 +00:00
|
|
|
params ["_interactionType"];
|
2015-03-11 17:45:01 +00:00
|
|
|
|
2015-08-24 03:55:43 +00:00
|
|
|
//Ignore self-interaction menu or mounted vehicle interaction
|
|
|
|
if ((_interactionType != 0) || {(vehicle ACE_player) != ACE_player}) exitWith {};
|
2015-03-10 21:01:46 +00:00
|
|
|
|
|
|
|
//for performance only do stuff it they have a wirecutter item
|
|
|
|
//(if they somehow get one durring keydown they'll just have to reopen)
|
|
|
|
if (!("ACE_wirecutter" in (items ace_player))) exitWith {};
|
|
|
|
|
2015-08-24 03:55:43 +00:00
|
|
|
TRACE_1("Starting wire-cut action PFEH",_interactionType);
|
|
|
|
|
2015-03-10 21:01:46 +00:00
|
|
|
[{
|
2015-04-18 03:40:37 +00:00
|
|
|
private ["_fncStatement", "_attachedFence", "_fncCondition", "_helper", "_action"];
|
2015-08-23 23:39:08 +00:00
|
|
|
params ["_args", "_pfID"];
|
|
|
|
_args params ["_setPosition", "_addedHelpers", "_fencesHelped"];
|
2015-03-10 21:01:46 +00:00
|
|
|
|
|
|
|
if (!EGVAR(interact_menu,keyDown)) then {
|
2015-08-23 23:39:08 +00:00
|
|
|
{deleteVehicle _x; nil} count _addedHelpers;
|
2015-03-10 21:01:46 +00:00
|
|
|
[_pfID] call CBA_fnc_removePerFrameHandler;
|
|
|
|
} else {
|
2015-03-24 09:03:16 +00:00
|
|
|
// Prevent Rare Error when ending mission with interact key down:
|
|
|
|
if (isNull ace_player) exitWith {};
|
2015-04-15 23:32:47 +00:00
|
|
|
|
2015-03-24 09:03:16 +00:00
|
|
|
//If player moved >5 meters from last pos, then rescan
|
2015-03-10 21:01:46 +00:00
|
|
|
if (((getPosASL ace_player) distance _setPosition) > 5) then {
|
|
|
|
|
|
|
|
_fncStatement = {
|
2015-08-23 23:39:08 +00:00
|
|
|
params ["", "_player", "_attachedFence"];
|
2015-03-29 17:08:01 +00:00
|
|
|
[_player, _attachedFence] call FUNC(cutDownFence);
|
2015-03-10 21:01:46 +00:00
|
|
|
};
|
|
|
|
_fncCondition = {
|
2016-06-15 00:32:30 +00:00
|
|
|
params ["_helper", "_player", "_attachedFence"];
|
2015-08-23 23:39:08 +00:00
|
|
|
if (!([_player, _attachedFence, []] call EFUNC(common,canInteractWith))) exitWith {false};
|
2016-06-15 00:32:30 +00:00
|
|
|
((!isNull _attachedFence) && {(damage _attachedFence) < 1} && {("ACE_wirecutter" in (items _player))} && {
|
|
|
|
//Custom LOS check for fence
|
|
|
|
private _headPos = ACE_player modelToWorldVisual (ACE_player selectionPosition "pilot");
|
|
|
|
((!(lineIntersects [AGLtoASL _headPos, AGLtoASL (_helper modelToWorldVisual [0,0,1.25]), _attachedFence, ACE_player])) ||
|
|
|
|
{!(lineIntersects [AGLtoASL _headPos, getPosASL _attachedFence, _attachedFence, ACE_player])})
|
|
|
|
})
|
2015-03-10 21:01:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!(_x in _fencesHelped)) then {
|
|
|
|
if ([_x] call FUNC(isFence)) then {
|
|
|
|
_fencesHelped pushBack _x;
|
2015-08-23 23:39:08 +00:00
|
|
|
_helper = "ACE_LogicDummy" createVehicleLocal (getpos _x);
|
2016-06-15 00:32:30 +00:00
|
|
|
_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);
|
2015-03-29 17:08:01 +00:00
|
|
|
[_helper, 0, [],_action] call EFUNC(interact_menu,addActionToObject);
|
2015-03-10 21:01:46 +00:00
|
|
|
_helper setPosASL ((getPosASL _x) vectorAdd [0,0,1.25]);
|
|
|
|
_addedHelpers pushBack _helper;
|
|
|
|
};
|
|
|
|
};
|
2015-08-23 23:39:08 +00:00
|
|
|
nil
|
|
|
|
} count nearestObjects [ace_player, [], 15];
|
2015-03-10 21:01:46 +00:00
|
|
|
|
|
|
|
_args set [0, (getPosASL ace_player)];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}, 0.1, [((getPosASL ace_player) vectorAdd [-100,0,0]), [], []]] call CBA_fnc_addPerFrameHandler;
|