Fix error, Set disabled collision objects to object variable

This commit is contained in:
jonpas 2016-10-29 21:31:54 +02:00
parent 8bfcb5a1b1
commit c08d15151e
3 changed files with 10 additions and 9 deletions

View File

@ -67,7 +67,7 @@ if (_target isKindOf "CAManBase") then {
};
// check everything
[FUNC(carryObjectPFH), 0.5, [_unit, _target, CBA_missionTime, []]] call CBA_fnc_addPerFrameHandler;
[FUNC(carryObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;
// reset current dragging height.
GVAR(currentHeightChange) = 0;

View File

@ -7,14 +7,13 @@
* 0: Unit <OBJECT>
* 1: Target <OBJECT>
* 2: Start time <NUMBER>
* 3: Disabled Collision Objects <ARRAY> (empty for in-PFH changes)
* 1: PFEH Id <NUMBER>
*
* Return Value:
* None
*
* Example:
* [[player, target, []], 20] call ace_dragging_fnc_carryObjectPFH;
* [[player, target], 20] call ace_dragging_fnc_carryObjectPFH;
*
* Public: No
*/
@ -25,7 +24,7 @@
#endif
params ["_args", "_idPFH"];
_args params ["_unit","_target", "_startTime", "_disabledCollisionObjects"];
_args params ["_unit","_target", "_startTime"];
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {
TRACE_2("carry false",_unit,_target);
@ -40,13 +39,15 @@ if (!alive _target || {_unit distance _target > 10}) then {
//so wait a full second to exit if out of range (this is critical as we would otherwise detach and set it's pos to weird pos)
TRACE_3("ignoring bad distance at start",_unit distance _target,_startTime,CBA_missionTime);
};
[_unit, _target, _disabledCollisionObjects] call FUNC(dropObject_carry);
[_unit, _target] call FUNC(dropObject_carry);
[_idPFH] call CBA_fnc_removePerFrameHandler;
};
// Disable collision with nearby players
private _disabledCollisionObjects = _target getVariable [QGVAR(disabledCollisionObjects), []];
TRACE_1("Disable collision objects",_disabledCollisionObjects);
private _nearUnits = _target nearObjects ["CAManBase", DISABLE_COLLISION_DISTANCE];
{
if !(_x in _disabledCollisionObjects) then {
@ -54,6 +55,7 @@ private _nearUnits = _target nearObjects ["CAManBase", DISABLE_COLLISION_DISTANC
_target disableCollisionWith _x;
_disabledCollisionObjects pushBack _x;
};
false
} count _nearUnits;
_disabledCollisionObjects = _disabledCollisionObjects select {
@ -66,4 +68,4 @@ _disabledCollisionObjects = _disabledCollisionObjects select {
};
};
_args set [3, _disabledCollisionObjects];
_target setVariable [QGVAR(disabledCollisionObjects), _disabledCollisionObjects];

View File

@ -5,7 +5,6 @@
* Arguments:
* 0: Unit that carries the other object <OBJECT>
* 1: Carried object to drop <OBJECT>
* 2: Disabled Collision Objects <ARRAY>
*
* Return Value:
* None
@ -17,7 +16,7 @@
*/
#include "script_component.hpp"
params ["_unit", "_target", "_disabledCollisionObjects"];
params ["_unit", "_target"];
TRACE_1("params",_this);
// remove drop action
@ -80,4 +79,4 @@ if (_target getVariable [QGVAR(isUAV), false]) then {
// Reenable collision with nearby objects
{
_target enableCollisionWith _x;
} forEach _disabledCollisionObjects;
} forEach (_target getVariable [QGVAR(disabledCollisionObjects), []]);