Fix Advanced Throwing IR Chemlight and in-hand pick up (#4313)

* Fix IR Chemlights pick up

* Fix attached throwable pick up interaction condition

* Fix in hand pick up locality
This commit is contained in:
jonpas 2016-09-02 14:57:20 +02:00 committed by GitHub
parent c4d2383005
commit d3ee125d5e
5 changed files with 34 additions and 16 deletions

View File

@ -79,7 +79,8 @@ reverse _pathData;
{
_x params ["_col", "_newTrajAGL", "_iDim"];
drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_1_ca.paa", _col, _newTrajAGL, _iDim, _iDim, 0, "", 2];
#ifdef DEBUG_MODE_FULL
#ifdef DRAW_THROW_PATH
drawIcon3D ["", _col, _newTrajAGL, _iDim, _iDim, 0, str (ACE_player distance _newTrajAGL), 2, 0.05, "RobotoCondensed"];
#endif
} forEach _pathData;

View File

@ -88,6 +88,11 @@ if (isNull _activeThrowable) exitWith {
[ACE_player, "No active throwable (explosion in hand)"] call FUNC(exitThrowMode);
};
// Exit if locality changed (someone took the throwable from hand)
if (!local _activeThrowable && {ACE_player getVariable [QGVAR(localityChanged), true]}) exitWith {
[ACE_player, "Throwable locality changed"] call FUNC(exitThrowMode);
};
// Set position
private _posHeadRel = ACE_player selectionPosition "head";

View File

@ -41,6 +41,15 @@ if (!isNull _attachedTo) then {
// Change locality for manipulation (some commands require local object, such as setVelocity)
if (!local _activeThrowable) then {
["ace_setOwner", [_activeThrowable, CBA_clientID]] call CBA_fnc_serverEvent;
// Mark when it's safe to exit throw mode (locality change has delay)
_unit setVariable [QGVAR(localityChanged), false];
[{
// Becomes local or times out
local (_this select 0) || {(_this select 1) + 5 < CBA_missionTime}
}, {
(_this select 2) setVariable [QGVAR(localityChanged), true];
}, [_activeThrowable, CBA_missionTime, _unit]] call CBA_fnc_waitUntilAndExecute;
};
// Invoke listenable event

View File

@ -24,13 +24,13 @@
if (EGVAR(interact_menu,keyDown) && {!isNull ACE_player}) then {
// Rescan when player moved >5 meters from last pos, nearObjects is costly
if ((getPosASL ACE_player) distance _setPosition > 5) then {
// IR throwbles inherit from GrenadeCore, others from GrenadeHand
_nearThrowables = ACE_player nearObjects ["GrenadeHand", 10];
_nearThrowables append (ACE_player nearObjects ["GrenadeCore", 10]);
// IR throwbles inherit from GrenadeCore, others from GrenadeHand, IR Chemlights are special snowflakes
_nearThrowables = ACE_player nearObjects ["GrenadeHand", PICK_UP_DISTANCE];
_nearThrowables append (ACE_player nearObjects ["GrenadeCore", PICK_UP_DISTANCE]);
_nearThrowables append (ACE_player nearObjects ["ACE_Chemlight_IR_Dummy", PICK_UP_DISTANCE]);
{
if (_x in _throwablesHelped) exitWith {};
if (!(_x in _throwablesHelped) && {GVAR(enablePickUpAttached) || {!GVAR(enablePickUpAttached) && {isNull (attachedTo _x)}}}) then {
TRACE_2("Making PickUp Helper",_x,typeOf _x);
private _pickUpHelper = QGVAR(pickUpHelper) createVehicleLocal [0, 0, 0];
@ -39,19 +39,20 @@
_addedPickUpHelpers pushBack _pickUpHelper;
_throwablesHelped pushBack _x;
true
};
nil
} count _nearThrowables;
_args set [0, getPosASL ACE_player];
_args set [3, _nearThrowables];
};
// 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
{
if (!GVAR(enablePickUpAttached) && {!isNull (attachedTo _x)}) exitWith {};
// Only handling with attachTo works nicely
_x attachTo [_x getVariable [QGVAR(throwable), objNull], [0, 0, 0]];
true
nil
} count _addedPickUpHelpers;
} else {
TRACE_1("Cleaning Pick Up Helpers",count _addedPickUpHelpers);

View File

@ -27,3 +27,5 @@
#define THROW_TYPE_DEFAULT "normal"
#define THROW_SPEED_DEFAULT 18
#define DROP_DISTANCE_DEFAULT 0.2
#define PICK_UP_DISTANCE 10