2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2016-08-22 13:09:08 +00:00
|
|
|
/*
|
|
|
|
* Author: PabstMirror, Jonpas
|
|
|
|
* When interact_menu starts rendering (from "interact_keyDown" event).
|
|
|
|
* Add pick up helpers to all nearby throwables and keep setting them to their position (setVariable and attachTo does not work on CfgAmmo).
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
2016-08-22 13:09:08 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2016-09-02 23:39:34 +00:00
|
|
|
* call ace_advanced_throwing_fnc_renderPickUpInteraction
|
2016-08-22 13:09:08 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
[{
|
|
|
|
params ["_args", "_idPFH"];
|
|
|
|
_args params ["_setPosition", "_addedPickUpHelpers", "_throwablesHelped", "_nearThrowables"];
|
|
|
|
|
|
|
|
// isNull is necessarry to prevent rare error when ending mission with interact key down
|
|
|
|
if (EGVAR(interact_menu,keyDown) && {!isNull ACE_player}) then {
|
2016-09-05 18:23:03 +00:00
|
|
|
// Rescan when player moved >5 meters from last pos, nearObjects can be costly with a lot of objects around
|
2016-08-22 13:09:08 +00:00
|
|
|
if ((getPosASL ACE_player) distance _setPosition > 5) then {
|
2016-09-05 18:23:03 +00:00
|
|
|
// Grenades inherit from GrenadeHand, IR throwbles from IRStrobeBase, IR Chemlights are special snowflakes
|
|
|
|
// nearEntities does not see throwables
|
2016-09-02 12:57:20 +00:00
|
|
|
_nearThrowables = ACE_player nearObjects ["GrenadeHand", PICK_UP_DISTANCE];
|
2016-09-05 18:23:03 +00:00
|
|
|
_nearThrowables append (ACE_player nearObjects ["IRStrobeBase", PICK_UP_DISTANCE]);
|
2016-09-02 12:57:20 +00:00
|
|
|
_nearThrowables append (ACE_player nearObjects ["ACE_Chemlight_IR_Dummy", PICK_UP_DISTANCE]);
|
2016-08-22 13:09:08 +00:00
|
|
|
|
|
|
|
{
|
2016-09-05 18:23:03 +00:00
|
|
|
if (!(_x in _throwablesHelped) &&
|
|
|
|
{!(_x isKindOf "SmokeShellArty")} && {!(_x isKindOf "G_40mm_Smoke")} && // All smokes inherit from "GrenadeHand" >> "SmokeShell"
|
|
|
|
{GVAR(enablePickUpAttached) || {!GVAR(enablePickUpAttached) && {isNull (attachedTo _x)}}}
|
|
|
|
) then {
|
2016-09-02 12:57:20 +00:00
|
|
|
TRACE_2("Making PickUp Helper",_x,typeOf _x);
|
|
|
|
private _pickUpHelper = QGVAR(pickUpHelper) createVehicleLocal [0, 0, 0];
|
2016-08-22 13:09:08 +00:00
|
|
|
|
2016-09-02 12:57:20 +00:00
|
|
|
_pickUpHelper attachTo [_x, [0, 0, 0]];
|
|
|
|
_pickUpHelper setVariable [QGVAR(throwable), _x];
|
2016-08-22 13:09:08 +00:00
|
|
|
|
2016-09-02 12:57:20 +00:00
|
|
|
_addedPickUpHelpers pushBack _pickUpHelper;
|
|
|
|
_throwablesHelped pushBack _x;
|
|
|
|
};
|
|
|
|
nil
|
2016-08-22 13:09:08 +00:00
|
|
|
} count _nearThrowables;
|
|
|
|
|
|
|
|
_args set [0, getPosASL ACE_player];
|
|
|
|
_args set [3, _nearThrowables];
|
|
|
|
};
|
|
|
|
|
2016-09-02 12:57:20 +00:00
|
|
|
// Make sure helper is on correct location as it will not automatically move
|
|
|
|
// attachTo is not supported with CfgAmmo, it is only used to get location
|
2016-08-22 13:09:08 +00:00
|
|
|
{
|
|
|
|
// Only handling with attachTo works nicely
|
|
|
|
_x attachTo [_x getVariable [QGVAR(throwable), objNull], [0, 0, 0]];
|
2016-09-02 12:57:20 +00:00
|
|
|
nil
|
2016-08-22 13:09:08 +00:00
|
|
|
} count _addedPickUpHelpers;
|
|
|
|
} else {
|
|
|
|
TRACE_1("Cleaning Pick Up Helpers",count _addedPickUpHelpers);
|
|
|
|
{deleteVehicle _x} count _addedPickUpHelpers;
|
|
|
|
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
|
|
|
};
|
|
|
|
}, 0, [(getPosASL ACE_player) vectorAdd [-100, 0, 0], [], [], []]] call CBA_fnc_addPerFrameHandler;
|