2015-05-27 19:09:06 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror
|
|
|
|
* When interact_menu starts rendering (from "interact_keyDown" event)
|
|
|
|
* Add defuse helpers to all nearby mines
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* Interact Menu Type (0 - world, 1 - self) <NUMBER>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-15 19:35:33 +00:00
|
|
|
params ["_interactionType"];
|
|
|
|
TRACE_1("params",_interactionType);
|
2015-05-27 19:09:06 +00:00
|
|
|
|
|
|
|
//Ignore self-interaction menu
|
|
|
|
if (_interactionType != 0) exitWith {};
|
|
|
|
//Ignore while mounted:
|
|
|
|
if ((vehicle ACE_player) != ACE_player) exitWith {};
|
|
|
|
//Ignore if we don't have defuse kit
|
|
|
|
if (!("ACE_DefusalKit" in (items ACE_player))) exitWith {};
|
|
|
|
|
|
|
|
[{
|
2015-08-15 19:35:33 +00:00
|
|
|
params ["_args", "_pfID"];
|
|
|
|
_args params ["_setPosition", "_addedDefuseHelpers", "_minesHelped"];
|
2015-05-27 19:09:06 +00:00
|
|
|
|
|
|
|
if (!EGVAR(interact_menu,keyDown)) then {
|
|
|
|
TRACE_1("Cleaning Defuse Helpers",(count _addedDefuseHelpers));
|
|
|
|
{deleteVehicle _x;} forEach _addedDefuseHelpers;
|
|
|
|
[_pfID] call CBA_fnc_removePerFrameHandler;
|
|
|
|
} else {
|
|
|
|
// Prevent Rare Error when ending mission with interact key down:
|
|
|
|
if (isNull ace_player) exitWith {};
|
|
|
|
|
|
|
|
//If player moved >5 meters from last pos, then rescan
|
|
|
|
if (((getPosASL ace_player) distance _setPosition) > 5) then {
|
|
|
|
{
|
2017-10-15 11:13:16 +00:00
|
|
|
if (((_x distance ACE_player) < 15) && {!(_x in _minesHelped)} && {(getModelInfo _x) select 0 != "empty.p3d"}) then {
|
2015-12-30 08:11:57 +00:00
|
|
|
|
|
|
|
private _config = configFile >> "CfgAmmo" >> typeOf _x;
|
2017-06-09 17:52:55 +00:00
|
|
|
private _size = getNumber (_config >> QGVAR(size));
|
|
|
|
TRACE_3("Making Defuse Helper",(_x),(typeOf _x),(_size == 1));
|
2017-10-10 14:39:59 +00:00
|
|
|
private _defuseHelper = objNull;
|
2017-06-09 17:52:55 +00:00
|
|
|
if (_size == 1) then {
|
|
|
|
_defuseHelper = "ACE_DefuseObject_Large" createVehicleLocal (getPos _x);
|
|
|
|
} else {
|
|
|
|
_defuseHelper = "ACE_DefuseObject" createVehicleLocal (getPos _x);
|
|
|
|
};
|
2015-12-30 08:11:57 +00:00
|
|
|
|
|
|
|
private _defuseObjectPosition = getArray (_config >> QGVAR(defuseObjectPosition));
|
|
|
|
if (_defuseObjectPosition isEqualTo []) then {
|
|
|
|
_defuseObjectPosition = [0,0,0];
|
|
|
|
};
|
|
|
|
|
|
|
|
TRACE_1("DefuseObjectPosition",(_defuseObjectPosition));
|
|
|
|
|
|
|
|
_defuseHelper attachTo [_x, _defuseObjectPosition];
|
2015-05-27 19:09:06 +00:00
|
|
|
_defuseHelper setVariable [QGVAR(Explosive),_x];
|
|
|
|
_addedDefuseHelpers pushBack _defuseHelper;
|
|
|
|
_minesHelped pushBack _x;
|
|
|
|
};
|
|
|
|
} forEach allMines;
|
|
|
|
_args set [0, (getPosASL ace_player)];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}, 0.5, [((getPosASL ace_player) vectorAdd [-100,0,0]), [], []]] call CBA_fnc_addPerFrameHandler;
|