2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-05-27 19:09:06 +00:00
|
|
|
/*
|
2018-07-13 17:04:55 +00:00
|
|
|
* Author: PabstMirror, mharis001
|
|
|
|
* Dynamically adds "Defuse" actions to nearby mines when interact_menu is opened.
|
|
|
|
* Called by the "ace_interactMenuOpened" event.
|
2015-05-27 19:09:06 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2018-07-13 17:04:55 +00:00
|
|
|
* Interact Menu Type (0 - World, 1 - Self) <NUMBER>
|
2015-05-27 19:09:06 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
2015-05-27 19:09:06 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [0] call ace_explosives_fnc_interactEH
|
|
|
|
*
|
2018-07-13 17:04:55 +00:00
|
|
|
* Public: No
|
2015-05-27 19:09:06 +00:00
|
|
|
*/
|
|
|
|
|
2015-08-15 19:35:33 +00:00
|
|
|
params ["_interactionType"];
|
2018-07-13 17:04:55 +00:00
|
|
|
TRACE_1("Explosives interactEH",_interactionType);
|
2015-05-27 19:09:06 +00:00
|
|
|
|
2018-07-13 17:04:55 +00:00
|
|
|
// Ignore self-interaction menu or mounted vehicle interaction
|
|
|
|
// For performance reasons only add PFH if player has a defusal kit
|
|
|
|
// If player somehow gets a defusal kit during keyDown, they will just have to reopen menu
|
|
|
|
if (
|
|
|
|
_interactionType != 0
|
|
|
|
|| {vehicle ACE_player != ACE_player}
|
2018-09-23 02:59:16 +00:00
|
|
|
|| {!("ACE_DefusalKit" in (ACE_player call EFUNC(common,uniqueItems)))}
|
2018-07-13 17:04:55 +00:00
|
|
|
) exitWith {};
|
2015-05-27 19:09:06 +00:00
|
|
|
|
|
|
|
[{
|
2018-07-13 17:04:55 +00:00
|
|
|
BEGIN_COUNTER(interactEH);
|
|
|
|
params ["_args", "_pfhID"];
|
|
|
|
_args params ["_setPosition", "_addedHelpers", "_minesHelped"];
|
2015-05-27 19:09:06 +00:00
|
|
|
|
|
|
|
if (!EGVAR(interact_menu,keyDown)) then {
|
2018-07-13 17:04:55 +00:00
|
|
|
TRACE_1("Cleaning defuse helpers",count _addedHelpers);
|
|
|
|
{deleteVehicle _x} forEach _addedHelpers;
|
|
|
|
[_pfhID] call CBA_fnc_removePerFrameHandler;
|
2015-05-27 19:09:06 +00:00
|
|
|
} else {
|
2018-09-23 02:59:16 +00:00
|
|
|
// Prevent Rare Error when ending mission with interact key down
|
2018-07-13 17:04:55 +00:00
|
|
|
private _player = ACE_player;
|
|
|
|
if (isNull _player) exitWith {};
|
|
|
|
private _playerPos = getPosASL _player;
|
2015-05-27 19:09:06 +00:00
|
|
|
|
2018-07-13 17:04:55 +00:00
|
|
|
// Rescan if player has moved more than 5 meters from last position
|
|
|
|
if (_playerPos distanceSqr _setPosition > 25) then {
|
|
|
|
private _cfgAmmo = configFile >> "CfgAmmo";
|
2015-05-27 19:09:06 +00:00
|
|
|
{
|
2021-10-11 20:49:27 +00:00
|
|
|
if (_x distanceSqr _player < 225 && {!(_x in _minesHelped)} && {!(_x in GVAR(excludedMines))} && {getModelInfo _x select 0 isNotEqualTo "empty.p3d"}) then {
|
2018-07-13 17:04:55 +00:00
|
|
|
private _config = _cfgAmmo >> typeOf _x;
|
2017-06-09 17:52:55 +00:00
|
|
|
private _size = getNumber (_config >> QGVAR(size));
|
2018-07-13 17:04:55 +00:00
|
|
|
private _defuseClass = ["ACE_DefuseObject", "ACE_DefuseObject_Large"] select (_size == 1);
|
|
|
|
private _defusePos = getArray (_config >> QGVAR(defuseObjectPosition));
|
|
|
|
if (_defusePos isEqualTo []) then {
|
|
|
|
_defusePos = [0, 0, 0];
|
2015-12-30 08:11:57 +00:00
|
|
|
};
|
|
|
|
|
2018-07-13 17:04:55 +00:00
|
|
|
TRACE_4("Creating defuse helper",_x,typeOf _x,_defuseClass,_defusePos);
|
|
|
|
private _helper = _defuseClass createVehicleLocal [0, 0, 0];
|
2015-12-30 08:11:57 +00:00
|
|
|
|
2018-07-13 17:04:55 +00:00
|
|
|
_helper attachTo [_x, _defusePos];
|
|
|
|
_helper setVariable [QGVAR(Explosive), _x];
|
|
|
|
_addedHelpers pushBack _helper;
|
2015-05-27 19:09:06 +00:00
|
|
|
_minesHelped pushBack _x;
|
|
|
|
};
|
|
|
|
} forEach allMines;
|
2018-07-13 17:04:55 +00:00
|
|
|
|
|
|
|
_args set [0, _playerPos];
|
2015-05-27 19:09:06 +00:00
|
|
|
};
|
|
|
|
};
|
2018-07-13 17:04:55 +00:00
|
|
|
END_COUNTER(interactEH);
|
|
|
|
}, 0.5, [getPosASL ACE_player vectorAdd [-100, 0, 0], [], []]] call CBA_fnc_addPerFrameHandler;
|